/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../chunks/_rollupPluginBabelHelpers","../../../../core/maybe","../../../../core/promiseUtils","../core/shaderModules/interfaces","./basicInterfaces","./GLMaterial"],(function(e,t,r,i,s,u,l){"use strict";let n=function(e){function s(t){var r;return(r=e.call(this,t)||this)._numLoading=0,r._disposed=!1,r._textureRepository=t.textureRep,r._textureId=t.textureId,r._acquire(t.textureId,(e=>r._texture=e)),r._acquire(t.normalTextureId,(e=>r._textureNormal=e)),r._acquire(t.emissiveTextureId,(e=>r._textureEmissive=e)),r._acquire(t.occlusionTextureId,(e=>r._textureOcclusion=e)),r._acquire(t.metallicRoughnessTextureId,(e=>r._textureMetallicRoughness=e)),r}t._inheritsLoose(s,e);var l=s.prototype;return l.dispose=function(){this._texture=r.releaseMaybe(this._texture),this._textureNormal=r.releaseMaybe(this._textureNormal),this._textureEmissive=r.releaseMaybe(this._textureEmissive),this._textureOcclusion=r.releaseMaybe(this._textureOcclusion),this._textureMetallicRoughness=r.releaseMaybe(this._textureMetallicRoughness),this._disposed=!0},l.ensureResources=function(e){return 0===this._numLoading?u.ResourceState.LOADED:u.ResourceState.LOADING},l.updateTexture=function(e){(r.isNone(this._texture)||e!==this._texture.id)&&(this._texture=r.releaseMaybe(this._texture),this._textureId=e,this._acquire(this._textureId,(e=>this._texture=e)))},l._acquire=function(e,t){if(r.isNone(e))return void t(null);const s=this._textureRepository.acquire(e);if(i.isPromiseLike(s))return++this._numLoading,void s.then((e=>{if(this._disposed)return r.releaseMaybe(e),void t(null);t(e)})).finally((()=>--this._numLoading));t(s)},t._createClass(s,[{key:"textureBindParameters",get:function(){return new o(r.isSome(this._texture)?this._texture.glTexture:null,r.isSome(this._textureNormal)?this._textureNormal.glTexture:null,r.isSome(this._textureEmissive)?this._textureEmissive.glTexture:null,r.isSome(this._textureOcclusion)?this._textureOcclusion.glTexture:null,r.isSome(this._textureMetallicRoughness)?this._textureMetallicRoughness.glTexture:null)}}]),s}(l),o=function(e){function r(t=null,r=null,i=null,s=null,u=null){var l;return(l=e.call(this)||this).texture=t,l.textureNormal=r,l.textureEmissive=i,l.textureOcclusion=s,l.textureMetallicRoughness=u,l}return t._inheritsLoose(r,e),r}(s.NoParameters);e.GLTextureMaterial=n,e.GLTextureMaterialBindParameters=o,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
