var gdjs;(function(g){const u=new g.Logger("PIXI Image manager"),d=GlobalPIXIModule.PIXI,c=(a,e)=>{u.error("Unable to load file "+a+" with error:",e||"(unknown error)")},x=(a,e)=>{!a||e.smoothed||(a.baseTexture.scaleMode=d.SCALE_MODES.NEAREST)},I=(a,e,n)=>{for(let s=0,r=a.length;s<r;++s){const t=a[s];if(t.name===e&&t.kind===n)return t}return null};class R{constructor(e,n){this._resources=e,this._resourcesLoader=n,this._invalidTexture=d.Texture.from("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAFElEQVQoU2P8z/D/PwMewDgyFAAApMMX8Zi0uXAAAAAASUVORK5CYIIA"),this._loadedTextures=new Hashtable}setResources(e){this._resources=e}getPIXITexture(e){if(this._loadedTextures.containsKey(e)){const t=this._loadedTextures.get(e);if(t.valid)return t;u.error("Texture for "+e+" is not valid anymore (or never was).")}if(e==="")return this._invalidTexture;const n=I(this._resources,e,"image");if(!n)return u.warn('Unable to find texture for resource "'+e+'".'),this._invalidTexture;u.log('Loading texture for resource "'+e+'"...');const s=n.file,r=d.Texture.from(this._resourcesLoader.getFullUrl(s),{resourceOptions:{crossorigin:this._resourcesLoader.checkIfCredentialsRequired(s)?"use-credentials":"anonymous"}}).on("error",t=>{c(s,t)});return x(r,n),this._loadedTextures.put(e,r),r}getPIXIVideoTexture(e){if(this._loadedTextures.containsKey(e))return this._loadedTextures.get(e);if(e==="")return this._invalidTexture;const n=I(this._resources,e,"video");if(!n)return u.warn('Unable to find video texture for resource "'+e+'".'),this._invalidTexture;const s=n.file;u.log('Loading video texture for resource "'+e+'"...');const r=d.Texture.from(this._resourcesLoader.getFullUrl(s),{resourceOptions:{crossorigin:this._resourcesLoader.checkIfCredentialsRequired(s)?"use-credentials":"anonymous"}}).on("error",t=>{c(s,t)});return this._loadedTextures.put(e,r),r}getInvalidPIXITexture(){return this._invalidTexture}loadTextures(e,n){const s=this._resources,r={};for(let i=0,l=s.length;i<l;++i){const o=s[i];if(o.file&&o.kind==="image"){if(this._loadedTextures.containsKey(o.name))continue;r[o.file]=r[o.file]?r[o.file].concat(o):[o]}}const t=Object.keys(r).length;if(t===0)return n(t);const f=d.Loader.shared;let A=0;const _=f.onProgress.add(function(){A++,e(A,t)});for(const i in r)r.hasOwnProperty(i)&&f.add({name:i,url:this._resourcesLoader.getFullUrl(i),loadType:d.LoaderResource.LOAD_TYPE.IMAGE,crossOrigin:this._resourcesLoader.checkIfCredentialsRequired(i)?"use-credentials":"anonymous"});f.load((i,l)=>{i.onProgress.detach(_);for(const o in l)if(l.hasOwnProperty(o)){if(!r.hasOwnProperty(o))continue;r[o].forEach(T=>{const h=l[o].texture;if(!h){const P=l[o].error;c(o,P);return}this._loadedTextures.put(T.name,h),x(h,T)})}n(t)})}}g.PixiImageManager=R,g.ImageManager=g.PixiImageManager})(gdjs||(gdjs={}));
//# sourceMappingURL=pixi-image-manager.js.map
