/*
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/Logger","../../../core/promiseUtils","../../../core/reactiveUtils","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","../../../support/GraphicsCollection","../engine/BitmapContainer","./LayerView2D","./graphics/GraphicsView2D","./graphics/HighlightGraphicContainer","./support/ExportStrategy","../../layers/LayerView","../../layers/MapImageLayerView","../../layers/RefreshableLayerView","../../support/drapedUtils"],(function(e,t,i,r,a,s,o,n,h,p,c,u,l,d,g,y,m,f,v,w){"use strict";const _=i.getLogger("esri.views.2d.layers.MapImageLayerView2D");let C=function(t){function i(){var e;return(e=t.apply(this,arguments)||this)._highlightGraphics=new c.GraphicsCollection,e}e._inheritsLoose(i,t);var s=i.prototype;return s.update=function(e){this.strategy.update(e).catch((e=>{r.isAbortError(e)||_.error(e)}))},s.attach=function(){const{imageMaxWidth:e,imageMaxHeight:t,version:i}=this.layer,r=i>=10.3,s=i>=10;this._bitmapContainer=new u.BitmapContainer,this.container.addChild(this._bitmapContainer);const o=new d({view:this.view,graphics:this._highlightGraphics,requestUpdateCallback:()=>this.requestUpdate(),container:new g(this.view.featuresTilingScheme)});this.container.addChild(o.container),this.strategy=new y({container:this._bitmapContainer,fetchSource:this.fetchImage.bind(this),requestUpdate:this.requestUpdate.bind(this),imageMaxWidth:e,imageMaxHeight:t,imageRotationSupported:r,imageNormalizationSupported:s,hidpi:!0}),this.handles.add(a.watch((()=>this.exportImageVersion),(()=>this.requestUpdate())),"exportImageVersion"),this.handles.add(a.watch((()=>{var e;return null==(e=this.view)?void 0:e.floors}),(()=>this.requestUpdate())),"view.floors"),this.requestUpdate()},s.detach=function(){this.handles.remove("exportImageVersion"),this.handles.remove("view.floors"),this.strategy.destroy(),this.container.removeAllChildren(),this._bitmapContainer.removeAllChildren()},s.moveStart=function(){},s.viewChange=function(){},s.moveEnd=function(){this.requestUpdate()},s.highlight=function(e,t){return this._highlightGraphics.add(e),{remove:()=>{this._highlightGraphics.remove(e)}}},s.supportsSpatialReference=function(e){return this.layer.serviceSupportsSpatialReference(e)},s.createFetchPopupFeaturesQueryGeometry=function(e,t){return w.createQueryGeometry(e,t,this.view)},s.doRefresh=function(){var t=e._asyncToGenerator((function*(){this.requestUpdate()}));function i(){return t.apply(this,arguments)}return i}(),s.isUpdating=function(){return this.strategy.updating||this.updateRequested},s.fetchImage=function(e,t,i,r){return this.layer.fetchImage(e,t,i,{timeExtent:this.timeExtent,floors:this.view.floors,...r})},i}(f(v(l.LayerView2DMixin(m))));t.__decorate([s.property()],C.prototype,"strategy",void 0),t.__decorate([s.property()],C.prototype,"updating",void 0),C=t.__decorate([p.subclass("esri.views.2d.layers.MapImageLayerView2D")],C);return C}));
