/*
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","../PopupTemplate","../core/maybe","../core/MultiOriginJSONSupport","../core/promiseUtils","../core/accessorSupport/decorators/property","../core/arrayUtils","../core/has","../core/accessorSupport/ensureType","../core/accessorSupport/decorators/subclass","../core/accessorSupport/decorators/writer","./Layer","./mixins/ArcGISImageService","./mixins/ArcGISService","./mixins/BlendLayer","./mixins/CustomParametersMixin","./mixins/OperationalLayer","./mixins/PortalLayer","./mixins/RefreshableLayer","./mixins/ScaleRangeLayer","./mixins/TemporalLayer","./support/commonProperties","./support/versionUtils","../support/popupUtils"],(function(e,r,t,a,o,i,p,s,n,c,l,u,y,d,m,S,v,f,h,g,L,I,_,T,b){"use strict";let w=function(r){function t(...e){var t;return(t=r.call(this,...e)||this).legendEnabled=!0,t.isReference=null,t.operationalLayerType="ArcGISImageServiceLayer",t.popupEnabled=!0,t.popupTemplate=null,t.type="imagery",t}e._inheritsLoose(t,r);var o=t.prototype;return o.normalizeCtorArgs=function(e,r){return"string"==typeof e?{url:e,...r}:e},o.load=function(e){const r=a.isSome(e)?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Image Service"]},e).catch(i.throwIfAbortError).then((()=>this._fetchService(r)))),Promise.resolve(this)},o.writeOperationalLayerType=function(e,r,t){var a;const o="vector-field"===(null==(a=this.renderer)?void 0:a.type);r[t]=o?"ArcGISImageServiceVectorLayer":"ArcGISImageServiceLayer"},o.createPopupTemplate=function(e){const r=this.rasterFields,t=this.title,a=new Set;let o=!1,i=!1;this.capabilities&&(o=this.capabilities.operations.supportsQuery&&this.fields&&this.fields.length>0,i="esriImageServiceDataTypeVector-UV"===this.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===this.serviceDataType);const p=new Set;o&&p.add("raster.itempixelvalue");for(const s of r){const e=s.name.toLowerCase();p.has(e)||e.includes("raster.servicepixelvalue.")||a.add(s.name)}return i&&a.add("raster.magnitude").add("raster.direction"),b.createPopupTemplate({fields:r,title:t},{...e,visibleFieldNames:a})},o.queryFeatures=function(e,r){return this.queryRasters(e,r).then((e=>{if(null!=e&&e.features)for(const r of e.features)r.layer=r.sourceLayer=this;return e}))},o.queryFeatureCount=function(e,r){return this.queryRasterCount(e,r)},o.redraw=function(){this.emit("redraw")},o.serviceSupportsSpatialReference=function(e){return T.serviceSupportsSpatialReference(this,e)},e._createClass(t,[{key:"defaultPopupTemplate",get:function(){return this.createPopupTemplate()}}]),t}(S.BlendLayer(I.TemporalLayer(g.RefreshableLayer(L.ScaleRangeLayer(f.OperationalLayer(h.PortalLayer(d.ArcGISImageService(v.CustomParametersMixin(m.ArcGISService(o.MultiOriginJSONMixin(y)))))))))));r.__decorate([p.property(_.legendEnabled)],w.prototype,"legendEnabled",void 0),r.__decorate([p.property({type:["show","hide"]})],w.prototype,"listMode",void 0),r.__decorate([p.property({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],w.prototype,"isReference",void 0),r.__decorate([p.property({type:["ArcGISImageServiceLayer"],json:{origins:{"web-map":{type:["ArcGISImageServiceLayer","ArcGISImageServiceVectorLayer"],read:!1,write:{target:"layerType",ignoreOrigin:!0}}}}})],w.prototype,"operationalLayerType",void 0),r.__decorate([u.writer("web-map","operationalLayerType")],w.prototype,"writeOperationalLayerType",null),r.__decorate([p.property(_.popupEnabled)],w.prototype,"popupEnabled",void 0),r.__decorate([p.property({type:t,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],w.prototype,"popupTemplate",void 0),r.__decorate([p.property({readOnly:!0})],w.prototype,"defaultPopupTemplate",null),r.__decorate([p.property({readOnly:!0,json:{read:!1}})],w.prototype,"type",void 0),w=r.__decorate([l.subclass("esri.layers.ImageryLayer")],w);return w}));
