// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define(["../../request","../../core/Error","../../core/Logger","../../core/typedArrayUtil","../../core/urlUtils"],function(h,g,n,k,l){function m(a){var b=document.createElement("canvas");const e=b.getContext("2d");b.width=a.width;b.height=a.height;e.drawImage(a,0,0,a.width,a.height);b=e.getImageData(0,0,a.width,a.height);return{width:a.width,height:a.height,data:new Uint8Array(b.data)}}class p{constructor(a,b){this._spriteSource=a;this._maxTextureSize=b;this.devicePixelRatio=1;this._spriteImageFormat= "png";this._isRetina=!1;this._spritesData={};this.height=this.width=this.image=null;this.loadStatus="not-loaded";"url"===a.type&&a.spriteFormat&&(this._spriteImageFormat=a.spriteFormat);a.pixelRatio&&(this.devicePixelRatio=a.pixelRatio);this.baseURL=a.spriteUrl}get spriteNames(){const a=[];for(const b in this._spritesData)a.push(b);a.sort();return a}getSpriteInfo(a){return this._spritesData?this._spritesData[a]:null}async load(a){if(this.baseURL){this.loadStatus="loading";try{await this._loadSprites(a), this.loadStatus="loaded"}catch{this.loadStatus="failed"}}else this.loadStatus="failed"}async _loadSprites(a){this._isRetina=1.15a||e>a)throw a=`Sprite resource for style ${this.baseURL} is bigger than the maximum allowed of ${a} pixels}`,n.getLogger("esri.layers.support.SpriteSource").error(a), new g("SpriteSource",a);for(let d=0;dthis.devicePixelRatio){if(!a.spriteSource1x)throw new g("SpriteSource","no image data provided for low resolution sprites!");b=a.spriteSource1x.image;a=a.spriteSource1x.json}else{if(!a.spriteSource2x)throw new g("SpriteSource","no image data provided for high resolution sprites!"); b=a.spriteSource2x.image;a=a.spriteSource2x.json}return"width"in b&&"height"in b&&"data"in b&&(k.isArrayBuffer(b.data)||k.isUint8ClampedArray(b.data))?{width:b.width,height:b.height,data:new Uint8Array(b.data),json:a}:{...m(b),json:a}}a=l.urlToObject(this.baseURL);const e=a.query?"?"+l.objectToQuery(a.query):"",c=this._isRetina?"@2x":"",f=`${a.path}${c}.${this._spriteImageFormat}${e}`,[d,q]=await Promise.all([h(`${a.path}${c}.json${e}`,b),h(f,{responseType:"image",...b})]);return{...m(q.data),json:d.data}}} return p});