modern-canvas 0.4.19 → 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 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 = viewWidth;
2237
- this.view.height = viewHeight;
2232
+ this.view.width = Math.floor(width * this.pixelRatio);
2233
+ this.view.height = Math.floor(height * this.pixelRatio);
2238
2234
  }
2239
- this.screen.width = screenWidth;
2240
- this.screen.height = screenHeight;
2235
+ this.screen.width = width;
2236
+ this.screen.height = height;
2241
2237
  if (updateStyle && this.view) {
2242
- this.view.style.width = `${screenWidth}px`;
2243
- this.view.style.height = `${screenHeight}px`;
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(value * this.pixelRatio);
5281
+ this.source.width = Math.round(this.width * this.pixelRatio);
5286
5282
  break;
5287
5283
  case "height":
5288
- this.source.height = Math.round(value * this.pixelRatio);
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 {
@@ -13124,7 +13124,8 @@ class Engine extends SceneTree {
13124
13124
  this.renderer.resize(width, height, updateCss);
13125
13125
  this.root.width = width;
13126
13126
  this.root.height = height;
13127
- this.renderer.program.uniforms.projectionMatrix = this.root.toProjectionArray(true);
13127
+ this.root.requestUpload();
13128
+ this.render();
13128
13129
  return this;
13129
13130
  }
13130
13131
  nextTick() {
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;
@@ -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 = viewWidth;
2231
- this.view.height = viewHeight;
2226
+ this.view.width = Math.floor(width * this.pixelRatio);
2227
+ this.view.height = Math.floor(height * this.pixelRatio);
2232
2228
  }
2233
- this.screen.width = screenWidth;
2234
- this.screen.height = screenHeight;
2229
+ this.screen.width = width;
2230
+ this.screen.height = height;
2235
2231
  if (updateStyle && this.view) {
2236
- this.view.style.width = `${screenWidth}px`;
2237
- this.view.style.height = `${screenHeight}px`;
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(value * this.pixelRatio);
5275
+ this.source.width = Math.round(this.width * this.pixelRatio);
5280
5276
  break;
5281
5277
  case "height":
5282
- this.source.height = Math.round(value * this.pixelRatio);
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 {
@@ -13118,7 +13118,8 @@ class Engine extends SceneTree {
13118
13118
  this.renderer.resize(width, height, updateCss);
13119
13119
  this.root.width = width;
13120
13120
  this.root.height = height;
13121
- this.renderer.program.uniforms.projectionMatrix = this.root.toProjectionArray(true);
13121
+ this.root.requestUpload();
13122
+ this.render();
13122
13123
  return this;
13123
13124
  }
13124
13125
  nextTick() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.4.19",
4
+ "version": "0.4.20",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",