/*
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/Error","../core/maybe","../core/MultiOriginJSONSupport","../core/reactiveUtils","../core/accessorSupport/decorators/aliasOf","../core/arrayUtils","../core/has","../core/accessorSupport/ensureType","../core/accessorSupport/decorators/property","../core/accessorSupport/decorators/subclass","./Layer","./mixins/BlendLayer","./mixins/CustomParametersMixin","./mixins/ImageryTileMixin","./mixins/OperationalLayer","./mixins/PortalLayer","./mixins/RefreshableLayer","./mixins/ScaleRangeLayer","./mixins/TemporalLayer","./support/commonProperties","./support/Field","./support/rasterDatasets/WCSRaster","../support/popupUtils"],(function(e,r,t,o,i,s,a,n,l,p,u,c,d,y,m,v,f,h,g,_,P,S,x,L,I){"use strict";const T=new Set(["milliseconds","seconds","minutes","hours","days","weeks","months","years","decades","centuries"]);let O=function(r){function i(...e){var t;return(t=r.call(this,...e)||this).coverageId=null,t.coverageInfo=null,t.version=null,t.isReference=null,t.type="wcs",t.popupEnabled=!0,t.popupTemplate=null,t.fields=null,t}e._inheritsLoose(i,r);var a=i.prototype;return a.normalizeCtorArgs=function(e,r){return"string"==typeof e?{url:e,...r}:e},a.load=function(e){const r=o.isSome(e)?e.signal:null;return this.addResolvingPromise(this._openRaster(r)),Promise.resolve(this)},a.createPopupTemplate=function(e){return I.createPopupTemplate({fields:this.rasterFields,title:this.title},e)},a._openRaster=function(){var r=e._asyncToGenerator((function*(e){const r=new L({url:this.url,version:this.version,coverageId:this.coverageId,ioConfig:{sampling:"closest",...this.ioConfig,customFetchParameters:this.customParameters}});if(yield r.open({signal:e}),!r.rasterInfo)throw r.destroy(),new t("wcs-layer:load","cannot load resources on "+this.url);null==this.title&&this.setAtOrigin("title",r.datasetName,"service"),null==this.coverageId&&this.setAtOrigin("coverageId",r.coverageInfo.id,"service");const{multidimensionalInfo:i}=r.rasterInfo;if(o.isSome(i)){const e=i.variables[0].dimensions.find((({name:e})=>"StdTime"===e));if(e){var a,n,l,p,u;let r=null!=(a=null==(n=e.extent)?void 0:n[0])?a:e.values[0];Array.isArray(r)&&(r=r[0]);let t=null!=(l=null==(p=e.extent)?void 0:p[1])?l:e.values[e.values.length-1];Array.isArray(t)&&(t=t[1]);const o=T.has(null==(u=e.intervalUnit)?void 0:u.toLowerCase())?e.intervalUnit.toLowerCase():null;this.set("timeInfo",{startField:"StdTime",fullTimeExtent:{start:r,end:t},timeReference:null,interval:o?{value:e.interval,unit:o}:null})}}this.raster=r,this._configDefaultSettings(),this.own(s.watch((()=>this.customParameters),(e=>this.raster.ioConfig.customFetchParameters=e)))}));function i(e){return r.apply(this,arguments)}return i}(),e._createClass(i,[{key:"defaultPopupTemplate",get:function(){return this.createPopupTemplate()}},{key:"rasterFields",get:function(){return[new x({name:"Raster.ServicePixelValue",alias:"Pixel Value",domain:null,editable:!1,length:50,type:"string"})]}}]),i}(y.BlendLayer(_.ScaleRangeLayer(f.OperationalLayer(h.PortalLayer(m.CustomParametersMixin(v.ImageryTileMixin(P.TemporalLayer(g.RefreshableLayer(i.MultiOriginJSONMixin(d))))))))));r.__decorate([u.property({type:String,nonNullable:!0,json:{write:!0}})],O.prototype,"coverageId",void 0),r.__decorate([u.property({readOnly:!0}),a.aliasOf("raster.coverageInfo")],O.prototype,"coverageInfo",void 0),r.__decorate([u.property()],O.prototype,"version",void 0),r.__decorate([u.property()],O.prototype,"isReference",void 0),r.__decorate([u.property({readOnly:!0})],O.prototype,"type",void 0),r.__decorate([u.property(S.popupEnabled)],O.prototype,"popupEnabled",void 0),r.__decorate([u.property()],O.prototype,"popupTemplate",void 0),r.__decorate([u.property({readOnly:!0})],O.prototype,"defaultPopupTemplate",null),r.__decorate([u.property({readOnly:!0,type:[x]})],O.prototype,"fields",void 0),r.__decorate([u.property({readOnly:!0,type:[x]})],O.prototype,"rasterFields",null),O=r.__decorate([c.subclass("esri.layers.WCSLayer")],O);return O}));
