/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../../chunks/_rollupPluginBabelHelpers","../../../../chunks/tslib.es6","../../../../core/maybe","../../../../core/accessorSupport/decorators/property","../../../../core/arrayUtils","../../../../core/has","../../../../core/accessorSupport/ensureType","../../../../core/accessorSupport/decorators/subclass","../../engine/imagery/RasterTileContainer","./BaseImageryTileSubView2D","../support/util"],(function(e,r,t,i,o,n,s,a,l,c,u){"use strict";let p=function(r){function i(){var e;return(e=r.apply(this,arguments)||this).container=null,e.layer=null,e.type="raster",e}e._inheritsLoose(i,r);var o=i.prototype;return o.attach=function(){r.prototype.attach.call(this),this.container=new l.RasterTileContainer(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme},o.detach=function(){r.prototype.detach.call(this),this.container.removeAllChildren(),this.container=null},o.canUseWebGLForProcessing=function(){return this.useWebGLForProcessing&&this.layer.symbolizer.canRenderInWebGL&&!("majority"===this.layer.interpolation&&u.canUseMajorityInterpolationOnDataSource(this.layer))},o.fetchTile=function(e,r){return this.layer.fetchTile(e.level,e.row,e.col,r)},o.updateTileSource=function(){var r=e._asyncToGenerator((function*(e,r){const{bandIds:i}=this.layer,o=this._getLayerInterpolation(),n=this.canUseWebGLForProcessing(),{source:s,globalSymbolizerParams:a,suspended:l,coords:c,resolution:u}=r,p=this.layerView.hasTilingEffects?a:r.symbolizerParams,{bitmap:y}=e;if([y.x,y.y]=c,y.resolution=u,s&&t.isSome(s)&&t.isSome(s.pixelBlock)){const e={extent:s.extent,pixelBlock:s.pixelBlock};if(y.rawPixelData=e,n)y.source=s.pixelBlock,y.isRendereredSource=!1;else{const r=yield this.layer.applyRenderer(e,"stretch"===(null==a?void 0:a.type)?a:null);y.source=r,y.isRendereredSource=!0}y.symbolizerParameters=n?p:null,n?y.transformGrid||(y.transformGrid=s.transformGrid):y.transformGrid=null}else{const e=this.createEmptyTilePixelBlock();y.source=e,y.symbolizerParameters=n?p:null,y.transformGrid=null}y.bandIds=n?i:null,y.width=this._tileInfoView.tileInfo.size[0],y.height=this._tileInfoView.tileInfo.size[1],y.interpolation=o,y.suspended=l,y.invalidateTexture()}));function i(e,t){return r.apply(this,arguments)}return i}(),o.updateTileSymbolizerParameters=function(){var r=e._asyncToGenerator((function*(e,r){const{local:i,global:o}=r,{bandIds:n}=this.layer,s=this._getLayerInterpolation(),a=this.canUseWebGLForProcessing(),{bitmap:l}=e,{rawPixelData:c}=l;!a&&t.isSome(c)?(l.source=yield this.layer.applyRenderer(c,"stretch"===(null==o?void 0:o.type)?o:null),l.isRendereredSource=!0):(l.isRendereredSource&&t.isSome(c)&&(l.source=c.pixelBlock),l.isRendereredSource=!1),l.symbolizerParameters=a?this.layerView.hasTilingEffects?o:i:null,l.bandIds=a?n:null,l.interpolation=s,l.suspended=!1}));function i(e,t){return r.apply(this,arguments)}return i}(),o._getLayerInterpolation=function(){const e=this.layer.renderer.type;if("raster-colormap"===e||"unique-value"===e||"class-breaks"===e)return"nearest";const{interpolation:r}=this.layer,{renderer:t}=this.layer;return"raster-stretch"===t.type&&null!=t.colorRamp?"bilinear"===r||"cubic"===r?"bilinear":"nearest":r},i}(c.BaseImageryTileSubView2D);r.__decorate([i.property()],p.prototype,"container",void 0),r.__decorate([i.property()],p.prototype,"layer",void 0),r.__decorate([i.property()],p.prototype,"type",void 0),p=r.__decorate([a.subclass("esri.views.2d.layers.imagery.ImageryTileView2D")],p);return p}));
