modern-canvas 0.4.18 → 0.4.20
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 +45 -26
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -4
- package/dist/index.mjs +45 -26
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2228,19 +2228,15 @@ class Renderer {
|
|
|
2228
2228
|
return related;
|
|
2229
2229
|
}
|
|
2230
2230
|
resize(width, height, updateStyle = true) {
|
|
2231
|
-
const viewWidth = Math.floor(width * this.pixelRatio);
|
|
2232
|
-
const viewHeight = Math.floor(height * this.pixelRatio);
|
|
2233
|
-
const screenWidth = viewWidth / this.pixelRatio;
|
|
2234
|
-
const screenHeight = viewHeight / this.pixelRatio;
|
|
2235
2231
|
if (this.view) {
|
|
2236
|
-
this.view.width =
|
|
2237
|
-
this.view.height =
|
|
2232
|
+
this.view.width = Math.floor(width * this.pixelRatio);
|
|
2233
|
+
this.view.height = Math.floor(height * this.pixelRatio);
|
|
2238
2234
|
}
|
|
2239
|
-
this.screen.width =
|
|
2240
|
-
this.screen.height =
|
|
2235
|
+
this.screen.width = width;
|
|
2236
|
+
this.screen.height = height;
|
|
2241
2237
|
if (updateStyle && this.view) {
|
|
2242
|
-
this.view.style.width = `${
|
|
2243
|
-
this.view.style.height = `${
|
|
2238
|
+
this.view.style.width = `${width}px`;
|
|
2239
|
+
this.view.style.height = `${height}px`;
|
|
2244
2240
|
}
|
|
2245
2241
|
}
|
|
2246
2242
|
}
|
|
@@ -5282,10 +5278,14 @@ class PixelsTexture extends Texture2D {
|
|
|
5282
5278
|
_updateProperty(key, value, oldValue, declaration) {
|
|
5283
5279
|
switch (key) {
|
|
5284
5280
|
case "width":
|
|
5285
|
-
this.source.width = Math.round(
|
|
5281
|
+
this.source.width = Math.round(this.width * this.pixelRatio);
|
|
5286
5282
|
break;
|
|
5287
5283
|
case "height":
|
|
5288
|
-
this.source.height = Math.round(
|
|
5284
|
+
this.source.height = Math.round(this.height * this.pixelRatio);
|
|
5285
|
+
break;
|
|
5286
|
+
case "pixelRatio":
|
|
5287
|
+
this.source.width = Math.round(this.width * this.pixelRatio);
|
|
5288
|
+
this.source.height = Math.round(this.height * this.pixelRatio);
|
|
5289
5289
|
break;
|
|
5290
5290
|
}
|
|
5291
5291
|
super._updateProperty(key, value, oldValue, declaration);
|
|
@@ -6208,9 +6208,9 @@ exports.Viewport = class Viewport extends exports.Node {
|
|
|
6208
6208
|
const { pixelRatio } = renderer;
|
|
6209
6209
|
this._framebuffers.forEach((framebuffer) => {
|
|
6210
6210
|
const texture = framebuffer.texture;
|
|
6211
|
-
texture.pixelRatio = pixelRatio;
|
|
6212
6211
|
texture.width = width;
|
|
6213
6212
|
texture.height = height;
|
|
6213
|
+
texture.pixelRatio = pixelRatio;
|
|
6214
6214
|
texture.upload(renderer);
|
|
6215
6215
|
});
|
|
6216
6216
|
return {
|
|
@@ -9790,6 +9790,7 @@ exports.Text2D = class Text2D extends TextureRect2D {
|
|
|
9790
9790
|
fonts;
|
|
9791
9791
|
texture = new CanvasTexture();
|
|
9792
9792
|
text = new modernText.Text();
|
|
9793
|
+
measureResult;
|
|
9793
9794
|
_subTextsCount = 0;
|
|
9794
9795
|
constructor(properties, children = []) {
|
|
9795
9796
|
super();
|
|
@@ -9823,7 +9824,17 @@ exports.Text2D = class Text2D extends TextureRect2D {
|
|
|
9823
9824
|
this.text.requestUpdate();
|
|
9824
9825
|
}
|
|
9825
9826
|
_updateStyleProperty(key, value, oldValue) {
|
|
9826
|
-
|
|
9827
|
+
switch (key) {
|
|
9828
|
+
case "left":
|
|
9829
|
+
case "top":
|
|
9830
|
+
case "width":
|
|
9831
|
+
case "height":
|
|
9832
|
+
this.requestRedraw();
|
|
9833
|
+
break;
|
|
9834
|
+
default:
|
|
9835
|
+
super._updateStyleProperty(key, value, oldValue);
|
|
9836
|
+
break;
|
|
9837
|
+
}
|
|
9827
9838
|
switch (key) {
|
|
9828
9839
|
case "width":
|
|
9829
9840
|
if (this.split) {
|
|
@@ -9845,10 +9856,9 @@ exports.Text2D = class Text2D extends TextureRect2D {
|
|
|
9845
9856
|
}
|
|
9846
9857
|
_updateSubTexts() {
|
|
9847
9858
|
const subTexts = this._getSubTexts();
|
|
9848
|
-
const result = this.measure();
|
|
9849
9859
|
let i = 0;
|
|
9850
9860
|
if (this.split) {
|
|
9851
|
-
|
|
9861
|
+
this.updateMeasure().measureResult?.paragraphs.forEach((p) => {
|
|
9852
9862
|
p.fragments.forEach((f) => {
|
|
9853
9863
|
f.characters.forEach((c) => {
|
|
9854
9864
|
const child = subTexts[i];
|
|
@@ -9864,21 +9874,26 @@ exports.Text2D = class Text2D extends TextureRect2D {
|
|
|
9864
9874
|
}
|
|
9865
9875
|
measure() {
|
|
9866
9876
|
this._updateText();
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
9877
|
+
return this.text.measure();
|
|
9878
|
+
}
|
|
9879
|
+
updateMeasure() {
|
|
9880
|
+
this.measureResult = this.measure();
|
|
9881
|
+
const textWidth = this.measureResult.boundingBox.width;
|
|
9882
|
+
const textHeight = this.measureResult.boundingBox.height;
|
|
9883
|
+
const { left, top, width, height = textHeight } = this.style;
|
|
9884
|
+
this.position.x = left + Math.min(0, ((width || textWidth) - textWidth) / 2);
|
|
9885
|
+
this.position.y = top + Math.min(0, ((height || textHeight) - textHeight) / 2);
|
|
9886
|
+
this.size.width = textWidth;
|
|
9887
|
+
this.size.height = textHeight;
|
|
9888
|
+
return this;
|
|
9873
9889
|
}
|
|
9874
9890
|
_updateSplit() {
|
|
9875
9891
|
if (this._subTextsCount) {
|
|
9876
9892
|
this.getChildren("front").forEach((child) => this.removeChild(child));
|
|
9877
9893
|
this._subTextsCount = 0;
|
|
9878
9894
|
}
|
|
9879
|
-
const result = this.measure();
|
|
9880
9895
|
if (this.split) {
|
|
9881
|
-
|
|
9896
|
+
this.measureResult?.paragraphs.forEach((p) => {
|
|
9882
9897
|
p.fragments.forEach((f) => {
|
|
9883
9898
|
f.characters.forEach((c) => {
|
|
9884
9899
|
this.appendChild(
|
|
@@ -9901,13 +9916,16 @@ exports.Text2D = class Text2D extends TextureRect2D {
|
|
|
9901
9916
|
});
|
|
9902
9917
|
}
|
|
9903
9918
|
}
|
|
9919
|
+
_redraw() {
|
|
9920
|
+
this.updateMeasure();
|
|
9921
|
+
return super._redraw();
|
|
9922
|
+
}
|
|
9904
9923
|
_drawContent() {
|
|
9905
9924
|
if (!this.split) {
|
|
9906
9925
|
const onText2DRender = this.getChildren()?.find((child) => "onText2DRender" in child)?.onText2DRender;
|
|
9907
9926
|
if (onText2DRender) {
|
|
9908
9927
|
onText2DRender();
|
|
9909
9928
|
} else {
|
|
9910
|
-
this._updateText();
|
|
9911
9929
|
this.text.render({
|
|
9912
9930
|
pixelRatio: this.texture.pixelRatio,
|
|
9913
9931
|
view: this.texture.source
|
|
@@ -13106,7 +13124,8 @@ class Engine extends SceneTree {
|
|
|
13106
13124
|
this.renderer.resize(width, height, updateCss);
|
|
13107
13125
|
this.root.width = width;
|
|
13108
13126
|
this.root.height = height;
|
|
13109
|
-
this.
|
|
13127
|
+
this.root.requestUpload();
|
|
13128
|
+
this.render();
|
|
13110
13129
|
return this;
|
|
13111
13130
|
}
|
|
13112
13131
|
nextTick() {
|
package/dist/index.d.cts
CHANGED
|
@@ -2132,6 +2132,7 @@ declare class Text2D extends TextureRect2D<CanvasTexture> {
|
|
|
2132
2132
|
fonts?: TextOptions['fonts'];
|
|
2133
2133
|
texture: CanvasTexture;
|
|
2134
2134
|
text: Text;
|
|
2135
|
+
measureResult?: MeasureResult;
|
|
2135
2136
|
protected _subTextsCount: number;
|
|
2136
2137
|
constructor(properties?: Partial<Text2DProperties>, children?: Node[]);
|
|
2137
2138
|
protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
|
|
@@ -2140,7 +2141,9 @@ declare class Text2D extends TextureRect2D<CanvasTexture> {
|
|
|
2140
2141
|
protected _getSubTexts(): Text2D[];
|
|
2141
2142
|
protected _updateSubTexts(): void;
|
|
2142
2143
|
measure(): MeasureResult;
|
|
2144
|
+
updateMeasure(): this;
|
|
2143
2145
|
protected _updateSplit(): void;
|
|
2146
|
+
protected _redraw(): CanvasBatchable[];
|
|
2144
2147
|
protected _drawContent(): void;
|
|
2145
2148
|
}
|
|
2146
2149
|
|
package/dist/index.d.mts
CHANGED
|
@@ -2132,6 +2132,7 @@ declare class Text2D extends TextureRect2D<CanvasTexture> {
|
|
|
2132
2132
|
fonts?: TextOptions['fonts'];
|
|
2133
2133
|
texture: CanvasTexture;
|
|
2134
2134
|
text: Text;
|
|
2135
|
+
measureResult?: MeasureResult;
|
|
2135
2136
|
protected _subTextsCount: number;
|
|
2136
2137
|
constructor(properties?: Partial<Text2DProperties>, children?: Node[]);
|
|
2137
2138
|
protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
|
|
@@ -2140,7 +2141,9 @@ declare class Text2D extends TextureRect2D<CanvasTexture> {
|
|
|
2140
2141
|
protected _getSubTexts(): Text2D[];
|
|
2141
2142
|
protected _updateSubTexts(): void;
|
|
2142
2143
|
measure(): MeasureResult;
|
|
2144
|
+
updateMeasure(): this;
|
|
2143
2145
|
protected _updateSplit(): void;
|
|
2146
|
+
protected _redraw(): CanvasBatchable[];
|
|
2144
2147
|
protected _drawContent(): void;
|
|
2145
2148
|
}
|
|
2146
2149
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2132,6 +2132,7 @@ declare class Text2D extends TextureRect2D<CanvasTexture> {
|
|
|
2132
2132
|
fonts?: TextOptions['fonts'];
|
|
2133
2133
|
texture: CanvasTexture;
|
|
2134
2134
|
text: Text;
|
|
2135
|
+
measureResult?: MeasureResult;
|
|
2135
2136
|
protected _subTextsCount: number;
|
|
2136
2137
|
constructor(properties?: Partial<Text2DProperties>, children?: Node[]);
|
|
2137
2138
|
protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
|
|
@@ -2140,7 +2141,9 @@ declare class Text2D extends TextureRect2D<CanvasTexture> {
|
|
|
2140
2141
|
protected _getSubTexts(): Text2D[];
|
|
2141
2142
|
protected _updateSubTexts(): void;
|
|
2142
2143
|
measure(): MeasureResult;
|
|
2144
|
+
updateMeasure(): this;
|
|
2143
2145
|
protected _updateSplit(): void;
|
|
2146
|
+
protected _redraw(): CanvasBatchable[];
|
|
2144
2147
|
protected _drawContent(): void;
|
|
2145
2148
|
}
|
|
2146
2149
|
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(u,$e){typeof exports=="object"&&typeof module<"u"?$e(exports):typeof define=="function"&&define.amd?define(["exports"],$e):(u=typeof globalThis<"u"?globalThis:u||self,$e(u.modernCanvas={}))})(this,function(u){"use strict";var qI=Object.defineProperty;var XI=(u,$e,Lt)=>$e in u?qI(u,$e,{enumerable:!0,configurable:!0,writable:!0,value:Lt}):u[$e]=Lt;var c=(u,$e,Lt)=>XI(u,typeof $e!="symbol"?$e+"":$e,Lt);var DA,cA;var $e=typeof document<"u"?document.currentScript:null;const Lt=Math.PI,et=Lt*2;let $l=0;function Fn(r){var A;return((A=r==null?void 0:r.__SPECTOR_Object_TAG)==null?void 0:A.id)??++$l}function es(r){return!(r&r-1)&&!!r}const eg=/([\w-]+)\((.+?)\)/g,tg=/[^,]+/g,Ag=/([-e.\d]+)(.*)/;function ts(r){return Array.isArray(r)?r.map(A=>({name:A.name,args:A.args.map(e=>({...e,normalizedIntValue:e.normalizedDefaultIntValue}))})):{...r,normalizedIntValue:r.normalizedDefaultIntValue}}function ri(r,A,e={}){const t=si(A,e);return t.length?t:Tn(r,A,e)}function si(r,A={}){const e=[];let t;for(;(t=eg.exec(r))!==null;){const[,i,s]=t;i&&e.push({name:i,args:ig(i,s,A)})}return e}function ig(r,A,e={}){const t=[];let i,s=0;for(;(i=tg.exec(A))!==null;)t.push(Tn(r,i[0],{...e,index:s++}));return t}function Tn(r,A,e={}){const{width:t=1,height:i=1,index:s=0}=e,n=A.match(Ag),o={unit:(n==null?void 0:n[2])??null,value:A,intValue:Number(n==null?void 0:n[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(r){case"scale":case"scaleX":case"scaleY":case"scale3d":o.normalizedDefaultIntValue=1;break}switch(o.unit){case"%":o.normalizedIntValue=o.intValue/100;break;case"rad":o.normalizedIntValue=o.intValue/et;break;case"deg":o.normalizedIntValue=o.intValue/360;break;case"px":switch(s){case 0:o.normalizedIntValue=o.intValue/t;break;case 1:o.normalizedIntValue=o.intValue/i;break}break;case"turn":case"em":case"rem":default:o.normalizedIntValue=o.intValue;break}return o}const Ln="WebGL2RenderingContext"in globalThis,Gn="ImageBitmap"in globalThis,On="ResizeObserver"in globalThis,xA="PointerEvent"in globalThis,Hn="WheelEvent"in globalThis,rg="MouseEvent"in globalThis,Gt="ontouchstart"in globalThis,Jn="onclick"in globalThis,As="createImageBitmap"in globalThis,is="AudioContext"in globalThis,rs="webkitAudioContext"in globalThis,ss="OfflineAudioContext"in globalThis,Kn="webkitOfflineAudioContext"in globalThis,Yn=is||rs,ni=typeof window<"u",ns=globalThis.devicePixelRatio||1,os=r=>r!==null&&typeof r=="object"&&r.nodeType===1,Wn=r=>os(r)&&r.tagName==="VIDEO",sg=r=>os(r)&&r.tagName==="IMG";function Vn(r){return typeof r=="object"&&r!==null&&r.nodeType===1&&r.tagName==="CANVAS"}function zn(r){return Ln&&r instanceof globalThis.WebGL2RenderingContext}function qn(){if(ni)return globalThis.document.createElement("canvas")}function Xn(r,A=globalThis.location){if(r.startsWith("data:"))return"";A=A||globalThis.location;const e=new URL(r,document.baseURI);return e.hostname!==A.hostname||e.port!==A.port||e.protocol!==A.protocol?"anonymous":""}function jn(r,A,e){e===null&&!A.startsWith("data:")?r.crossOrigin=Xn(A):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}class SA{constructor(){c(this,"_map",new WeakMap)}_toRaw(A){if(A&&typeof A=="object"){const e=A.__v_raw;e&&(A=this._toRaw(e))}return A}delete(A){return this._map.delete(this._toRaw(A))}get(A){return this._map.get(this._toRaw(A))}has(A){return this._map.has(this._toRaw(A))}set(A,e){return this._map.set(this._toRaw(A),this._toRaw(e)),this}}const Zn=new SA;function Vi(r){let A=Zn.get(r);if(!A){const e=Object.getPrototypeOf(r);A=new Map(e?Vi(e):void 0),Zn.set(r,A)}return A}function oi(r,A,e={}){Vi(r).set(A,e);const{default:t,alias:i}=e;let s=Object.getOwnPropertyDescriptor(r.prototype,A);if(!s){const n=i??Symbol.for(String(A));s={get(){return this[n]},set(o){this[n]=o}}}Object.defineProperty(r.prototype,A,{get(){var n;return((n=s.get)==null?void 0:n.call(this))??t},set(n){var a,l,g;const o=((a=s.get)==null?void 0:a.call(this))??t;(l=s.set)==null||l.call(this,n),(g=this.requestUpdate)==null||g.call(this,A,o,e)},configurable:!0,enumerable:!0})}function U(r){return function(A,e){oi(A.constructor,e,r)}}const zi=new Map;function re(r,A){return function(e){Object.defineProperty(e.prototype,"tag",{value:r,enumerable:!0,configurable:!0}),A&&Object.keys(A).forEach(t=>{oi(e,t,{default:A[t]})}),zi.set(r,e)}}function Ee(r){return U({...r,protected:!0})}function ng(r="node",A={}){const e=zi.get(r);if(!e)throw new Error(`Failed to createNode, tag: ${r}`);return new e().setProperties(A)}class xe{static get currentTime(){return this._currentTime}static get elapsed(){return this._elapsed}static on(A,e={}){const{sort:t=0,once:i=!1}=e;this._queue[t]||(this._queue[t]=[]),this._queue[t].push({cb:A,once:i})}static off(A,e={}){const{sort:t=0}=e,i=this._queue[t];if(!i)return;const s=[];for(let n=i.length,o=0;o<n;o++){const a=i[o];a.cb!==A&&s.push(a)}s.length?this._queue[t]=s:this._queue.splice(t,1)}static start(){"requestAnimationFrame"in globalThis&&(this._currentTime=performance.now(),this._requestId=requestAnimationFrame(A=>this._update(A)))}static stop(){this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=void 0)}static _update(A){this._elapsed=A-this._currentTime,this._currentTime=A,this._requestId=requestAnimationFrame(e=>this._update(e)),this._performUpdate()}static _performUpdate(){const A=this._queue,e=[];for(let t=A.length,i=t;i>=0;i--){const s=A[i];if(!s)continue;const n=[];for(let o=s.length,a=0;a<o;a++){const l=s[a];try{l.cb()}catch(g){console.warn(g)}l.once||n.push(l)}n.length&&(e[i]=n)}this._queue=e}}c(xe,"_queue",[]),c(xe,"_currentTime",0),c(xe,"_elapsed",0),c(xe,"_requestId"),xe.start();async function as(r){return new Promise(A=>{xe.on(()=>{r==null||r(),A()},{sort:1,once:!0})})}let Ot=class{constructor(){c(this,"eventListeners",new Map)}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(A){return this.eventListeners.has(A)}on(A,e,t){const i={value:e,options:t},s=this.eventListeners.get(A);return s?Array.isArray(s)?s.push(i):this.eventListeners.set(A,[s,i]):this.eventListeners.set(A,i),this}once(A,e){return this.on(A,e,{once:!0})}off(A,e,t){var s,n;if(!e)return this.eventListeners.delete(A),this;const i=this.eventListeners.get(A);if(!i)return this;if(Array.isArray(i)){const o=[];for(let a=0,l=i.length;a<l;a++){const g=i[a];(g.value!==e||typeof t=="object"&&(t!=null&&t.once)&&(typeof g.options=="boolean"||!((s=g.options)!=null&&s.once)))&&o.push(g)}o.length?this.eventListeners.set(A,o.length===1?o[0]:o):this.eventListeners.delete(A)}else i.value===e&&(typeof t=="boolean"||!(t!=null&&t.once)||typeof i.options=="boolean"||(n=i.options)!=null&&n.once)&&this.eventListeners.delete(A);return this}emit(A,...e){var i,s;const t=this.eventListeners.get(A);if(t){if(Array.isArray(t))for(let n=t.length,o=0;o<n;o++){const a=t[o];typeof a.options=="object"&&((i=a.options)!=null&&i.once)&&this.off(A,a.value,a.options),a.value.apply(this,e)}else typeof t.options=="object"&&((s=t.options)!=null&&s.once)&&this.off(A,t.value,t.options),t.value.apply(this,e);return!0}else return!1}},og=0;class qi extends Ot{constructor(){super(...arguments);c(this,"instanceId",++og);c(this,"_defaultProperties");c(this,"_updatedProperties",new Map);c(this,"_changedProperties",new Set);c(this,"_updatingPromise",Promise.resolve());c(this,"_updating",!1)}is(e){return!!(e&&this.instanceId===e.instanceId)}async _enqueueUpdate(){this._updating=!0;try{await this._updatingPromise}catch(e){Promise.reject(e)}await as(),this._updating&&(this.update(),this._updating=!1)}update(){this._update(this._updatedProperties),this._updatedProperties=new Map}_update(e){}_updateProperty(e,t,i,s){}isDirty(e){return this._updatedProperties.has(e)}getPropertyDeclarations(){return Vi(this.constructor)}getPropertyDeclaration(e){return this.getPropertyDeclarations().get(e)}getDefaultProperties(){if(!this._defaultProperties){this._defaultProperties={};for(const[e,t]of this.getPropertyDeclarations())!t.protected&&!t.alias&&(this._defaultProperties[e]=t.default)}return this._defaultProperties}getProperty(e){return this[e]}setProperty(e,t){return this[e]=t,this}getProperties(e){const t={};for(const[i,s]of this.getPropertyDeclarations())!s.protected&&!s.alias&&(!e||e.includes(i))&&(t[i]=this.getProperty(i));return t}setProperties(e){if(e)for(const[t]of this.getPropertyDeclarations())t in e&&this.setProperty(t,e[t]);return this}requestUpdate(e,t,i){if(e!==void 0){const s=this[e];if(!Object.is(s,t))this._updatedProperties.set(e,t),this._changedProperties.add(e),i??(i=this.getPropertyDeclaration(e)),this._updateProperty(e,s,t,i),this.emit("updateProperty",e,s,t,i);else return}this._updating||(this._updatingPromise=this._enqueueUpdate())}toJSON(){return this.getProperties(Array.from(this._changedProperties))}clone(){return new this.constructor(this.toJSON())}free(){this.removeAllListeners()}}class $n extends qi{}class Xi{constructor(){c(this,"bubbles",!0);c(this,"cancelable",!1);c(this,"which");c(this,"cancelBubble",!0);c(this,"returnValue");c(this,"srcElement");c(this,"composed",!1);c(this,"currentTarget");c(this,"defaultPrevented",!1);c(this,"eventPhase",Xi.prototype.NONE);c(this,"isTrusted");c(this,"target");c(this,"timeStamp");c(this,"type");c(this,"nativeEvent");c(this,"originalEvent");c(this,"propagationStopped",!1);c(this,"propagationImmediatelyStopped",!1);c(this,"path");c(this,"detail");c(this,"view");c(this,"layer",{x:0,y:0});c(this,"page",{x:0,y:0});c(this,"NONE",0);c(this,"CAPTURING_PHASE",1);c(this,"AT_TARGET",2);c(this,"BUBBLING_PHASE",3)}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}initEvent(...A){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(...A){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}composedPath(){return this.path}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class ls extends Xi{constructor(){super(...arguments);c(this,"altKey");c(this,"button");c(this,"buttons");c(this,"ctrlKey");c(this,"metaKey");c(this,"relatedTarget");c(this,"shiftKey");c(this,"client",{x:0,y:0});c(this,"movement",{x:0,y:0});c(this,"offset",{x:0,y:0});c(this,"global",{x:0,y:0});c(this,"screen",{x:0,y:0})}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(...e){throw new Error("Method not implemented.")}}class eo extends ls{constructor(){super(...arguments);c(this,"width",0);c(this,"height",0);c(this,"isPrimary",!1);c(this,"pointerType");c(this,"pressure");c(this,"tangentialPressure");c(this,"tiltX");c(this,"tiltY");c(this,"twist")}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class ai extends ls{constructor(){super(...arguments);c(this,"deltaMode");c(this,"deltaX");c(this,"deltaY");c(this,"deltaZ");c(this,"DOM_DELTA_PIXEL",0);c(this,"DOM_DELTA_LINE",1);c(this,"DOM_DELTA_PAGE",2)}}c(ai,"DOM_DELTA_PIXEL",0),c(ai,"DOM_DELTA_LINE",1),c(ai,"DOM_DELTA_PAGE",2);const ag={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class to extends Ot{constructor(){super(...arguments);c(this,"target");c(this,"cursor","default");c(this,"cursorStyles",{default:"inherit",pointer:"pointer"});c(this,"setuped",!1);c(this,"event");c(this,"enableMoveEvent",!0);c(this,"enableWheelEvent",!0);c(this,"enableClickEvent",!0);c(this,"onPointerDown",e=>{if(Gt&&e.pointerType==="touch")return;const t=this.normalize(e);for(let i=0,s=t.length;i<s;i++)this.emit("pointerdown",this.event=this.clonePointerEvent(t[i]));this.setCursor(this.cursor)});c(this,"onPointerOver",e=>{if(!this.enableClickEvent||Gt&&e.pointerType==="touch")return;const t=this.normalize(e);for(let i=0,s=t.length;i<s;i++)this.emit("pointerover",this.event=this.clonePointerEvent(t[i]))});c(this,"onPointerMove",e=>{if(!this.enableMoveEvent||Gt&&e.pointerType==="touch")return;const t=this.normalize(e);for(let i=0,s=t.length;i<s;i++)this.emit("pointermove",this.event=this.clonePointerEvent(t[i]))});c(this,"onPointerUp",e=>{if(!this.enableClickEvent||Gt&&e.pointerType==="touch")return;let t=e.target;e.composedPath&&e.composedPath().length>0&&(t=e.composedPath()[0]);const i=t!==this.target?"outside":"",s=this.normalize(e);for(let n=0,o=s.length;n<o;n++){const a=this.clonePointerEvent(s[n]);a.type+=i,this.emit("pointerup",this.event=a)}});c(this,"onWheel",e=>{if(!this.enableWheelEvent)return;const t=this.normalize(e);for(let i=0,s=t.length;i<s;i++)this.emit("wheel",this.event=this.cloneWheelEvent(t[i]))})}setTarget(e){this.removeEventListeners(),this.target=e,this.addEventListeners()}removeEventListeners(){if(!this.setuped||!this.target)return;const e=this.target.style;globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):xA&&(e.touchAction=""),xA?(this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointerleave",this.onPointerOver),this.target.removeEventListener("pointerover",this.onPointerOver),this.target.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.target.ownerDocument.removeEventListener("pointerup",this.onPointerUp)):(this.target.removeEventListener("mousedown",this.onPointerDown),this.target.removeEventListener("mouseout",this.onPointerOver),this.target.removeEventListener("mouseover",this.onPointerOver),this.target.ownerDocument.removeEventListener("mousemove",this.onPointerMove),this.target.ownerDocument.removeEventListener("mouseup",this.onPointerUp)),Gt&&(this.target.removeEventListener("touchstart",this.onPointerDown),this.target.removeEventListener("touchmove",this.onPointerMove),this.target.removeEventListener("touchend",this.onPointerUp)),this.target.removeEventListener("wheel",this.onWheel),this.target=void 0,this.setuped=!1}addEventListeners(){if(this.setuped||!this.target)return;const e=this.target.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):xA&&(e.touchAction="none")),xA?(this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointerleave",this.onPointerOver),this.target.addEventListener("pointerover",this.onPointerOver),this.target.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.target.ownerDocument.addEventListener("pointerup",this.onPointerUp)):(this.target.addEventListener("mousedown",this.onPointerDown),this.target.addEventListener("mouseout",this.onPointerOver),this.target.addEventListener("mouseover",this.onPointerOver),this.target.ownerDocument.addEventListener("mousemove",this.onPointerMove),this.target.ownerDocument.addEventListener("mouseup",this.onPointerUp)),Gt&&(this.target.addEventListener("touchstart",this.onPointerDown),this.target.addEventListener("touchmove",this.onPointerMove),this.target.addEventListener("touchend",this.onPointerUp)),this.target.addEventListener("wheel",this.onWheel),this.setuped=!0}normalize(e){const t=[];if(Gt&&e instanceof globalThis.TouchEvent)for(let i=0,s=e.changedTouches.length;i<s;i++){const n=e.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.type=e.type,t.push(n)}else if(Hn&&e instanceof globalThis.WheelEvent)t.push(e);else if(xA&&e instanceof globalThis.PointerEvent)t.push(e);else{const i=e;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=1),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),t.push(i)}return t}cloneWheelEvent(e){const t=new ai;return this.copyMouseEvent(t,e),t.wheelDeltaY=e.wheelDeltaY,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.x=t.screen.x,t.global.y=t.screen.y,t.offset.x=t.screen.x,t.offset.y=t.screen.y,t.nativeEvent=e,t.type=e.type,t}clonePointerEvent(e){const t=new eo;return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,t.isTrusted=e.isTrusted,this.copyMouseEvent(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.x=t.screen.x,t.global.y=t.screen.y,t.offset.x=t.screen.x,t.offset.y=t.screen.y,t.type==="pointerleave"?t.type="pointerout":t.type.startsWith("mouse")?t.type=t.type.replace("mouse","pointer"):t.type.startsWith("touch")&&(t.type=ag[t.type]||t.type),t}copyMouseEvent(e,t){e.preventDefault=t.preventDefault.bind(t),e.stopPropagation=t.stopPropagation.bind(t),e.isTrusted=t.isTrusted,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}setCursor(e){if(!this.target||(e=e||"default",this.cursor===e))return;this.cursor=e;const t=!(globalThis.OffscreenCanvas&&this.target instanceof OffscreenCanvas),i=this.cursorStyles[e];if(i)switch(typeof i){case"string":t&&(this.target.style.cursor=i);break;case"function":i(e);break;case"object":t&&Object.assign(this.target.style,i);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.target.style.cursor=e)}mapPositionToPoint(e,t,i){if(!this.target)return;const s=Number(this.target.getAttribute("width"))||0,n=Number(this.target.getAttribute("height"))||0,o=Number(this.target.getAttribute("data-pixel-ratio"))||1,a=this.target.isConnected?this.target.getBoundingClientRect():{width:s,height:n,left:0,top:0},l=1/o;e.x=(t-a.left)*(s/a.width)*l,e.y=(i-a.top)*(n/a.height)*l}}class Ht extends $n{}var lg={grad:.9,turn:360,rad:360/(2*Math.PI)},Jt=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},Ue=function(r,A,e){return A===void 0&&(A=0),e===void 0&&(e=Math.pow(10,A)),Math.round(e*r)/e+0},ft=function(r,A,e){return A===void 0&&(A=0),e===void 0&&(e=1),r>e?e:r>A?r:A},Ao=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},io=function(r){return{r:ft(r.r,0,255),g:ft(r.g,0,255),b:ft(r.b,0,255),a:ft(r.a)}},gs=function(r){return{r:Ue(r.r),g:Ue(r.g),b:Ue(r.b),a:Ue(r.a,3)}},gg=/^#([0-9a-f]{3,8})$/i,ji=function(r){var A=r.toString(16);return A.length<2?"0"+A:A},ro=function(r){var A=r.r,e=r.g,t=r.b,i=r.a,s=Math.max(A,e,t),n=s-Math.min(A,e,t),o=n?s===A?(e-t)/n:s===e?2+(t-A)/n:4+(A-e)/n:0;return{h:60*(o<0?o+6:o),s:s?n/s*100:0,v:s/255*100,a:i}},so=function(r){var A=r.h,e=r.s,t=r.v,i=r.a;A=A/360*6,e/=100,t/=100;var s=Math.floor(A),n=t*(1-e),o=t*(1-(A-s)*e),a=t*(1-(1-A+s)*e),l=s%6;return{r:255*[t,o,n,n,a,t][l],g:255*[a,t,t,o,n,n][l],b:255*[n,n,a,t,t,o][l],a:i}},no=function(r){return{h:Ao(r.h),s:ft(r.s,0,100),l:ft(r.l,0,100),a:ft(r.a)}},oo=function(r){return{h:Ue(r.h),s:Ue(r.s),l:Ue(r.l),a:Ue(r.a,3)}},ao=function(r){return so((e=(A=r).s,{h:A.h,s:(e*=((t=A.l)<50?t:100-t)/100)>0?2*e/(t+e)*100:0,v:t+e,a:A.a}));var A,e,t},li=function(r){return{h:(A=ro(r)).h,s:(i=(200-(e=A.s))*(t=A.v)/100)>0&&i<200?e*t/100/(i<=100?i:200-i)*100:0,l:i/2,a:A.a};var A,e,t,i},hg=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,cg=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ug=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,fg=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hs={string:[[function(r){var A=gg.exec(r);return A?(r=A[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?Ue(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?Ue(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var A=ug.exec(r)||fg.exec(r);return A?A[2]!==A[4]||A[4]!==A[6]?null:io({r:Number(A[1])/(A[2]?100/255:1),g:Number(A[3])/(A[4]?100/255:1),b:Number(A[5])/(A[6]?100/255:1),a:A[7]===void 0?1:Number(A[7])/(A[8]?100:1)}):null},"rgb"],[function(r){var A=hg.exec(r)||cg.exec(r);if(!A)return null;var e,t,i=no({h:(e=A[1],t=A[2],t===void 0&&(t="deg"),Number(e)*(lg[t]||1)),s:Number(A[3]),l:Number(A[4]),a:A[5]===void 0?1:Number(A[5])/(A[6]?100:1)});return ao(i)},"hsl"]],object:[[function(r){var A=r.r,e=r.g,t=r.b,i=r.a,s=i===void 0?1:i;return Jt(A)&&Jt(e)&&Jt(t)?io({r:Number(A),g:Number(e),b:Number(t),a:Number(s)}):null},"rgb"],[function(r){var A=r.h,e=r.s,t=r.l,i=r.a,s=i===void 0?1:i;if(!Jt(A)||!Jt(e)||!Jt(t))return null;var n=no({h:Number(A),s:Number(e),l:Number(t),a:Number(s)});return ao(n)},"hsl"],[function(r){var A=r.h,e=r.s,t=r.v,i=r.a,s=i===void 0?1:i;if(!Jt(A)||!Jt(e)||!Jt(t))return null;var n=function(o){return{h:Ao(o.h),s:ft(o.s,0,100),v:ft(o.v,0,100),a:ft(o.a)}}({h:Number(A),s:Number(e),v:Number(t),a:Number(s)});return so(n)},"hsv"]]},lo=function(r,A){for(var e=0;e<A.length;e++){var t=A[e][0](r);if(t)return[t,A[e][1]]}return[null,void 0]},dg=function(r){return typeof r=="string"?lo(r.trim(),hs.string):typeof r=="object"&&r!==null?lo(r,hs.object):[null,void 0]},cs=function(r,A){var e=li(r);return{h:e.h,s:ft(e.s+100*A,0,100),l:e.l,a:e.a}},us=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},go=function(r,A){var e=li(r);return{h:e.h,s:e.s,l:ft(e.l+100*A,0,100),a:e.a}},fs=function(){function r(A){this.parsed=dg(A)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return Ue(us(this.rgba),2)},r.prototype.isDark=function(){return us(this.rgba)<.5},r.prototype.isLight=function(){return us(this.rgba)>=.5},r.prototype.toHex=function(){return A=gs(this.rgba),e=A.r,t=A.g,i=A.b,n=(s=A.a)<1?ji(Ue(255*s)):"","#"+ji(e)+ji(t)+ji(i)+n;var A,e,t,i,s,n},r.prototype.toRgb=function(){return gs(this.rgba)},r.prototype.toRgbString=function(){return A=gs(this.rgba),e=A.r,t=A.g,i=A.b,(s=A.a)<1?"rgba("+e+", "+t+", "+i+", "+s+")":"rgb("+e+", "+t+", "+i+")";var A,e,t,i,s},r.prototype.toHsl=function(){return oo(li(this.rgba))},r.prototype.toHslString=function(){return A=oo(li(this.rgba)),e=A.h,t=A.s,i=A.l,(s=A.a)<1?"hsla("+e+", "+t+"%, "+i+"%, "+s+")":"hsl("+e+", "+t+"%, "+i+"%)";var A,e,t,i,s},r.prototype.toHsv=function(){return A=ro(this.rgba),{h:Ue(A.h),s:Ue(A.s),v:Ue(A.v),a:Ue(A.a,3)};var A},r.prototype.invert=function(){return _t({r:255-(A=this.rgba).r,g:255-A.g,b:255-A.b,a:A.a});var A},r.prototype.saturate=function(A){return A===void 0&&(A=.1),_t(cs(this.rgba,A))},r.prototype.desaturate=function(A){return A===void 0&&(A=.1),_t(cs(this.rgba,-A))},r.prototype.grayscale=function(){return _t(cs(this.rgba,-1))},r.prototype.lighten=function(A){return A===void 0&&(A=.1),_t(go(this.rgba,A))},r.prototype.darken=function(A){return A===void 0&&(A=.1),_t(go(this.rgba,-A))},r.prototype.rotate=function(A){return A===void 0&&(A=15),this.hue(this.hue()+A)},r.prototype.alpha=function(A){return typeof A=="number"?_t({r:(e=this.rgba).r,g:e.g,b:e.b,a:A}):Ue(this.rgba.a,3);var e},r.prototype.hue=function(A){var e=li(this.rgba);return typeof A=="number"?_t({h:A,s:e.s,l:e.l,a:e.a}):Ue(e.h)},r.prototype.isEqual=function(A){return this.toHex()===_t(A).toHex()},r}(),_t=function(r){return r instanceof fs?r:new fs(r)},ho=[],Ig=function(r){r.forEach(function(A){ho.indexOf(A)<0&&(A(fs,hs),ho.push(A))})};function Bg(r,A){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},t={};for(var i in e)t[e[i]]=i;var s={};r.prototype.toName=function(n){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,a,l=t[this.toHex()];if(l)return l;if(n!=null&&n.closest){var g=this.toRgb(),h=1/0,f="black";if(!s.length)for(var I in e)s[I]=new r(e[I]).toRgb();for(var d in e){var C=(o=g,a=s[d],Math.pow(o.r-a.r,2)+Math.pow(o.g-a.g,2)+Math.pow(o.b-a.b,2));C<h&&(h=C,f=d)}return f}},A.string.push([function(n){var o=n.toLowerCase(),a=o==="transparent"?"#0000":e[o];return a?new r(a).toRgb():null},"name"])}Ig([Bg]);class Zt{get value(){return this._value}set value(A){if(A===void 0||this._value===A)return;this._value=A;let e;typeof A=="number"?e={r:A>>24&255,g:A>>16&255,b:A>>8&255,a:(A&255)/255}:e=A;const t=_t(e);t.isValid()?this._colord=t:console.warn(`Unable to convert color ${A}`)}get r8(){return this._colord.rgba.r}get g8(){return this._colord.rgba.g}get b8(){return this._colord.rgba.b}get a8(){return this._colord.rgba.a*255&255}get r(){return this.r8/255}get g(){return this.g8/255}get b(){return this.b8/255}get a(){return this._colord.rgba.a}get rgb(){return(this.r8<<16)+(this.g8<<8)+this.b8}get bgr(){return(this.b8<<16)+(this.g8<<8)+this.r8}get abgr(){return(this.a8<<24)+this.bgr}constructor(A=0){this.value=A}toArgb(A=this.a,e=!0){if(A===1)return(255<<24)+this.rgb;if(A===0)return e?0:this.rgb;let t=this.r8,i=this.g8,s=this.b8;return e&&(t=t*A+.5|0,i=i*A+.5|0,s=s*A+.5|0),(A*255<<24)+(t<<16)+(i<<8)+s}toHex(){return this._colord.toHex()}toArray(){return[this.r,this.g,this.b,this.a]}}class pt extends Ot{constructor(e){super();c(this,"_array",[]);this.dim=e}get length(){return this.dim}_operate(e,t,i){const{dim:s,_array:n}=this;let o;typeof t=="number"?o=Array.from({length:s},()=>t):t instanceof Dt||t instanceof pt?o=t.toArray():o=t;let a,l=[];if(i?i instanceof pt?a=i:l=i:a=this,t instanceof Dt){const{cols:g}=t;switch(e){case"*":for(let h=0;h<s;h++){let f=0;for(let I=0;I<s;I++)f+=n[h]*o[I*g+h];l[h]=f}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"+":for(let g=0;g<s;g++)l[g]=n[g]+o[g];break;case"-":for(let g=0;g<s;g++)l[g]=n[g]-o[g];break;case"*":for(let g=0;g<s;g++)l[g]=n[g]*o[g];break;case"/":for(let g=0;g<s;g++)l[g]=n[g]/o[g];break;case"rot":{const g=Math.cos(o[0]),h=Math.sin(o[0]);l[0]=n[0]*g-n[1]*h,l[1]=n[1]*g+n[0]*h;break}case"==":{let g=!0;for(let h=0;h<s;h++)g=g&&n[h]===o[h];return g}case"=":for(let g=0;g<s;g++){const h=o[g];h!==void 0&&(n[g]=h)}return this._onUpdate(n),this.emit("update",n),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Vector'`)}return(a==null?void 0:a.set(l))??l}add(e,t){return this._operate("+",e,t)}sub(e,t){return this._operate("-",e,t)}multiply(e,t){return this._operate("*",e,t)}divide(e,t){return this._operate("/",e,t)}rotate(e){return this._operate("rot",e)}set(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this._operate("=",e)}equals(e){return this._operate("==",e)}copy(e){return this.set(e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}_onUpdate(e){}toArray(){return this._array.slice()}toName(){return`Vector${this.dim}`}}class Dt extends Ot{constructor(e,t,i){super();c(this,"_array",[]);c(this,"dirtyId",0);this.rows=e,this.cols=t,i?this.set(i):this.identity()}get length(){return this.cols*this.rows}_operate(e,t,i){const{cols:s,rows:n,length:o,_array:a}=this;let l;typeof t=="number"?l=Array.from({length:o},()=>t):t instanceof pt||t instanceof Dt?l=t.toArray():l=t;let g,h=[];if(i?i instanceof pt||i instanceof Dt?g=i:h=i:t instanceof pt?g=new t.constructor:g=this,t instanceof pt){const{dim:f}=t;switch(e){case"*":for(let I=0;I<f;I++){let d=0;for(let C=0;C<s;C++)C<f&&(d+=a[I*s+C]*(l[C]??0));h[I]=d}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"*":for(let f=0;f<s;f++)for(let I=0;I<n;I++){const d=I*s;let C=0;for(let B=0;B<n;B++){const R=d+B,S=B*s+f;C+=a[R]*(l[S]??0)}h[d+f]=C}break;case"=":for(let f=0;f<o;f++){const I=l[f];I!==void 0&&(a[f]=I)}return this._onUpdate(a),this.emit("update",a),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Matrix2'`)}return(g==null?void 0:g.set(h))??h}identity(){const{cols:e,rows:t}=this,i=[];for(let s=0;s<e;s++)for(let n=0;n<t;n++){const o=n*e,a=s+o;i[a]=n+o===a?1:0}return this.set(i)}set(e){return this._operate("=",e)}copy(e){return this.set(e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}multiply(e,t){return this._operate("*",e,t)}_onUpdate(e){this.dirtyId++}toArray(e=!1){const{cols:t,rows:i,_array:s}=this;if(e){const n=[];for(let o=0;o<i;o++)for(let a=0;a<t;a++)n[o+a*t]=s[a+o*t];return n}return s.slice()}toName(){return`Matrix${this.rows}(${this.rows}x${this.cols})`}toJSON(){return this._array}}class co extends Dt{constructor(A){super(4,4,A)}}const uo=Lt/180,Eg=180/Lt;function bt(r,A,e){return Math.max(r,Math.min(A,e))}function Se(r,A,e){return(1-e)*r+e*A}const pg={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(r,A=20){if(!this.adaptive||!r||Number.isNaN(r))return A;let e=Math.ceil(r/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class fo extends pt{constructor(A=0,e=0,t=0,i=0){super(4),this.set([A,e,t,i])}}class ds extends Dt{constructor(A){super(4,5,A)}hueRotate(A=0){const e=Math.sin(A),t=Math.cos(A),i=.213,s=.715,n=.072;return this.multiply([i+t*(1-i)+e*-.213,s+t*-.715+e*-.715,n+t*-.072+e*(1-n),0,0,i+t*-.213+e*.143,s+t*(1-s)+e*.14,n+t*-.072+e*-.283,0,0,i+t*-.213+e*-.787,s+t*-.715+e*s,n+t*(1-n)+e*n,0,0,0,0,0,1,0])}saturate(A=1){const e=(A-1)*2/3+1,t=(e-1)*-.5;return this.multiply([e,t,t,0,0,t,e,t,0,0,t,t,e,0,0,0,0,0,1,0])}brightness(A=1){const e=A;return this.multiply([e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0])}contrast(A=1){const e=A,t=-128*(e-1);return this.multiply([e,0,0,0,t,0,e,0,0,t,0,0,e,0,t,0,0,0,1,0])}invert(A=1){const e=Se(1,-1,A),t=Se(0,255,A);return this.multiply([e,0,0,0,t,0,e,0,0,t,0,0,e,0,t,0,0,0,1,0])}sepia(A=1){const e=bt(0,A,1);return this.multiply([Se(1,.393,e),Se(0,.7689999,e),Se(0,.18899999,e),0,0,Se(0,.349,e),Se(1,.6859999,e),Se(0,.16799999,e),0,0,Se(0,.272,e),Se(0,.5339999,e),Se(1,.13099999,e),0,0,0,0,0,1,0])}opacity(A=1){return this.multiply([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,A,0])}grayscale(A=1){const e=bt(0,A,1),t=Se(1,.3,e),i=Se(0,.3,e),s=Se(1,.59,e),n=Se(0,.59,e),o=Se(1,.11,e),a=Se(0,.11,e);return this.multiply([t,n,a,0,0,i,s,a,0,0,i,n,o,0,0,0,0,0,1,0])}multiply(A){const e=A,t=this._array;return this.set([t[0]*e[0]+t[1]*e[5]+t[2]*e[10]+t[3]*e[15],t[0]*e[1]+t[1]*e[6]+t[2]*e[11]+t[3]*e[16],t[0]*e[2]+t[1]*e[7]+t[2]*e[12]+t[3]*e[17],t[0]*e[3]+t[1]*e[8]+t[2]*e[13]+t[3]*e[18],t[0]*e[4]+t[1]*e[9]+t[2]*e[14]+t[3]*e[19]+t[4],t[5]*e[0]+t[6]*e[5]+t[7]*e[10]+t[8]*e[15],t[5]*e[1]+t[6]*e[6]+t[7]*e[11]+t[8]*e[16],t[5]*e[2]+t[6]*e[7]+t[7]*e[12]+t[8]*e[17],t[5]*e[3]+t[6]*e[8]+t[7]*e[13]+t[8]*e[18],t[5]*e[4]+t[6]*e[9]+t[7]*e[14]+t[8]*e[19]+t[9],t[10]*e[0]+t[11]*e[5]+t[12]*e[10]+t[13]*e[15],t[10]*e[1]+t[11]*e[6]+t[12]*e[11]+t[13]*e[16],t[10]*e[2]+t[11]*e[7]+t[12]*e[12]+t[13]*e[17],t[10]*e[3]+t[11]*e[8]+t[12]*e[13]+t[13]*e[18],t[10]*e[4]+t[11]*e[9]+t[12]*e[14]+t[13]*e[19]+t[14],t[15]*e[0]+t[16]*e[5]+t[17]*e[10]+t[18]*e[15],t[15]*e[1]+t[16]*e[6]+t[17]*e[11]+t[18]*e[16],t[15]*e[2]+t[16]*e[7]+t[17]*e[12]+t[18]*e[17],t[15]*e[3]+t[16]*e[8]+t[17]*e[13]+t[18]*e[18],t[15]*e[4]+t[16]*e[9]+t[17]*e[14]+t[18]*e[19]+t[19]])}toMatrix4(){const A=this._array;return new co([A[0],A[1],A[2],A[3],A[5],A[6],A[7],A[8],A[10],A[11],A[12],A[13],A[15],A[16],A[17],A[18]])}toVector4(){const A=this._array;return new fo(A[4]/255,A[9]/255,A[14]/255,A[19]/255)}}class Cg extends Dt{constructor(A){super(2,2,A)}}let Is=class extends Dt{constructor(A){super(3,3,A)}invert(){const[A,e,t,i,s,n,o,a,l]=this._array,g=l*s-n*a,h=n*o-l*i,f=a*i-s*o,I=A*g+e*h+t*f;if(I===0)return this.set([0,0,0,0,0,0,0,0,0]);const d=1/I;return this.set([g*d,(t*a-l*e)*d,(n*e-t*s)*d,h*d,(l*A-t*o)*d,(t*i-n*A)*d,f*d,(e*o-a*A)*d,(s*A-e*i)*d])}};class Io extends Is{constructor(A=0,e=0,t=0,i=0,s=!1){super(),this._x=A,this._y=e,this._width=t,this._height=i,this._flipY=s,this._performUpdateArray()}flipY(A){return this._flipY!==A&&(this._flipY=A,this._performUpdateArray()),this}translate(A,e){return(this._x!==A||this._y!==e)&&(this._x=A,this._y=e,this._performUpdateArray()),this}resize(A,e){return(this._width!==A||this._height!==e)&&(this._width=A,this._height=e,this._performUpdateArray()),this}_performUpdateArray(){const A=this._width,e=this._height;if(!A||!e)return;const t=this._x,i=this._y,s=this._flipY?-1:1,n=1/A*2,o=s*(1/e*2),a=-1-t*n,l=-s-i*o;this.set([n,0,a,0,o,l,0,0,1])}}let Ct=class $r extends pt{get x(){return this._array[0]}set x(A){const[e,t]=this._array;e!==A&&this.set(A,t)}get y(){return this._array[1]}set y(A){const[e,t]=this._array;t!==A&&this.set(e,A)}get width(){return this.x}set width(A){this.x=A}get height(){return this.y}set height(A){this.y=A}get left(){return this.x}set left(A){this.x=A}get top(){return this.y}set top(A){this.y=A}constructor(A=0,e){super(2),this.set(typeof A=="number"?[A,e??A]:A)}update(A,e){const[t,i]=this._array;return(t!==A||i!==e)&&this.set(A,e),this}getLength(){const[A,e]=this._array;return Math.sqrt(A*A+e*e)}getAngle(){const[A,e]=this._array;return Math.atan2(-A,-e)+Math.PI}distanceTo(A){return Math.hypot(A.x-this.x,A.y-this.y)}normalize(){const[A,e]=this._array,t=1/(this.getLength()||1);return this.set(A*t,e*t),this}static lerp(A,e,t){return new $r(e).clone().sub(new $r(A)).multiply(t).add(new $r(A))}};class Bs{constructor(...A){c(this,"end",new Ct);c(this,"position");c(this,"size");const e=new Ct,t=new Ct;switch(A.length){case 0:break;case 1:e.set(A[0].position),t.set(A[0].size);break;case 2:e.set(A[0]),t.set(A[1]);break;default:e.set(A[0],A[1]),t.set(A[2],A[3]);break}this.update=this.update.bind(this),this.position=e.on("update",this.update),this.size=t.on("update",this.update),this.update()}get x(){return this.position.x}get y(){return this.position.y}get left(){return this.position.x}get top(){return this.position.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get width(){return this.size.x}get height(){return this.size.y}update(){return this.end.set(this.position.x+this.size.x,this.position.y+this.size.y),this}toArray(){return[this.x,this.y,this.width,this.height]}}const hA=class hA extends Is{premultiply(A){return A.multiply(this,this)}skewX(A){return this.skew(A,1)}skewY(A){return this.skew(1,A)}skew(A,e){return this.premultiply(hA._t2d.makeSkew(A,e))}makeSkew(A,e){const t=Math.cos(e),i=Math.sin(e),s=-Math.sin(-A),n=Math.cos(-A);return this.set([t,s,0,i,n,0,0,0,1]),this}translateX(A){return this.translate(A,0)}translateY(A){return this.translate(0,A)}translateZ(A){return this.translate(0,0,A)}translate3d(A,e,t){return this.translate(A,e,t)}translate(A,e,t=0){return this.premultiply(hA._t2d.makeTranslation(A,e,t))}makeTranslation(A,e,t=0){return this.set([1,0,A,0,1,e,0,0,1]),this}scaleX(A){return this.scale(A,1)}scaleY(A){return this.scale(1,A)}scale3d(A,e,t=1){return this.scale(A,e,t)}scale(A,e,t=1){return this.premultiply(hA._t2d.makeScale(A,e,t))}makeScale(A,e,t=1){return this.set([A,0,0,0,e,0,0,0,t]),this}rotateX(A){return this.scaleY(this._rotateToScale(A))}rotateY(A){return this.scaleX(this._rotateToScale(A))}rotateZ(A){return this.rotate(A)}rotate(A){return this.premultiply(hA._t2d.makeRotation(A))}rotate3d(A,e,t,i){const[s,n,o]=this._rotate3d(A,e,t,i);return s&&this.rotateX(s),n&&this.rotateY(n),o&&this.rotateZ(o),this}_rotateToScale(A){const e=A/et;return e<=.5?e*-4+1:(e-1)*4+1}_rotate3d(A,e,t,i){if(A===1&&e===0&&t===0)return[i,0,0];if(A===0&&e===1&&t===0)return[0,i,0];if(A===0&&e===0)return[0,0,i];{const s=Math.cos(i),n=Math.sin(i),o=s+A*A*(1-s),a=A*e*(1-s)-t*n,l=A*t*(1-s)+e*n,g=s+e*e*(1-s),h=e*t*(1-s)-A*n,f=s+t*t*(1-s),I=-Math.atan2(-h,g),d=-Math.atan2(l,Math.sqrt(h*h+f*f)),C=-Math.atan2(-a,o);return[I,d,C]}}makeRotation(A){const e=Math.cos(A),t=Math.sin(A);return this.set([e,-t,0,t,e,0,0,0,1]),this}applyToPoint(A,e){const{a:t,c:i,tx:s,b:n,d:o,ty:a}=this.toObject();return[t*A+i*e+s,n*A+o*e+a]}inverse(){return this.clone().invert()}isIdentity(){const{a:A,b:e,c:t,d:i,tx:s,ty:n}=this.toObject();return A===1&&e===0&&t===0&&i===1&&s===0&&n===0}toObject(){const[A,e,t,i,s,n,,,o]=this._array;return{a:A,c:e,tx:t,b:i,d:s,ty:n,tz:o}}};c(hA,"_t2d",new hA);let Qt=hA;class Qg extends pt{constructor(){super(3)}}var yg=Object.defineProperty,Bo=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&yg(A,e,i),i};class Zi extends qi{constructor(){super();c(this,"_starting",!1);c(this,"_nextDeltaTime",0);this._onNextTick=this._onNextTick.bind(this)}get starting(){return this._starting}get spf(){return this.fps?Math.floor(1e3/this.fps):0}start(e){this._starting||(this._starting=!0,this.off("process"),this.on("process",e),xe.on(this._onNextTick,{sort:0}))}stop(){this._starting&&(this._starting=!1,xe.off(this._onNextTick,{sort:0}))}_onNextTick(){const e=xe.elapsed*this.speed;if((this._nextDeltaTime-=e)<=0){const i=(this._nextDeltaTime=this.spf)||e;this.emit("process",i)}}free(){super.free(),this.stop()}}Bo([U({default:24})],Zi.prototype,"fps"),Bo([U({default:1})],Zi.prototype,"speed");class Eo{constructor(){c(this,"view");c(this,"pixelRatio",ns);c(this,"screen",{x:0,y:0,width:0,height:0});c(this,"related",new SA)}getRelated(A,e){let t=this.related.get(A);return t||(e?(this.related.set(A,t=e()),t):(console.warn("Failed to get related",A),null))}resize(A,e,t=!0){const i=Math.floor(A*this.pixelRatio),s=Math.floor(e*this.pixelRatio),n=i/this.pixelRatio,o=s/this.pixelRatio;this.view&&(this.view.width=i,this.view.height=s),this.screen.width=n,this.screen.height=o,t&&this.view&&(this.view.style.width=`${n}px`,this.view.style.height=`${o}px`)}}var MA=(r=>(r.NORMAL="normal",r.ADD="add",r.MULTIPLY="multiply",r.SCREEN="screen",r.NONE="none",r.NORMAL_NPM="normal_npm",r.ADD_NPM="add_npm",r.SCREEN_NPM="screen_npm",r.SRC_IN="src_in",r.SRC_OUT="src_out",r.SRC_ATOP="src_atop",r.DST_OVER="dst_over",r.DST_IN="dst_in",r.DST_OUT="dst_out",r.DST_ATOP="dst_atop",r.XOR="xor",r.SUBTRACT="subtract",r))(MA||{});function po(r){return{normal:[r.ONE,r.ONE_MINUS_SRC_ALPHA],add:[r.ONE,r.ONE],multiply:[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],screen:[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],none:[0,0],normal_npm:[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],add_npm:[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],screen_npm:[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],src_in:[r.DST_ALPHA,r.ZERO],src_out:[r.ONE_MINUS_DST_ALPHA,r.ZERO],src_atop:[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],dst_over:[r.ONE_MINUS_DST_ALPHA,r.ONE],dst_in:[r.ZERO,r.SRC_ALPHA],dst_out:[r.ZERO,r.ONE_MINUS_SRC_ALPHA],dst_atop:[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],xor:[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],subtract:[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD]}}class dt{get gl(){return this._renderer.gl}install(A){this._renderer=A}onUpdateContext(){}flush(){}reset(){}free(){}}const Fr=class Fr{constructor(A){c(this,"_blendMode",MA.NORMAL);c(this,"_polygonOffset",0);c(this,"bitmap",0);if(A)for(const e in A)this[e]=A[e]}static _init(){this._properties.forEach((A,e)=>{Object.defineProperty(this.prototype,A,{get(){return!!(this.bitmap&1<<e)},set(t){!!(this.bitmap&1<<e)!==t&&(this.bitmap^=1<<e)},enumerable:!0,configurable:!0})})}static for2D(){const A=new Fr;return A.depthTest=!1,A.blend=!0,A}get blendMode(){return this._blendMode}set blendMode(A){this.blend=A!==MA.NONE,this._blendMode=A}get polygonOffset(){return this._polygonOffset}set polygonOffset(A){this.offsets=!!A,this._polygonOffset=A}};c(Fr,"_properties",["blend","offsets","culling","depthTest","clockwiseFrontFace","depthMask"]);let dA=Fr;dA._init();class Co extends dt{constructor(){super(...arguments);c(this,"_blendEq",!1);c(this,"_setters",dA._properties.map(e=>this[`set${e.replace(/^\S/,t=>t.toUpperCase())}`]));c(this,"boundStateBitmap",0);c(this,"boundBlendMode");c(this,"blendModes");c(this,"defaultState",new dA({blend:!0}))}install(e){super.install(e),e.state=this}onUpdateContext(){super.onUpdateContext(),this.blendModes=po(this._renderer.gl)}toggle(e,t){this._renderer.gl[t?"enable":"disable"](e)}setBlend(e){this.toggle(this._renderer.gl.BLEND,e)}setOffsets(e){this.toggle(this._renderer.gl.POLYGON_OFFSET_FILL,e)}setCulling(e){this.toggle(this._renderer.gl.CULL_FACE,e)}setDepthTest(e){this.toggle(this._renderer.gl.DEPTH_TEST,e)}setDepthMask(e){this._renderer.gl.depthMask(e)}setClockwiseFrontFace(e){const t=this._renderer.gl;t.frontFace(t[e?"CW":"CCW"])}setBlendMode(e){if(e===this.boundBlendMode)return;this.boundBlendMode=e;const t=this.blendModes[e],i=this._renderer.gl;t.length===2?i.blendFunc(t[0],t[1]):i.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,i.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(e,t){this._renderer.gl.polygonOffset(e,t)}bind(e){var t;if(this.boundStateBitmap!==e.bitmap){let i=this.boundStateBitmap^e.bitmap,s=0;for(;i;)i&1&&((t=this._setters[s])==null||t.call(this,!!(e.bitmap&1<<s))),i=i>>1,s++;this.boundStateBitmap=e.bitmap}e.blend&&this.setBlendMode(e.blendMode),e.offsets&&this.setPolygonOffset(1,e.polygonOffset)}reset(){super.reset();const e=this._renderer.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),this.bind(this.defaultState),this._blendEq=!0,this.setBlendMode(MA.NORMAL)}}class Qo extends dt{constructor(){super(...arguments);c(this,"_state",dA.for2D());c(this,"_batchSize",4096*4);c(this,"_drawCallUid",0);c(this,"_defaultModulate",4294967295);c(this,"_defaultBackgroundColor",0);c(this,"_defaultColorMatrixOffset",[0,0,0,0]);c(this,"_defaultColorMatrix",[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);c(this,"_batchables",[]);c(this,"_vertexCount",0);c(this,"_indexCount",0);c(this,"_attributeBuffer",[]);c(this,"_indexBuffers",[]);c(this,"_shaders",new Map);c(this,"_attributes",{aTextureId:{size:1,normalized:!0,type:"float"},aPosition:{size:2,normalized:!1,type:"float"},aUv:{size:2,normalized:!1,type:"float"},aModulate:{size:4,normalized:!0,type:"unsigned_byte"},aBackgroundColor:{size:4,normalized:!0,type:"unsigned_byte"},aDisableWrapMode:{size:4,normalized:!0,type:"float"},aColorMatrixOffset:{size:4,normalized:!1,type:"float"},aColorMatrix:{size:4,normalized:!1,type:"float"}});c(this,"_vertexSize",31)}install(e){super.install(e),e.batch2D=this}_getShader(e){let t=this._shaders.get(e);return t||this._shaders.set(e,t=this._createShader(e)),t}_createShader(e){const t=this._renderer,i=t.program.create({vert:`precision highp float;
|
|
1
|
+
(function(u,$e){typeof exports=="object"&&typeof module<"u"?$e(exports):typeof define=="function"&&define.amd?define(["exports"],$e):(u=typeof globalThis<"u"?globalThis:u||self,$e(u.modernCanvas={}))})(this,function(u){"use strict";var qI=Object.defineProperty;var XI=(u,$e,Lt)=>$e in u?qI(u,$e,{enumerable:!0,configurable:!0,writable:!0,value:Lt}):u[$e]=Lt;var c=(u,$e,Lt)=>XI(u,typeof $e!="symbol"?$e+"":$e,Lt);var DA,cA;var $e=typeof document<"u"?document.currentScript:null;const Lt=Math.PI,et=Lt*2;let $l=0;function Fn(r){var A;return((A=r==null?void 0:r.__SPECTOR_Object_TAG)==null?void 0:A.id)??++$l}function es(r){return!(r&r-1)&&!!r}const eg=/([\w-]+)\((.+?)\)/g,tg=/[^,]+/g,Ag=/([-e.\d]+)(.*)/;function ts(r){return Array.isArray(r)?r.map(A=>({name:A.name,args:A.args.map(e=>({...e,normalizedIntValue:e.normalizedDefaultIntValue}))})):{...r,normalizedIntValue:r.normalizedDefaultIntValue}}function ri(r,A,e={}){const t=si(A,e);return t.length?t:Tn(r,A,e)}function si(r,A={}){const e=[];let t;for(;(t=eg.exec(r))!==null;){const[,i,s]=t;i&&e.push({name:i,args:ig(i,s,A)})}return e}function ig(r,A,e={}){const t=[];let i,s=0;for(;(i=tg.exec(A))!==null;)t.push(Tn(r,i[0],{...e,index:s++}));return t}function Tn(r,A,e={}){const{width:t=1,height:i=1,index:s=0}=e,n=A.match(Ag),o={unit:(n==null?void 0:n[2])??null,value:A,intValue:Number(n==null?void 0:n[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(r){case"scale":case"scaleX":case"scaleY":case"scale3d":o.normalizedDefaultIntValue=1;break}switch(o.unit){case"%":o.normalizedIntValue=o.intValue/100;break;case"rad":o.normalizedIntValue=o.intValue/et;break;case"deg":o.normalizedIntValue=o.intValue/360;break;case"px":switch(s){case 0:o.normalizedIntValue=o.intValue/t;break;case 1:o.normalizedIntValue=o.intValue/i;break}break;case"turn":case"em":case"rem":default:o.normalizedIntValue=o.intValue;break}return o}const Ln="WebGL2RenderingContext"in globalThis,Gn="ImageBitmap"in globalThis,On="ResizeObserver"in globalThis,xA="PointerEvent"in globalThis,Hn="WheelEvent"in globalThis,rg="MouseEvent"in globalThis,Gt="ontouchstart"in globalThis,Jn="onclick"in globalThis,As="createImageBitmap"in globalThis,is="AudioContext"in globalThis,rs="webkitAudioContext"in globalThis,ss="OfflineAudioContext"in globalThis,Kn="webkitOfflineAudioContext"in globalThis,Yn=is||rs,ni=typeof window<"u",ns=globalThis.devicePixelRatio||1,os=r=>r!==null&&typeof r=="object"&&r.nodeType===1,Wn=r=>os(r)&&r.tagName==="VIDEO",sg=r=>os(r)&&r.tagName==="IMG";function Vn(r){return typeof r=="object"&&r!==null&&r.nodeType===1&&r.tagName==="CANVAS"}function zn(r){return Ln&&r instanceof globalThis.WebGL2RenderingContext}function qn(){if(ni)return globalThis.document.createElement("canvas")}function Xn(r,A=globalThis.location){if(r.startsWith("data:"))return"";A=A||globalThis.location;const e=new URL(r,document.baseURI);return e.hostname!==A.hostname||e.port!==A.port||e.protocol!==A.protocol?"anonymous":""}function jn(r,A,e){e===null&&!A.startsWith("data:")?r.crossOrigin=Xn(A):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}class SA{constructor(){c(this,"_map",new WeakMap)}_toRaw(A){if(A&&typeof A=="object"){const e=A.__v_raw;e&&(A=this._toRaw(e))}return A}delete(A){return this._map.delete(this._toRaw(A))}get(A){return this._map.get(this._toRaw(A))}has(A){return this._map.has(this._toRaw(A))}set(A,e){return this._map.set(this._toRaw(A),this._toRaw(e)),this}}const Zn=new SA;function Vi(r){let A=Zn.get(r);if(!A){const e=Object.getPrototypeOf(r);A=new Map(e?Vi(e):void 0),Zn.set(r,A)}return A}function oi(r,A,e={}){Vi(r).set(A,e);const{default:t,alias:i}=e;let s=Object.getOwnPropertyDescriptor(r.prototype,A);if(!s){const n=i??Symbol.for(String(A));s={get(){return this[n]},set(o){this[n]=o}}}Object.defineProperty(r.prototype,A,{get(){var n;return((n=s.get)==null?void 0:n.call(this))??t},set(n){var a,l,g;const o=((a=s.get)==null?void 0:a.call(this))??t;(l=s.set)==null||l.call(this,n),(g=this.requestUpdate)==null||g.call(this,A,o,e)},configurable:!0,enumerable:!0})}function U(r){return function(A,e){oi(A.constructor,e,r)}}const zi=new Map;function re(r,A){return function(e){Object.defineProperty(e.prototype,"tag",{value:r,enumerable:!0,configurable:!0}),A&&Object.keys(A).forEach(t=>{oi(e,t,{default:A[t]})}),zi.set(r,e)}}function Ee(r){return U({...r,protected:!0})}function ng(r="node",A={}){const e=zi.get(r);if(!e)throw new Error(`Failed to createNode, tag: ${r}`);return new e().setProperties(A)}class xe{static get currentTime(){return this._currentTime}static get elapsed(){return this._elapsed}static on(A,e={}){const{sort:t=0,once:i=!1}=e;this._queue[t]||(this._queue[t]=[]),this._queue[t].push({cb:A,once:i})}static off(A,e={}){const{sort:t=0}=e,i=this._queue[t];if(!i)return;const s=[];for(let n=i.length,o=0;o<n;o++){const a=i[o];a.cb!==A&&s.push(a)}s.length?this._queue[t]=s:this._queue.splice(t,1)}static start(){"requestAnimationFrame"in globalThis&&(this._currentTime=performance.now(),this._requestId=requestAnimationFrame(A=>this._update(A)))}static stop(){this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=void 0)}static _update(A){this._elapsed=A-this._currentTime,this._currentTime=A,this._requestId=requestAnimationFrame(e=>this._update(e)),this._performUpdate()}static _performUpdate(){const A=this._queue,e=[];for(let t=A.length,i=t;i>=0;i--){const s=A[i];if(!s)continue;const n=[];for(let o=s.length,a=0;a<o;a++){const l=s[a];try{l.cb()}catch(g){console.warn(g)}l.once||n.push(l)}n.length&&(e[i]=n)}this._queue=e}}c(xe,"_queue",[]),c(xe,"_currentTime",0),c(xe,"_elapsed",0),c(xe,"_requestId"),xe.start();async function as(r){return new Promise(A=>{xe.on(()=>{r==null||r(),A()},{sort:1,once:!0})})}let Ot=class{constructor(){c(this,"eventListeners",new Map)}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(A){return this.eventListeners.has(A)}on(A,e,t){const i={value:e,options:t},s=this.eventListeners.get(A);return s?Array.isArray(s)?s.push(i):this.eventListeners.set(A,[s,i]):this.eventListeners.set(A,i),this}once(A,e){return this.on(A,e,{once:!0})}off(A,e,t){var s,n;if(!e)return this.eventListeners.delete(A),this;const i=this.eventListeners.get(A);if(!i)return this;if(Array.isArray(i)){const o=[];for(let a=0,l=i.length;a<l;a++){const g=i[a];(g.value!==e||typeof t=="object"&&(t!=null&&t.once)&&(typeof g.options=="boolean"||!((s=g.options)!=null&&s.once)))&&o.push(g)}o.length?this.eventListeners.set(A,o.length===1?o[0]:o):this.eventListeners.delete(A)}else i.value===e&&(typeof t=="boolean"||!(t!=null&&t.once)||typeof i.options=="boolean"||(n=i.options)!=null&&n.once)&&this.eventListeners.delete(A);return this}emit(A,...e){var i,s;const t=this.eventListeners.get(A);if(t){if(Array.isArray(t))for(let n=t.length,o=0;o<n;o++){const a=t[o];typeof a.options=="object"&&((i=a.options)!=null&&i.once)&&this.off(A,a.value,a.options),a.value.apply(this,e)}else typeof t.options=="object"&&((s=t.options)!=null&&s.once)&&this.off(A,t.value,t.options),t.value.apply(this,e);return!0}else return!1}},og=0;class qi extends Ot{constructor(){super(...arguments);c(this,"instanceId",++og);c(this,"_defaultProperties");c(this,"_updatedProperties",new Map);c(this,"_changedProperties",new Set);c(this,"_updatingPromise",Promise.resolve());c(this,"_updating",!1)}is(e){return!!(e&&this.instanceId===e.instanceId)}async _enqueueUpdate(){this._updating=!0;try{await this._updatingPromise}catch(e){Promise.reject(e)}await as(),this._updating&&(this.update(),this._updating=!1)}update(){this._update(this._updatedProperties),this._updatedProperties=new Map}_update(e){}_updateProperty(e,t,i,s){}isDirty(e){return this._updatedProperties.has(e)}getPropertyDeclarations(){return Vi(this.constructor)}getPropertyDeclaration(e){return this.getPropertyDeclarations().get(e)}getDefaultProperties(){if(!this._defaultProperties){this._defaultProperties={};for(const[e,t]of this.getPropertyDeclarations())!t.protected&&!t.alias&&(this._defaultProperties[e]=t.default)}return this._defaultProperties}getProperty(e){return this[e]}setProperty(e,t){return this[e]=t,this}getProperties(e){const t={};for(const[i,s]of this.getPropertyDeclarations())!s.protected&&!s.alias&&(!e||e.includes(i))&&(t[i]=this.getProperty(i));return t}setProperties(e){if(e)for(const[t]of this.getPropertyDeclarations())t in e&&this.setProperty(t,e[t]);return this}requestUpdate(e,t,i){if(e!==void 0){const s=this[e];if(!Object.is(s,t))this._updatedProperties.set(e,t),this._changedProperties.add(e),i??(i=this.getPropertyDeclaration(e)),this._updateProperty(e,s,t,i),this.emit("updateProperty",e,s,t,i);else return}this._updating||(this._updatingPromise=this._enqueueUpdate())}toJSON(){return this.getProperties(Array.from(this._changedProperties))}clone(){return new this.constructor(this.toJSON())}free(){this.removeAllListeners()}}class $n extends qi{}class Xi{constructor(){c(this,"bubbles",!0);c(this,"cancelable",!1);c(this,"which");c(this,"cancelBubble",!0);c(this,"returnValue");c(this,"srcElement");c(this,"composed",!1);c(this,"currentTarget");c(this,"defaultPrevented",!1);c(this,"eventPhase",Xi.prototype.NONE);c(this,"isTrusted");c(this,"target");c(this,"timeStamp");c(this,"type");c(this,"nativeEvent");c(this,"originalEvent");c(this,"propagationStopped",!1);c(this,"propagationImmediatelyStopped",!1);c(this,"path");c(this,"detail");c(this,"view");c(this,"layer",{x:0,y:0});c(this,"page",{x:0,y:0});c(this,"NONE",0);c(this,"CAPTURING_PHASE",1);c(this,"AT_TARGET",2);c(this,"BUBBLING_PHASE",3)}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}initEvent(...A){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(...A){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}composedPath(){return this.path}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class ls extends Xi{constructor(){super(...arguments);c(this,"altKey");c(this,"button");c(this,"buttons");c(this,"ctrlKey");c(this,"metaKey");c(this,"relatedTarget");c(this,"shiftKey");c(this,"client",{x:0,y:0});c(this,"movement",{x:0,y:0});c(this,"offset",{x:0,y:0});c(this,"global",{x:0,y:0});c(this,"screen",{x:0,y:0})}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(...e){throw new Error("Method not implemented.")}}class eo extends ls{constructor(){super(...arguments);c(this,"width",0);c(this,"height",0);c(this,"isPrimary",!1);c(this,"pointerType");c(this,"pressure");c(this,"tangentialPressure");c(this,"tiltX");c(this,"tiltY");c(this,"twist")}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class ai extends ls{constructor(){super(...arguments);c(this,"deltaMode");c(this,"deltaX");c(this,"deltaY");c(this,"deltaZ");c(this,"DOM_DELTA_PIXEL",0);c(this,"DOM_DELTA_LINE",1);c(this,"DOM_DELTA_PAGE",2)}}c(ai,"DOM_DELTA_PIXEL",0),c(ai,"DOM_DELTA_LINE",1),c(ai,"DOM_DELTA_PAGE",2);const ag={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class to extends Ot{constructor(){super(...arguments);c(this,"target");c(this,"cursor","default");c(this,"cursorStyles",{default:"inherit",pointer:"pointer"});c(this,"setuped",!1);c(this,"event");c(this,"enableMoveEvent",!0);c(this,"enableWheelEvent",!0);c(this,"enableClickEvent",!0);c(this,"onPointerDown",e=>{if(Gt&&e.pointerType==="touch")return;const t=this.normalize(e);for(let i=0,s=t.length;i<s;i++)this.emit("pointerdown",this.event=this.clonePointerEvent(t[i]));this.setCursor(this.cursor)});c(this,"onPointerOver",e=>{if(!this.enableClickEvent||Gt&&e.pointerType==="touch")return;const t=this.normalize(e);for(let i=0,s=t.length;i<s;i++)this.emit("pointerover",this.event=this.clonePointerEvent(t[i]))});c(this,"onPointerMove",e=>{if(!this.enableMoveEvent||Gt&&e.pointerType==="touch")return;const t=this.normalize(e);for(let i=0,s=t.length;i<s;i++)this.emit("pointermove",this.event=this.clonePointerEvent(t[i]))});c(this,"onPointerUp",e=>{if(!this.enableClickEvent||Gt&&e.pointerType==="touch")return;let t=e.target;e.composedPath&&e.composedPath().length>0&&(t=e.composedPath()[0]);const i=t!==this.target?"outside":"",s=this.normalize(e);for(let n=0,o=s.length;n<o;n++){const a=this.clonePointerEvent(s[n]);a.type+=i,this.emit("pointerup",this.event=a)}});c(this,"onWheel",e=>{if(!this.enableWheelEvent)return;const t=this.normalize(e);for(let i=0,s=t.length;i<s;i++)this.emit("wheel",this.event=this.cloneWheelEvent(t[i]))})}setTarget(e){this.removeEventListeners(),this.target=e,this.addEventListeners()}removeEventListeners(){if(!this.setuped||!this.target)return;const e=this.target.style;globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):xA&&(e.touchAction=""),xA?(this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointerleave",this.onPointerOver),this.target.removeEventListener("pointerover",this.onPointerOver),this.target.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.target.ownerDocument.removeEventListener("pointerup",this.onPointerUp)):(this.target.removeEventListener("mousedown",this.onPointerDown),this.target.removeEventListener("mouseout",this.onPointerOver),this.target.removeEventListener("mouseover",this.onPointerOver),this.target.ownerDocument.removeEventListener("mousemove",this.onPointerMove),this.target.ownerDocument.removeEventListener("mouseup",this.onPointerUp)),Gt&&(this.target.removeEventListener("touchstart",this.onPointerDown),this.target.removeEventListener("touchmove",this.onPointerMove),this.target.removeEventListener("touchend",this.onPointerUp)),this.target.removeEventListener("wheel",this.onWheel),this.target=void 0,this.setuped=!1}addEventListeners(){if(this.setuped||!this.target)return;const e=this.target.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):xA&&(e.touchAction="none")),xA?(this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointerleave",this.onPointerOver),this.target.addEventListener("pointerover",this.onPointerOver),this.target.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.target.ownerDocument.addEventListener("pointerup",this.onPointerUp)):(this.target.addEventListener("mousedown",this.onPointerDown),this.target.addEventListener("mouseout",this.onPointerOver),this.target.addEventListener("mouseover",this.onPointerOver),this.target.ownerDocument.addEventListener("mousemove",this.onPointerMove),this.target.ownerDocument.addEventListener("mouseup",this.onPointerUp)),Gt&&(this.target.addEventListener("touchstart",this.onPointerDown),this.target.addEventListener("touchmove",this.onPointerMove),this.target.addEventListener("touchend",this.onPointerUp)),this.target.addEventListener("wheel",this.onWheel),this.setuped=!0}normalize(e){const t=[];if(Gt&&e instanceof globalThis.TouchEvent)for(let i=0,s=e.changedTouches.length;i<s;i++){const n=e.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.type=e.type,t.push(n)}else if(Hn&&e instanceof globalThis.WheelEvent)t.push(e);else if(xA&&e instanceof globalThis.PointerEvent)t.push(e);else{const i=e;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=1),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),t.push(i)}return t}cloneWheelEvent(e){const t=new ai;return this.copyMouseEvent(t,e),t.wheelDeltaY=e.wheelDeltaY,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.x=t.screen.x,t.global.y=t.screen.y,t.offset.x=t.screen.x,t.offset.y=t.screen.y,t.nativeEvent=e,t.type=e.type,t}clonePointerEvent(e){const t=new eo;return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,t.isTrusted=e.isTrusted,this.copyMouseEvent(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.x=t.screen.x,t.global.y=t.screen.y,t.offset.x=t.screen.x,t.offset.y=t.screen.y,t.type==="pointerleave"?t.type="pointerout":t.type.startsWith("mouse")?t.type=t.type.replace("mouse","pointer"):t.type.startsWith("touch")&&(t.type=ag[t.type]||t.type),t}copyMouseEvent(e,t){e.preventDefault=t.preventDefault.bind(t),e.stopPropagation=t.stopPropagation.bind(t),e.isTrusted=t.isTrusted,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}setCursor(e){if(!this.target||(e=e||"default",this.cursor===e))return;this.cursor=e;const t=!(globalThis.OffscreenCanvas&&this.target instanceof OffscreenCanvas),i=this.cursorStyles[e];if(i)switch(typeof i){case"string":t&&(this.target.style.cursor=i);break;case"function":i(e);break;case"object":t&&Object.assign(this.target.style,i);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.target.style.cursor=e)}mapPositionToPoint(e,t,i){if(!this.target)return;const s=Number(this.target.getAttribute("width"))||0,n=Number(this.target.getAttribute("height"))||0,o=Number(this.target.getAttribute("data-pixel-ratio"))||1,a=this.target.isConnected?this.target.getBoundingClientRect():{width:s,height:n,left:0,top:0},l=1/o;e.x=(t-a.left)*(s/a.width)*l,e.y=(i-a.top)*(n/a.height)*l}}class Ht extends $n{}var lg={grad:.9,turn:360,rad:360/(2*Math.PI)},Jt=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},Ue=function(r,A,e){return A===void 0&&(A=0),e===void 0&&(e=Math.pow(10,A)),Math.round(e*r)/e+0},ft=function(r,A,e){return A===void 0&&(A=0),e===void 0&&(e=1),r>e?e:r>A?r:A},Ao=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},io=function(r){return{r:ft(r.r,0,255),g:ft(r.g,0,255),b:ft(r.b,0,255),a:ft(r.a)}},gs=function(r){return{r:Ue(r.r),g:Ue(r.g),b:Ue(r.b),a:Ue(r.a,3)}},gg=/^#([0-9a-f]{3,8})$/i,ji=function(r){var A=r.toString(16);return A.length<2?"0"+A:A},ro=function(r){var A=r.r,e=r.g,t=r.b,i=r.a,s=Math.max(A,e,t),n=s-Math.min(A,e,t),o=n?s===A?(e-t)/n:s===e?2+(t-A)/n:4+(A-e)/n:0;return{h:60*(o<0?o+6:o),s:s?n/s*100:0,v:s/255*100,a:i}},so=function(r){var A=r.h,e=r.s,t=r.v,i=r.a;A=A/360*6,e/=100,t/=100;var s=Math.floor(A),n=t*(1-e),o=t*(1-(A-s)*e),a=t*(1-(1-A+s)*e),l=s%6;return{r:255*[t,o,n,n,a,t][l],g:255*[a,t,t,o,n,n][l],b:255*[n,n,a,t,t,o][l],a:i}},no=function(r){return{h:Ao(r.h),s:ft(r.s,0,100),l:ft(r.l,0,100),a:ft(r.a)}},oo=function(r){return{h:Ue(r.h),s:Ue(r.s),l:Ue(r.l),a:Ue(r.a,3)}},ao=function(r){return so((e=(A=r).s,{h:A.h,s:(e*=((t=A.l)<50?t:100-t)/100)>0?2*e/(t+e)*100:0,v:t+e,a:A.a}));var A,e,t},li=function(r){return{h:(A=ro(r)).h,s:(i=(200-(e=A.s))*(t=A.v)/100)>0&&i<200?e*t/100/(i<=100?i:200-i)*100:0,l:i/2,a:A.a};var A,e,t,i},hg=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,cg=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ug=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,fg=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hs={string:[[function(r){var A=gg.exec(r);return A?(r=A[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?Ue(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?Ue(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var A=ug.exec(r)||fg.exec(r);return A?A[2]!==A[4]||A[4]!==A[6]?null:io({r:Number(A[1])/(A[2]?100/255:1),g:Number(A[3])/(A[4]?100/255:1),b:Number(A[5])/(A[6]?100/255:1),a:A[7]===void 0?1:Number(A[7])/(A[8]?100:1)}):null},"rgb"],[function(r){var A=hg.exec(r)||cg.exec(r);if(!A)return null;var e,t,i=no({h:(e=A[1],t=A[2],t===void 0&&(t="deg"),Number(e)*(lg[t]||1)),s:Number(A[3]),l:Number(A[4]),a:A[5]===void 0?1:Number(A[5])/(A[6]?100:1)});return ao(i)},"hsl"]],object:[[function(r){var A=r.r,e=r.g,t=r.b,i=r.a,s=i===void 0?1:i;return Jt(A)&&Jt(e)&&Jt(t)?io({r:Number(A),g:Number(e),b:Number(t),a:Number(s)}):null},"rgb"],[function(r){var A=r.h,e=r.s,t=r.l,i=r.a,s=i===void 0?1:i;if(!Jt(A)||!Jt(e)||!Jt(t))return null;var n=no({h:Number(A),s:Number(e),l:Number(t),a:Number(s)});return ao(n)},"hsl"],[function(r){var A=r.h,e=r.s,t=r.v,i=r.a,s=i===void 0?1:i;if(!Jt(A)||!Jt(e)||!Jt(t))return null;var n=function(o){return{h:Ao(o.h),s:ft(o.s,0,100),v:ft(o.v,0,100),a:ft(o.a)}}({h:Number(A),s:Number(e),v:Number(t),a:Number(s)});return so(n)},"hsv"]]},lo=function(r,A){for(var e=0;e<A.length;e++){var t=A[e][0](r);if(t)return[t,A[e][1]]}return[null,void 0]},dg=function(r){return typeof r=="string"?lo(r.trim(),hs.string):typeof r=="object"&&r!==null?lo(r,hs.object):[null,void 0]},cs=function(r,A){var e=li(r);return{h:e.h,s:ft(e.s+100*A,0,100),l:e.l,a:e.a}},us=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},go=function(r,A){var e=li(r);return{h:e.h,s:e.s,l:ft(e.l+100*A,0,100),a:e.a}},fs=function(){function r(A){this.parsed=dg(A)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return Ue(us(this.rgba),2)},r.prototype.isDark=function(){return us(this.rgba)<.5},r.prototype.isLight=function(){return us(this.rgba)>=.5},r.prototype.toHex=function(){return A=gs(this.rgba),e=A.r,t=A.g,i=A.b,n=(s=A.a)<1?ji(Ue(255*s)):"","#"+ji(e)+ji(t)+ji(i)+n;var A,e,t,i,s,n},r.prototype.toRgb=function(){return gs(this.rgba)},r.prototype.toRgbString=function(){return A=gs(this.rgba),e=A.r,t=A.g,i=A.b,(s=A.a)<1?"rgba("+e+", "+t+", "+i+", "+s+")":"rgb("+e+", "+t+", "+i+")";var A,e,t,i,s},r.prototype.toHsl=function(){return oo(li(this.rgba))},r.prototype.toHslString=function(){return A=oo(li(this.rgba)),e=A.h,t=A.s,i=A.l,(s=A.a)<1?"hsla("+e+", "+t+"%, "+i+"%, "+s+")":"hsl("+e+", "+t+"%, "+i+"%)";var A,e,t,i,s},r.prototype.toHsv=function(){return A=ro(this.rgba),{h:Ue(A.h),s:Ue(A.s),v:Ue(A.v),a:Ue(A.a,3)};var A},r.prototype.invert=function(){return _t({r:255-(A=this.rgba).r,g:255-A.g,b:255-A.b,a:A.a});var A},r.prototype.saturate=function(A){return A===void 0&&(A=.1),_t(cs(this.rgba,A))},r.prototype.desaturate=function(A){return A===void 0&&(A=.1),_t(cs(this.rgba,-A))},r.prototype.grayscale=function(){return _t(cs(this.rgba,-1))},r.prototype.lighten=function(A){return A===void 0&&(A=.1),_t(go(this.rgba,A))},r.prototype.darken=function(A){return A===void 0&&(A=.1),_t(go(this.rgba,-A))},r.prototype.rotate=function(A){return A===void 0&&(A=15),this.hue(this.hue()+A)},r.prototype.alpha=function(A){return typeof A=="number"?_t({r:(e=this.rgba).r,g:e.g,b:e.b,a:A}):Ue(this.rgba.a,3);var e},r.prototype.hue=function(A){var e=li(this.rgba);return typeof A=="number"?_t({h:A,s:e.s,l:e.l,a:e.a}):Ue(e.h)},r.prototype.isEqual=function(A){return this.toHex()===_t(A).toHex()},r}(),_t=function(r){return r instanceof fs?r:new fs(r)},ho=[],Ig=function(r){r.forEach(function(A){ho.indexOf(A)<0&&(A(fs,hs),ho.push(A))})};function Bg(r,A){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},t={};for(var i in e)t[e[i]]=i;var s={};r.prototype.toName=function(n){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,a,l=t[this.toHex()];if(l)return l;if(n!=null&&n.closest){var g=this.toRgb(),h=1/0,f="black";if(!s.length)for(var I in e)s[I]=new r(e[I]).toRgb();for(var d in e){var C=(o=g,a=s[d],Math.pow(o.r-a.r,2)+Math.pow(o.g-a.g,2)+Math.pow(o.b-a.b,2));C<h&&(h=C,f=d)}return f}},A.string.push([function(n){var o=n.toLowerCase(),a=o==="transparent"?"#0000":e[o];return a?new r(a).toRgb():null},"name"])}Ig([Bg]);class Zt{get value(){return this._value}set value(A){if(A===void 0||this._value===A)return;this._value=A;let e;typeof A=="number"?e={r:A>>24&255,g:A>>16&255,b:A>>8&255,a:(A&255)/255}:e=A;const t=_t(e);t.isValid()?this._colord=t:console.warn(`Unable to convert color ${A}`)}get r8(){return this._colord.rgba.r}get g8(){return this._colord.rgba.g}get b8(){return this._colord.rgba.b}get a8(){return this._colord.rgba.a*255&255}get r(){return this.r8/255}get g(){return this.g8/255}get b(){return this.b8/255}get a(){return this._colord.rgba.a}get rgb(){return(this.r8<<16)+(this.g8<<8)+this.b8}get bgr(){return(this.b8<<16)+(this.g8<<8)+this.r8}get abgr(){return(this.a8<<24)+this.bgr}constructor(A=0){this.value=A}toArgb(A=this.a,e=!0){if(A===1)return(255<<24)+this.rgb;if(A===0)return e?0:this.rgb;let t=this.r8,i=this.g8,s=this.b8;return e&&(t=t*A+.5|0,i=i*A+.5|0,s=s*A+.5|0),(A*255<<24)+(t<<16)+(i<<8)+s}toHex(){return this._colord.toHex()}toArray(){return[this.r,this.g,this.b,this.a]}}class pt extends Ot{constructor(e){super();c(this,"_array",[]);this.dim=e}get length(){return this.dim}_operate(e,t,i){const{dim:s,_array:n}=this;let o;typeof t=="number"?o=Array.from({length:s},()=>t):t instanceof Dt||t instanceof pt?o=t.toArray():o=t;let a,l=[];if(i?i instanceof pt?a=i:l=i:a=this,t instanceof Dt){const{cols:g}=t;switch(e){case"*":for(let h=0;h<s;h++){let f=0;for(let I=0;I<s;I++)f+=n[h]*o[I*g+h];l[h]=f}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"+":for(let g=0;g<s;g++)l[g]=n[g]+o[g];break;case"-":for(let g=0;g<s;g++)l[g]=n[g]-o[g];break;case"*":for(let g=0;g<s;g++)l[g]=n[g]*o[g];break;case"/":for(let g=0;g<s;g++)l[g]=n[g]/o[g];break;case"rot":{const g=Math.cos(o[0]),h=Math.sin(o[0]);l[0]=n[0]*g-n[1]*h,l[1]=n[1]*g+n[0]*h;break}case"==":{let g=!0;for(let h=0;h<s;h++)g=g&&n[h]===o[h];return g}case"=":for(let g=0;g<s;g++){const h=o[g];h!==void 0&&(n[g]=h)}return this._onUpdate(n),this.emit("update",n),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Vector'`)}return(a==null?void 0:a.set(l))??l}add(e,t){return this._operate("+",e,t)}sub(e,t){return this._operate("-",e,t)}multiply(e,t){return this._operate("*",e,t)}divide(e,t){return this._operate("/",e,t)}rotate(e){return this._operate("rot",e)}set(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this._operate("=",e)}equals(e){return this._operate("==",e)}copy(e){return this.set(e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}_onUpdate(e){}toArray(){return this._array.slice()}toName(){return`Vector${this.dim}`}}class Dt extends Ot{constructor(e,t,i){super();c(this,"_array",[]);c(this,"dirtyId",0);this.rows=e,this.cols=t,i?this.set(i):this.identity()}get length(){return this.cols*this.rows}_operate(e,t,i){const{cols:s,rows:n,length:o,_array:a}=this;let l;typeof t=="number"?l=Array.from({length:o},()=>t):t instanceof pt||t instanceof Dt?l=t.toArray():l=t;let g,h=[];if(i?i instanceof pt||i instanceof Dt?g=i:h=i:t instanceof pt?g=new t.constructor:g=this,t instanceof pt){const{dim:f}=t;switch(e){case"*":for(let I=0;I<f;I++){let d=0;for(let C=0;C<s;C++)C<f&&(d+=a[I*s+C]*(l[C]??0));h[I]=d}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"*":for(let f=0;f<s;f++)for(let I=0;I<n;I++){const d=I*s;let C=0;for(let B=0;B<n;B++){const R=d+B,S=B*s+f;C+=a[R]*(l[S]??0)}h[d+f]=C}break;case"=":for(let f=0;f<o;f++){const I=l[f];I!==void 0&&(a[f]=I)}return this._onUpdate(a),this.emit("update",a),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Matrix2'`)}return(g==null?void 0:g.set(h))??h}identity(){const{cols:e,rows:t}=this,i=[];for(let s=0;s<e;s++)for(let n=0;n<t;n++){const o=n*e,a=s+o;i[a]=n+o===a?1:0}return this.set(i)}set(e){return this._operate("=",e)}copy(e){return this.set(e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}multiply(e,t){return this._operate("*",e,t)}_onUpdate(e){this.dirtyId++}toArray(e=!1){const{cols:t,rows:i,_array:s}=this;if(e){const n=[];for(let o=0;o<i;o++)for(let a=0;a<t;a++)n[o+a*t]=s[a+o*t];return n}return s.slice()}toName(){return`Matrix${this.rows}(${this.rows}x${this.cols})`}toJSON(){return this._array}}class co extends Dt{constructor(A){super(4,4,A)}}const uo=Lt/180,Eg=180/Lt;function bt(r,A,e){return Math.max(r,Math.min(A,e))}function Se(r,A,e){return(1-e)*r+e*A}const pg={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(r,A=20){if(!this.adaptive||!r||Number.isNaN(r))return A;let e=Math.ceil(r/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class fo extends pt{constructor(A=0,e=0,t=0,i=0){super(4),this.set([A,e,t,i])}}class ds extends Dt{constructor(A){super(4,5,A)}hueRotate(A=0){const e=Math.sin(A),t=Math.cos(A),i=.213,s=.715,n=.072;return this.multiply([i+t*(1-i)+e*-.213,s+t*-.715+e*-.715,n+t*-.072+e*(1-n),0,0,i+t*-.213+e*.143,s+t*(1-s)+e*.14,n+t*-.072+e*-.283,0,0,i+t*-.213+e*-.787,s+t*-.715+e*s,n+t*(1-n)+e*n,0,0,0,0,0,1,0])}saturate(A=1){const e=(A-1)*2/3+1,t=(e-1)*-.5;return this.multiply([e,t,t,0,0,t,e,t,0,0,t,t,e,0,0,0,0,0,1,0])}brightness(A=1){const e=A;return this.multiply([e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0])}contrast(A=1){const e=A,t=-128*(e-1);return this.multiply([e,0,0,0,t,0,e,0,0,t,0,0,e,0,t,0,0,0,1,0])}invert(A=1){const e=Se(1,-1,A),t=Se(0,255,A);return this.multiply([e,0,0,0,t,0,e,0,0,t,0,0,e,0,t,0,0,0,1,0])}sepia(A=1){const e=bt(0,A,1);return this.multiply([Se(1,.393,e),Se(0,.7689999,e),Se(0,.18899999,e),0,0,Se(0,.349,e),Se(1,.6859999,e),Se(0,.16799999,e),0,0,Se(0,.272,e),Se(0,.5339999,e),Se(1,.13099999,e),0,0,0,0,0,1,0])}opacity(A=1){return this.multiply([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,A,0])}grayscale(A=1){const e=bt(0,A,1),t=Se(1,.3,e),i=Se(0,.3,e),s=Se(1,.59,e),n=Se(0,.59,e),o=Se(1,.11,e),a=Se(0,.11,e);return this.multiply([t,n,a,0,0,i,s,a,0,0,i,n,o,0,0,0,0,0,1,0])}multiply(A){const e=A,t=this._array;return this.set([t[0]*e[0]+t[1]*e[5]+t[2]*e[10]+t[3]*e[15],t[0]*e[1]+t[1]*e[6]+t[2]*e[11]+t[3]*e[16],t[0]*e[2]+t[1]*e[7]+t[2]*e[12]+t[3]*e[17],t[0]*e[3]+t[1]*e[8]+t[2]*e[13]+t[3]*e[18],t[0]*e[4]+t[1]*e[9]+t[2]*e[14]+t[3]*e[19]+t[4],t[5]*e[0]+t[6]*e[5]+t[7]*e[10]+t[8]*e[15],t[5]*e[1]+t[6]*e[6]+t[7]*e[11]+t[8]*e[16],t[5]*e[2]+t[6]*e[7]+t[7]*e[12]+t[8]*e[17],t[5]*e[3]+t[6]*e[8]+t[7]*e[13]+t[8]*e[18],t[5]*e[4]+t[6]*e[9]+t[7]*e[14]+t[8]*e[19]+t[9],t[10]*e[0]+t[11]*e[5]+t[12]*e[10]+t[13]*e[15],t[10]*e[1]+t[11]*e[6]+t[12]*e[11]+t[13]*e[16],t[10]*e[2]+t[11]*e[7]+t[12]*e[12]+t[13]*e[17],t[10]*e[3]+t[11]*e[8]+t[12]*e[13]+t[13]*e[18],t[10]*e[4]+t[11]*e[9]+t[12]*e[14]+t[13]*e[19]+t[14],t[15]*e[0]+t[16]*e[5]+t[17]*e[10]+t[18]*e[15],t[15]*e[1]+t[16]*e[6]+t[17]*e[11]+t[18]*e[16],t[15]*e[2]+t[16]*e[7]+t[17]*e[12]+t[18]*e[17],t[15]*e[3]+t[16]*e[8]+t[17]*e[13]+t[18]*e[18],t[15]*e[4]+t[16]*e[9]+t[17]*e[14]+t[18]*e[19]+t[19]])}toMatrix4(){const A=this._array;return new co([A[0],A[1],A[2],A[3],A[5],A[6],A[7],A[8],A[10],A[11],A[12],A[13],A[15],A[16],A[17],A[18]])}toVector4(){const A=this._array;return new fo(A[4]/255,A[9]/255,A[14]/255,A[19]/255)}}class Cg extends Dt{constructor(A){super(2,2,A)}}let Is=class extends Dt{constructor(A){super(3,3,A)}invert(){const[A,e,t,i,s,n,o,a,l]=this._array,g=l*s-n*a,h=n*o-l*i,f=a*i-s*o,I=A*g+e*h+t*f;if(I===0)return this.set([0,0,0,0,0,0,0,0,0]);const d=1/I;return this.set([g*d,(t*a-l*e)*d,(n*e-t*s)*d,h*d,(l*A-t*o)*d,(t*i-n*A)*d,f*d,(e*o-a*A)*d,(s*A-e*i)*d])}};class Io extends Is{constructor(A=0,e=0,t=0,i=0,s=!1){super(),this._x=A,this._y=e,this._width=t,this._height=i,this._flipY=s,this._performUpdateArray()}flipY(A){return this._flipY!==A&&(this._flipY=A,this._performUpdateArray()),this}translate(A,e){return(this._x!==A||this._y!==e)&&(this._x=A,this._y=e,this._performUpdateArray()),this}resize(A,e){return(this._width!==A||this._height!==e)&&(this._width=A,this._height=e,this._performUpdateArray()),this}_performUpdateArray(){const A=this._width,e=this._height;if(!A||!e)return;const t=this._x,i=this._y,s=this._flipY?-1:1,n=1/A*2,o=s*(1/e*2),a=-1-t*n,l=-s-i*o;this.set([n,0,a,0,o,l,0,0,1])}}let Ct=class $r extends pt{get x(){return this._array[0]}set x(A){const[e,t]=this._array;e!==A&&this.set(A,t)}get y(){return this._array[1]}set y(A){const[e,t]=this._array;t!==A&&this.set(e,A)}get width(){return this.x}set width(A){this.x=A}get height(){return this.y}set height(A){this.y=A}get left(){return this.x}set left(A){this.x=A}get top(){return this.y}set top(A){this.y=A}constructor(A=0,e){super(2),this.set(typeof A=="number"?[A,e??A]:A)}update(A,e){const[t,i]=this._array;return(t!==A||i!==e)&&this.set(A,e),this}getLength(){const[A,e]=this._array;return Math.sqrt(A*A+e*e)}getAngle(){const[A,e]=this._array;return Math.atan2(-A,-e)+Math.PI}distanceTo(A){return Math.hypot(A.x-this.x,A.y-this.y)}normalize(){const[A,e]=this._array,t=1/(this.getLength()||1);return this.set(A*t,e*t),this}static lerp(A,e,t){return new $r(e).clone().sub(new $r(A)).multiply(t).add(new $r(A))}};class Bs{constructor(...A){c(this,"end",new Ct);c(this,"position");c(this,"size");const e=new Ct,t=new Ct;switch(A.length){case 0:break;case 1:e.set(A[0].position),t.set(A[0].size);break;case 2:e.set(A[0]),t.set(A[1]);break;default:e.set(A[0],A[1]),t.set(A[2],A[3]);break}this.update=this.update.bind(this),this.position=e.on("update",this.update),this.size=t.on("update",this.update),this.update()}get x(){return this.position.x}get y(){return this.position.y}get left(){return this.position.x}get top(){return this.position.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get width(){return this.size.x}get height(){return this.size.y}update(){return this.end.set(this.position.x+this.size.x,this.position.y+this.size.y),this}toArray(){return[this.x,this.y,this.width,this.height]}}const hA=class hA extends Is{premultiply(A){return A.multiply(this,this)}skewX(A){return this.skew(A,1)}skewY(A){return this.skew(1,A)}skew(A,e){return this.premultiply(hA._t2d.makeSkew(A,e))}makeSkew(A,e){const t=Math.cos(e),i=Math.sin(e),s=-Math.sin(-A),n=Math.cos(-A);return this.set([t,s,0,i,n,0,0,0,1]),this}translateX(A){return this.translate(A,0)}translateY(A){return this.translate(0,A)}translateZ(A){return this.translate(0,0,A)}translate3d(A,e,t){return this.translate(A,e,t)}translate(A,e,t=0){return this.premultiply(hA._t2d.makeTranslation(A,e,t))}makeTranslation(A,e,t=0){return this.set([1,0,A,0,1,e,0,0,1]),this}scaleX(A){return this.scale(A,1)}scaleY(A){return this.scale(1,A)}scale3d(A,e,t=1){return this.scale(A,e,t)}scale(A,e,t=1){return this.premultiply(hA._t2d.makeScale(A,e,t))}makeScale(A,e,t=1){return this.set([A,0,0,0,e,0,0,0,t]),this}rotateX(A){return this.scaleY(this._rotateToScale(A))}rotateY(A){return this.scaleX(this._rotateToScale(A))}rotateZ(A){return this.rotate(A)}rotate(A){return this.premultiply(hA._t2d.makeRotation(A))}rotate3d(A,e,t,i){const[s,n,o]=this._rotate3d(A,e,t,i);return s&&this.rotateX(s),n&&this.rotateY(n),o&&this.rotateZ(o),this}_rotateToScale(A){const e=A/et;return e<=.5?e*-4+1:(e-1)*4+1}_rotate3d(A,e,t,i){if(A===1&&e===0&&t===0)return[i,0,0];if(A===0&&e===1&&t===0)return[0,i,0];if(A===0&&e===0)return[0,0,i];{const s=Math.cos(i),n=Math.sin(i),o=s+A*A*(1-s),a=A*e*(1-s)-t*n,l=A*t*(1-s)+e*n,g=s+e*e*(1-s),h=e*t*(1-s)-A*n,f=s+t*t*(1-s),I=-Math.atan2(-h,g),d=-Math.atan2(l,Math.sqrt(h*h+f*f)),C=-Math.atan2(-a,o);return[I,d,C]}}makeRotation(A){const e=Math.cos(A),t=Math.sin(A);return this.set([e,-t,0,t,e,0,0,0,1]),this}applyToPoint(A,e){const{a:t,c:i,tx:s,b:n,d:o,ty:a}=this.toObject();return[t*A+i*e+s,n*A+o*e+a]}inverse(){return this.clone().invert()}isIdentity(){const{a:A,b:e,c:t,d:i,tx:s,ty:n}=this.toObject();return A===1&&e===0&&t===0&&i===1&&s===0&&n===0}toObject(){const[A,e,t,i,s,n,,,o]=this._array;return{a:A,c:e,tx:t,b:i,d:s,ty:n,tz:o}}};c(hA,"_t2d",new hA);let Qt=hA;class Qg extends pt{constructor(){super(3)}}var yg=Object.defineProperty,Bo=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&yg(A,e,i),i};class Zi extends qi{constructor(){super();c(this,"_starting",!1);c(this,"_nextDeltaTime",0);this._onNextTick=this._onNextTick.bind(this)}get starting(){return this._starting}get spf(){return this.fps?Math.floor(1e3/this.fps):0}start(e){this._starting||(this._starting=!0,this.off("process"),this.on("process",e),xe.on(this._onNextTick,{sort:0}))}stop(){this._starting&&(this._starting=!1,xe.off(this._onNextTick,{sort:0}))}_onNextTick(){const e=xe.elapsed*this.speed;if((this._nextDeltaTime-=e)<=0){const i=(this._nextDeltaTime=this.spf)||e;this.emit("process",i)}}free(){super.free(),this.stop()}}Bo([U({default:24})],Zi.prototype,"fps"),Bo([U({default:1})],Zi.prototype,"speed");class Eo{constructor(){c(this,"view");c(this,"pixelRatio",ns);c(this,"screen",{x:0,y:0,width:0,height:0});c(this,"related",new SA)}getRelated(A,e){let t=this.related.get(A);return t||(e?(this.related.set(A,t=e()),t):(console.warn("Failed to get related",A),null))}resize(A,e,t=!0){this.view&&(this.view.width=Math.floor(A*this.pixelRatio),this.view.height=Math.floor(e*this.pixelRatio)),this.screen.width=A,this.screen.height=e,t&&this.view&&(this.view.style.width=`${A}px`,this.view.style.height=`${e}px`)}}var MA=(r=>(r.NORMAL="normal",r.ADD="add",r.MULTIPLY="multiply",r.SCREEN="screen",r.NONE="none",r.NORMAL_NPM="normal_npm",r.ADD_NPM="add_npm",r.SCREEN_NPM="screen_npm",r.SRC_IN="src_in",r.SRC_OUT="src_out",r.SRC_ATOP="src_atop",r.DST_OVER="dst_over",r.DST_IN="dst_in",r.DST_OUT="dst_out",r.DST_ATOP="dst_atop",r.XOR="xor",r.SUBTRACT="subtract",r))(MA||{});function po(r){return{normal:[r.ONE,r.ONE_MINUS_SRC_ALPHA],add:[r.ONE,r.ONE],multiply:[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],screen:[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],none:[0,0],normal_npm:[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],add_npm:[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],screen_npm:[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],src_in:[r.DST_ALPHA,r.ZERO],src_out:[r.ONE_MINUS_DST_ALPHA,r.ZERO],src_atop:[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],dst_over:[r.ONE_MINUS_DST_ALPHA,r.ONE],dst_in:[r.ZERO,r.SRC_ALPHA],dst_out:[r.ZERO,r.ONE_MINUS_SRC_ALPHA],dst_atop:[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],xor:[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],subtract:[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD]}}class dt{get gl(){return this._renderer.gl}install(A){this._renderer=A}onUpdateContext(){}flush(){}reset(){}free(){}}const Fr=class Fr{constructor(A){c(this,"_blendMode",MA.NORMAL);c(this,"_polygonOffset",0);c(this,"bitmap",0);if(A)for(const e in A)this[e]=A[e]}static _init(){this._properties.forEach((A,e)=>{Object.defineProperty(this.prototype,A,{get(){return!!(this.bitmap&1<<e)},set(t){!!(this.bitmap&1<<e)!==t&&(this.bitmap^=1<<e)},enumerable:!0,configurable:!0})})}static for2D(){const A=new Fr;return A.depthTest=!1,A.blend=!0,A}get blendMode(){return this._blendMode}set blendMode(A){this.blend=A!==MA.NONE,this._blendMode=A}get polygonOffset(){return this._polygonOffset}set polygonOffset(A){this.offsets=!!A,this._polygonOffset=A}};c(Fr,"_properties",["blend","offsets","culling","depthTest","clockwiseFrontFace","depthMask"]);let dA=Fr;dA._init();class Co extends dt{constructor(){super(...arguments);c(this,"_blendEq",!1);c(this,"_setters",dA._properties.map(e=>this[`set${e.replace(/^\S/,t=>t.toUpperCase())}`]));c(this,"boundStateBitmap",0);c(this,"boundBlendMode");c(this,"blendModes");c(this,"defaultState",new dA({blend:!0}))}install(e){super.install(e),e.state=this}onUpdateContext(){super.onUpdateContext(),this.blendModes=po(this._renderer.gl)}toggle(e,t){this._renderer.gl[t?"enable":"disable"](e)}setBlend(e){this.toggle(this._renderer.gl.BLEND,e)}setOffsets(e){this.toggle(this._renderer.gl.POLYGON_OFFSET_FILL,e)}setCulling(e){this.toggle(this._renderer.gl.CULL_FACE,e)}setDepthTest(e){this.toggle(this._renderer.gl.DEPTH_TEST,e)}setDepthMask(e){this._renderer.gl.depthMask(e)}setClockwiseFrontFace(e){const t=this._renderer.gl;t.frontFace(t[e?"CW":"CCW"])}setBlendMode(e){if(e===this.boundBlendMode)return;this.boundBlendMode=e;const t=this.blendModes[e],i=this._renderer.gl;t.length===2?i.blendFunc(t[0],t[1]):i.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,i.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(e,t){this._renderer.gl.polygonOffset(e,t)}bind(e){var t;if(this.boundStateBitmap!==e.bitmap){let i=this.boundStateBitmap^e.bitmap,s=0;for(;i;)i&1&&((t=this._setters[s])==null||t.call(this,!!(e.bitmap&1<<s))),i=i>>1,s++;this.boundStateBitmap=e.bitmap}e.blend&&this.setBlendMode(e.blendMode),e.offsets&&this.setPolygonOffset(1,e.polygonOffset)}reset(){super.reset();const e=this._renderer.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),this.bind(this.defaultState),this._blendEq=!0,this.setBlendMode(MA.NORMAL)}}class Qo extends dt{constructor(){super(...arguments);c(this,"_state",dA.for2D());c(this,"_batchSize",4096*4);c(this,"_drawCallUid",0);c(this,"_defaultModulate",4294967295);c(this,"_defaultBackgroundColor",0);c(this,"_defaultColorMatrixOffset",[0,0,0,0]);c(this,"_defaultColorMatrix",[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);c(this,"_batchables",[]);c(this,"_vertexCount",0);c(this,"_indexCount",0);c(this,"_attributeBuffer",[]);c(this,"_indexBuffers",[]);c(this,"_shaders",new Map);c(this,"_attributes",{aTextureId:{size:1,normalized:!0,type:"float"},aPosition:{size:2,normalized:!1,type:"float"},aUv:{size:2,normalized:!1,type:"float"},aModulate:{size:4,normalized:!0,type:"unsigned_byte"},aBackgroundColor:{size:4,normalized:!0,type:"unsigned_byte"},aDisableWrapMode:{size:4,normalized:!0,type:"float"},aColorMatrixOffset:{size:4,normalized:!1,type:"float"},aColorMatrix:{size:4,normalized:!1,type:"float"}});c(this,"_vertexSize",31)}install(e){super.install(e),e.batch2D=this}_getShader(e){let t=this._shaders.get(e);return t||this._shaders.set(e,t=this._createShader(e)),t}_createShader(e){const t=this._renderer,i=t.program.create({vert:`precision highp float;
|
|
2
2
|
attribute float aTextureId;
|
|
3
3
|
attribute vec2 aPosition;
|
|
4
4
|
attribute vec2 aUv;
|
|
@@ -110,7 +110,7 @@ uniform sampler2D sampler;
|
|
|
110
110
|
uniform vec4 tint;
|
|
111
111
|
void main(void) {
|
|
112
112
|
gl_FragColor = texture2D(sampler, vUv) * tint;
|
|
113
|
-
}`,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])}})}}c(kA,"_instance");class fe extends $i{static get instance(){return this._instance??(this._instance=new this)}static draw(A,e=kA.instance,t){this.instance.draw(A,e,t)}constructor(){super({vertexAttributes:{position:new lt({buffer:new Kt({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new lt({buffer:new Kt({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new RA({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}c(fe,"_instance");class Rg extends $i{constructor(){const e=new Kt({data:new Float32Array,dynamic:!0}),t=new Kt({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new lt({buffer:e,size:2,normalized:!1,type:"float"}),uv:new lt({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new RA({data:new Uint16Array,dynamic:!0})});c(this,"positionBuffer");c(this,"uvBuffer");this.positionBuffer=e,this.uvBuffer=t}}var kg=Object.defineProperty,UA=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&kg(A,e,i),i};class ve extends Ht{constructor(e){super();c(this,"_isPowerOfTwo",!1);c(this,"_needsUpload",!1);this.source=e,this._updateSize()}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])})}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)}_glTextureOptions(e,t){let i=this.wrapMode;return e.version===1&&!this._isPowerOfTwo&&(i="clamp_to_edge"),{value:this.source,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:i,...t}}_glTexture(e,t){return e.getRelated(this,()=>e.texture.create(this._glTextureOptions(e,t)))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"width":case"height":this._updatePOT();break;case"source":this._updateSize();break;case"filterMode":case"wrapMode":case"pixelRatio":this.requestUpload();break}}_updatePOT(){this._isPowerOfTwo=es(this.realWidth)&&es(this.realHeight),this.requestUpload()}_updateSize(){const e=this.source;"pixels"in e?(this.width=e.width/this.pixelRatio,this.height=e.height/this.pixelRatio):(this.width=Number(e.naturalWidth||e.videoWidth||e.width||0)/this.pixelRatio,this.height=Number(e.naturalHeight||e.videoHeight||e.height||0)/this.pixelRatio),this.requestUpload()}requestUpload(){this._needsUpload=!0}upload(e,t){return this._needsUpload&&this.valid?(this._needsUpload=!1,e.texture.update(this._glTexture(e,t),this._glTextureOptions(e,t)),!0):!1}activate(e,t=0){return this.valid?(e.texture.bind({target:"texture_2d",value:this._glTexture(e,{location:t}),location:t}),this.upload(e,{location:t}),!0):!1}inactivate(e){e.texture.unbind(this._glTexture(e))}free(){Gn&&this.source instanceof ImageBitmap&&this.source.close()}}UA([Ee()],ve.prototype,"source"),UA([U({default:0})],ve.prototype,"width"),UA([U({default:0})],ve.prototype,"height"),UA([U({default:"linear"})],ve.prototype,"filterMode"),UA([U({default:"clamp_to_edge"})],ve.prototype,"wrapMode"),UA([U({default:1})],ve.prototype,"pixelRatio");class tr extends Ht{constructor(e){super();c(this,"frames");let t;if(Array.isArray(e))t=e;else if(e instanceof ve)t=[{texture:e,duration:0}];else throw new TypeError("Failed new AnimatedTexture");this.frames=t,this.updateDuration()}updateDuration(){return this.duration=this.frames.reduce((e,t)=>t.duration+e,0),this}free(){this.frames.forEach(e=>{e.texture.free()})}}var Ug=Object.defineProperty,Pg=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&Ug(A,e,i),i};class gi extends ve{constructor(A=document.createElement("canvas")){super(A)}_updateProperty(A,e,t,i){switch(A){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(A,e,t,i)}}Pg([U({default:2})],gi.prototype,"pixelRatio");class Cs extends ve{constructor(A){const e=new Zt(A);super({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])})}}function Ng(r){return{autoLoad:!!((r==null?void 0:r.autoLoad)??!0),useBitmap:!!((r==null?void 0:r.useBitmap)??!0)&&As,crossorigin:(r==null?void 0:r.crossorigin)??null}}class Fg extends ve{constructor(e,t){const i=Ng(t);super(e);c(this,"bitmap");c(this,"useBitmap");c(this,"preserveBitmap",!1);c(this,"_loadSource");c(this,"_loadBitmap");const s=e.src,n=s.includes(".svg")||s.startsWith("data:image/svg+xml");this.useBitmap=i.useBitmap&&!n,i.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(e=>{this._loadSource=void 0;const t=this.source,i=()=>{t.onload=null,t.onerror=null},s=()=>{i(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>e(this)):e(this)},n=o=>{i(),console.warn(`Failed to load ImageTexture, src: ${t.src}`,o),this.emit("error",o),e(this)};t.complete&&t.src?s():(t.onload=s,t.onerror=n)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!As)return Promise.resolve(this);const e=this.source,t=!e.crossOrigin||e.crossOrigin==="anonymous";return this._loadBitmap=fetch(e.src,{mode:t?"cors":"no-cors"}).then(i=>i.blob()).then(i=>createImageBitmap(i,0,0,e.width,e.height,{premultiplyAlpha:"premultiply"})).then(i=>(this.bitmap=i,this.requestUpload(),this._loadBitmap=void 0,this)).catch(i=>(console.warn("Failed to genBitmap",i),this)),this._loadBitmap}_glTextureOptions(e){return{...super._glTextureOptions(e),value:this.bitmap??this.source}}upload(e){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const i=this.source;if(ni&&i instanceof HTMLImageElement&&(!i.complete||i.naturalWidth===0))return!1}const t=super.upload(e);return this.preserveBitmap&&this.bitmap&&(this.bitmap.close(),this.bitmap=void 0),t}}class Qs extends ve{constructor(A,e=1,t=1){const i={width:e,height:t,pixels:null};A&&(ArrayBuffer.isView(A)?i.pixels=new Uint8Array(A.buffer):i.pixels=new Uint8Array(A)),super(i)}_updateProperty(A,e,t,i){switch(A){case"width":this.source.width=Math.round(e*this.pixelRatio);break;case"height":this.source.height=Math.round(e*this.pixelRatio);break}super._updateProperty(A,e,t,i)}}var Tg=Object.defineProperty,Lo=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&Tg(A,e,i),i};function Lg(r){return{autoLoad:!!((r==null?void 0:r.autoLoad)??!0),autoPlay:!!((r==null?void 0:r.autoPlay)??!1),fps:Number((r==null?void 0:r.fps)??0),crossorigin:(r==null?void 0:r.crossorigin)??null,loop:!!((r==null?void 0:r.loop)??!1),muted:!!((r==null?void 0:r.muted)??!1),playsinline:!!((r==null?void 0:r.playsinline)??!0)}}const ys=(DA=class extends ve{constructor(e,t){const i=Lg(t);if(!Wn(e)){typeof e=="string"&&(e=[e]);const s=e[0].src||e[0],n=document.createElement("video");i.autoLoad&&n.setAttribute("preload","auto"),i.playsinline&&(n.setAttribute("webkit-playsinline",""),n.setAttribute("playsinline","")),i.muted&&(n.setAttribute("muted",""),n.muted=!0),i.loop&&n.setAttribute("loop",""),i.autoPlay&&n.setAttribute("autoplay",""),jn(n,s,i.crossorigin);for(let o=0;o<e.length;++o){let{src:a,mime:l}=e[o];if(a=a||e[o],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),f=h.slice(h.lastIndexOf(".")+1);l=l||DA.mimeTypes.get(f)||`video/${f}`}const g=document.createElement("source");g.src=a,l&&(g.type=l),n.appendChild(g)}e=n}super(e);c(this,"_spf",0);c(this,"_autoPlay",!1);c(this,"_sourceLoad");c(this,"_nextTime",0);c(this,"_connected",!1);c(this,"_requestId");c(this,"_resolve");c(this,"_reject");c(this,"_onPlayStart",()=>{this.valid||this._onCanPlay(),this._setupAutoUpdate()});c(this,"_onPlayStop",()=>{this._setupAutoUpdate()});c(this,"_onCanPlay",()=>{const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this._nextTime=0,this._updateSize(),this.requestUpload(),this._nextTime=0,!t&&this._resolve&&(this._resolve(this),this._sourceLoad=void 0,this._resolve=void 0,this._reject=void 0),this.isPlaying?this._onPlayStart():this._autoPlay&&e.play()});c(this,"_onError",e=>{this.source.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=void 0,this._resolve=void 0)});c(this,"_onSeeked",()=>{this.autoUpdate&&!this.isPlaying&&(this._nextTime=0,this.requestUpload(),this._nextTime=0)});c(this,"_videoFrameRequestCallback",()=>{this.requestUpload(),this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)});c(this,"requestUpload",()=>{const e=Math.floor(xe.elapsed*this.source.playbackRate);this._nextTime-=e,(!this._spf||this._nextTime<=0)&&(super.requestUpload(),this._nextTime=this._spf||0)});this.fps=i.fps,this._autoPlay=i.autoPlay,i.autoPlay&&this.load(),this._setupAutoUpdate()}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(e){this.source.currentTime=e}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"fps":this._spf=t?Math.floor(1e3/t):0,this._setupAutoUpdate();break;case"autoUpdate":this._setupAutoUpdate();break}}_setupAutoUpdate(){this.autoUpdate&&this.isPlaying?!this.fps&&this.source.requestVideoFrameCallback?(this._connected&&(xe.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||(xe.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(xe.off(this.requestUpload),this._connected=!1,this._nextTime=0))}async load(){if(!this._sourceLoad){const e=this.source;(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this.isReady?this._onCanPlay():(e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlay),e.addEventListener("error",this._onError,!0)),this._sourceLoad=new Promise((t,i)=>{this.valid?(this._sourceLoad=void 0,t(this)):(this._resolve=t,this._reject=i,e.load())})}return this._sourceLoad}free(){this._setupAutoUpdate();const e=this.source;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load())}},c(DA,"mimeTypes",new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}))),DA);Lo([Ee({default:!0})],ys.prototype,"autoUpdate"),Lo([Ee({default:0})],ys.prototype,"fps");let Go=ys;class ms extends Qs{}var Gg=Object.defineProperty,Og=Object.getOwnPropertyDescriptor,BA=(r,A,e,t)=>{for(var i=t>1?void 0:t?Og(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Gg(A,e,i),i};const Oo={};function Hg(r){let A=Oo[r]??0;return A++,Oo[r]=A,A}u.Node=class extends qi{constructor(e,t=[]){super();c(this,"_readyed",!1);c(this,"_tree");c(this,"_parent");c(this,"_children",[]);c(this,"_meta",new Map);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.tag}:${Hg(this.tag)}`,...e}).append(t),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)}getName(){return this.name}setName(e){return this.name=e,this}get tree(){return this.getTree()}set tree(e){this.setTree(e)}getTree(){return this._tree}getViewport(){var e;return(e=this._tree)==null?void 0:e.getCurrentViewport()}getWindow(){var e;return(e=this._tree)==null?void 0:e.root}isInsideTree(){return!!this._tree}setTree(e){const t=this._tree;if(!(e!=null&&e.is(t))){t&&this.emit("treeExit",t),this._tree=e,e&&this.emit("treeEnter",e);for(let i=this._children.length,s=0;s<i;s++){const n=this._children[s];!e&&this.emit("childExitingTree",n),n.setTree(e),e&&this.emit("childEnteredTree",n)}e&&(this.emit("treePostEnter",e),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}get parent(){return this._parent}set parent(e){this.setParent(e)}hasParent(){return!!this._parent}getParent(){return this._parent}setParent(e){var t;if(!((t=this._parent)!=null&&t.is(e))){const i=this._parent;i&&this.emit("unparented",i),this._parent=e,e&&this.emit("parented",e),this.setTree(e==null?void 0:e._tree)}return this}get siblingIndex(){return this.getIndex()}set siblingIndex(e){var t;(t=this._parent)==null||t.moveChild(this,e)}get previousSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[this.getIndex()-1]}get nextSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[this.getIndex()+1]}get firstSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[0]}get lastSibling(){var t;const e=(t=this._parent)==null?void 0:t.getChildren();return e?e[e.length-1]:void 0}hasMeta(e){return this._meta.has(e)}getMeta(e,t){return this._meta.get(e)??t}setMeta(e,t){this._meta.set(e,t)}deleteMeta(e){this._meta.delete(e)}clearMeta(){this._meta.clear()}canProcess(){var e;if(!this._tree)return!1;switch(this.processMode){case"inherit":return((e=this._parent)==null?void 0:e.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(){var e;if(!this._tree)return!1;switch(this.renderMode){case"inherit":return((e=this._parent)==null?void 0:e.canRender())??!0;case"always":return!0;case"disabled":default:return!1}}_update(e){var t;(t=this._tree)==null||t.log(this.name,"updating"),super._update(e)}_updateProperty(e,t,i,s){var n;(n=this._tree)==null||n.log(this.name,`updating [${String(e)}]`),super._updateProperty(e,t,i,s)}_onTreeEnter(e){this._treeEnter(e),this.emit("treeEntered",e)}_onTreeExit(e){this.emit("treeExiting",e),this._treeExit(e),this.emit("treeExited",e)}_onParented(e){this._parented(e)}_onUnparented(e){this._unparented(e)}_onReady(){this._ready()}_onProcess(e=0){const t=this._tree,i=this.canRender(),s=this.canProcess(),n=[],o=[];for(let l=this._children.length,g=0;g<l;g++){const h=this._children[g];switch(h.processSortMode){case"default":o.push(h);break;case"parent_before":n.push(h);break}}n.forEach(l=>{l.emit("process",e)}),s&&(t==null||t.emit("nodeProcessing",this),this.emit("processing",e),this._process(e));let a;if(i){const l=t.renderStack.push(this);a=t.renderStack.currentCall,t.renderStack.currentCall=l}if(this.mask instanceof u.Node)this.getNode("__$mask")||(this.mask.processMode="disabled",this.appendChild(this.mask,"front"));else{const l=this.getNode("__$mask");l&&this.removeChild(l)}o.forEach(l=>{l.emit("process",e)}),i&&(t.renderStack.currentCall=a),s&&(this.emit("processed",e),t==null||t.emit("nodeProcessed",this))}render(e,t){const i=this.mask;i&&(e.flush(),e.mask.push(this,i)),this._render(e),t==null||t(),i&&(e.flush(),e.mask.pop(this))}input(e,t){for(let i=this._children.length-1;i>=0;i--)this._children[i].input(e,t);this._input(e,t)}getChildren(e=!1){switch(e){case!0:return this._children;case!1:return this._children.filter(t=>t.internalMode==="default");default:return this._children.filter(t=>t.internalMode===e)}}getIndex(e=!1){var t;return((t=this._parent)==null?void 0:t.getChildren(e).indexOf(this))??0}getNode(e){return this._children.find(t=>t.name===e)}removeNode(e){var t;(t=this.getNode(e))==null||t.remove()}addSibling(e){return this.is(e)||!this.hasParent()||e.hasParent()?this:(e.internalMode=this.internalMode,this._parent.moveChild(e,this.getIndex(!0)+1),this)}prepend(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{this.moveChild(i,0)})}append(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{this.appendChild(i)})}before(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{var s;(s=this._parent)==null||s.moveChild(i,this.getIndex(!0))})}after(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{var s;(s=this._parent)==null||s.moveChild(i,this.getIndex(!0)+1)})}insertBefore(e,t){return!t.hasParent()||!this.is(t.parent)||this.moveChild(e,t.getIndex(!0)),e}appendChild(e,t=e.internalMode){if(this.is(e)||e.hasParent())return e;switch(t){case"default":case"front":{const i=t==="default"?"back":"front",s=this._children.findIndex(n=>n.internalMode===i);s>-1?this._children.splice(s,0,e):this._children.push(e);break}case"back":this._children.push(e);break}return e.internalMode=t,e.setParent(this),this.emit("appendChild",e),e}moveChild(e,t,i=e.internalMode){if(this.is(e)||e.hasParent()&&!this.is(e.parent))return this;e.internalMode=i;const s=this._children.indexOf(e);let n=this._children.findIndex(l=>{switch(i){case"default":return l.internalMode!=="front";case"back":return l.internalMode==="back";case"front":default:return!0}});n=n>-1?n:Math.max(0,this._children.length-1);let o=this._children.slice(n).findIndex(l=>{switch(i){case"front":return l.internalMode!=="front";case"default":return l.internalMode==="back";case"back":default:return!1}});o=o>-1?n+o:Math.max(0,this._children.length);const a=bt(n,t>-1?t:o,o);return a!==s&&(s>-1&&this._children.splice(s,1),e.setParent(this),a>-1&&a<this._children.length?this._children.splice(a,0,e):this._children.push(e),s>-1?this.emit("moveChild",e,a,s):this.emit("appendChild",e)),this}removeChild(e){const t=e.getIndex(!0);return this.is(e.parent)&&t>-1&&(this._children.splice(t,1),e.setParent(void 0),this.emit("removeChild",e,t)),e}removeChildren(){this.getChildren().forEach(e=>this.removeChild(e))}remove(){var e;(e=this._parent)==null||e.removeChild(this)}forEach(e){return this.getChildren().forEach(e),this}deepForEach(e){return this.getChildren().forEach(t=>{e(t),t.deepForEach(e)}),this}_ready(){}_treeEnter(e){}_treeExit(e){}_parented(e){}_unparented(e){}_process(e){}_input(e,t){}_render(e){}clone(){return new this.constructor(this.toJSON().props,this.getChildren(!0))}toJSON(){return{tag:this.tag,props:{name:this.name,...super.toJSON()},meta:Object.fromEntries(this._meta.entries()),children:this.getChildren().map(e=>e.toJSON())}}static parse(e){if(Array.isArray(e))return e.map(a=>this.parse(a));const{tag:t,props:i,children:s}=e,n=zi.get(t)??u.Node,o=new n(i);return s==null||s.forEach(a=>o.appendChild(this.parse(a))),o}},BA([Ee()],u.Node.prototype,"name",2),BA([U()],u.Node.prototype,"mask",2),BA([U({default:"inherit"})],u.Node.prototype,"processMode",2),BA([U({default:"default"})],u.Node.prototype,"processSortMode",2),BA([U({default:"inherit"})],u.Node.prototype,"renderMode",2),BA([U({default:"default"})],u.Node.prototype,"internalMode",2),u.Node=BA([re("Node")],u.Node);var Jg=Object.defineProperty,Kg=Object.getOwnPropertyDescriptor,hi=(r,A,e,t)=>{for(var i=t>1?void 0:t?Kg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Jg(A,e,i),i};u.TimelineNode=class extends u.Node{constructor(e,t=[]){super();c(this,"computedDuration",0);c(this,"_currentTime",0);c(this,"_startTime",0);this.setProperties(e).append(t)}get timeline(){var e;return(e=this._tree)==null?void 0:e.timeline}get timelineCurrentTime(){var e;return((e=this.timeline)==null?void 0:e.currentTime)??0}get parentStartTime(){var e;return((e=this._parent)==null?void 0:e.startTime)??0}get currentTime(){return bt(0,this._currentTime,this.computedDuration)}get startTime(){return this._startTime}set startTime(e){this.delay=e-this.parentStartTime,this._updateCurrentTime(!0)}get endTime(){return this._startTime+this.computedDuration}get currentTimeProgress(){return this.computedDuration?bt(0,this._currentTime/this.computedDuration,1):0}isInsideTimeRange(){const e=this._currentTime;return this.computedDuration?e>=0&&e<=this.computedDuration:e>=0}_updateCurrentTime(e=!1){if(e||!this.paused){const t=this._parent;this._startTime=this.delay+this.parentStartTime,this.computedDuration=t!=null&&t.computedDuration?Math.min(this._startTime+this.duration,t.endTime)-this._startTime:this.duration,this._currentTime=this.timelineCurrentTime-this._startTime,this.emit("updateCurrentTime",this._currentTime),this.insideTimeRange=this.isInsideTimeRange()}}_process(e){super._process(e),this._updateCurrentTime()}},hi([U({default:0})],u.TimelineNode.prototype,"delay",2),hi([U({default:0})],u.TimelineNode.prototype,"duration",2),hi([U({default:!1})],u.TimelineNode.prototype,"paused",2),hi([Ee()],u.TimelineNode.prototype,"insideTimeRange",2),u.TimelineNode=hi([re("TimelineNode")],u.TimelineNode);var Yg=Object.defineProperty,Wg=Object.getOwnPropertyDescriptor,ci=(r,A,e,t)=>{for(var i=t>1?void 0:t?Wg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Yg(A,e,i),i};u.Viewport=class extends u.Node{constructor(e=!1){super();c(this,"_projection",new Io);c(this,"_framebufferIndex",0);c(this,"_framebuffers",[{texture:new ms,needsUpload:!1},{texture:new ms,needsUpload:!1}]);this.flipY=e,this._projection.flipY(e)}get valid(){return!!(this.width&&this.height)}get framebuffer(){return this._framebuffers[this._framebufferIndex]}get texture(){return this.framebuffer.texture}_glFramebufferOptions(e){const{width:t,height:i}=this,{pixelRatio:s}=e;return this._framebuffers.forEach(n=>{const o=n.texture;o.pixelRatio=s,o.width=t,o.height=i,o.upload(e)}),{width:t,height:i,colorTextures:[this.texture._glTexture(e)]}}_glFramebuffer(e){return e.getRelated(this.framebuffer,()=>e.framebuffer.create(this._glFramebufferOptions(e)))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){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(e=>e.needsUpload=!0)}resize(e,t){this.width=e,this.height=t}upload(e){const t=this.framebuffer;return t.needsUpload&&this.valid?(t.needsUpload=!1,e.framebuffer.update(this._glFramebuffer(e),this._glFramebufferOptions(e)),!0):!1}activate(e){var t;return this.valid?(e.flush(),(t=this._tree)==null||t.setCurrentViewport(this),this.upload(e),e.framebuffer.bind(this._glFramebuffer(e)),!0):!1}redraw(e,t){if(this.valid){e.flush();const i=this.framebuffer.texture;return this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(e),e.clear(),i.activate(e,0),t(),!0}return!1}activateWithCopy(e,t){this.resize(t.width,t.height),this.activate(e)&&(e.clear(),t.texture.activate(e,0),fe.draw(e,kA.instance,{sampler:0}))}render(e,t){var s,n;const i=(s=this._tree)==null?void 0:s.getCurrentViewport();this.activate(e),e.clear(),super.render(e,t),e.flush(),i?i.activate(e):(e.framebuffer.bind(null),(n=this._tree)==null||n.setCurrentViewport(void 0))}getRect(){return new Bs(this.x,this.y,this.width,this.height)}toProjectionArray(e=!1){return this._projection.toArray(e)}},ci([U({default:0})],u.Viewport.prototype,"x",2),ci([U({default:0})],u.Viewport.prototype,"y",2),ci([U({default:0})],u.Viewport.prototype,"width",2),ci([U({default:0})],u.Viewport.prototype,"height",2),u.Viewport=ci([re("Viewport")],u.Viewport);var Vg=Object.defineProperty,zg=Object.getOwnPropertyDescriptor,ui=(r,A,e,t)=>{for(var i=t>1?void 0:t?zg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Vg(A,e,i),i};u.Effect=class extends u.TimelineNode{constructor(e,t=[]){super();c(this,"viewport1",new u.Viewport);c(this,"viewport2",new u.Viewport);c(this,"_renderId",0);c(this,"_renderViewport");c(this,"_previousSibling");c(this,"_nextSibling");this._onProcessing=this._onProcessing.bind(this),this._onNodeProcessed=this._onNodeProcessed.bind(this),this.setProperties(e).append(t)}get _effectMode(){return this.effectMode??"parent"}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"glsl":{const n=new er(t);!this.effectMode&&n.has.transition&&(this.effectMode="transition"),this.material=n;break}case"glslSrc":{t?Nt.text.load(t).then(n=>this.glsl=n):this.glsl="";break}}}_treeEnter(e){e.on("processing",this._onProcessing),e.on("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(e),this.viewport2.setTree(e)}_treeExit(e){e.off("processing",this._onProcessing),e.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(e){var i;if(!this.canProcess()||!this.isInsideTimeRange())return;const t=(i=this._tree)==null?void 0:i.renderStack;if(t)switch(this._effectMode){case"transition":e.is(this._previousSibling)?(this._previousSibling=void 0,t.push(this)):e.is(this._nextSibling)&&(this._nextSibling=void 0,t.push(this));break}}_processParent(){var o,a;const e=(o=this._tree)==null?void 0:o.renderStack;if(!e)return;const t=(a=e.currentCall)==null?void 0:a.parentCall;if(!t)return;const i=t.calls;let s,n;i.forEach((l,g)=>{var h;(l.renderable.is(this._parent)||(h=l.renderable.parent)!=null&&h.is(this._parent))&&(s=s??g,n=g)}),!(s===void 0||n===void 0)&&(i.splice(n+1,0,e.createCall(this)),i.splice(s,0,e.createCall(this)))}_processChildren(){var e;this._children.length&&(super.emit("process"),(e=this._tree)==null||e.renderStack.push(this))}_onProcess(e=0){if(this.canProcess())switch(this._renderId=0,this._effectMode){case"before":super._onProcess(e);break;case"parent":this._processParent();break;case"children":this._processChildren();break}}_renderBefore(e){var i;const t=(i=this._tree)==null?void 0:i.getCurrentViewport();t&&this.apply(e,t,{redraw:!0})}_renderTransition(e){var t;if(this._renderId%2===0)this._renderViewport=(t=this._tree)==null?void 0:t.getCurrentViewport(),this._renderViewport&&(this.viewport1.activateWithCopy(e,this._renderViewport),this.viewport2.resize(this._renderViewport.width,this._renderViewport.height)),this.viewport2.activate(e),e.clear();else{const i=this._renderViewport;this._renderViewport=void 0,i&&(i.activate(e),e.clear(),this.viewport1.texture.activate(e,0),this.viewport2.texture.activate(e,1),this.apply(e,i,{from:this.viewport1,to:this.viewport2}),e.texture.unbind(0),e.texture.unbind(1))}}_renderParentOrChildren(e){var t;if(this._renderId%2===0)this._renderViewport=(t=this._tree)==null?void 0:t.getCurrentViewport(),this._renderViewport&&this.viewport1.resize(this._renderViewport.width,this._renderViewport.height),this.viewport1.activate(e),e.clear();else{const i=this._renderViewport;this._renderViewport=void 0,i&&(this.viewport1.activate(e),this.apply(e,this.viewport1,{redraw:!0,target:this._effectMode==="parent"?this._parent??void 0:void 0,targetArea:this._parseTargetArea()}),i.activate(e),this.viewport1.texture.activate(e,0),fe.draw(e))}}_parseTargetArea(){if(this._effectMode==="parent"&&this._parent&&"getRect"in this._parent){const e=this._parent.getRect();if(e)return[e.left/this.viewport1.width,e.top/this.viewport1.height,e.width/this.viewport1.width,e.height/this.viewport1.height]}}_render(e){switch(this._effectMode){case"before":this._renderBefore(e);break;case"transition":this._renderTransition(e);break;case"parent":case"children":default:this._renderParentOrChildren(e);break}this._renderId++}apply(e,t,i){this.material&&(i!=null&&i.redraw?t.redraw(e,()=>{fe.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:t.width/t.height})}):fe.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:i!=null&&i.from?i.from.width/i.from.height:0}))}},ui([Ee()],u.Effect.prototype,"material",2),ui([U()],u.Effect.prototype,"effectMode",2),ui([U({default:""})],u.Effect.prototype,"glsl",2),ui([U({default:""})],u.Effect.prototype,"glslSrc",2),u.Effect=ui([re("Effect")],u.Effect);var Ho=Object.defineProperty,qg=Object.getOwnPropertyDescriptor,Xg=(r,A,e)=>A in r?Ho(r,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[A]=e,ws=(r,A,e,t)=>{for(var i=t>1?void 0:t?qg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Ho(A,e,i),i},Jo=(r,A,e)=>Xg(r,typeof A!="symbol"?A+"":A,e);const jg=`attribute vec2 position;
|
|
113
|
+
}`,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])}})}}c(kA,"_instance");class fe extends $i{static get instance(){return this._instance??(this._instance=new this)}static draw(A,e=kA.instance,t){this.instance.draw(A,e,t)}constructor(){super({vertexAttributes:{position:new lt({buffer:new Kt({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new lt({buffer:new Kt({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new RA({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}c(fe,"_instance");class Rg extends $i{constructor(){const e=new Kt({data:new Float32Array,dynamic:!0}),t=new Kt({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new lt({buffer:e,size:2,normalized:!1,type:"float"}),uv:new lt({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new RA({data:new Uint16Array,dynamic:!0})});c(this,"positionBuffer");c(this,"uvBuffer");this.positionBuffer=e,this.uvBuffer=t}}var kg=Object.defineProperty,UA=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&kg(A,e,i),i};class ve extends Ht{constructor(e){super();c(this,"_isPowerOfTwo",!1);c(this,"_needsUpload",!1);this.source=e,this._updateSize()}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])})}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)}_glTextureOptions(e,t){let i=this.wrapMode;return e.version===1&&!this._isPowerOfTwo&&(i="clamp_to_edge"),{value:this.source,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:i,...t}}_glTexture(e,t){return e.getRelated(this,()=>e.texture.create(this._glTextureOptions(e,t)))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"width":case"height":this._updatePOT();break;case"source":this._updateSize();break;case"filterMode":case"wrapMode":case"pixelRatio":this.requestUpload();break}}_updatePOT(){this._isPowerOfTwo=es(this.realWidth)&&es(this.realHeight),this.requestUpload()}_updateSize(){const e=this.source;"pixels"in e?(this.width=e.width/this.pixelRatio,this.height=e.height/this.pixelRatio):(this.width=Number(e.naturalWidth||e.videoWidth||e.width||0)/this.pixelRatio,this.height=Number(e.naturalHeight||e.videoHeight||e.height||0)/this.pixelRatio),this.requestUpload()}requestUpload(){this._needsUpload=!0}upload(e,t){return this._needsUpload&&this.valid?(this._needsUpload=!1,e.texture.update(this._glTexture(e,t),this._glTextureOptions(e,t)),!0):!1}activate(e,t=0){return this.valid?(e.texture.bind({target:"texture_2d",value:this._glTexture(e,{location:t}),location:t}),this.upload(e,{location:t}),!0):!1}inactivate(e){e.texture.unbind(this._glTexture(e))}free(){Gn&&this.source instanceof ImageBitmap&&this.source.close()}}UA([Ee()],ve.prototype,"source"),UA([U({default:0})],ve.prototype,"width"),UA([U({default:0})],ve.prototype,"height"),UA([U({default:"linear"})],ve.prototype,"filterMode"),UA([U({default:"clamp_to_edge"})],ve.prototype,"wrapMode"),UA([U({default:1})],ve.prototype,"pixelRatio");class tr extends Ht{constructor(e){super();c(this,"frames");let t;if(Array.isArray(e))t=e;else if(e instanceof ve)t=[{texture:e,duration:0}];else throw new TypeError("Failed new AnimatedTexture");this.frames=t,this.updateDuration()}updateDuration(){return this.duration=this.frames.reduce((e,t)=>t.duration+e,0),this}free(){this.frames.forEach(e=>{e.texture.free()})}}var Ug=Object.defineProperty,Pg=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&Ug(A,e,i),i};class gi extends ve{constructor(A=document.createElement("canvas")){super(A)}_updateProperty(A,e,t,i){switch(A){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(A,e,t,i)}}Pg([U({default:2})],gi.prototype,"pixelRatio");class Cs extends ve{constructor(A){const e=new Zt(A);super({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])})}}function Ng(r){return{autoLoad:!!((r==null?void 0:r.autoLoad)??!0),useBitmap:!!((r==null?void 0:r.useBitmap)??!0)&&As,crossorigin:(r==null?void 0:r.crossorigin)??null}}class Fg extends ve{constructor(e,t){const i=Ng(t);super(e);c(this,"bitmap");c(this,"useBitmap");c(this,"preserveBitmap",!1);c(this,"_loadSource");c(this,"_loadBitmap");const s=e.src,n=s.includes(".svg")||s.startsWith("data:image/svg+xml");this.useBitmap=i.useBitmap&&!n,i.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(e=>{this._loadSource=void 0;const t=this.source,i=()=>{t.onload=null,t.onerror=null},s=()=>{i(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>e(this)):e(this)},n=o=>{i(),console.warn(`Failed to load ImageTexture, src: ${t.src}`,o),this.emit("error",o),e(this)};t.complete&&t.src?s():(t.onload=s,t.onerror=n)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!As)return Promise.resolve(this);const e=this.source,t=!e.crossOrigin||e.crossOrigin==="anonymous";return this._loadBitmap=fetch(e.src,{mode:t?"cors":"no-cors"}).then(i=>i.blob()).then(i=>createImageBitmap(i,0,0,e.width,e.height,{premultiplyAlpha:"premultiply"})).then(i=>(this.bitmap=i,this.requestUpload(),this._loadBitmap=void 0,this)).catch(i=>(console.warn("Failed to genBitmap",i),this)),this._loadBitmap}_glTextureOptions(e){return{...super._glTextureOptions(e),value:this.bitmap??this.source}}upload(e){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const i=this.source;if(ni&&i instanceof HTMLImageElement&&(!i.complete||i.naturalWidth===0))return!1}const t=super.upload(e);return this.preserveBitmap&&this.bitmap&&(this.bitmap.close(),this.bitmap=void 0),t}}class Qs extends ve{constructor(A,e=1,t=1){const i={width:e,height:t,pixels:null};A&&(ArrayBuffer.isView(A)?i.pixels=new Uint8Array(A.buffer):i.pixels=new Uint8Array(A)),super(i)}_updateProperty(A,e,t,i){switch(A){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(A,e,t,i)}}var Tg=Object.defineProperty,Lo=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&Tg(A,e,i),i};function Lg(r){return{autoLoad:!!((r==null?void 0:r.autoLoad)??!0),autoPlay:!!((r==null?void 0:r.autoPlay)??!1),fps:Number((r==null?void 0:r.fps)??0),crossorigin:(r==null?void 0:r.crossorigin)??null,loop:!!((r==null?void 0:r.loop)??!1),muted:!!((r==null?void 0:r.muted)??!1),playsinline:!!((r==null?void 0:r.playsinline)??!0)}}const ys=(DA=class extends ve{constructor(e,t){const i=Lg(t);if(!Wn(e)){typeof e=="string"&&(e=[e]);const s=e[0].src||e[0],n=document.createElement("video");i.autoLoad&&n.setAttribute("preload","auto"),i.playsinline&&(n.setAttribute("webkit-playsinline",""),n.setAttribute("playsinline","")),i.muted&&(n.setAttribute("muted",""),n.muted=!0),i.loop&&n.setAttribute("loop",""),i.autoPlay&&n.setAttribute("autoplay",""),jn(n,s,i.crossorigin);for(let o=0;o<e.length;++o){let{src:a,mime:l}=e[o];if(a=a||e[o],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),f=h.slice(h.lastIndexOf(".")+1);l=l||DA.mimeTypes.get(f)||`video/${f}`}const g=document.createElement("source");g.src=a,l&&(g.type=l),n.appendChild(g)}e=n}super(e);c(this,"_spf",0);c(this,"_autoPlay",!1);c(this,"_sourceLoad");c(this,"_nextTime",0);c(this,"_connected",!1);c(this,"_requestId");c(this,"_resolve");c(this,"_reject");c(this,"_onPlayStart",()=>{this.valid||this._onCanPlay(),this._setupAutoUpdate()});c(this,"_onPlayStop",()=>{this._setupAutoUpdate()});c(this,"_onCanPlay",()=>{const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this._nextTime=0,this._updateSize(),this.requestUpload(),this._nextTime=0,!t&&this._resolve&&(this._resolve(this),this._sourceLoad=void 0,this._resolve=void 0,this._reject=void 0),this.isPlaying?this._onPlayStart():this._autoPlay&&e.play()});c(this,"_onError",e=>{this.source.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=void 0,this._resolve=void 0)});c(this,"_onSeeked",()=>{this.autoUpdate&&!this.isPlaying&&(this._nextTime=0,this.requestUpload(),this._nextTime=0)});c(this,"_videoFrameRequestCallback",()=>{this.requestUpload(),this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)});c(this,"requestUpload",()=>{const e=Math.floor(xe.elapsed*this.source.playbackRate);this._nextTime-=e,(!this._spf||this._nextTime<=0)&&(super.requestUpload(),this._nextTime=this._spf||0)});this.fps=i.fps,this._autoPlay=i.autoPlay,i.autoPlay&&this.load(),this._setupAutoUpdate()}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(e){this.source.currentTime=e}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"fps":this._spf=t?Math.floor(1e3/t):0,this._setupAutoUpdate();break;case"autoUpdate":this._setupAutoUpdate();break}}_setupAutoUpdate(){this.autoUpdate&&this.isPlaying?!this.fps&&this.source.requestVideoFrameCallback?(this._connected&&(xe.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||(xe.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(xe.off(this.requestUpload),this._connected=!1,this._nextTime=0))}async load(){if(!this._sourceLoad){const e=this.source;(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this.isReady?this._onCanPlay():(e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlay),e.addEventListener("error",this._onError,!0)),this._sourceLoad=new Promise((t,i)=>{this.valid?(this._sourceLoad=void 0,t(this)):(this._resolve=t,this._reject=i,e.load())})}return this._sourceLoad}free(){this._setupAutoUpdate();const e=this.source;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load())}},c(DA,"mimeTypes",new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}))),DA);Lo([Ee({default:!0})],ys.prototype,"autoUpdate"),Lo([Ee({default:0})],ys.prototype,"fps");let Go=ys;class ms extends Qs{}var Gg=Object.defineProperty,Og=Object.getOwnPropertyDescriptor,BA=(r,A,e,t)=>{for(var i=t>1?void 0:t?Og(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Gg(A,e,i),i};const Oo={};function Hg(r){let A=Oo[r]??0;return A++,Oo[r]=A,A}u.Node=class extends qi{constructor(e,t=[]){super();c(this,"_readyed",!1);c(this,"_tree");c(this,"_parent");c(this,"_children",[]);c(this,"_meta",new Map);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.tag}:${Hg(this.tag)}`,...e}).append(t),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)}getName(){return this.name}setName(e){return this.name=e,this}get tree(){return this.getTree()}set tree(e){this.setTree(e)}getTree(){return this._tree}getViewport(){var e;return(e=this._tree)==null?void 0:e.getCurrentViewport()}getWindow(){var e;return(e=this._tree)==null?void 0:e.root}isInsideTree(){return!!this._tree}setTree(e){const t=this._tree;if(!(e!=null&&e.is(t))){t&&this.emit("treeExit",t),this._tree=e,e&&this.emit("treeEnter",e);for(let i=this._children.length,s=0;s<i;s++){const n=this._children[s];!e&&this.emit("childExitingTree",n),n.setTree(e),e&&this.emit("childEnteredTree",n)}e&&(this.emit("treePostEnter",e),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}get parent(){return this._parent}set parent(e){this.setParent(e)}hasParent(){return!!this._parent}getParent(){return this._parent}setParent(e){var t;if(!((t=this._parent)!=null&&t.is(e))){const i=this._parent;i&&this.emit("unparented",i),this._parent=e,e&&this.emit("parented",e),this.setTree(e==null?void 0:e._tree)}return this}get siblingIndex(){return this.getIndex()}set siblingIndex(e){var t;(t=this._parent)==null||t.moveChild(this,e)}get previousSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[this.getIndex()-1]}get nextSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[this.getIndex()+1]}get firstSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[0]}get lastSibling(){var t;const e=(t=this._parent)==null?void 0:t.getChildren();return e?e[e.length-1]:void 0}hasMeta(e){return this._meta.has(e)}getMeta(e,t){return this._meta.get(e)??t}setMeta(e,t){this._meta.set(e,t)}deleteMeta(e){this._meta.delete(e)}clearMeta(){this._meta.clear()}canProcess(){var e;if(!this._tree)return!1;switch(this.processMode){case"inherit":return((e=this._parent)==null?void 0:e.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(){var e;if(!this._tree)return!1;switch(this.renderMode){case"inherit":return((e=this._parent)==null?void 0:e.canRender())??!0;case"always":return!0;case"disabled":default:return!1}}_update(e){var t;(t=this._tree)==null||t.log(this.name,"updating"),super._update(e)}_updateProperty(e,t,i,s){var n;(n=this._tree)==null||n.log(this.name,`updating [${String(e)}]`),super._updateProperty(e,t,i,s)}_onTreeEnter(e){this._treeEnter(e),this.emit("treeEntered",e)}_onTreeExit(e){this.emit("treeExiting",e),this._treeExit(e),this.emit("treeExited",e)}_onParented(e){this._parented(e)}_onUnparented(e){this._unparented(e)}_onReady(){this._ready()}_onProcess(e=0){const t=this._tree,i=this.canRender(),s=this.canProcess(),n=[],o=[];for(let l=this._children.length,g=0;g<l;g++){const h=this._children[g];switch(h.processSortMode){case"default":o.push(h);break;case"parent_before":n.push(h);break}}n.forEach(l=>{l.emit("process",e)}),s&&(t==null||t.emit("nodeProcessing",this),this.emit("processing",e),this._process(e));let a;if(i){const l=t.renderStack.push(this);a=t.renderStack.currentCall,t.renderStack.currentCall=l}if(this.mask instanceof u.Node)this.getNode("__$mask")||(this.mask.processMode="disabled",this.appendChild(this.mask,"front"));else{const l=this.getNode("__$mask");l&&this.removeChild(l)}o.forEach(l=>{l.emit("process",e)}),i&&(t.renderStack.currentCall=a),s&&(this.emit("processed",e),t==null||t.emit("nodeProcessed",this))}render(e,t){const i=this.mask;i&&(e.flush(),e.mask.push(this,i)),this._render(e),t==null||t(),i&&(e.flush(),e.mask.pop(this))}input(e,t){for(let i=this._children.length-1;i>=0;i--)this._children[i].input(e,t);this._input(e,t)}getChildren(e=!1){switch(e){case!0:return this._children;case!1:return this._children.filter(t=>t.internalMode==="default");default:return this._children.filter(t=>t.internalMode===e)}}getIndex(e=!1){var t;return((t=this._parent)==null?void 0:t.getChildren(e).indexOf(this))??0}getNode(e){return this._children.find(t=>t.name===e)}removeNode(e){var t;(t=this.getNode(e))==null||t.remove()}addSibling(e){return this.is(e)||!this.hasParent()||e.hasParent()?this:(e.internalMode=this.internalMode,this._parent.moveChild(e,this.getIndex(!0)+1),this)}prepend(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{this.moveChild(i,0)})}append(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{this.appendChild(i)})}before(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{var s;(s=this._parent)==null||s.moveChild(i,this.getIndex(!0))})}after(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{var s;(s=this._parent)==null||s.moveChild(i,this.getIndex(!0)+1)})}insertBefore(e,t){return!t.hasParent()||!this.is(t.parent)||this.moveChild(e,t.getIndex(!0)),e}appendChild(e,t=e.internalMode){if(this.is(e)||e.hasParent())return e;switch(t){case"default":case"front":{const i=t==="default"?"back":"front",s=this._children.findIndex(n=>n.internalMode===i);s>-1?this._children.splice(s,0,e):this._children.push(e);break}case"back":this._children.push(e);break}return e.internalMode=t,e.setParent(this),this.emit("appendChild",e),e}moveChild(e,t,i=e.internalMode){if(this.is(e)||e.hasParent()&&!this.is(e.parent))return this;e.internalMode=i;const s=this._children.indexOf(e);let n=this._children.findIndex(l=>{switch(i){case"default":return l.internalMode!=="front";case"back":return l.internalMode==="back";case"front":default:return!0}});n=n>-1?n:Math.max(0,this._children.length-1);let o=this._children.slice(n).findIndex(l=>{switch(i){case"front":return l.internalMode!=="front";case"default":return l.internalMode==="back";case"back":default:return!1}});o=o>-1?n+o:Math.max(0,this._children.length);const a=bt(n,t>-1?t:o,o);return a!==s&&(s>-1&&this._children.splice(s,1),e.setParent(this),a>-1&&a<this._children.length?this._children.splice(a,0,e):this._children.push(e),s>-1?this.emit("moveChild",e,a,s):this.emit("appendChild",e)),this}removeChild(e){const t=e.getIndex(!0);return this.is(e.parent)&&t>-1&&(this._children.splice(t,1),e.setParent(void 0),this.emit("removeChild",e,t)),e}removeChildren(){this.getChildren().forEach(e=>this.removeChild(e))}remove(){var e;(e=this._parent)==null||e.removeChild(this)}forEach(e){return this.getChildren().forEach(e),this}deepForEach(e){return this.getChildren().forEach(t=>{e(t),t.deepForEach(e)}),this}_ready(){}_treeEnter(e){}_treeExit(e){}_parented(e){}_unparented(e){}_process(e){}_input(e,t){}_render(e){}clone(){return new this.constructor(this.toJSON().props,this.getChildren(!0))}toJSON(){return{tag:this.tag,props:{name:this.name,...super.toJSON()},meta:Object.fromEntries(this._meta.entries()),children:this.getChildren().map(e=>e.toJSON())}}static parse(e){if(Array.isArray(e))return e.map(a=>this.parse(a));const{tag:t,props:i,children:s}=e,n=zi.get(t)??u.Node,o=new n(i);return s==null||s.forEach(a=>o.appendChild(this.parse(a))),o}},BA([Ee()],u.Node.prototype,"name",2),BA([U()],u.Node.prototype,"mask",2),BA([U({default:"inherit"})],u.Node.prototype,"processMode",2),BA([U({default:"default"})],u.Node.prototype,"processSortMode",2),BA([U({default:"inherit"})],u.Node.prototype,"renderMode",2),BA([U({default:"default"})],u.Node.prototype,"internalMode",2),u.Node=BA([re("Node")],u.Node);var Jg=Object.defineProperty,Kg=Object.getOwnPropertyDescriptor,hi=(r,A,e,t)=>{for(var i=t>1?void 0:t?Kg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Jg(A,e,i),i};u.TimelineNode=class extends u.Node{constructor(e,t=[]){super();c(this,"computedDuration",0);c(this,"_currentTime",0);c(this,"_startTime",0);this.setProperties(e).append(t)}get timeline(){var e;return(e=this._tree)==null?void 0:e.timeline}get timelineCurrentTime(){var e;return((e=this.timeline)==null?void 0:e.currentTime)??0}get parentStartTime(){var e;return((e=this._parent)==null?void 0:e.startTime)??0}get currentTime(){return bt(0,this._currentTime,this.computedDuration)}get startTime(){return this._startTime}set startTime(e){this.delay=e-this.parentStartTime,this._updateCurrentTime(!0)}get endTime(){return this._startTime+this.computedDuration}get currentTimeProgress(){return this.computedDuration?bt(0,this._currentTime/this.computedDuration,1):0}isInsideTimeRange(){const e=this._currentTime;return this.computedDuration?e>=0&&e<=this.computedDuration:e>=0}_updateCurrentTime(e=!1){if(e||!this.paused){const t=this._parent;this._startTime=this.delay+this.parentStartTime,this.computedDuration=t!=null&&t.computedDuration?Math.min(this._startTime+this.duration,t.endTime)-this._startTime:this.duration,this._currentTime=this.timelineCurrentTime-this._startTime,this.emit("updateCurrentTime",this._currentTime),this.insideTimeRange=this.isInsideTimeRange()}}_process(e){super._process(e),this._updateCurrentTime()}},hi([U({default:0})],u.TimelineNode.prototype,"delay",2),hi([U({default:0})],u.TimelineNode.prototype,"duration",2),hi([U({default:!1})],u.TimelineNode.prototype,"paused",2),hi([Ee()],u.TimelineNode.prototype,"insideTimeRange",2),u.TimelineNode=hi([re("TimelineNode")],u.TimelineNode);var Yg=Object.defineProperty,Wg=Object.getOwnPropertyDescriptor,ci=(r,A,e,t)=>{for(var i=t>1?void 0:t?Wg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Yg(A,e,i),i};u.Viewport=class extends u.Node{constructor(e=!1){super();c(this,"_projection",new Io);c(this,"_framebufferIndex",0);c(this,"_framebuffers",[{texture:new ms,needsUpload:!1},{texture:new ms,needsUpload:!1}]);this.flipY=e,this._projection.flipY(e)}get valid(){return!!(this.width&&this.height)}get framebuffer(){return this._framebuffers[this._framebufferIndex]}get texture(){return this.framebuffer.texture}_glFramebufferOptions(e){const{width:t,height:i}=this,{pixelRatio:s}=e;return this._framebuffers.forEach(n=>{const o=n.texture;o.width=t,o.height=i,o.pixelRatio=s,o.upload(e)}),{width:t,height:i,colorTextures:[this.texture._glTexture(e)]}}_glFramebuffer(e){return e.getRelated(this.framebuffer,()=>e.framebuffer.create(this._glFramebufferOptions(e)))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){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(e=>e.needsUpload=!0)}resize(e,t){this.width=e,this.height=t}upload(e){const t=this.framebuffer;return t.needsUpload&&this.valid?(t.needsUpload=!1,e.framebuffer.update(this._glFramebuffer(e),this._glFramebufferOptions(e)),!0):!1}activate(e){var t;return this.valid?(e.flush(),(t=this._tree)==null||t.setCurrentViewport(this),this.upload(e),e.framebuffer.bind(this._glFramebuffer(e)),!0):!1}redraw(e,t){if(this.valid){e.flush();const i=this.framebuffer.texture;return this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(e),e.clear(),i.activate(e,0),t(),!0}return!1}activateWithCopy(e,t){this.resize(t.width,t.height),this.activate(e)&&(e.clear(),t.texture.activate(e,0),fe.draw(e,kA.instance,{sampler:0}))}render(e,t){var s,n;const i=(s=this._tree)==null?void 0:s.getCurrentViewport();this.activate(e),e.clear(),super.render(e,t),e.flush(),i?i.activate(e):(e.framebuffer.bind(null),(n=this._tree)==null||n.setCurrentViewport(void 0))}getRect(){return new Bs(this.x,this.y,this.width,this.height)}toProjectionArray(e=!1){return this._projection.toArray(e)}},ci([U({default:0})],u.Viewport.prototype,"x",2),ci([U({default:0})],u.Viewport.prototype,"y",2),ci([U({default:0})],u.Viewport.prototype,"width",2),ci([U({default:0})],u.Viewport.prototype,"height",2),u.Viewport=ci([re("Viewport")],u.Viewport);var Vg=Object.defineProperty,zg=Object.getOwnPropertyDescriptor,ui=(r,A,e,t)=>{for(var i=t>1?void 0:t?zg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Vg(A,e,i),i};u.Effect=class extends u.TimelineNode{constructor(e,t=[]){super();c(this,"viewport1",new u.Viewport);c(this,"viewport2",new u.Viewport);c(this,"_renderId",0);c(this,"_renderViewport");c(this,"_previousSibling");c(this,"_nextSibling");this._onProcessing=this._onProcessing.bind(this),this._onNodeProcessed=this._onNodeProcessed.bind(this),this.setProperties(e).append(t)}get _effectMode(){return this.effectMode??"parent"}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"glsl":{const n=new er(t);!this.effectMode&&n.has.transition&&(this.effectMode="transition"),this.material=n;break}case"glslSrc":{t?Nt.text.load(t).then(n=>this.glsl=n):this.glsl="";break}}}_treeEnter(e){e.on("processing",this._onProcessing),e.on("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(e),this.viewport2.setTree(e)}_treeExit(e){e.off("processing",this._onProcessing),e.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(e){var i;if(!this.canProcess()||!this.isInsideTimeRange())return;const t=(i=this._tree)==null?void 0:i.renderStack;if(t)switch(this._effectMode){case"transition":e.is(this._previousSibling)?(this._previousSibling=void 0,t.push(this)):e.is(this._nextSibling)&&(this._nextSibling=void 0,t.push(this));break}}_processParent(){var o,a;const e=(o=this._tree)==null?void 0:o.renderStack;if(!e)return;const t=(a=e.currentCall)==null?void 0:a.parentCall;if(!t)return;const i=t.calls;let s,n;i.forEach((l,g)=>{var h;(l.renderable.is(this._parent)||(h=l.renderable.parent)!=null&&h.is(this._parent))&&(s=s??g,n=g)}),!(s===void 0||n===void 0)&&(i.splice(n+1,0,e.createCall(this)),i.splice(s,0,e.createCall(this)))}_processChildren(){var e;this._children.length&&(super.emit("process"),(e=this._tree)==null||e.renderStack.push(this))}_onProcess(e=0){if(this.canProcess())switch(this._renderId=0,this._effectMode){case"before":super._onProcess(e);break;case"parent":this._processParent();break;case"children":this._processChildren();break}}_renderBefore(e){var i;const t=(i=this._tree)==null?void 0:i.getCurrentViewport();t&&this.apply(e,t,{redraw:!0})}_renderTransition(e){var t;if(this._renderId%2===0)this._renderViewport=(t=this._tree)==null?void 0:t.getCurrentViewport(),this._renderViewport&&(this.viewport1.activateWithCopy(e,this._renderViewport),this.viewport2.resize(this._renderViewport.width,this._renderViewport.height)),this.viewport2.activate(e),e.clear();else{const i=this._renderViewport;this._renderViewport=void 0,i&&(i.activate(e),e.clear(),this.viewport1.texture.activate(e,0),this.viewport2.texture.activate(e,1),this.apply(e,i,{from:this.viewport1,to:this.viewport2}),e.texture.unbind(0),e.texture.unbind(1))}}_renderParentOrChildren(e){var t;if(this._renderId%2===0)this._renderViewport=(t=this._tree)==null?void 0:t.getCurrentViewport(),this._renderViewport&&this.viewport1.resize(this._renderViewport.width,this._renderViewport.height),this.viewport1.activate(e),e.clear();else{const i=this._renderViewport;this._renderViewport=void 0,i&&(this.viewport1.activate(e),this.apply(e,this.viewport1,{redraw:!0,target:this._effectMode==="parent"?this._parent??void 0:void 0,targetArea:this._parseTargetArea()}),i.activate(e),this.viewport1.texture.activate(e,0),fe.draw(e))}}_parseTargetArea(){if(this._effectMode==="parent"&&this._parent&&"getRect"in this._parent){const e=this._parent.getRect();if(e)return[e.left/this.viewport1.width,e.top/this.viewport1.height,e.width/this.viewport1.width,e.height/this.viewport1.height]}}_render(e){switch(this._effectMode){case"before":this._renderBefore(e);break;case"transition":this._renderTransition(e);break;case"parent":case"children":default:this._renderParentOrChildren(e);break}this._renderId++}apply(e,t,i){this.material&&(i!=null&&i.redraw?t.redraw(e,()=>{fe.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:t.width/t.height})}):fe.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:i!=null&&i.from?i.from.width/i.from.height:0}))}},ui([Ee()],u.Effect.prototype,"material",2),ui([U()],u.Effect.prototype,"effectMode",2),ui([U({default:""})],u.Effect.prototype,"glsl",2),ui([U({default:""})],u.Effect.prototype,"glslSrc",2),u.Effect=ui([re("Effect")],u.Effect);var Ho=Object.defineProperty,qg=Object.getOwnPropertyDescriptor,Xg=(r,A,e)=>A in r?Ho(r,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[A]=e,ws=(r,A,e,t)=>{for(var i=t>1?void 0:t?qg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Ho(A,e,i),i},Jo=(r,A,e)=>Xg(r,typeof A!="symbol"?A+"":A,e);const jg=`attribute vec2 position;
|
|
114
114
|
attribute vec2 uv;
|
|
115
115
|
varying vec2 vUv[9];
|
|
116
116
|
uniform float strength;
|
|
@@ -773,7 +773,7 @@ void main() {
|
|
|
773
773
|
src: url(${e});
|
|
774
774
|
}`)),document.head.appendChild(t),this}_parseUrls(A){const e=Array.from(new Set([...A.split(","),A]));return Array.from(new Set(e.map(t=>this.familyToUrl.get(t.trim())??this.familyToUrl.get(t)??t)))}get(A){let e;return A&&(e=this._parseUrls(A).reduce((i,s)=>i||this.loaded.get(s),void 0)),e??this.fallbackFont}set(A,e){return this.familyToUrl.set(A,e.src),this.loaded.set(e.src,e),this}delete(A){return this._parseUrls(A).forEach(e=>{this.familyToUrl.delete(e),this.loaded.delete(e)}),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}async load(A,e={}){const{cancelOther:t,injectFontFace:i=!0,injectStyleTag:s=!0,...n}=e,{src:o}=A;if(this.loaded.has(o))return t&&(this.loading.forEach(f=>f.cancel()),this.loading.clear()),g(this.loaded.get(o));let a=this.loading.get(o);return a||(a=this._createRequest(o,n),this.loading.set(o,a)),t&&this.loading.forEach((f,I)=>{f!==a&&(f.cancel(),this.loading.delete(I))}),a.when.then(f=>{if(this.loaded.has(o))return g(this.loaded.get(o));{const I=h(f);return e.noAdd||this.loaded.set(A.src,I),I.familySet.forEach(d=>{this.familyToUrl.set(d,o),typeof document<"u"&&(i&&this.injectFontFace(d,f),s&&this.injectStyleTag(d,o))}),I}}).catch(f=>{if(f instanceof DOMException&&f.message==="The user aborted a request.")return h();throw f}).finally(()=>{this.loading.delete(o)});function l(){return A.family?Array.isArray(A.family)?A.family:[A.family]:[]}function g(f){return l().forEach(I=>{f.familySet.add(I)}),f}function h(f=new ArrayBuffer(0)){let I;function d(){return I||(I=f.byteLength?ul(f,!1):void 0),I}function C(){const B=d();if(B instanceof Et||B instanceof br)return B.sfnt}return{...A,buffer:f,familySet:new Set(l()),getFont:d,getSFNT:C}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(A=>A.when))}};c(Gr,"defaultRequestInit",{cache:"force-cache"});let xr=Gr;const fl=new xr,ed=Object.freeze(Object.defineProperty({__proto__:null,BaseFont:dr,get Cff(){return yA},get Cmap(){return qA},CmapSubtableFormat0:An,CmapSubtableFormat12:on,CmapSubtableFormat14:Fi,CmapSubtableFormat2:Ui,CmapSubtableFormat4:nn,CmapSubtableFormat6:wA,FontDataObject:ht,FontDataView:Fe,Fonts:xr,get Glyf(){return yr},Glyph:$s,GlyphSet:en,get Gpos(){return gn},get Gsub(){return Vt},get Head(){return Me},get Hhea(){return Ke},get Hmtx(){return mr},get Kern(){return hn},get Loca(){return wr},get Maxp(){return Le},get Name(){return XA},get Os2(){return ie},get Post(){return Bt},SFNT:QA,TTF:Et,TableDirectory:VA,get Vhea(){return Ye},get Vmtx(){return _r},WOFF:br,WOFFTableDirectoryEntry:_A,createCmapSegments:sn,dataTypeToByteLength:Mi,defineColumn:y,defineSFNTTable:Je,fonts:fl,parseFont:ul,parseSFNTFont:cl},Symbol.toStringTag,{value:"Module"}));function un(r,A,e){if(typeof A=="string"&&A.startsWith("linear-gradient")){const{x0:t,y0:i,x1:s,y1:n,stops:o}=td(A,e.left,e.top,e.width,e.height),a=r.createLinearGradient(t,i,s,n);return o.forEach(l=>a.addColorStop(l.offset,l.color)),a}return A}function Sr(r,A,e){r!=null&&r.color&&(r.color=un(e,r.color,A)),r!=null&&r.backgroundColor&&(r.backgroundColor=un(e,r.backgroundColor,A)),r!=null&&r.textStrokeColor&&(r.textStrokeColor=un(e,r.textStrokeColor,A))}function td(r,A,e,t,i){var I;const s=((I=r.match(/linear-gradient\((.+)\)$/))==null?void 0:I[1])??"",n=s.split(",")[0],o=n.includes("deg")?n:"0deg",a=s.replace(o,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+%)/gi),g=(Number(o.replace("deg",""))||0)*Math.PI/180,h=t*Math.sin(g),f=i*Math.cos(g);return{x0:A+t/2-h,y0:e+i/2+f,x1:A+t/2+h,y1:e+i/2-f,stops:Array.from(a).map(d=>{let C=d[2];return C.startsWith("(")?C=C.split(",").length>3?`rgba${C}`:`rgb${C}`:C=`#${C}`,{offset:Number(d[3].replace("%",""))/100,color:C}})}}function Gi(r){const{ctx:A,path:e,fontSize:t,clipRect:i}=r;A.save(),A.beginPath();const s=e.style,n={...s,fill:r.color??s.fill,stroke:r.textStrokeColor??s.stroke,strokeWidth:r.textStrokeWidth?r.textStrokeWidth*t:s.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round",shadowOffsetX:(r.shadowOffsetX??0)*t,shadowOffsetY:(r.shadowOffsetY??0)*t,shadowBlur:(r.shadowBlur??0)*t,shadowColor:r.shadowColor};i&&(A.rect(i.left,i.top,i.width,i.height),A.clip(),A.beginPath()),e.drawTo(A,n),A.restore()}function Ad(r,A,e){const{left:t,top:i,width:s,height:n}=e,o=r.canvas;o.dataset.viewBox=`${t} ${i} ${s} ${n}`,o.dataset.pixelRatio=String(A);const a=s,l=n;o.width=Math.max(1,Math.ceil(a*A)),o.height=Math.max(1,Math.ceil(l*A)),o.style.width=`${a}px`,o.style.height=`${l}px`,r.clearRect(0,0,o.width,o.height),r.scale(A,A),r.translate(-t,-i)}function id(r,A){const{paragraphs:e,computedStyle:t,glyphBox:i}=A;Sr(t,i,r),e.forEach(s=>{Sr(s.computedStyle,s.lineBox,r),s.fragments.forEach(n=>{Sr(n.computedStyle,n.inlineBox,r)})})}const rd=new Set(["©","®","÷"]),sd=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),nd={1:"italic",32:"bold"},od={1:"italic",2:"bold"},dl={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class ad{constructor(A,e,t){c(this,"path",new He);c(this,"lineBox",new ce);c(this,"inlineBox",new ce);c(this,"glyphBox");c(this,"advanceWidth",0);c(this,"advanceHeight",0);c(this,"underlinePosition",0);c(this,"underlineThickness",0);c(this,"strikeoutPosition",0);c(this,"strikeoutSize",0);c(this,"ascender",0);c(this,"descender",0);c(this,"typoAscender",0);c(this,"typoDescender",0);c(this,"typoLineGap",0);c(this,"winAscent",0);c(this,"winDescent",0);c(this,"xHeight",0);c(this,"capHeight",0);c(this,"baseline",0);c(this,"centerDiviation",0);c(this,"fontStyle");this.content=A,this.index=e,this.parent=t}get center(){var A;return(A=this.glyphBox)==null?void 0:A.center}get computedStyle(){return this.parent.computedStyle}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get fontSize(){return this.computedStyle.fontSize}get fontHeight(){return this.fontSize*this.computedStyle.lineHeight}_getFontSFNT(A){const e=this.computedStyle.fontFamily,t=A??fl,i=e?t.get(e):t.fallbackFont;return i==null?void 0:i.getSFNT()}updateGlyph(A=this._getFontSFNT()){if(!A)return this;const{hhea:e,os2:t,post:i,head:s}=A,n=s.unitsPerEm,o=e.ascent,a=e.descent,{content:l,computedStyle:g,isVertical:h}=this,{fontSize:f}=g,I=n/f,d=A.getAdvanceWidth(l,f),C=(o+Math.abs(a))/I,B=o/I;return this.advanceWidth=d,this.advanceHeight=C,this.inlineBox.width=h?C:d,this.inlineBox.height=h?d:C,this.underlinePosition=(o-i.underlinePosition)/I,this.underlineThickness=i.underlineThickness/I,this.strikeoutPosition=(o-t.yStrikeoutPosition)/I,this.strikeoutSize=t.yStrikeoutSize/I,this.ascender=o/I,this.descender=a/I,this.typoAscender=t.sTypoAscender/I,this.typoDescender=t.sTypoDescender/I,this.typoLineGap=t.sTypoLineGap/I,this.winAscent=t.usWinAscent/I,this.winDescent=t.usWinDescent/I,this.xHeight=t.sxHeight/I,this.capHeight=t.sCapHeight/I,this.baseline=B,this.centerDiviation=C/2-B,this.fontStyle=nd[t.fsSelection]??od[s.macStyle],this}update(A){const e=this._getFontSFNT(A);if(!e)return this;this.updateGlyph(e);const{isVertical:t,content:i,computedStyle:s,baseline:n,inlineBox:o,ascender:a,descender:l,typoAscender:g,fontStyle:h,advanceWidth:f,advanceHeight:I}=this,{left:d,top:C}=o,B=s.fontStyle==="italic"&&h!=="italic";let R=d,S=C+n,_;const M=new He;if(t&&(R+=(I-f)/2,Math.abs(f-I)>.1&&(S-=(a-g)/(a+Math.abs(l))*I),_=void 0),t&&!rd.has(i)&&(i.codePointAt(0)<=256||sd.has(i))){M.addCommands(e.getPathCommands(i,R,C+n-(I-f)/2,s.fontSize));const v={y:C-(I-f)/2+I/2,x:R+f/2};B&&this._italic(M,t?{x:v.x,y:C-(I-f)/2+n}:void 0),M.rotate(90,v)}else _!==void 0?(M.addCommands(e.glyphs.get(_).getPathCommands(R,S,s.fontSize)),B&&this._italic(M,t?{x:R+f/2,y:C+g/(a+Math.abs(l))*I}:void 0)):(M.addCommands(e.getPathCommands(i,R,S,s.fontSize)),B&&this._italic(M,t?{x:R+I/2,y:S}:void 0));const w=s.fontWeight??400;return w in dl&&(w===700||w==="bold")&&h!=="bold"&&M.bold(dl[w]*s.fontSize*.05),M.style={fill:s.color,stroke:s.textStrokeWidth?s.textStrokeColor:"none",strokeWidth:s.textStrokeWidth?s.textStrokeWidth*s.fontSize*.03:0},this.path=M,this.glyphBox=this.getGlyphBoundingBox(),this}_italic(A,e){A.skew(-.24,0,e||{y:this.inlineBox.top+this.baseline,x:this.inlineBox.left+this.inlineBox.width/2})}getGlyphMinMax(A,e,t){var i;if((i=this.path.curves[0])!=null&&i.curves.length)return this.path.getMinMax(A,e,t)}getGlyphBoundingBox(A){const e=this.getGlyphMinMax(void 0,void 0,A);if(!e)return;const{min:t,max:i}=e;return new ce(t.x,t.y,i.x-t.x,i.y-t.y)}drawTo(A,e={}){const t=this.computedStyle,i={ctx:A,path:this.path,fontSize:t.fontSize,color:t.color,...e};if(this.glyphBox)Gi(i);else{A.save(),A.beginPath();const s=this.path.style,n={...s,fill:i.color??s.fill,stroke:i.textStrokeColor??s.stroke,strokeWidth:i.textStrokeWidth?i.textStrokeWidth*i.fontSize:s.strokeWidth,shadowOffsetX:(i.shadowOffsetX??0)*i.fontSize,shadowOffsetY:(i.shadowOffsetY??0)*i.fontSize,shadowBlur:(i.shadowBlur??0)*i.fontSize,shadowColor:i.shadowColor};Ms(A,n),A.font=`${i.fontSize}px ${i.fontFamily}`,this.isVertical?(A.textBaseline="middle",A.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.inlineBox.height/2)):(A.textBaseline="alphabetic",A.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.baseline)),A.restore()}}}function fn(r,A){return typeof r=="number"?r:r.endsWith("%")?(r=r.substring(0,r.length-1),Math.ceil(Number(r)/100*A.total)):r.endsWith("rem")?(r=r.substring(0,r.length-3),Number(r)*A.fontSize):r.endsWith("em")?(r=r.substring(0,r.length-2),Number(r)*A.fontSize):Number(r)}function Il(r){const A=nA(r)?{}:r;return Object.keys(A).reduce((e,t)=>{let i=A[t];const s=Bl(t),n=Bl(i);return s&&(t=s),n&&(i=n),e[t]=i,e},{})}function nA(r){return!r||r==="none"}function ld(r,A){const e=Object.keys(r),t=Object.keys(A);return Array.from(new Set([...e,...t])).every(s=>jA(r[s],A[s]))}function jA(r,A){const e=typeof r;return e===typeof A?e==="object"?ld(r,A):r===A:!1}function Bl(r){const A=r.startsWith("#")?r.slice(1):r;if(!/^(?:[0-9A-F]{3}|[0-9A-F]{6})$/i.test(A))return null;const t=A.length===3?A.split("").map(o=>o+o).join(""):A,i=Number.parseInt(t.slice(0,2),16),s=Number.parseInt(t.slice(2,4),16),n=Number.parseInt(t.slice(4,6),16);return`rgb(${i}, ${s}, ${n})`}function dn(r){if(!r)return r;const A={};for(const e in r)r[e]!==""&&r[e]!==void 0&&(A[e]=r[e]);return A}function In(r){return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("blob://")}class gd{constructor(A,e={},t){c(this,"inlineBox",new ce);this.content=A,this.style=e,this.parent=t,this.updateComputedStyle().initCharacters()}get computedContent(){const A=this.computedStyle;return A.textTransform==="uppercase"?this.content.toUpperCase():A.textTransform==="lowercase"?this.content.toLowerCase():this.content}updateComputedStyle(){return this.computedStyle={...this.parent.computedStyle,...dn(this.style)},this}initCharacters(){const A=[];let e=0;for(const t of this.computedContent)A.push(new ad(t,e++,this));return this.characters=A,this}}class Oi{constructor(A,e){c(this,"lineBox",new ce);c(this,"fragments",[]);this.style=A,this.parentStyle=e,this.updateComputedStyle()}updateComputedStyle(){return this.computedStyle={...dn(this.parentStyle),...dn(this.style)},this}addFragment(A,e){const t=new gd(A,e,this);return this.fragments.push(t),t}}function jI(r){return r}const ti=class ti{_styleToDomStyle(A){const e={};for(const t in A){const i=A[t];ti.notZeroStyles.has(t)&&i===0||(typeof i=="number"&&ti.pxStyles.has(t)?e[t]=`${i}px`:e[t]=i)}return e}createParagraphDom(A,e){const t=document.createDocumentFragment(),i=document.createElement("section"),s={...e},n=e.writingMode.includes("horizontal");switch(e.textAlign){case"start":case"left":s.justifyContent="flex-start";break;case"center":s.justifyContent="center";break;case"end":case"right":s.justifyContent="flex-end";break}switch(e.verticalAlign){case"top":s.alignItems="flex-start";break;case"middle":s.alignItems="center";break;case"bottom":s.alignItems="flex-end";break}const o=!!(s.justifyContent||s.alignItems);Object.assign(i.style,{...this._styleToDomStyle({...s,boxSizing:s.boxSizing??"border-box",display:s.display??(o?"inline-flex":void 0),width:s.width??"max-content",height:s.height??"max-content"}),whiteSpace:"pre-wrap",wordBreak:"break-all",position:"fixed",visibility:"hidden"});const a=document.createElement("ul");return Object.assign(a.style,{verticalAlign:"inherit",listStyleType:"inherit",padding:"0",margin:"0",width:o&&n?"100%":void 0,height:o&&!n?"100%":void 0}),A.forEach(l=>{const g=document.createElement("li");Object.assign(g.style,{verticalAlign:"inherit",...this._styleToDomStyle(l.style)}),l.fragments.forEach(h=>{const f=document.createElement("span");Object.assign(f.style,{verticalAlign:"inherit",...this._styleToDomStyle(h.style)}),f.appendChild(document.createTextNode(h.content)),g.appendChild(f)}),a.appendChild(g)}),i.appendChild(a),t.appendChild(i),document.body.appendChild(t),{dom:i,destory:()=>{var l;return(l=i.parentNode)==null?void 0:l.removeChild(i)}}}measureDomText(A){const e=document.createRange();e.selectNodeContents(A);const t=A.data??"";let i=0;return Array.from(t).map(s=>{var h;const n=i+=t.substring(i).indexOf(s),o=n+s.length;i+=s.length,e.setStart(A,Math.max(n,0)),e.setEnd(A,o);const a=((h=e.getClientRects)==null?void 0:h.call(e))??[e.getBoundingClientRect()];let l=a[a.length-1];a.length>1&&l.width<2&&(l=a[a.length-2]);const g=e.toString();if(g!==""&&l&&l.width+l.height!==0)return{content:g,top:l.top,left:l.left,height:l.height,width:l.width}}).filter(Boolean)}measureDom(A){const e=[],t=[],i=[];return A.querySelectorAll("li").forEach((s,n)=>{const o=s.getBoundingClientRect();e.push({paragraphIndex:n,left:o.left,top:o.top,width:o.width,height:o.height}),s.querySelectorAll(":scope > *").forEach((a,l)=>{const g=a.getBoundingClientRect();t.push({paragraphIndex:n,fragmentIndex:l,left:g.left,top:g.top,width:g.width,height:g.height});let h=0;!a.children.length&&a.firstChild instanceof window.Text?this.measureDomText(a.firstChild).forEach(f=>{i.push({...f,newParagraphIndex:-1,paragraphIndex:n,fragmentIndex:l,characterIndex:h++,textWidth:-1,textHeight:-1})}):a.querySelectorAll(":scope > *").forEach(f=>{f.firstChild instanceof window.Text&&this.measureDomText(f.firstChild).forEach(I=>{i.push({...I,newParagraphIndex:-1,paragraphIndex:n,fragmentIndex:l,characterIndex:h++,textWidth:-1,textHeight:-1})})})})}),{paragraphs:e,fragments:t,characters:i}}measureParagraphDom(A,e){const t=e.getBoundingClientRect(),i=this.measureDom(e);i.paragraphs.forEach(o=>{const a=A[o.paragraphIndex];a.lineBox.left=o.left-t.left,a.lineBox.top=o.top-t.top,a.lineBox.width=o.width,a.lineBox.height=o.height}),i.fragments.forEach(o=>{const a=A[o.paragraphIndex].fragments[o.fragmentIndex];a.inlineBox.left=o.left-t.left,a.inlineBox.top=o.top-t.top,a.inlineBox.width=o.width,a.inlineBox.height=o.height});const s=[];let n=0;return i.characters.forEach(o=>{const{paragraphIndex:a,fragmentIndex:l,characterIndex:g}=o;s.push({...o,newParagraphIndex:a,left:o.left-t.left,top:o.top-t.top});const h=A[a].fragments[l].characters[g],{fontHeight:f,isVertical:I}=h,d=s[n];h.inlineBox.left=d.left,h.inlineBox.top=d.top,h.inlineBox.width=d.width,h.inlineBox.height=d.height,I?(h.lineBox.left=d.left+(d.width-f)/2,h.lineBox.top=d.top,h.lineBox.width=f,h.lineBox.height=d.height):(h.lineBox.left=d.left,h.lineBox.top=d.top+(d.height-f)/2,h.lineBox.width=d.width,h.lineBox.height=f),n++}),{paragraphs:A,boundingBox:new ce(0,0,t.width,t.height)}}measure(A,e,t){let i;t||({dom:t,destory:i}=this.createParagraphDom(A,e));const s=this.measureParagraphDom(A,t);return i==null||i(),s}};c(ti,"notZeroStyles",new Set(["width","height"])),c(ti,"pxStyles",new Set(["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur","marginLeft","marginTop","marginRight","marginBottom","paddingLeft","paddingTop","paddingRight","paddingBottom"]));let Bn=ti;class hd{constructor(){c(this,"eventListeners",new Map)}addEventListener(A,e,t){const i={value:e,options:t},s=this.eventListeners.get(A);return s?Array.isArray(s)?s.push(i):this.eventListeners.set(A,[s,i]):this.eventListeners.set(A,i),this}removeEventListener(A,e,t){var s,n;if(!e)return this.eventListeners.delete(A),this;const i=this.eventListeners.get(A);if(!i)return this;if(Array.isArray(i)){const o=[];for(let a=0,l=i.length;a<l;a++){const g=i[a];(g.value!==e||typeof t=="object"&&(t!=null&&t.once)&&(typeof g.options=="boolean"||!((s=g.options)!=null&&s.once)))&&o.push(g)}o.length?this.eventListeners.set(A,o.length===1?o[0]:o):this.eventListeners.delete(A)}else i.value===e&&(typeof t=="boolean"||!(t!=null&&t.once)||typeof i.options=="boolean"||(n=i.options)!=null&&n.once)&&this.eventListeners.delete(A);return this}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(A){return this.eventListeners.has(A)}dispatchEvent(A,e){var i,s;const t=this.eventListeners.get(A);if(t){if(Array.isArray(t))for(let n=t.length,o=0;o<n;o++){const a=t[o];typeof a.options=="object"&&((i=a.options)!=null&&i.once)&&this.off(A,a.value,a.options),a.value.apply(this,[e])}else typeof t.options=="object"&&((s=t.options)!=null&&s.once)&&this.off(A,t.value,t.options),t.value.apply(this,[e]);return!0}else return!1}on(A,e,t){return this.addEventListener(A,e,t)}once(A,e){return this.addEventListener(A,e,{once:!0})}off(A,e,t){return this.removeEventListener(A,e,t)}emit(A,e){this.dispatchEvent(A,e)}}function cd(){return{name:"background"}}function En(r){const{highlight:A,highlightImage:e,highlightReferImage:t,highlightColormap:i,highlightLine:s,highlightSize:n,highlightThickness:o}=r;return{image:(A==null?void 0:A.image)??e??"none",referImage:(A==null?void 0:A.referImage)??t??"none",colormap:(A==null?void 0:A.colormap)??i??"none",line:(A==null?void 0:A.line)??s??"none",size:(A==null?void 0:A.size)??n??"cover",thickness:(A==null?void 0:A.thickness)??o??"100%"}}function ud(){const r=[],A=[],e=new Map,t=new Map;async function i(n){if(!e.has(n)){e.set(n,n);try{e.set(n,await fetch(n).then(o=>o.text()))}catch(o){console.warn(o),e.delete(n)}}}function s(n){let o=t.get(n);if(!o){const a=va(In(n)?e.get(n)??n:n),l=Sa(a);o={dom:a,pathSet:l},t.set(n,o)}return o}return{name:"highlight",paths:r,load:async n=>{const o=new Set;n.forEachCharacter(a=>{const{computedStyle:l}=a,{image:g,referImage:h}=En(l);In(g)&&o.add(g),In(h)&&o.add(h)}),await Promise.all(Array.from(o).map(a=>i(a)))},update:n=>{A.length=0,r.length=0;let o=[],a,l;n.forEachCharacter(g=>{const{computedStyle:h}=g,f=En(h),{image:I,colormap:d,line:C,size:B,thickness:R}=f;if(nA(I))a!=null&&a.length&&(a=[],o.push(a));else{const{inlineBox:S,isVertical:_}=g,{fontSize:M}=h;(!l||jA(l.image,I)&&jA(l.colormap,d)&&jA(l.line,C)&&jA(l.size,B)&&jA(l.thickness,R))&&(a!=null&&a.length)&&(_?a[0].inlineBox.left===S.left:a[0].inlineBox.top===S.top)&&a[0].fontSize===M?a.push(g):(a=[],a.push(g),o.push(a))}l=f}),o=o.filter(g=>g.length);for(let g=0;g<o.length;g++){const h=o[g],f=h[0],I=ce.from(...h.filter(H=>H.glyphBox).map(H=>H.glyphBox)),{computedStyle:d}=f,{fontSize:C,writingMode:B}=d,{image:R,referImage:S,colormap:_,line:M,size:w,thickness:v}=En(d),D=B.includes("vertical"),x=fn(v,{fontSize:C,total:I.width})/I.width,L=Il(_),{pathSet:j,dom:Y}=s(R),T=j.getBoundingBox(!0),$=C/T.width*2,P=new ce().copy(I);D&&(P.width=I.height,P.height=I.width,P.left=I.left+I.width);const X=Math.floor(P.width);let ee=X;if(w!=="cover"&&(ee=fn(w,{fontSize:C,total:I.width})||X,P.width=ee),!nA(S)&&nA(M)){const H=s(S).pathSet.getBoundingBox(!0);T.copy(H)}else{let H;if(nA(M))if(T.width/T.height>4){H="underline";const ne=Y.getAttribute("viewBox");if(ne){const[q,W,oe,te]=ne.split(" ").map(Ae=>Number(Ae)),ae=W+te/2;T.y<ae&&T.y+T.height>ae?H="line-through":T.y+T.height<ae?H="overline":H="underline"}}else H="outline";else H=M;switch(H){case"outline":{const ne=P.width*.2,q=P.height*.2;P.width+=ne,P.height+=q,D?(P.x-=q/2,P.y-=ne/2,P.x+=P.height):(P.x-=ne/2,P.y-=q/2);break}case"overline":P.height=T.height*$,D?P.x=f.inlineBox.left+f.inlineBox.width:P.y=f.inlineBox.top;break;case"line-through":P.height=T.height*$,D?P.x=f.inlineBox.left+f.inlineBox.width-f.strikeoutPosition+P.height/2:P.y=f.inlineBox.top+f.strikeoutPosition-P.height/2;break;case"underline":P.height=T.height*$,D?P.x=f.inlineBox.left+f.inlineBox.width-f.underlinePosition:P.y=f.inlineBox.top+f.underlinePosition;break}}const J=new ot().translate(-T.x,-T.y).scale(P.width/T.width,P.height/T.height);D&&J.rotate(-Math.PI/2),J.translate(P.x,P.y);for(let H=0;H<Math.ceil(X/ee);H++){const ne=J.clone();D?ne.translate(0,H*P.width):ne.translate(H*P.width,0),j.paths.forEach(q=>{const W=q.clone().applyTransform(ne);W.style.strokeWidth&&(W.style.strokeWidth*=$*x),W.style.strokeMiterlimit&&(W.style.strokeMiterlimit*=$),W.style.strokeDashoffset&&(W.style.strokeDashoffset*=$),W.style.strokeDasharray&&(W.style.strokeDasharray=W.style.strokeDasharray.map(oe=>oe*$)),W.style.fill&&W.style.fill in L&&(W.style.fill=L[W.style.fill]),W.style.stroke&&W.style.stroke in L&&(W.style.stroke=L[W.style.stroke]),r.push(W),X!==ee&&(D?A[r.length-1]=new ce(I.left-I.width*2,I.top,I.width*4,I.height):A[r.length-1]=new ce(I.left,I.top-I.height*2,I.width,I.height*4))})}}},renderOrder:-1,render:(n,o)=>{r.forEach((a,l)=>{if(Gi({ctx:n,path:a,fontSize:o.computedStyle.fontSize,clipRect:A[l]}),o.debug){const g=new Ts([a]).getBoundingBox();g&&n.strokeRect(g.x,g.y,g.width,g.height)}})}}}function fd(r,A){return`<svg width="${r*2}" height="${r*2}" xmlns="http://www.w3.org/2000/svg">
|
|
775
775
|
<circle cx="${r}" cy="${r}" r="${r}" fill="${A}" />
|
|
776
|
-
</svg>`}function dd(){const r=[];return{name:"listStyle",paths:r,update:A=>{r.length=0;const{paragraphs:e,isVertical:t,fontSize:i}=A,s=i*.45;e.forEach(n=>{const{computedStyle:o}=n,{color:a,listStyleImage:l,listStyleColormap:g,listStyleSize:h,listStyleType:f}=o,I=Il(g);let d=h,C;if(!nA(l))C=l;else if(!nA(f)){const _=i*.38/2;switch(d=d==="cover"?_*2:d,f){case"disc":C=fd(_,String(a));break}}if(!C)return;const B=Sa(C),R=B.getBoundingBox();let S;n.fragments.forEach(_=>{_.characters.forEach(M=>{const{inlineBox:w}=M;if(t?(S==null?void 0:S.inlineBox.left)!==w.left:(S==null?void 0:S.inlineBox.top)!==w.top){S=M;const v=d==="cover"?1:fn(d,{total:i,fontSize:i})/i,D=new ot;if(t){const x=i/R.height*v;D.translate(-R.left,-R.top).rotate(Math.PI/2).scale(x,x).translate(w.left+(w.width-R.height*x)/2,w.top-s)}else{const x=i/R.height*v;D.translate(-R.left,-R.top).scale(x,x).translate(w.left-R.width*x-s,w.top+(w.height-R.height*x)/2)}r.push(...B.paths.map(x=>{const L=x.clone();return L.applyTransform(D),L.style.fill&&L.style.fill in I&&(L.style.fill=I[L.style.fill]),L.style.stroke&&L.style.stroke in I&&(L.style.stroke=I[L.style.stroke]),L}))}})})})}}}function Id(){return{name:"outline"}}const oA=new G,ZA=new ot,aA=new ot;function Bd(){return{name:"render",getBoundingBox:r=>{const{characters:A,fontSize:e,effects:t}=r,i=[];return A.forEach(s=>{t==null||t.forEach(n=>{if(!s.glyphBox)return;const o=s.glyphBox.clone(),a=pn(r,n);oA.set(o.left,o.top),oA.applyMatrix3(a),o.left=oA.x,o.top=oA.y,oA.set(o.right,o.bottom),oA.applyMatrix3(a),o.width=oA.x-o.left,o.height=oA.y-o.top;const l=(n.shadowOffsetX??0)*e,g=(n.shadowOffsetY??0)*e,h=Math.max(.1,n.textStrokeWidth??0)*e;o.left+=l-h,o.top+=g-h,o.width+=h*2,o.height+=h*2,i.push(o)})}),i.length?ce.from(...i):void 0},render:(r,A)=>{const{paragraphs:e,glyphBox:t,effects:i,style:s}=A;function n(o,a){r.fillStyle=o,r.fillRect(a.left,a.top,a.width,a.height)}s!=null&&s.backgroundColor&&n(s.backgroundColor,new ce(0,0,r.canvas.width,r.canvas.height)),e.forEach(o=>{var a;(a=o.style)!=null&&a.backgroundColor&&n(o.style.backgroundColor,o.lineBox)}),i?i.forEach(o=>{Sr(o,t,r),r.save();const[a,l,g,h,f,I]=pn(A,o).transpose().elements;r.transform(a,h,l,f,g,I),A.forEachCharacter(d=>{var C;(C=d.parent.style)!=null&&C.backgroundColor&&n(d.parent.style.backgroundColor,d.inlineBox),d.drawTo(r,o)}),r.restore()}):e.forEach(o=>{o.fragments.forEach(a=>{var l;(l=a.style)!=null&&l.backgroundColor&&n(a.computedStyle.backgroundColor,a.inlineBox),a.characters.forEach(g=>{g.drawTo(r)})})}),A.debug&&e.forEach(o=>{r.strokeRect(o.lineBox.x,o.lineBox.y,o.lineBox.width,o.lineBox.height)})}}}function pn(r,A){const{fontSize:e,glyphBox:t}=r,i=(A.translateX??0)*e,s=(A.translateY??0)*e,n=Math.PI*2,o=(A.skewX??0)/360*n,a=(A.skewY??0)/360*n,{left:l,top:g,width:h,height:f}=t,I=l+h/2,d=g+f/2;return ZA.identity(),aA.makeTranslation(i,s),ZA.multiply(aA),aA.makeTranslation(I,d),ZA.multiply(aA),aA.set(1,Math.tan(o),0,Math.tan(a),1,0,0,0,1),ZA.multiply(aA),aA.makeTranslation(-I,-d),ZA.multiply(aA),ZA.clone()}function Ed(){const r=[];return{name:"textDecoration",paths:r,update:A=>{r.length=0;const e=[];let t,i;A.forEachCharacter(s=>{const{computedStyle:n,isVertical:o,inlineBox:a,underlinePosition:l,underlineThickness:g,strikeoutPosition:h,strikeoutSize:f}=s,{color:I,textDecoration:d,writingMode:C}=n;if(nA(d))i=void 0;else{let B=!1;if((i==null?void 0:i.textDecoration)===d&&(i==null?void 0:i.writingMode)===C&&(i==null?void 0:i.color)===I&&(o?t[0].inlineBox.left===a.left:t[0].inlineBox.top===a.top))switch(d){case"underline":t[0].underlinePosition===l&&t[0].underlineThickness===g&&(B=!0);break;case"line-through":t[0].strikeoutPosition===h&&t[0].strikeoutSize===f&&(B=!0);break}B?t.push(s):(t=[],t.push(s),e.push(t)),i=n}}),e.forEach(s=>{const{computedStyle:n,isVertical:o,underlinePosition:a,underlineThickness:l,strikeoutPosition:g,strikeoutSize:h}=s[0],{color:f,textDecoration:I}=n,{left:d,top:C,width:B,height:R}=ce.from(...s.map(v=>v.inlineBox));let S=o?d+B:C;const _=o?-1:1;let M=0;switch(I){case"overline":M=l*2;break;case"underline":S+=_*a,M=l*2;break;case"line-through":S+=_*g,M=h*2;break}S-=M;let w;o?w=new He([{type:"M",x:S,y:C},{type:"L",x:S,y:C+R},{type:"L",x:S+M,y:C+R},{type:"L",x:S+M,y:C},{type:"Z"}],{fill:f}):w=new He([{type:"M",x:d,y:S},{type:"L",x:d+B,y:S},{type:"L",x:d+B,y:S+M},{type:"L",x:d,y:S+M},{type:"Z"}],{fill:f}),r.push(w)})},render:(A,e)=>{const{effects:t,computedStyle:i}=e;t?t.forEach(s=>{A.save();const[n,o,a,l,g,h]=pn(e,s).transpose().elements;A.transform(n,l,o,g,a,h),r.forEach(f=>{Gi({ctx:A,path:f,fontSize:i.fontSize,...s})}),A.restore()}):r.forEach(s=>{Gi({ctx:A,path:s,fontSize:i.fontSize})})}}}const Cn=ka();class pd extends hd{constructor(e={}){super();c(this,"debug");c(this,"content");c(this,"style");c(this,"effects");c(this,"measureDom");c(this,"needsUpdate",!0);c(this,"computedStyle",{...Cn});c(this,"paragraphs",[]);c(this,"lineBox",new ce);c(this,"rawGlyphBox",new ce);c(this,"glyphBox",new ce);c(this,"pathBox",new ce);c(this,"boundingBox",new ce);c(this,"measurer",new Bn);c(this,"plugins",new Map);c(this,"fonts");this.debug=e.debug??!1,this.content=e.content??"",this.style=e.style??{},this.measureDom=e.measureDom,this.effects=e.effects,this.fonts=e.fonts,this.use(cd()).use(Id()).use(dd()).use(Ed()).use(ud()).use(Bd()),this.updateParagraphs()}get fontSize(){return this.computedStyle.fontSize}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get characters(){return this.paragraphs.flatMap(e=>e.fragments.flatMap(t=>t.characters))}use(e){return this.plugins.set(e.name,e),this}forEachCharacter(e){return this.paragraphs.forEach((t,i)=>{t.fragments.forEach((s,n)=>{s.characters.forEach((o,a)=>{e(o,{paragraphIndex:i,fragmentIndex:n,characterIndex:a})})})}),this}async load(){await Promise.all(Array.from(this.plugins.values()).map(e=>{var t;return(t=e.load)==null?void 0:t.call(e,this)}))}updateParagraphs(){this.computedStyle={...Cn,...this.style};let{content:e,computedStyle:t}=this;const i=[];if(typeof e=="string"){const s=new Oi({},t);s.addFragment(e),i.push(s)}else{e=Array.isArray(e)?e:[e];for(const s of e)if(typeof s=="string"){const n=new Oi({},t);n.addFragment(s),i.push(n)}else if(Array.isArray(s)){const n=new Oi({},t);s.forEach(o=>{if(typeof o=="string")n.addFragment(o);else{const{content:a,...l}=o;a!==void 0&&n.addFragment(a,l)}}),i.push(n)}else if("fragments"in s){const{fragments:n,...o}=s,a=new Oi(o,t);n.forEach(l=>{const{content:g,...h}=l;g!==void 0&&a.addFragment(g,h)}),i.push(a)}else if("content"in s){const{content:n,...o}=s;if(n!==void 0){const a=new Oi(o,t);a.addFragment(n),i.push(a)}}}return this.paragraphs=i,this}measure(e=this.measureDom){const t={paragraphs:this.paragraphs,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this.updateParagraphs();const i=this.measurer.measure(this.paragraphs,this.computedStyle,e);this.paragraphs=i.paragraphs,this.lineBox=i.boundingBox,this.characters.forEach(s=>{s.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox(),Array.from(this.plugins.values()).sort((s,n)=>(s.updateOrder??0)-(n.updateOrder??0)).forEach(s=>{var n;(n=s.update)==null||n.call(s,this)}),this.glyphBox=this.getGlyphBox(),this.updatePathBox().updateBoundingBox();for(const s in t)i[s]=this[s],this[s]=t[s];return this.emit("measure",{text:this,result:i}),i}getGlyphBox(){const e=G.MAX,t=G.MIN;return this.characters.forEach(i=>{if(!i.getGlyphMinMax(e,t)){const{inlineBox:s}=i,n=new G(s.left,s.top),o=new G(s.left+s.width,s.top+s.height);e.min(n,o),t.max(n,o)}}),new ce(e.x,e.y,t.x-e.x,t.y-e.y)}updatePathBox(){return this.pathBox=ce.from(this.glyphBox,...Array.from(this.plugins.values()).map(e=>e.getBoundingBox?e.getBoundingBox(this):new Ts(e.paths??[]).getBoundingBox()).filter(Boolean)),this}updateBoundingBox(){const{lineBox:e,rawGlyphBox:t,pathBox:i}=this,s=Math.min(i.left,i.left+e.left-t.left),n=Math.min(i.top,i.top+e.top-t.top),o=Math.max(i.right,i.right+e.right-t.right),a=Math.max(i.bottom,i.bottom+e.bottom-t.bottom);return this.boundingBox=new ce(s,n,o-s,a-n),this}requestUpdate(){return this.needsUpdate=!0,this}update(){const e=this.measure();for(const t in e)this[t]=e[t];return this.emit("update",{text:this}),this.needsUpdate=!1,this}render(e){const{view:t,pixelRatio:i=2}=e,s=t.getContext("2d");s&&(this.needsUpdate&&this.update(),Ad(s,i,this.boundingBox),id(s,this),Array.from(this.plugins.values()).sort((n,o)=>(n.renderOrder??0)-(o.renderOrder??0)).forEach(n=>{var o;if(n.render)(o=n.render)==null||o.call(n,s,this);else if(n.paths){const a=this.computedStyle;n.paths.forEach(l=>{Gi({ctx:s,path:l,fontSize:a.fontSize})})}}),this.emit("render",{text:this,view:t,pixelRatio:i}))}}var Cd=Object.defineProperty,Qd=Object.getOwnPropertyDescriptor,$A=(r,A,e,t)=>{for(var i=t>1?void 0:t?Qd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Cd(A,e,i),i};const yd=new Set(Object.keys(Cn));u.Text2D=class extends hr{constructor(e,t=[]){super();c(this,"effects");c(this,"measureDom");c(this,"fonts");c(this,"texture",new gi);c(this,"text",new pd);c(this,"_subTextsCount",0);this.setProperties(e),this.append(t)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"content":case"effects":case"measureDom":case"fonts":case"split":this._updateSplit(),this.requestRedraw();break}this._subTextsCount&&e==="effects"&&this._getSubTexts().forEach(n=>{n.setProperties({[e]:t})})}_updateText(){this.text.style=this.style.toJSON(),this.text.content=this.content??"",this.text.effects=this.effects,this.text.fonts=this.fonts,this.text.measureDom=this.measureDom,this.text.requestUpdate()}_updateStyleProperty(e,t,i){switch(super._updateStyleProperty(e,t,i),e){case"width":this.split&&this._updateSubTexts();break}typeof e=="string"&&yd.has(e)&&(this._subTextsCount&&e!=="width"&&e!=="height"&&this._getSubTexts().forEach(s=>{s.style.setProperties({[e]:t})}),this.requestRedraw())}_getSubTexts(){return this.getChildren("front").filter(e=>e instanceof u.Text2D)}_updateSubTexts(){const e=this._getSubTexts(),t=this.measure();let i=0;this.split&&t.paragraphs.forEach(s=>{s.fragments.forEach(n=>{n.characters.forEach(o=>{const a=e[i];a&&(a.style.left=o.inlineBox.left,a.style.top=o.inlineBox.top),i++})})})}measure(){this._updateText();const e=this.text.measure();return this.style.width||(this.style.width=e.boundingBox.width),this.style.height||(this.style.height=e.boundingBox.height),e}_updateSplit(){this._subTextsCount&&(this.getChildren("front").forEach(t=>this.removeChild(t)),this._subTextsCount=0);const e=this.measure();this.split&&e.paragraphs.forEach(t=>{t.fragments.forEach(i=>{i.characters.forEach(s=>{this.appendChild(new u.Text2D({content:s.content,style:{...s.computedStyle,left:s.inlineBox.x,top:s.inlineBox.y,width:0,height:0,effects:this.effects}}),"front"),this._subTextsCount++})})})}_drawContent(){var e,t;if(!this.split){const i=(t=(e=this.getChildren())==null?void 0:e.find(s=>"onText2DRender"in s))==null?void 0:t.onText2DRender;i?i():(this._updateText(),this.text.render({pixelRatio:this.texture.pixelRatio,view:this.texture.source})),this.texture.requestUpload(),super._drawContent()}}},$A([U({default:!1})],u.Text2D.prototype,"split",2),$A([U({default:""})],u.Text2D.prototype,"content",2),$A([U()],u.Text2D.prototype,"effects",2),$A([Ee()],u.Text2D.prototype,"measureDom",2),$A([Ee()],u.Text2D.prototype,"fonts",2),u.Text2D=$A([re("Text2D")],u.Text2D);var md=Object.defineProperty,wd=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&md(A,e,i),i};class Qn extends u.Element2D{constructor(A,e=[]){super(),this.setProperties(A).append(e)}_updateStyleProperty(A,e,t,i){switch(super._updateStyleProperty(A,e,t,i),A){case"width":case"height":this.requestRedraw();break}}_drawCircle(A,e){this.context.arc(A,e,this.handleSize,0,Math.PI*2,!0),this.context.fillStyle=ve.WHITE,this.context.fill(),this.context.arc(A,e,this.handleSize,0,Math.PI*2,!0),this.context.strokeStyle="rgba(0, 0, 0, 0.2)",this.context.stroke()}_drawEllipse(A,e){this.context.roundRect(A-this.handleSize,e-this.handleSize*2,this.handleSize*2,this.handleSize*4,this.handleSize),this.context.fillStyle=ve.WHITE,this.context.fill(),this.context.roundRect(A-this.handleSize,e-this.handleSize*2,this.handleSize*2,this.handleSize*4,this.handleSize),this.context.strokeStyle="rgba(0, 0, 0, 0.2)",this.context.stroke()}_draw(){const{width:A,height:e}=this.getRect();this.context.rect(0,0,A,e),this.context.strokeStyle="#00FF00",this.context.stroke(),this._drawCircle(0,0),this._drawCircle(A,e),this._drawCircle(0,e),this._drawEllipse(0,e/2),this._drawCircle(A,0),this._drawEllipse(A,e/2)}}wd([U({default:6})],Qn.prototype,"handleSize");var vd=Object.defineProperty,_d=Object.getOwnPropertyDescriptor,El=(r,A,e,t)=>{for(var i=t>1?void 0:t?_d(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&vd(A,e,i),i};u.Video2D=class extends hr{constructor(e,t=[]){super();c(this,"_wait",Promise.resolve());this.setProperties(e),this.append(t)}get videoDuration(){var e;return(((e=this.texture)==null?void 0:e.duration)??0)*1e3}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"src":this._wait=this._load(t);break}}waitLoad(){return this._wait}async _load(e){this.texture=await Nt.video.load(e),(!this.style.width||!this.style.height)&&(this.style.width=this.texture.width,this.style.height=this.texture.height),this.requestRedraw()}_updateVideoCurrentTime(){let e=this._currentTime;if(e<0)return;const t=this.texture;if(!t)return;const i=t.duration;e=i?e%(i*1e3):0,!t.isPlaying&&!t.seeking&&(e=~~e/1e3,t.currentTime!==e&&(t.currentTime=e))}_process(e){this._updateVideoCurrentTime(),super._process(e)}},El([U({default:""})],u.Video2D.prototype,"src",2),u.Video2D=El([re("Video2D")],u.Video2D);var Dd=Object.defineProperty,bd=Object.getOwnPropertyDescriptor,Hi=(r,A,e,t)=>{for(var i=t>1?void 0:t?bd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Dd(A,e,i),i};const pl=r=>r,Cl=ei(.25,.1,.25,1),Ql=ei(.42,0,1,1),yl=ei(0,0,.58,1),ml=ei(.42,0,.58,1);function ei(r,A,e,t){const s=3*r-3*e+1,n=3*e-6*r,o=3*r,a=3*A-3*t+1,l=3*t-6*A,g=3*A,h=C=>(3*s*C+2*n)*C+o,f=C=>((s*C+n)*C+o)*C,I=C=>((a*C+l)*C+g)*C;function d(C){let B=C,R,S;for(let w=0;w<8;w++){if(S=f(B)-C,Math.abs(S)<1e-6)return B;if(R=h(B),Math.abs(R)<1e-6)break;B-=S/R}let _=1,M=0;for(B=C;_>M;){if(S=f(B)-C,Math.abs(S)<1e-6)return B;S>0?_=B:M=B,B=(_+M)/2}return B}return C=>I(d(C))}const Mr={linear:pl,ease:Cl,easeIn:Ql,easeOut:yl,easeInOut:ml};u.Animation=class extends u.TimelineNode{constructor(e,t=[]){super();c(this,"easing");c(this,"_keyframes",[]);c(this,"_isFirstUpdatePosition",!1);c(this,"_cachedProps",new SA);c(this,"_stoped",!1);this.setProperties(e).append(t)}_parented(e){super._parented(e),this._updateCachedProps()}_unparented(e){super._unparented(e),this.cancel()}_process(){this.canProcess()&&this.commitStyles()}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"effectMode":case"keyframes":this._updateKeyframes();break}}_getTargets(){var t;let e;switch(this.effectMode){case"sibling":e=((t=this.getParent())==null?void 0:t.getChildren(!0).filter(i=>i instanceof u.CanvasItem))??[];break;case"parent":default:e=[this.getParent()].filter(Boolean);break}return e.map(i=>i.style)}_updateKeyframes(){const e=[],t=this.keyframes;for(let n=t.length,o=0;o<n;o++){const{offset:a=o===0?0:o/(n-1),easing:l="linear",...g}=t[o];e.push({offset:a,easing:this._parseEasing(l),props:g})}const i=e[0],s=e[e.length-1];i&&i.offset!==0&&e.unshift({offset:0,easing:this._parseEasing("linear"),props:{}}),s&&s.offset!==1&&e.push({offset:1,easing:this._parseEasing("linear"),props:{}}),this._keyframes=e,this._updateCachedProps()}commitStyles(){if(!this.keyframes.length)return;if(this._updateCurrentTime(),this.isInsideTimeRange())this._isFirstUpdatePosition||(this._isFirstUpdatePosition=!0,this._updateCachedProps());else{if(!this._isFirstUpdatePosition)return;this._isFirstUpdatePosition=!1}const e=this._getTargets(),t=1/e.length,i=this.currentTimeProgress;e.forEach((s,n)=>{const o=t===1?i:bt(0,Math.max(0,i-t*n)/t,1),a=this._cachedProps.get(s);if(!a)return;const l=this._parseKeyframes(o,a);l!=null&&l.length&&this._commitStyle(o,s,a,l[0],l[1])})}_updateCachedProps(){this.cancel(),this._getTargets().forEach(e=>{const t=new Map,i=this._keyframes;for(let s=i.length,n=0;n<s;n++)Object.keys(i[n].props).forEach(o=>{t.set(o,e[o])});this._cachedProps.set(e,t)})}_parseEasing(e){if(!e)return Mr.linear;if(e in Mr)return Mr[e];const t=e.replace(/cubic-bezier\((.+)\)/,"$1").split(",").map(i=>Number(i));return ei(t[0],t[1],t[2],t[3])}_parseKeyframes(e,t){let i;const s=this._keyframes;for(let n=s.length,o=0;o<n;o++){const a=s[o],{offset:l,easing:g}=a,h={...a.props};if(i&&e<=l){const{offset:f,easing:I}=i,d={...i.props};return t.forEach((C,B)=>{(!(B in d)||d[B]===null)&&(d[B]=C),(!(B in h)||h[B]===null)&&(h[B]=C)}),[{offset:f,easing:I,props:d},{offset:l,easing:g,props:h}]}i=a}return null}_commitStyle(e,t,i,s,n){const{offset:o,easing:a,props:l}=s,{offset:g,props:h}=n,f=g-o,I=a((e-o)/f),d={width:t.width,height:t.height,fontSize:t.fontSize};i.forEach((C,B)=>{t[B]=this._getDiffValue(B,l[B],h[B],I,d)})}_getDiffValue(e,t,i,s,n){let o,a;if(t==="none"&&(t=void 0),i==="none"&&(i=void 0),t===void 0||i===void 0)if(t!==void 0)o=ri(e,String(t),n),a=ts(o);else if(i!==void 0)a=ri(e,String(i),n),o=ts(a);else return;else o=ri(e,String(t),n),a=ri(e,String(i),n);if(Array.isArray(o)&&Array.isArray(a)){const l=new Set,g={},h={};o.forEach(({name:I,args:d})=>{g[I]=d,l.add(I)}),a.forEach(({name:I,args:d})=>{h[I]=d,l.add(I)});let f="";return l.forEach(I=>{var R,S;const d=Math.max(((R=g[I])==null?void 0:R.length)??0,((S=h[I])==null?void 0:S.length)??0),C=g[I],B=h[I];f+=`${I}(${Array.from({length:d},(_,M)=>{const w=C==null?void 0:C[M],v=B==null?void 0:B[M],D=(w==null?void 0:w.normalizedIntValue)??0,x=(v==null?void 0:v.normalizedIntValue)??0;return Number.isNaN(D)||Number.isNaN(x)?(v==null?void 0:v.value)??0:Se(D,x,s)}).join(", ")}) `}),f}else if(!Array.isArray(o)&&!Array.isArray(a))return Number.isNaN(o.normalizedIntValue)||Number.isNaN(a.normalizedIntValue)?a.value:Se(o.normalizedIntValue,a.normalizedIntValue,s)}isPlaying(){return!this.paused&&this.isInsideTimeRange()}play(){return this._stoped?(this._stoped=!1,this.startTime=this.timelineCurrentTime):this.startTime=this.timelineCurrentTime-this.currentTime,this.paused=!1,!0}pause(){return this.paused=!0,!0}stop(){return this._stoped=!0,this.paused=!0,this._currentTime=0,!0}cancel(){this._getTargets().forEach(e=>{var t;(t=this._cachedProps.get(e))==null||t.forEach((i,s)=>{e[s]=i}),this._cachedProps.delete(e)})}},Hi([U({default:"parent"})],u.Animation.prototype,"effectMode",2),Hi([U({default:!1})],u.Animation.prototype,"loop",2),Hi([U({default:[]})],u.Animation.prototype,"keyframes",2),Hi([U()],u.Animation.prototype,"easing",2),u.Animation=Hi([re("Animation",{renderMode:"disabled",processMode:"pausable",processSortMode:"parent_before",duration:2e3})],u.Animation);const Or=class Or extends Ot{constructor(){super(...arguments);c(this,"playbackRate",1);c(this,"muted",!1);c(this,"volume",1);c(this,"paused",!1)}static get instance(){return this._instance||(this._instance=new Or),this._instance}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(e){console.warn("HTML Audio does not support processors")}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}free(){this.removeAllListeners()}};c(Or,"_instance");let Rr=Or;const Ki=class Ki extends Ot{constructor(){super(...arguments);c(this,"_source",null);c(this,"_audio",null);c(this,"_end",0);c(this,"_pausedReal",!1);c(this,"_duration",0);c(this,"_start",0);c(this,"_playing",!1);c(this,"_paused",!1);c(this,"_playbackRate",1);c(this,"_volume",1);c(this,"_loop",!1);c(this,"_muted",!1);c(this,"_onUpdate",()=>{this._source&&(this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete())})}get progress(){var e;return(((e=this._source)==null?void 0:e.currentTime)??0)/this._duration}get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh())}get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}set(e,t){if(this[e]===void 0)throw new Error(`Property with name ${e} does not exist.`);switch(e){case"playbackRate":this.playbackRate=t;break;case"volume":this.volume=t;break;case"paused":this.paused=t;break;case"loop":this.loop=t;break;case"muted":this.muted=t;break}return this}_onPlay(){this._playing=!0}_onPause(){this._playing=!1}init(e){this._playing=!1,this._duration=e.source.duration;const t=this._source=e.source.cloneNode(!1);return t.src=e.parent.src,t.onplay=this._onPlay.bind(this),t.onpause=this._onPause.bind(this),e.context.on("refresh",this.refresh),e.context.on("refreshPaused",this.refreshPaused),this._audio=e,this}_stop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause())}stop(){this._stop(),this._source&&this.emit("stop")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(e){console.warn("HTML Audio does not support processors")}refresh(){if(!this._audio||!this._source)return;const e=this._audio.context,t=this._audio.parent;this._source.loop=this._loop||t.loop;const i=e.volume*(e.muted?0:1),s=t.volume*(t.muted?0:1),n=this._volume*(this._muted?0:1);this._source.volume=n*i*s,this._source.playbackRate=this._playbackRate*e.playbackRate*t.playbackRate}refreshPaused(){if(!this._source||!this._audio)return;const e=this._paused||this._audio.parent.paused||this._audio.context.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,playbackRate:this._playbackRate,loop:this._loop})),this.emit("pause",e))}play(e={}){if(!this._source)return;const{start:t=0,end:i=0}=e;i&&console.assert(i>t,"End time is before start time"),e.playbackRate!==void 0&&(this._playbackRate=e.playbackRate),e.volume!==void 0&&(this._volume=e.volume),e.loop!==void 0&&(this._loop=e.loop),e.muted!==void 0&&(this._muted=e.muted),this.refresh(),this.loop&&i!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=!1),this._start=t,this._end=i||this._duration,this._start=Math.max(0,this._start-Ki.PADDING),this._end=Math.min(this._end+Ki.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t,this._duration),xe.on(this._onUpdate))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onComplete(){xe.off(this._onUpdate),this._stop(),this.emit("progress",1,this._duration),this.emit("end",this)}free(){xe.off(this._onUpdate),this.removeAllListeners();const e=this._source;e&&(e.onended=null,e.onplay=null,e.onpause=null,this._stop()),this._source=null,this._playbackRate=1,this._volume=1,this._loop=!1,this._end=0,this._start=0,this._duration=0,this._playing=!1,this._pausedReal=!1,this._paused=!1,this._muted=!1,this._audio&&(this._audio.context.off("refresh",this.refresh),this._audio.context.off("refreshPaused",this.refreshPaused),this._audio=null)}};c(Ki,"PADDING",.1);let kr=Ki;class wl{constructor(A){c(this,"source",new globalThis.Audio);c(this,"_src","");this.parent=A}get src(){return this._src}set src(A){this._src!==A&&(this._src=A,this.load())}get duration(){return this.source.duration}get isPlayable(){return!!this.source&&this.source.readyState===4}get context(){return Rr.instance}async load(){return new Promise(A=>{this.source.onload=()=>A(this),this.source.src=this._src,this.source.load()})}createSound(){return new kr}}class yn extends Ot{constructor(e,t){super();c(this,"_processers",[]);this._input=e,this._output=t}get processors(){return this._processers}set processors(e){if(this._processers.forEach(t=>t.disconnect()),this._processers.length=0,this._input.connect(this._output),e.length){this._processers=e.slice(0),this._input.disconnect();let t;e.forEach(i=>{t?t.connect(i.destination):this._input.connect(i.destination),t=i}),t.connect(this._output)}}get destination(){return this._input}}class xd{constructor(A,e=null){this.destination=A,this.source=e}connect(A){var e;(e=this.source)==null||e.connect(A)}disconnect(){var A;(A=this.source)==null||A.disconnect()}}function Sd(){if(is)return new AudioContext;if(rs){const r=globalThis.webkitAudioContext;return new r}else throw new Error("Failed to createAudioContext")}function Md(r,A,e){if(ss)return new OfflineAudioContext(r,A,e);if(Kn){const t=globalThis.webkitOfflineAudioContext;return new t(r,A,e)}else throw new Error("Failed to createOfflineAudioContext")}const Hr=class Hr extends yn{constructor(){const e=Sd(),t=Md(1,2,ss?Math.max(8e3,Math.min(96e3,e.sampleRate)):44100),i=e.createDynamicsCompressor(),s=e.createAnalyser();s.connect(i),i.connect(e.destination);super(s,i);c(this,"_context");c(this,"_offlineContext");c(this,"_locked");c(this,"muted",!1);c(this,"volume",1);c(this,"playbackRate",1);c(this,"autoPause",!0);c(this,"_paused",!1);c(this,"_pausedOnBlur",!1);c(this,"_compressor");c(this,"_analyser");c(this,"_unlock",()=>{this._locked&&(this.playEmptySound(),this._context.state==="running"&&(document.removeEventListener("mousedown",this._unlock,!0),document.removeEventListener("touchend",this._unlock,!0),document.removeEventListener("touchstart",this._unlock,!0),this._locked=!1))});this._context=e,this._offlineContext=t,this._compressor=i,this._analyser=s,this._locked=e.state==="suspended"&&(Gt||Jn),ni&&(this._locked&&(this._unlock(),document.addEventListener("mousedown",this._unlock,!0),document.addEventListener("touchstart",this._unlock,!0),document.addEventListener("touchend",this._unlock,!0)),globalThis.addEventListener("focus",this._onFocus),globalThis.addEventListener("blur",this._onBlur))}static get instance(){return this._instance||(this._instance=new Hr),this._instance}static get audioContext(){return this.instance.audioContext}static get offlineContext(){return this.instance.offlineContext}static setParamValue(e,t){this.instance.setParamValue(e,t)}static decode(e){return this.instance.decode(e)}get audioContext(){return this._context}get offlineContext(){return this._offlineContext}get paused(){return this._paused}set paused(e){e&&this._context.state==="running"?this._context.suspend():!e&&this._context.state==="suspended"&&this._context.resume(),this._paused=e}_onFocus(){if(!this.autoPause)return;const e=this._context.state;(e==="suspended"||e==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused())}_onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=!0,this.refreshPaused()))}playEmptySound(){const e=this._context.createBufferSource();e.buffer=this._context.createBuffer(1,1,22050),e.connect(this._context.destination),e.start(0,0,0),e.context.state==="suspended"&&e.context.resume()}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(e){return new Promise((t,i)=>{const s=o=>{i(new Error((o==null?void 0:o.message)||"Unable to decode file"))},n=this._offlineContext.decodeAudioData(e,t,s);n&&n.catch(s)})}setParamValue(e,t){e.setValueAtTime?e.setValueAtTime(t,this._context.currentTime):e.value=t}};c(Hr,"_instance");let lA=Hr;class vl extends Ot{constructor(){super(...arguments);c(this,"_audio",null);c(this,"_sourceNode",null);c(this,"_gain",null);c(this,"_progress",0);c(this,"_pausedReal",!1);c(this,"_paused",!1);c(this,"_volume",1);c(this,"_playbackRate",1);c(this,"_loop",!1);c(this,"_muted",!1);c(this,"_duration",0);c(this,"_end",0);c(this,"_elapsed",0);c(this,"_lastUpdate",this._now());c(this,"_processors",[]);c(this,"_onComplete",()=>{if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(e){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",e)}}this._sourceNode=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this)});c(this,"_updateListener",()=>this._update())}get progress(){return this._progress}get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh(),this._update(!0))}get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}init(e){return this._audio=e,e.context.on("refresh",this.refresh),e.context.on("refreshPaused",this.refreshPaused),this}_now(){var e;return((e=this._audio)==null?void 0:e.context.audioContext.currentTime)??0}play(e={}){var o;if(!this._audio)return;const{end:t=0,start:i=0}=e;t&&console.assert(t>i,"End time is before start time"),this._end=t,this._elapsed=i,e.volume!==void 0&&(this._volume=e.volume),e.playbackRate!==void 0&&(this._playbackRate=e.playbackRate),e.muted!==void 0&&(this._muted=e.muted),e.loop!==void 0&&(this._loop=e.loop),e.processors!==void 0&&(this._processors=e.processors),this._paused=!1;const{source:s,gain:n}=this._audio.cloneSource();this._sourceNode=s,this._gain=n,this.refresh(),s.onended=this._onComplete.bind(this),this._duration=((o=s.buffer)==null?void 0:o.duration)??0,this._lastUpdate=this._now(),this._loop?(s.loopStart=i,s.loopEnd=t,s.start(0,i)):t?s.start(0,i,t-i):s.start(0,i),this.emit("start"),this._update(!0),this._enableTicker(!0)}_stop(){if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.stop(0),this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(e){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",e)}this._sourceNode=null}}stop(){this._sourceNode&&(this._stop(),this.emit("stop"))}_update(e=!1){if(this._sourceNode){const t=this._now(),i=t-this._lastUpdate;if(i>0||e){this._elapsed+=i*this._sourceNode.playbackRate.value,this._lastUpdate=t;const s=this._duration;let n;if(this._sourceNode.loopStart){const o=this._sourceNode.loopEnd-this._sourceNode.loopStart;n=(this._sourceNode.loopStart+this._elapsed%o)/s}else n=this._elapsed%s/s;this._progress=n,this.emit("progress",n,s)}}}refresh(){if(!this._audio||!this._sourceNode)return;const e=this._audio.context,t=this._audio.parent;this._sourceNode.loop=this._loop||t.loop,e.setParamValue(this._gain.gain,this._volume*(this._muted?0:1)*t.volume*(t.muted?0:1)*e.volume*(e.muted?0:1)),e.setParamValue(this._sourceNode.playbackRate,this._playbackRate*t.playbackRate*e.playbackRate),this.applyProcessors()}applyProcessors(){if(this._sourceNode&&this._processors.length){this._sourceNode.disconnect();let e=this._sourceNode;this._processors.forEach(t=>{e.connect(t.destination),e=t}),e.connect(this._gain)}}refreshPaused(){if(!this._audio)return;const e=this._paused||this._audio.parent.paused||this._audio.context.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,playbackRate:this._playbackRate,loop:this._loop,volume:this._volume})),this.emit("pause",e))}_enableTicker(e){xe.off(this._updateListener),e&&xe.on(this._updateListener)}free(){var e,t,i;this.removeAllListeners(),this._stop(),(e=this._gain)==null||e.disconnect(),this._gain=null,(t=this._audio)==null||t.context.off("refresh",this.refresh),(i=this._audio)==null||i.context.off("refreshPaused",this.refreshPaused),this._audio=null,this._processors.forEach(s=>s.disconnect()),this._processors.length=0,this._end=0,this._playbackRate=1,this._volume=1,this._loop=!1,this._elapsed=0,this._duration=0,this._paused=!1,this._muted=!1,this._pausedReal=!1}}class _l extends yn{constructor(e){const t=lA.audioContext,i=t.createBufferSource(),s=t.createGain(),n=t.createAnalyser();i.connect(n),n.connect(s),s.connect(lA.instance.destination);super(n,s);c(this,"_sourceBuffer");c(this,"_sourceNode");c(this,"_sourceLoad");c(this,"gain");c(this,"analyser");this.parent=e,this._sourceNode=i,this.gain=s,this.analyser=n}get context(){return lA.instance}get isPlayable(){return!!this._sourceNode.buffer}get duration(){var e;return((e=this._sourceNode.buffer)==null?void 0:e.duration)??0}get buffer(){return this._sourceNode.buffer}set buffer(e){this._sourceNode.buffer=e}async load(){return this._sourceLoad||(this._sourceLoad=new Promise(e=>{this._sourceBuffer?this._decode(this._sourceBuffer).then(()=>e(this)):this.parent.src?this._loadUrl(this.parent.src).then(()=>e(this)):e(this)})),this._sourceLoad}_loadUrl(e){return new Promise(t=>{fetch(e).then(i=>i.arrayBuffer()).then(i=>this._decode(i)).finally(()=>t(this))})}_decode(e){return Promise.resolve(e instanceof AudioBuffer?e:lA.decode(e)).then(t=>(this.parent.isLoaded=!0,this.buffer=t,t))}cloneSource(){const e=this.context,t=this._sourceNode,i=e.audioContext.createBufferSource(),s=e.audioContext.createGain();return i.buffer=t.buffer,i.loop=t.loop,e.setParamValue(i.playbackRate,t.playbackRate.value),i.connect(s),s.connect(this.destination),{source:i,gain:s}}createSound(){return new vl}}var Rd=Object.defineProperty,kd=Object.getOwnPropertyDescriptor,Ud=(r,A,e)=>A in r?Rd(r,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[A]=e,Pd=(r,A,e,t)=>{for(var i=t>1?void 0:t?kd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(i)||i);return i},Nd=(r,A,e)=>Ud(r,A+"",e);u.Audio=class extends u.TimelineNode{constructor(e=""){super();c(this,"_sounds",[]);c(this,"_platformAudio",Yn?new _l(this):new wl(this));c(this,"_src");c(this,"isLoaded",!1);c(this,"_volume",1);c(this,"_muted",!1);c(this,"_loop",!1);c(this,"_playbackRate",1);c(this,"_isPlaying",!1);c(this,"multiple",!1);c(this,"start",0);c(this,"end",0);c(this,"_onComplete",e=>{if(this._sounds){const t=this._sounds.indexOf(e);t>-1&&this._sounds.splice(t,1),this._isPlaying=this._sounds.length>0}this._recycleSound(e)});c(this,"_prevTime",0);c(this,"_timer",0);this.src=e}get platformAudio(){return this._platformAudio}get src(){return this._src}set src(e){this._src!==e&&(this._src=e,this.load())}get isPlayable(){return this.isLoaded&&this._platformAudio.isPlayable}get audioDuration(){return this._platformAudio.duration*1e3}get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh())}get isPlaying(){return this._isPlaying}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"paused":this.refreshPaused();break}}async load(){return await this._platformAudio.load(),this}pause(){return this._isPlaying=!1,this.paused=!0,this}resume(){return this._isPlaying=this._sounds.length>0,this.paused=!1,this}stop(){if(!this.isPlayable)return this;this._isPlaying=!1;for(let e=this._sounds.length-1;e>=0;e--)this._sounds[e].stop();return this}play(e={}){if(!this.isLoaded)return;this.multiple||this._removeSounds(),this._isPlaying=!0;const t=this._createSound();this._sounds.push(t),t.once("end",()=>{var n;(n=e.complete)==null||n.call(e),this._onComplete(t)}),t.once("stop",()=>this._onComplete(t));const i=((e==null?void 0:e.start)??this.start)/1e3,s=((e==null?void 0:e.end)??this.end)/1e3;return t.play({...e,start:i,end:s}),t}_removeSounds(){for(let e=this._sounds.length-1;e>=0;e--)this._recycleSound(this._sounds[e]);this._sounds.length=0}_createSound(){return u.Audio._soundPool.length>0?u.Audio._soundPool.pop().init(this._platformAudio):this._platformAudio.createSound().init(this._platformAudio)}refresh(){for(let e=this._sounds.length,t=0;t<e;t++)this._sounds[t].refresh()}refreshPaused(){for(let e=this._sounds.length,t=0;t<e;t++)this._sounds[t].refreshPaused()}_recycleSound(e){e.free(),u.Audio._soundPool.includes(e)||u.Audio._soundPool.push(e)}_process(e){var t;if(super._process(e),this.canProcess()){const i=((t=this._tree)==null?void 0:t.timeline.currentTime)??0;i-this._prevTime>0&&(this._timer||(this._setTimeStop(),this.play({start:this.start+(i-this.delay)%this.duration})),this._isPlaying&&this._setTimeStop()),this._prevTime=i}}_setTimeStop(){this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this.stop(),this._timer=0},100)}},Nd(u.Audio,"_soundPool",[]),u.Audio=Pd([re("Audio")],u.Audio);class Fd extends u.Node2D{}var Td=Object.defineProperty,Ld=Object.getOwnPropertyDescriptor,Ur=(r,A,e,t)=>{for(var i=t>1?void 0:t?Ld(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Td(A,e,i),i};u.AudioWaveform=class extends u.Element2D{constructor(e={}){super();c(this,"src");c(this,"gap",0);c(this,"color","#000000");c(this,"_audioBuffer");c(this,"_src",ni?new ve(document.createElement("canvas")):void 0);c(this,"_needsUpdateTexture",!1);this.setProperties(e)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"src":this._loadSrc(t);break;case"gap":case"color":case"width":case"height":this._needsUpdateTexture=!0;break}}async _loadSrc(e){await globalThis.fetch(e).then(t=>t.arrayBuffer()).then(t=>lA.decode(t)).then(t=>{this._audioBuffer=t,this.syncTexture(!0)})}syncTexture(e=!1){var h,f;const t=this._audioBuffer;if(!t||!e&&!this._needsUpdateTexture)return;this._needsUpdateTexture=!1;const i=(h=this._src)==null?void 0:h.source;if(!i)return;const{width:s=0,height:n=0}=this.style;i.width=s,i.height=n;const o=i.getContext("2d");if(!o){console.warn("Failed to getContext('2d') in syncTexture");return}o.fillStyle=this.color;const a=t.getChannelData(0),l=Math.ceil(a.length/s),g=n/2;for(let I=1,d=-1,C=0;C<s;C++){for(let B=0;B<l;B++){const R=a[C*l+B];R<I&&(I=R),R>d&&(d=R)}if(!this.gap||C%(this.gap*2)===0){const B=C,R=(1+I)*g,S=this.gap||1,_=Math.max(1,(d-I)*g);o.fillRect(B,R,S,_),I=1,d=-1}}(f=this._src)==null||f.requestUpload(),this.requestRedraw()}_process(e){this.syncTexture(),super._process(e)}_drawSrc(){const e=this._src;e!=null&&e.valid&&(this.context.fillStyle=e,this.context.textureTransform=new Qt().scale(1/this.style.width,1/this.style.height))}},Ur([U()],u.AudioWaveform.prototype,"src",2),Ur([U()],u.AudioWaveform.prototype,"gap",2),Ur([U()],u.AudioWaveform.prototype,"color",2),u.AudioWaveform=Ur([re("AudioWaveform")],u.AudioWaveform);var Gd=Object.getOwnPropertyDescriptor,Od=(r,A,e,t)=>{for(var i=t>1?void 0:t?Gd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(i)||i);return i};u.Control=class extends u.Element2D{constructor(A,e=[]){super(),this._parentUpdateRect=this._parentUpdateRect.bind(this),this.setProperties(A),this.append(e)}_parented(A){super._parented(A),A.on("updateRect",this._parentUpdateRect)}_unparented(A){super._unparented(A),A.off("updateRect",this._parentUpdateRect)}_parentUpdateRect(){const A=this._parent.getRect();this.style.left=A.left,this.style.top=A.top,this.style.width=A.width,this.style.height=A.height}_input(A,e){super._input(A,e),this._guiInput(A,e)}_updateStyleProperty(A,e,t,i){switch(super._updateStyleProperty(A,e,t,i),A){case"width":case"height":case"left":case"top":this.emit("updateRect");break}}_guiInput(A,e){}},u.Control=Od([re("Control")],u.Control);var Hd=Object.defineProperty,Jd=Object.getOwnPropertyDescriptor,gA=(r,A,e,t)=>{for(var i=t>1?void 0:t?Jd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Hd(A,e,i),i};u.Range=class extends u.Control{constructor(A,e=[]){super(),this.setProperties(A).append(e)}_updateProperty(A,e,t,i){switch(super._updateProperty(A,e,t,i),A){case"allowGreater":case"allowLesser":case"page":case"minValue":case"maxValue":case"step":case"value":this.requestRedraw();break}}},gA([U({default:!1})],u.Range.prototype,"allowGreater",2),gA([U({default:!1})],u.Range.prototype,"allowLesser",2),gA([U({default:1})],u.Range.prototype,"page",2),gA([U({default:0})],u.Range.prototype,"minValue",2),gA([U({default:100})],u.Range.prototype,"maxValue",2),gA([U({default:.01})],u.Range.prototype,"step",2),gA([U({default:0})],u.Range.prototype,"value",2),u.Range=gA([re("Range")],u.Range);var Kd=Object.defineProperty,Yd=Object.getOwnPropertyDescriptor,Pt=(r,A,e,t)=>{for(var i=t>1?void 0:t?Yd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Kd(A,e,i),i};u.Ruler=class extends u.Control{constructor(e,t=[]){super();c(this,"texture",new gi);this.setProperties(e),this.append(t)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"offsetX":case"offsetY":case"thickness":case"markHeight":case"color":case"markBackgroundColor":case"markColor":case"gap":case"scale":this.requestRedraw();break}}_updateStyleProperty(e,t,i,s){switch(super._updateStyleProperty(e,t,i,s),e){case"width":case"height":this.texture[e]=t,this.requestRedraw();break}}_drawTexture(){const{width:e,height:t}=this.size,{offsetX:i,offsetY:s,thickness:n,markHeight:o,markBackgroundColor:a,markColor:l,color:g,gap:h,gapScale:f}=this,d=this.texture.source.getContext("2d");d.reset(),d.scale(this.texture.pixelRatio,this.texture.pixelRatio);const C=Math.round(i),B=Math.round(s);d.beginPath(),d.fillStyle=a||"#EEE",d.fillRect(0,0,e,n),d.fillRect(0,0,n,t),d.fill(),d.strokeStyle=l||"#000",d.moveTo(n,0),d.lineTo(n,t),d.moveTo(0,n),d.lineTo(e,n),d.stroke();const R=h,S=h*f;let _,M,w,v,D;for(R>=S?(_=R/S,M=Math.floor(_)*R/20,w=R/20*Math.floor(_)/_):(_=S/R,M=Math.floor(R/20/_),M>=2?M=Math.floor(M/2)*2:M=1,w=M*_),d.fillStyle=d.strokeStyle,v=C,D=0;v<e;D++,v+=w)d.moveTo(v,n-(D%5?o:2*o)),d.lineTo(v,n);for(v=C,D=0;v>n;D++,v-=w)d.moveTo(v,n-(D%5?o:2*o)),d.lineTo(v,n);let x=0;for(v=B,D=0;v>n;D++,v-=w)d.moveTo(n-(D%5?o:2*o),v),d.lineTo(n,v);for(v=B,D=0;v<t;D++,v+=w)d.moveTo(n-(D%5?o:2*o),v),d.lineTo(n,v);for(d.save(),d.fillStyle=g,d.scale(.8,.8),x=n-8,v=C,D=0;v<e;D++,v+=w)D%10===0&&d.fillText(String(Math.ceil(M*D)),v*1.25-3,x*1.25);for(v=C,D=0;v>n;D++,v-=w)D%10===0&&d.fillText(String(Math.ceil(-M*D)),v*1.25-3,x*1.25);for(x=0,v=B,D=0;v>n;D++,v-=w)D%10===0&&d.fillText(String(Math.ceil(M*D)),x*1.25,v*1.25+3);for(v=B,D=0;v<t;D++,v+=w)D%10===0&&d.fillText(String(Math.ceil(-M*D)),x*1.25,v*1.25+3);d.restore(),d.stroke(),this.texture.requestUpload()}_draw(){this._drawTexture();const e=this.texture;e!=null&&e.valid&&(this.context.fillStyle=e,this.context.textureTransform=new Qt().scale(1/this.size.width,1/this.size.height),this.context.rect(0,0,e.width,e.height),this.context.fill())}},Pt([U({default:0})],u.Ruler.prototype,"offsetX",2),Pt([U({default:0})],u.Ruler.prototype,"offsetY",2),Pt([U({default:20})],u.Ruler.prototype,"thickness",2),Pt([U({default:3})],u.Ruler.prototype,"markHeight",2),Pt([U({default:"#b2b6bc"})],u.Ruler.prototype,"color",2),Pt([U({default:"#f9f9fa"})],u.Ruler.prototype,"markBackgroundColor",2),Pt([U({default:"#b2b6bc"})],u.Ruler.prototype,"markColor",2),Pt([U({default:300})],u.Ruler.prototype,"gap",2),Pt([U({default:1})],u.Ruler.prototype,"gapScale",2),u.Ruler=Pt([re("Ruler")],u.Ruler);var Wd=Object.defineProperty,Vd=Object.getOwnPropertyDescriptor,Dl=(r,A,e,t)=>{for(var i=t>1?void 0:t?Vd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Wd(A,e,i),i};u.ScrollBar=class extends u.Range{constructor(A,e=[]){super(),this.setProperties(A).append(e)}_updateStyleProperty(A,e,t,i){switch(super._updateStyleProperty(A,e,t,i),A){case"width":case"height":case"left":case"top":this.requestRedraw();break}}_rect(){const{size:A,position:e}=this;let t,i,s,n,o;return this.direction==="vertical"?(s=10,n=A.height*(this.page/(this.maxValue-this.minValue)),t=e.left+A.width-s,i=A.height*(this.value/(this.maxValue-this.minValue)),o=s/2):(s=A.width*(this.page/(this.maxValue-this.minValue)),n=10,t=A.width*(this.value/(this.maxValue-this.minValue)),i=e.top+A.height-n,o=n/2),{left:t,top:i,width:s,height:n,radii:o}}_draw(){const{left:A,top:e,width:t,height:i,radii:s}=this._rect();this.context.roundRect(A,e,t,i,s),this.context.fillStyle=34,this.context.fill()}_pointerInput(A,e){var a,l;const{left:t,top:i,width:s,height:n}=this._rect(),o=A.x>=t&&A.x<t+s&&A.y>=i&&A.y<i+n;switch(e){case"pointerdown":case"pointermove":o?(a=this._tree)==null||a.input.setCursor("pointer"):(l=this._tree)==null||l.input.setCursor(void 0);break}return!1}},Dl([U({default:"vertical"})],u.ScrollBar.prototype,"direction",2),u.ScrollBar=Dl([re("ScrollBar")],u.ScrollBar);var zd=Object.getOwnPropertyDescriptor,qd=(r,A,e,t)=>{for(var i=t>1?void 0:t?zd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(i)||i);return i};u.XScrollBar=class extends u.ScrollBar{constructor(A,e=[]){super(),this.setProperties(A).append(e)}},u.XScrollBar=qd([re("XScrollBar",{direction:"horizontal"})],u.XScrollBar);var Xd=Object.getOwnPropertyDescriptor,jd=(r,A,e,t)=>{for(var i=t>1?void 0:t?Xd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(i)||i);return i};u.YScrollBar=class extends u.ScrollBar{constructor(A,e=[]){super(),this.setProperties(A).append(e)}},u.YScrollBar=jd([re("YScrollBar",{direction:"vertical"})],u.YScrollBar);var Zd=Object.defineProperty,$d=Object.getOwnPropertyDescriptor,Pr=(r,A,e,t)=>{for(var i=t>1?void 0:t?$d(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Zd(A,e,i),i};u.Scaler=class extends u.Node{get target(){var A;if((A=this.parent)!=null&&A.style)return this.parent}constructor(A,e=[]){super(),this.setProperties(A),this.append(e)}_updateProperty(A,e,t,i){switch(super._updateProperty(A,e,t,i),A){case"value":case"min":case"max":{this.value=bt(this.minValue,this.value,this.maxValue),this._updateScale();break}}}_updateScale(){const A=this.target;A&&(A.style.scaleX=this.value,A.style.scaleY=this.value,this.emit("updateScale",this.value))}_onWheel(A){if(!this.target)return;if(A.preventDefault(),!(A.wheelDeltaY?Math.abs(Math.abs(A.wheelDeltaY)-Math.abs(3*A.deltaY))<3:A.deltaMode===0)&&A.ctrlKey){A.preventDefault();let i=A.deltaY/(A.ctrlKey?1:100);i*=-.015,this.value+=i}}_input(A,e){switch(super._input(A,e),e){case"wheel":this._onWheel(A);break}}},Pr([U({default:1})],u.Scaler.prototype,"value",2),Pr([U({default:.05})],u.Scaler.prototype,"minValue",2),Pr([U({default:10})],u.Scaler.prototype,"maxValue",2),u.Scaler=Pr([re("Scaler",{processMode:"disabled",renderMode:"disabled"})],u.Scaler);var eI=Object.defineProperty,tI=Object.getOwnPropertyDescriptor,AI=(r,A,e)=>A in r?eI(r,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[A]=e,iI=(r,A,e,t)=>{for(var i=t>1?void 0:t?tI(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(i)||i);return i},rI=(r,A,e)=>AI(r,A+"",e);u.KawaseTransition=class extends u.Transition{constructor(){super(...arguments);c(this,"blur",10);c(this,"quality",10)}apply(e,t){const i=this.currentTimeProgress;let s,n;i<.5?(s=0,n=(.5-i)/.5):(s=1,n=(i-.5)/.5);const o=this.blur,a=this.quality,l=t.width,g=t.height,h=[],f=[o];if(o>0){let S=o;const _=o/a;for(let M=1;M<a;M++)S-=_,f.push(S)}const I=1/l,d=1/g,C=[];let B;const R=a-1;for(let S=0;S<R;S++)B=f[S]+.5,C[0]=B*I,C[1]=B*d,h.push({offset:C});B=f[R]+.5,C[0]=B*I,C[1]=B*d,h.push({offset:C}),h.forEach(S=>{fe.draw(e,u.KawaseTransition.material,{sampler:s,progress:n,...S})})}},rI(u.KawaseTransition,"material",new Qe({vert:`attribute vec2 position;
|
|
776
|
+
</svg>`}function dd(){const r=[];return{name:"listStyle",paths:r,update:A=>{r.length=0;const{paragraphs:e,isVertical:t,fontSize:i}=A,s=i*.45;e.forEach(n=>{const{computedStyle:o}=n,{color:a,listStyleImage:l,listStyleColormap:g,listStyleSize:h,listStyleType:f}=o,I=Il(g);let d=h,C;if(!nA(l))C=l;else if(!nA(f)){const _=i*.38/2;switch(d=d==="cover"?_*2:d,f){case"disc":C=fd(_,String(a));break}}if(!C)return;const B=Sa(C),R=B.getBoundingBox();let S;n.fragments.forEach(_=>{_.characters.forEach(M=>{const{inlineBox:w}=M;if(t?(S==null?void 0:S.inlineBox.left)!==w.left:(S==null?void 0:S.inlineBox.top)!==w.top){S=M;const v=d==="cover"?1:fn(d,{total:i,fontSize:i})/i,D=new ot;if(t){const x=i/R.height*v;D.translate(-R.left,-R.top).rotate(Math.PI/2).scale(x,x).translate(w.left+(w.width-R.height*x)/2,w.top-s)}else{const x=i/R.height*v;D.translate(-R.left,-R.top).scale(x,x).translate(w.left-R.width*x-s,w.top+(w.height-R.height*x)/2)}r.push(...B.paths.map(x=>{const L=x.clone();return L.applyTransform(D),L.style.fill&&L.style.fill in I&&(L.style.fill=I[L.style.fill]),L.style.stroke&&L.style.stroke in I&&(L.style.stroke=I[L.style.stroke]),L}))}})})})}}}function Id(){return{name:"outline"}}const oA=new G,ZA=new ot,aA=new ot;function Bd(){return{name:"render",getBoundingBox:r=>{const{characters:A,fontSize:e,effects:t}=r,i=[];return A.forEach(s=>{t==null||t.forEach(n=>{if(!s.glyphBox)return;const o=s.glyphBox.clone(),a=pn(r,n);oA.set(o.left,o.top),oA.applyMatrix3(a),o.left=oA.x,o.top=oA.y,oA.set(o.right,o.bottom),oA.applyMatrix3(a),o.width=oA.x-o.left,o.height=oA.y-o.top;const l=(n.shadowOffsetX??0)*e,g=(n.shadowOffsetY??0)*e,h=Math.max(.1,n.textStrokeWidth??0)*e;o.left+=l-h,o.top+=g-h,o.width+=h*2,o.height+=h*2,i.push(o)})}),i.length?ce.from(...i):void 0},render:(r,A)=>{const{paragraphs:e,glyphBox:t,effects:i,style:s}=A;function n(o,a){r.fillStyle=o,r.fillRect(a.left,a.top,a.width,a.height)}s!=null&&s.backgroundColor&&n(s.backgroundColor,new ce(0,0,r.canvas.width,r.canvas.height)),e.forEach(o=>{var a;(a=o.style)!=null&&a.backgroundColor&&n(o.style.backgroundColor,o.lineBox)}),i?i.forEach(o=>{Sr(o,t,r),r.save();const[a,l,g,h,f,I]=pn(A,o).transpose().elements;r.transform(a,h,l,f,g,I),A.forEachCharacter(d=>{var C;(C=d.parent.style)!=null&&C.backgroundColor&&n(d.parent.style.backgroundColor,d.inlineBox),d.drawTo(r,o)}),r.restore()}):e.forEach(o=>{o.fragments.forEach(a=>{var l;(l=a.style)!=null&&l.backgroundColor&&n(a.computedStyle.backgroundColor,a.inlineBox),a.characters.forEach(g=>{g.drawTo(r)})})}),A.debug&&e.forEach(o=>{r.strokeRect(o.lineBox.x,o.lineBox.y,o.lineBox.width,o.lineBox.height)})}}}function pn(r,A){const{fontSize:e,glyphBox:t}=r,i=(A.translateX??0)*e,s=(A.translateY??0)*e,n=Math.PI*2,o=(A.skewX??0)/360*n,a=(A.skewY??0)/360*n,{left:l,top:g,width:h,height:f}=t,I=l+h/2,d=g+f/2;return ZA.identity(),aA.makeTranslation(i,s),ZA.multiply(aA),aA.makeTranslation(I,d),ZA.multiply(aA),aA.set(1,Math.tan(o),0,Math.tan(a),1,0,0,0,1),ZA.multiply(aA),aA.makeTranslation(-I,-d),ZA.multiply(aA),ZA.clone()}function Ed(){const r=[];return{name:"textDecoration",paths:r,update:A=>{r.length=0;const e=[];let t,i;A.forEachCharacter(s=>{const{computedStyle:n,isVertical:o,inlineBox:a,underlinePosition:l,underlineThickness:g,strikeoutPosition:h,strikeoutSize:f}=s,{color:I,textDecoration:d,writingMode:C}=n;if(nA(d))i=void 0;else{let B=!1;if((i==null?void 0:i.textDecoration)===d&&(i==null?void 0:i.writingMode)===C&&(i==null?void 0:i.color)===I&&(o?t[0].inlineBox.left===a.left:t[0].inlineBox.top===a.top))switch(d){case"underline":t[0].underlinePosition===l&&t[0].underlineThickness===g&&(B=!0);break;case"line-through":t[0].strikeoutPosition===h&&t[0].strikeoutSize===f&&(B=!0);break}B?t.push(s):(t=[],t.push(s),e.push(t)),i=n}}),e.forEach(s=>{const{computedStyle:n,isVertical:o,underlinePosition:a,underlineThickness:l,strikeoutPosition:g,strikeoutSize:h}=s[0],{color:f,textDecoration:I}=n,{left:d,top:C,width:B,height:R}=ce.from(...s.map(v=>v.inlineBox));let S=o?d+B:C;const _=o?-1:1;let M=0;switch(I){case"overline":M=l*2;break;case"underline":S+=_*a,M=l*2;break;case"line-through":S+=_*g,M=h*2;break}S-=M;let w;o?w=new He([{type:"M",x:S,y:C},{type:"L",x:S,y:C+R},{type:"L",x:S+M,y:C+R},{type:"L",x:S+M,y:C},{type:"Z"}],{fill:f}):w=new He([{type:"M",x:d,y:S},{type:"L",x:d+B,y:S},{type:"L",x:d+B,y:S+M},{type:"L",x:d,y:S+M},{type:"Z"}],{fill:f}),r.push(w)})},render:(A,e)=>{const{effects:t,computedStyle:i}=e;t?t.forEach(s=>{A.save();const[n,o,a,l,g,h]=pn(e,s).transpose().elements;A.transform(n,l,o,g,a,h),r.forEach(f=>{Gi({ctx:A,path:f,fontSize:i.fontSize,...s})}),A.restore()}):r.forEach(s=>{Gi({ctx:A,path:s,fontSize:i.fontSize})})}}}const Cn=ka();class pd extends hd{constructor(e={}){super();c(this,"debug");c(this,"content");c(this,"style");c(this,"effects");c(this,"measureDom");c(this,"needsUpdate",!0);c(this,"computedStyle",{...Cn});c(this,"paragraphs",[]);c(this,"lineBox",new ce);c(this,"rawGlyphBox",new ce);c(this,"glyphBox",new ce);c(this,"pathBox",new ce);c(this,"boundingBox",new ce);c(this,"measurer",new Bn);c(this,"plugins",new Map);c(this,"fonts");this.debug=e.debug??!1,this.content=e.content??"",this.style=e.style??{},this.measureDom=e.measureDom,this.effects=e.effects,this.fonts=e.fonts,this.use(cd()).use(Id()).use(dd()).use(Ed()).use(ud()).use(Bd()),this.updateParagraphs()}get fontSize(){return this.computedStyle.fontSize}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get characters(){return this.paragraphs.flatMap(e=>e.fragments.flatMap(t=>t.characters))}use(e){return this.plugins.set(e.name,e),this}forEachCharacter(e){return this.paragraphs.forEach((t,i)=>{t.fragments.forEach((s,n)=>{s.characters.forEach((o,a)=>{e(o,{paragraphIndex:i,fragmentIndex:n,characterIndex:a})})})}),this}async load(){await Promise.all(Array.from(this.plugins.values()).map(e=>{var t;return(t=e.load)==null?void 0:t.call(e,this)}))}updateParagraphs(){this.computedStyle={...Cn,...this.style};let{content:e,computedStyle:t}=this;const i=[];if(typeof e=="string"){const s=new Oi({},t);s.addFragment(e),i.push(s)}else{e=Array.isArray(e)?e:[e];for(const s of e)if(typeof s=="string"){const n=new Oi({},t);n.addFragment(s),i.push(n)}else if(Array.isArray(s)){const n=new Oi({},t);s.forEach(o=>{if(typeof o=="string")n.addFragment(o);else{const{content:a,...l}=o;a!==void 0&&n.addFragment(a,l)}}),i.push(n)}else if("fragments"in s){const{fragments:n,...o}=s,a=new Oi(o,t);n.forEach(l=>{const{content:g,...h}=l;g!==void 0&&a.addFragment(g,h)}),i.push(a)}else if("content"in s){const{content:n,...o}=s;if(n!==void 0){const a=new Oi(o,t);a.addFragment(n),i.push(a)}}}return this.paragraphs=i,this}measure(e=this.measureDom){const t={paragraphs:this.paragraphs,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this.updateParagraphs();const i=this.measurer.measure(this.paragraphs,this.computedStyle,e);this.paragraphs=i.paragraphs,this.lineBox=i.boundingBox,this.characters.forEach(s=>{s.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox(),Array.from(this.plugins.values()).sort((s,n)=>(s.updateOrder??0)-(n.updateOrder??0)).forEach(s=>{var n;(n=s.update)==null||n.call(s,this)}),this.glyphBox=this.getGlyphBox(),this.updatePathBox().updateBoundingBox();for(const s in t)i[s]=this[s],this[s]=t[s];return this.emit("measure",{text:this,result:i}),i}getGlyphBox(){const e=G.MAX,t=G.MIN;return this.characters.forEach(i=>{if(!i.getGlyphMinMax(e,t)){const{inlineBox:s}=i,n=new G(s.left,s.top),o=new G(s.left+s.width,s.top+s.height);e.min(n,o),t.max(n,o)}}),new ce(e.x,e.y,t.x-e.x,t.y-e.y)}updatePathBox(){return this.pathBox=ce.from(this.glyphBox,...Array.from(this.plugins.values()).map(e=>e.getBoundingBox?e.getBoundingBox(this):new Ts(e.paths??[]).getBoundingBox()).filter(Boolean)),this}updateBoundingBox(){const{lineBox:e,rawGlyphBox:t,pathBox:i}=this,s=Math.min(i.left,i.left+e.left-t.left),n=Math.min(i.top,i.top+e.top-t.top),o=Math.max(i.right,i.right+e.right-t.right),a=Math.max(i.bottom,i.bottom+e.bottom-t.bottom);return this.boundingBox=new ce(s,n,o-s,a-n),this}requestUpdate(){return this.needsUpdate=!0,this}update(){const e=this.measure();for(const t in e)this[t]=e[t];return this.emit("update",{text:this}),this.needsUpdate=!1,this}render(e){const{view:t,pixelRatio:i=2}=e,s=t.getContext("2d");s&&(this.needsUpdate&&this.update(),Ad(s,i,this.boundingBox),id(s,this),Array.from(this.plugins.values()).sort((n,o)=>(n.renderOrder??0)-(o.renderOrder??0)).forEach(n=>{var o;if(n.render)(o=n.render)==null||o.call(n,s,this);else if(n.paths){const a=this.computedStyle;n.paths.forEach(l=>{Gi({ctx:s,path:l,fontSize:a.fontSize})})}}),this.emit("render",{text:this,view:t,pixelRatio:i}))}}var Cd=Object.defineProperty,Qd=Object.getOwnPropertyDescriptor,$A=(r,A,e,t)=>{for(var i=t>1?void 0:t?Qd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Cd(A,e,i),i};const yd=new Set(Object.keys(Cn));u.Text2D=class extends hr{constructor(e,t=[]){super();c(this,"effects");c(this,"measureDom");c(this,"fonts");c(this,"texture",new gi);c(this,"text",new pd);c(this,"measureResult");c(this,"_subTextsCount",0);this.setProperties(e),this.append(t)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"content":case"effects":case"measureDom":case"fonts":case"split":this._updateSplit(),this.requestRedraw();break}this._subTextsCount&&e==="effects"&&this._getSubTexts().forEach(n=>{n.setProperties({[e]:t})})}_updateText(){this.text.style=this.style.toJSON(),this.text.content=this.content??"",this.text.effects=this.effects,this.text.fonts=this.fonts,this.text.measureDom=this.measureDom,this.text.requestUpdate()}_updateStyleProperty(e,t,i){switch(e){case"left":case"top":case"width":case"height":this.requestRedraw();break;default:super._updateStyleProperty(e,t,i);break}switch(e){case"width":this.split&&this._updateSubTexts();break}typeof e=="string"&&yd.has(e)&&(this._subTextsCount&&e!=="width"&&e!=="height"&&this._getSubTexts().forEach(s=>{s.style.setProperties({[e]:t})}),this.requestRedraw())}_getSubTexts(){return this.getChildren("front").filter(e=>e instanceof u.Text2D)}_updateSubTexts(){var i;const e=this._getSubTexts();let t=0;this.split&&((i=this.updateMeasure().measureResult)==null||i.paragraphs.forEach(s=>{s.fragments.forEach(n=>{n.characters.forEach(o=>{const a=e[t];a&&(a.style.left=o.inlineBox.left,a.style.top=o.inlineBox.top),t++})})}))}measure(){return this._updateText(),this.text.measure()}updateMeasure(){this.measureResult=this.measure();const e=this.measureResult.boundingBox.width,t=this.measureResult.boundingBox.height,{left:i,top:s,width:n,height:o=t}=this.style;return this.position.x=i+Math.min(0,((n||e)-e)/2),this.position.y=s+Math.min(0,((o||t)-t)/2),this.size.width=e,this.size.height=t,this}_updateSplit(){var e;this._subTextsCount&&(this.getChildren("front").forEach(t=>this.removeChild(t)),this._subTextsCount=0),this.split&&((e=this.measureResult)==null||e.paragraphs.forEach(t=>{t.fragments.forEach(i=>{i.characters.forEach(s=>{this.appendChild(new u.Text2D({content:s.content,style:{...s.computedStyle,left:s.inlineBox.x,top:s.inlineBox.y,width:0,height:0,effects:this.effects}}),"front"),this._subTextsCount++})})}))}_redraw(){return this.updateMeasure(),super._redraw()}_drawContent(){var e,t;if(!this.split){const i=(t=(e=this.getChildren())==null?void 0:e.find(s=>"onText2DRender"in s))==null?void 0:t.onText2DRender;i?i():this.text.render({pixelRatio:this.texture.pixelRatio,view:this.texture.source}),this.texture.requestUpload(),super._drawContent()}}},$A([U({default:!1})],u.Text2D.prototype,"split",2),$A([U({default:""})],u.Text2D.prototype,"content",2),$A([U()],u.Text2D.prototype,"effects",2),$A([Ee()],u.Text2D.prototype,"measureDom",2),$A([Ee()],u.Text2D.prototype,"fonts",2),u.Text2D=$A([re("Text2D")],u.Text2D);var md=Object.defineProperty,wd=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&md(A,e,i),i};class Qn extends u.Element2D{constructor(A,e=[]){super(),this.setProperties(A).append(e)}_updateStyleProperty(A,e,t,i){switch(super._updateStyleProperty(A,e,t,i),A){case"width":case"height":this.requestRedraw();break}}_drawCircle(A,e){this.context.arc(A,e,this.handleSize,0,Math.PI*2,!0),this.context.fillStyle=ve.WHITE,this.context.fill(),this.context.arc(A,e,this.handleSize,0,Math.PI*2,!0),this.context.strokeStyle="rgba(0, 0, 0, 0.2)",this.context.stroke()}_drawEllipse(A,e){this.context.roundRect(A-this.handleSize,e-this.handleSize*2,this.handleSize*2,this.handleSize*4,this.handleSize),this.context.fillStyle=ve.WHITE,this.context.fill(),this.context.roundRect(A-this.handleSize,e-this.handleSize*2,this.handleSize*2,this.handleSize*4,this.handleSize),this.context.strokeStyle="rgba(0, 0, 0, 0.2)",this.context.stroke()}_draw(){const{width:A,height:e}=this.getRect();this.context.rect(0,0,A,e),this.context.strokeStyle="#00FF00",this.context.stroke(),this._drawCircle(0,0),this._drawCircle(A,e),this._drawCircle(0,e),this._drawEllipse(0,e/2),this._drawCircle(A,0),this._drawEllipse(A,e/2)}}wd([U({default:6})],Qn.prototype,"handleSize");var vd=Object.defineProperty,_d=Object.getOwnPropertyDescriptor,El=(r,A,e,t)=>{for(var i=t>1?void 0:t?_d(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&vd(A,e,i),i};u.Video2D=class extends hr{constructor(e,t=[]){super();c(this,"_wait",Promise.resolve());this.setProperties(e),this.append(t)}get videoDuration(){var e;return(((e=this.texture)==null?void 0:e.duration)??0)*1e3}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"src":this._wait=this._load(t);break}}waitLoad(){return this._wait}async _load(e){this.texture=await Nt.video.load(e),(!this.style.width||!this.style.height)&&(this.style.width=this.texture.width,this.style.height=this.texture.height),this.requestRedraw()}_updateVideoCurrentTime(){let e=this._currentTime;if(e<0)return;const t=this.texture;if(!t)return;const i=t.duration;e=i?e%(i*1e3):0,!t.isPlaying&&!t.seeking&&(e=~~e/1e3,t.currentTime!==e&&(t.currentTime=e))}_process(e){this._updateVideoCurrentTime(),super._process(e)}},El([U({default:""})],u.Video2D.prototype,"src",2),u.Video2D=El([re("Video2D")],u.Video2D);var Dd=Object.defineProperty,bd=Object.getOwnPropertyDescriptor,Hi=(r,A,e,t)=>{for(var i=t>1?void 0:t?bd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Dd(A,e,i),i};const pl=r=>r,Cl=ei(.25,.1,.25,1),Ql=ei(.42,0,1,1),yl=ei(0,0,.58,1),ml=ei(.42,0,.58,1);function ei(r,A,e,t){const s=3*r-3*e+1,n=3*e-6*r,o=3*r,a=3*A-3*t+1,l=3*t-6*A,g=3*A,h=C=>(3*s*C+2*n)*C+o,f=C=>((s*C+n)*C+o)*C,I=C=>((a*C+l)*C+g)*C;function d(C){let B=C,R,S;for(let w=0;w<8;w++){if(S=f(B)-C,Math.abs(S)<1e-6)return B;if(R=h(B),Math.abs(R)<1e-6)break;B-=S/R}let _=1,M=0;for(B=C;_>M;){if(S=f(B)-C,Math.abs(S)<1e-6)return B;S>0?_=B:M=B,B=(_+M)/2}return B}return C=>I(d(C))}const Mr={linear:pl,ease:Cl,easeIn:Ql,easeOut:yl,easeInOut:ml};u.Animation=class extends u.TimelineNode{constructor(e,t=[]){super();c(this,"easing");c(this,"_keyframes",[]);c(this,"_isFirstUpdatePosition",!1);c(this,"_cachedProps",new SA);c(this,"_stoped",!1);this.setProperties(e).append(t)}_parented(e){super._parented(e),this._updateCachedProps()}_unparented(e){super._unparented(e),this.cancel()}_process(){this.canProcess()&&this.commitStyles()}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"effectMode":case"keyframes":this._updateKeyframes();break}}_getTargets(){var t;let e;switch(this.effectMode){case"sibling":e=((t=this.getParent())==null?void 0:t.getChildren(!0).filter(i=>i instanceof u.CanvasItem))??[];break;case"parent":default:e=[this.getParent()].filter(Boolean);break}return e.map(i=>i.style)}_updateKeyframes(){const e=[],t=this.keyframes;for(let n=t.length,o=0;o<n;o++){const{offset:a=o===0?0:o/(n-1),easing:l="linear",...g}=t[o];e.push({offset:a,easing:this._parseEasing(l),props:g})}const i=e[0],s=e[e.length-1];i&&i.offset!==0&&e.unshift({offset:0,easing:this._parseEasing("linear"),props:{}}),s&&s.offset!==1&&e.push({offset:1,easing:this._parseEasing("linear"),props:{}}),this._keyframes=e,this._updateCachedProps()}commitStyles(){if(!this.keyframes.length)return;if(this._updateCurrentTime(),this.isInsideTimeRange())this._isFirstUpdatePosition||(this._isFirstUpdatePosition=!0,this._updateCachedProps());else{if(!this._isFirstUpdatePosition)return;this._isFirstUpdatePosition=!1}const e=this._getTargets(),t=1/e.length,i=this.currentTimeProgress;e.forEach((s,n)=>{const o=t===1?i:bt(0,Math.max(0,i-t*n)/t,1),a=this._cachedProps.get(s);if(!a)return;const l=this._parseKeyframes(o,a);l!=null&&l.length&&this._commitStyle(o,s,a,l[0],l[1])})}_updateCachedProps(){this.cancel(),this._getTargets().forEach(e=>{const t=new Map,i=this._keyframes;for(let s=i.length,n=0;n<s;n++)Object.keys(i[n].props).forEach(o=>{t.set(o,e[o])});this._cachedProps.set(e,t)})}_parseEasing(e){if(!e)return Mr.linear;if(e in Mr)return Mr[e];const t=e.replace(/cubic-bezier\((.+)\)/,"$1").split(",").map(i=>Number(i));return ei(t[0],t[1],t[2],t[3])}_parseKeyframes(e,t){let i;const s=this._keyframes;for(let n=s.length,o=0;o<n;o++){const a=s[o],{offset:l,easing:g}=a,h={...a.props};if(i&&e<=l){const{offset:f,easing:I}=i,d={...i.props};return t.forEach((C,B)=>{(!(B in d)||d[B]===null)&&(d[B]=C),(!(B in h)||h[B]===null)&&(h[B]=C)}),[{offset:f,easing:I,props:d},{offset:l,easing:g,props:h}]}i=a}return null}_commitStyle(e,t,i,s,n){const{offset:o,easing:a,props:l}=s,{offset:g,props:h}=n,f=g-o,I=a((e-o)/f),d={width:t.width,height:t.height,fontSize:t.fontSize};i.forEach((C,B)=>{t[B]=this._getDiffValue(B,l[B],h[B],I,d)})}_getDiffValue(e,t,i,s,n){let o,a;if(t==="none"&&(t=void 0),i==="none"&&(i=void 0),t===void 0||i===void 0)if(t!==void 0)o=ri(e,String(t),n),a=ts(o);else if(i!==void 0)a=ri(e,String(i),n),o=ts(a);else return;else o=ri(e,String(t),n),a=ri(e,String(i),n);if(Array.isArray(o)&&Array.isArray(a)){const l=new Set,g={},h={};o.forEach(({name:I,args:d})=>{g[I]=d,l.add(I)}),a.forEach(({name:I,args:d})=>{h[I]=d,l.add(I)});let f="";return l.forEach(I=>{var R,S;const d=Math.max(((R=g[I])==null?void 0:R.length)??0,((S=h[I])==null?void 0:S.length)??0),C=g[I],B=h[I];f+=`${I}(${Array.from({length:d},(_,M)=>{const w=C==null?void 0:C[M],v=B==null?void 0:B[M],D=(w==null?void 0:w.normalizedIntValue)??0,x=(v==null?void 0:v.normalizedIntValue)??0;return Number.isNaN(D)||Number.isNaN(x)?(v==null?void 0:v.value)??0:Se(D,x,s)}).join(", ")}) `}),f}else if(!Array.isArray(o)&&!Array.isArray(a))return Number.isNaN(o.normalizedIntValue)||Number.isNaN(a.normalizedIntValue)?a.value:Se(o.normalizedIntValue,a.normalizedIntValue,s)}isPlaying(){return!this.paused&&this.isInsideTimeRange()}play(){return this._stoped?(this._stoped=!1,this.startTime=this.timelineCurrentTime):this.startTime=this.timelineCurrentTime-this.currentTime,this.paused=!1,!0}pause(){return this.paused=!0,!0}stop(){return this._stoped=!0,this.paused=!0,this._currentTime=0,!0}cancel(){this._getTargets().forEach(e=>{var t;(t=this._cachedProps.get(e))==null||t.forEach((i,s)=>{e[s]=i}),this._cachedProps.delete(e)})}},Hi([U({default:"parent"})],u.Animation.prototype,"effectMode",2),Hi([U({default:!1})],u.Animation.prototype,"loop",2),Hi([U({default:[]})],u.Animation.prototype,"keyframes",2),Hi([U()],u.Animation.prototype,"easing",2),u.Animation=Hi([re("Animation",{renderMode:"disabled",processMode:"pausable",processSortMode:"parent_before",duration:2e3})],u.Animation);const Or=class Or extends Ot{constructor(){super(...arguments);c(this,"playbackRate",1);c(this,"muted",!1);c(this,"volume",1);c(this,"paused",!1)}static get instance(){return this._instance||(this._instance=new Or),this._instance}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(e){console.warn("HTML Audio does not support processors")}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}free(){this.removeAllListeners()}};c(Or,"_instance");let Rr=Or;const Ki=class Ki extends Ot{constructor(){super(...arguments);c(this,"_source",null);c(this,"_audio",null);c(this,"_end",0);c(this,"_pausedReal",!1);c(this,"_duration",0);c(this,"_start",0);c(this,"_playing",!1);c(this,"_paused",!1);c(this,"_playbackRate",1);c(this,"_volume",1);c(this,"_loop",!1);c(this,"_muted",!1);c(this,"_onUpdate",()=>{this._source&&(this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete())})}get progress(){var e;return(((e=this._source)==null?void 0:e.currentTime)??0)/this._duration}get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh())}get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}set(e,t){if(this[e]===void 0)throw new Error(`Property with name ${e} does not exist.`);switch(e){case"playbackRate":this.playbackRate=t;break;case"volume":this.volume=t;break;case"paused":this.paused=t;break;case"loop":this.loop=t;break;case"muted":this.muted=t;break}return this}_onPlay(){this._playing=!0}_onPause(){this._playing=!1}init(e){this._playing=!1,this._duration=e.source.duration;const t=this._source=e.source.cloneNode(!1);return t.src=e.parent.src,t.onplay=this._onPlay.bind(this),t.onpause=this._onPause.bind(this),e.context.on("refresh",this.refresh),e.context.on("refreshPaused",this.refreshPaused),this._audio=e,this}_stop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause())}stop(){this._stop(),this._source&&this.emit("stop")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(e){console.warn("HTML Audio does not support processors")}refresh(){if(!this._audio||!this._source)return;const e=this._audio.context,t=this._audio.parent;this._source.loop=this._loop||t.loop;const i=e.volume*(e.muted?0:1),s=t.volume*(t.muted?0:1),n=this._volume*(this._muted?0:1);this._source.volume=n*i*s,this._source.playbackRate=this._playbackRate*e.playbackRate*t.playbackRate}refreshPaused(){if(!this._source||!this._audio)return;const e=this._paused||this._audio.parent.paused||this._audio.context.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,playbackRate:this._playbackRate,loop:this._loop})),this.emit("pause",e))}play(e={}){if(!this._source)return;const{start:t=0,end:i=0}=e;i&&console.assert(i>t,"End time is before start time"),e.playbackRate!==void 0&&(this._playbackRate=e.playbackRate),e.volume!==void 0&&(this._volume=e.volume),e.loop!==void 0&&(this._loop=e.loop),e.muted!==void 0&&(this._muted=e.muted),this.refresh(),this.loop&&i!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=!1),this._start=t,this._end=i||this._duration,this._start=Math.max(0,this._start-Ki.PADDING),this._end=Math.min(this._end+Ki.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t,this._duration),xe.on(this._onUpdate))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onComplete(){xe.off(this._onUpdate),this._stop(),this.emit("progress",1,this._duration),this.emit("end",this)}free(){xe.off(this._onUpdate),this.removeAllListeners();const e=this._source;e&&(e.onended=null,e.onplay=null,e.onpause=null,this._stop()),this._source=null,this._playbackRate=1,this._volume=1,this._loop=!1,this._end=0,this._start=0,this._duration=0,this._playing=!1,this._pausedReal=!1,this._paused=!1,this._muted=!1,this._audio&&(this._audio.context.off("refresh",this.refresh),this._audio.context.off("refreshPaused",this.refreshPaused),this._audio=null)}};c(Ki,"PADDING",.1);let kr=Ki;class wl{constructor(A){c(this,"source",new globalThis.Audio);c(this,"_src","");this.parent=A}get src(){return this._src}set src(A){this._src!==A&&(this._src=A,this.load())}get duration(){return this.source.duration}get isPlayable(){return!!this.source&&this.source.readyState===4}get context(){return Rr.instance}async load(){return new Promise(A=>{this.source.onload=()=>A(this),this.source.src=this._src,this.source.load()})}createSound(){return new kr}}class yn extends Ot{constructor(e,t){super();c(this,"_processers",[]);this._input=e,this._output=t}get processors(){return this._processers}set processors(e){if(this._processers.forEach(t=>t.disconnect()),this._processers.length=0,this._input.connect(this._output),e.length){this._processers=e.slice(0),this._input.disconnect();let t;e.forEach(i=>{t?t.connect(i.destination):this._input.connect(i.destination),t=i}),t.connect(this._output)}}get destination(){return this._input}}class xd{constructor(A,e=null){this.destination=A,this.source=e}connect(A){var e;(e=this.source)==null||e.connect(A)}disconnect(){var A;(A=this.source)==null||A.disconnect()}}function Sd(){if(is)return new AudioContext;if(rs){const r=globalThis.webkitAudioContext;return new r}else throw new Error("Failed to createAudioContext")}function Md(r,A,e){if(ss)return new OfflineAudioContext(r,A,e);if(Kn){const t=globalThis.webkitOfflineAudioContext;return new t(r,A,e)}else throw new Error("Failed to createOfflineAudioContext")}const Hr=class Hr extends yn{constructor(){const e=Sd(),t=Md(1,2,ss?Math.max(8e3,Math.min(96e3,e.sampleRate)):44100),i=e.createDynamicsCompressor(),s=e.createAnalyser();s.connect(i),i.connect(e.destination);super(s,i);c(this,"_context");c(this,"_offlineContext");c(this,"_locked");c(this,"muted",!1);c(this,"volume",1);c(this,"playbackRate",1);c(this,"autoPause",!0);c(this,"_paused",!1);c(this,"_pausedOnBlur",!1);c(this,"_compressor");c(this,"_analyser");c(this,"_unlock",()=>{this._locked&&(this.playEmptySound(),this._context.state==="running"&&(document.removeEventListener("mousedown",this._unlock,!0),document.removeEventListener("touchend",this._unlock,!0),document.removeEventListener("touchstart",this._unlock,!0),this._locked=!1))});this._context=e,this._offlineContext=t,this._compressor=i,this._analyser=s,this._locked=e.state==="suspended"&&(Gt||Jn),ni&&(this._locked&&(this._unlock(),document.addEventListener("mousedown",this._unlock,!0),document.addEventListener("touchstart",this._unlock,!0),document.addEventListener("touchend",this._unlock,!0)),globalThis.addEventListener("focus",this._onFocus),globalThis.addEventListener("blur",this._onBlur))}static get instance(){return this._instance||(this._instance=new Hr),this._instance}static get audioContext(){return this.instance.audioContext}static get offlineContext(){return this.instance.offlineContext}static setParamValue(e,t){this.instance.setParamValue(e,t)}static decode(e){return this.instance.decode(e)}get audioContext(){return this._context}get offlineContext(){return this._offlineContext}get paused(){return this._paused}set paused(e){e&&this._context.state==="running"?this._context.suspend():!e&&this._context.state==="suspended"&&this._context.resume(),this._paused=e}_onFocus(){if(!this.autoPause)return;const e=this._context.state;(e==="suspended"||e==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused())}_onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=!0,this.refreshPaused()))}playEmptySound(){const e=this._context.createBufferSource();e.buffer=this._context.createBuffer(1,1,22050),e.connect(this._context.destination),e.start(0,0,0),e.context.state==="suspended"&&e.context.resume()}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(e){return new Promise((t,i)=>{const s=o=>{i(new Error((o==null?void 0:o.message)||"Unable to decode file"))},n=this._offlineContext.decodeAudioData(e,t,s);n&&n.catch(s)})}setParamValue(e,t){e.setValueAtTime?e.setValueAtTime(t,this._context.currentTime):e.value=t}};c(Hr,"_instance");let lA=Hr;class vl extends Ot{constructor(){super(...arguments);c(this,"_audio",null);c(this,"_sourceNode",null);c(this,"_gain",null);c(this,"_progress",0);c(this,"_pausedReal",!1);c(this,"_paused",!1);c(this,"_volume",1);c(this,"_playbackRate",1);c(this,"_loop",!1);c(this,"_muted",!1);c(this,"_duration",0);c(this,"_end",0);c(this,"_elapsed",0);c(this,"_lastUpdate",this._now());c(this,"_processors",[]);c(this,"_onComplete",()=>{if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(e){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",e)}}this._sourceNode=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this)});c(this,"_updateListener",()=>this._update())}get progress(){return this._progress}get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh(),this._update(!0))}get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}init(e){return this._audio=e,e.context.on("refresh",this.refresh),e.context.on("refreshPaused",this.refreshPaused),this}_now(){var e;return((e=this._audio)==null?void 0:e.context.audioContext.currentTime)??0}play(e={}){var o;if(!this._audio)return;const{end:t=0,start:i=0}=e;t&&console.assert(t>i,"End time is before start time"),this._end=t,this._elapsed=i,e.volume!==void 0&&(this._volume=e.volume),e.playbackRate!==void 0&&(this._playbackRate=e.playbackRate),e.muted!==void 0&&(this._muted=e.muted),e.loop!==void 0&&(this._loop=e.loop),e.processors!==void 0&&(this._processors=e.processors),this._paused=!1;const{source:s,gain:n}=this._audio.cloneSource();this._sourceNode=s,this._gain=n,this.refresh(),s.onended=this._onComplete.bind(this),this._duration=((o=s.buffer)==null?void 0:o.duration)??0,this._lastUpdate=this._now(),this._loop?(s.loopStart=i,s.loopEnd=t,s.start(0,i)):t?s.start(0,i,t-i):s.start(0,i),this.emit("start"),this._update(!0),this._enableTicker(!0)}_stop(){if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.stop(0),this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(e){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",e)}this._sourceNode=null}}stop(){this._sourceNode&&(this._stop(),this.emit("stop"))}_update(e=!1){if(this._sourceNode){const t=this._now(),i=t-this._lastUpdate;if(i>0||e){this._elapsed+=i*this._sourceNode.playbackRate.value,this._lastUpdate=t;const s=this._duration;let n;if(this._sourceNode.loopStart){const o=this._sourceNode.loopEnd-this._sourceNode.loopStart;n=(this._sourceNode.loopStart+this._elapsed%o)/s}else n=this._elapsed%s/s;this._progress=n,this.emit("progress",n,s)}}}refresh(){if(!this._audio||!this._sourceNode)return;const e=this._audio.context,t=this._audio.parent;this._sourceNode.loop=this._loop||t.loop,e.setParamValue(this._gain.gain,this._volume*(this._muted?0:1)*t.volume*(t.muted?0:1)*e.volume*(e.muted?0:1)),e.setParamValue(this._sourceNode.playbackRate,this._playbackRate*t.playbackRate*e.playbackRate),this.applyProcessors()}applyProcessors(){if(this._sourceNode&&this._processors.length){this._sourceNode.disconnect();let e=this._sourceNode;this._processors.forEach(t=>{e.connect(t.destination),e=t}),e.connect(this._gain)}}refreshPaused(){if(!this._audio)return;const e=this._paused||this._audio.parent.paused||this._audio.context.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,playbackRate:this._playbackRate,loop:this._loop,volume:this._volume})),this.emit("pause",e))}_enableTicker(e){xe.off(this._updateListener),e&&xe.on(this._updateListener)}free(){var e,t,i;this.removeAllListeners(),this._stop(),(e=this._gain)==null||e.disconnect(),this._gain=null,(t=this._audio)==null||t.context.off("refresh",this.refresh),(i=this._audio)==null||i.context.off("refreshPaused",this.refreshPaused),this._audio=null,this._processors.forEach(s=>s.disconnect()),this._processors.length=0,this._end=0,this._playbackRate=1,this._volume=1,this._loop=!1,this._elapsed=0,this._duration=0,this._paused=!1,this._muted=!1,this._pausedReal=!1}}class _l extends yn{constructor(e){const t=lA.audioContext,i=t.createBufferSource(),s=t.createGain(),n=t.createAnalyser();i.connect(n),n.connect(s),s.connect(lA.instance.destination);super(n,s);c(this,"_sourceBuffer");c(this,"_sourceNode");c(this,"_sourceLoad");c(this,"gain");c(this,"analyser");this.parent=e,this._sourceNode=i,this.gain=s,this.analyser=n}get context(){return lA.instance}get isPlayable(){return!!this._sourceNode.buffer}get duration(){var e;return((e=this._sourceNode.buffer)==null?void 0:e.duration)??0}get buffer(){return this._sourceNode.buffer}set buffer(e){this._sourceNode.buffer=e}async load(){return this._sourceLoad||(this._sourceLoad=new Promise(e=>{this._sourceBuffer?this._decode(this._sourceBuffer).then(()=>e(this)):this.parent.src?this._loadUrl(this.parent.src).then(()=>e(this)):e(this)})),this._sourceLoad}_loadUrl(e){return new Promise(t=>{fetch(e).then(i=>i.arrayBuffer()).then(i=>this._decode(i)).finally(()=>t(this))})}_decode(e){return Promise.resolve(e instanceof AudioBuffer?e:lA.decode(e)).then(t=>(this.parent.isLoaded=!0,this.buffer=t,t))}cloneSource(){const e=this.context,t=this._sourceNode,i=e.audioContext.createBufferSource(),s=e.audioContext.createGain();return i.buffer=t.buffer,i.loop=t.loop,e.setParamValue(i.playbackRate,t.playbackRate.value),i.connect(s),s.connect(this.destination),{source:i,gain:s}}createSound(){return new vl}}var Rd=Object.defineProperty,kd=Object.getOwnPropertyDescriptor,Ud=(r,A,e)=>A in r?Rd(r,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[A]=e,Pd=(r,A,e,t)=>{for(var i=t>1?void 0:t?kd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(i)||i);return i},Nd=(r,A,e)=>Ud(r,A+"",e);u.Audio=class extends u.TimelineNode{constructor(e=""){super();c(this,"_sounds",[]);c(this,"_platformAudio",Yn?new _l(this):new wl(this));c(this,"_src");c(this,"isLoaded",!1);c(this,"_volume",1);c(this,"_muted",!1);c(this,"_loop",!1);c(this,"_playbackRate",1);c(this,"_isPlaying",!1);c(this,"multiple",!1);c(this,"start",0);c(this,"end",0);c(this,"_onComplete",e=>{if(this._sounds){const t=this._sounds.indexOf(e);t>-1&&this._sounds.splice(t,1),this._isPlaying=this._sounds.length>0}this._recycleSound(e)});c(this,"_prevTime",0);c(this,"_timer",0);this.src=e}get platformAudio(){return this._platformAudio}get src(){return this._src}set src(e){this._src!==e&&(this._src=e,this.load())}get isPlayable(){return this.isLoaded&&this._platformAudio.isPlayable}get audioDuration(){return this._platformAudio.duration*1e3}get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh())}get isPlaying(){return this._isPlaying}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"paused":this.refreshPaused();break}}async load(){return await this._platformAudio.load(),this}pause(){return this._isPlaying=!1,this.paused=!0,this}resume(){return this._isPlaying=this._sounds.length>0,this.paused=!1,this}stop(){if(!this.isPlayable)return this;this._isPlaying=!1;for(let e=this._sounds.length-1;e>=0;e--)this._sounds[e].stop();return this}play(e={}){if(!this.isLoaded)return;this.multiple||this._removeSounds(),this._isPlaying=!0;const t=this._createSound();this._sounds.push(t),t.once("end",()=>{var n;(n=e.complete)==null||n.call(e),this._onComplete(t)}),t.once("stop",()=>this._onComplete(t));const i=((e==null?void 0:e.start)??this.start)/1e3,s=((e==null?void 0:e.end)??this.end)/1e3;return t.play({...e,start:i,end:s}),t}_removeSounds(){for(let e=this._sounds.length-1;e>=0;e--)this._recycleSound(this._sounds[e]);this._sounds.length=0}_createSound(){return u.Audio._soundPool.length>0?u.Audio._soundPool.pop().init(this._platformAudio):this._platformAudio.createSound().init(this._platformAudio)}refresh(){for(let e=this._sounds.length,t=0;t<e;t++)this._sounds[t].refresh()}refreshPaused(){for(let e=this._sounds.length,t=0;t<e;t++)this._sounds[t].refreshPaused()}_recycleSound(e){e.free(),u.Audio._soundPool.includes(e)||u.Audio._soundPool.push(e)}_process(e){var t;if(super._process(e),this.canProcess()){const i=((t=this._tree)==null?void 0:t.timeline.currentTime)??0;i-this._prevTime>0&&(this._timer||(this._setTimeStop(),this.play({start:this.start+(i-this.delay)%this.duration})),this._isPlaying&&this._setTimeStop()),this._prevTime=i}}_setTimeStop(){this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this.stop(),this._timer=0},100)}},Nd(u.Audio,"_soundPool",[]),u.Audio=Pd([re("Audio")],u.Audio);class Fd extends u.Node2D{}var Td=Object.defineProperty,Ld=Object.getOwnPropertyDescriptor,Ur=(r,A,e,t)=>{for(var i=t>1?void 0:t?Ld(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Td(A,e,i),i};u.AudioWaveform=class extends u.Element2D{constructor(e={}){super();c(this,"src");c(this,"gap",0);c(this,"color","#000000");c(this,"_audioBuffer");c(this,"_src",ni?new ve(document.createElement("canvas")):void 0);c(this,"_needsUpdateTexture",!1);this.setProperties(e)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"src":this._loadSrc(t);break;case"gap":case"color":case"width":case"height":this._needsUpdateTexture=!0;break}}async _loadSrc(e){await globalThis.fetch(e).then(t=>t.arrayBuffer()).then(t=>lA.decode(t)).then(t=>{this._audioBuffer=t,this.syncTexture(!0)})}syncTexture(e=!1){var h,f;const t=this._audioBuffer;if(!t||!e&&!this._needsUpdateTexture)return;this._needsUpdateTexture=!1;const i=(h=this._src)==null?void 0:h.source;if(!i)return;const{width:s=0,height:n=0}=this.style;i.width=s,i.height=n;const o=i.getContext("2d");if(!o){console.warn("Failed to getContext('2d') in syncTexture");return}o.fillStyle=this.color;const a=t.getChannelData(0),l=Math.ceil(a.length/s),g=n/2;for(let I=1,d=-1,C=0;C<s;C++){for(let B=0;B<l;B++){const R=a[C*l+B];R<I&&(I=R),R>d&&(d=R)}if(!this.gap||C%(this.gap*2)===0){const B=C,R=(1+I)*g,S=this.gap||1,_=Math.max(1,(d-I)*g);o.fillRect(B,R,S,_),I=1,d=-1}}(f=this._src)==null||f.requestUpload(),this.requestRedraw()}_process(e){this.syncTexture(),super._process(e)}_drawSrc(){const e=this._src;e!=null&&e.valid&&(this.context.fillStyle=e,this.context.textureTransform=new Qt().scale(1/this.style.width,1/this.style.height))}},Ur([U()],u.AudioWaveform.prototype,"src",2),Ur([U()],u.AudioWaveform.prototype,"gap",2),Ur([U()],u.AudioWaveform.prototype,"color",2),u.AudioWaveform=Ur([re("AudioWaveform")],u.AudioWaveform);var Gd=Object.getOwnPropertyDescriptor,Od=(r,A,e,t)=>{for(var i=t>1?void 0:t?Gd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(i)||i);return i};u.Control=class extends u.Element2D{constructor(A,e=[]){super(),this._parentUpdateRect=this._parentUpdateRect.bind(this),this.setProperties(A),this.append(e)}_parented(A){super._parented(A),A.on("updateRect",this._parentUpdateRect)}_unparented(A){super._unparented(A),A.off("updateRect",this._parentUpdateRect)}_parentUpdateRect(){const A=this._parent.getRect();this.style.left=A.left,this.style.top=A.top,this.style.width=A.width,this.style.height=A.height}_input(A,e){super._input(A,e),this._guiInput(A,e)}_updateStyleProperty(A,e,t,i){switch(super._updateStyleProperty(A,e,t,i),A){case"width":case"height":case"left":case"top":this.emit("updateRect");break}}_guiInput(A,e){}},u.Control=Od([re("Control")],u.Control);var Hd=Object.defineProperty,Jd=Object.getOwnPropertyDescriptor,gA=(r,A,e,t)=>{for(var i=t>1?void 0:t?Jd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Hd(A,e,i),i};u.Range=class extends u.Control{constructor(A,e=[]){super(),this.setProperties(A).append(e)}_updateProperty(A,e,t,i){switch(super._updateProperty(A,e,t,i),A){case"allowGreater":case"allowLesser":case"page":case"minValue":case"maxValue":case"step":case"value":this.requestRedraw();break}}},gA([U({default:!1})],u.Range.prototype,"allowGreater",2),gA([U({default:!1})],u.Range.prototype,"allowLesser",2),gA([U({default:1})],u.Range.prototype,"page",2),gA([U({default:0})],u.Range.prototype,"minValue",2),gA([U({default:100})],u.Range.prototype,"maxValue",2),gA([U({default:.01})],u.Range.prototype,"step",2),gA([U({default:0})],u.Range.prototype,"value",2),u.Range=gA([re("Range")],u.Range);var Kd=Object.defineProperty,Yd=Object.getOwnPropertyDescriptor,Pt=(r,A,e,t)=>{for(var i=t>1?void 0:t?Yd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Kd(A,e,i),i};u.Ruler=class extends u.Control{constructor(e,t=[]){super();c(this,"texture",new gi);this.setProperties(e),this.append(t)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"offsetX":case"offsetY":case"thickness":case"markHeight":case"color":case"markBackgroundColor":case"markColor":case"gap":case"scale":this.requestRedraw();break}}_updateStyleProperty(e,t,i,s){switch(super._updateStyleProperty(e,t,i,s),e){case"width":case"height":this.texture[e]=t,this.requestRedraw();break}}_drawTexture(){const{width:e,height:t}=this.size,{offsetX:i,offsetY:s,thickness:n,markHeight:o,markBackgroundColor:a,markColor:l,color:g,gap:h,gapScale:f}=this,d=this.texture.source.getContext("2d");d.reset(),d.scale(this.texture.pixelRatio,this.texture.pixelRatio);const C=Math.round(i),B=Math.round(s);d.beginPath(),d.fillStyle=a||"#EEE",d.fillRect(0,0,e,n),d.fillRect(0,0,n,t),d.fill(),d.strokeStyle=l||"#000",d.moveTo(n,0),d.lineTo(n,t),d.moveTo(0,n),d.lineTo(e,n),d.stroke();const R=h,S=h*f;let _,M,w,v,D;for(R>=S?(_=R/S,M=Math.floor(_)*R/20,w=R/20*Math.floor(_)/_):(_=S/R,M=Math.floor(R/20/_),M>=2?M=Math.floor(M/2)*2:M=1,w=M*_),d.fillStyle=d.strokeStyle,v=C,D=0;v<e;D++,v+=w)d.moveTo(v,n-(D%5?o:2*o)),d.lineTo(v,n);for(v=C,D=0;v>n;D++,v-=w)d.moveTo(v,n-(D%5?o:2*o)),d.lineTo(v,n);let x=0;for(v=B,D=0;v>n;D++,v-=w)d.moveTo(n-(D%5?o:2*o),v),d.lineTo(n,v);for(v=B,D=0;v<t;D++,v+=w)d.moveTo(n-(D%5?o:2*o),v),d.lineTo(n,v);for(d.save(),d.fillStyle=g,d.scale(.8,.8),x=n-8,v=C,D=0;v<e;D++,v+=w)D%10===0&&d.fillText(String(Math.ceil(M*D)),v*1.25-3,x*1.25);for(v=C,D=0;v>n;D++,v-=w)D%10===0&&d.fillText(String(Math.ceil(-M*D)),v*1.25-3,x*1.25);for(x=0,v=B,D=0;v>n;D++,v-=w)D%10===0&&d.fillText(String(Math.ceil(M*D)),x*1.25,v*1.25+3);for(v=B,D=0;v<t;D++,v+=w)D%10===0&&d.fillText(String(Math.ceil(-M*D)),x*1.25,v*1.25+3);d.restore(),d.stroke(),this.texture.requestUpload()}_draw(){this._drawTexture();const e=this.texture;e!=null&&e.valid&&(this.context.fillStyle=e,this.context.textureTransform=new Qt().scale(1/this.size.width,1/this.size.height),this.context.rect(0,0,e.width,e.height),this.context.fill())}},Pt([U({default:0})],u.Ruler.prototype,"offsetX",2),Pt([U({default:0})],u.Ruler.prototype,"offsetY",2),Pt([U({default:20})],u.Ruler.prototype,"thickness",2),Pt([U({default:3})],u.Ruler.prototype,"markHeight",2),Pt([U({default:"#b2b6bc"})],u.Ruler.prototype,"color",2),Pt([U({default:"#f9f9fa"})],u.Ruler.prototype,"markBackgroundColor",2),Pt([U({default:"#b2b6bc"})],u.Ruler.prototype,"markColor",2),Pt([U({default:300})],u.Ruler.prototype,"gap",2),Pt([U({default:1})],u.Ruler.prototype,"gapScale",2),u.Ruler=Pt([re("Ruler")],u.Ruler);var Wd=Object.defineProperty,Vd=Object.getOwnPropertyDescriptor,Dl=(r,A,e,t)=>{for(var i=t>1?void 0:t?Vd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Wd(A,e,i),i};u.ScrollBar=class extends u.Range{constructor(A,e=[]){super(),this.setProperties(A).append(e)}_updateStyleProperty(A,e,t,i){switch(super._updateStyleProperty(A,e,t,i),A){case"width":case"height":case"left":case"top":this.requestRedraw();break}}_rect(){const{size:A,position:e}=this;let t,i,s,n,o;return this.direction==="vertical"?(s=10,n=A.height*(this.page/(this.maxValue-this.minValue)),t=e.left+A.width-s,i=A.height*(this.value/(this.maxValue-this.minValue)),o=s/2):(s=A.width*(this.page/(this.maxValue-this.minValue)),n=10,t=A.width*(this.value/(this.maxValue-this.minValue)),i=e.top+A.height-n,o=n/2),{left:t,top:i,width:s,height:n,radii:o}}_draw(){const{left:A,top:e,width:t,height:i,radii:s}=this._rect();this.context.roundRect(A,e,t,i,s),this.context.fillStyle=34,this.context.fill()}_pointerInput(A,e){var a,l;const{left:t,top:i,width:s,height:n}=this._rect(),o=A.x>=t&&A.x<t+s&&A.y>=i&&A.y<i+n;switch(e){case"pointerdown":case"pointermove":o?(a=this._tree)==null||a.input.setCursor("pointer"):(l=this._tree)==null||l.input.setCursor(void 0);break}return!1}},Dl([U({default:"vertical"})],u.ScrollBar.prototype,"direction",2),u.ScrollBar=Dl([re("ScrollBar")],u.ScrollBar);var zd=Object.getOwnPropertyDescriptor,qd=(r,A,e,t)=>{for(var i=t>1?void 0:t?zd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(i)||i);return i};u.XScrollBar=class extends u.ScrollBar{constructor(A,e=[]){super(),this.setProperties(A).append(e)}},u.XScrollBar=qd([re("XScrollBar",{direction:"horizontal"})],u.XScrollBar);var Xd=Object.getOwnPropertyDescriptor,jd=(r,A,e,t)=>{for(var i=t>1?void 0:t?Xd(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(i)||i);return i};u.YScrollBar=class extends u.ScrollBar{constructor(A,e=[]){super(),this.setProperties(A).append(e)}},u.YScrollBar=jd([re("YScrollBar",{direction:"vertical"})],u.YScrollBar);var Zd=Object.defineProperty,$d=Object.getOwnPropertyDescriptor,Pr=(r,A,e,t)=>{for(var i=t>1?void 0:t?$d(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&Zd(A,e,i),i};u.Scaler=class extends u.Node{get target(){var A;if((A=this.parent)!=null&&A.style)return this.parent}constructor(A,e=[]){super(),this.setProperties(A),this.append(e)}_updateProperty(A,e,t,i){switch(super._updateProperty(A,e,t,i),A){case"value":case"min":case"max":{this.value=bt(this.minValue,this.value,this.maxValue),this._updateScale();break}}}_updateScale(){const A=this.target;A&&(A.style.scaleX=this.value,A.style.scaleY=this.value,this.emit("updateScale",this.value))}_onWheel(A){if(!this.target)return;if(A.preventDefault(),!(A.wheelDeltaY?Math.abs(Math.abs(A.wheelDeltaY)-Math.abs(3*A.deltaY))<3:A.deltaMode===0)&&A.ctrlKey){A.preventDefault();let i=A.deltaY/(A.ctrlKey?1:100);i*=-.015,this.value+=i}}_input(A,e){switch(super._input(A,e),e){case"wheel":this._onWheel(A);break}}},Pr([U({default:1})],u.Scaler.prototype,"value",2),Pr([U({default:.05})],u.Scaler.prototype,"minValue",2),Pr([U({default:10})],u.Scaler.prototype,"maxValue",2),u.Scaler=Pr([re("Scaler",{processMode:"disabled",renderMode:"disabled"})],u.Scaler);var eI=Object.defineProperty,tI=Object.getOwnPropertyDescriptor,AI=(r,A,e)=>A in r?eI(r,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[A]=e,iI=(r,A,e,t)=>{for(var i=t>1?void 0:t?tI(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(i)||i);return i},rI=(r,A,e)=>AI(r,A+"",e);u.KawaseTransition=class extends u.Transition{constructor(){super(...arguments);c(this,"blur",10);c(this,"quality",10)}apply(e,t){const i=this.currentTimeProgress;let s,n;i<.5?(s=0,n=(.5-i)/.5):(s=1,n=(i-.5)/.5);const o=this.blur,a=this.quality,l=t.width,g=t.height,h=[],f=[o];if(o>0){let S=o;const _=o/a;for(let M=1;M<a;M++)S-=_,f.push(S)}const I=1/l,d=1/g,C=[];let B;const R=a-1;for(let S=0;S<R;S++)B=f[S]+.5,C[0]=B*I,C[1]=B*d,h.push({offset:C});B=f[R]+.5,C[0]=B*I,C[1]=B*d,h.push({offset:C}),h.forEach(S=>{fe.draw(e,u.KawaseTransition.material,{sampler:s,progress:n,...S})})}},rI(u.KawaseTransition,"material",new Qe({vert:`attribute vec2 position;
|
|
777
777
|
attribute vec2 uv;
|
|
778
778
|
varying vec2 vUv;
|
|
779
779
|
void main() {
|
|
@@ -909,4 +909,4 @@ void main(void) {
|
|
|
909
909
|
coord = twist(coord, radius - (progress * radius));
|
|
910
910
|
coord = unmapCoord(coord);
|
|
911
911
|
gl_FragColor = texture2D(sampler, coord);
|
|
912
|
-
}`})),u.TwistTransition=EI([re("TwistTransition")],u.TwistTransition);class bl extends $t{install(A){const e=async t=>{const{decodeFrames:i}=await import("modern-gif");return await A.fetch(t).then(s=>s.arrayBuffer()).then(s=>i(s)).then(s=>new tr(s.map(n=>({duration:n.delay,texture:new Qs(n.data,n.width,n.height)}))))};return this.load=t=>A.loadBy(t,()=>e(t)),["image/gif"].forEach(t=>{A.register(t,e)}),A.gif=this,this}}class xl extends $t{install(A){const e=t=>A.fetch(t).then(i=>i.json());return this.load=t=>A.loadBy(t,()=>e(t)),["json"].forEach(t=>{A.register(t,e)}),A.json=this,this}}class Sl extends $t{install(A){const e=async(t,i)=>(await import("lottie-web").then(n=>n.default)).loadAnimation({container:null,renderer:"canvas",rendererSettings:{context:i.getContext("2d")},loop:!1,autoplay:!1,animationData:await A.fetch(t).then(n=>n.json())});return this.load=(t,i)=>A.loadBy(t,()=>e(t,i)),["lottie"].forEach(t=>{A.register(t,e)}),A.lottie=this,this}}class Ml extends $t{install(A){const e=async t=>await A.fetch(t).then(i=>i.text());return this.load=t=>A.loadBy(t,()=>e(t)),A.text=this,this}}class Rl extends $t{install(A){const e=t=>A.fetchImageBitmap(t,{premultiplyAlpha:"premultiply"}).then(i=>new ve(i));return this.load=t=>A.loadBy(t,()=>e(t)),["image/gif","image/jpeg","image/png","image/tiff","image/vnd.wap.wbmp","image/x-icon","image/x-jng","image/x-ms-bmp","image/svg+xml","image/webp"].forEach(t=>{A.register(t,e)}),A.texture=this,this}}class kl extends $t{install(A){const e=t=>new Go(t).load();return this.load=t=>A.loadBy(t,()=>e(t)),["video/3gpp","video/mpeg","video/quicktime","video/x-flv","video/x-mng","video/x-ms-asf","video/x-ms-wmv","video/x-msvideo","video/mp4"].forEach(t=>{A.register(t,e)}),A.video=this,this}}const CI=Object.entries({"text/html":["html","htm","shtml"],"text/css":["css"],"text/xml":["xml"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls"],"application/vnd.ms-powerpoint":["ppt"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"]});function QI(r){for(const[A,e]of CI)if(e.includes(r))return A}async function yI(r){var e,t;let A;if(r.startsWith("data:"))A=(e=r.match(/^data:(.+?);/))==null?void 0:e[1];else if(r.startsWith("http")){const i=(t=r.split(/[#?]/)[0].split(".").pop())==null?void 0:t.trim();i&&(A=QI(i))}return A??await fetch(r).then(i=>i.headers.get("Content-Type"))??""}const Nr="WeakRef"in globalThis;class Ul{constructor(){c(this,"defaultHandler",A=>this.fetch(A));c(this,"_handlers",new Map);c(this,"_handleing",new Map);c(this,"_handled",new Map);c(this,"_gc",Nr?new FinalizationRegistry(A=>{const e=this.get(A);e&&"free"in e&&e.free(),this._handled.delete(A)}):void 0);Nr||xe.on(this.gc.bind(this),{sort:2})}use(A){return A.install(this),this}register(A,e){return this._handlers.set(A,e),this}fetch(A){return fetch(A)}_fixSVG(A){const e=new DOMParser().parseFromString(decodeURIComponent(A.split(",")[1]),"image/svg+xml").documentElement;return e.setAttribute("width","512"),e.setAttribute("height","512"),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e.outerHTML)}`}async fetchImageBitmap(A,e){return A.startsWith("http")?await this.fetch(A).then(t=>t.blob()).then(t=>t.type==="image/svg+xml"?t.text().then(i=>this.fetchImageBitmap(this._fixSVG(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`),e)):createImageBitmap(t,e)):(A.startsWith("data:image/svg+xml;charset=utf-8,")&&(A=this._fixSVG(A)),new Promise(t=>{const i=new Image;i.src=A,i.onload=()=>{i.decode().finally(()=>{t(i)})}}).then(t=>createImageBitmap(t,e)))}get(A){let e=this._handled.get(A);return Nr&&e instanceof WeakRef&&(e=e.deref(),e||this._handleing.delete(A)),e}set(A,e){let t=e;Nr&&typeof e=="object"&&(this._gc.register(e,A),t=new WeakRef(e)),this._handled.set(A,t)}async loadBy(A,e){const t=this.get(A)??this._handleing.get(A);if(t)return t;const i=e().then(s=>(this.set(A,s),s)).finally(()=>{this._handleing.delete(A)});return this._handleing.set(A,i),i}async load(A,e){return this.loadBy(A,async()=>{const t=await yI(A);return(this._handlers.get(t)??this.defaultHandler)(A,e)})}async waitUntilLoad(){await Promise.all(Array.from(this._handleing.values()))}gc(){this._handled.forEach((A,e)=>{const t=this.get(e);t&&"free"in t&&t.free()}),this._handled.clear()}}const Nt=new Ul().use(new Ro).use(new bl).use(new xl).use(new Sl).use(new Ml).use(new Rl).use(new kl);class mI extends u.Control{constructor(){super();c(this,"_pointerStart");c(this,"_pointerOffset");c(this,"selected");c(this,"dragging");c(this,"hovered");c(this,"hover",new u.Element2D({name:"hover",internalMode:"back",style:{visibility:"hidden",outlineStyle:"solid",outlineColor:16711935,outlineWidth:2,pointerEvents:"none"}}));c(this,"transformRect",new Qn({name:"transformRect",internalMode:"back",style:{visibility:"hidden",pointerEvents:"none"}}));c(this,"scaler",new u.Scaler({internalMode:"back"}).on("updateScale",e=>{this.ruler.gapScale=e,this._updateScrollbars(),this._updateSelectionRect()}));c(this,"xScrollBar",new u.XScrollBar({internalMode:"back",style:{visibility:"hidden"}}));c(this,"yScrollBar",new u.YScrollBar({internalMode:"back",style:{visibility:"hidden"}}));c(this,"drawboard",new u.Element2D({name:"drawboard",style:{width:500,height:500,backgroundColor:4294967295,overflow:"hidden",pointerEvents:"none",boxShadow:"2px 2px 2px 1px rgba(0, 0, 0, 0.2)"}},[this.scaler]));c(this,"ruler",new u.Ruler({name:"ruler",offsetX:100,offsetY:100,style:{pointerEvents:"none"}},[this.drawboard,this.hover,this.transformRect,this.xScrollBar,this.yScrollBar]));this._onPointerdown=this._onPointerdown.bind(this),this._onPointermove=this._onPointermove.bind(this),this._onPointerup=this._onPointerup.bind(this),this.append(this.ruler)}_updateStyleProperty(e,t,i,s){switch(super._updateStyleProperty(e,t,i,s),e){case"width":this.drawboard.style.left=(this.size.width-this.drawboard.size.width)/2,this.ruler.offsetX=this.drawboard.style.left;break;case"height":this.drawboard.style.top=(this.size.height-this.drawboard.size.height)/2,this.ruler.offsetY=this.drawboard.style.top;break}}_guiInput(e,t){switch(super._guiInput(e,t),t){case"pointerdown":this._onPointerdown(e);break;case"pointermove":this._onPointermove(e);break;case"pointerup":this._onPointerup();break}}_onPointerdown(e){let t=e.target;t!=null&&t.is(this)&&(t=void 0),t!=null&&t.is(this.transformRect)&&(t=this.selected),this._pointerOffset={x:e.offsetX,y:e.offsetY},this.selected=t,this.dragging=t,t instanceof u.Element2D?this._pointerStart=t.style.clone():this._pointerStart=void 0,this._updateHover(),this._updateSelectionRect()}_onPointermove(e){let t=e.target;t!=null&&t.is(this)&&(t=void 0),t!=null&&t.is(this.transformRect)&&(t=this.selected);const{selected:i,dragging:s,_pointerStart:n,_pointerOffset:o}=this;i&&(t!=null&&t.is(i))?this.hovered=void 0:this.hovered=t;const a=o?{x:e.offsetX-o.x,y:e.offsetY-o.y}:{x:0,y:0};s&&n&&(s.style.left=n.left+a.x/this.scaler.value,s.style.top=n.top+a.y/this.scaler.value,s.update()),this._updateHover(),this._updateSelectionRect()}_onPointerup(){this.dragging=void 0,this._updateHover(),this._updateSelectionRect()}_copyGlobalTransform(e,t){e.style.visibility="visible",e.style.width=t.globalScale.x*t.size.x,e.style.height=t.globalScale.y*t.size.y,e.style.left=t.globalPosition.x,e.style.top=t.globalPosition.y,e.style.rotate=t.globalRotation,e.update()}_updateHover(){const e=this.hovered;e instanceof u.Element2D?(this.hover.style.visibility="visible",this._copyGlobalTransform(this.hover,e),this.hover.requestRedraw()):this.hover.style.visibility="hidden"}_updateSelectionRect(){this.selected?(this.transformRect.style.visibility="visible",this._copyGlobalTransform(this.transformRect,this.selected)):this.transformRect.style.visibility="hidden"}_updateScrollbars(){const e=this.ruler.gapScale,t=this.drawboard.size.height*e,i=this.drawboard.size.width*e;t>this.size.height?(this.yScrollBar.style.visibility="visible",this.yScrollBar.maxValue=t,this.yScrollBar.page=this.size.height):this.yScrollBar.style.visibility="hidden",i>this.size.width?(this.xScrollBar.style.visibility="visible",this.xScrollBar.maxValue=i,this.xScrollBar.page=this.size.width):this.xScrollBar.style.visibility="hidden"}}const Pl={alpha:!0,stencil:!0,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"};class Nl extends mi{constructor(e={}){var I,d;const{debug:t=!1,view:i,width:s,height:n,pixelRatio:o=ns,backgroundColor:a=0,autoResize:l,autoStart:g,timeline:h,...f}=e;super(h);c(this,"renderer");c(this,"_resizeObserver",On?new ResizeObserver(e=>{const t=e[0];if(t.target===this.view){const{inlineSize:i,blockSize:s}=Array.isArray(t.contentBoxSize)?t.contentBoxSize[0]:t.contentBoxSize;this.resize(i,s)}}):void 0);this.debug=t,this.renderer=new Mo(i,{...Pl,...f}),this._setupInput(),this.pixelRatio=o,this.backgroundColor=a,l?(!i&&this.renderer.view&&(this.renderer.view.style.width="100%",this.renderer.view.style.height="100%"),this.enableAutoResize(l)):this.resize(s||this.gl.drawingBufferWidth||((I=this.view)==null?void 0:I.clientWidth)||200,n||this.gl.drawingBufferHeight||((d=this.view)==null?void 0:d.clientHeight)||200,!i),g&&this.start()}get view(){return this.renderer.view}get gl(){return this.renderer.gl}get screen(){return this.renderer.screen}get width(){return this.screen.width}get height(){return this.screen.height}get pixelRatio(){return this.renderer.pixelRatio}set pixelRatio(e){this.renderer.pixelRatio=e,this.resize(this.width,this.height),this.view&&(this.view.dataset.pixelRatio=String(e))}_setupInput(){return this.view&&(this.input.setTarget(this.view),["pointerdown","pointerover","pointermove","pointerup","wheel"].forEach(e=>{this.input.on(e,t=>{this.root.input(t,e),this.emit(e,t)})})),this}enableAutoResize(e=!0){var t,i;return this.view&&(e?(t=this._resizeObserver)==null||t.observe(this.view):(i=this._resizeObserver)==null||i.unobserve(this.view)),this}resize(e,t,i=!1){return this.renderer.resize(e,t,i),this.root.width=e,this.root.height=t,this.renderer.program.uniforms.projectionMatrix=this.root.toProjectionArray(!0),this}nextTick(){return as()}async waitUntilLoad(){await Nt.waitUntilLoad(),await this.nextTick()}async waitAndRender(e=0){await Nt.waitUntilLoad(),this._process(e),await this.nextTick(),this._render(this.renderer)}render(e=0){this._process(e),this._render(this.renderer)}async start(){await this.waitAndRender(),super.start(e=>{this._process(e),this._render(this.renderer)})}free(){super.free(),this.enableAutoResize(!1),this.renderer.free()}toPixels(){return this.renderer.toPixels()}toImageData(){return new ImageData(this.toPixels(),this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)}toCanvas2D(){var s,n;const e=this.toImageData(),t=document.createElement("canvas");t.width=e.width,t.height=e.height,(s=t.getContext("2d"))==null||s.putImageData(e,0,0);const i=document.createElement("canvas");return i.width=this.width,i.height=this.height,(n=i.getContext("2d"))==null||n.drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),i}}let Ft;const mn=[];let wn=!1;async function wI(r=100){if(!wn){for(wn=!0;mn.length;){const A=mn.shift();if(A)try{await A()}catch(e){console.error(e)}else await new Promise(e=>setTimeout(e,r))}wn=!1}}async function vI(r){var n;const{data:A,width:e,height:t,debug:i=!1,time:s=0}=r;return Ft??(Ft=new Nl({width:1,height:1,preserveDrawingBuffer:!0})),Ft.debug=i,Ft.root.removeChildren(),Ft.timeline.currentTime=s,Ft.resize(e,t,!0),(Array.isArray(A)?A:[A]).forEach(o=>{o instanceof u.Node?Ft.root.appendChild(o):Ft.root.appendChild(u.Node.parse(o))}),await((n=r.onBeforeRender)==null?void 0:n.call(r,Ft)),await Ft.waitAndRender(),Ft.toCanvas2D()}async function _I(r){return new Promise(A=>{mn.push(async()=>A(await vI(r))),wI()})}u.AnimatedTexture=tr,u.Assets=Ul,u.AudioPipeline=yn,u.AudioProcessor=xd,u.AudioSpectrum=Fd,u.BaseElement2DStyle=vi,u.CanvasContext=Ma,u.CanvasItemEditor=mI,u.CanvasTexture=gi,u.Color=Zt,u.ColorMatrix=ds,u.ColorTexture=Cs,u.CoreObject=qi,u.DEG_TO_RAD=uo,u.DEVICE_PIXEL_RATIO=ns,u.EffectMaterial=er,u.Element2DStyle=Os,u.Engine=Nl,u.EventEmitter=Ot,u.FlexElement2DStyle=Fa,u.FlexLayout=gr,u.FontLoader=Ro,u.GIFLoader=bl,u.Geometry=$i,u.HTMLAudio=wl,u.HTMLAudioContext=Rr,u.HTMLSound=kr,u.IN_BROWSER=ni,u.ImageTexture=Fg,u.IndexBuffer=RA,u.Input=to,u.InputEvent=Xi,u.JSONLoader=xl,u.Loader=$t,u.LottieLoader=Sl,u.MainLoop=Zi,u.Material=Qe,u.Matrix=Dt,u.Matrix2=Cg,u.Matrix3=Is,u.Matrix4=co,u.MouseInputEvent=ls,u.PI=Lt,u.PI_2=et,u.PixelsTexture=Qs,u.PointerInputEvent=eo,u.Projection2D=Io,u.QuadGeometry=bg,u.QuadUvGeometry=fe,u.RAD_TO_DEG=Eg,u.RawWeakMap=SA,u.Rect2=Bs,u.RefCounted=$n,u.Renderer=Eo,u.Resource=Ht,u.SUPPORTS_AUDIO_CONTEXT=is,u.SUPPORTS_CLICK_EVENTS=Jn,u.SUPPORTS_CREATE_IMAGE_BITMAP=As,u.SUPPORTS_IMAGE_BITMAP=Gn,u.SUPPORTS_MOUSE_EVENTS=rg,u.SUPPORTS_OFFLINE_AUDIO_CONTEXT=ss,u.SUPPORTS_POINTER_EVENTS=xA,u.SUPPORTS_RESIZE_OBSERVER=On,u.SUPPORTS_TOUCH_EVENTS=Gt,u.SUPPORTS_WEBGL2=Ln,u.SUPPORTS_WEBKIT_AUDIO_CONTEXT=rs,u.SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT=Kn,u.SUPPORTS_WEB_AUDIO=Yn,u.SUPPORTS_WHEEL_EVENTS=Hn,u.SceneTree=mi,u.TextLoader=Ml,u.Texture2D=ve,u.TextureLoader=Rl,u.TextureRect2D=hr,u.Ticker=xe,u.Transform2D=Qt,u.TransformRect2D=Qn,u.UvGeometry=Rg,u.UvMaterial=kA,u.Vector=pt,u.Vector2=Ct,u.Vector3=Qg,u.Vector4=fo,u.VertexAttribute=lt,u.VertexBuffer=Kt,u.VideoLoader=kl,u.VideoTexture=Go,u.ViewportTexture=ms,u.WebAudio=_l,u.WebAudioContext=lA,u.WebGLBatch2DModule=Qo,u.WebGLBlendMode=MA,u.WebGLBufferModule=yo,u.WebGLFramebufferModule=mo,u.WebGLMaskModule=wo,u.WebGLModule=dt,u.WebGLProgramModule=vo,u.WebGLRenderer=Mo,u.WebGLScissorModule=_o,u.WebGLState=dA,u.WebGLStateModule=Co,u.WebGLStencilModule=Do,u.WebGLTextureModule=bo,u.WebGLVertexArrayModule=xo,u.WebGLViewportModule=So,u.WebSound=vl,u.WheelInputEvent=ai,u.assets=Nt,u.clamp=bt,u.createHTMLCanvas=qn,u.createNode=ng,u.crossOrigin=jn,u.cubicBezier=ei,u.curves=pg,u.customNode=re,u.customNodes=zi,u.defaultOptions=Pl,u.defineProperty=oi,u.determineCrossOrigin=Xn,u.ease=Cl,u.easeIn=Ql,u.easeInOut=ml,u.easeOut=yl,u.getDeclarations=Vi,u.getDefaultCssPropertyValue=ts,u.isCanvasElement=Vn,u.isElementNode=os,u.isImageElement=sg,u.isPow2=es,u.isVideoElement=Wn,u.isWebgl2=zn,u.lerp=Se,u.linear=pl,u.log2=ps,u.mapWebGLBlendModes=po,u.nextPow2=Es,u.nextTick=as,u.parseCSSFilter=Uo,u.parseCSSTransform=Po,u.parseCSSTransformOrigin=No,u.parseCssFunctions=si,u.parseCssProperty=ri,u.property=U,u.protectedProperty=Ee,u.render=_I,u.timingFunctions=Mr,u.uid=Fn,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
912
|
+
}`})),u.TwistTransition=EI([re("TwistTransition")],u.TwistTransition);class bl extends $t{install(A){const e=async t=>{const{decodeFrames:i}=await import("modern-gif");return await A.fetch(t).then(s=>s.arrayBuffer()).then(s=>i(s)).then(s=>new tr(s.map(n=>({duration:n.delay,texture:new Qs(n.data,n.width,n.height)}))))};return this.load=t=>A.loadBy(t,()=>e(t)),["image/gif"].forEach(t=>{A.register(t,e)}),A.gif=this,this}}class xl extends $t{install(A){const e=t=>A.fetch(t).then(i=>i.json());return this.load=t=>A.loadBy(t,()=>e(t)),["json"].forEach(t=>{A.register(t,e)}),A.json=this,this}}class Sl extends $t{install(A){const e=async(t,i)=>(await import("lottie-web").then(n=>n.default)).loadAnimation({container:null,renderer:"canvas",rendererSettings:{context:i.getContext("2d")},loop:!1,autoplay:!1,animationData:await A.fetch(t).then(n=>n.json())});return this.load=(t,i)=>A.loadBy(t,()=>e(t,i)),["lottie"].forEach(t=>{A.register(t,e)}),A.lottie=this,this}}class Ml extends $t{install(A){const e=async t=>await A.fetch(t).then(i=>i.text());return this.load=t=>A.loadBy(t,()=>e(t)),A.text=this,this}}class Rl extends $t{install(A){const e=t=>A.fetchImageBitmap(t,{premultiplyAlpha:"premultiply"}).then(i=>new ve(i));return this.load=t=>A.loadBy(t,()=>e(t)),["image/gif","image/jpeg","image/png","image/tiff","image/vnd.wap.wbmp","image/x-icon","image/x-jng","image/x-ms-bmp","image/svg+xml","image/webp"].forEach(t=>{A.register(t,e)}),A.texture=this,this}}class kl extends $t{install(A){const e=t=>new Go(t).load();return this.load=t=>A.loadBy(t,()=>e(t)),["video/3gpp","video/mpeg","video/quicktime","video/x-flv","video/x-mng","video/x-ms-asf","video/x-ms-wmv","video/x-msvideo","video/mp4"].forEach(t=>{A.register(t,e)}),A.video=this,this}}const CI=Object.entries({"text/html":["html","htm","shtml"],"text/css":["css"],"text/xml":["xml"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls"],"application/vnd.ms-powerpoint":["ppt"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"]});function QI(r){for(const[A,e]of CI)if(e.includes(r))return A}async function yI(r){var e,t;let A;if(r.startsWith("data:"))A=(e=r.match(/^data:(.+?);/))==null?void 0:e[1];else if(r.startsWith("http")){const i=(t=r.split(/[#?]/)[0].split(".").pop())==null?void 0:t.trim();i&&(A=QI(i))}return A??await fetch(r).then(i=>i.headers.get("Content-Type"))??""}const Nr="WeakRef"in globalThis;class Ul{constructor(){c(this,"defaultHandler",A=>this.fetch(A));c(this,"_handlers",new Map);c(this,"_handleing",new Map);c(this,"_handled",new Map);c(this,"_gc",Nr?new FinalizationRegistry(A=>{const e=this.get(A);e&&"free"in e&&e.free(),this._handled.delete(A)}):void 0);Nr||xe.on(this.gc.bind(this),{sort:2})}use(A){return A.install(this),this}register(A,e){return this._handlers.set(A,e),this}fetch(A){return fetch(A)}_fixSVG(A){const e=new DOMParser().parseFromString(decodeURIComponent(A.split(",")[1]),"image/svg+xml").documentElement;return e.setAttribute("width","512"),e.setAttribute("height","512"),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e.outerHTML)}`}async fetchImageBitmap(A,e){return A.startsWith("http")?await this.fetch(A).then(t=>t.blob()).then(t=>t.type==="image/svg+xml"?t.text().then(i=>this.fetchImageBitmap(this._fixSVG(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`),e)):createImageBitmap(t,e)):(A.startsWith("data:image/svg+xml;charset=utf-8,")&&(A=this._fixSVG(A)),new Promise(t=>{const i=new Image;i.src=A,i.onload=()=>{i.decode().finally(()=>{t(i)})}}).then(t=>createImageBitmap(t,e)))}get(A){let e=this._handled.get(A);return Nr&&e instanceof WeakRef&&(e=e.deref(),e||this._handleing.delete(A)),e}set(A,e){let t=e;Nr&&typeof e=="object"&&(this._gc.register(e,A),t=new WeakRef(e)),this._handled.set(A,t)}async loadBy(A,e){const t=this.get(A)??this._handleing.get(A);if(t)return t;const i=e().then(s=>(this.set(A,s),s)).finally(()=>{this._handleing.delete(A)});return this._handleing.set(A,i),i}async load(A,e){return this.loadBy(A,async()=>{const t=await yI(A);return(this._handlers.get(t)??this.defaultHandler)(A,e)})}async waitUntilLoad(){await Promise.all(Array.from(this._handleing.values()))}gc(){this._handled.forEach((A,e)=>{const t=this.get(e);t&&"free"in t&&t.free()}),this._handled.clear()}}const Nt=new Ul().use(new Ro).use(new bl).use(new xl).use(new Sl).use(new Ml).use(new Rl).use(new kl);class mI extends u.Control{constructor(){super();c(this,"_pointerStart");c(this,"_pointerOffset");c(this,"selected");c(this,"dragging");c(this,"hovered");c(this,"hover",new u.Element2D({name:"hover",internalMode:"back",style:{visibility:"hidden",outlineStyle:"solid",outlineColor:16711935,outlineWidth:2,pointerEvents:"none"}}));c(this,"transformRect",new Qn({name:"transformRect",internalMode:"back",style:{visibility:"hidden",pointerEvents:"none"}}));c(this,"scaler",new u.Scaler({internalMode:"back"}).on("updateScale",e=>{this.ruler.gapScale=e,this._updateScrollbars(),this._updateSelectionRect()}));c(this,"xScrollBar",new u.XScrollBar({internalMode:"back",style:{visibility:"hidden"}}));c(this,"yScrollBar",new u.YScrollBar({internalMode:"back",style:{visibility:"hidden"}}));c(this,"drawboard",new u.Element2D({name:"drawboard",style:{width:500,height:500,backgroundColor:4294967295,overflow:"hidden",pointerEvents:"none",boxShadow:"2px 2px 2px 1px rgba(0, 0, 0, 0.2)"}},[this.scaler]));c(this,"ruler",new u.Ruler({name:"ruler",offsetX:100,offsetY:100,style:{pointerEvents:"none"}},[this.drawboard,this.hover,this.transformRect,this.xScrollBar,this.yScrollBar]));this._onPointerdown=this._onPointerdown.bind(this),this._onPointermove=this._onPointermove.bind(this),this._onPointerup=this._onPointerup.bind(this),this.append(this.ruler)}_updateStyleProperty(e,t,i,s){switch(super._updateStyleProperty(e,t,i,s),e){case"width":this.drawboard.style.left=(this.size.width-this.drawboard.size.width)/2,this.ruler.offsetX=this.drawboard.style.left;break;case"height":this.drawboard.style.top=(this.size.height-this.drawboard.size.height)/2,this.ruler.offsetY=this.drawboard.style.top;break}}_guiInput(e,t){switch(super._guiInput(e,t),t){case"pointerdown":this._onPointerdown(e);break;case"pointermove":this._onPointermove(e);break;case"pointerup":this._onPointerup();break}}_onPointerdown(e){let t=e.target;t!=null&&t.is(this)&&(t=void 0),t!=null&&t.is(this.transformRect)&&(t=this.selected),this._pointerOffset={x:e.offsetX,y:e.offsetY},this.selected=t,this.dragging=t,t instanceof u.Element2D?this._pointerStart=t.style.clone():this._pointerStart=void 0,this._updateHover(),this._updateSelectionRect()}_onPointermove(e){let t=e.target;t!=null&&t.is(this)&&(t=void 0),t!=null&&t.is(this.transformRect)&&(t=this.selected);const{selected:i,dragging:s,_pointerStart:n,_pointerOffset:o}=this;i&&(t!=null&&t.is(i))?this.hovered=void 0:this.hovered=t;const a=o?{x:e.offsetX-o.x,y:e.offsetY-o.y}:{x:0,y:0};s&&n&&(s.style.left=n.left+a.x/this.scaler.value,s.style.top=n.top+a.y/this.scaler.value,s.update()),this._updateHover(),this._updateSelectionRect()}_onPointerup(){this.dragging=void 0,this._updateHover(),this._updateSelectionRect()}_copyGlobalTransform(e,t){e.style.visibility="visible",e.style.width=t.globalScale.x*t.size.x,e.style.height=t.globalScale.y*t.size.y,e.style.left=t.globalPosition.x,e.style.top=t.globalPosition.y,e.style.rotate=t.globalRotation,e.update()}_updateHover(){const e=this.hovered;e instanceof u.Element2D?(this.hover.style.visibility="visible",this._copyGlobalTransform(this.hover,e),this.hover.requestRedraw()):this.hover.style.visibility="hidden"}_updateSelectionRect(){this.selected?(this.transformRect.style.visibility="visible",this._copyGlobalTransform(this.transformRect,this.selected)):this.transformRect.style.visibility="hidden"}_updateScrollbars(){const e=this.ruler.gapScale,t=this.drawboard.size.height*e,i=this.drawboard.size.width*e;t>this.size.height?(this.yScrollBar.style.visibility="visible",this.yScrollBar.maxValue=t,this.yScrollBar.page=this.size.height):this.yScrollBar.style.visibility="hidden",i>this.size.width?(this.xScrollBar.style.visibility="visible",this.xScrollBar.maxValue=i,this.xScrollBar.page=this.size.width):this.xScrollBar.style.visibility="hidden"}}const Pl={alpha:!0,stencil:!0,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"};class Nl extends mi{constructor(e={}){var I,d;const{debug:t=!1,view:i,width:s,height:n,pixelRatio:o=ns,backgroundColor:a=0,autoResize:l,autoStart:g,timeline:h,...f}=e;super(h);c(this,"renderer");c(this,"_resizeObserver",On?new ResizeObserver(e=>{const t=e[0];if(t.target===this.view){const{inlineSize:i,blockSize:s}=Array.isArray(t.contentBoxSize)?t.contentBoxSize[0]:t.contentBoxSize;this.resize(i,s)}}):void 0);this.debug=t,this.renderer=new Mo(i,{...Pl,...f}),this._setupInput(),this.pixelRatio=o,this.backgroundColor=a,l?(!i&&this.renderer.view&&(this.renderer.view.style.width="100%",this.renderer.view.style.height="100%"),this.enableAutoResize(l)):this.resize(s||this.gl.drawingBufferWidth||((I=this.view)==null?void 0:I.clientWidth)||200,n||this.gl.drawingBufferHeight||((d=this.view)==null?void 0:d.clientHeight)||200,!i),g&&this.start()}get view(){return this.renderer.view}get gl(){return this.renderer.gl}get screen(){return this.renderer.screen}get width(){return this.screen.width}get height(){return this.screen.height}get pixelRatio(){return this.renderer.pixelRatio}set pixelRatio(e){this.renderer.pixelRatio=e,this.resize(this.width,this.height),this.view&&(this.view.dataset.pixelRatio=String(e))}_setupInput(){return this.view&&(this.input.setTarget(this.view),["pointerdown","pointerover","pointermove","pointerup","wheel"].forEach(e=>{this.input.on(e,t=>{this.root.input(t,e),this.emit(e,t)})})),this}enableAutoResize(e=!0){var t,i;return this.view&&(e?(t=this._resizeObserver)==null||t.observe(this.view):(i=this._resizeObserver)==null||i.unobserve(this.view)),this}resize(e,t,i=!1){return this.renderer.resize(e,t,i),this.root.width=e,this.root.height=t,this.root.requestUpload(),this.render(),this}nextTick(){return as()}async waitUntilLoad(){await Nt.waitUntilLoad(),await this.nextTick()}async waitAndRender(e=0){await Nt.waitUntilLoad(),this._process(e),await this.nextTick(),this._render(this.renderer)}render(e=0){this._process(e),this._render(this.renderer)}async start(){await this.waitAndRender(),super.start(e=>{this._process(e),this._render(this.renderer)})}free(){super.free(),this.enableAutoResize(!1),this.renderer.free()}toPixels(){return this.renderer.toPixels()}toImageData(){return new ImageData(this.toPixels(),this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)}toCanvas2D(){var s,n;const e=this.toImageData(),t=document.createElement("canvas");t.width=e.width,t.height=e.height,(s=t.getContext("2d"))==null||s.putImageData(e,0,0);const i=document.createElement("canvas");return i.width=this.width,i.height=this.height,(n=i.getContext("2d"))==null||n.drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),i}}let Ft;const mn=[];let wn=!1;async function wI(r=100){if(!wn){for(wn=!0;mn.length;){const A=mn.shift();if(A)try{await A()}catch(e){console.error(e)}else await new Promise(e=>setTimeout(e,r))}wn=!1}}async function vI(r){var n;const{data:A,width:e,height:t,debug:i=!1,time:s=0}=r;return Ft??(Ft=new Nl({width:1,height:1,preserveDrawingBuffer:!0})),Ft.debug=i,Ft.root.removeChildren(),Ft.timeline.currentTime=s,Ft.resize(e,t,!0),(Array.isArray(A)?A:[A]).forEach(o=>{o instanceof u.Node?Ft.root.appendChild(o):Ft.root.appendChild(u.Node.parse(o))}),await((n=r.onBeforeRender)==null?void 0:n.call(r,Ft)),await Ft.waitAndRender(),Ft.toCanvas2D()}async function _I(r){return new Promise(A=>{mn.push(async()=>A(await vI(r))),wI()})}u.AnimatedTexture=tr,u.Assets=Ul,u.AudioPipeline=yn,u.AudioProcessor=xd,u.AudioSpectrum=Fd,u.BaseElement2DStyle=vi,u.CanvasContext=Ma,u.CanvasItemEditor=mI,u.CanvasTexture=gi,u.Color=Zt,u.ColorMatrix=ds,u.ColorTexture=Cs,u.CoreObject=qi,u.DEG_TO_RAD=uo,u.DEVICE_PIXEL_RATIO=ns,u.EffectMaterial=er,u.Element2DStyle=Os,u.Engine=Nl,u.EventEmitter=Ot,u.FlexElement2DStyle=Fa,u.FlexLayout=gr,u.FontLoader=Ro,u.GIFLoader=bl,u.Geometry=$i,u.HTMLAudio=wl,u.HTMLAudioContext=Rr,u.HTMLSound=kr,u.IN_BROWSER=ni,u.ImageTexture=Fg,u.IndexBuffer=RA,u.Input=to,u.InputEvent=Xi,u.JSONLoader=xl,u.Loader=$t,u.LottieLoader=Sl,u.MainLoop=Zi,u.Material=Qe,u.Matrix=Dt,u.Matrix2=Cg,u.Matrix3=Is,u.Matrix4=co,u.MouseInputEvent=ls,u.PI=Lt,u.PI_2=et,u.PixelsTexture=Qs,u.PointerInputEvent=eo,u.Projection2D=Io,u.QuadGeometry=bg,u.QuadUvGeometry=fe,u.RAD_TO_DEG=Eg,u.RawWeakMap=SA,u.Rect2=Bs,u.RefCounted=$n,u.Renderer=Eo,u.Resource=Ht,u.SUPPORTS_AUDIO_CONTEXT=is,u.SUPPORTS_CLICK_EVENTS=Jn,u.SUPPORTS_CREATE_IMAGE_BITMAP=As,u.SUPPORTS_IMAGE_BITMAP=Gn,u.SUPPORTS_MOUSE_EVENTS=rg,u.SUPPORTS_OFFLINE_AUDIO_CONTEXT=ss,u.SUPPORTS_POINTER_EVENTS=xA,u.SUPPORTS_RESIZE_OBSERVER=On,u.SUPPORTS_TOUCH_EVENTS=Gt,u.SUPPORTS_WEBGL2=Ln,u.SUPPORTS_WEBKIT_AUDIO_CONTEXT=rs,u.SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT=Kn,u.SUPPORTS_WEB_AUDIO=Yn,u.SUPPORTS_WHEEL_EVENTS=Hn,u.SceneTree=mi,u.TextLoader=Ml,u.Texture2D=ve,u.TextureLoader=Rl,u.TextureRect2D=hr,u.Ticker=xe,u.Transform2D=Qt,u.TransformRect2D=Qn,u.UvGeometry=Rg,u.UvMaterial=kA,u.Vector=pt,u.Vector2=Ct,u.Vector3=Qg,u.Vector4=fo,u.VertexAttribute=lt,u.VertexBuffer=Kt,u.VideoLoader=kl,u.VideoTexture=Go,u.ViewportTexture=ms,u.WebAudio=_l,u.WebAudioContext=lA,u.WebGLBatch2DModule=Qo,u.WebGLBlendMode=MA,u.WebGLBufferModule=yo,u.WebGLFramebufferModule=mo,u.WebGLMaskModule=wo,u.WebGLModule=dt,u.WebGLProgramModule=vo,u.WebGLRenderer=Mo,u.WebGLScissorModule=_o,u.WebGLState=dA,u.WebGLStateModule=Co,u.WebGLStencilModule=Do,u.WebGLTextureModule=bo,u.WebGLVertexArrayModule=xo,u.WebGLViewportModule=So,u.WebSound=vl,u.WheelInputEvent=ai,u.assets=Nt,u.clamp=bt,u.createHTMLCanvas=qn,u.createNode=ng,u.crossOrigin=jn,u.cubicBezier=ei,u.curves=pg,u.customNode=re,u.customNodes=zi,u.defaultOptions=Pl,u.defineProperty=oi,u.determineCrossOrigin=Xn,u.ease=Cl,u.easeIn=Ql,u.easeInOut=ml,u.easeOut=yl,u.getDeclarations=Vi,u.getDefaultCssPropertyValue=ts,u.isCanvasElement=Vn,u.isElementNode=os,u.isImageElement=sg,u.isPow2=es,u.isVideoElement=Wn,u.isWebgl2=zn,u.lerp=Se,u.linear=pl,u.log2=ps,u.mapWebGLBlendModes=po,u.nextPow2=Es,u.nextTick=as,u.parseCSSFilter=Uo,u.parseCSSTransform=Po,u.parseCSSTransformOrigin=No,u.parseCssFunctions=si,u.parseCssProperty=ri,u.property=U,u.protectedProperty=Ee,u.render=_I,u.timingFunctions=Mr,u.uid=Fn,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -2222,19 +2222,15 @@ class Renderer {
|
|
|
2222
2222
|
return related;
|
|
2223
2223
|
}
|
|
2224
2224
|
resize(width, height, updateStyle = true) {
|
|
2225
|
-
const viewWidth = Math.floor(width * this.pixelRatio);
|
|
2226
|
-
const viewHeight = Math.floor(height * this.pixelRatio);
|
|
2227
|
-
const screenWidth = viewWidth / this.pixelRatio;
|
|
2228
|
-
const screenHeight = viewHeight / this.pixelRatio;
|
|
2229
2225
|
if (this.view) {
|
|
2230
|
-
this.view.width =
|
|
2231
|
-
this.view.height =
|
|
2226
|
+
this.view.width = Math.floor(width * this.pixelRatio);
|
|
2227
|
+
this.view.height = Math.floor(height * this.pixelRatio);
|
|
2232
2228
|
}
|
|
2233
|
-
this.screen.width =
|
|
2234
|
-
this.screen.height =
|
|
2229
|
+
this.screen.width = width;
|
|
2230
|
+
this.screen.height = height;
|
|
2235
2231
|
if (updateStyle && this.view) {
|
|
2236
|
-
this.view.style.width = `${
|
|
2237
|
-
this.view.style.height = `${
|
|
2232
|
+
this.view.style.width = `${width}px`;
|
|
2233
|
+
this.view.style.height = `${height}px`;
|
|
2238
2234
|
}
|
|
2239
2235
|
}
|
|
2240
2236
|
}
|
|
@@ -5276,10 +5272,14 @@ class PixelsTexture extends Texture2D {
|
|
|
5276
5272
|
_updateProperty(key, value, oldValue, declaration) {
|
|
5277
5273
|
switch (key) {
|
|
5278
5274
|
case "width":
|
|
5279
|
-
this.source.width = Math.round(
|
|
5275
|
+
this.source.width = Math.round(this.width * this.pixelRatio);
|
|
5280
5276
|
break;
|
|
5281
5277
|
case "height":
|
|
5282
|
-
this.source.height = Math.round(
|
|
5278
|
+
this.source.height = Math.round(this.height * this.pixelRatio);
|
|
5279
|
+
break;
|
|
5280
|
+
case "pixelRatio":
|
|
5281
|
+
this.source.width = Math.round(this.width * this.pixelRatio);
|
|
5282
|
+
this.source.height = Math.round(this.height * this.pixelRatio);
|
|
5283
5283
|
break;
|
|
5284
5284
|
}
|
|
5285
5285
|
super._updateProperty(key, value, oldValue, declaration);
|
|
@@ -6202,9 +6202,9 @@ let Viewport = class extends Node {
|
|
|
6202
6202
|
const { pixelRatio } = renderer;
|
|
6203
6203
|
this._framebuffers.forEach((framebuffer) => {
|
|
6204
6204
|
const texture = framebuffer.texture;
|
|
6205
|
-
texture.pixelRatio = pixelRatio;
|
|
6206
6205
|
texture.width = width;
|
|
6207
6206
|
texture.height = height;
|
|
6207
|
+
texture.pixelRatio = pixelRatio;
|
|
6208
6208
|
texture.upload(renderer);
|
|
6209
6209
|
});
|
|
6210
6210
|
return {
|
|
@@ -9784,6 +9784,7 @@ let Text2D = class extends TextureRect2D {
|
|
|
9784
9784
|
fonts;
|
|
9785
9785
|
texture = new CanvasTexture();
|
|
9786
9786
|
text = new Text();
|
|
9787
|
+
measureResult;
|
|
9787
9788
|
_subTextsCount = 0;
|
|
9788
9789
|
constructor(properties, children = []) {
|
|
9789
9790
|
super();
|
|
@@ -9817,7 +9818,17 @@ let Text2D = class extends TextureRect2D {
|
|
|
9817
9818
|
this.text.requestUpdate();
|
|
9818
9819
|
}
|
|
9819
9820
|
_updateStyleProperty(key, value, oldValue) {
|
|
9820
|
-
|
|
9821
|
+
switch (key) {
|
|
9822
|
+
case "left":
|
|
9823
|
+
case "top":
|
|
9824
|
+
case "width":
|
|
9825
|
+
case "height":
|
|
9826
|
+
this.requestRedraw();
|
|
9827
|
+
break;
|
|
9828
|
+
default:
|
|
9829
|
+
super._updateStyleProperty(key, value, oldValue);
|
|
9830
|
+
break;
|
|
9831
|
+
}
|
|
9821
9832
|
switch (key) {
|
|
9822
9833
|
case "width":
|
|
9823
9834
|
if (this.split) {
|
|
@@ -9839,10 +9850,9 @@ let Text2D = class extends TextureRect2D {
|
|
|
9839
9850
|
}
|
|
9840
9851
|
_updateSubTexts() {
|
|
9841
9852
|
const subTexts = this._getSubTexts();
|
|
9842
|
-
const result = this.measure();
|
|
9843
9853
|
let i = 0;
|
|
9844
9854
|
if (this.split) {
|
|
9845
|
-
|
|
9855
|
+
this.updateMeasure().measureResult?.paragraphs.forEach((p) => {
|
|
9846
9856
|
p.fragments.forEach((f) => {
|
|
9847
9857
|
f.characters.forEach((c) => {
|
|
9848
9858
|
const child = subTexts[i];
|
|
@@ -9858,21 +9868,26 @@ let Text2D = class extends TextureRect2D {
|
|
|
9858
9868
|
}
|
|
9859
9869
|
measure() {
|
|
9860
9870
|
this._updateText();
|
|
9861
|
-
|
|
9862
|
-
|
|
9863
|
-
|
|
9864
|
-
|
|
9865
|
-
|
|
9866
|
-
|
|
9871
|
+
return this.text.measure();
|
|
9872
|
+
}
|
|
9873
|
+
updateMeasure() {
|
|
9874
|
+
this.measureResult = this.measure();
|
|
9875
|
+
const textWidth = this.measureResult.boundingBox.width;
|
|
9876
|
+
const textHeight = this.measureResult.boundingBox.height;
|
|
9877
|
+
const { left, top, width, height = textHeight } = this.style;
|
|
9878
|
+
this.position.x = left + Math.min(0, ((width || textWidth) - textWidth) / 2);
|
|
9879
|
+
this.position.y = top + Math.min(0, ((height || textHeight) - textHeight) / 2);
|
|
9880
|
+
this.size.width = textWidth;
|
|
9881
|
+
this.size.height = textHeight;
|
|
9882
|
+
return this;
|
|
9867
9883
|
}
|
|
9868
9884
|
_updateSplit() {
|
|
9869
9885
|
if (this._subTextsCount) {
|
|
9870
9886
|
this.getChildren("front").forEach((child) => this.removeChild(child));
|
|
9871
9887
|
this._subTextsCount = 0;
|
|
9872
9888
|
}
|
|
9873
|
-
const result = this.measure();
|
|
9874
9889
|
if (this.split) {
|
|
9875
|
-
|
|
9890
|
+
this.measureResult?.paragraphs.forEach((p) => {
|
|
9876
9891
|
p.fragments.forEach((f) => {
|
|
9877
9892
|
f.characters.forEach((c) => {
|
|
9878
9893
|
this.appendChild(
|
|
@@ -9895,13 +9910,16 @@ let Text2D = class extends TextureRect2D {
|
|
|
9895
9910
|
});
|
|
9896
9911
|
}
|
|
9897
9912
|
}
|
|
9913
|
+
_redraw() {
|
|
9914
|
+
this.updateMeasure();
|
|
9915
|
+
return super._redraw();
|
|
9916
|
+
}
|
|
9898
9917
|
_drawContent() {
|
|
9899
9918
|
if (!this.split) {
|
|
9900
9919
|
const onText2DRender = this.getChildren()?.find((child) => "onText2DRender" in child)?.onText2DRender;
|
|
9901
9920
|
if (onText2DRender) {
|
|
9902
9921
|
onText2DRender();
|
|
9903
9922
|
} else {
|
|
9904
|
-
this._updateText();
|
|
9905
9923
|
this.text.render({
|
|
9906
9924
|
pixelRatio: this.texture.pixelRatio,
|
|
9907
9925
|
view: this.texture.source
|
|
@@ -13100,7 +13118,8 @@ class Engine extends SceneTree {
|
|
|
13100
13118
|
this.renderer.resize(width, height, updateCss);
|
|
13101
13119
|
this.root.width = width;
|
|
13102
13120
|
this.root.height = height;
|
|
13103
|
-
this.
|
|
13121
|
+
this.root.requestUpload();
|
|
13122
|
+
this.render();
|
|
13104
13123
|
return this;
|
|
13105
13124
|
}
|
|
13106
13125
|
nextTick() {
|