@arcgis/core 4.21.0-next.20210916 → 4.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/EULA.pdf +0 -0
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/836e8ed3f37b014670ec.js +1 -0
  4. package/assets/esri/core/workers/chunks/a1d5d196d14b194636ee.js +1 -0
  5. package/assets/esri/core/workers/chunks/dd33c0ef52ad555092bd.js +1 -0
  6. package/assets/esri/core/workers/chunks/ee32a34cce5d2f65d01c.js +1 -0
  7. package/assets/esri/core/workers/chunks/f57c8fc116d64723c16c.js +1 -0
  8. package/config.js +1 -1
  9. package/interfaces.d.ts +47 -123
  10. package/layers/ImageryTileLayer.js +1 -1
  11. package/layers/mixins/ArcGISImageService.js +1 -1
  12. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  13. package/package.json +1 -1
  14. package/support/revision.js +1 -1
  15. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  16. package/views/2d/layers/features/controllers/support/sourceAdapters.js +1 -1
  17. package/views/2d/layers/features/schemaUtils.js +1 -1
  18. package/views/2d/layers/features/sources/BaseFeatureSource.js +1 -1
  19. package/views/2d/layers/features/sources/DataTileSource.js +1 -1
  20. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  21. package/views/3d/layers/analysis/LineOfSight/LineOfSightController.js +1 -1
  22. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  23. package/views/draw/support/Reshape.js +1 -1
  24. package/widgets/BasemapLayerList/BasemapLayerListViewModel.js +1 -1
  25. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  26. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
  27. package/assets/esri/core/workers/chunks/05ad927ed6b27c8134b4.js +0 -1
  28. package/assets/esri/core/workers/chunks/42f1ea5f61521156e044.js +0 -1
  29. package/assets/esri/core/workers/chunks/5ec6930af98cbccc6a9a.js +0 -1
  30. package/assets/esri/core/workers/chunks/62f264baf3cbd76ecac6.js +0 -1
  31. package/assets/esri/core/workers/chunks/d4a77cf8f298d94879d6.js +0 -1
  32. package/views/2d/layers/features/controllers/support/sources.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.21/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{read as r,rasterRendererTypes as i,websceneRasterRendererTypes as s}from"../../rasterRenderers.js";import n from"../../request.js";import a from"../../core/Error.js";import{strict as o}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import u from"../../core/Logger.js";import{isNone as p,isSome as c}from"../../core/maybe.js";import{when as m}from"../../core/promiseUtils.js";import{urlToObject as d}from"../../core/urlUtils.js";import{aliasOf as h}from"../../core/accessorSupport/decorators/aliasOf.js";import{ensureClass as f,Integer as y,ensureNumber as g}from"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{property as R,ensureRange as v}from"../../core/accessorSupport/decorators/property.js";import{reader as x}from"../../core/accessorSupport/decorators/reader.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{writer as I}from"../../core/accessorSupport/decorators/writer.js";import{opacity as S,url as w}from"../support/commonProperties.js";import _ from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as O}from"../support/ExportImageServiceParameters.js";import F from"../support/Field.js";import P from"../support/FieldsIndex.js";import{isSupportedRendererType as N}from"../support/imageryRendererUtils.js";import j from"../support/MosaicRule.js";import T from"../support/PixelBlock.js";import{interpolationKebab as D,noDataInterpretationKebab as C}from"../support/rasterEnums.js";import J from"../support/RasterFunction.js";import q from"../support/RasterInfo.js";import V from"../support/RasterJobHandler.js";import{decode as M,getFormat as z}from"../support/rasterFormats/RasterCodec.js";import{uvComponentToVector as Q}from"../support/rasterFunctions/vectorFieldUtils.js";import{getSupportedRendererTypes as A,getDefaultBandCombination as E,createDefaultRenderer as U,normalizeRendererJSON as H}from"../../renderers/support/rasterRendererHelper.js";import L from"../../renderers/support/RasterSymbolizer.js";import{computeHistograms as k,computeStatisticsHistograms as B,getSamples as G,identify as W}from"../../rest/imageService.js";import"../../kernel.js";import"../../rest/query/support/AttachmentInfo.js";import"../../rest/support/AttachmentQuery.js";import{executeForCount as X}from"../../rest/query/executeForCount.js";import Y from"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import K from"../../geometry/Point.js";import $ from"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtils.js";import"../../core/pbf.js";import"../../core/unitUtils.js";import"../../geometry/support/spatialReferenceUtils.js";import Z from"../../rest/support/Query.js";import{executeForIds as ee}from"../../rest/query/executeForIds.js";import{executeQueryJSON as te}from"../../rest/query/executeQueryJSON.js";import"../graphics/featureConversionUtils.js";import re from"../../rest/support/FeatureSet.js";import"../../rest/support/RelationshipQuery.js";import"../../rest/support/TopFeaturesQuery.js";import ie from"../../rest/support/ImageHistogramParameters.js";import se from"../../rest/support/ImageIdentifyParameters.js";import ne from"../../rest/support/ImageSampleParameters.js";import ae from"../../geometry/SpatialReference.js";const oe=u.getLogger("esri.layers.mixins.ArcGISImageService"),le=o()({U1:"u1",U2:"u2",U4:"u4",U8:"u8",S8:"s8",U16:"u16",S16:"s16",U32:"u32",S32:"s32",F32:"f32",F64:"f64",C64:"c64",C128:"c128",UNKNOWN:"unknown"}),ue=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),pe=v(g,{min:0,max:255});function ce(e){if(!e)return null;const t=JSON.stringify(e).match(/"rasterFunction":"(.*?")/gi),r=null==t?void 0:t.map((e=>e.replace('"rasterFunction":"',"").replace('"',"")));return r?r.join("/"):null}const me=o=>{let u=class extends o{constructor(){super(...arguments),this._functionRasterInfos={},this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this._symbolizer=null,this._defaultServiceMosaicRule=null,this.rasterAttributeTableFieldPrefix="Raster.",this.adjustAspectRatio=null,this.bandCount=null,this.bandIds=void 0,this.capabilities=null,this.compressionQuality=void 0,this.compressionTolerance=.01,this.copyright=null,this.definitionExpression=null,this.exportImageServiceParameters=null,this.rasterInfo=null,this.fields=null,this.fullExtent=null,this.hasMultidimensions=!1,this.imageMaxHeight=4100,this.imageMaxWidth=4100,this.interpolation=void 0,this.minScale=0,this.maxScale=0,this.multidimensionalInfo=null,this.noData=null,this.noDataInterpretation=void 0,this.objectIdField=null,this.geometryType="polygon",this.typeIdField=null,this.types=[],this.pixelSizeX=null,this.pixelSizeY=null,this.pixelFilter=null,this.raster=void 0,this.viewId=void 0,this.renderer=null,this.rasterAttributeTable=null,this.rasterFunctionInfos=null,this.serviceDataType=null,this.spatialReference=null,this.pixelType=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.url=null,this.version=null}initialize(){this._set("exportImageServiceParameters",new O({layer:this}))}readDefaultServiceMosaicRule(e,t){return j.fromJSON(t)}get rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||this.rasterFunctionInfos.length<1||this.rasterFunctionInfos.forEach((t=>{e.set(t.name.toLowerCase().replace(/ /gi,"_"),t.name)})),e}readBandIds(e,t){if(Array.isArray(e)&&e.length>0&&e.every((e=>"number"==typeof e)))return e}readCapabilities(e,t){return this._readCapabilities(t)}writeCompressionQuality(e,t,r){null!=e&&"lerc"!==this.format&&(t[r]=e)}writeCompressionTolerance(e,t,r){"lerc"===this.format&&null!=e&&(t[r]=e)}get fieldsIndex(){return this.fields?new P(this.fields):null}set format(e){e&&ue.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t&&t.mosaicMethod&&(t=j.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){return j.fromJSON(e||t.mosaicRule||t)}writeMosaicRule(e,t,r){let i=this.mosaicRule;const s=this.definitionExpression;i?s&&s!==i.where&&(i=i.clone(),i.where=s):s&&(i=new j({where:s})),this._isValidCustomizedMosaicRule(i)&&(t[r]=i.toJSON())}writeNoData(e,t,r){null!=e&&"number"==typeof e&&(t[r]=pe(e))}readObjectIdField(e,t){if(!e){const r=t.fields.filter((e=>"esriFieldTypeOID"===e.type||"oid"===e.type));e=r&&r[0]&&r[0].name}return e}get parsedUrl(){return this.url?d(this.url):null}readRenderer(e,t,i){var s,n;const a=null==t||null==(s=t.layerDefinition)||null==(n=s.drawingInfo)?void 0:n.renderer,o=r(a,i);return null==o?null:("vector-field"===o.type&&t.symbolTileSize&&!a.symbolTileSize&&(o.symbolTileSize=t.symbolTileSize),N(o)||oe.warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),o)}writeRenderer(e,t,r){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this.rasterAttributeTableFieldPrefix||"Raster.",t=new F({name:"Raster.ItemPixelValue",alias:"Item Pixel Value",domain:null,editable:!1,length:50,type:"string"}),r=new F({name:"Raster.ServicePixelValue",alias:"Service Pixel Value",domain:null,editable:!1,length:50,type:"string"}),i=new F({name:"Raster.ServicePixelValue.Raw",alias:"Raw Service Pixel Value",domain:null,editable:!1,length:50,type:"string"});let s=this.fields?l(this.fields):[];s.push(r),this.capabilities.operations.supportsQuery&&this.fields&&this.fields.length>0&&s.push(t),this.version>=10.4&&this.rasterFunctionInfos&&this.rasterFunctionInfos.some((e=>"none"===e.name.toLowerCase()))&&s.push(i),this.rasterFunctionInfos&&this.rasterFunctionInfos.filter((e=>"none"!==e.name.toLowerCase())).forEach((e=>{s.push(new F({name:"Raster.ServicePixelValue."+e.name,alias:e.name,domain:null,editable:!1,length:50,type:"string"}))})),null==this.pixelFilter||"esriImageServiceDataTypeVector-UV"!==this.serviceDataType&&"esriImageServiceDataTypeVector-MagDir"!==this.serviceDataType||(s.push(new F({name:"Raster.Magnitude",alias:"Magnitude",domain:null,editable:!1,type:"double"})),s.push(new F({name:"Raster.Direction",alias:"Direction",domain:null,editable:!1,type:"double"})));const n=this.rasterInfo.attributeTable&&this.rasterInfo.attributeTable.fields||null;if(n&&n.length>0){const t=n.filter((e=>"esriFieldTypeOID"!==e.type&&"value"!==e.name.toLowerCase())).map((t=>{const r=l(t);return r.name=e+t.name,r}));s=s.concat(t)}return s}set renderingRule(e){let t=e;t&&t.rasterFunction&&(t=J.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("renderingRule",t)}readRenderingRule(e,t){const r=t.rasterFunctionInfos;return t.renderingRule||r&&r.length&&"None"!==r[0].name?J.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}writeRenderingRule(e,t,r){this._isRFTJson(e)||(t[r]=e.toJSON())}readSpatialReference(e,t){const r=e||t.extent.spatialReference;return r?ae.fromJSON(r):null}readPixelType(e){return le.fromJSON(e)||e}writePixelType(e,t,r){(p(this.serviceRasterInfo)||this.pixelType!==this.serviceRasterInfo.pixelType)&&(t[r]=le.toJSON(e))}readVersion(e,t){let r=t.currentVersion;return r||(r=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),r}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let r=e;if(!this._isPicture()&&this.renderer&&this._symbolizer&&!this.pixelFilter){const i=JSON.stringify(this._cachedRendererJson)!==JSON.stringify(this.renderer.toJSON()),s=this._rasterJobHandler.instance,{bandIds:n}=this;if(s){i&&(this._symbolizer.bind(),await s.updateSymbolizer(this._symbolizer,t),this._cachedRendererJson=this.renderer.toJSON());const a=await s.symbolize({bandIds:n,...e},t);r={extent:e.extent,pixelBlock:a}}else r={extent:e.extent,pixelBlock:this._symbolizer.symbolize({bandIds:n,...e})}}return r}destroy(){this._shutdownJobHandler()}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}async computeHistograms(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsComputeHistograms)throw new a("imagery-layer:compute-histograms","this operation is not supported on the input image service");e=f(ie,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;return s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule&&(e.mosaicRule=i),r&&null==e.raster&&(e.raster=r),k(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsComputeStatisticsHistograms)throw new a("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");e=f(ie,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;return s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule&&(e.mosaicRule=i),r&&null==e.raster&&(e.raster=r),B(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return c(t)?t.get(e):void 0}getFieldDomain(e,t){const r=this.getField(e);return r?r.domain:null}fetchImage(e,t,r,i={}){if(null==e||null==t||null==r)return Promise.reject(new a("imagery-layer:fetch-image","Insufficient parameters for requesting an image. A valid extent, width and height values are required."));const s=this.renderer||this._symbolizer?this.generateRasterInfo(this.renderingRule,{signal:i.signal}):null;return m(s).then((s=>{s&&(this.rasterInfo=s);const n={imageServiceParameters:this.getExportImageServiceParameters(e,t,r,i.timeExtent),imageProps:{extent:e,width:t,height:r,format:this.format},requestAsImageElement:i.requestAsImageElement&&!this.pixelFilter||!1,signal:i.signal};return this._requestArrayBuffer(n)}))}fetchKeyProperties(e){const t=e&&e.renderingRule&&e.renderingRule.toJSON();return n(this.parsedUrl.path+"/keyProperties",{query:this._getQueryParams({renderingRule:this.version>=10.3&&t?JSON.stringify(t):null})}).then((e=>e.data))}fetchRasterAttributeTable(e){const t=e&&e.renderingRule&&e.renderingRule.toJSON();return this.version<10.1?Promise.reject(new a("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):n(this.parsedUrl.path+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3&&t?JSON.stringify(t):null})}).then((e=>re.fromJSON(e.data)))}async getCatalogItemRasterInfo(e,t){const r=n(this.parsedUrl.path+"/"+e+"/info",{query:this._getQueryParams(),...t}).then((e=>e.data)),i=n(this.parsedUrl.path+"/"+e+"/info/keyProperties",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>{})),s=await Promise.all([r,i]);if(!s[0])return;const a=Y.fromJSON(s[0].extent),o=s[0].statistics?s[0].statistics.map((e=>({min:e[0],max:e[1],avg:e[2],stddev:e[3]}))):null;return new q({bandCount:s[0].bandCount,extent:a,spatialReference:a.sr,pixelSize:new K({x:s[0].pixelSizeX,y:s[0].pixelSizeY,spatialReference:a.sr}),pixelType:s[0].pixelType.toLowerCase(),statistics:o,histograms:s[0].histograms,keyProperties:s[1]||{}})}async getCatalogItemICSInfo(e,t){const{data:r}=await n(this.parsedUrl.path+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),i=r&&r.ics;if(!i)return;let s=null;try{s=(await n(this.parsedUrl.path+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!s||!s.spatialReference)return{ics:i,icsToPixelTransform:null,icsExtent:null,northDirection:null};const a=this.version>=10.7?n(this.parsedUrl.path+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>({}))):{},o=s.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[s]}),inSR:o.wkid||JSON.stringify(o),outSR:"0:"+e},u=n(this.parsedUrl.path+"/project",{query:this._getQueryParams(l),...t}).then((e=>e.data)).catch((()=>({}))),p=5,c=(s.xmin+s.xmax)/2,m=(s.ymax-s.ymin)/(p+1),d=s.ymin+m,h=[];for(let n=0;n<p;n++)h.push({x:c,y:d+m*n});const f={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:h}),inSR:o.wkid||JSON.stringify(o),outSR:"0:"+e},y=n(this.parsedUrl.path+"/project",{query:this._getQueryParams(f),...t}).then((e=>e.data)).catch((()=>({}))),g=await Promise.all([a,u,y]);let R=g[0].ipxf;if(null==R){var v,x,b;const e=null==(v=i.geodataXform)?void 0:v.xf_0;"topup"===(null==e||null==(x=e.name)?void 0:x.toLowerCase())&&6===(null==e||null==(b=e.coefficients)?void 0:b.length)&&(R={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const I=Y.fromJSON(g[1]&&g[1].geometries&&g[1].geometries[0]);I&&(I.spatialReference=new ae({wkid:0,imageCoordinateSystem:i}));const S=g[2].geometries?g[2].geometries.filter((e=>null!=e&&null!=e.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y)):[],w=S.length;if(w<3)return{ics:i,icsToPixelTransform:R,icsExtent:I,northDirection:null};let _=0,O=0,F=0,P=0;for(let n=0;n<w;n++)_+=S[n].x,O+=S[n].y,F+=S[n].x*S[n].x,P+=S[n].x*S[n].y;const N=(w*P-_*O)/(w*F-_*_);let j=0;const T=S[p-1].x>S[0].x,D=S[p-1].y>S[0].y;return N===1/0?j=D?90:270:0===N?j=T?0:180:N>0?j=T?180*Math.atan(N)/Math.PI:180*Math.atan(N)/Math.PI+180:N<0&&(j=D?180+180*Math.atan(N)/Math.PI:360+180*Math.atan(N)/Math.PI),{ics:i,icsToPixelTransform:R,icsExtent:I,northDirection:j}}async generateRasterInfo(e,t){if((!e||"none"===e.functionName.toLowerCase()||this._isVectorFieldResampleFunction(e))&&c(this.serviceRasterInfo))return this.serviceRasterInfo;const r=ce(e);if(this._functionRasterInfos[r])return this._functionRasterInfos[r];const i=this._generateRasterInfo(e,t);this._functionRasterInfos[r]=i;try{return await i}catch{return this._functionRasterInfos[r]=null,null}}getExportImageServiceParameters(e,t,r,i){const s=(e=e.clone().shiftCentralMeridian()).spatialReference;let n;if(s.imageCoordinateSystem){const{id:e,referenceServiceName:t}=s.imageCoordinateSystem;n=null!=e?t?this.parsedUrl.path.toLowerCase().indexOf("/"+t.toLowerCase()+"/")>-1?"0:"+e:JSON.stringify({icsid:e,icsns:t}):"0:"+e:JSON.stringify({ics:s.imageCoordinateSystem})}else n=s.wkid||JSON.stringify(s.toJSON());c(this.serviceRasterInfo)&&this.pixelType!==this.serviceRasterInfo.pixelType&&(this.exportImageServiceParameters.pixelType=this.pixelType);const a=this.exportImageServiceParameters.toJSON(),{bandIds:o,noData:l,mosaicRule:u}=a;let{renderingRule:p}=a;if(o instanceof Array&&o.length>0&&!this.renderingRule?a.bandIds=o.join(","):a.bandIds=void 0,null!=o&&o.length&&this.renderingRule)if("Colormap"===p.rasterFunction){const e=new J({functionName:"ExtractBand",functionArguments:{BandIds:o,raster:p.rasterFunctionArguments.Raster}});p.rasterFunctionArguments.Raster=e}else{p=new J({functionName:"ExtractBand",functionArguments:{BandIds:o,raster:p}})}l instanceof Array&&l.length>0&&(a.noData=l.join(","));const m=this.timeInfo;u&&u.multidimensionalDefinition&&i&&m&&m.startField&&(u.multidimensionalDefinition=u.multidimensionalDefinition.filter((e=>e.dimensionName!==m.startField))),a.mosaicRule=u&&JSON.stringify(u),a.renderingRule=p&&JSON.stringify(p);const d={};if(i){const{start:e,end:t}=i.toJSON();e&&t&&e===t?d.time=""+e:null==e&&null==t||(d.time=`${null==e?"null":e},${null==t?"null":t}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:n,imageSR:n,size:t+","+r,...a,...d}}async getSamples(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsGetSamples)throw new a("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=f(ne,e).clone();const{raster:r}=this;return r&&null==e.raster&&(e.raster=r),G(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsIdentify)throw new a("imagery-layer:query-rasters","query operation is not supported on the input image service");e=f(se,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;return s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule&&(e.mosaicRule=i),r&&null==e.raster&&(e.raster=r),W(this.url,e,this._getRequestOptions(t))}createQuery(){const e=new Z;return e.outFields=["*"],e.returnGeometry=!0,e.where=this.definitionExpression||"1=1",e}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),te(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ee(this.url,e,t)}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),X(this.url,e,t)}queryVisibleRasters(e,t){if(!e)return Promise.reject(new a("imagery-layer: query-visible-rasters","missing query parameter"));const{pixelSize:r,returnDomainValues:i,returnTopmostRaster:s,showNoDataRecords:n}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const m="raster.servicepixelvalue",d=this.rasterFunctionNamesIndex;if(c(e.outFields)&&(o=e.outFields.some((e=>-1===e.toLowerCase().indexOf(m))),this.version>=10.4)){const t=e.outFields.filter((e=>e.toLowerCase().indexOf(m)>-1&&e.length>m.length)).map((e=>{const t=e.slice(m.length+1);return[this._updateRenderingRulesFunctionName(t,d),t]}));l=t.map((e=>new J({functionName:e[0]}))),u=t.map((e=>e[1])),0===l.length?this.renderingRule?(l.push(this.renderingRule),u.push(this.renderingRule.functionName)):l=null:this.renderingRule&&!l.some((e=>e.functionName===this.renderingRule.functionName))&&(l.push(this.renderingRule),u.push(this.renderingRule.functionName))}const h=p(e.outSpatialReference)||e.outSpatialReference.equals(this.spatialReference),f=this._getQueryParams({geometry:e.geometry,timeExtent:e.timeExtent||this.timeExtent,mosaicRule:this.exportImageServiceParameters.mosaicRule,renderingRule:this.version<10.4?this.renderingRule:null,renderingRules:l,pixelSize:r,returnCatalogItems:o,returnGeometry:h,raster:this.raster,maxItemCount:s?1:null});delete f.f;const y=new se(f),g=this.generateRasterInfo(this.renderingRule);return new Promise((r=>{g.then((()=>{W(this.url,y,{signal:null==t?void 0:t.signal,query:{...this.customParameters}}).then((t=>{const s=e.outFields;if(o&&!h&&t.catalogItems&&t.catalogItems.features&&t.catalogItems.features.length>0){const o=this.objectIdField||"ObjectId",l=t.catalogItems.features,p=l.map((e=>e.attributes&&e.attributes[o])),c=new Z({objectIds:p,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[o]});return this.queryRasters(c).then((a=>{a&&a.features&&a.features.length>0&&a.features.forEach((t=>{l.forEach((r=>{r.attributes[o]===t.attributes[o]&&(r.geometry=new $(t.geometry),r.geometry.spatialReference=e.outSpatialReference)}))})),r(this._processVisibleRastersResponse(t,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s}))})).catch((()=>{throw new a("imagery-layer:query-visible-rasters","encountered error when querying visible rasters geometry")}))}r(this._processVisibleRastersResponse(t,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s}))})).catch((()=>{throw new a("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}))}))}))}async fetchVariableStatisticsHistograms(e,t){const r=n(this.parsedUrl.path+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>{var t;return null==(t=e.data)?void 0:t.statistics})),i=n(this.parsedUrl.path+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>{var t;return null==(t=e.data)?void 0:t.histograms})),s=await Promise.all([r,i]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[1]||null}}async _fetchService(e){await this._fetchServiceInfo(e),c(this.serviceRasterInfo)&&!this.rasterInfo&&(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,r=c(this.serviceRasterInfo)?Promise.resolve(this.serviceRasterInfo):this._fetchAuxiliaryRasterInfo({serviceInfo:t,signal:e}).then((e=>(this._set("serviceRasterInfo",e),e))),i=this.renderingRule&&"none"!==this.renderingRule.functionName.toLowerCase()?this.generateRasterInfo(this.renderingRule,{signal:e}):null;return Promise.all([r,i]).then((e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),this.renderer&&!this._isSupportedRenderer(this.renderer)&&(this.renderer=null,oe.warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._configDefaultRenderer(),this.watch("renderer",(()=>this._configDefaultRenderer())),this.watch("renderingRule",(e=>{(this.renderer||this._symbolizer||this.popupEnabled&&this.popupTemplate)&&this.generateRasterInfo(e).then((e=>{e&&(this.rasterInfo=e)}))}));const t=c(this.serviceRasterInfo)&&this.serviceRasterInfo.multidimensionalInfo;t&&this._updateMultidimensionalDefinition(t)}))}async _prepareForQuery(e,t){var r;if(await this._fetchCapabilities(null==(r=t)?void 0:r.signal),!this.capabilities.operations.supportsQuery)throw new a("imagery-layer:query-rasters","query operation is not supported on the input image service");return e=c(e)?f(Z,e):this.createQuery(),t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:e,requestOptions:t}}async _initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new V;this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{this._rasterJobHandler.instance=e}),(()=>null)),await this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0}_isSupportedRenderer(e){const{rasterInfo:t,renderingRule:r}=this;return"unique-value"===e.type&&r&&"none"!==r.functionName.toLowerCase()&&1===t.bandCount&&["u8","s8"].includes(t.pixelType)||A(this.rasterInfo).includes(this.renderer.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){var t;let r=this.sourceJSON;if(!r){const{data:t,ssl:i}=await n(this.parsedUrl.path,{query:this._getQueryParams(),signal:e});r=t,this.sourceJSON=r,i&&(this.url=this.url.replace(/^http:/i,"https:"))}if((null==(t=r.capabilities)?void 0:t.toLowerCase().split(",").map((e=>e.trim())).indexOf("tilesonly"))>-1)throw new a("imagery-layer:fetch-service-info","use ImageryTileLayer to open tiles-only image services");this.read(r,{origin:"service",url:this.parsedUrl})}_isVectorFieldResampleFunction(e){if(!c(e))return!1;const{functionName:t,functionArguments:r}=e,i="resample"===t.toLowerCase(),s=(null==r?void 0:r.ResampleType)||(null==r?void 0:r.resampleType);return i&&(7===s||10===s)}_isPicture(){return!this.format||this.format.indexOf("jpg")>-1||this.format.indexOf("png")>-1}_configDefaultRenderer(){if(!this._isPicture()&&!this.pixelFilter){if(!this.bandIds&&this.rasterInfo.bandCount>=3){const e=E(this.rasterInfo);!e||3===this.rasterInfo.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}var e,t;if(!this.renderer)this.renderer=U(this.rasterInfo,{bandIds:this.bandIds,variableName:this.renderingRule?null:null==(e=this.mosaicRule)||null==(t=e.multidimensionalDefinition)?void 0:t[0].variableName});this._symbolizer?(this._symbolizer.rendererJSON=H(this.renderer.toJSON()),this._symbolizer.rasterInfo=this.rasterInfo):this._symbolizer=new L({rendererJSON:this.renderer.toJSON(),rasterInfo:this.rasterInfo}),this._symbolizer.bind()||(this._symbolizer=null)}}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:c(e.pixelBlock)&&e.pixelBlock.clone()}}_getQueryParams(e){const{raster:t,viewId:r}=this;return{raster:t,viewId:r,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...null==e?void 0:e.query,...this.customParameters}}}_decodePixelBlock(e,t,r){return this._rasterJobHandler.instance?this._rasterJobHandler.instance.decode({data:e,options:t}):M(e,t,r)}async _fetchMultidimensionalInfo(e){var t;const r=await n(this.parsedUrl.path+"/multidimensionalInfo",{query:this._getQueryParams(),signal:e}).then((e=>{var t;return null==(t=e.data)?void 0:t.multidimensionalInfo}));return null!=(t=r.variables)&&t.length&&r.variables.forEach((e=>{var t;null!=(t=e.statistics)&&t.length&&e.statistics.forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation}))})),r}_fetchAuxiliaryRasterInfo(e){const t=e&&e.serviceInfo;if(!t)return Promise.reject(new a("imagery-layer:fetch-metadata","valid serviceInfo is required"));const r=e.renderingRule?JSON.stringify(e.renderingRule.toJSON()):null,i=e.signal,s=!!(t.hasRasterAttributeTable&&this.version>=10.1)&&n(this.parsedUrl.path+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.1?r:null}),signal:i}).then((e=>re.fromJSON(e.data))).catch((()=>null)),o=!!(t.hasColormap&&this.version>=10.1)&&n(this.parsedUrl.path+"/colormap",{query:this._getQueryParams({renderingRule:this.version>=10.6?r:null}),signal:i}).then((e=>{var t;return null==(t=e.data)?void 0:t.colormap})),l=!!(t.hasHistograms&&this.version>=10.1)&&n(this.parsedUrl.path+"/histograms",{query:this._getQueryParams({renderingRule:this.version>=10.1?r:null}),signal:i}).then((e=>{var t;return null==(t=e.data)?void 0:t.histograms})),u=this.version>=10.3&&n(this.parsedUrl.path+"/keyProperties",{query:this._getQueryParams({renderingRule:r}),signal:i}).then((e=>e.data)).catch((()=>{})),p=!!(t.hasMultidimensions&&this.version>=10.3)&&this._fetchMultidimensionalInfo();return Promise.all([s,o,l,u,p]).then((e=>{let r=null;if(t.minValues&&t.minValues.length===t.bandCount){r=[];for(let e=0;e<t.minValues.length;e++)r.push({min:t.minValues[e],max:t.maxValues[e],avg:t.meanValues[e],stddev:t.stdvValues[e]})}const i=Math.ceil((t.extent.xmax-t.extent.xmin)/t.pixelSizeX-.1),s=Math.ceil((t.extent.ymax-t.extent.ymin)/t.pixelSizeY-.1),n=ae.fromJSON(t.spatialReference||t.extent.spatialReference);return new q({width:i,height:s,bandCount:t.bandCount,extent:Y.fromJSON(t.extent),spatialReference:n,pixelSize:new K({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:n}),pixelType:t.pixelType.toLowerCase(),statistics:r,attributeTable:e[0]||null,colormap:e[1]||null,histograms:e[2]||null,keyProperties:e[3]||{},multidimensionalInfo:e[4]||null})}))}_requestArrayBuffer(e){const{imageProps:t,requestAsImageElement:r,signal:i}=e;if(r&&!this.pixelFilter&&t.format&&t.format.indexOf("png")>-1)return n(this.parsedUrl.path+"/exportImage",{responseType:"image",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:i}).then((e=>({imageElement:e.data,params:t})));const s=this._initJobHandler(),o=n(this.parsedUrl.path+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:i});return Promise.all([o,s]).then((e=>{const r=e[0].data,s=t.format||"jpgpng";let n=s;if("bsq"!==n&&"bip"!==n&&(n=z(r)),!n){throw new a("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(r)))}const o="gif"===s||"bmp"===s||s.indexOf("png")>-1&&("png"===n||"jpg"===n),l={signal:i};return o?M(r,{useCanvas:!0,...t},l).then((e=>({pixelData:{pixelBlock:e,extent:t.extent},params:t}))):this._decodePixelBlock(r,{width:t.width,height:t.height,planes:null,pixelType:null,noDataValue:null,format:s},l).then((e=>({pixelData:{pixelBlock:e,extent:t.extent},params:t})))}))}async _generateRasterInfo(e,t){const{data:r}=await n(this.parsedUrl.path,{query:this._getQueryParams({renderingRule:e}),...t});return await this._fetchAuxiliaryRasterInfo({serviceInfo:r,renderingRule:e,...t})}_isValidCustomizedMosaicRule(e){return e&&JSON.stringify(e.toJSON())!==JSON.stringify(this._defaultServiceMosaicRule&&this._defaultServiceMosaicRule.toJSON())}_updateMultidimensionalDefinition(e){if(this._isValidCustomizedMosaicRule(this.mosaicRule))return;const t=e.variables[0].dimensions,r="",i=[];for(const s in t)if(t.hasOwnProperty(s)){const e=t[s],n=e.extent;let a=!0,o=[n[0]];e.hasRanges&&!0===e.hasRanges?(a=!1,o=[e.values[0]]):"stdz"===e.name.toLowerCase()&&Math.abs(n[1])<=Math.abs(n[0])&&(o=[n[1]]),i.push(new _({variableName:r,dimensionName:t[s].name,isSlice:a,values:o}))}if(i.length>0){this.mosaicRule=this.mosaicRule||new j;const e=this.mosaicRule.multidimensionalDefinition;(!e||e&&e.length<=0)&&(this.mosaicRule.multidimensionalDefinition=i)}}_formatAttributeValue(e,t){if("string"==typeof e){const r=this.popupTemplate&&this.popupTemplate.fieldInfos,i=this._getFieldInfo(r,t),s=i&&i.format;if(s){let t,r;return e.trim().indexOf(",")>-1?(t=",",r=t+" ",this._formatDelimitedString(e,t,r,s)):e.trim().indexOf(" ")>-1?(t=r=" ",this._formatDelimitedString(e,t,r,s)):this._formatNumberFromString(e,s)}}return e}_getFieldInfo(e,t){if(!e||!e.length||!t)return;const r=t.toLowerCase();let i;return e.some((e=>!(!e.fieldName||e.fieldName.toLowerCase()!==r&&e.fieldName.toLowerCase()!==r.replace(/ /g,"_"))&&(i=e,!0))),i}_formatDelimitedString(e,t,r,i){return e&&t&&r&&i?e.trim().split(t).map((e=>this._formatNumberFromString(e,i))).join(r):e}_formatNumberFromString(e,t){if(!e||!t)return e;const r=Number(e);return isNaN(r)?e:t.format(r)}_processVisibleRastersResponse(e,r){r=r||{};const i=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:a,templateFields:o}=r,l=e.processedValues;let u=e.catalogItems&&e.catalogItems.features,p=e.properties&&e.properties.Values&&e.properties.Values.map((e=>e.replace(/ /gi,", ")))||[];const m=this.objectIdField||"ObjectId",d="string"==typeof i&&i.toLowerCase().indexOf("nodata")>-1,h=[];if(i&&!u&&!d){const e={};e[m]=0;p=[i],u=[new t(this.fullExtent,null,e)]}if(!u)return[];let f,y,g;this._updateResponseFieldNames(u,o),d&&!n&&(u=[]);for(let t=0;t<u.length;t++){if(f=u[t],null!=i&&!d){if(y=p[t],g=this.renderingRule&&l&&l.length>0&&s&&s.length>0&&s.indexOf(this.renderingRule.functionName)>-1?l[s.indexOf(this.renderingRule.functionName)]:i,"nodata"===y.toLowerCase()&&!n)continue;const e="Raster.ItemPixelValue",r="Raster.ServicePixelValue";f.attributes[e]=this._formatAttributeValue(y,e),f.attributes[r]=this._formatAttributeValue(g,r),this._updateFeatureWithMagDirValues(f,y);const a=this.fields&&this.fields.length>0;let o=this.renderingRule&&c(this.serviceRasterInfo)&&this.serviceRasterInfo.attributeTable?a?y:i:g;this.renderingRule||(o=a?y:i),this._updateFeatureWithRasterAttributeTableValues(f,o)}if(f.sourceLayer=this,a&&this._updateFeatureWithDomainValues(f),s&&l&&s.length===l.length)for(let e=0;e<s.length;e++){const t="Raster.ServicePixelValue."+s[e];f.attributes[t]=this._formatAttributeValue(l[e],t)}h.push(u[t])}return h}_updateFeatureWithRasterAttributeTableValues(e,t){const r=this.rasterInfo&&this.rasterInfo.attributeTable||c(this.serviceRasterInfo)&&this.serviceRasterInfo.attributeTable,i=r&&r.features;if(!i)return;const s=r.fields,n=s.map((e=>e.name)).filter((e=>"value"===e.toLowerCase())),a=n&&n[0];if(!a)return;const o=i.filter((e=>e.attributes[a]===(null!=t?parseInt(t,10):null)));o&&o[0]&&s.forEach((t=>{const r=this.rasterAttributeTableFieldPrefix+t.name;e.attributes[r]=this._formatAttributeValue(o[0].attributes[t.name],r)}))}_updateFeatureWithMagDirValues(e,t){if("esriImageServiceDataTypeVector-UV"!==this.serviceDataType&&"esriImageServiceDataTypeVector-MagDir"!==this.serviceDataType)return;const r=t.split(/,\s*/).map((e=>parseFloat(e))),i=r.map((e=>[e])),s=r.map((e=>({minValue:e,maxValue:e,noDataValue:null}))),n=new T({height:1,width:1,pixelType:"f32",pixels:i,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new Y(0,0,0,0,this.spatialReference)});const a="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:Q([n.pixels[0][0],n.pixels[1][0]]);e.attributes["Raster.Magnitude"]=a[0],e.attributes["Raster.Direction"]=a[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter((e=>e.domain&&"coded-value"===e.domain.type));null!=t&&t.forEach((t=>{const r=e.attributes[t.name];if(null!=r){const i=t.domain.codedValues.filter((e=>e.code===r))[0];i&&(e.attributes[t.name]=i.name)}}))}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const r=this.fieldsIndex;c(r)&&e.forEach((e=>{if(e&&e.attributes)for(const i of t)if(r.has(i)){const t=r.get(i).name;t!==i&&(e.attributes[i]=e.attributes[t],delete e.attributes[t])}}))}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const r=e.toLowerCase().replace(/ /gi,"_");return t.has(r)?t.get(r):e}_isRFTJson(e){return e.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map((e=>e.trim())):["image","catalog"],{currentVersion:r,advancedQueryCapabilities:i,maxRecordCount:s}=e,n=t.indexOf("image")>-1,a="esriImageServiceDataTypeElevation"===e.serviceDataType,o=!!(e.spatialReference||e.extent&&e.extent.spatialReference),l=t.includes("edit");return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:n,supportsExportImage:n,supportsIdentify:n,supportsMeasure:t.indexOf("mensuration")>-1&&o,supportsDownload:t.indexOf("download")>-1,supportsQuery:t.indexOf("catalog")>-1&&e.fields&&e.fields.length>0,supportsGetSamples:r>=10.2&&n,supportsProject:r>=10.3&&n,supportsComputeStatisticsHistograms:r>=10.4&&n,supportsQueryBoundary:r>=10.6&&n,supportsCalculateVolume:r>=10.7&&a,supportsComputePixelLocation:r>=10.7&&t.indexOf("catalog")>-1,supportsAdd:l,supportsDelete:l,supportsEditing:l,supportsUpdate:l,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1},query:{maxRecordCount:s,maxRecordCountFactor:void 0,supportsStatistics:!(null==i||!i.supportsStatistics),supportsOrderBy:!(null==i||!i.supportsOrderBy),supportsDistinct:!(null==i||!i.supportsDistinct),supportsPagination:!(null==i||!i.supportsPagination),supportsStandardizedQueriesOnly:!(null==i||!i.useStandardizedQueries),supportsPercentileStatistics:!(null==i||!i.supportsPercentileStatistics),supportsCentroid:!(null==i||!i.supportsReturningGeometryCentroid),supportsDistance:!(null==i||!i.supportsQueryWithDistance),supportsExtent:!(null==i||!i.supportsReturningQueryExtent),supportsGeometryProperties:!(null==i||!i.supportsReturningGeometryProperties),supportsHavingClause:!(null==i||!i.supportsHavingClause),supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:!1,supportsTopFeaturesQuery:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0}}}};return e([R()],u.prototype,"_functionRasterInfos",void 0),e([R()],u.prototype,"_rasterJobHandler",void 0),e([R()],u.prototype,"_symbolizer",void 0),e([R()],u.prototype,"_defaultServiceMosaicRule",void 0),e([x("_defaultServiceMosaicRule",["defaultMosaicMethod"])],u.prototype,"readDefaultServiceMosaicRule",null),e([R()],u.prototype,"_cachedRendererJson",void 0),e([R()],u.prototype,"rasterAttributeTableFieldPrefix",void 0),e([R({readOnly:!0})],u.prototype,"rasterFunctionNamesIndex",null),e([R()],u.prototype,"adjustAspectRatio",void 0),e([R({readOnly:!0}),h("serviceRasterInfo.bandCount")],u.prototype,"bandCount",void 0),e([R({type:[y],json:{write:!0}})],u.prototype,"bandIds",void 0),e([x("bandIds")],u.prototype,"readBandIds",null),e([R({readOnly:!0,json:{read:!1}})],u.prototype,"capabilities",void 0),e([x("service","capabilities",["capabilities","currentVersion","serviceDataType"])],u.prototype,"readCapabilities",null),e([R({type:Number})],u.prototype,"compressionQuality",void 0),e([I("compressionQuality")],u.prototype,"writeCompressionQuality",null),e([R({type:Number})],u.prototype,"compressionTolerance",void 0),e([I("compressionTolerance")],u.prototype,"writeCompressionTolerance",null),e([R({json:{read:{source:"copyrightText"}}})],u.prototype,"copyright",void 0),e([R({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],u.prototype,"definitionExpression",void 0),e([R({readOnly:!0,constructOnly:!0})],u.prototype,"exportImageServiceParameters",void 0),e([R()],u.prototype,"rasterInfo",void 0),e([R({readOnly:!0,type:[F]})],u.prototype,"fields",void 0),e([R({readOnly:!0})],u.prototype,"fieldsIndex",null),e([R({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"],json:{write:!0}})],u.prototype,"format",null),e([x("service","format",["serviceDataType"])],u.prototype,"readFormat",null),e([R({type:Y})],u.prototype,"fullExtent",void 0),e([R({readOnly:!0})],u.prototype,"hasMultidimensions",void 0),e([R({json:{read:{source:"maxImageHeight"}}})],u.prototype,"imageMaxHeight",void 0),e([R({json:{read:{source:"maxImageWidth"}}})],u.prototype,"imageMaxWidth",void 0),e([R({type:String,json:{type:D.jsonValues,read:D.read,write:D.write}})],u.prototype,"interpolation",void 0),e([R()],u.prototype,"minScale",void 0),e([x("service","minScale")],u.prototype,"readMinScale",null),e([R()],u.prototype,"maxScale",void 0),e([x("service","maxScale")],u.prototype,"readMaxScale",null),e([R({type:j})],u.prototype,"mosaicRule",null),e([x("mosaicRule",["mosaicRule","defaultMosaicMethod"])],u.prototype,"readMosaicRule",null),e([I("mosaicRule")],u.prototype,"writeMosaicRule",null),e([R({readOnly:!0}),h("serviceRasterInfo.multidimensionalInfo")],u.prototype,"multidimensionalInfo",void 0),e([R({json:{type:y}})],u.prototype,"noData",void 0),e([I("noData")],u.prototype,"writeNoData",null),e([R({type:String,json:{type:C.jsonValues,read:C.read,write:C.write}})],u.prototype,"noDataInterpretation",void 0),e([R({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],u.prototype,"objectIdField",void 0),e([x("objectIdField")],u.prototype,"readObjectIdField",null),e([R({})],u.prototype,"geometryType",void 0),e([R({})],u.prototype,"typeIdField",void 0),e([R({})],u.prototype,"types",void 0),e([R({readOnly:!0})],u.prototype,"parsedUrl",null),e([R({readOnly:!0}),h("serviceRasterInfo.pixelSize.x")],u.prototype,"pixelSizeX",void 0),e([R({readOnly:!0}),h("serviceRasterInfo.pixelSize.y")],u.prototype,"pixelSizeY",void 0),e([R({type:Function})],u.prototype,"pixelFilter",void 0),e([R()],u.prototype,"raster",void 0),e([R()],u.prototype,"viewId",void 0),e([R({types:i,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:s,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type})}}}}})],u.prototype,"renderer",void 0),e([x("renderer")],u.prototype,"readRenderer",null),e([I("renderer")],u.prototype,"writeRenderer",null),e([R(S)],u.prototype,"opacity",void 0),e([R({readOnly:!0}),h("serviceRasterInfo.attributeTable")],u.prototype,"rasterAttributeTable",void 0),e([R({readOnly:!0})],u.prototype,"rasterFields",null),e([R({readOnly:!0})],u.prototype,"rasterFunctionInfos",void 0),e([R({type:J})],u.prototype,"renderingRule",null),e([x("renderingRule",["renderingRule","rasterFunctionInfos"])],u.prototype,"readRenderingRule",null),e([I("renderingRule")],u.prototype,"writeRenderingRule",null),e([R()],u.prototype,"serviceDataType",void 0),e([R({readOnly:!0,type:ae})],u.prototype,"spatialReference",void 0),e([x("spatialReference",["spatialReference","extent"])],u.prototype,"readSpatialReference",null),e([R({json:{type:le.jsonValues}})],u.prototype,"pixelType",void 0),e([x("pixelType")],u.prototype,"readPixelType",null),e([I("pixelType")],u.prototype,"writePixelType",null),e([R({constructOnly:!0,type:q})],u.prototype,"serviceRasterInfo",void 0),e([R()],u.prototype,"sourceJSON",void 0),e([R(w)],u.prototype,"url",void 0),e([R({readOnly:!0})],u.prototype,"version",void 0),e([x("version",["currentVersion","fields","timeInfo"])],u.prototype,"readVersion",null),u=e([b("esri.layers.mixins.ArcGISImageService")],u),u};export{me as ArcGISImageService};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{read as r,rasterRendererTypes as i,websceneRasterRendererTypes as s}from"../../rasterRenderers.js";import n from"../../request.js";import a from"../../core/Error.js";import{strict as o}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import u from"../../core/Logger.js";import{isNone as p,isSome as c,unwrap as m}from"../../core/maybe.js";import{when as d}from"../../core/promiseUtils.js";import{urlToObject as h}from"../../core/urlUtils.js";import{aliasOf as f}from"../../core/accessorSupport/decorators/aliasOf.js";import{ensureClass as y,Integer as g,ensureNumber as R}from"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{property as v,ensureRange as x}from"../../core/accessorSupport/decorators/property.js";import{reader as b}from"../../core/accessorSupport/decorators/reader.js";import{subclass as I}from"../../core/accessorSupport/decorators/subclass.js";import{writer as S}from"../../core/accessorSupport/decorators/writer.js";import{opacity as w,url as _}from"../support/commonProperties.js";import O from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as F}from"../support/ExportImageServiceParameters.js";import P from"../support/Field.js";import N from"../support/FieldsIndex.js";import{isSupportedRendererType as j}from"../support/imageryRendererUtils.js";import T from"../support/MosaicRule.js";import D from"../support/PixelBlock.js";import{interpolationKebab as C,noDataInterpretationKebab as J}from"../support/rasterEnums.js";import q from"../support/RasterFunction.js";import M from"../support/RasterInfo.js";import V from"../support/RasterJobHandler.js";import{decode as z,getFormat as Q}from"../support/rasterFormats/RasterCodec.js";import{uvComponentToVector as A}from"../support/rasterFunctions/vectorFieldUtils.js";import{getSupportedRendererTypes as E,getDefaultBandCombination as U,createDefaultRenderer as H,normalizeRendererJSON as L}from"../../renderers/support/rasterRendererHelper.js";import k from"../../renderers/support/RasterSymbolizer.js";import{computeHistograms as B,computeStatisticsHistograms as G,getSamples as W,identify as X}from"../../rest/imageService.js";import"../../kernel.js";import"../../rest/query/support/AttachmentInfo.js";import"../../rest/support/AttachmentQuery.js";import{executeForCount as Y}from"../../rest/query/executeForCount.js";import K from"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import $ from"../../geometry/Point.js";import Z from"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtils.js";import"../../core/pbf.js";import"../../core/unitUtils.js";import"../../geometry/support/spatialReferenceUtils.js";import ee from"../../rest/support/Query.js";import{executeForIds as te}from"../../rest/query/executeForIds.js";import{executeQueryJSON as re}from"../../rest/query/executeQueryJSON.js";import"../graphics/featureConversionUtils.js";import ie from"../../rest/support/FeatureSet.js";import"../../rest/support/RelationshipQuery.js";import"../../rest/support/TopFeaturesQuery.js";import se from"../../rest/support/ImageHistogramParameters.js";import ne from"../../rest/support/ImageIdentifyParameters.js";import ae from"../../rest/support/ImageSampleParameters.js";import oe from"../../geometry/SpatialReference.js";const le=u.getLogger("esri.layers.mixins.ArcGISImageService"),ue=o()({U1:"u1",U2:"u2",U4:"u4",U8:"u8",S8:"s8",U16:"u16",S16:"s16",U32:"u32",S32:"s32",F32:"f32",F64:"f64",C64:"c64",C128:"c128",UNKNOWN:"unknown"}),pe=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),ce=x(R,{min:0,max:255});function me(e){if(!e)return null;const t=JSON.stringify(e).match(/"rasterFunction":"(.*?")/gi),r=null==t?void 0:t.map((e=>e.replace('"rasterFunction":"',"").replace('"',"")));return r?r.join("/"):null}const de=o=>{let u=class extends o{constructor(){super(...arguments),this._functionRasterInfos={},this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this._symbolizer=null,this._defaultServiceMosaicRule=null,this.rasterAttributeTableFieldPrefix="Raster.",this.adjustAspectRatio=null,this.bandCount=null,this.bandIds=void 0,this.capabilities=null,this.compressionQuality=void 0,this.compressionTolerance=.01,this.copyright=null,this.definitionExpression=null,this.exportImageServiceParameters=null,this.rasterInfo=null,this.fields=null,this.fullExtent=null,this.hasMultidimensions=!1,this.imageMaxHeight=4100,this.imageMaxWidth=4100,this.interpolation=void 0,this.minScale=0,this.maxScale=0,this.multidimensionalInfo=null,this.noData=null,this.noDataInterpretation=void 0,this.objectIdField=null,this.geometryType="polygon",this.typeIdField=null,this.types=[],this.pixelSizeX=null,this.pixelSizeY=null,this.pixelFilter=null,this.raster=void 0,this.viewId=void 0,this.renderer=null,this.rasterAttributeTable=null,this.rasterFunctionInfos=null,this.serviceDataType=null,this.spatialReference=null,this.pixelType=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.url=null,this.version=null}initialize(){this._set("exportImageServiceParameters",new F({layer:this}))}readDefaultServiceMosaicRule(e,t){return T.fromJSON(t)}get rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||this.rasterFunctionInfos.length<1||this.rasterFunctionInfos.forEach((t=>{e.set(t.name.toLowerCase().replace(/ /gi,"_"),t.name)})),e}readBandIds(e,t){if(Array.isArray(e)&&e.length>0&&e.every((e=>"number"==typeof e)))return e}readCapabilities(e,t){return this._readCapabilities(t)}writeCompressionQuality(e,t,r){null!=e&&"lerc"!==this.format&&(t[r]=e)}writeCompressionTolerance(e,t,r){"lerc"===this.format&&null!=e&&(t[r]=e)}get fieldsIndex(){return this.fields?new N(this.fields):null}set format(e){e&&pe.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t&&t.mosaicMethod&&(t=T.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){return T.fromJSON(e||t.mosaicRule||t)}writeMosaicRule(e,t,r){let i=this.mosaicRule;const s=this.definitionExpression;i?s&&s!==i.where&&(i=i.clone(),i.where=s):s&&(i=new T({where:s})),this._isValidCustomizedMosaicRule(i)&&(t[r]=i.toJSON())}writeNoData(e,t,r){null!=e&&"number"==typeof e&&(t[r]=ce(e))}readObjectIdField(e,t){if(!e){const r=t.fields.filter((e=>"esriFieldTypeOID"===e.type||"oid"===e.type));e=r&&r[0]&&r[0].name}return e}get parsedUrl(){return this.url?h(this.url):null}readRenderer(e,t,i){var s,n;const a=null==t||null==(s=t.layerDefinition)||null==(n=s.drawingInfo)?void 0:n.renderer,o=r(a,i);return null==o?null:("vector-field"===o.type&&t.symbolTileSize&&!a.symbolTileSize&&(o.symbolTileSize=t.symbolTileSize),j(o)||le.warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),o)}writeRenderer(e,t,r){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this.rasterAttributeTableFieldPrefix||"Raster.",t=new P({name:"Raster.ItemPixelValue",alias:"Item Pixel Value",domain:null,editable:!1,length:50,type:"string"}),r=new P({name:"Raster.ServicePixelValue",alias:"Service Pixel Value",domain:null,editable:!1,length:50,type:"string"}),i=new P({name:"Raster.ServicePixelValue.Raw",alias:"Raw Service Pixel Value",domain:null,editable:!1,length:50,type:"string"});let s=this.fields?l(this.fields):[];s.push(r),this.capabilities.operations.supportsQuery&&this.fields&&this.fields.length>0&&s.push(t),this.version>=10.4&&this.rasterFunctionInfos&&this.rasterFunctionInfos.some((e=>"none"===e.name.toLowerCase()))&&s.push(i),this.rasterFunctionInfos&&this.rasterFunctionInfos.filter((e=>"none"!==e.name.toLowerCase())).forEach((e=>{s.push(new P({name:"Raster.ServicePixelValue."+e.name,alias:e.name,domain:null,editable:!1,length:50,type:"string"}))})),null==this.pixelFilter||"esriImageServiceDataTypeVector-UV"!==this.serviceDataType&&"esriImageServiceDataTypeVector-MagDir"!==this.serviceDataType||(s.push(new P({name:"Raster.Magnitude",alias:"Magnitude",domain:null,editable:!1,type:"double"})),s.push(new P({name:"Raster.Direction",alias:"Direction",domain:null,editable:!1,type:"double"})));const n=this.rasterInfo.attributeTable&&this.rasterInfo.attributeTable.fields||null;if(n&&n.length>0){const t=n.filter((e=>"esriFieldTypeOID"!==e.type&&"value"!==e.name.toLowerCase())).map((t=>{const r=l(t);return r.name=e+t.name,r}));s=s.concat(t)}return s}set renderingRule(e){let t=e;t&&t.rasterFunction&&(t=q.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("renderingRule",t)}readRenderingRule(e,t){const r=t.rasterFunctionInfos;return t.renderingRule||r&&r.length&&"None"!==r[0].name?q.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}writeRenderingRule(e,t,r){this._isRFTJson(e)||(t[r]=e.toJSON())}readSpatialReference(e,t){const r=e||t.extent.spatialReference;return r?oe.fromJSON(r):null}readPixelType(e){return ue.fromJSON(e)||e}writePixelType(e,t,r){(p(this.serviceRasterInfo)||this.pixelType!==this.serviceRasterInfo.pixelType)&&(t[r]=ue.toJSON(e))}readVersion(e,t){let r=t.currentVersion;return r||(r=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),r}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let r=e;if(!this._isPicture()&&this.renderer&&this._symbolizer&&!this.pixelFilter){const i=JSON.stringify(this._cachedRendererJson)!==JSON.stringify(this.renderer.toJSON()),s=this._rasterJobHandler.instance,{bandIds:n}=this;if(s){i&&(this._symbolizer.bind(),await s.updateSymbolizer(this._symbolizer,t),this._cachedRendererJson=this.renderer.toJSON());const a=await s.symbolize({bandIds:n,...e},t);r={extent:e.extent,pixelBlock:a}}else r={extent:e.extent,pixelBlock:this._symbolizer.symbolize({bandIds:n,...e})}}return r}destroy(){this._shutdownJobHandler()}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}async computeHistograms(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsComputeHistograms)throw new a("imagery-layer:compute-histograms","this operation is not supported on the input image service");e=y(se,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;return s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule&&(e.mosaicRule=i),r&&null==e.raster&&(e.raster=r),B(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsComputeStatisticsHistograms)throw new a("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");e=y(se,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;return s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule&&(e.mosaicRule=i),r&&null==e.raster&&(e.raster=r),G(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return c(t)?t.get(e):void 0}getFieldDomain(e,t){const r=this.getField(e);return r?r.domain:null}fetchImage(e,t,r,i={}){if(null==e||null==t||null==r)return Promise.reject(new a("imagery-layer:fetch-image","Insufficient parameters for requesting an image. A valid extent, width and height values are required."));const s=this.renderer||this._symbolizer?this.generateRasterInfo(this.renderingRule,{signal:i.signal}):null;return d(s).then((s=>{s&&(this.rasterInfo=s);const n={imageServiceParameters:this.getExportImageServiceParameters(e,t,r,i.timeExtent),imageProps:{extent:e,width:t,height:r,format:this.format},requestAsImageElement:i.requestAsImageElement&&!this.pixelFilter||!1,signal:i.signal};return this._requestArrayBuffer(n)}))}fetchKeyProperties(e){const t=e&&e.renderingRule&&e.renderingRule.toJSON();return n(this.parsedUrl.path+"/keyProperties",{query:this._getQueryParams({renderingRule:this.version>=10.3&&t?JSON.stringify(t):null})}).then((e=>e.data))}fetchRasterAttributeTable(e){const t=e&&e.renderingRule&&e.renderingRule.toJSON();return this.version<10.1?Promise.reject(new a("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):n(this.parsedUrl.path+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3&&t?JSON.stringify(t):null})}).then((e=>ie.fromJSON(e.data)))}async getCatalogItemRasterInfo(e,t){const r=n(this.parsedUrl.path+"/"+e+"/info",{query:this._getQueryParams(),...t}).then((e=>e.data)),i=n(this.parsedUrl.path+"/"+e+"/info/keyProperties",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>{})),s=await Promise.all([r,i]);if(!s[0])return;const a=K.fromJSON(s[0].extent),o=s[0].statistics?s[0].statistics.map((e=>({min:e[0],max:e[1],avg:e[2],stddev:e[3]}))):null;return new M({bandCount:s[0].bandCount,extent:a,spatialReference:a.sr,pixelSize:new $({x:s[0].pixelSizeX,y:s[0].pixelSizeY,spatialReference:a.sr}),pixelType:s[0].pixelType.toLowerCase(),statistics:o,histograms:s[0].histograms,keyProperties:s[1]||{}})}async getCatalogItemICSInfo(e,t){const{data:r}=await n(this.parsedUrl.path+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),i=r&&r.ics;if(!i)return;let s=null;try{s=(await n(this.parsedUrl.path+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!s||!s.spatialReference)return{ics:i,icsToPixelTransform:null,icsExtent:null,northDirection:null};const a=this.version>=10.7?n(this.parsedUrl.path+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>({}))):{},o=s.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[s]}),inSR:o.wkid||JSON.stringify(o),outSR:"0:"+e},u=n(this.parsedUrl.path+"/project",{query:this._getQueryParams(l),...t}).then((e=>e.data)).catch((()=>({}))),p=5,c=(s.xmin+s.xmax)/2,m=(s.ymax-s.ymin)/(p+1),d=s.ymin+m,h=[];for(let n=0;n<p;n++)h.push({x:c,y:d+m*n});const f={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:h}),inSR:o.wkid||JSON.stringify(o),outSR:"0:"+e},y=n(this.parsedUrl.path+"/project",{query:this._getQueryParams(f),...t}).then((e=>e.data)).catch((()=>({}))),g=await Promise.all([a,u,y]);let R=g[0].ipxf;if(null==R){var v,x,b;const e=null==(v=i.geodataXform)?void 0:v.xf_0;"topup"===(null==e||null==(x=e.name)?void 0:x.toLowerCase())&&6===(null==e||null==(b=e.coefficients)?void 0:b.length)&&(R={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const I=K.fromJSON(g[1]&&g[1].geometries&&g[1].geometries[0]);I&&(I.spatialReference=new oe({wkid:0,imageCoordinateSystem:i}));const S=g[2].geometries?g[2].geometries.filter((e=>null!=e&&null!=e.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y)):[],w=S.length;if(w<3)return{ics:i,icsToPixelTransform:R,icsExtent:I,northDirection:null};let _=0,O=0,F=0,P=0;for(let n=0;n<w;n++)_+=S[n].x,O+=S[n].y,F+=S[n].x*S[n].x,P+=S[n].x*S[n].y;const N=(w*P-_*O)/(w*F-_*_);let j=0;const T=S[p-1].x>S[0].x,D=S[p-1].y>S[0].y;return N===1/0?j=D?90:270:0===N?j=T?0:180:N>0?j=T?180*Math.atan(N)/Math.PI:180*Math.atan(N)/Math.PI+180:N<0&&(j=D?180+180*Math.atan(N)/Math.PI:360+180*Math.atan(N)/Math.PI),{ics:i,icsToPixelTransform:R,icsExtent:I,northDirection:j}}async generateRasterInfo(e,t){if((!e||"none"===e.functionName.toLowerCase()||this._isVectorFieldResampleFunction(e))&&c(this.serviceRasterInfo))return this.serviceRasterInfo;const r=me(e);if(this._functionRasterInfos[r])return this._functionRasterInfos[r];const i=this._generateRasterInfo(e,t);this._functionRasterInfos[r]=i;try{return await i}catch{return this._functionRasterInfos[r]=null,null}}getExportImageServiceParameters(e,t,r,i){const s=(e=e.clone().shiftCentralMeridian()).spatialReference;let n;if(s.imageCoordinateSystem){const{id:e,referenceServiceName:t}=s.imageCoordinateSystem;n=null!=e?t?this.parsedUrl.path.toLowerCase().indexOf("/"+t.toLowerCase()+"/")>-1?"0:"+e:JSON.stringify({icsid:e,icsns:t}):"0:"+e:JSON.stringify({ics:s.imageCoordinateSystem})}else n=s.wkid||JSON.stringify(s.toJSON());c(this.serviceRasterInfo)&&this.pixelType!==this.serviceRasterInfo.pixelType&&(this.exportImageServiceParameters.pixelType=this.pixelType);const a=this.exportImageServiceParameters.toJSON(),{bandIds:o,noData:l}=a;let{renderingRule:u}=a;if(o instanceof Array&&o.length>0&&!this.renderingRule?a.bandIds=o.join(","):a.bandIds=void 0,null!=o&&o.length&&this.renderingRule)if("Colormap"===u.rasterFunction){const e=new q({functionName:"ExtractBand",functionArguments:{BandIds:o,raster:u.rasterFunctionArguments.Raster}});u.rasterFunctionArguments.Raster=e}else{u=new q({functionName:"ExtractBand",functionArguments:{BandIds:o,raster:u}})}l instanceof Array&&l.length>0&&(a.noData=l.join(","));const p=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,i);a.mosaicRule=p&&JSON.stringify(p),a.renderingRule=u&&JSON.stringify(u);const m={};if(i){const{start:e,end:t}=i.toJSON();e&&t&&e===t?m.time=""+e:null==e&&null==t||(m.time=`${null==e?"null":e},${null==t?"null":t}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:n,imageSR:n,size:t+","+r,...a,...m}}async getSamples(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsGetSamples)throw new a("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=y(ae,e).clone();const{raster:r}=this;return r&&null==e.raster&&(e.raster=r),W(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsIdentify)throw new a("imagery-layer:query-rasters","query operation is not supported on the input image service");e=y(ne,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;if(s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule){const t=this._combineMosaicRuleWithTimeExtent(i,e.timeExtent);e.mosaicRule=m(t)}return r&&null==e.raster&&(e.raster=r),X(this.url,e,this._getRequestOptions(t))}createQuery(){const e=new ee;return e.outFields=["*"],e.returnGeometry=!0,e.where=this.definitionExpression||"1=1",e}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),re(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),te(this.url,e,t)}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Y(this.url,e,t)}queryVisibleRasters(e,t){if(!e)return Promise.reject(new a("imagery-layer: query-visible-rasters","missing query parameter"));const{pixelSize:r,returnDomainValues:i,returnTopmostRaster:s,showNoDataRecords:n}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const m="raster.servicepixelvalue",d=this.rasterFunctionNamesIndex;if(c(e.outFields)&&(o=e.outFields.some((e=>-1===e.toLowerCase().indexOf(m))),this.version>=10.4)){const t=e.outFields.filter((e=>e.toLowerCase().indexOf(m)>-1&&e.length>m.length)).map((e=>{const t=e.slice(m.length+1);return[this._updateRenderingRulesFunctionName(t,d),t]}));l=t.map((e=>new q({functionName:e[0]}))),u=t.map((e=>e[1])),0===l.length?this.renderingRule?(l.push(this.renderingRule),u.push(this.renderingRule.functionName)):l=null:this.renderingRule&&!l.some((e=>e.functionName===this.renderingRule.functionName))&&(l.push(this.renderingRule),u.push(this.renderingRule.functionName))}const h=p(e.outSpatialReference)||e.outSpatialReference.equals(this.spatialReference),f=e.timeExtent||this.timeExtent,y=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,f),g=this._getQueryParams({geometry:e.geometry,timeExtent:f,mosaicRule:y,renderingRule:this.version<10.4?this.renderingRule:null,renderingRules:l,pixelSize:r,returnCatalogItems:o,returnGeometry:h,raster:this.raster,maxItemCount:s?1:null});delete g.f;const R=new ne(g),v=this.generateRasterInfo(this.renderingRule);return new Promise((r=>{v.then((()=>{X(this.url,R,{signal:null==t?void 0:t.signal,query:{...this.customParameters}}).then((t=>{const s=e.outFields;if(o&&!h&&t.catalogItems&&t.catalogItems.features&&t.catalogItems.features.length>0){const o=this.objectIdField||"ObjectId",l=t.catalogItems.features,p=l.map((e=>e.attributes&&e.attributes[o])),c=new ee({objectIds:p,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[o]});return this.queryRasters(c).then((a=>{a&&a.features&&a.features.length>0&&a.features.forEach((t=>{l.forEach((r=>{r.attributes[o]===t.attributes[o]&&(r.geometry=new Z(t.geometry),r.geometry.spatialReference=e.outSpatialReference)}))})),r(this._processVisibleRastersResponse(t,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s}))})).catch((()=>{throw new a("imagery-layer:query-visible-rasters","encountered error when querying visible rasters geometry")}))}r(this._processVisibleRastersResponse(t,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s}))})).catch((()=>{throw new a("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}))}))}))}async fetchVariableStatisticsHistograms(e,t){const r=n(this.parsedUrl.path+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>{var t;return null==(t=e.data)?void 0:t.statistics})),i=n(this.parsedUrl.path+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>{var t;return null==(t=e.data)?void 0:t.histograms})),s=await Promise.all([r,i]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[1]||null}}async _fetchService(e){await this._fetchServiceInfo(e),c(this.serviceRasterInfo)&&!this.rasterInfo&&(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,r=c(this.serviceRasterInfo)?Promise.resolve(this.serviceRasterInfo):this._fetchAuxiliaryRasterInfo({serviceInfo:t,signal:e}).then((e=>(this._set("serviceRasterInfo",e),e))),i=this.renderingRule&&"none"!==this.renderingRule.functionName.toLowerCase()?this.generateRasterInfo(this.renderingRule,{signal:e}):null;return Promise.all([r,i]).then((e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),this.renderer&&!this._isSupportedRenderer(this.renderer)&&(this.renderer=null,le.warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._configDefaultRenderer(),this.watch("renderer",(()=>this._configDefaultRenderer())),this.watch("renderingRule",(e=>{(this.renderer||this._symbolizer||this.popupEnabled&&this.popupTemplate)&&this.generateRasterInfo(e).then((e=>{e&&(this.rasterInfo=e)}))}));const t=c(this.serviceRasterInfo)&&this.serviceRasterInfo.multidimensionalInfo;t&&this._updateMultidimensionalDefinition(t)}))}_combineMosaicRuleWithTimeExtent(e,t){const r=this.timeInfo;return p(e)||p(e.multidimensionalDefinition)||p(this.multidimensionalInfo)||p(t)||p(null==r?void 0:r.startField)||((e=e.clone()).multidimensionalDefinition=e.multidimensionalDefinition.filter((e=>e.dimensionName!==r.startField))),e}async _prepareForQuery(e,t){var r;if(await this._fetchCapabilities(null==(r=t)?void 0:r.signal),!this.capabilities.operations.supportsQuery)throw new a("imagery-layer:query-rasters","query operation is not supported on the input image service");return e=c(e)?y(ee,e):this.createQuery(),t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:e,requestOptions:t}}async _initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new V;this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{this._rasterJobHandler.instance=e}),(()=>null)),await this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0}_isSupportedRenderer(e){const{rasterInfo:t,renderingRule:r}=this;return"unique-value"===e.type&&r&&"none"!==r.functionName.toLowerCase()&&1===t.bandCount&&["u8","s8"].includes(t.pixelType)||E(this.rasterInfo).includes(this.renderer.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){var t;let r=this.sourceJSON;if(!r){const{data:t,ssl:i}=await n(this.parsedUrl.path,{query:this._getQueryParams(),signal:e});r=t,this.sourceJSON=r,i&&(this.url=this.url.replace(/^http:/i,"https:"))}if((null==(t=r.capabilities)?void 0:t.toLowerCase().split(",").map((e=>e.trim())).indexOf("tilesonly"))>-1)throw new a("imagery-layer:fetch-service-info","use ImageryTileLayer to open tiles-only image services");this.read(r,{origin:"service",url:this.parsedUrl})}_isVectorFieldResampleFunction(e){if(!c(e))return!1;const{functionName:t,functionArguments:r}=e,i="resample"===t.toLowerCase(),s=(null==r?void 0:r.ResampleType)||(null==r?void 0:r.resampleType);return i&&(7===s||10===s)}_isPicture(){return!this.format||this.format.indexOf("jpg")>-1||this.format.indexOf("png")>-1}_configDefaultRenderer(){if(!this._isPicture()&&!this.pixelFilter){if(!this.bandIds&&this.rasterInfo.bandCount>=3){const e=U(this.rasterInfo);!e||3===this.rasterInfo.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}var e,t;if(!this.renderer)this.renderer=H(this.rasterInfo,{bandIds:this.bandIds,variableName:this.renderingRule?null:null==(e=this.mosaicRule)||null==(t=e.multidimensionalDefinition)?void 0:t[0].variableName});this._symbolizer?(this._symbolizer.rendererJSON=L(this.renderer.toJSON()),this._symbolizer.rasterInfo=this.rasterInfo):this._symbolizer=new k({rendererJSON:this.renderer.toJSON(),rasterInfo:this.rasterInfo}),this._symbolizer.bind()||(this._symbolizer=null)}}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:c(e.pixelBlock)&&e.pixelBlock.clone()}}_getQueryParams(e){const{raster:t,viewId:r}=this;return{raster:t,viewId:r,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...null==e?void 0:e.query,...this.customParameters}}}_decodePixelBlock(e,t,r){return this._rasterJobHandler.instance?this._rasterJobHandler.instance.decode({data:e,options:t}):z(e,t,r)}async _fetchMultidimensionalInfo(e){var t;const r=await n(this.parsedUrl.path+"/multidimensionalInfo",{query:this._getQueryParams(),signal:e}).then((e=>{var t;return null==(t=e.data)?void 0:t.multidimensionalInfo}));return null!=(t=r.variables)&&t.length&&r.variables.forEach((e=>{var t;null!=(t=e.statistics)&&t.length&&e.statistics.forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation}))})),r}_fetchAuxiliaryRasterInfo(e){const t=e&&e.serviceInfo;if(!t)return Promise.reject(new a("imagery-layer:fetch-metadata","valid serviceInfo is required"));const r=e.renderingRule?JSON.stringify(e.renderingRule.toJSON()):null,i=e.signal,s=!!(t.hasRasterAttributeTable&&this.version>=10.1)&&n(this.parsedUrl.path+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.1?r:null}),signal:i}).then((e=>ie.fromJSON(e.data))).catch((()=>null)),o=!!(t.hasColormap&&this.version>=10.1)&&n(this.parsedUrl.path+"/colormap",{query:this._getQueryParams({renderingRule:this.version>=10.6?r:null}),signal:i}).then((e=>{var t;return null==(t=e.data)?void 0:t.colormap})),l=!!(t.hasHistograms&&this.version>=10.1)&&n(this.parsedUrl.path+"/histograms",{query:this._getQueryParams({renderingRule:this.version>=10.1?r:null}),signal:i}).then((e=>{var t;return null==(t=e.data)?void 0:t.histograms})),u=this.version>=10.3&&n(this.parsedUrl.path+"/keyProperties",{query:this._getQueryParams({renderingRule:r}),signal:i}).then((e=>e.data)).catch((()=>{})),p=!!(t.hasMultidimensions&&this.version>=10.3)&&this._fetchMultidimensionalInfo();return Promise.all([s,o,l,u,p]).then((e=>{let r=null;if(t.minValues&&t.minValues.length===t.bandCount){r=[];for(let e=0;e<t.minValues.length;e++)r.push({min:t.minValues[e],max:t.maxValues[e],avg:t.meanValues[e],stddev:t.stdvValues[e]})}const i=Math.ceil((t.extent.xmax-t.extent.xmin)/t.pixelSizeX-.1),s=Math.ceil((t.extent.ymax-t.extent.ymin)/t.pixelSizeY-.1),n=oe.fromJSON(t.spatialReference||t.extent.spatialReference);return new M({width:i,height:s,bandCount:t.bandCount,extent:K.fromJSON(t.extent),spatialReference:n,pixelSize:new $({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:n}),pixelType:t.pixelType.toLowerCase(),statistics:r,attributeTable:e[0]||null,colormap:e[1]||null,histograms:e[2]||null,keyProperties:e[3]||{},multidimensionalInfo:e[4]||null})}))}_requestArrayBuffer(e){const{imageProps:t,requestAsImageElement:r,signal:i}=e;if(r&&!this.pixelFilter&&t.format&&t.format.indexOf("png")>-1)return n(this.parsedUrl.path+"/exportImage",{responseType:"image",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:i}).then((e=>({imageElement:e.data,params:t})));const s=this._initJobHandler(),o=n(this.parsedUrl.path+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:i});return Promise.all([o,s]).then((e=>{const r=e[0].data,s=t.format||"jpgpng";let n=s;if("bsq"!==n&&"bip"!==n&&(n=Q(r)),!n){throw new a("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(r)))}const o="gif"===s||"bmp"===s||s.indexOf("png")>-1&&("png"===n||"jpg"===n),l={signal:i};return o?z(r,{useCanvas:!0,...t},l).then((e=>({pixelData:{pixelBlock:e,extent:t.extent},params:t}))):this._decodePixelBlock(r,{width:t.width,height:t.height,planes:null,pixelType:null,noDataValue:null,format:s},l).then((e=>({pixelData:{pixelBlock:e,extent:t.extent},params:t})))}))}async _generateRasterInfo(e,t){const{data:r}=await n(this.parsedUrl.path,{query:this._getQueryParams({renderingRule:e}),...t});return await this._fetchAuxiliaryRasterInfo({serviceInfo:r,renderingRule:e,...t})}_isValidCustomizedMosaicRule(e){return e&&JSON.stringify(e.toJSON())!==JSON.stringify(this._defaultServiceMosaicRule&&this._defaultServiceMosaicRule.toJSON())}_updateMultidimensionalDefinition(e){if(this._isValidCustomizedMosaicRule(this.mosaicRule))return;const t=e.variables[0].dimensions,r="",i=[];for(const s in t)if(t.hasOwnProperty(s)){const e=t[s],n=e.extent;let a=!0,o=[n[0]];e.hasRanges&&!0===e.hasRanges?(a=!1,o=[e.values[0]]):"stdz"===e.name.toLowerCase()&&Math.abs(n[1])<=Math.abs(n[0])&&(o=[n[1]]),i.push(new O({variableName:r,dimensionName:t[s].name,isSlice:a,values:o}))}if(i.length>0){this.mosaicRule=this.mosaicRule||new T;const e=this.mosaicRule.multidimensionalDefinition;(!e||e&&e.length<=0)&&(this.mosaicRule.multidimensionalDefinition=i)}}_formatAttributeValue(e,t){if("string"==typeof e){const r=this.popupTemplate&&this.popupTemplate.fieldInfos,i=this._getFieldInfo(r,t),s=i&&i.format;if(s){let t,r;return e.trim().indexOf(",")>-1?(t=",",r=t+" ",this._formatDelimitedString(e,t,r,s)):e.trim().indexOf(" ")>-1?(t=r=" ",this._formatDelimitedString(e,t,r,s)):this._formatNumberFromString(e,s)}}return e}_getFieldInfo(e,t){if(!e||!e.length||!t)return;const r=t.toLowerCase();let i;return e.some((e=>!(!e.fieldName||e.fieldName.toLowerCase()!==r&&e.fieldName.toLowerCase()!==r.replace(/ /g,"_"))&&(i=e,!0))),i}_formatDelimitedString(e,t,r,i){return e&&t&&r&&i?e.trim().split(t).map((e=>this._formatNumberFromString(e,i))).join(r):e}_formatNumberFromString(e,t){if(!e||!t)return e;const r=Number(e);return isNaN(r)?e:t.format(r)}_processVisibleRastersResponse(e,r){r=r||{};const i=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:a,templateFields:o}=r,l=e.processedValues;let u=e.catalogItems&&e.catalogItems.features,p=e.properties&&e.properties.Values&&e.properties.Values.map((e=>e.replace(/ /gi,", ")))||[];const m=this.objectIdField||"ObjectId",d="string"==typeof i&&i.toLowerCase().indexOf("nodata")>-1,h=[];if(i&&!u&&!d){const e={};e[m]=0;p=[i],u=[new t(this.fullExtent,null,e)]}if(!u)return[];let f,y,g;this._updateResponseFieldNames(u,o),d&&!n&&(u=[]);for(let t=0;t<u.length;t++){if(f=u[t],null!=i&&!d){if(y=p[t],g=this.renderingRule&&l&&l.length>0&&s&&s.length>0&&s.indexOf(this.renderingRule.functionName)>-1?l[s.indexOf(this.renderingRule.functionName)]:i,"nodata"===y.toLowerCase()&&!n)continue;const e="Raster.ItemPixelValue",r="Raster.ServicePixelValue";f.attributes[e]=this._formatAttributeValue(y,e),f.attributes[r]=this._formatAttributeValue(g,r),this._updateFeatureWithMagDirValues(f,y);const a=this.fields&&this.fields.length>0;let o=this.renderingRule&&c(this.serviceRasterInfo)&&this.serviceRasterInfo.attributeTable?a?y:i:g;this.renderingRule||(o=a?y:i),this._updateFeatureWithRasterAttributeTableValues(f,o)}if(f.sourceLayer=this,a&&this._updateFeatureWithDomainValues(f),s&&l&&s.length===l.length)for(let e=0;e<s.length;e++){const t="Raster.ServicePixelValue."+s[e];f.attributes[t]=this._formatAttributeValue(l[e],t)}h.push(u[t])}return h}_updateFeatureWithRasterAttributeTableValues(e,t){const r=this.rasterInfo&&this.rasterInfo.attributeTable||c(this.serviceRasterInfo)&&this.serviceRasterInfo.attributeTable,i=r&&r.features;if(!i)return;const s=r.fields,n=s.map((e=>e.name)).filter((e=>"value"===e.toLowerCase())),a=n&&n[0];if(!a)return;const o=i.filter((e=>e.attributes[a]===(null!=t?parseInt(t,10):null)));o&&o[0]&&s.forEach((t=>{const r=this.rasterAttributeTableFieldPrefix+t.name;e.attributes[r]=this._formatAttributeValue(o[0].attributes[t.name],r)}))}_updateFeatureWithMagDirValues(e,t){if("esriImageServiceDataTypeVector-UV"!==this.serviceDataType&&"esriImageServiceDataTypeVector-MagDir"!==this.serviceDataType)return;const r=t.split(/,\s*/).map((e=>parseFloat(e))),i=r.map((e=>[e])),s=r.map((e=>({minValue:e,maxValue:e,noDataValue:null}))),n=new D({height:1,width:1,pixelType:"f32",pixels:i,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new K(0,0,0,0,this.spatialReference)});const a="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:A([n.pixels[0][0],n.pixels[1][0]]);e.attributes["Raster.Magnitude"]=a[0],e.attributes["Raster.Direction"]=a[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter((e=>e.domain&&"coded-value"===e.domain.type));null!=t&&t.forEach((t=>{const r=e.attributes[t.name];if(null!=r){const i=t.domain.codedValues.filter((e=>e.code===r))[0];i&&(e.attributes[t.name]=i.name)}}))}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const r=this.fieldsIndex;c(r)&&e.forEach((e=>{if(e&&e.attributes)for(const i of t)if(r.has(i)){const t=r.get(i).name;t!==i&&(e.attributes[i]=e.attributes[t],delete e.attributes[t])}}))}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const r=e.toLowerCase().replace(/ /gi,"_");return t.has(r)?t.get(r):e}_isRFTJson(e){return e.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map((e=>e.trim())):["image","catalog"],{currentVersion:r,advancedQueryCapabilities:i,maxRecordCount:s}=e,n=t.indexOf("image")>-1,a="esriImageServiceDataTypeElevation"===e.serviceDataType,o=!!(e.spatialReference||e.extent&&e.extent.spatialReference),l=t.includes("edit");return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:n,supportsExportImage:n,supportsIdentify:n,supportsMeasure:t.indexOf("mensuration")>-1&&o,supportsDownload:t.indexOf("download")>-1,supportsQuery:t.indexOf("catalog")>-1&&e.fields&&e.fields.length>0,supportsGetSamples:r>=10.2&&n,supportsProject:r>=10.3&&n,supportsComputeStatisticsHistograms:r>=10.4&&n,supportsQueryBoundary:r>=10.6&&n,supportsCalculateVolume:r>=10.7&&a,supportsComputePixelLocation:r>=10.7&&t.indexOf("catalog")>-1,supportsAdd:l,supportsDelete:l,supportsEditing:l,supportsUpdate:l,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1},query:{maxRecordCount:s,maxRecordCountFactor:void 0,supportsStatistics:!(null==i||!i.supportsStatistics),supportsOrderBy:!(null==i||!i.supportsOrderBy),supportsDistinct:!(null==i||!i.supportsDistinct),supportsPagination:!(null==i||!i.supportsPagination),supportsStandardizedQueriesOnly:!(null==i||!i.useStandardizedQueries),supportsPercentileStatistics:!(null==i||!i.supportsPercentileStatistics),supportsCentroid:!(null==i||!i.supportsReturningGeometryCentroid),supportsDistance:!(null==i||!i.supportsQueryWithDistance),supportsExtent:!(null==i||!i.supportsReturningQueryExtent),supportsGeometryProperties:!(null==i||!i.supportsReturningGeometryProperties),supportsHavingClause:!(null==i||!i.supportsHavingClause),supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:!1,supportsTopFeaturesQuery:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0}}}};return e([v()],u.prototype,"_functionRasterInfos",void 0),e([v()],u.prototype,"_rasterJobHandler",void 0),e([v()],u.prototype,"_symbolizer",void 0),e([v()],u.prototype,"_defaultServiceMosaicRule",void 0),e([b("_defaultServiceMosaicRule",["defaultMosaicMethod"])],u.prototype,"readDefaultServiceMosaicRule",null),e([v()],u.prototype,"_cachedRendererJson",void 0),e([v()],u.prototype,"rasterAttributeTableFieldPrefix",void 0),e([v({readOnly:!0})],u.prototype,"rasterFunctionNamesIndex",null),e([v()],u.prototype,"adjustAspectRatio",void 0),e([v({readOnly:!0}),f("serviceRasterInfo.bandCount")],u.prototype,"bandCount",void 0),e([v({type:[g],json:{write:!0}})],u.prototype,"bandIds",void 0),e([b("bandIds")],u.prototype,"readBandIds",null),e([v({readOnly:!0,json:{read:!1}})],u.prototype,"capabilities",void 0),e([b("service","capabilities",["capabilities","currentVersion","serviceDataType"])],u.prototype,"readCapabilities",null),e([v({type:Number})],u.prototype,"compressionQuality",void 0),e([S("compressionQuality")],u.prototype,"writeCompressionQuality",null),e([v({type:Number})],u.prototype,"compressionTolerance",void 0),e([S("compressionTolerance")],u.prototype,"writeCompressionTolerance",null),e([v({json:{read:{source:"copyrightText"}}})],u.prototype,"copyright",void 0),e([v({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],u.prototype,"definitionExpression",void 0),e([v({readOnly:!0,constructOnly:!0})],u.prototype,"exportImageServiceParameters",void 0),e([v()],u.prototype,"rasterInfo",void 0),e([v({readOnly:!0,type:[P]})],u.prototype,"fields",void 0),e([v({readOnly:!0})],u.prototype,"fieldsIndex",null),e([v({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"],json:{write:!0}})],u.prototype,"format",null),e([b("service","format",["serviceDataType"])],u.prototype,"readFormat",null),e([v({type:K})],u.prototype,"fullExtent",void 0),e([v({readOnly:!0})],u.prototype,"hasMultidimensions",void 0),e([v({json:{read:{source:"maxImageHeight"}}})],u.prototype,"imageMaxHeight",void 0),e([v({json:{read:{source:"maxImageWidth"}}})],u.prototype,"imageMaxWidth",void 0),e([v({type:String,json:{type:C.jsonValues,read:C.read,write:C.write}})],u.prototype,"interpolation",void 0),e([v()],u.prototype,"minScale",void 0),e([b("service","minScale")],u.prototype,"readMinScale",null),e([v()],u.prototype,"maxScale",void 0),e([b("service","maxScale")],u.prototype,"readMaxScale",null),e([v({type:T})],u.prototype,"mosaicRule",null),e([b("mosaicRule",["mosaicRule","defaultMosaicMethod"])],u.prototype,"readMosaicRule",null),e([S("mosaicRule")],u.prototype,"writeMosaicRule",null),e([v({readOnly:!0}),f("serviceRasterInfo.multidimensionalInfo")],u.prototype,"multidimensionalInfo",void 0),e([v({json:{type:g}})],u.prototype,"noData",void 0),e([S("noData")],u.prototype,"writeNoData",null),e([v({type:String,json:{type:J.jsonValues,read:J.read,write:J.write}})],u.prototype,"noDataInterpretation",void 0),e([v({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],u.prototype,"objectIdField",void 0),e([b("objectIdField")],u.prototype,"readObjectIdField",null),e([v({})],u.prototype,"geometryType",void 0),e([v({})],u.prototype,"typeIdField",void 0),e([v({})],u.prototype,"types",void 0),e([v({readOnly:!0})],u.prototype,"parsedUrl",null),e([v({readOnly:!0}),f("serviceRasterInfo.pixelSize.x")],u.prototype,"pixelSizeX",void 0),e([v({readOnly:!0}),f("serviceRasterInfo.pixelSize.y")],u.prototype,"pixelSizeY",void 0),e([v({type:Function})],u.prototype,"pixelFilter",void 0),e([v()],u.prototype,"raster",void 0),e([v()],u.prototype,"viewId",void 0),e([v({types:i,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:s,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type})}}}}})],u.prototype,"renderer",void 0),e([b("renderer")],u.prototype,"readRenderer",null),e([S("renderer")],u.prototype,"writeRenderer",null),e([v(w)],u.prototype,"opacity",void 0),e([v({readOnly:!0}),f("serviceRasterInfo.attributeTable")],u.prototype,"rasterAttributeTable",void 0),e([v({readOnly:!0})],u.prototype,"rasterFields",null),e([v({readOnly:!0})],u.prototype,"rasterFunctionInfos",void 0),e([v({type:q})],u.prototype,"renderingRule",null),e([b("renderingRule",["renderingRule","rasterFunctionInfos"])],u.prototype,"readRenderingRule",null),e([S("renderingRule")],u.prototype,"writeRenderingRule",null),e([v()],u.prototype,"serviceDataType",void 0),e([v({readOnly:!0,type:oe})],u.prototype,"spatialReference",void 0),e([b("spatialReference",["spatialReference","extent"])],u.prototype,"readSpatialReference",null),e([v({json:{type:ue.jsonValues}})],u.prototype,"pixelType",void 0),e([b("pixelType")],u.prototype,"readPixelType",null),e([S("pixelType")],u.prototype,"writePixelType",null),e([v({constructOnly:!0,type:M})],u.prototype,"serviceRasterInfo",void 0),e([v()],u.prototype,"sourceJSON",void 0),e([v(_)],u.prototype,"url",void 0),e([v({readOnly:!0})],u.prototype,"version",void 0),e([b("version",["currentVersion","fields","timeInfo"])],u.prototype,"readVersion",null),u=e([I("esri.layers.mixins.ArcGISImageService")],u),u};export{de as ArcGISImageService};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.21/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../request.js";import r from"../../../core/Error.js";import{JSONSupport as o}from"../../../core/JSONSupport.js";import i from"../../../core/Logger.js";import{isSome as n,isNone as s,unwrap as a}from"../../../core/maybe.js";import{EsriPromiseMixin as l}from"../../../core/Promise.js";import{createAbortController as c,onAbort as u}from"../../../core/promiseUtils.js";import{property as f}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../../core/accessorSupport/decorators/subclass.js";import{sanitizeUrl as h}from"../arcgisLayerUrl.js";import{url as d}from"../commonProperties.js";import g from"../RasterStorageInfo.js";import p from"../TileInfo.js";import{getRasterId as x,getBlock as y,putBlock as I,deleteBlock as w,decreaseRefCount as v}from"./RawBlockCache.js";import{decode as k}from"../rasterFormats/RasterCodec.js";import{mosaic as R,approximateTransform as b}from"../rasterFunctions/pixelUtils.js";import{load as C,projectPoint as M,snapPyramid as T,snapExtent as P,getWorldWrapCount as B,projectResolution as S,projectExtent as F,getProjectionOffsetGrid as j,getRasterDatasetAlignmentInfo as L}from"../rasterFunctions/rasterProjectionHelper.js";import{uvComponentToVector as D}from"../rasterFunctions/vectorFieldUtils.js";import H from"../../../geometry/Point.js";import _ from"../../../geometry/Extent.js";let A=class extends(l(o)){constructor(){super(...arguments),this.rasterJobHandler=null,this.datasetName=null,this.datasetFormat=null,this.rasterInfo=null,this.ioConfig={sampling:"closest"}}async init(){const e=C();this.addResolvingPromise(e),await this.when()}normalizeCtorArgs(e){return e&&e.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:p.create(),...e.ioConfig}}),e}set url(e){this._set("url",h(e,i.getLogger(this.declaredClass)))}async open(e){throw new r("BaseRaster:open-not-implemented","open() is not implemented")}async fetchTile(e,t,r,o={}){var i;const{tileInfo:s}=o,a=s.lodAt(e),l=this.getTileExtent({x:a.resolution,y:a.resolution},t,r,s.origin,s.spatialReference,s.size);return null!=(i=o.multidimensionalDefinition)&&i.length&&n(this.rasterInfo.multidimensionalInfo)&&null==o.sliceId&&(o={...o,sliceId:this.getSliceIndex(o.multidimensionalDefinition)||0}),this.fetchPixels(l,s.size[0],s.size[1],o)}async identify(e,t={}){const{spatialReference:r,extent:o}=this.rasterInfo,{datumTransformation:i}=t;let a=M(e,r,i);if(!o.intersects(a))return{location:a,value:null};if(n(this.rasterInfo.transform)){const e=this.rasterInfo.transform.inverseTransform(a);if(!this.rasterInfo.nativeExtent.intersects(e))return{location:e,value:null};a=e}let l=0;if(t.srcResolution){l=T(t.srcResolution,this.rasterInfo,this.ioConfig.sampling).pyramidLevel}else if(l=await this.computeBestPyramidLevelForLocation(e,t),null==l)return{location:a,value:null};const c=this.identifyPixelLocation(a,l,null);if(null===c)return{location:a,value:null};const{row:u,col:f,rowOffset:m,colOffset:h}=c,d=x(this.url,t.sliceId),g=`${l}/${u}/${f}`;let p=y(d,null,g);s(p)&&(p=this.fetchRawTile(l,u,f,t),I(d,null,g,p));const w=await p;if(s(w)||!w.pixels||0===w.pixels.length)return{location:a,value:null};const v=m*this.rasterInfo.storageInfo.blockHeight+h,k=!w.mask||w.mask[v]?w.pixels.map((e=>e[v])):null,R=this.rasterInfo.dataType;if(("vector-magdir"===R||"vector-uv"===R)&&(null==k?void 0:k.length)>1){return{location:a,value:k,magdirValue:"vector-magdir"===R?[k[0],k[1]]:D([k[0],k[1]]),pyramidLevel:l}}return{location:a,value:k,pyramidLevel:l}}async fetchPixels(e,t,r,o={}){e=P(e);const i=B(e),n=this.rasterInfo.spatialReference,s=!e.spatialReference.equals(n),{datumTransformation:l}=o,c=new H({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/r,spatialReference:e.spatialReference}),u=o.srcResolution||(s?S(c,n,e,l):c);if(!u)return null;const{pyramidLevel:f,pyramidResolution:m,excessiveReading:h}=T(u,this.rasterInfo,this.ioConfig.sampling);if(h)return null;const d=this.rasterInfo.storageInfo;let g=s?F(e,n,l):e;const p=a(this.rasterInfo.transform);if(p&&(g=p.inverseTransform(g)),null==g)return null;const x={x:Math.floor((g.xmin-d.origin.x)/m.x+.1),y:Math.floor((d.origin.y-g.ymax)/m.y+.1)},y=Math.ceil((g.xmax-g.xmin)/m.x-.1),I=Math.ceil((g.ymax-g.ymin)/m.y-.1);if(y/t>8||I/r>8||i>=2)return null;const w=await this.fetchRawPixels(f,x,{width:y,height:I,wrapCount:i},o);if(!w)return null;const v=f>0?d.pyramidBlockWidth:d.blockWidth,k=f>0?d.pyramidBlockHeight:d.blockHeight,C=v===y&&k===I&&x.x%v==0&&x.y%k==0;if(!s&&C&&1===w.pixelBlocks.length&&v===t&&k===r&&u.x===c.x&&u.y===c.y)return{extent:e,srcExtent:g,pixelBlock:w.pixelBlocks[0]};const M=j(e,w.extent,c,l,p,i>0);let L;const D=!o.requestRawData,_={rows:M.spacing[0],cols:M.spacing[1]},A=a(this._getRasterTileAlignmentInfo(f,w.extent.xmin)),{pixelBlocks:W,mosaicSize:z,isPartiallyFilled:U}=w;if(this.rasterJobHandler)L=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:W,srcMosaicSize:z,destDimension:D?{width:t,height:r}:null,coefs:D?M.coefficients:null,sampleSpacing:D?_:null,interpolation:o.interpolation,alignmentInfo:A},o);else{const e=R(W,z,null,null,A);L=D?b(e,{width:t,height:r},M.coefficients,_,o.interpolation):e}return o.requestRawData?{srcExtent:g,pixelBlock:L,transformGrid:M,extent:e,isPartiallyFilled:U}:{srcExtent:g,extent:e,pixelBlock:L}}async fetchRawPixels(e,t,r,o){const{origin:i,blockBoundary:n}=this.rasterInfo.storageInfo,{blockWidth:s,blockHeight:l}=this.getBlockWidthHeight(e);let{x:c,y:u}=t,{width:f,height:m,wrapCount:h}=r;const d=a(this._getRasterTileAlignmentInfo(e,0));o.buffer&&(c-=o.buffer.cols,u-=o.buffer.rows,f+=2*o.buffer.cols,m+=2*o.buffer.rows);const g=Math.floor(c/s),p=Math.floor(u/l),x=Math.floor((c+f-1)/s),y=Math.floor((u+m-1)/l),I=n[e];if(!I)return null;const{minRow:w,minCol:v,maxCol:k,maxRow:R}=I;if(y<w||x<v||p>R||g>k)return null;const b=new Array;let C=!1;const M=null==this.ioConfig.allowPartialFill?o.allowPartialFill:this.ioConfig.allowPartialFill;for(let a=p;a<=y;a++)for(let t=g;t<=x;t++){const r=0===h||null==d||t<d.worldColumnCountFromOrigin?t:t%d.worldColumnCountFromOrigin-d.originColumnOffset;if(a>=w&&r>=v&&R>=a&&k>=r){const t=this._fetchRawTile(e,a,r,o);M?b.push(new Promise((e=>{t.then((t=>e(t))).catch((()=>{C=!0,e(null)}))}))):b.push(t)}else b.push(null)}if(0===b.length)return null;const T=await Promise.all(b),P={height:(y-p+1)*l,width:(x-g+1)*s},{spatialReference:B}=this.rasterInfo,S=this.getPyramidPixelSize(e),{x:F,y:j}=S;return{extent:new _({xmin:i.x+g*s*F,xmax:i.x+(x+1)*s*F,ymin:i.y-(y+1)*l*j,ymax:i.y-p*l*j,spatialReference:B}),pixelBlocks:T,mosaicSize:P,isPartiallyFilled:C}}fetchRawTile(e,t,o,i){throw new r("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return F(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?k(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,r,o){var i,n;const{customFetchParameters:s}=this.ioConfig,{range:a,query:l,headers:c}=r;o=null!=(i=null!=(n=o)?n:r.retryCount)?i:this.ioConfig.retryCount;const u=a?{Range:`bytes=${a.from}-${a.to}`}:null;try{return await t(e,{...r,query:{...l,...s},headers:{...c,...u}})}catch(f){if(o>0)return o--,this.request(e,r,o);throw f}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;if(!n(t)||null==e||!e.length)return null;let r=0;const o=e[0].variableName;for(let i=0;i<t.variables.length;i++){const n=t.variables[i],s=n.dimensions;if(n.name!==o){r+=s.map((e=>this._getDimensionValuesCount(e))).reduce(((e,t)=>e+t));break}const a=s.map((e=>this._getDimensionValuesCount(e))),l=s.length;for(let t=0;t<l;t++){const o=e.filter((e=>e.dimensionName===s[t].name))[0];if(null==o)return null;const i=Array.isArray(o.values[0])?o.values[0][0]:o.values[0],n=this._getIndexFromDimensions(i,s[t]);if(-1===n)return null;a.shift(),r+=t===l-1?n:n*a.reduce(((e,t)=>e+t))}}return r}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:r,pixelSize:o}=this.rasterInfo;if(!e.tileInfo){const i=[],n=e.maximumPyramidLevel||0;let s=Math.max(o.x,o.y),a=1/.0254*96*s;for(let e=0;e<=n;e++)i.push({level:n-e,resolution:s,scale:a}),s*=2,a*=2;const l=new H({x:r.xmin,y:r.ymax,spatialReference:t});e.tileInfo=new p({origin:l,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:i}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,r=512,o){const{width:i,height:n,nativeExtent:s,pixelSize:a,spatialReference:l}=e,c=new H({x:s.xmin,y:s.ymax,spatialReference:l});null==o&&(o=Math.max(0,Math.round(Math.log(Math.max(i,n))/Math.LN2-8)));const u=this.computeBlockBoundary(s,512,512,{x:s.xmin,y:s.ymax},[a],o);e.storageInfo=new g({blockWidth:t,blockHeight:r,pyramidBlockWidth:t,pyramidBlockHeight:r,origin:c,firstPyramidLevel:1,maximumPyramidLevel:o,blockBoundary:u})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,r,o,i,n=0,s=2){if(1===i.length&&n>0){i=[...i];let{x:e,y:t}=i[0];for(let r=0;r<n;r++)e*=s,t*=s,i.push({x:e,y:t})}const a=[],{x:l,y:c}=o;for(let u=0;u<i.length;u++){const{x:o,y:n}=i[u];a.push({minCol:Math.floor((e.xmin-l+.1*o)/t/o),maxCol:Math.floor((e.xmax-l-.1*o)/t/o),minRow:Math.floor((c-e.ymax+.1*n)/r/n),maxRow:Math.floor((c-e.ymin-.1*n)/r/n)})}return a}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:r,pyramidScalingFactor:o}=this.rasterInfo.storageInfo;if(0===e)return t;if(n(r)&&r.length)return r[e-1];const i=o**e;return{x:t.x*i,y:t.y*i}}identifyPixelLocation(e,t,r){const{spatialReference:o,nativeExtent:i}=this.rasterInfo,{blockWidth:n,blockHeight:s,maximumPyramidLevel:a,origin:l}=this.rasterInfo.storageInfo,c=M(e,o,r);if(!i.intersects(c))return null;if(t<0||t>a)return null;const u=this.getPyramidPixelSize(t),{x:f,y:m}=u,h=(l.y-c.y)/m/s,d=(c.x-l.x)/f/n,g=Math.min(s-1,Math.floor((h-Math.floor(h))*s)),p=Math.min(n-1,Math.floor((d-Math.floor(d))*n));return{pyramidLevel:t,row:Math.floor(h),col:Math.floor(d),rowOffset:g,colOffset:p,srcLocation:c}}getTileExtent(e,t,r,o,i,n){const[s,a]=n,l=o.x+r*s*e.x,c=l+s*e.x,u=o.y-t*a*e.y,f=u-a*e.y;return new _({xmin:l,xmax:c,ymin:f,ymax:u,spatialReference:i})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,r){const o=this.rasterInfo.storageInfo.blockBoundary[e];return!o||o.maxRow<t||o.maxCol<r||o.minRow>t||o.minCol>r}_fetchRawTile(e,t,r,o){const i=this.rasterInfo.storageInfo.blockBoundary[e];if(!i)return Promise.resolve(null);const{minRow:n,minCol:a,maxCol:l,maxRow:f}=i;if(t<n||r<a||t>f||r>l)return Promise.resolve(null);const m=x(this.url,o.sliceId),h=`${e}/${t}/${r}`;let d=y(m,o.registryId,h);if(s(d)){const i=c();d=this.fetchRawTile(e,t,r,{...o,signal:i.signal}),I(m,o.registryId,h,d,i),d.catch((()=>w(m,o.registryId,h)))}return o.signal&&u(o,(()=>{v(m,o.registryId,h)})),d}_getIndexFromDimensions(e,t){const{extent:r,interval:o,unit:i,values:n}=t;if(null!=n&&n.length)return Array.isArray(n[0])?n.findIndex((t=>t[0]<=e&&t[1]>=e)):n.indexOf(e);if(e>r[1])return-1;const s=r[0];let a=-1;if("ISO8601"===i){var l;switch((null==(l=t.intervalUnit)?void 0:l.toLowerCase())||"seconds"){case"seconds":a=Math.round((e-s)/1e3/o);break;case"minutes":a=Math.round((e-s)/6e4/o);break;case"hours":a=Math.round((e-s)/36e5/o);break;case"days":a=Math.round((e-s)/864e5/o);break;case"years":a=Math.round((new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear())/o);break;case"decades":a=Math.round((new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear())/10/o)}return a}return Math.round((e-s)/o)}_getDimensionValuesCount(e){const{extent:t,interval:r,unit:o,values:i}=e;let n=(null==i?void 0:i.length)||0;if(n)return n;const s=t[0];if(0===n&&"ISO8601"===o){var a;switch((null==(a=e.intervalUnit)?void 0:a.toLowerCase())||"seconds"){case"seconds":n=Math.round((t[1]-t[0])/1e3/r);break;case"minutes":n=Math.round((t[1]-t[0])/6e4/r);break;case"hours":n=Math.round((t[1]-t[0])/36e5/r);break;case"days":n=Math.round((t[1]-t[0])/864e5/r);break;case"years":n=Math.round((new Date(t[1]).getUTCFullYear()-new Date(s).getUTCFullYear())/r);break;case"decades":n=Math.round((new Date(t[1]).getUTCFullYear()-new Date(s).getUTCFullYear())/10/r)}return n}return Math.round((t[1]-t[0])/r)}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlighmentInfo&&(this._rasterTileAlighmentInfo=L(this.rasterInfo)),n(this._rasterTileAlighmentInfo.pyramidsInfo)?{startX:t,halfWorldWidth:this._rasterTileAlighmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlighmentInfo.hasGCSSShiftTransform,...this._rasterTileAlighmentInfo.pyramidsInfo[e]}:null}};e([f()],A.prototype,"_rasterTileAlighmentInfo",void 0),e([f(d)],A.prototype,"url",null),e([f({type:String,json:{write:!0}})],A.prototype,"datasetName",void 0),e([f({type:String,json:{write:!0}})],A.prototype,"datasetFormat",void 0),e([f()],A.prototype,"rasterInfo",void 0),e([f()],A.prototype,"ioConfig",void 0),e([f()],A.prototype,"sourceJSON",void 0),A=e([m("esri.layers.support.rasterDatasets.BaseRaster")],A);var W=A;export{W as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../request.js";import r from"../../../core/Error.js";import{JSONSupport as o}from"../../../core/JSONSupport.js";import i from"../../../core/Logger.js";import{isSome as n,isNone as s,unwrap as a}from"../../../core/maybe.js";import{EsriPromiseMixin as l}from"../../../core/Promise.js";import{createAbortController as c,onAbort as u}from"../../../core/promiseUtils.js";import{property as f}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../../core/accessorSupport/decorators/subclass.js";import{sanitizeUrl as h}from"../arcgisLayerUrl.js";import{url as d}from"../commonProperties.js";import g from"../RasterStorageInfo.js";import p from"../TileInfo.js";import{getRasterId as x,getBlock as y,putBlock as I,deleteBlock as w,decreaseRefCount as v}from"./RawBlockCache.js";import{decode as k}from"../rasterFormats/RasterCodec.js";import{mosaic as R,approximateTransform as b}from"../rasterFunctions/pixelUtils.js";import{load as C,projectPoint as M,snapPyramid as T,snapExtent as P,getWorldWrapCount as S,projectResolution as B,projectExtent as F,getProjectionOffsetGrid as j,getRasterDatasetAlignmentInfo as L}from"../rasterFunctions/rasterProjectionHelper.js";import{uvComponentToVector as _}from"../rasterFunctions/vectorFieldUtils.js";import D from"../../../geometry/Point.js";import H from"../../../geometry/Extent.js";let W=class extends(l(o)){constructor(){super(...arguments),this.rasterJobHandler=null,this.datasetName=null,this.datasetFormat=null,this.rasterInfo=null,this.ioConfig={sampling:"closest"}}async init(){const e=C();this.addResolvingPromise(e),await this.when()}normalizeCtorArgs(e){return e&&e.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:p.create(),...e.ioConfig}}),e}set url(e){this._set("url",h(e,i.getLogger(this.declaredClass)))}async open(e){throw new r("BaseRaster:open-not-implemented","open() is not implemented")}async fetchTile(e,t,r,o={}){const{tileInfo:i}=o,n=i.lodAt(e),s=this.getTileExtent({x:n.resolution,y:n.resolution},t,r,i.origin,i.spatialReference,i.size);return o=this._getRequestOptionsWithSliceId(o),this.fetchPixels(s,i.size[0],i.size[1],o)}async identify(e,t={}){t=this._getRequestOptionsWithSliceId(t);const{spatialReference:r,extent:o}=this.rasterInfo,{datumTransformation:i}=t;let a=M(e,r,i);if(!o.intersects(a))return{location:a,value:null};if(n(this.rasterInfo.transform)){const e=this.rasterInfo.transform.inverseTransform(a);if(!this.rasterInfo.nativeExtent.intersects(e))return{location:e,value:null};a=e}let l=0;if(t.srcResolution){l=T(t.srcResolution,this.rasterInfo,this.ioConfig.sampling).pyramidLevel}else if(l=await this.computeBestPyramidLevelForLocation(e,t),null==l)return{location:a,value:null};const c=this.identifyPixelLocation(a,l,null);if(null===c)return{location:a,value:null};const{row:u,col:f,rowOffset:m,colOffset:h}=c,d=x(this.url,t.sliceId),g=`${l}/${u}/${f}`;let p=y(d,null,g);s(p)&&(p=this.fetchRawTile(l,u,f,t),I(d,null,g,p));const w=await p;if(s(w)||!w.pixels||0===w.pixels.length)return{location:a,value:null};const v=m*this.rasterInfo.storageInfo.blockHeight+h,k=!w.mask||w.mask[v]?w.pixels.map((e=>e[v])):null,R=this.rasterInfo.dataType;if(("vector-magdir"===R||"vector-uv"===R)&&(null==k?void 0:k.length)>1){return{location:a,value:k,magdirValue:"vector-magdir"===R?[k[0],k[1]]:_([k[0],k[1]]),pyramidLevel:l}}return{location:a,value:k,pyramidLevel:l}}async fetchPixels(e,t,r,o={}){e=P(e);const i=S(e),n=this.rasterInfo.spatialReference,s=!e.spatialReference.equals(n),{datumTransformation:l}=o,c=new D({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/r,spatialReference:e.spatialReference}),u=o.srcResolution||(s?B(c,n,e,l):c);if(!u)return null;const{pyramidLevel:f,pyramidResolution:m,excessiveReading:h}=T(u,this.rasterInfo,this.ioConfig.sampling);if(h)return null;const d=this.rasterInfo.storageInfo;let g=s?F(e,n,l):e;const p=a(this.rasterInfo.transform);if(p&&(g=p.inverseTransform(g)),null==g)return null;const x={x:Math.floor((g.xmin-d.origin.x)/m.x+.1),y:Math.floor((d.origin.y-g.ymax)/m.y+.1)},y=Math.ceil((g.xmax-g.xmin)/m.x-.1),I=Math.ceil((g.ymax-g.ymin)/m.y-.1);if(y/t>8||I/r>8||i>=2)return null;const w=await this.fetchRawPixels(f,x,{width:y,height:I,wrapCount:i},o);if(!w)return null;const v=f>0?d.pyramidBlockWidth:d.blockWidth,k=f>0?d.pyramidBlockHeight:d.blockHeight,C=v===y&&k===I&&x.x%v==0&&x.y%k==0;if(!s&&C&&1===w.pixelBlocks.length&&v===t&&k===r&&u.x===c.x&&u.y===c.y)return{extent:e,srcExtent:g,pixelBlock:w.pixelBlocks[0]};const M=j(e,w.extent,c,l,p,i>0);let L;const _=!o.requestRawData,H={rows:M.spacing[0],cols:M.spacing[1]},W=a(this._getRasterTileAlignmentInfo(f,w.extent.xmin)),{pixelBlocks:A,mosaicSize:O,isPartiallyFilled:z}=w;if(this.rasterJobHandler)L=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:A,srcMosaicSize:O,destDimension:_?{width:t,height:r}:null,coefs:_?M.coefficients:null,sampleSpacing:_?H:null,interpolation:o.interpolation,alignmentInfo:W},o);else{const e=R(A,O,null,null,W);L=_?b(e,{width:t,height:r},M.coefficients,H,o.interpolation):e}return o.requestRawData?{srcExtent:g,pixelBlock:L,transformGrid:M,extent:e,isPartiallyFilled:z}:{srcExtent:g,extent:e,pixelBlock:L}}async fetchRawPixels(e,t,r,o){const{origin:i,blockBoundary:n}=this.rasterInfo.storageInfo,{blockWidth:s,blockHeight:l}=this.getBlockWidthHeight(e);let{x:c,y:u}=t,{width:f,height:m,wrapCount:h}=r;const d=a(this._getRasterTileAlignmentInfo(e,0));o.buffer&&(c-=o.buffer.cols,u-=o.buffer.rows,f+=2*o.buffer.cols,m+=2*o.buffer.rows);const g=Math.floor(c/s),p=Math.floor(u/l),x=Math.floor((c+f-1)/s),y=Math.floor((u+m-1)/l),I=n[e];if(!I)return null;const{minRow:w,minCol:v,maxCol:k,maxRow:R}=I;if(y<w||x<v||p>R||g>k)return null;const b=new Array;let C=!1;const M=null==this.ioConfig.allowPartialFill?o.allowPartialFill:this.ioConfig.allowPartialFill;for(let a=p;a<=y;a++)for(let t=g;t<=x;t++){const r=0===h||null==d||t<d.worldColumnCountFromOrigin?t:t%d.worldColumnCountFromOrigin-d.originColumnOffset;if(a>=w&&r>=v&&R>=a&&k>=r){const t=this._fetchRawTile(e,a,r,o);M?b.push(new Promise((e=>{t.then((t=>e(t))).catch((()=>{C=!0,e(null)}))}))):b.push(t)}else b.push(null)}if(0===b.length)return null;const T=await Promise.all(b),P={height:(y-p+1)*l,width:(x-g+1)*s},{spatialReference:S}=this.rasterInfo,B=this.getPyramidPixelSize(e),{x:F,y:j}=B;return{extent:new H({xmin:i.x+g*s*F,xmax:i.x+(x+1)*s*F,ymin:i.y-(y+1)*l*j,ymax:i.y-p*l*j,spatialReference:S}),pixelBlocks:T,mosaicSize:P,isPartiallyFilled:C}}fetchRawTile(e,t,o,i){throw new r("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return F(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?k(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,r,o){var i,n;const{customFetchParameters:s}=this.ioConfig,{range:a,query:l,headers:c}=r;o=null!=(i=null!=(n=o)?n:r.retryCount)?i:this.ioConfig.retryCount;const u=a?{Range:`bytes=${a.from}-${a.to}`}:null;try{return await t(e,{...r,query:{...l,...s},headers:{...c,...u}})}catch(f){if(o>0)return o--,this.request(e,r,o);throw f}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;if(!n(t)||null==e||!e.length)return null;let r=0;const o=e[0].variableName;for(let i=0;i<t.variables.length;i++){const n=t.variables[i],s=n.dimensions;if(n.name!==o){r+=s.map((e=>this._getDimensionValuesCount(e))).reduce(((e,t)=>e+t));break}const a=s.map((e=>this._getDimensionValuesCount(e))),l=s.length;for(let t=0;t<l;t++){const o=e.filter((e=>e.dimensionName===s[t].name))[0];if(null==o)return null;const i=Array.isArray(o.values[0])?o.values[0][0]:o.values[0],n=this._getIndexFromDimensions(i,s[t]);if(-1===n)return null;a.shift(),r+=t===l-1?n:n*a.reduce(((e,t)=>e+t))}}return r}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:r,pixelSize:o}=this.rasterInfo;if(!e.tileInfo){const i=[],n=e.maximumPyramidLevel||0;let s=Math.max(o.x,o.y),a=1/.0254*96*s;for(let e=0;e<=n;e++)i.push({level:n-e,resolution:s,scale:a}),s*=2,a*=2;const l=new D({x:r.xmin,y:r.ymax,spatialReference:t});e.tileInfo=new p({origin:l,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:i}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,r=512,o){const{width:i,height:n,nativeExtent:s,pixelSize:a,spatialReference:l}=e,c=new D({x:s.xmin,y:s.ymax,spatialReference:l});null==o&&(o=Math.max(0,Math.round(Math.log(Math.max(i,n))/Math.LN2-8)));const u=this.computeBlockBoundary(s,512,512,{x:s.xmin,y:s.ymax},[a],o);e.storageInfo=new g({blockWidth:t,blockHeight:r,pyramidBlockWidth:t,pyramidBlockHeight:r,origin:c,firstPyramidLevel:1,maximumPyramidLevel:o,blockBoundary:u})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,r,o,i,n=0,s=2){if(1===i.length&&n>0){i=[...i];let{x:e,y:t}=i[0];for(let r=0;r<n;r++)e*=s,t*=s,i.push({x:e,y:t})}const a=[],{x:l,y:c}=o;for(let u=0;u<i.length;u++){const{x:o,y:n}=i[u];a.push({minCol:Math.floor((e.xmin-l+.1*o)/t/o),maxCol:Math.floor((e.xmax-l-.1*o)/t/o),minRow:Math.floor((c-e.ymax+.1*n)/r/n),maxRow:Math.floor((c-e.ymin-.1*n)/r/n)})}return a}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:r,pyramidScalingFactor:o}=this.rasterInfo.storageInfo;if(0===e)return t;if(n(r)&&r.length)return r[e-1];const i=o**e;return{x:t.x*i,y:t.y*i}}identifyPixelLocation(e,t,r){const{spatialReference:o,nativeExtent:i}=this.rasterInfo,{blockWidth:n,blockHeight:s,maximumPyramidLevel:a,origin:l}=this.rasterInfo.storageInfo,c=M(e,o,r);if(!i.intersects(c))return null;if(t<0||t>a)return null;const u=this.getPyramidPixelSize(t),{x:f,y:m}=u,h=(l.y-c.y)/m/s,d=(c.x-l.x)/f/n,g=Math.min(s-1,Math.floor((h-Math.floor(h))*s)),p=Math.min(n-1,Math.floor((d-Math.floor(d))*n));return{pyramidLevel:t,row:Math.floor(h),col:Math.floor(d),rowOffset:g,colOffset:p,srcLocation:c}}getTileExtent(e,t,r,o,i,n){const[s,a]=n,l=o.x+r*s*e.x,c=l+s*e.x,u=o.y-t*a*e.y,f=u-a*e.y;return new H({xmin:l,xmax:c,ymin:f,ymax:u,spatialReference:i})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,r){const o=this.rasterInfo.storageInfo.blockBoundary[e];return!o||o.maxRow<t||o.maxCol<r||o.minRow>t||o.minCol>r}_fetchRawTile(e,t,r,o){const i=this.rasterInfo.storageInfo.blockBoundary[e];if(!i)return Promise.resolve(null);const{minRow:n,minCol:a,maxCol:l,maxRow:f}=i;if(t<n||r<a||t>f||r>l)return Promise.resolve(null);const m=x(this.url,o.sliceId),h=`${e}/${t}/${r}`;let d=y(m,o.registryId,h);if(s(d)){const i=c();d=this.fetchRawTile(e,t,r,{...o,signal:i.signal}),I(m,o.registryId,h,d,i),d.catch((()=>w(m,o.registryId,h)))}return o.signal&&u(o,(()=>{v(m,o.registryId,h)})),d}_getIndexFromDimensions(e,t){const{extent:r,interval:o,unit:i,values:n}=t;if(null!=n&&n.length)return Array.isArray(n[0])?n.findIndex((t=>t[0]<=e&&t[1]>=e)):n.indexOf(e);if(e>r[1])return-1;const s=r[0];let a=-1;if("ISO8601"===i){var l;switch((null==(l=t.intervalUnit)?void 0:l.toLowerCase())||"seconds"){case"seconds":a=Math.round((e-s)/1e3/o);break;case"minutes":a=Math.round((e-s)/6e4/o);break;case"hours":a=Math.round((e-s)/36e5/o);break;case"days":a=Math.round((e-s)/864e5/o);break;case"years":a=Math.round((new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear())/o);break;case"decades":a=Math.round((new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear())/10/o)}return a}return Math.round((e-s)/o)}_getDimensionValuesCount(e){const{extent:t,interval:r,unit:o,values:i}=e;let n=(null==i?void 0:i.length)||0;if(n)return n;const s=t[0];if(0===n&&"ISO8601"===o){var a;switch((null==(a=e.intervalUnit)?void 0:a.toLowerCase())||"seconds"){case"seconds":n=Math.round((t[1]-t[0])/1e3/r);break;case"minutes":n=Math.round((t[1]-t[0])/6e4/r);break;case"hours":n=Math.round((t[1]-t[0])/36e5/r);break;case"days":n=Math.round((t[1]-t[0])/864e5/r);break;case"years":n=Math.round((new Date(t[1]).getUTCFullYear()-new Date(s).getUTCFullYear())/r);break;case"decades":n=Math.round((new Date(t[1]).getUTCFullYear()-new Date(s).getUTCFullYear())/10/r)}return n}return Math.round((t[1]-t[0])/r)}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlighmentInfo&&(this._rasterTileAlighmentInfo=L(this.rasterInfo)),n(this._rasterTileAlighmentInfo.pyramidsInfo)?{startX:t,halfWorldWidth:this._rasterTileAlighmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlighmentInfo.hasGCSSShiftTransform,...this._rasterTileAlighmentInfo.pyramidsInfo[e]}:null}_getRequestOptionsWithSliceId(e){var t;return null!=(t=e.multidimensionalDefinition)&&t.length&&n(this.rasterInfo.multidimensionalInfo)&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)||0}),e}};e([f()],W.prototype,"_rasterTileAlighmentInfo",void 0),e([f(d)],W.prototype,"url",null),e([f({type:String,json:{write:!0}})],W.prototype,"datasetName",void 0),e([f({type:String,json:{write:!0}})],W.prototype,"datasetFormat",void 0),e([f()],W.prototype,"rasterInfo",void 0),e([f()],W.prototype,"ioConfig",void 0),e([f()],W.prototype,"sourceJSON",void 0),W=e([m("esri.layers.support.rasterDatasets.BaseRaster")],W);var A=W;export{A as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.21.0-next.20210916",
3
+ "version": "4.21.0",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS API for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.21/esri/copyright.txt for details.
4
4
  */
5
- const c="20210916",d="7e6e1e4086272cbd3b40749349f028d8d15fcdc7";export{c as buildDate,d as commitHash};
5
+ const e="20210922",f="aef4166d070e919476e6cf2284f60caf022ae200";export{e as buildDate,f as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.21/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../AggregateGraphic.js";import"../../../geometry.js";import i from"../../../Graphic.js";import{flatten as r}from"../../../core/arrayUtils.js";import s from"../../../core/Collection.js";import a from"../../../core/Error.js";import n from"../../../core/has.js";import{clone as l}from"../../../core/lang.js";import o from"../../../core/Logger.js";import{andThen as h,unwrapOr as u,isSome as d,isNone as p}from"../../../core/maybe.js";import{debounce as c,eachAlwaysValues as f,isAbortError as y,after as g}from"../../../core/promiseUtils.js";import{init as m,whenFalseOnce as _}from"../../../core/watchUtils.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as b}from"../../../core/accessorSupport/decorators/subclass.js";import R from"../../../layers/effects/EffectList.js";import{calculateTolerance as x}from"../../../renderers/support/clickToleranceUtils.js";import w from"../../../rest/support/FeatureSet.js";import S from"../../../rest/support/Query.js";import{MAX_FILTERS as F}from"../engine/webgl/definitions.js";import{LayerView2DMixin as U}from"./LayerView2D.js";import{createSchema as I}from"./features/schemaUtils.js";import{createOrReuseTileRenderer as O}from"./features/tileRenderers.js";import{computePxBuffer as E}from"./features/support/pixelBuffering.js";import{findSizeVV as T,createClusterCountSizeVariable as C,isClusterCompatibleRenderer as j,createClusterRenderer as q}from"./support/clusterUtils.js";import P from"./support/FeatureCommandQueue.js";import V from"./support/FeatureLayerProxy.js";import{toJSONGeometryType as L}from"./support/util.js";import{TileManager as N}from"../tiling/TileManager.js";import{FeatureLayerView as H}from"../../layers/FeatureLayerView.js";import k from"../../layers/LayerView.js";import{RefreshableLayerView as J}from"../../layers/RefreshableLayerView.js";import z from"../../layers/support/FeatureFilter.js";import A from"../../layers/support/FeatureEffect.js";import{createQueryGeometry as $}from"../../support/drapedUtils.js";import B from"../../webgl/capabilities.js";import M from"../../../geometry/Extent.js";const Q=2147483648,G=1,D=e=>(e&Q)>>>31===G;function K(e){return e&&"openPorts"in e}const W=o.getLogger("esri.views.2d.layers.FeatureLayerView2D");let X=class extends(H(J(U(k)))){constructor(){super(...arguments),this._pipelineIsUpdating=!0,this._commandsQueue=new P({process:e=>{switch(e.type){case"processed-edit":return this._doEdit(e);case"refresh":return this._doRefresh();case"update":return this._doUpdate()}}}),this._visibilityOverrides=new Set,this._effect=null,this._highlightIds=new Map,this._lastPixelBuffer=0,this._updateHighlight=c((async()=>this._proxy.setHighlight(Array.from(this._highlightIds.keys())))),this._uploadsLocked=!1,this._needsClusterSizeUpdate=!1,this.filter=null,this.effectLists={included:new R,excluded:new R}}destroy(){var e,t;h(this._updateClusterSizeTask,(e=>e.remove())),null==(e=this._proxy)||e.destroy(),null==(t=this.tileRenderer)||t.destroy(),this._commandsQueue.destroy()}initialize(){this.addResolvingPromise(Promise.all([this._initProxy(),this._initServiceOptions()])),this.handles.add([this.on("valueRangesChanged",(e=>{this._set("_aggregateValueRanges",e.valueRanges)})),m(this,"effect",(e=>{this.effectLists.included.effect=null==e?void 0:e.includedEffect})),m(this,"effect",(e=>{this.effectLists.excluded.effect=null==e?void 0:e.excludedEffect}))])}async _initProxy(){if("isTable"in this.layer&&this.layer.isTable)throw new a("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:this.layer});this._proxy&&this._proxy.destroy();const e=this._createClientOptions();return this._set("_proxy",new V({client:e})),this._proxy.when()}async _initServiceOptions(){this._set("_serviceOptions",await this._createServiceOptions())}get orderByFields(){return"stream"!==this._serviceOptions.type&&this._serviceOptions.orderByFields}get labelsVisible(){const e="subtype-group"===this.layer.type?this.layer.sublayers.items:[this.layer];return!this.suspended&&e.some((e=>e.labelingInfo&&e.labelsVisible))}get effect(){return u(this._effect,null)}set effect(e){const t=this._effect;d(t)&&d(t.filter)&&t.filter.enabled&&d(e)&&d(e.filter)&&e.filter.enable(),this._effect=e,this.notifyChange("effect")}get effects(){return this.effect&&[this.effect]||[]}get queryMode(){return this._serviceOptions.type}get renderingConfigHash(){if(!this.layer)return null;const e=this.availableFields,t=this.layer,i=this.view.floors,{definitionExpression:r}=t,s="subtype-group"!==this.layer.type&&this.layer.labelsVisible&&this.layer.labelingInfo,a="renderer"in t&&t.renderer,n="feature"===t.type?t.gdbVersion:void 0,l="feature"===t.type&&t.historicMoment?t.historicMoment.getTime():void 0,{timeExtent:o}=this,h="stream"===t.type?`${JSON.stringify(t.geometryDefinition)}${t.definitionExpression}`:null,u=JSON.stringify(this.clips),p=t.featureReduction&&t.featureReduction.toJSON(),c="orderBy"in this.layer&&JSON.stringify(this.layer.orderBy),f="sublayers"in this.layer&&this.layer.sublayers.items.reduce(((e,t)=>e+`${t.visible?1:0}.${JSON.stringify(t.renderer)}.${t.labelsVisible}\n.${JSON.stringify(t.labelingInfo)}`),"");return JSON.stringify({orderBy:c,sublayerHash:f,filterHash:d(this.filter)&&this.filter.toJSON(),effectHash:d(this.effect)&&this.effect.toJSON(),streamFilter:h,gdbVersion:n,definitionExpression:r,historicMoment:l,availableFields:e,renderer:a,labelingInfo:s,timeExtent:o,floors:i,clipsHash:u,featureReduction:p})}get hasEffects(){return this.effectLists.included.hasEffects||this.effectLists.excluded.hasEffects}highlight(e){let t;return e instanceof i?t=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?t=[e]:s.isCollection(e)?t=e.map((e=>e&&e.getAttribute(this.layer.objectIdField))).toArray():Array.isArray(e)&&e.length>0&&(t="number"==typeof e[0]||"string"==typeof e[0]?e:e.map((e=>e&&e.getAttribute(this.layer.objectIdField)))),t&&t.length?(t=t.filter((e=>null!=e)),this._addHighlight(t),{remove:()=>this._removeHighlight(t)}):{remove:()=>{}}}hasHighlight(){return!!this._highlightIds.size}hitTest(e,t){return this._hitTest(e,t)}async queryAggregates(){return(await this._proxy.getAggregates()).map((e=>t.fromJSON(e)))}queryStatistics(){return this._proxy.queryStatistics()}async querySummaryStatistics(e,t,i){const r={...t};var s;t.valueExpression&&(r.viewInfoParams={viewingMode:"map",scale:this.view.scale,spatialReference:null==(s=this.view.spatialReference)?void 0:s.toJSON()});return this._proxy.querySummaryStatistics(this._cleanUpQuery(e),r,i)}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=w.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}queryFeaturesJSON(e,t){return this._proxy.queryFeatures(this._cleanUpQuery(e),t)}queryObjectIds(e,t){return this._proxy.queryObjectIds(this._cleanUpQuery(e),t)}queryFeatureCount(e,t){return this._proxy.queryFeatureCount(this._cleanUpQuery(e),t)}queryExtent(e,t){return this._proxy.queryExtent(this._cleanUpQuery(e),t).then((e=>({count:e.count,extent:M.fromJSON(e.extent)})))}setVisibility(e,t){t?this._visibilityOverrides.delete(e):this._visibilityOverrides.add(e),this._update()}update(e){if(!this._tileStrategy||!this.tileRenderer)return;const{hasMissingTiles:t,added:i,removed:r}=this._tileStrategy.update(e);(i.length||r.length)&&this._proxy.updateTiles({added:i,removed:r}),t&&this.requestUpdate(),this.notifyChange("updating")}attach(){this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._tileStrategy=new N({acquireTile:e=>this._acquireTile(e),releaseTile:e=>this._releaseTile(e),tileInfoView:this.view.featuresTilingScheme,buffer:0}),this.handles.add(m(this,"renderingConfigHash",(()=>this._update())),"attach"),"stream"!==this.layer.type&&this.handles.add(this.layer.on("edits",(e=>this._edit(e))),"attach")}detach(){this.container.removeAllChildren(),this.handles.remove("attach"),this.tileRenderer&&(this.tileRenderer.uninstall(this.container),this.tileRenderer=null),this._tileStrategy&&(this._tileStrategy.destroy(),this._tileStrategy=null),this._tileRendererHash=null}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}async fetchPopupFeatures(e,i){if(d(i)&&i.clientGraphics.length){const e=i.clientGraphics[0];if(e instanceof t)return[e];i.clientGraphics=i.clientGraphics.filter((e=>{const{layer:t}=e,i="popupEnabled"in t&&t.popupEnabled,r="popupTemplate"in t&&t.popupTemplate,s=this.view.popup.defaultPopupTemplateEnabled;return i&&(r||s)}))}const s=this.validateFetchPopupFeatures(i);if(s)throw s;if(d(i)&&0===i.clientGraphics.length)return[];const a=this.fetchClientPopupFeatures(i);if(!e)return a;const n=this._fetchServicePopupFeatures(e,i);return f([a,n]).then(r)}async _fetchServicePopupFeatures(e,t){if("stream"===this.layer.type||"ogc-feature"===this.layer.type)return[];const i=await this.createPopupQuery(t),{layer:r}=this,s="renderer"in r&&r.renderer,a=d(t)?t.event:null,n=x({renderer:s,event:a});i.geometry=this.createFetchPopupFeaturesQueryGeometry(e,n);const l=new Set,{objectIdField:o}=r,h=d(t)?t.clientGraphics:null;if(h)for(const u of h)l.add(u.attributes[o]);return r.queryFeatures(i).then((e=>e.features.filter((e=>!l.has(e.attributes[o])))))}createFetchPopupFeaturesQueryGeometry(e,t){return $(e,t,this.view)}isUpdating(){var e;const t="renderer"in this.layer&&null!=this.layer.renderer,i=this._commandsQueue.updating,r=null!=this._updatingRequiredFieldsPromise,s=!this._proxy||!this._proxy.isReady,a=this._pipelineIsUpdating,l=null===this.tileRenderer||(null==(e=this.tileRenderer)?void 0:e.updating),o=t&&(i||r||s||a||l);return n("esri-2d-log-updating")&&console.log(`Updating FLV2D: ${o}\n -> hasRenderer ${t}\n -> hasPendingCommand ${i}\n -> updatingRequiredFields ${r}\n -> updatingProxy ${s}\n -> updatingPipeline ${a}\n -> updatingTileRenderer ${l}\n`),o}_createClientOptions(){return{setUpdating:e=>{this._set("_pipelineIsUpdating",e)},emitEvent:e=>{this.emit(e.name,e.event)}}}async _detectQueryMode(e){if("path"in e&&("feature"===this.layer.type||"subtype-group"===this.layer.type)&&"point"===this.layer.geometryType&&this.layer.capabilities.query.supportsPagination&&!this.layer.capabilities.operations.supportsEditing&&n("featurelayer-snapshot-enabled"))try{const e=await this.layer.queryFeatureCount();if(e<=n("featurelayer-snapshot-point-min-threshold"))return{mode:"snapshot",featureCount:e};const t=n("featurelayer-snapshot-point-max-threshold"),i=n("featurelayer-snapshot-point-coverage"),r=this.view.extent,s=this.layer.fullExtent,a=null==s?void 0:s.clone().intersection(r),l=d(a)?a.width*a.height:0,o=(null==s?void 0:s.width)*(null==s?void 0:s.height),h=0===o?0:l/o;if(e<=t&&h>=i)return{mode:"snapshot",featureCount:e}}catch(t){W.warn("mapview-feature-layer","Encountered an error when querying for featureCount",{error:t})}return{mode:"on-demand"}}async _createServiceOptions(){var e;const t=this.layer;if("stream"===t.type)return null;const{capabilities:i,objectIdField:r}=t,s=t.fields.map((e=>e.toJSON())),a=t.fullExtent&&t.fullExtent.toJSON(),n=L(t.geometryType),o=t.timeInfo&&t.timeInfo.toJSON()||null,h=t.spatialReference?t.spatialReference.toJSON():null,u={..."customParameters"in t?t.customParameters:void 0,token:"apiKey"in t?t.apiKey:void 0},p="feature"===t.type?t.globalIdField:null;let c;"ogc-feature"===t.type?c=t.source.getFeatureDefinition():K(t.source)?c=await t.source.openPorts():t.parsedUrl&&(c=l(t.parsedUrl),"dynamicDataSource"in t&&t.dynamicDataSource&&(c.query={layer:JSON.stringify({source:t.dynamicDataSource})}));const f="datesInUnknownTimezone"in this.layer&&this.layer.datesInUnknownTimezone,y=null!=(e="subtypeField"in this.layer&&this.layer.subtypeField)?e:null,{mode:g,featureCount:m}=await this._detectQueryMode(c);let _=this.layer.objectIdField;if("feature"===this.layer.type&&d(this.layer.orderBy)&&this.layer.orderBy.length){const e=!this.layer.orderBy[0].valueExpression&&this.layer.orderBy[0].field;e&&(_=e)}return{type:g,timeReferenceUnknownClient:f,subtypeField:y,featureCount:m,globalIdField:p,maxRecordCount:i.query.maxRecordCount,tileMaxRecordCount:i.query.tileMaxRecordCount,capabilities:i,fields:s,fullExtent:a,geometryType:n,objectIdField:r,source:c,timeInfo:o,spatialReference:h,customParameters:u,orderByFields:_}}async _createMemoryServiceOptions(e){const t=await e.openPorts();return{...this._createServiceOptions(),type:"memory",source:t}}_cleanUpQuery(e){const t=S.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(e){if(this._validateEdit(e))return this._commandsQueue.push({type:"edit",edits:e})}async doRefresh(){return this._commandsQueue.push({type:"refresh"})}_validateEdit(e){const t="globalIdField"in this.layer&&this.layer.globalIdField,i=e.deletedFeatures.some((e=>-1===e.objectId||!e.objectId)),r=t&&this.availableFields.includes(t);return i&&!r?(W.error(new a("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected on the map`)),null):e}async _doUpdate(){try{if(this.destroyed||!this._hasRequiredSupport(this.layer)||!this._tileStrategy)return;const{effect:t,filter:i}=this;await this._updateRequiredFields();const{renderer:r}=this._getEffectiveRenderer();this._set("_effectiveRenderer",r);const s=this._createSchemaConfig(),a=L(this.layer.geometryType),n=await E(r,a,this.layer.featureReduction),l=this._createConfiguration(s,i,t);this._lastPixelBuffer=0===n?0:Math.max(n,this._lastPixelBuffer),l.schema.source.pixelBuffer=this._lastPixelBuffer;const o=this._createTileRendererHash(r);if(o!==this._tileRendererHash){await this._initTileRenderer(r);const e=this._serviceOptions;this.effects.forEach((e=>d(e)&&d(e.filter)&&e.filter.enable())),this.tileRenderer.onConfigUpdate(r);const t={added:this._tileStrategy.tileKeys(),removed:[]},i=this.layer;"stream"!==i.type&&K(i.source)&&(e.source=await i.source.openPorts()),"stream"===i.type&&await this._initServiceOptions(),await this._proxy.startup(this.view.featuresTilingScheme,l,e,t),this.hasHighlight()&&await this._proxy.setHighlight(Array.from(this._highlightIds.keys())),await this._onceTilesUpdated(),this.tileRenderer.onConfigUpdate(r)}else{const t=await this._proxy.update(l);(t.mesh||t.targets.aggregate)&&this._lockGPUUploads();try{await this._proxy.applyUpdate(t)}catch(e){y(e)||W.error(e)}(t.mesh||t.targets.aggregate)&&this._unlockGPUUploads(),this.effects.forEach((e=>d(e)&&d(e.filter)&&e.filter.enable())),this.tileRenderer.onConfigUpdate(r),this._updateClusterSizeVariable(),this._forceAttributeTextureUpload()}this._tileRendererHash=o,this.tileRenderer.invalidateLabels(),this.requestUpdate()}catch(e){}}async _doEdit(e){try{await this._proxy.onEdits(e)}catch(t){y(t),0}}async _doRefresh(){this._lockGPUUploads();try{await this._proxy.refresh()}catch(e){y(e),0}this._unlockGPUUploads()}_updateClusterSizeVariable(){this._needsClusterSizeUpdate&&(this.tileRenderer.onConfigUpdate(this._effectiveRenderer),this._needsClusterSizeUpdate=!1)}_createUpdateClusterSizeTask(e,t){return this.watch("_aggregateValueRanges",(async i=>{this._updateClusterEffectiveRendererSizeVariable(e,t,i),this._needsClusterSizeUpdate=!0,this._uploadsLocked||this._updateClusterSizeVariable()}))}async _updateClusterEffectiveRendererSizeVariable(e,t,i){if(e.dynamicClusterSize&&"visualVariables"in e&&e.visualVariables){const r=T(e.visualVariables);if(d(r)&&"cluster_count"===r.field){const s=e.visualVariables.indexOf(r);e.visualVariables[s]=C(t,i);const a=e.clone();a.dynamicClusterSize=!0,this._set("_effectiveRenderer",a)}}}_getEffectiveRenderer(){const e="renderer"in this.layer&&this.layer.renderer,t=this.layer.featureReduction;if(d(this._updateClusterSizeTask)&&(this._updateClusterSizeTask.remove(),this._updateClusterSizeTask=null),t&&"cluster"===t.type&&j(e)){const i=t,r=[],s=q(r,e,i,this._aggregateValueRanges);return h(this._updateClusterSizeTask,(e=>e.remove())),this._updateClusterSizeTask=this._createUpdateClusterSizeTask(s,i),{renderer:s,aggregateFields:r,featureReduction:t}}return{renderer:e,aggregateFields:[],featureReduction:null}}_acquireTile(e){const t=this.tileRenderer.acquireTile(e);return t.once("attach",(()=>{this.requestUpdate()})),t}_releaseTile(e){this.tileRenderer.releaseTile(e)}async _initTileRenderer(e){const t=await O(e,{layerView:this,tileInfoView:this.view.featuresTilingScheme,layer:this.layer});return this.tileRenderer&&(this._tileStrategy.clear(),this.tileRenderer.uninstall(this.container),this.tileRenderer.destroy(),this.tileRenderer=null),this.destroyed?null:(this._proxy.tileRenderer=t,this._set("tileRenderer",t),this.tileRenderer.install(this.container),this.tileRenderer.onConfigUpdate(e),this.requestUpdate(),this.tileRenderer)}_createTileRendererHash(e){return`${"heatmap"===e.type?"heatmap":"symbol"}.${"dot-density"===e.type}`}_createFeatureDataHash(e,t,i){const r=e.getAttributeHash(),s=JSON.stringify(t),a=d(i)&&JSON.stringify(i.filter),n=JSON.stringify(this.timeExtent);let l="";return this._visibilityOverrides.forEach((e=>l+=e)),`${r}.${s}.${a}.${n}.${l}`}get hasFilter(){const e=!!("floorInfo"in this.layer&&this.layer.floorInfo&&this.view.floors&&this.view.floors.length);return!!this.filter||e||!!this._visibilityOverrides.size||!!this.timeExtent}_injectOverrides(e){const t=d(e)?e.timeExtent:null,i=d(this.timeExtent)&&d(t)?this.timeExtent.intersection(t):this.timeExtent||t;let r=null;const s="floorInfo"in this.layer&&this.layer.floorInfo;if(s){const t=d(e)&&e.where;r=this._addFloorFilterClause(t)}if(!this._visibilityOverrides.size&&!i&&!s)return e;const a=d(e)&&e.clone()||new z;return a.hiddenIds=this._visibilityOverrides,a.timeExtent=i,r&&(a.where=r),a}_addFloorFilterClause(e){const t=this.layer;let i=e||"";if("floorInfo"in t&&t.floorInfo){var r;let e=this.view.floors;if(!e||!e.length)return i;null!=(r=t.floorInfo.viewAllLevelIds)&&r.length&&(e=t.floorInfo.viewAllLevelIds);const s=e.filter((e=>""!==e)).map((e=>"'"+e+"'"));s.push("''");const a=t.floorInfo.floorField;let n="("+a+" IN ({ids}) OR "+a+" IS NULL)";if(n=n.replace("{ids}",s.join(", ")),d(i)&&i.includes(a)){let e=new RegExp("AND \\("+a+".*NULL\\)","g");i=i.replace(e,""),e=new RegExp("\\("+a+".*NULL\\)","g"),i=i.replace(e,""),i=i.replace(/\s+/g," ").trim()}i=""!==i?"("+i+") AND "+n:n}return""!==i?i:null}_createConfiguration(e,t,i){const r="feature"===this.layer.type&&this.layer.historicMoment?this.layer.historicMoment.getTime():void 0,s="feature"===this.layer.type?this.layer.gdbVersion:void 0,a=new Array(F),n=this._injectOverrides(t);a[0]=d(n)?n.toJSON():null,a[1]=d(i)&&i.filter?i.filter.toJSON():null;const l=I(e);if(p(l))return null;const o=B();return{definitionExpression:this.layer.definitionExpression,availableFields:this.availableFields,gdbVersion:s,historicMoment:r,devicePixelRatio:window.devicePixelRatio||1,filters:a,schema:l,supportsTextureFloat:o.supportsTextureFloat,maxTextureSize:o.maxTextureSize}}_hasRequiredSupport(e){var t;return!("renderer"in e&&"dot-density"===(null==(t=e.renderer)?void 0:t.type)&&!B().supportsTextureFloat)||(W.error(new a("webgl-missing-extension","Missing WebGL extension OES_Texture_Float which is required for DotDensity")),!1)}_onceTilesUpdated(){return this.requestUpdate(),_(this,"_pipelineIsUpdating",!1)}_lockGPUUploads(){this.tileRenderer&&(this._uploadsLocked=!0,this.tileRenderer.lockGPUUploads())}_unlockGPUUploads(){this.tileRenderer&&(this._uploadsLocked=!1,this.tileRenderer.unlockGPUUploads())}_forceAttributeTextureUpload(){this.tileRenderer&&this.tileRenderer.forceAttributeTextureUpload()}_createSchemaConfig(){const e="feature"===this.layer.type?this.layer.historicMoment:null,t="feature"===this.layer.type?this.layer.gdbVersion:null;return{renderer:"renderer"in this.layer&&this.layer.renderer,spatialReference:this.layer.spatialReference,timeExtent:this.layer.timeExtent,definitionExpression:this.layer.definitionExpression,featureReduction:this.layer.featureReduction,fields:this.layer.fields,geometryType:this.layer.geometryType,historicMoment:e,labelsVisible:"labelsVisible"in this.layer&&this.layer.labelsVisible,labelingInfo:"labelingInfo"in this.layer&&this.layer.labelingInfo,availableFields:this.availableFields,effect:this.effect,filter:this.filter,gdbVersion:t,pixelBuffer:0,orderBy:"orderBy"in this.layer&&this.layer.orderBy?this.layer.orderBy:null}}_addHighlight(e){for(const t of e)if(this._highlightIds.has(t)){const e=this._highlightIds.get(t);this._highlightIds.set(t,e+1)}else this._highlightIds.set(t,1);this._updateHighlight().catch((e=>{y(e)||W.error(e)}))}_removeHighlight(e){for(const t of e)if(this._highlightIds.has(t)){const e=this._highlightIds.get(t)-1;0===e?this._highlightIds.delete(t):this._highlightIds.set(t,e)}this._updateHighlight().catch((e=>{y(e)||W.error(e)}))}_setLayersForFeature(e){const t=this.layer;e.layer=t,e.sourceLayer=t}_createHittestResult(e){return this._setLayersForFeature(e),d(e.geometry)&&(e.geometry.spatialReference=this.view.spatialReference),e}async _hitTest(e,r){if(this.suspended||!this.tileRenderer)return null;const s=await this.tileRenderer.hitTest(e,r);if(0===s.length)return await g(1),null;const a=s[0];if(!D(a)){const e=await this._proxy.getFeature(a);return h(e,(e=>this._createHittestResult(i.fromJSON(e))))}const n=await this._proxy.getAggregate(a);if(p(n))return null;if(d(n.referenceId)){const e=await this._proxy.getFeature(n.referenceId);return h(e,(e=>this._createHittestResult(i.fromJSON(e))))}return this._createHittestResult(t.fromJSON(n))}};e([v()],X.prototype,"_serviceOptions",void 0),e([v()],X.prototype,"_proxy",void 0),e([v()],X.prototype,"_pipelineIsUpdating",void 0),e([v()],X.prototype,"_effectiveRenderer",void 0),e([v()],X.prototype,"_aggregateValueRanges",void 0),e([v()],X.prototype,"_commandsQueue",void 0),e([v()],X.prototype,"labelsVisible",null),e([v({type:z})],X.prototype,"filter",void 0),e([v({type:A})],X.prototype,"effect",null),e([v({readOnly:!0})],X.prototype,"effects",null),e([v({readOnly:!0})],X.prototype,"queryMode",null),e([v()],X.prototype,"renderingConfigHash",null),e([v()],X.prototype,"tileRenderer",void 0),e([v()],X.prototype,"updating",void 0),X=e([b("esri.views.2d.layers.FeatureLayerView2D")],X);var Y=X;export{Y as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../AggregateGraphic.js";import"../../../geometry.js";import i from"../../../Graphic.js";import{flatten as r}from"../../../core/arrayUtils.js";import s from"../../../core/Collection.js";import a from"../../../core/Error.js";import n from"../../../core/has.js";import{clone as l}from"../../../core/lang.js";import o from"../../../core/Logger.js";import{andThen as h,unwrapOr as u,isSome as d,isNone as p}from"../../../core/maybe.js";import{debounce as c,eachAlwaysValues as y,isAbortError as f,after as g}from"../../../core/promiseUtils.js";import{init as m,whenFalseOnce as _}from"../../../core/watchUtils.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as b}from"../../../core/accessorSupport/decorators/subclass.js";import R from"../../../layers/effects/EffectList.js";import{calculateTolerance as x}from"../../../renderers/support/clickToleranceUtils.js";import w from"../../../rest/support/FeatureSet.js";import S from"../../../rest/support/Query.js";import{MAX_FILTERS as F}from"../engine/webgl/definitions.js";import{LayerView2DMixin as U}from"./LayerView2D.js";import{createSchema as I}from"./features/schemaUtils.js";import{createOrReuseTileRenderer as O}from"./features/tileRenderers.js";import{computePxBuffer as E}from"./features/support/pixelBuffering.js";import{findSizeVV as T,createClusterCountSizeVariable as C,isClusterCompatibleRenderer as j,createClusterRenderer as P}from"./support/clusterUtils.js";import q from"./support/FeatureCommandQueue.js";import V from"./support/FeatureLayerProxy.js";import{toJSONGeometryType as L}from"./support/util.js";import{TileManager as N}from"../tiling/TileManager.js";import{FeatureLayerView as H}from"../../layers/FeatureLayerView.js";import J from"../../layers/LayerView.js";import{RefreshableLayerView as k}from"../../layers/RefreshableLayerView.js";import z from"../../layers/support/FeatureFilter.js";import A from"../../layers/support/FeatureEffect.js";import{createQueryGeometry as $}from"../../support/drapedUtils.js";import B from"../../webgl/capabilities.js";import M from"../../../geometry/Extent.js";const Q=2147483648,G=1,D=e=>(e&Q)>>>31===G;function K(e){return e&&"openPorts"in e}const W=o.getLogger("esri.views.2d.layers.FeatureLayerView2D");let X=class extends(H(k(U(J)))){constructor(){super(...arguments),this._pipelineIsUpdating=!0,this._commandsQueue=new q({process:e=>{switch(e.type){case"processed-edit":return this._doEdit(e);case"refresh":return this._doRefresh();case"update":return this._doUpdate()}}}),this._visibilityOverrides=new Set,this._effect=null,this._highlightIds=new Map,this._lastPixelBuffer=0,this._updateHighlight=c((async()=>this._proxy.setHighlight(Array.from(this._highlightIds.keys())))),this._uploadsLocked=!1,this._needsClusterSizeUpdate=!1,this.filter=null,this.effectLists={included:new R,excluded:new R}}destroy(){var e,t;h(this._updateClusterSizeTask,(e=>e.remove())),null==(e=this._proxy)||e.destroy(),null==(t=this.tileRenderer)||t.destroy(),this._commandsQueue.destroy()}initialize(){this.addResolvingPromise(Promise.all([this._initProxy(),this._initServiceOptions()])),this.handles.add([this.on("valueRangesChanged",(e=>{this._set("_aggregateValueRanges",e.valueRanges)})),m(this,"effect",(e=>{this.effectLists.included.effect=null==e?void 0:e.includedEffect})),m(this,"effect",(e=>{this.effectLists.excluded.effect=null==e?void 0:e.excludedEffect}))])}async _initProxy(){if("isTable"in this.layer&&this.layer.isTable)throw new a("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:this.layer});this._proxy&&this._proxy.destroy();const e=this._createClientOptions();return this._set("_proxy",new V({client:e})),this._proxy.when()}async _initServiceOptions(){this._set("_serviceOptions",await this._createServiceOptions())}get orderByFields(){return"stream"!==this._serviceOptions.type&&this._serviceOptions.orderByFields}get labelsVisible(){const e="subtype-group"===this.layer.type?this.layer.sublayers.items:[this.layer];return!this.suspended&&e.some((e=>e.labelingInfo&&e.labelsVisible))}get effect(){return u(this._effect,null)}set effect(e){const t=this._effect;d(t)&&d(t.filter)&&t.filter.enabled&&d(e)&&d(e.filter)&&e.filter.enable(),this._effect=e,this.notifyChange("effect")}get effects(){return this.effect&&[this.effect]||[]}get queryMode(){return this._serviceOptions.type}get renderingConfigHash(){if(!this.layer)return null;const e=this.availableFields,t=this.layer,i=this.view.floors,{definitionExpression:r}=t,s="subtype-group"!==this.layer.type&&this.layer.labelsVisible&&this.layer.labelingInfo,a="renderer"in t&&t.renderer,n="feature"===t.type?t.gdbVersion:void 0,l="feature"===t.type&&t.historicMoment?t.historicMoment.getTime():void 0,{timeExtent:o}=this,h="customParameters"in t?JSON.stringify(t.customParameters):void 0,u="apiKey"in t?t.apiKey:void 0,p="stream"===t.type?`${JSON.stringify(t.geometryDefinition)}${t.definitionExpression}`:null,c=JSON.stringify(this.clips),y=t.featureReduction&&t.featureReduction.toJSON(),f="orderBy"in this.layer&&JSON.stringify(this.layer.orderBy),g="sublayers"in this.layer&&this.layer.sublayers.items.reduce(((e,t)=>e+`${t.visible?1:0}.${JSON.stringify(t.renderer)}.${t.labelsVisible}\n.${JSON.stringify(t.labelingInfo)}`),"");return JSON.stringify({orderBy:f,sublayerHash:g,filterHash:d(this.filter)&&this.filter.toJSON(),effectHash:d(this.effect)&&this.effect.toJSON(),streamFilter:p,gdbVersion:n,definitionExpression:r,historicMoment:l,availableFields:e,renderer:a,labelingInfo:s,timeExtent:o,floors:i,clipsHash:c,featureReduction:y,customParameters:h,apiKey:u})}get hasEffects(){return this.effectLists.included.hasEffects||this.effectLists.excluded.hasEffects}highlight(e){let t;return e instanceof i?t=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?t=[e]:s.isCollection(e)?t=e.map((e=>e&&e.getAttribute(this.layer.objectIdField))).toArray():Array.isArray(e)&&e.length>0&&(t="number"==typeof e[0]||"string"==typeof e[0]?e:e.map((e=>e&&e.getAttribute(this.layer.objectIdField)))),t&&t.length?(t=t.filter((e=>null!=e)),this._addHighlight(t),{remove:()=>this._removeHighlight(t)}):{remove:()=>{}}}hasHighlight(){return!!this._highlightIds.size}hitTest(e,t){return this._hitTest(e,t)}async queryAggregates(){return(await this._proxy.getAggregates()).map((e=>t.fromJSON(e)))}queryStatistics(){return this._proxy.queryStatistics()}async querySummaryStatistics(e,t,i){const r={...t};var s;t.valueExpression&&(r.viewInfoParams={viewingMode:"map",scale:this.view.scale,spatialReference:null==(s=this.view.spatialReference)?void 0:s.toJSON()});return this._proxy.querySummaryStatistics(this._cleanUpQuery(e),r,i)}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=w.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}queryFeaturesJSON(e,t){return this._proxy.queryFeatures(this._cleanUpQuery(e),t)}queryObjectIds(e,t){return this._proxy.queryObjectIds(this._cleanUpQuery(e),t)}queryFeatureCount(e,t){return this._proxy.queryFeatureCount(this._cleanUpQuery(e),t)}queryExtent(e,t){return this._proxy.queryExtent(this._cleanUpQuery(e),t).then((e=>({count:e.count,extent:M.fromJSON(e.extent)})))}setVisibility(e,t){t?this._visibilityOverrides.delete(e):this._visibilityOverrides.add(e),this._update()}update(e){if(!this._tileStrategy||!this.tileRenderer)return;const{hasMissingTiles:t,added:i,removed:r}=this._tileStrategy.update(e);(i.length||r.length)&&this._proxy.updateTiles({added:i,removed:r}),t&&this.requestUpdate(),this.notifyChange("updating")}attach(){this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._tileStrategy=new N({acquireTile:e=>this._acquireTile(e),releaseTile:e=>this._releaseTile(e),tileInfoView:this.view.featuresTilingScheme,buffer:0}),this.handles.add(m(this,"renderingConfigHash",(()=>this._update())),"attach"),"stream"!==this.layer.type&&this.handles.add(this.layer.on("edits",(e=>this._edit(e))),"attach")}detach(){this.container.removeAllChildren(),this.handles.remove("attach"),this.tileRenderer&&(this.tileRenderer.uninstall(this.container),this.tileRenderer=null),this._tileStrategy&&(this._tileStrategy.destroy(),this._tileStrategy=null),this._tileRendererHash=null}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}async fetchPopupFeatures(e,i){if(d(i)&&i.clientGraphics.length){const e=i.clientGraphics[0];if(e instanceof t)return[e];i.clientGraphics=i.clientGraphics.filter((e=>{const{layer:t}=e,i="popupEnabled"in t&&t.popupEnabled,r="popupTemplate"in t&&t.popupTemplate,s=this.view.popup.defaultPopupTemplateEnabled;return i&&(r||s)}))}const s=this.validateFetchPopupFeatures(i);if(s)throw s;if(d(i)&&0===i.clientGraphics.length)return[];const a=this.fetchClientPopupFeatures(i);if(!e)return a;const n=this._fetchServicePopupFeatures(e,i);return y([a,n]).then(r)}async _fetchServicePopupFeatures(e,t){if("stream"===this.layer.type||"ogc-feature"===this.layer.type)return[];const i=await this.createPopupQuery(t),{layer:r}=this,s="renderer"in r&&r.renderer,a=d(t)?t.event:null,n=x({renderer:s,event:a});i.geometry=this.createFetchPopupFeaturesQueryGeometry(e,n);const l=new Set,{objectIdField:o}=r,h=d(t)?t.clientGraphics:null;if(h)for(const u of h)l.add(u.attributes[o]);return r.queryFeatures(i).then((e=>e.features.filter((e=>!l.has(e.attributes[o])))))}createFetchPopupFeaturesQueryGeometry(e,t){return $(e,t,this.view)}isUpdating(){var e;const t="renderer"in this.layer&&null!=this.layer.renderer,i=this._commandsQueue.updating,r=null!=this._updatingRequiredFieldsPromise,s=!this._proxy||!this._proxy.isReady,a=this._pipelineIsUpdating,l=null===this.tileRenderer||(null==(e=this.tileRenderer)?void 0:e.updating),o=t&&(i||r||s||a||l);return n("esri-2d-log-updating")&&console.log(`Updating FLV2D: ${o}\n -> hasRenderer ${t}\n -> hasPendingCommand ${i}\n -> updatingRequiredFields ${r}\n -> updatingProxy ${s}\n -> updatingPipeline ${a}\n -> updatingTileRenderer ${l}\n`),o}_createClientOptions(){return{setUpdating:e=>{this._set("_pipelineIsUpdating",e)},emitEvent:e=>{this.emit(e.name,e.event)}}}async _detectQueryMode(e){if("path"in e&&("feature"===this.layer.type||"subtype-group"===this.layer.type)&&"point"===this.layer.geometryType&&this.layer.capabilities.query.supportsPagination&&!this.layer.capabilities.operations.supportsEditing&&n("featurelayer-snapshot-enabled"))try{const e=await this.layer.queryFeatureCount();if(e<=n("featurelayer-snapshot-point-min-threshold"))return{mode:"snapshot",featureCount:e};const t=n("featurelayer-snapshot-point-max-threshold"),i=n("featurelayer-snapshot-point-coverage"),r=this.view.extent,s=this.layer.fullExtent,a=null==s?void 0:s.clone().intersection(r),l=d(a)?a.width*a.height:0,o=(null==s?void 0:s.width)*(null==s?void 0:s.height),h=0===o?0:l/o;if(e<=t&&h>=i)return{mode:"snapshot",featureCount:e}}catch(t){W.warn("mapview-feature-layer","Encountered an error when querying for featureCount",{error:t})}return{mode:"on-demand"}}async _createServiceOptions(){var e;const t=this.layer;if("stream"===t.type)return null;const{capabilities:i,objectIdField:r}=t,s=t.fields.map((e=>e.toJSON())),a=t.fullExtent&&t.fullExtent.toJSON(),n=L(t.geometryType),o=t.timeInfo&&t.timeInfo.toJSON()||null,h=t.spatialReference?t.spatialReference.toJSON():null,u="feature"===t.type?t.globalIdField:null;let p;"ogc-feature"===t.type?p=t.source.getFeatureDefinition():K(t.source)?p=await t.source.openPorts():t.parsedUrl&&(p=l(t.parsedUrl),"dynamicDataSource"in t&&t.dynamicDataSource&&(p.query={layer:JSON.stringify({source:t.dynamicDataSource})}));const c="datesInUnknownTimezone"in this.layer&&this.layer.datesInUnknownTimezone,y=null!=(e="subtypeField"in this.layer&&this.layer.subtypeField)?e:null,{mode:f,featureCount:g}=await this._detectQueryMode(p);let m=this.layer.objectIdField;if("feature"===this.layer.type&&d(this.layer.orderBy)&&this.layer.orderBy.length){const e=!this.layer.orderBy[0].valueExpression&&this.layer.orderBy[0].field;e&&(m=e)}return{type:f,timeReferenceUnknownClient:c,subtypeField:y,featureCount:g,globalIdField:u,maxRecordCount:i.query.maxRecordCount,tileMaxRecordCount:i.query.tileMaxRecordCount,capabilities:i,fields:s,fullExtent:a,geometryType:n,objectIdField:r,source:p,timeInfo:o,spatialReference:h,orderByFields:m}}async _createMemoryServiceOptions(e){const t=await e.openPorts();return{...this._createServiceOptions(),type:"memory",source:t}}_cleanUpQuery(e){const t=S.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(e){if(this._validateEdit(e))return this._commandsQueue.push({type:"edit",edits:e})}async doRefresh(){return this._commandsQueue.push({type:"refresh"})}_validateEdit(e){const t="globalIdField"in this.layer&&this.layer.globalIdField,i=e.deletedFeatures.some((e=>-1===e.objectId||!e.objectId)),r=t&&this.availableFields.includes(t);return i&&!r?(W.error(new a("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected on the map`)),null):e}async _doUpdate(){try{if(this.destroyed||!this._hasRequiredSupport(this.layer)||!this._tileStrategy)return;const{effect:t,filter:i}=this;await this._updateRequiredFields();const{renderer:r}=this._getEffectiveRenderer();this._set("_effectiveRenderer",r);const s=this._createSchemaConfig(),a=L(this.layer.geometryType),n=await E(r,a,this.layer.featureReduction),l=this._createConfiguration(s,i,t);this._lastPixelBuffer=0===n?0:Math.max(n,this._lastPixelBuffer),l.schema.source.pixelBuffer=this._lastPixelBuffer;const o=this._createTileRendererHash(r);if(o!==this._tileRendererHash){await this._initTileRenderer(r);const e=this._serviceOptions;this.effects.forEach((e=>d(e)&&d(e.filter)&&e.filter.enable())),this.tileRenderer.onConfigUpdate(r);const t={added:this._tileStrategy.tileKeys(),removed:[]},i=this.layer;"stream"!==i.type&&K(i.source)&&(e.source=await i.source.openPorts()),"stream"===i.type&&await this._initServiceOptions(),await this._proxy.startup(this.view.featuresTilingScheme,l,e,t),this.hasHighlight()&&await this._proxy.setHighlight(Array.from(this._highlightIds.keys())),await this._onceTilesUpdated(),this.tileRenderer.onConfigUpdate(r)}else{const t=await this._proxy.update(l);(t.mesh||t.targets.aggregate)&&this._lockGPUUploads();try{await this._proxy.applyUpdate(t)}catch(e){f(e)||W.error(e)}(t.mesh||t.targets.aggregate)&&this._unlockGPUUploads(),this.effects.forEach((e=>d(e)&&d(e.filter)&&e.filter.enable())),this.tileRenderer.onConfigUpdate(r),this._updateClusterSizeVariable(),this._forceAttributeTextureUpload()}this._tileRendererHash=o,this.tileRenderer.invalidateLabels(),this.requestUpdate()}catch(e){}}async _doEdit(e){try{await this._proxy.onEdits(e)}catch(t){f(t),0}}async _doRefresh(){this._lockGPUUploads();try{await this._proxy.refresh()}catch(e){f(e),0}this._unlockGPUUploads()}_updateClusterSizeVariable(){this._needsClusterSizeUpdate&&(this.tileRenderer.onConfigUpdate(this._effectiveRenderer),this._needsClusterSizeUpdate=!1)}_createUpdateClusterSizeTask(e,t){return this.watch("_aggregateValueRanges",(async i=>{this._updateClusterEffectiveRendererSizeVariable(e,t,i),this._needsClusterSizeUpdate=!0,this._uploadsLocked||this._updateClusterSizeVariable()}))}async _updateClusterEffectiveRendererSizeVariable(e,t,i){if(e.dynamicClusterSize&&"visualVariables"in e&&e.visualVariables){const r=T(e.visualVariables);if(d(r)&&"cluster_count"===r.field){const s=e.visualVariables.indexOf(r);e.visualVariables[s]=C(t,i);const a=e.clone();a.dynamicClusterSize=!0,this._set("_effectiveRenderer",a)}}}_getEffectiveRenderer(){const e="renderer"in this.layer&&this.layer.renderer,t=this.layer.featureReduction;if(d(this._updateClusterSizeTask)&&(this._updateClusterSizeTask.remove(),this._updateClusterSizeTask=null),t&&"cluster"===t.type&&j(e)){const i=t,r=[],s=P(r,e,i,this._aggregateValueRanges);return h(this._updateClusterSizeTask,(e=>e.remove())),this._updateClusterSizeTask=this._createUpdateClusterSizeTask(s,i),{renderer:s,aggregateFields:r,featureReduction:t}}return{renderer:e,aggregateFields:[],featureReduction:null}}_acquireTile(e){const t=this.tileRenderer.acquireTile(e);return t.once("attach",(()=>{this.requestUpdate()})),t}_releaseTile(e){this.tileRenderer.releaseTile(e)}async _initTileRenderer(e){const t=await O(e,{layerView:this,tileInfoView:this.view.featuresTilingScheme,layer:this.layer});return this.tileRenderer&&(this._tileStrategy.clear(),this.tileRenderer.uninstall(this.container),this.tileRenderer.destroy(),this.tileRenderer=null),this.destroyed?null:(this._proxy.tileRenderer=t,this._set("tileRenderer",t),this.tileRenderer.install(this.container),this.tileRenderer.onConfigUpdate(e),this.requestUpdate(),this.tileRenderer)}_createTileRendererHash(e){return`${"heatmap"===e.type?"heatmap":"symbol"}.${"dot-density"===e.type}`}_createFeatureDataHash(e,t,i){const r=e.getAttributeHash(),s=JSON.stringify(t),a=d(i)&&JSON.stringify(i.filter),n=JSON.stringify(this.timeExtent);let l="";return this._visibilityOverrides.forEach((e=>l+=e)),`${r}.${s}.${a}.${n}.${l}`}get hasFilter(){const e=!!("floorInfo"in this.layer&&this.layer.floorInfo&&this.view.floors&&this.view.floors.length);return!!this.filter||e||!!this._visibilityOverrides.size||!!this.timeExtent}_injectOverrides(e){const t=d(e)?e.timeExtent:null,i=d(this.timeExtent)&&d(t)?this.timeExtent.intersection(t):this.timeExtent||t;let r=null;const s="floorInfo"in this.layer&&this.layer.floorInfo;if(s){const t=d(e)&&e.where;r=this._addFloorFilterClause(t)}if(!this._visibilityOverrides.size&&!i&&!s)return e;const a=d(e)&&e.clone()||new z;return a.hiddenIds=this._visibilityOverrides,a.timeExtent=i,r&&(a.where=r),a}_addFloorFilterClause(e){const t=this.layer;let i=e||"";if("floorInfo"in t&&t.floorInfo){var r;let e=this.view.floors;if(!e||!e.length)return i;null!=(r=t.floorInfo.viewAllLevelIds)&&r.length&&(e=t.floorInfo.viewAllLevelIds);const s=e.filter((e=>""!==e)).map((e=>"'"+e+"'"));s.push("''");const a=t.floorInfo.floorField;let n="("+a+" IN ({ids}) OR "+a+" IS NULL)";if(n=n.replace("{ids}",s.join(", ")),d(i)&&i.includes(a)){let e=new RegExp("AND \\("+a+".*NULL\\)","g");i=i.replace(e,""),e=new RegExp("\\("+a+".*NULL\\)","g"),i=i.replace(e,""),i=i.replace(/\s+/g," ").trim()}i=""!==i?"("+i+") AND "+n:n}return""!==i?i:null}_createConfiguration(e,t,i){const r="feature"===this.layer.type&&this.layer.historicMoment?this.layer.historicMoment.getTime():void 0,s="feature"===this.layer.type?this.layer.gdbVersion:void 0,a=new Array(F),n=this._injectOverrides(t);a[0]=d(n)?n.toJSON():null,a[1]=d(i)&&i.filter?i.filter.toJSON():null;const l=I(e);if(p(l))return null;const o=B();return{definitionExpression:this.layer.definitionExpression,availableFields:this.availableFields,gdbVersion:s,historicMoment:r,devicePixelRatio:window.devicePixelRatio||1,filters:a,schema:l,supportsTextureFloat:o.supportsTextureFloat,maxTextureSize:o.maxTextureSize}}_hasRequiredSupport(e){var t;return!("renderer"in e&&"dot-density"===(null==(t=e.renderer)?void 0:t.type)&&!B().supportsTextureFloat)||(W.error(new a("webgl-missing-extension","Missing WebGL extension OES_Texture_Float which is required for DotDensity")),!1)}_onceTilesUpdated(){return this.requestUpdate(),_(this,"_pipelineIsUpdating",!1)}_lockGPUUploads(){this.tileRenderer&&(this._uploadsLocked=!0,this.tileRenderer.lockGPUUploads())}_unlockGPUUploads(){this.tileRenderer&&(this._uploadsLocked=!1,this.tileRenderer.unlockGPUUploads())}_forceAttributeTextureUpload(){this.tileRenderer&&this.tileRenderer.forceAttributeTextureUpload()}_createSchemaConfig(){const e="feature"===this.layer.type?this.layer.historicMoment:null,t="feature"===this.layer.type?this.layer.gdbVersion:null;return{renderer:"renderer"in this.layer&&this.layer.renderer,spatialReference:this.layer.spatialReference,timeExtent:this.layer.timeExtent,definitionExpression:this.layer.definitionExpression,featureReduction:this.layer.featureReduction,fields:this.layer.fields,geometryType:this.layer.geometryType,historicMoment:e,labelsVisible:"labelsVisible"in this.layer&&this.layer.labelsVisible,labelingInfo:"labelingInfo"in this.layer&&this.layer.labelingInfo,availableFields:this.availableFields,effect:this.effect,filter:this.filter,gdbVersion:t,pixelBuffer:0,orderBy:"orderBy"in this.layer&&this.layer.orderBy?this.layer.orderBy:null,customParameters:{..."customParameters"in this.layer?this.layer.customParameters:void 0,token:"apiKey"in this.layer?this.layer.apiKey:void 0}}}_addHighlight(e){for(const t of e)if(this._highlightIds.has(t)){const e=this._highlightIds.get(t);this._highlightIds.set(t,e+1)}else this._highlightIds.set(t,1);this._updateHighlight().catch((e=>{f(e)||W.error(e)}))}_removeHighlight(e){for(const t of e)if(this._highlightIds.has(t)){const e=this._highlightIds.get(t)-1;0===e?this._highlightIds.delete(t):this._highlightIds.set(t,e)}this._updateHighlight().catch((e=>{f(e)||W.error(e)}))}_setLayersForFeature(e){const t=this.layer;e.layer=t,e.sourceLayer=t}_createHittestResult(e){return this._setLayersForFeature(e),d(e.geometry)&&(e.geometry.spatialReference=this.view.spatialReference),e}async _hitTest(e,r){if(this.suspended||!this.tileRenderer)return null;const s=await this.tileRenderer.hitTest(e,r);if(0===s.length)return await g(1),null;const a=s[0];if(!D(a)){const e=await this._proxy.getFeature(a);return h(e,(e=>this._createHittestResult(i.fromJSON(e))))}const n=await this._proxy.getAggregate(a);if(p(n))return null;if(d(n.referenceId)){const e=await this._proxy.getFeature(n.referenceId);return h(e,(e=>this._createHittestResult(i.fromJSON(e))))}return this._createHittestResult(t.fromJSON(n))}};e([v()],X.prototype,"_serviceOptions",void 0),e([v()],X.prototype,"_proxy",void 0),e([v()],X.prototype,"_pipelineIsUpdating",void 0),e([v()],X.prototype,"_effectiveRenderer",void 0),e([v()],X.prototype,"_aggregateValueRanges",void 0),e([v()],X.prototype,"_commandsQueue",void 0),e([v()],X.prototype,"labelsVisible",null),e([v({type:z})],X.prototype,"filter",void 0),e([v({type:A})],X.prototype,"effect",null),e([v({readOnly:!0})],X.prototype,"effects",null),e([v({readOnly:!0})],X.prototype,"queryMode",null),e([v()],X.prototype,"renderingConfigHash",null),e([v()],X.prototype,"tileRenderer",void 0),e([v()],X.prototype,"updating",void 0),X=e([b("esri.views.2d.layers.FeatureLayerView2D")],X);var Y=X;export{Y as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.21/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../../core/has.js";import{isSome as t,unwrap as r}from"../../../../../../core/maybe.js";import{openWithPorts as s}from"../../../../../../core/workers/workers.js";import{toQuantizationTransform as i}from"../../../../../../geometry/support/quantizationUtils.js";import{convertFromFeatureSet as a,quantizeOptimizedFeatureSet as o}from"../../../../../../layers/graphics/featureConversionUtils.js";import{queryOptimizedFeatureSet as n}from"../../../../../../layers/ogc/ogcFeatureUtils.js";import{executeQueryPBFBuffer as u,executeQuery as c}from"../../../../../../rest/query/operations/query.js";import{FeatureSetReaderJSON as l}from"../../support/FeatureSetReaderJSON.js";import{FeatureSetReaderPBF as m}from"../../support/FeatureSetReaderPBF.js";class p{constructor(e){this.service=e}destroy(){}}function y(e){return Array.isArray(e.source)}function f(e){return e&&e.capabilities&&e.collection&&e.layerDefinition}function d(t){const{capabilities:r}=t;return f(t.source)?new F(t):y(t)?new h(t):r.query.supportsFormatPBF&&e("featurelayer-pbf")?new q(t):new v(t)}class h extends p{constructor(e){super(e),this._portsOpen=s(e.source).then((e=>this.client=e))}destroy(){this.client.close(),this.client=null}async executeQuery(e,t){await this._portsOpen;const r=await this.client.invoke("queryFeatures",e.toJSON(),t);return l.fromFeatureSet(r,this.service.objectIdField)}}class q extends p{async executeQuery(e,t){const{data:r}=await u(this.service.source,e,{signal:null==t?void 0:t.signal,query:{...null==t?void 0:t.query,...this.service.customParameters}}),s=!e.quantizationParameters;return m.fromBuffer(r,this.service.geometryType,s)}}class v extends p{async executeQuery(e,s){const{source:n,capabilities:u,spatialReference:m,objectIdField:p}=this.service;if(t(e.quantizationParameters)&&!u.query.supportsQuantization){const t=e.clone(),u=i(r(t.quantizationParameters));t.quantizationParameters=null;const{data:y}=await c(n,t,m,{signal:null==s?void 0:s.signal,query:{...null==s?void 0:s.query,...this.service.customParameters}}),f=a(y,p);return o(u,f),l.fromOptimizedFeatureSet(f)}const{data:y}=await c(n,e,this.service.spatialReference,{...s,query:{...null==s?void 0:s.query,...this.service.customParameters}});return l.fromFeatureSet(y,this.service.objectIdField)}}class F extends p{async executeQuery(e,t){const{capabilities:s}=this.service;if(e.quantizationParameters&&!s.query.supportsQuantization){const s=e.clone(),a=i(r(s.quantizationParameters));s.quantizationParameters=null;const u=await n(this.service.source,e,t);return o(a,u),l.fromOptimizedFeatureSet(u)}const a=await n(this.service.source,e,t);return l.fromOptimizedFeatureSet(a)}}export{p as SourceAdapter,d as createSourceAdapter};
5
+ import e from"../../../../../../core/has.js";import{isSome as t,unwrap as r}from"../../../../../../core/maybe.js";import{openWithPorts as s}from"../../../../../../core/workers/workers.js";import{toQuantizationTransform as i}from"../../../../../../geometry/support/quantizationUtils.js";import{convertFromFeatureSet as a,quantizeOptimizedFeatureSet as o}from"../../../../../../layers/graphics/featureConversionUtils.js";import{queryOptimizedFeatureSet as n}from"../../../../../../layers/ogc/ogcFeatureUtils.js";import{executeQueryPBFBuffer as c,executeQuery as u}from"../../../../../../rest/query/operations/query.js";import{FeatureSetReaderJSON as p}from"../../support/FeatureSetReaderJSON.js";import{FeatureSetReaderPBF as m}from"../../support/FeatureSetReaderPBF.js";class l{constructor(e){this.service=e}destroy(){}}function f(e){return Array.isArray(e.source)}function y(e){return e&&e.capabilities&&e.collection&&e.layerDefinition}function d(t){const{capabilities:r}=t;return y(t.source)?new w(t):f(t)?new h(t):r.query.supportsFormatPBF&&e("featurelayer-pbf")?new F(t):new q(t)}class h extends l{constructor(e){super(e),this._portsOpen=s(e.source).then((e=>this.client=e))}destroy(){this.client.close(),this.client=null}async executeQuery(e,t){await this._portsOpen;const r=await this.client.invoke("queryFeatures",e.toJSON(),t);return p.fromFeatureSet(r,this.service.objectIdField)}}class F extends l{async executeQuery(e,t){const{data:r}=await c(this.service.source,e,t),s=!e.quantizationParameters;return m.fromBuffer(r,this.service.geometryType,s)}}class q extends l{async executeQuery(e,s){const{source:n,capabilities:c,spatialReference:m,objectIdField:l}=this.service;if(t(e.quantizationParameters)&&!c.query.supportsQuantization){const t=e.clone(),c=i(r(t.quantizationParameters));t.quantizationParameters=null;const{data:f}=await u(n,t,m,s),y=a(f,l);return o(c,y),p.fromOptimizedFeatureSet(y)}const{data:f}=await u(n,e,this.service.spatialReference,s);return p.fromFeatureSet(f,this.service.objectIdField)}}class w extends l{async executeQuery(e,t){const{capabilities:s}=this.service;if(e.quantizationParameters&&!s.query.supportsQuantization){const s=e.clone(),a=i(r(s.quantizationParameters));s.quantizationParameters=null;const c=await n(this.service.source,e,t);return o(a,c),p.fromOptimizedFeatureSet(c)}const a=await n(this.service.source,e,t);return p.fromOptimizedFeatureSet(a)}}export{l as SourceAdapter,d as createSourceAdapter};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.21/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../renderers/ClassBreaksRenderer.js";import"../../../../renderers/DictionaryRenderer.js";import"../../../../renderers/DotDensityRenderer.js";import"../../../../renderers/HeatmapRenderer.js";import"../../../../renderers/Renderer.js";import e from"../../../../renderers/SimpleRenderer.js";import"../../../../renderers/UniqueValueRenderer.js";import"../../../../renderers/support/jsonUtils.js";import t from"../../../../core/Error.js";import r from"../../../../core/has.js";import{clone as i}from"../../../../core/lang.js";import n from"../../../../core/Logger.js";import{isSome as l,isNone as s,unwrapOr as a}from"../../../../core/maybe.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{fromJSON as u}from"../../../../symbols/support/jsonUtils.js";import{WGLGeometryType as d}from"../../engine/webgl/enums.js";import{getVVType as f}from"../../engine/webgl/Utils.js";import{createMaterialKey as c,hydrateMaterialKey as p}from"../../engine/webgl/materialKey/MaterialKey.js";import{getVVFlags as m}from"../../engine/webgl/util/vvFlagUtils.js";import{getPtMaxVVSize as y}from"./support/pixelBuffering.js";import{simplifyVisualVariables as g}from"./support/rendererUtils.js";import{createClusterRenderer as b}from"../support/clusterUtils.js";import{toJSONGeometryType as h}from"../support/util.js";const x=n.getLogger("esri.views.2d.layers.features.schemaUtils"),v="ValidationError",w={esriGeometryPoint:["above-right","above-center","above-left","center-center","center-left","center-right","below-center","below-left","below-right"],esriGeometryPolygon:["always-horizontal"],esriGeometryPolyline:["center-along"],esriGeometryMultipoint:null};function E(e){return p(e)}function I(e){return e}function S(e){if("line-marker"===e.type){var t;return{type:"line-marker",color:null==(t=e.color)?void 0:t.toJSON(),placement:e.placement,style:e.style}}return u(e.toJSON()).toJSON()}function F(e,t,r){if(!e)return null;let i=0,n=!1,s=0;switch(l(t)&&(s=y(t),"visualVariables"in t&&(i=m(t.visualVariables||[]),n="dot-density"===t.type)),e.type){case"simple-fill":case"picture-fill":return V(e,i,n,r);case"simple-marker":case"picture-marker":return j(e,i,s,r);case"simple-line":return z(e,i,r);case"text":return T(e,i,s,r);case"label":return K(e,i,r);case"cim":return{type:"cim",rendererKey:i,data:e.data,maxVVSize:s};case"web-style":return{...S(e),type:"web-style",hash:e.hash(),rendererKey:i,maxVVSize:s};default:throw new Error(`symbol not supported ${e.type}`)}}function V(e,t,r,i){const n=c(d.FILL,t,!1,r),l=i?E(n):n,s=e.clone(),a=s.outline;s.outline=null;const o=[],u={materialKey:l,hash:s.hash(),...S(s)};if(o.push(u),a){const e=c(d.LINE,t,!0,!1),r={materialKey:i?E(e):e,hash:a.hash(),...S(a)};o.push(r)}return{type:"composite-symbol",layers:o,hash:o.reduce(((e,t)=>t.hash+e),"")}}function z(e,t,r){const i=c(d.LINE,t,!1,!1),n=r?E(i):i,l=e.clone(),s=l.marker;l.marker=null;const a=[];if(a.push({materialKey:n,hash:l.hash(),...S(l)}),s){var o;const e=c(d.MARKER,t,!1,!1),i=r?E(e):e;s.color=null!=(o=s.color)?o:l.color,a.push({materialKey:i,hash:s.hash(),lineWidth:l.width,...S(s)})}return{type:"composite-symbol",layers:a,hash:a.reduce(((e,t)=>t.hash+e),"")}}function j(e,t,r,i){const n=c(d.MARKER,t,!1,!1),l=i?E(n):n,s=S(e);return{materialKey:l,hash:e.hash(),...s,angle:e.angle,maxVVSize:r}}function T(e,t,r,i){const n=c(d.TEXT,t,!1,!1),l=i?E(n):n,s=S(e);return{materialKey:l,hash:e.hash(),...s,angle:e.angle,maxVVSize:r}}function N(e,r){const i=e.labelPlacement,n=w[r];if(!e.symbol)return x.warn("No ILabelClass symbol specified."),!0;if(!n)return x.error(new t("mapview-labeling:unsupported-geometry-type",`Unable to create labels for Feature Layer, ${r} is not supported`)),!0;if(!n.some((e=>e===i))){const t=n[0];i&&x.warn(`Found invalid label placement type ${i} for ${r}. Defaulting to ${t}`),e.labelPlacement=t}return!1}function R(e,t){const r=i(e);return r.some((e=>N(e,t)))?[]:r}function K(e,t,r){const i=e.toJSON(),n=c(d.LABEL,t,!1,!1,i.labelPlacement);return{materialKey:r?E(n):n,hash:e.hash(),...i,labelPlacement:i.labelPlacement}}function M(e){return r("esri-2d-update-debug")&&console.debug("Created new schema",O(e,!0)),O(e)}function O(e,t=!1){try{var r,i;const n=C(e,t),l={};n.map((t=>k(l,e,t)));return{source:{definitionExpression:e.definitionExpression,fields:e.fields.map((e=>e.toJSON())),gdbVersion:e.gdbVersion,historicMoment:null==(r=e.historicMoment)?void 0:r.getTime(),outFields:e.availableFields,pixelBuffer:e.pixelBuffer,spatialReference:e.spatialReference.toJSON(),timeExtent:null==(i=e.timeExtent)?void 0:i.toJSON()},attributes:{fields:{},indexCount:0},processors:n,targets:l}}catch(n){if(n.fieldName===v)return x.error(n),null;throw n}}function k(e,r,i){switch(i.target){case"feature":return void J(e,L(r),i);case"aggregate":{if(!("featureReduction"in r))return;const n=r.featureReduction;if("selection"===n.type)throw new t(v,"Mapview does not support `selection` reduction type",n);return J(e,L(r),i),void D(e,n,i)}}}function B(e,t){for(const r in t){const i=t[r];if(i.target!==e.name)continue;const n=e.attributes[r];n?(n.context.mesh=n.context.mesh||i.context.mesh,n.context.storage=n.context.storage||i.context.storage):e.attributes[r]=i}return e}function L(e){var t,r,i,n,l;return[null!=(t=null==(r=e.filter)?void 0:r.toJSON())?t:null,null!=(i=null==(n=e.effect)||null==(l=n.filter)?void 0:l.toJSON())?i:null]}function J(e,t,r){return e.feature||(e.feature={name:"feature",input:"source",filters:t,attributes:{}}),B(e.feature,r.attributes.fields),e}function D(e,t,r){return e.aggregate||(e.aggregate={name:"aggregate",input:"feature",filters:null,attributes:{},params:{clusterRadius:o(t.clusterRadius/2),clusterPixelBuffer:64*Math.ceil(o(t.clusterMaxSize)/64),fields:r.aggregateFields}}),B(e.aggregate,r.attributes.fields),e}function P(e,t){return t.field?U(e,{...t,type:"field",field:t.field}):t.valueExpression?U(e,{...t,type:"expression",valueExpression:t.valueExpression}):{field:null,fieldIndex:null}}function U(e,t){switch(t.type){case"expression":{const r=I(t.valueExpression);if(!e.fields[r]){const i=e.indexCount++;e.fields[r]={...t,name:r,fieldIndex:i}}return{fieldIndex:e.fields[r].fieldIndex}}case"label-expression":{const r=I(JSON.stringify(t.label));if(!e.fields[r]){const i=e.indexCount++;e.fields[r]={...t,name:r,fieldIndex:i}}return{fieldIndex:e.fields[r].fieldIndex}}case"field":{const r=t.field;return"aggregate"===t.target&&e.fields[r]||(e.fields[r]={...t,name:r}),{field:r}}case"statistic":return e.fields[t.name]={...t},{field:t.name}}}function C(e,t=!1){const r=new Array;let i=0;return r.push(q(e,i++,t)),r}function $(e,t,r,i,n,l=!1){const s=U(t,{type:"label-expression",target:i,context:{mesh:!0},resultType:"string",label:{labelExpression:r.labelExpression,labelExpressionInfo:r.labelExpressionInfo?{expression:r.labelExpressionInfo.expression}:null,symbol:!!r.symbol,where:r.where}}),{fieldIndex:a}=s;return{...F(r,e,l),fieldIndex:a,target:i,index:n}}function q(r,i,n=!1){const s={indexCount:0,fields:{}},a="featureReduction"in r&&r.featureReduction,o=a?"aggregate":"feature";if("sublayers"in r){const e={type:"subtype",subtypeField:r.subtypeField,renderers:{}},i={type:"subtype",mapping:{},target:"feature"},a={type:"subtype",classes:{}},u={type:"symbol",target:"feature",aggregateFields:[],attributes:s,storage:i,mesh:{matcher:e,aggregateMatcher:null,labels:a,sortKey:null}},d=new Set;let f=0;for(const{renderer:c,subtypeCode:p,labelingInfo:m,labelsVisible:y}of r.sublayers){const r=Q(s,o,c,n),u=H(s,o,c),g=y&&m;if("visualVariables"in c&&c.visualVariables&&c.visualVariables.length)throw new t(v,"Visual variables are currently not supported for subtype layers");if("dictionary"===r.type)throw new t(v,"Dictionary renderer is not supported in subtype layers");if("subtype"===r.type)throw new t(v,"Nested subtype renderers is not supported");if(l(u)&&"subtype"===u.type)throw new t(v,"Nested subtype storage is not supported");if(l(u)&&"dot-density"===u.type)throw new t(v,"Dot density attributes are not supported in subtype layers");if(d.has(p))throw new t(v,"Subtype codes for sublayers must be unique");d.add(p),e.renderers[p]=r,i.mapping[p]=u,g&&(a.classes[p]=g.map((e=>$(c,s,e,"feature",f++,n))))}return u}if("heatmap"===r.renderer.type){const{blurRadius:e,fieldOffset:t,field:i}=r.renderer;return{type:"heatmap",aggregateFields:[],attributes:s,target:o,storage:null,mesh:{blurRadius:e,fieldOffset:t,field:P(s,{target:o,field:i,resultType:"numeric"}).field}}}{const i=[],l="aggregate"===o?b(i,r.renderer,a,null):r.renderer;G(s,i);const u=Q(s,o,l,n);let d=null;const f=H(s,o,l),c=h(r.geometryType);let p=r.labelsVisible&&r.labelingInfo||[],m=[];if(a){if("selection"===a.type)throw new t(v,"Mapview does not support `selection` reduction type",a);if(a.symbol){const t=new e({symbol:a.symbol,visualVariables:"visualVariables"in l?l.visualVariables:null});d=Q(s,o,t,n)}m=a&&a.labelsVisible&&a.labelingInfo||[]}p=R(p,c),m=R(m,c);let y=0;const g=[...p.map((e=>$(l,s,e,"feature",y++,n))),...m.map((e=>$(l,s,e,"aggregate",y++,n)))],x=A(s,r.orderBy);return{type:"symbol",target:o,attributes:s,aggregateFields:i,storage:f,mesh:{matcher:u,labels:{type:"simple",classes:g},aggregateMatcher:d,sortKey:x}}}}function A(e,r){if(s(r)||!r.length)return null;r.length>1&&x.warn(`Layer rendering currently only supports ordering by 1 orderByInfo, but found ${r.length}. All but the first will be discarded`);const i=r[0],n="ascending"===i.order?"asc":"desc";if(i.field)return{field:i.field,order:n};if(i.valueExpression){return{fieldIndex:U(e,{type:"expression",target:"feature",valueExpression:i.valueExpression,resultType:"numeric"}).fieldIndex,order:n}}return x.error(new t(v,"Expected to find a field or valueExpression for OrderByInfo",i)),null}function G(e,t){const r={mesh:!0,storage:!0};for(const i of t){const{name:t,outStatistic:n}=i,{statisticType:l,onStatisticField:s}=n;let a=null,o=null,u=null;const d="numeric",f="feature";if("onStatisticValueExpression"in n){o=U(e,{type:"expression",target:f,valueExpression:n.onStatisticValueExpression,resultType:d}).fieldIndex}else if("onStatisticNormalizationField"in n){a=U(e,{type:"field",target:f,field:s,resultType:d}).field,u=n.onStatisticNormalizationField}else{a=U(e,{type:"field",target:f,field:s,resultType:d}).field}U(e,{type:"statistic",target:"aggregate",name:t,context:r,inField:a,inNormalizationField:u,inFieldIndex:o,statisticType:l})}}function H(e,t,r){switch(r.type){case"dot-density":return W(e,t,r.attributes);case"simple":case"class-breaks":case"unique-value":case"dictionary":return X(e,t,r.visualVariables);case"heatmap":return null}}function W(e,t,r){if(!r||!r.length)return{type:"dot-density",mapping:[],target:t};return{type:"dot-density",mapping:r.map(((r,i)=>{const{field:n,fieldIndex:l}=P(e,{valueExpression:r.valueExpression,field:r.field,resultType:"numeric",target:t});return{binding:i,field:n,fieldIndex:l}})),target:t}}function X(e,t,r){if(!r||!r.length)return{type:"visual-variable",mapping:[],target:t};const i={storage:!0},n="numeric";return{type:"visual-variable",mapping:g(r).map((r=>{var l;const s=f(r.type),{field:a,fieldIndex:o}=P(e,{target:t,valueExpression:r.valueExpression,field:r.field,context:i,resultType:n});switch(r.type){case"size":return"$view.scale"===r.valueExpression?null:{type:"size",binding:s,field:a,fieldIndex:o,normalizationField:P(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field,valueRepresentation:null!=(l=r.valueRepresentation)?l:null};case"color":return{type:"color",binding:s,field:a,fieldIndex:o,normalizationField:P(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field};case"opacity":return{type:"opacity",binding:s,field:a,fieldIndex:o,normalizationField:P(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field};case"rotation":return{type:"rotation",binding:s,field:a,fieldIndex:o}}})).filter((e=>e)),target:t}}function Q(e,t,r,i=!1){const n=a(e,{indexCount:0,fields:{}});switch(r.type){case"simple":case"dot-density":return Y(n,r,"dot-density"===r.type,i);case"class-breaks":return Z(n,t,r,i);case"unique-value":return _(n,t,r,i);case"dictionary":return ee(n,r,i)}}function Y(e,t,r,i=!1){const n=t.getSymbols();return{type:"simple",symbol:F(n.length?n[0]:null,t,i),isDotDensity:r}}function Z(e,t,r,i=!1){const n={mesh:!0,use:"renderer.field"},l=r.backgroundFillSymbol,{field:s,fieldIndex:a}=P(e,{target:t,field:r.field,valueExpression:r.valueExpression,resultType:"numeric",context:n}),o=r.normalizationType,u="log"===o?"esriNormalizeByLog":"percent-of-total"===o?"esriNormalizeByPercentOfTotal":"field"===o?"esriNormalizeByField":null,d=r.classBreakInfos.map((e=>({symbol:F(e.symbol,r,i),min:e.minValue,max:e.maxValue}))).sort(((e,t)=>e.min-t.min));return{type:"interval",attributes:e.fields,field:s,fieldIndex:a,backgroundFillSymbol:F(l,r,i),defaultSymbol:F(r.defaultSymbol,r,i),intervals:d,normalizationField:r.normalizationField,normalizationTotal:r.normalizationTotal,normalizationType:u,isMaxInclusive:r.isMaxInclusive}}function _(e,r,i,n=!1){const l=[],s=i.backgroundFillSymbol,a={target:r,context:{mesh:!0},resultType:"string"};if(i.field&&"string"!=typeof i.field)throw new t(v,"Expected renderer.field to be a string",i);const{field:o,fieldIndex:u}=P(e,{...a,field:i.field,valueExpression:i.valueExpression});for(const t of i.uniqueValueInfos)l.push({value:""+t.value,symbol:F(t.symbol,i,n)});return{type:"map",attributes:e.fields,field:o,fieldIndex:u,field2:P(e,{...a,field:i.field2}).field,field3:P(e,{...a,field:i.field3}).field,fieldDelimiter:i.fieldDelimiter,backgroundFillSymbol:F(s,i),defaultSymbol:F(i.defaultSymbol,i),map:l}}function ee(e,t,r=!1){return{type:"dictionary",renderer:t.toJSON()}}export{G as addAggregateFields,Q as createMatcherSchema,M as createSchema,F as createSymbolSchema};
5
+ import"../../../../renderers/ClassBreaksRenderer.js";import"../../../../renderers/DictionaryRenderer.js";import"../../../../renderers/DotDensityRenderer.js";import"../../../../renderers/HeatmapRenderer.js";import"../../../../renderers/Renderer.js";import e from"../../../../renderers/SimpleRenderer.js";import"../../../../renderers/UniqueValueRenderer.js";import"../../../../renderers/support/jsonUtils.js";import t from"../../../../core/Error.js";import r from"../../../../core/has.js";import{clone as i}from"../../../../core/lang.js";import n from"../../../../core/Logger.js";import{isSome as l,isNone as s,unwrapOr as a}from"../../../../core/maybe.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{fromJSON as u}from"../../../../symbols/support/jsonUtils.js";import{WGLGeometryType as d}from"../../engine/webgl/enums.js";import{getVVType as f}from"../../engine/webgl/Utils.js";import{createMaterialKey as c,hydrateMaterialKey as p}from"../../engine/webgl/materialKey/MaterialKey.js";import{getVVFlags as m}from"../../engine/webgl/util/vvFlagUtils.js";import{getPtMaxVVSize as y}from"./support/pixelBuffering.js";import{simplifyVisualVariables as g}from"./support/rendererUtils.js";import{createClusterRenderer as b}from"../support/clusterUtils.js";import{toJSONGeometryType as h}from"../support/util.js";const x=n.getLogger("esri.views.2d.layers.features.schemaUtils"),v="ValidationError",w={esriGeometryPoint:["above-right","above-center","above-left","center-center","center-left","center-right","below-center","below-left","below-right"],esriGeometryPolygon:["always-horizontal"],esriGeometryPolyline:["center-along"],esriGeometryMultipoint:null};function E(e){return p(e)}function I(e){return e}function S(e){if("line-marker"===e.type){var t;return{type:"line-marker",color:null==(t=e.color)?void 0:t.toJSON(),placement:e.placement,style:e.style}}return u(e.toJSON()).toJSON()}function F(e,t,r){if(!e)return null;let i=0,n=!1,s=0;switch(l(t)&&(s=y(t),"visualVariables"in t&&(i=m(t.visualVariables||[]),n="dot-density"===t.type)),e.type){case"simple-fill":case"picture-fill":return V(e,i,n,r);case"simple-marker":case"picture-marker":return j(e,i,s,r);case"simple-line":return z(e,i,r);case"text":return T(e,i,s,r);case"label":return K(e,i,r);case"cim":return{type:"cim",rendererKey:i,data:e.data,maxVVSize:s};case"web-style":return{...S(e),type:"web-style",hash:e.hash(),rendererKey:i,maxVVSize:s};default:throw new Error(`symbol not supported ${e.type}`)}}function V(e,t,r,i){const n=c(d.FILL,t,!1,r),l=i?E(n):n,s=e.clone(),a=s.outline;s.outline=null;const o=[],u={materialKey:l,hash:s.hash(),...S(s)};if(o.push(u),a){const e=c(d.LINE,t,!0,!1),r={materialKey:i?E(e):e,hash:a.hash(),...S(a)};o.push(r)}return{type:"composite-symbol",layers:o,hash:o.reduce(((e,t)=>t.hash+e),"")}}function z(e,t,r){const i=c(d.LINE,t,!1,!1),n=r?E(i):i,l=e.clone(),s=l.marker;l.marker=null;const a=[];if(a.push({materialKey:n,hash:l.hash(),...S(l)}),s){var o;const e=c(d.MARKER,t,!1,!1),i=r?E(e):e;s.color=null!=(o=s.color)?o:l.color,a.push({materialKey:i,hash:s.hash(),lineWidth:l.width,...S(s)})}return{type:"composite-symbol",layers:a,hash:a.reduce(((e,t)=>t.hash+e),"")}}function j(e,t,r,i){const n=c(d.MARKER,t,!1,!1),l=i?E(n):n,s=S(e);return{materialKey:l,hash:e.hash(),...s,angle:e.angle,maxVVSize:r}}function T(e,t,r,i){const n=c(d.TEXT,t,!1,!1),l=i?E(n):n,s=S(e);return{materialKey:l,hash:e.hash(),...s,angle:e.angle,maxVVSize:r}}function N(e,r){const i=e.labelPlacement,n=w[r];if(!e.symbol)return x.warn("No ILabelClass symbol specified."),!0;if(!n)return x.error(new t("mapview-labeling:unsupported-geometry-type",`Unable to create labels for Feature Layer, ${r} is not supported`)),!0;if(!n.some((e=>e===i))){const t=n[0];i&&x.warn(`Found invalid label placement type ${i} for ${r}. Defaulting to ${t}`),e.labelPlacement=t}return!1}function R(e,t){const r=i(e);return r.some((e=>N(e,t)))?[]:r}function K(e,t,r){const i=e.toJSON(),n=c(d.LABEL,t,!1,!1,i.labelPlacement);return{materialKey:r?E(n):n,hash:e.hash(),...i,labelPlacement:i.labelPlacement}}function M(e){return r("esri-2d-update-debug")&&console.debug("Created new schema",O(e,!0)),O(e)}function O(e,t=!1){try{var r,i;const n=C(e,t),l={};n.map((t=>k(l,e,t)));return{source:{definitionExpression:e.definitionExpression,fields:e.fields.map((e=>e.toJSON())),gdbVersion:e.gdbVersion,historicMoment:null==(r=e.historicMoment)?void 0:r.getTime(),outFields:e.availableFields,pixelBuffer:e.pixelBuffer,spatialReference:e.spatialReference.toJSON(),timeExtent:null==(i=e.timeExtent)?void 0:i.toJSON(),customParameters:e.customParameters},attributes:{fields:{},indexCount:0},processors:n,targets:l}}catch(n){if(n.fieldName===v)return x.error(n),null;throw n}}function k(e,r,i){switch(i.target){case"feature":return void P(e,L(r),i);case"aggregate":{if(!("featureReduction"in r))return;const n=r.featureReduction;if("selection"===n.type)throw new t(v,"Mapview does not support `selection` reduction type",n);return P(e,L(r),i),void J(e,n,i)}}}function B(e,t){for(const r in t){const i=t[r];if(i.target!==e.name)continue;const n=e.attributes[r];n?(n.context.mesh=n.context.mesh||i.context.mesh,n.context.storage=n.context.storage||i.context.storage):e.attributes[r]=i}return e}function L(e){var t,r,i,n,l;return[null!=(t=null==(r=e.filter)?void 0:r.toJSON())?t:null,null!=(i=null==(n=e.effect)||null==(l=n.filter)?void 0:l.toJSON())?i:null]}function P(e,t,r){return e.feature||(e.feature={name:"feature",input:"source",filters:t,attributes:{}}),B(e.feature,r.attributes.fields),e}function J(e,t,r){return e.aggregate||(e.aggregate={name:"aggregate",input:"feature",filters:null,attributes:{},params:{clusterRadius:o(t.clusterRadius/2),clusterPixelBuffer:64*Math.ceil(o(t.clusterMaxSize)/64),fields:r.aggregateFields}}),B(e.aggregate,r.attributes.fields),e}function D(e,t){return t.field?U(e,{...t,type:"field",field:t.field}):t.valueExpression?U(e,{...t,type:"expression",valueExpression:t.valueExpression}):{field:null,fieldIndex:null}}function U(e,t){switch(t.type){case"expression":{const r=I(t.valueExpression);if(!e.fields[r]){const i=e.indexCount++;e.fields[r]={...t,name:r,fieldIndex:i}}return{fieldIndex:e.fields[r].fieldIndex}}case"label-expression":{const r=I(JSON.stringify(t.label));if(!e.fields[r]){const i=e.indexCount++;e.fields[r]={...t,name:r,fieldIndex:i}}return{fieldIndex:e.fields[r].fieldIndex}}case"field":{const r=t.field;return"aggregate"===t.target&&e.fields[r]||(e.fields[r]={...t,name:r}),{field:r}}case"statistic":return e.fields[t.name]={...t},{field:t.name}}}function C(e,t=!1){const r=new Array;let i=0;return r.push(q(e,i++,t)),r}function $(e,t,r,i,n,l=!1){const s=U(t,{type:"label-expression",target:i,context:{mesh:!0},resultType:"string",label:{labelExpression:r.labelExpression,labelExpressionInfo:r.labelExpressionInfo?{expression:r.labelExpressionInfo.expression}:null,symbol:!!r.symbol,where:r.where}}),{fieldIndex:a}=s;return{...F(r,e,l),fieldIndex:a,target:i,index:n}}function q(r,i,n=!1){const s={indexCount:0,fields:{}},a="featureReduction"in r&&r.featureReduction,o=a?"aggregate":"feature";if("sublayers"in r){const e={type:"subtype",subtypeField:r.subtypeField,renderers:{}},i={type:"subtype",mapping:{},target:"feature"},a={type:"subtype",classes:{}},u={type:"symbol",target:"feature",aggregateFields:[],attributes:s,storage:i,mesh:{matcher:e,aggregateMatcher:null,labels:a,sortKey:null}},d=new Set;let f=0;for(const{renderer:c,subtypeCode:p,labelingInfo:m,labelsVisible:y}of r.sublayers){const r=Q(s,o,c,n),u=H(s,o,c),g=y&&m;if("visualVariables"in c&&c.visualVariables&&c.visualVariables.length)throw new t(v,"Visual variables are currently not supported for subtype layers");if("dictionary"===r.type)throw new t(v,"Dictionary renderer is not supported in subtype layers");if("subtype"===r.type)throw new t(v,"Nested subtype renderers is not supported");if(l(u)&&"subtype"===u.type)throw new t(v,"Nested subtype storage is not supported");if(l(u)&&"dot-density"===u.type)throw new t(v,"Dot density attributes are not supported in subtype layers");if(d.has(p))throw new t(v,"Subtype codes for sublayers must be unique");d.add(p),e.renderers[p]=r,i.mapping[p]=u,g&&(a.classes[p]=g.map((e=>$(c,s,e,"feature",f++,n))))}return u}if("heatmap"===r.renderer.type){const{blurRadius:e,fieldOffset:t,field:i}=r.renderer;return{type:"heatmap",aggregateFields:[],attributes:s,target:o,storage:null,mesh:{blurRadius:e,fieldOffset:t,field:D(s,{target:o,field:i,resultType:"numeric"}).field}}}{const i=[],l="aggregate"===o?b(i,r.renderer,a,null):r.renderer;G(s,i);const u=Q(s,o,l,n);let d=null;const f=H(s,o,l),c=h(r.geometryType);let p=r.labelsVisible&&r.labelingInfo||[],m=[];if(a){if("selection"===a.type)throw new t(v,"Mapview does not support `selection` reduction type",a);if(a.symbol){const t=new e({symbol:a.symbol,visualVariables:"visualVariables"in l?l.visualVariables:null});d=Q(s,o,t,n)}m=a&&a.labelsVisible&&a.labelingInfo||[]}p=R(p,c),m=R(m,c);let y=0;const g=[...p.map((e=>$(l,s,e,"feature",y++,n))),...m.map((e=>$(l,s,e,"aggregate",y++,n)))],x=A(s,r.orderBy);return{type:"symbol",target:o,attributes:s,aggregateFields:i,storage:f,mesh:{matcher:u,labels:{type:"simple",classes:g},aggregateMatcher:d,sortKey:x}}}}function A(e,r){if(s(r)||!r.length)return null;r.length>1&&x.warn(`Layer rendering currently only supports ordering by 1 orderByInfo, but found ${r.length}. All but the first will be discarded`);const i=r[0],n="ascending"===i.order?"asc":"desc";if(i.field)return{field:i.field,order:n};if(i.valueExpression){return{fieldIndex:U(e,{type:"expression",target:"feature",valueExpression:i.valueExpression,resultType:"numeric"}).fieldIndex,order:n}}return x.error(new t(v,"Expected to find a field or valueExpression for OrderByInfo",i)),null}function G(e,t){const r={mesh:!0,storage:!0};for(const i of t){const{name:t,outStatistic:n}=i,{statisticType:l,onStatisticField:s}=n;let a=null,o=null,u=null;const d="numeric",f="feature";if("onStatisticValueExpression"in n){o=U(e,{type:"expression",target:f,valueExpression:n.onStatisticValueExpression,resultType:d}).fieldIndex}else if("onStatisticNormalizationField"in n){a=U(e,{type:"field",target:f,field:s,resultType:d}).field,u=n.onStatisticNormalizationField}else{a=U(e,{type:"field",target:f,field:s,resultType:d}).field}U(e,{type:"statistic",target:"aggregate",name:t,context:r,inField:a,inNormalizationField:u,inFieldIndex:o,statisticType:l})}}function H(e,t,r){switch(r.type){case"dot-density":return W(e,t,r.attributes);case"simple":case"class-breaks":case"unique-value":case"dictionary":return X(e,t,r.visualVariables);case"heatmap":return null}}function W(e,t,r){if(!r||!r.length)return{type:"dot-density",mapping:[],target:t};return{type:"dot-density",mapping:r.map(((r,i)=>{const{field:n,fieldIndex:l}=D(e,{valueExpression:r.valueExpression,field:r.field,resultType:"numeric",target:t});return{binding:i,field:n,fieldIndex:l}})),target:t}}function X(e,t,r){if(!r||!r.length)return{type:"visual-variable",mapping:[],target:t};const i={storage:!0},n="numeric";return{type:"visual-variable",mapping:g(r).map((r=>{var l;const s=f(r.type),{field:a,fieldIndex:o}=D(e,{target:t,valueExpression:r.valueExpression,field:r.field,context:i,resultType:n});switch(r.type){case"size":return"$view.scale"===r.valueExpression?null:{type:"size",binding:s,field:a,fieldIndex:o,normalizationField:D(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field,valueRepresentation:null!=(l=r.valueRepresentation)?l:null};case"color":return{type:"color",binding:s,field:a,fieldIndex:o,normalizationField:D(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field};case"opacity":return{type:"opacity",binding:s,field:a,fieldIndex:o,normalizationField:D(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field};case"rotation":return{type:"rotation",binding:s,field:a,fieldIndex:o}}})).filter((e=>e)),target:t}}function Q(e,t,r,i=!1){const n=a(e,{indexCount:0,fields:{}});switch(r.type){case"simple":case"dot-density":return Y(n,r,"dot-density"===r.type,i);case"class-breaks":return Z(n,t,r,i);case"unique-value":return _(n,t,r,i);case"dictionary":return ee(n,r,i)}}function Y(e,t,r,i=!1){const n=t.getSymbols();return{type:"simple",symbol:F(n.length?n[0]:null,t,i),isDotDensity:r}}function Z(e,t,r,i=!1){const n={mesh:!0,use:"renderer.field"},l=r.backgroundFillSymbol,{field:s,fieldIndex:a}=D(e,{target:t,field:r.field,valueExpression:r.valueExpression,resultType:"numeric",context:n}),o=r.normalizationType,u="log"===o?"esriNormalizeByLog":"percent-of-total"===o?"esriNormalizeByPercentOfTotal":"field"===o?"esriNormalizeByField":null,d=r.classBreakInfos.map((e=>({symbol:F(e.symbol,r,i),min:e.minValue,max:e.maxValue}))).sort(((e,t)=>e.min-t.min));return{type:"interval",attributes:e.fields,field:s,fieldIndex:a,backgroundFillSymbol:F(l,r,i),defaultSymbol:F(r.defaultSymbol,r,i),intervals:d,normalizationField:r.normalizationField,normalizationTotal:r.normalizationTotal,normalizationType:u,isMaxInclusive:r.isMaxInclusive}}function _(e,r,i,n=!1){const l=[],s=i.backgroundFillSymbol,a={target:r,context:{mesh:!0},resultType:"string"};if(i.field&&"string"!=typeof i.field)throw new t(v,"Expected renderer.field to be a string",i);const{field:o,fieldIndex:u}=D(e,{...a,field:i.field,valueExpression:i.valueExpression});for(const t of i.uniqueValueInfos)l.push({value:""+t.value,symbol:F(t.symbol,i,n)});return{type:"map",attributes:e.fields,field:o,fieldIndex:u,field2:D(e,{...a,field:i.field2}).field,field3:D(e,{...a,field:i.field3}).field,fieldDelimiter:i.fieldDelimiter,backgroundFillSymbol:F(s,i),defaultSymbol:F(i.defaultSymbol,i),map:l}}function ee(e,t,r=!1){return{type:"dictionary",renderer:t.toJSON()}}export{G as addAggregateFields,Q as createMatcherSchema,M as createSchema,F as createSymbolSchema};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.21/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../request.js";import t from"../../../../../core/Error.js";import r from"../../../../../core/has.js";import s from"../../../../../core/Logger.js";import{isSome as i,unwrapOr as a,isNone as o}from"../../../../../core/maybe.js";import{throwIfAborted as n,isAbortError as u}from"../../../../../core/promiseUtils.js";import{createSourceAdapter as c}from"../controllers/support/sourceAdapters.js";import{DataTileSource as d}from"./DataTileSource.js";import{QueueProcessor as l}from"../../../../support/QueueProcessor.js";const p=s.getLogger("esri.views.2d.layers.features.sources.BaseFeatureSource"),y=4;class h extends d{constructor(e){super(e),this.type="feature",this.mode="on-demand",this._adapter=c(e.serviceInfo),this._queue=new l({concurrency:8,process:async e=>{if(n(e),i(e.tile)){const t=e.tile.key.id,{signal:s}=e,i=r("esri-tiles-debug")?{tile:t.replace(/\//g,"."),depth:e.depth}:void 0,a=await this._adapter.executeQuery(e.query,{query:i,signal:s});return a.level=e.tile.key.level,a}return this._adapter.executeQuery(e.query,e)}}),this._patchQueue=new l({concurrency:8,process:async e=>{if(n(e),i(e.tile)){const t=e.tile.key.id,{signal:s}=e,i=r("esri-tiles-debug")?{tile:t.replace(/\//g,"."),depth:e.depth}:void 0,a=await this._adapter.executeQuery(e.query,{query:i,signal:s});return a.level=e.tile.key.level,a}return this._adapter.executeQuery(e.query,e)}})}destroy(){super.destroy(),this._adapter.destroy(),this._queue.destroy(),this._patchQueue.destroy()}get updating(){return!!this._queue.length||Array.from(this._subscriptions.values()).some((e=>!e.done))}get maxRecordCountFactor(){const{query:e}=this._serviceInfo.capabilities;return e.supportsMaxRecordCountFactor?y:null}get maxPageSize(){var e;const{query:t}=this._serviceInfo.capabilities;return(null!=(e=t.maxRecordCount)?e:8e3)*a(this.maxRecordCountFactor,1)}get pageSize(){return Math.min(8e3,this.maxPageSize)}enableEvent(e,t){}subscribe(e){super.subscribe(e);const r=this._subscriptions.get(e.id);this._fetchDataTile(e).catch((r=>{u(r)||p.error(new t("mapview-query-error","Encountered error when fetching tile",{tile:e,error:r}))})).then((()=>r.end()))}unsubscribe(e){super.unsubscribe(e)}readers(e){return this._subscriptions.get(e).readers()}async query(e){return this._adapter.executeQuery(e)}async queryLastEditDate(){const t=this._serviceInfo.source,r={...t.query,f:"json"};return(await e(t.path,{query:r,responseType:"json"})).data.editingInfo.lastEditDate}createTileQuery(e,t={}){var r;const s=this.createQuery(t);return s.quantizationParameters=null!=(r=t.quantizationParameters)?r:e.getQuantizationParameters(),s.resultType="tile",s.geometry=e.extent,s.quantizationParameters&&"esriGeometryPolyline"===this._serviceInfo.geometryType&&(s.maxAllowableOffset=e.resolution),s}async _executePatchQuery(e,t,r,s){const a=t.clone();a.outFields=[this._serviceInfo.objectIdField,...r],a.returnCentroid=!1,a.returnGeometry=!1;const o=i(a.start)?a.start/8e3:0,n=s.signal;return this._patchQueue.push({tile:e,query:a,signal:n,depth:o})}async _resend(e,t){const{query:r,message:s}=e,a=i(r.outFields)?r.outFields:[],u=this._queryInfo.outFields,c=u.filter((e=>-1===a.indexOf(e)));if(o(s.addOrUpdate))this._onMessage({...s,type:"append"});else if(c.length)try{const e=this._subscriptions.get(s.id).tile,i=await this._executePatchQuery(e,r,c,t);n(t),r.outFields=u,s.addOrUpdate.joinAttributes(i),this._onMessage({...s,end:s.end,type:"append"})}catch(d){}else this._onMessage({...s,type:"append"})}async _resendSubscription(e){if(e.empty)return this._onMessage({id:e.tile.id,addOrUpdate:null,end:!1,type:"append"});const t=e.signal;for(const r of e.requests.done)await this._resend(r,{signal:t});return i(e.edits)?this._onMessage(e.edits):void 0}async resend(){const e=Array.from(this._subscriptions.values());await Promise.all(e.map((e=>this._resendSubscription(e))))}}export{h as BaseFeatureSource};
5
+ import e from"../../../../../request.js";import t from"../../../../../core/Error.js";import r from"../../../../../core/has.js";import s from"../../../../../core/Logger.js";import{isSome as i,unwrapOr as a,isNone as o}from"../../../../../core/maybe.js";import{throwIfAborted as n,isAbortError as u}from"../../../../../core/promiseUtils.js";import{createSourceAdapter as c}from"../controllers/support/sourceAdapters.js";import{DataTileSource as d}from"./DataTileSource.js";import{QueueProcessor as l}from"../../../../support/QueueProcessor.js";const p=s.getLogger("esri.views.2d.layers.features.sources.BaseFeatureSource"),h=4;class y extends d{constructor(e){super(e),this.type="feature",this.mode="on-demand",this._adapter=c(e.serviceInfo),this._queue=new l({concurrency:8,process:async e=>{if(n(e),i(e.tile)){const t=e.tile.key.id,{signal:s}=e,i=r("esri-tiles-debug")?{tile:t.replace(/\//g,"."),depth:e.depth}:void 0,a=await this._adapter.executeQuery(e.query,{signal:s,query:{...i,...this._schema.customParameters}});return a.level=e.tile.key.level,a}return this._adapter.executeQuery(e.query,{...e,query:this._schema.customParameters})}}),this._patchQueue=new l({concurrency:8,process:async e=>{if(n(e),i(e.tile)){const t=e.tile.key.id,{signal:s}=e,i=r("esri-tiles-debug")?{tile:t.replace(/\//g,"."),depth:e.depth}:void 0,a=await this._adapter.executeQuery(e.query,{signal:s,query:{...i,...this._schema.customParameters}});return a.level=e.tile.key.level,a}return this._adapter.executeQuery(e.query,{...e,query:this._schema.customParameters})}})}destroy(){super.destroy(),this._adapter.destroy(),this._queue.destroy(),this._patchQueue.destroy()}get updating(){return!!this._queue.length||Array.from(this._subscriptions.values()).some((e=>!e.done))}get maxRecordCountFactor(){const{query:e}=this._serviceInfo.capabilities;return e.supportsMaxRecordCountFactor?h:null}get maxPageSize(){var e;const{query:t}=this._serviceInfo.capabilities;return(null!=(e=t.maxRecordCount)?e:8e3)*a(this.maxRecordCountFactor,1)}get pageSize(){return Math.min(8e3,this.maxPageSize)}enableEvent(e,t){}subscribe(e){super.subscribe(e);const r=this._subscriptions.get(e.id);this._fetchDataTile(e).catch((r=>{u(r)||p.error(new t("mapview-query-error","Encountered error when fetching tile",{tile:e,error:r}))})).then((()=>r.end()))}unsubscribe(e){super.unsubscribe(e)}readers(e){return this._subscriptions.get(e).readers()}async query(e){return this._adapter.executeQuery(e,{query:this._schema.customParameters})}async queryLastEditDate(){const t=this._serviceInfo.source,r={...t.query,f:"json"};return(await e(t.path,{query:r,responseType:"json"})).data.editingInfo.lastEditDate}createTileQuery(e,t={}){var r;const s=this.createQuery(t);return s.quantizationParameters=null!=(r=t.quantizationParameters)?r:e.getQuantizationParameters(),s.resultType="tile",s.geometry=e.extent,s.quantizationParameters&&"esriGeometryPolyline"===this._serviceInfo.geometryType&&(s.maxAllowableOffset=e.resolution),s}async _executePatchQuery(e,t,r,s){const a=t.clone();a.outFields=[this._serviceInfo.objectIdField,...r],a.returnCentroid=!1,a.returnGeometry=!1;const o=i(a.start)?a.start/8e3:0,n=s.signal;return this._patchQueue.push({tile:e,query:a,signal:n,depth:o})}async _resend(e,t){const{query:r,message:s}=e,a=i(r.outFields)?r.outFields:[],u=this._queryInfo.outFields,c=u.filter((e=>-1===a.indexOf(e)));if(o(s.addOrUpdate))this._onMessage({...s,type:"append"});else if(c.length)try{const e=this._subscriptions.get(s.id).tile,i=await this._executePatchQuery(e,r,c,t);n(t),r.outFields=u,s.addOrUpdate.joinAttributes(i),this._onMessage({...s,end:s.end,type:"append"})}catch(d){}else this._onMessage({...s,type:"append"})}async _resendSubscription(e){if(e.empty)return this._onMessage({id:e.tile.id,addOrUpdate:null,end:!1,type:"append"});const t=e.signal;for(const r of e.requests.done)await this._resend(r,{signal:t});return i(e.edits)?this._onMessage(e.edits):void 0}async resend(){const e=Array.from(this._subscriptions.values());await Promise.all(e.map((e=>this._resendSubscription(e))))}}export{y as BaseFeatureSource};