0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(e){return e[this._name]&&(this.ensureNonAliasedItems(),this.remove(e),this.items.push(e)),this}remove(e){let t=this.items.indexOf(e);return t!==-1&&(this.ensureNonAliasedItems(),this.items.splice(t,1)),this}contains(e){return this.items.includes(e)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}};Object.defineProperties(Ht.prototype,{dispatch:{value:Ht.prototype.emit},run:{value:Ht.prototype.emit}});var fr=class{constructor(e=0,t=0){this._width=e,this._height=t,this.destroyed=!1,this.internal=!1,this.onResize=new Ht("setRealSize"),this.onUpdate=new Ht("update"),this.onError=new Ht("onError")}bind(e){this.onResize.add(e),this.onUpdate.add(e),this.onError.add(e),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(e){this.onResize.remove(e),this.onUpdate.remove(e),this.onError.remove(e)}resize(e,t){(e!==this._width||t!==this._height)&&(this._width=e,this._height=t,this.onResize.emit(e,t))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(e,t,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(e,t){return!1}};var Q0=class extends fr{constructor(e,t){let{width:i,height:s}=t||{};if(!i||!s)throw new Error("BufferResource width or height invalid");super(i,s),this.data=e}upload(e,t,i){let s=e.gl;s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.alphaMode===Qt.UNPACK);let n=t.realWidth,o=t.realHeight;return i.width===n&&i.height===o?s.texSubImage2D(t.target,0,0,0,n,o,t.format,i.type,this.data):(i.width=n,i.height=o,s.texImage2D(t.target,0,i.internalFormat,n,o,0,t.format,i.type,this.data)),!0}dispose(){this.data=null}static test(e){return e instanceof Float32Array||e instanceof Uint8Array||e instanceof Uint32Array}};var nE={scaleMode:Nr.NEAREST,format:le.RGBA,alphaMode:Qt.NPM},Zo=class extends js.default{constructor(r=null,e=null){super(),e=Object.assign({},Zo.defaultOptions,e);let{alphaMode:t,mipmap:i,anisotropicLevel:s,scaleMode:n,width:o,height:a,wrapMode:l,format:c,type:h,target:d,resolution:p,resourceOptions:g}=e;r&&!(r instanceof fr)&&(r=Ko(r,g),r.internal=!0),this.resolution=p||K.RESOLUTION,this.width=Math.round((o||0)*this.resolution)/this.resolution,this.height=Math.round((a||0)*this.resolution)/this.resolution,this._mipmap=i,this.anisotropicLevel=s,this._wrapMode=l,this._scaleMode=n,this.format=c,this.type=h,this.target=d,this.alphaMode=t,this.uid=_i(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=o>0&&a>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(r)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(r){this._mipmap!==r&&(this._mipmap=r,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(r){this._scaleMode!==r&&(this._scaleMode=r,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(r){this._wrapMode!==r&&(this._wrapMode=r,this.dirtyStyleId++)}setStyle(r,e){let t;return r!==void 0&&r!==this.scaleMode&&(this.scaleMode=r,t=!0),e!==void 0&&e!==this.mipmap&&(this.mipmap=e,t=!0),t&&this.dirtyStyleId++,this}setSize(r,e,t){return t=t||this.resolution,this.setRealSize(r*t,e*t,t)}setRealSize(r,e,t){return this.resolution=t||this.resolution,this.width=Math.round(r)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=Ol(this.realWidth)&&Ol(this.realHeight)}setResolution(r){let e=this.resolution;return e===r?this:(this.resolution=r,this.valid&&(this.width=Math.round(this.width*e)/r,this.height=Math.round(this.height*e)/r,this.emit("update",this)),this._refreshPOT(),this)}setResource(r){if(this.resource===r)return this;if(this.resource)throw new Error("Resource can be set only once");return r.bind(this),this.resource=r,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(r){this.emit("error",this,r)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete O0[this.cacheId],delete c0[this.cacheId],this.cacheId=null),this.dispose(),Zo.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(r,e,t=K.STRICT_TEXTURE_CACHE){let i=typeof r=="string",s=null;if(i)s=r;else{if(!r._pixiId){let o=e?.pixiIdPrefix||"pixiid";r._pixiId=`${o}_${_i()}`}s=r._pixiId}let n=O0[s];if(i&&t&&!n)throw new Error(`The cacheId "${s}" does not exist in BaseTextureCache.`);return n||(n=new Zo(r,e),n.cacheId=s,Zo.addToCache(n,s)),n}static fromBuffer(r,e,t,i){r=r||new Float32Array(e*t*4);let s=new Q0(r,{width:e,height:t}),n=r instanceof Float32Array?Ce.FLOAT:Ce.UNSIGNED_BYTE;return new Zo(s,Object.assign({},nE,{type:n},i))}static addToCache(r,e){e&&(r.textureCacheIds.includes(e)||r.textureCacheIds.push(e),O0[e]&&O0[e]!==r&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),O0[e]=r)}static removeFromCache(r){if(typeof r=="string"){let e=O0[r];if(e){let t=e.textureCacheIds.indexOf(r);return t>-1&&e.textureCacheIds.splice(t,1),delete O0[r],e}}else if(r?.textureCacheIds){for(let e=0;e