@arcgis/core 4.26.0-next.20230119 → 4.26.0-next.20230121

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 (98) hide show
  1. package/arcade/ArcadeDate.js +1 -1
  2. package/arcade/Feature.js +1 -1
  3. package/arcade/featureset/support/shared.js +1 -1
  4. package/arcade/featureset/support/sqlUtils.js +1 -1
  5. package/arcade/languageUtils.js +1 -1
  6. package/arcade/lib/arcade-parser.js +1 -1
  7. package/arcade/lib/parser.js +1 -1
  8. package/arcade/lib/scanner.js +1 -1
  9. package/arcade/lib/types.js +1 -1
  10. package/arcade/validation/arcadeValidator.js +1 -1
  11. package/arcade/validation/diagnosticMessages.js +1 -1
  12. package/arcade/validation/languageKeywords.js +5 -0
  13. package/assets/esri/core/workers/RemoteClient.js +1 -1
  14. package/assets/esri/core/workers/chunks/{e6c6e3c9750829ec82c1.js → 09ac51aeb0f6fe16aa30.js} +1 -1
  15. package/assets/esri/core/workers/chunks/293594192932f0e00ecf.js +1 -0
  16. package/assets/esri/core/workers/chunks/4f4064eabbbc4a66f95a.js +1 -0
  17. package/assets/esri/core/workers/chunks/{0417369a1d563a6280ff.js → 63706a04e173000994db.js} +1 -1
  18. package/assets/esri/core/workers/chunks/6a90b1d73d5941ebb112.js +1 -0
  19. package/assets/esri/core/workers/chunks/{0c242aa92ab4f0c996db.js → 70f1fe5f36bc4abff2d2.js} +1 -1
  20. package/assets/esri/core/workers/chunks/96d4c50f74a9c0dcdb66.js +1 -0
  21. package/assets/esri/core/workers/chunks/b26a671d3523b8a48404.js +1 -0
  22. package/assets/esri/core/workers/chunks/{5dfed65b615b33588488.js → db96a2dc1879b4944cb8.js} +1 -1
  23. package/assets/esri/core/workers/chunks/fcf033c581f58d006cf6.js +1 -0
  24. package/assets/esri/core/workers/chunks/{5e872adb3a5e84c49865.js → fde8827bd7f1a97a6db3.js} +1 -1
  25. package/assets/esri/themes/base/widgets/_Editor.scss +9 -14
  26. package/assets/esri/themes/dark/main.css +1 -1
  27. package/assets/esri/themes/light/main.css +1 -1
  28. package/assets/esri/themes/light/view.css +1 -1
  29. package/chunks/languageUtils.js +1 -1
  30. package/core/scheduling.js +1 -1
  31. package/interfaces.d.ts +24 -12
  32. package/layers/StreamLayer.js +1 -1
  33. package/layers/VoxelWasmPerSceneView.js +1 -1
  34. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  35. package/layers/graphics/controllers/StreamController.js +1 -1
  36. package/layers/graphics/data/StreamFeatureManager.js +1 -1
  37. package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
  38. package/layers/graphics/sources/connections/WebSocketConnection.js +1 -1
  39. package/layers/support/FeatureReductionBinning.js +1 -1
  40. package/layers/support/FeatureReductionCluster.js +1 -1
  41. package/layers/support/StreamConnection.js +1 -1
  42. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  43. package/layers/support/rasterFormats/pixelRangeUtils.js +1 -1
  44. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  45. package/package.json +1 -1
  46. package/support/revision.js +1 -1
  47. package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
  48. package/views/2d/interactive/editingTools/MediaTransformToolsWrapper.js +1 -1
  49. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  50. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  51. package/views/2d/layers/StreamLayerView2D.js +1 -1
  52. package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
  53. package/views/2d/layers/features/schemaUtils.js +1 -1
  54. package/views/2d/layers/features/sources/GeoEventSource.js +1 -1
  55. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  56. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  57. package/views/2d/layers/support/FeatureLayerProxy.js +1 -1
  58. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  59. package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
  60. package/views/3d/layers/DynamicLayerView3D.js +1 -1
  61. package/views/3d/layers/I3SMeshView3D.js +1 -1
  62. package/views/3d/layers/I3SMeshViewLabeler.js +1 -1
  63. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  64. package/views/3d/layers/PointCloudWorker.js +1 -1
  65. package/views/3d/layers/RouteLayerView3D.js +1 -1
  66. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  67. package/views/3d/layers/SceneLayerView3D.js +1 -1
  68. package/views/3d/layers/StreamLayerView3D.js +1 -1
  69. package/views/3d/layers/TileLayerView3D.js +1 -1
  70. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  71. package/views/3d/layers/i3s/I3SLodHandling.js +1 -1
  72. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  73. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  74. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  75. package/views/3d/layers/i3s/I3SQueryEngine.js +1 -1
  76. package/views/3d/layers/i3s/PointCloudRendererUtil.js +1 -1
  77. package/views/3d/layers/i3s/PointCloudWorkerUtil.js +1 -1
  78. package/views/3d/layers/support/FeatureTileTree3D.js +1 -1
  79. package/views/3d/layers/support/I3STreeDebugger.js +1 -1
  80. package/views/3d/layers/support/SceneLayerViewRequiredFields.js +1 -1
  81. package/views/3d/terrain/TerrainSurface.js +1 -1
  82. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js +1 -1
  83. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  84. package/views/PopupView.js +1 -1
  85. package/views/SceneView.js +1 -1
  86. package/views/interactive/SegmentLabels.js +1 -1
  87. package/views/layers/ImageryLayerView.js +1 -1
  88. package/views/layers/SceneLayerView.js +1 -1
  89. package/views/layers/StreamLayerView.js +1 -1
  90. package/widgets/Editor.js +1 -1
  91. package/widgets/Fullscreen/FullscreenViewModel.js +1 -1
  92. package/widgets/Home/HomeViewModel.js +1 -1
  93. package/assets/esri/core/workers/chunks/0efee8d9fc5632346cb4.js +0 -1
  94. package/assets/esri/core/workers/chunks/10e715aa4ac96d7dd1b4.js +0 -1
  95. package/assets/esri/core/workers/chunks/2dfb17fa5b6a5d239942.js +0 -1
  96. package/assets/esri/core/workers/chunks/2e3962506c353b562a88.js +0 -1
  97. package/assets/esri/core/workers/chunks/7320e6d8f207399bc8f1.js +0 -1
  98. package/assets/esri/core/workers/chunks/a194f90ffe13b3d448b0.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/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 r from"../../../core/Collection.js";import s from"../../../core/Error.js";import has from"../../../core/has.js";import{clone as a}from"../../../core/lang.js";import n from"../../../core/Logger.js";import{applySome as o,isSome as l,destroyMaybe as u,unwrap as h,removeMaybe as d,isNone as c}from"../../../core/maybe.js";import{debounce as p,isAbortError as y}from"../../../core/promiseUtils.js";import{watch as g,whenOnce as f,syncAndInitial as m,initial as _}from"../../../core/reactiveUtils.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/FeatureEffectView.js";import S from"../../../layers/support/FeatureFilter.js";import w from"../../../rest/support/AggregateFeatureSet.js";import x from"../../../rest/support/FeatureSet.js";import U from"../../../rest/support/Query.js";import{MAX_FILTERS as C}from"../engine/webgl/definitions.js";import{LayerView2DMixin as F}from"./LayerView2D.js";import{createSchema as q}from"./features/schemaUtils.js";import{createOrReuseTileRenderer as I}from"./features/tileRenderers.js";import{isRendererSupported as O}from"./features/support/rendererUtils.js";import{findSizeVV as E,createClusterCountSizeVariable as T,injectDynamicLevelDependentSizeVisualVariable as V,isClusterCompatibleRenderer as j,createClusterRenderer as A}from"./support/clusterUtils.js";import N from"./support/FeatureCommandQueue.js";import Q from"./support/FeatureLayerProxy.js";import{toJSONGeometryType as L}from"./support/util.js";import{TileManager as k}from"../tiling/TileManager.js";import P from"../../layers/FeatureLayerView.js";import H from"../../layers/LayerView.js";import J from"../../layers/RefreshableLayerView.js";import{getWebGLCapabilities as z}from"../../webgl/capabilities.js";import M from"../../../geometry/Extent.js";function B(e){return e&&"openPorts"in e}let $=class extends(P(J(F(H)))){constructor(){super(...arguments),this._pipelineIsUpdating=!0,this._commandsQueue=new N({process:e=>{switch(e.type){case"processed-edit":return this._doEdit(e);case"refresh":return this._doRefresh(e.dataChanged);case"update":return this._doUpdate()}}}),this._visibilityOverrides=new Set,this._highlightIds=new Map,this._updateHighlight=p((async()=>this._proxy.setHighlight(Array.from(this._highlightIds.keys())))),this._uploadsLocked=!1,this._needsClusterSizeUpdate=!1,this.featureEffectView=new R,this._lastDefinitionExpression=null}destroy(){o(this._updateClusterSizeTask,(e=>e.remove())),this._proxy?.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)})),g((()=>this.featureEffect),(e=>{this.featureEffectView.featureEffect=e}),m)]),this.featureEffectView.endTransitions()}async _initProxy(){const e=this.layer;if("isTable"in e&&e.isTable)throw new s("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:this.layer});const t="feature"===e.type||"subtype-group"===e.type,i="capabilities"in e&&e.capabilities.operations.supportsQuery;if(t&&!i)throw new s("featurelayerview:query-not-supported","layer view requires a layer with query capability",{layer:e});this._proxy&&this._proxy.destroy();const r=this._createClientOptions();return this._set("_proxy",new Q({client:r})),this._proxy.when()}async _initServiceOptions(){return this._set("_serviceOptions",await this._createServiceOptions()),this._serviceOptions}get orderByFields(){return"stream"!==this._serviceOptions?.type?this._serviceOptions?.orderByFields:void 0}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 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="gdbVersion"in t?t.gdbVersion:void 0,o="historicMoment"in t?t.historicMoment?.getTime():void 0,{timeExtent:u}=this,h="customParameters"in t?JSON.stringify(t.customParameters):void 0,d="apiKey"in t?t.apiKey:void 0,c="stream"===t.type?`${JSON.stringify(t.geometryDefinition)}${t.definitionExpression}`:null,p=JSON.stringify(this.clips),y="featureReduction"in t?t.featureReduction?.toJSON():null,g="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)}`),""),m="subtypeCode"in this.layer&&this.layer.subtypeCode;return JSON.stringify({orderBy:g,sublayerHash:f,subtypeCode:m,filterHash:l(this.filter)&&this.filter.toJSON(),effectHash:l(this.featureEffect)&&this.featureEffect.toJSON(),streamFilter:c,gdbVersion:n,definitionExpression:r,historicMoment:o,availableFields:e,renderer:a,labelingInfo:s,timeExtent:u,floors:i,clipsHash:p,featureReduction:y,customParameters:h,apiKey:d})}highlight(e){let t;e instanceof i?t=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?t=[e]:r.isCollection(e)&&e.length>0?t=e.map((e=>e?.getObjectId())).toArray():Array.isArray(e)&&e.length>0&&(t="number"==typeof e[0]||"string"==typeof e[0]?e:e.map((e=>e?.getObjectId())));const s=t?.filter(l);return s&&s.length?(this._addHighlight(s),{remove:()=>this._removeHighlight(s)}):{remove:()=>{}}}hasHighlight(){return!!this._highlightIds.size}async hitTest(e,r){if(!this.tileRenderer)return null;const s=await this.tileRenderer.hitTest(r);if(0===s.length)return null;const{features:a,aggregates:n}=await this._proxy.getFeatures(s);return[...n.map((i=>this._createGraphicHit(e,t.fromJSON(i)))),...a.map((t=>this._createGraphicHit(e,i.fromJSON(t))))]}queryStatistics(){return this._proxy.queryStatistics()}async querySummaryStatistics(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.querySummaryStatistics(this._cleanUpQuery(e),r,i)}async queryAggregateSummaryStatistics(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.queryAggregateSummaryStatistics(this._cleanUpAggregateQuery(e),r,i)}async queryUniqueValues(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.queryUniqueValues(this._cleanUpQuery(e),r,i)}async queryAggregateUniqueValues(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.queryAggregateUniqueValues(this._cleanUpAggregateQuery(e),r,i)}async queryClassBreaks(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.queryClassBreaks(this._cleanUpQuery(e),r,i)}async queryAggregateClassBreaks(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.queryAggregateClassBreaks(this._cleanUpAggregateQuery(e),r,i)}async queryHistogram(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.queryHistogram(this._cleanUpQuery(e),r,i)}async queryAggregateHistogram(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.queryAggregateHistogram(this._cleanUpAggregateQuery(e),r,i)}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=x.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}queryVisibleFeatures(e,t){return this._proxy.queryVisibleFeatures(this._cleanUpQuery(e),t).then((e=>{const t=x.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}async queryAggregates(e,t){const i=await this._proxy.queryAggregates(this._cleanUpAggregateQuery(e),t),r=w.fromJSON(i);return r.features.forEach((e=>this._setLayersForFeature(e))),r}queryAggregateIds(e,t){return this._proxy.queryAggregateIds(this._cleanUpAggregateQuery(e),t)}queryAggregateCount(e,t){return this._proxy.queryAggregateCount(this._cleanUpAggregateQuery(e),t)}queryAggregateJSON(e,t){return this._proxy.queryAggregates(this._cleanUpAggregateQuery(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 k({acquireTile:e=>this._acquireTile(e),releaseTile:e=>this._releaseTile(e),tileInfoView:this.view.featuresTilingScheme,buffer:0}),this.handles.add(g((()=>this.renderingConfigHash),(()=>this._update()),_),"attach"),"stream"!==this.layer.type&&this.handles.add(this.layer.on("edits",(e=>this._edit(e))),"attach")}detach(){this._commandsQueue.clear(),this._proxy?.stop(),this.container.removeAllChildren(),this.handles.remove("attach"),this.tileRenderer?.uninstall(this.container),this.tileRenderer=null,this._tileStrategy=u(this._tileStrategy),this._tileRendererHash=null}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}isUpdating(){const e="renderer"in this.layer&&null!=this.layer.renderer,t=this._commandsQueue.updating,i=null!=this._updatingRequiredFieldsPromise,r=!this._proxy||!this._proxy.isReady,s=this._pipelineIsUpdating,a=null==this.tileRenderer||this.tileRenderer?.updating,n=e&&(t||i||r||s||a);return has("esri-2d-log-updating")&&console.log(`Updating FLV2D: ${n}\n -> hasRenderer ${e}\n -> hasPendingCommand ${t}\n -> updatingRequiredFields ${i}\n -> updatingProxy ${r}\n -> updatingPipeline ${s}\n -> updatingTileRenderer ${a}\n`),n}_createClientOptions(){return{setUpdating:e=>{this._set("_pipelineIsUpdating",e)},emitEvent:e=>{this.emit(e.name,e.event)}}}async _detectQueryMode(e){const t="path"in e,i="editingInfo"in this.layer&&this.layer.editingInfo?.lastEditDate,r="refreshInterval"in this.layer&&!!this.layer.refreshInterval,s=!i&&r;if(t&&("feature"===this.layer.type||"subtype-group"===this.layer.type)&&"point"===this.layer.geometryType&&this.layer.capabilities.query.supportsPagination&&!this.layer.capabilities.operations.supportsEditing&&!s&&has("featurelayer-snapshot-enabled"))try{const e=await this.layer.queryFeatureCount();if(e<=has("featurelayer-snapshot-point-min-threshold"))return{mode:"snapshot",featureCount:e};const t=has("featurelayer-snapshot-point-max-threshold"),i=has("featurelayer-snapshot-point-coverage"),r=this.view.extent,s=h(this.layer.fullExtent),a=s?.clone().intersection(r),n=l(a)?a.width*a.height:0,o=s?.width*s?.height;if(e<=t&&(0===o?0:n/o)>=i)return{mode:"snapshot",featureCount:e}}catch(a){n.getLogger(this.declaredClass).warn("mapview-feature-layer","Encountered an error when querying for featureCount",{error:a})}return{mode:"on-demand"}}async _createServiceOptions(){const e=this.layer;if("stream"===e.type)return null;const{capabilities:t,objectIdField:i}=e,r=e.fields.map((e=>e.toJSON())),s=l(e.fullExtent)?e.fullExtent.toJSON():null,n=L(e.geometryType),o="timeInfo"in e&&e.timeInfo&&e.timeInfo.toJSON()||null,u=e.spatialReference?e.spatialReference.toJSON():null,h="feature"===e.type?e.globalIdField:null;let d;"ogc-feature"===e.type?d=e.source.getSource():B(e.source)?d=await e.source.openPorts():e.parsedUrl&&(d=a(e.parsedUrl),"dynamicDataSource"in e&&e.dynamicDataSource&&(d.query={layer:JSON.stringify({source:e.dynamicDataSource})}));const c="datesInUnknownTimezone"in this.layer&&this.layer.datesInUnknownTimezone,p=("subtypeField"in this.layer?this.layer.subtypeField:null)??null,{mode:y,featureCount:g}=await this._detectQueryMode(d);let f=this.layer.objectIdField;if("feature"===this.layer.type&&l(this.layer.orderBy)&&this.layer.orderBy.length){const e=!this.layer.orderBy[0].valueExpression&&this.layer.orderBy[0].field;e&&(f=e)}return{type:y,timeReferenceUnknownClient:c,subtypeField:p,featureCount:g,globalIdField:h,maxRecordCount:t.query.maxRecordCount,tileMaxRecordCount:t.query.tileMaxRecordCount,capabilities:t,fields:r,fullExtent:s,geometryType:n,objectIdField:i,source:d,timeInfo:o,spatialReference:u,orderByFields:f,datesInUnknownTimezone:c,dateFieldsTimeReference:("dateFieldsTimeReference"in this.layer?this.layer.dateFieldsTimeReference?.toJSON():null)||null,preferredTimeReference:("preferredTimeReference"in this.layer?this.layer.preferredTimeReference?.toJSON():null)||null,editFieldsInfo:"editFieldsInfo"in this.layer?this.layer.editFieldsInfo?.toJSON():null}}async _createMemoryServiceOptions(e){const t=await e.openPorts();return{...this._createServiceOptions(),type:"memory",source:t}}_cleanUpQuery(e){const t=U.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t}_cleanUpAggregateQuery(e){const t=U.from(e)||this.createAggregateQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(e){if(this.suspended)return void this._clearTiles();return this._validateEdit(e)?this._commandsQueue.push({type:"edit",edits:e}):void 0}async doRefresh(e){if(this.attached&&this._tileStrategy.tileKeys().length)return this.suspended&&e?void this._clearTiles():this._commandsQueue.push({type:"refresh",dataChanged:e})}_clearTiles(){this._tileStrategy.tileKeys().length&&(this._proxy.updateTiles({added:[],removed:this._tileStrategy.tileKeys()}),this._tileStrategy.clear(),this.requestUpdate(),this._commandsQueue.clear(),this._update())}_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?(n.getLogger(this.declaredClass).error(new s("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{featureEffectView:t,filter:i}=this;if(await this._updateRequiredFields(),this.destroyed)return;const{renderer:r}=this._getEffectiveRenderer();this._set("_effectiveRenderer",r);const s=this._createSchemaConfig(),a=this._createConfiguration(s,i,t.filter),o=this._lastDefinitionExpression!==a.schema.source.definitionExpression;this._lastDefinitionExpression=a.schema.source.definitionExpression;const l=a.schema.tileRenderer,u=this._createTileRendererHash(l);if("snapshot"===this._serviceOptions.type&&(a.schema.source.initialFeatureCount=this._serviceOptions.featureCount),u!==this._tileRendererHash){await this._initTileRenderer(l,r);const e=this.layer,t="stream"===e.type?await this._initServiceOptions():this._serviceOptions;this.tileRenderer.onConfigUpdate(r),"stream"!==e.type&&B(e.source)&&(t.source=await e.source.openPorts());const i={added:this._tileStrategy.tileKeys(),removed:[]};await this._proxy.startup(this.view.featuresTilingScheme,a,t,i),this.hasHighlight()&&await this._proxy.setHighlight(Array.from(this._highlightIds.keys())),await this._onceTilesUpdated(),this.tileRenderer.onConfigUpdate(r)}else{"snapshot"===this._serviceOptions.type&&o&&(a.schema.source.changedFeatureCount=await this.layer.queryFeatureCount());const t=await this._proxy.update(a);(t.mesh||t.targets?.aggregate)&&this._lockGPUUploads();try{await this._proxy.applyUpdate(t)}catch(e){y(e)||n.getLogger(this.declaredClass).error(e)}(t.mesh||t.targets?.aggregate)&&this._unlockGPUUploads(),this.tileRenderer.onConfigUpdate(r),this._updateClusterSizeVariable(),this._forceAttributeTextureUpload()}this._tileRendererHash=u,this.tileRenderer.invalidateLabels(),this.requestUpdate()}catch(e){}}async _doEdit(e){try{await this._proxy.onEdits(e)}catch(t){y(t),0}}async _doRefresh(e){this._lockGPUUploads();try{let t;e&&"snapshot"===this.queryMode&&"queryFeatureCount"in this.layer&&(t=await this.layer.queryFeatureCount()),await this._proxy.refresh({dataChanged:e,featureCount:t})}catch(i){y(i),0}this._unlockGPUUploads();const t=this.layer;t&&"featureReduction"in t&&t.featureReduction&&this._updateClusterSizeVariable()}_updateClusterSizeVariable(){this._needsClusterSizeUpdate&&(this.tileRenderer.onConfigUpdate(this._effectiveRenderer),this._needsClusterSizeUpdate=!1)}_createUpdateClusterSizeTask(e,t){return g((()=>this._aggregateValueRanges),(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=E(e.visualVariables);if(l(r)&&"cluster_count"===r.field){const s=e.visualVariables.indexOf(r);e.visualVariables[s]=T(t,i);const a=e.clone();a.dynamicClusterSize=!0,this._set("_effectiveRenderer",a)}}}_getEffectiveRenderer(){const e=this.layer,t="renderer"in e?e.renderer:null,i="featureReduction"in e?e.featureReduction:null;if(this._updateClusterSizeTask=d(this._updateClusterSizeTask),i&&"renderer"in i&&i.renderer&&!i.renderer.authoringInfo?.isAutoGenerated){const e=i.fields;if("cluster"===i.type){const{renderer:t,didInject:r}=V(i.renderer,i,this._aggregateValueRanges);return r&&(this._updateClusterSizeTask=this._createUpdateClusterSizeTask(t,i)),{renderer:t,aggregateFields:e,featureReduction:i}}return{renderer:i.renderer,aggregateFields:e,featureReduction:i}}if(i&&"cluster"===i.type&&t&&j(t)){const e=i,r=[],s=A(r,t,e,this._aggregateValueRanges,!0);return this._updateClusterSizeTask=this._createUpdateClusterSizeTask(s,e),{renderer:s,aggregateFields:r,featureReduction:i}}return{renderer:t,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,t){const i=await I(e,{layerView:this,tileInfoView:this.view.featuresTilingScheme,layer:this.layer});return this.tileRenderer&&(this._tileStrategy.clear(),this.tileRenderer.uninstall(this.container),this.tileRenderer=u(this.tileRenderer)),this.destroyed?null:(this._proxy.tileRenderer=i,this._set("tileRenderer",i),this.tileRenderer.install(this.container),this.tileRenderer.onConfigUpdate(t),this.requestUpdate(),this.tileRenderer)}_createTileRendererHash(e){return`${e.type}`}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=l(e)?e.timeExtent:null,i=l(this.timeExtent)&&l(t)?this.timeExtent.intersection(t):this.timeExtent||t;let r=null;const s="floorInfo"in this.layer&&this.layer.floorInfo;if(s){const t=l(e)?e.where:null;r=this._addFloorFilterClause(t)}if(!this._visibilityOverrides.size&&!i&&!s)return l(e)?e.toJSON():null;(e=l(e)&&e.clone()||new S).timeExtent=i,r&&(e.where=r);const a=e.toJSON();return a.hiddenIds=Array.from(this._visibilityOverrides),a}_addFloorFilterClause(e){const t=this.layer;let i=e||"";if("floorInfo"in t&&t.floorInfo){let e=this.view.floors;if(!e||!e.length)return i;t.floorInfo.viewAllLevelIds?.length&&(e=t.floorInfo.viewAllLevelIds);const r=e.filter((e=>""!==e)).map((e=>"'"+e+"'"));r.push("''");const s=t.floorInfo.floorField;let a="("+s+" IN ({ids}) OR "+s+" IS NULL)";if(a=a.replace("{ids}",r.join(", ")),l(i)&&i.includes(s)){let e=new RegExp("AND \\("+s+".*NULL\\)","g");i=i.replace(e,""),e=new RegExp("\\("+s+".*NULL\\)","g"),i=i.replace(e,""),i=i.replace(/\s+/g," ").trim()}i=""!==i?"("+i+") AND "+a:a}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:void 0,a=new Array(C),n=this._injectOverrides(t);a[0]=n,a[1]=l(i)?i.toJSON():null;const o=q(e);if(c(o))return null;const u=z("2d");return{availableFields:this.availableFields,gdbVersion:s,historicMoment:r,devicePixelRatio:window.devicePixelRatio||1,filters:a,schema:o,supportsTextureFloat:u.supportsTextureFloat,maxTextureSize:u.maxTextureSize}}_hasRequiredSupport(e){return!("renderer"in e)||O(e.renderer)}_onceTilesUpdated(){return this.requestUpdate(),f((()=>!this._pipelineIsUpdating))}_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=this.layer;return{renderer:"renderer"in e?e.renderer:null,spatialReference:e.spatialReference,timeExtent:"timeExtent"in e?e.timeExtent:null,definitionExpression:e.definitionExpression,featureReduction:"featureReduction"in e?e.featureReduction:null,fields:e.fields,geometryType:e.geometryType,historicMoment:"historicMoment"in e?e.historicMoment:null,labelsVisible:"labelsVisible"in e&&e.labelsVisible,labelingInfo:"labelingInfo"in e?e.labelingInfo:null,availableFields:this.availableFields,featureEffect:this.featureEffect,filter:this.filter,gdbVersion:"gdbVersion"in e?e.gdbVersion:null,pixelBuffer:0,orderBy:"orderBy"in e&&e.orderBy?e.orderBy:null,customParameters:{..."customParameters"in e?e.customParameters:void 0,token:"apiKey"in e?e.apiKey??void 0:void 0},subtypeCode:"subtypeCode"in e?e.subtypeCode:void 0,subtypeField:"subtypeField"in e?e.subtypeField: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=>{y(e)||n.getLogger(this.declaredClass).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)||n.getLogger(this.declaredClass).error(e)}))}_setLayersForFeature(e){const t=this.layer;e.layer=t,e.sourceLayer=t}_createGraphicHit(e,t){return this._setLayersForFeature(t),l(t.geometry)&&(t.geometry.spatialReference=this.view.spatialReference),{type:"graphic",graphic:t,layer:this.layer,mapPoint:e}}};e([v()],$.prototype,"_serviceOptions",void 0),e([v()],$.prototype,"_proxy",void 0),e([v()],$.prototype,"_pipelineIsUpdating",void 0),e([v()],$.prototype,"_effectiveRenderer",void 0),e([v()],$.prototype,"_aggregateValueRanges",void 0),e([v()],$.prototype,"_commandsQueue",void 0),e([v()],$.prototype,"featureEffectView",void 0),e([v()],$.prototype,"labelsVisible",null),e([v({readOnly:!0})],$.prototype,"queryMode",null),e([v()],$.prototype,"renderingConfigHash",null),e([v()],$.prototype,"tileRenderer",void 0),e([v()],$.prototype,"updating",void 0),$=e([b("esri.views.2d.layers.FeatureLayerView2D")],$);const G=$;export{G 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 r from"../../../core/Collection.js";import s from"../../../core/Error.js";import has from"../../../core/has.js";import{clone as a}from"../../../core/lang.js";import n from"../../../core/Logger.js";import{applySome as o,isSome as l,destroyMaybe as h,unwrap as u,removeMaybe as d,isNone as c}from"../../../core/maybe.js";import{debounce as p,isAbortError as y}from"../../../core/promiseUtils.js";import{watch as g,whenOnce as f,syncAndInitial as m,initial as _}from"../../../core/reactiveUtils.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/FeatureEffectView.js";import S from"../../../layers/support/FeatureFilter.js";import x from"../../../rest/support/AggregateFeatureSet.js";import w from"../../../rest/support/FeatureSet.js";import F from"../../../rest/support/Query.js";import{MAX_FILTERS as U}from"../engine/webgl/definitions.js";import{LayerView2DMixin as C}from"./LayerView2D.js";import{createSchema as q}from"./features/schemaUtils.js";import{createOrReuseTileRenderer as I}from"./features/tileRenderers.js";import{isRendererSupported as O}from"./features/support/rendererUtils.js";import{findSizeVV as E,createClusterCountSizeVariable as T,injectDynamicLevelDependentSizeVisualVariable as V,isClusterCompatibleRenderer as j,createClusterRenderer as A}from"./support/clusterUtils.js";import N from"./support/FeatureCommandQueue.js";import Q from"./support/FeatureLayerProxy.js";import{toJSONGeometryType as L}from"./support/util.js";import{TileManager as k}from"../tiling/TileManager.js";import P from"../../layers/FeatureLayerView.js";import H from"../../layers/LayerView.js";import J from"../../layers/RefreshableLayerView.js";import{getWebGLCapabilities as z}from"../../webgl/capabilities.js";import M from"../../../geometry/Extent.js";function B(e){return e&&"openPorts"in e}let $=class extends(P(J(C(H)))){constructor(){super(...arguments),this._pipelineIsUpdating=!0,this._commandsQueue=new N({process:e=>{switch(e.type){case"processed-edit":return this._doEdit(e);case"refresh":return this._doRefresh(e.dataChanged);case"update":return this._doUpdate()}}}),this._visibilityOverrides=new Set,this._highlightIds=new Map,this._updateHighlight=p((async()=>this._proxy.setHighlight(Array.from(this._highlightIds.keys())))),this._uploadsLocked=!1,this._needsClusterSizeUpdate=!1,this.featureEffectView=new R,this._lastDefinitionExpression=null}destroy(){o(this._updateClusterSizeTask,(e=>e.remove())),this._proxy?.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)})),g((()=>this.featureEffect),(e=>{this.featureEffectView.featureEffect=e}),m)]),this.featureEffectView.endTransitions()}async _initProxy(){const e=this.layer;if("isTable"in e&&e.isTable)throw new s("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:this.layer});const t="feature"===e.type||"subtype-group"===e.type,i="capabilities"in e&&e.capabilities.operations.supportsQuery;if(t&&!i)throw new s("featurelayerview:query-not-supported","layer view requires a layer with query capability",{layer:e});this._proxy&&this._proxy.destroy();const r=this._createClientOptions();return this._set("_proxy",new Q({client:r})),this._proxy.when()}async _initServiceOptions(){return this._set("_serviceOptions",await this._createServiceOptions()),this._serviceOptions}get _effectiveFeatureReduction(){if(!("featureReduction"in this.layer))return null;const e=this.layer.featureReduction;return e&&(!("maxScale"in e)||!e.maxScale||e.maxScale<this.view.scale)?e:null}get orderByFields(){return"stream"!==this._serviceOptions?.type?this._serviceOptions?.orderByFields:void 0}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 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="gdbVersion"in t?t.gdbVersion:void 0,o="historicMoment"in t?t.historicMoment?.getTime():void 0,{timeExtent:h}=this,u="customParameters"in t?JSON.stringify(t.customParameters):void 0,d="apiKey"in t?t.apiKey:void 0,c="stream"===t.type?`${JSON.stringify(t.geometryDefinition)}${t.definitionExpression}`:null,p=JSON.stringify(this.clips),y=this._effectiveFeatureReduction?.toJSON(),g="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)}`),""),m="subtypeCode"in this.layer&&this.layer.subtypeCode;return JSON.stringify({orderBy:g,sublayerHash:f,subtypeCode:m,filterHash:l(this.filter)&&this.filter.toJSON(),effectHash:l(this.featureEffect)&&this.featureEffect.toJSON(),streamFilter:c,gdbVersion:n,definitionExpression:r,historicMoment:o,availableFields:e,renderer:a,labelingInfo:s,timeExtent:h,floors:i,clipsHash:p,featureReduction:y,customParameters:u,apiKey:d})}highlight(e){let t;e instanceof i?t=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?t=[e]:r.isCollection(e)&&e.length>0?t=e.map((e=>e?.getObjectId())).toArray():Array.isArray(e)&&e.length>0&&(t="number"==typeof e[0]||"string"==typeof e[0]?e:e.map((e=>e?.getObjectId())));const s=t?.filter(l);return s&&s.length?(this._addHighlight(s),{remove:()=>this._removeHighlight(s)}):{remove:()=>{}}}hasHighlight(){return!!this._highlightIds.size}async hitTest(e,r){if(!this.tileRenderer)return null;const s=await this.tileRenderer.hitTest(r);if(0===s.length)return null;const{features:a,aggregates:n}=await this._proxy.getFeatures(s);return[...n.map((i=>this._createGraphicHit(e,t.fromJSON(i)))),...a.map((t=>this._createGraphicHit(e,i.fromJSON(t))))]}queryStatistics(){return this._proxy.queryStatistics()}async querySummaryStatistics(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.querySummaryStatistics(this._cleanUpQuery(e),r,i)}async queryAggregateSummaryStatistics(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.queryAggregateSummaryStatistics(this._cleanUpAggregateQuery(e),r,i)}async queryUniqueValues(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.queryUniqueValues(this._cleanUpQuery(e),r,i)}async queryAggregateUniqueValues(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.queryAggregateUniqueValues(this._cleanUpAggregateQuery(e),r,i)}async queryClassBreaks(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.queryClassBreaks(this._cleanUpQuery(e),r,i)}async queryAggregateClassBreaks(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.queryAggregateClassBreaks(this._cleanUpAggregateQuery(e),r,i)}async queryHistogram(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.queryHistogram(this._cleanUpQuery(e),r,i)}async queryAggregateHistogram(e,t,i){const r={...t,scale:this.view.scale};return this._proxy.queryAggregateHistogram(this._cleanUpAggregateQuery(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}))}queryVisibleFeatures(e,t){return this._proxy.queryVisibleFeatures(this._cleanUpQuery(e),t).then((e=>{const t=w.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}async queryAggregates(e,t){const i=await this._proxy.queryAggregates(this._cleanUpAggregateQuery(e),t),r=x.fromJSON(i);return r.features.forEach((e=>this._setLayersForFeature(e))),r}queryAggregateIds(e,t){return this._proxy.queryAggregateIds(this._cleanUpAggregateQuery(e),t)}queryAggregateCount(e,t){return this._proxy.queryAggregateCount(this._cleanUpAggregateQuery(e),t)}queryAggregateJSON(e,t){return this._proxy.queryAggregates(this._cleanUpAggregateQuery(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 k({acquireTile:e=>this._acquireTile(e),releaseTile:e=>this._releaseTile(e),tileInfoView:this.view.featuresTilingScheme,buffer:0}),this.handles.add(g((()=>this.renderingConfigHash),(()=>this._update()),_),"attach"),"stream"!==this.layer.type&&this.handles.add(this.layer.on("edits",(e=>this._edit(e))),"attach")}detach(){this._commandsQueue.clear(),this._proxy?.stop(),this.container.removeAllChildren(),this.handles.remove("attach"),this.tileRenderer?.uninstall(this.container),this.tileRenderer=null,this._tileStrategy=h(this._tileStrategy),this._tileRendererHash=null}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}isUpdating(){const e="renderer"in this.layer&&null!=this.layer.renderer,t=this._commandsQueue.updating,i=null!=this._updatingRequiredFieldsPromise,r=!this._proxy||!this._proxy.isReady,s=this._pipelineIsUpdating,a=null==this.tileRenderer||this.tileRenderer?.updating,n=e&&(t||i||r||s||a);return has("esri-2d-log-updating")&&console.log(`Updating FLV2D: ${n}\n -> hasRenderer ${e}\n -> hasPendingCommand ${t}\n -> updatingRequiredFields ${i}\n -> updatingProxy ${r}\n -> updatingPipeline ${s}\n -> updatingTileRenderer ${a}\n`),n}_createClientOptions(){return{setUpdating:e=>{this._set("_pipelineIsUpdating",e)},emitEvent:e=>{this.emit(e.name,e.event)}}}async _detectQueryMode(e){const t="path"in e,i="editingInfo"in this.layer&&this.layer.editingInfo?.lastEditDate,r="refreshInterval"in this.layer&&!!this.layer.refreshInterval,s=!i&&r;if(t&&("feature"===this.layer.type||"subtype-group"===this.layer.type)&&"point"===this.layer.geometryType&&this.layer.capabilities.query.supportsPagination&&!this.layer.capabilities.operations.supportsEditing&&!s&&has("featurelayer-snapshot-enabled"))try{const e=await this.layer.queryFeatureCount();if(e<=has("featurelayer-snapshot-point-min-threshold"))return{mode:"snapshot",featureCount:e};const t=has("featurelayer-snapshot-point-max-threshold"),i=has("featurelayer-snapshot-point-coverage"),r=this.view.extent,s=u(this.layer.fullExtent),a=s?.clone().intersection(r),n=l(a)?a.width*a.height:0,o=s?.width*s?.height;if(e<=t&&(0===o?0:n/o)>=i)return{mode:"snapshot",featureCount:e}}catch(a){n.getLogger(this.declaredClass).warn("mapview-feature-layer","Encountered an error when querying for featureCount",{error:a})}return{mode:"on-demand"}}async _createServiceOptions(){const e=this.layer;if("stream"===e.type)return null;const{capabilities:t,objectIdField:i}=e,r=e.fields.map((e=>e.toJSON())),s=l(e.fullExtent)?e.fullExtent.toJSON():null,n=L(e.geometryType),o="timeInfo"in e&&e.timeInfo&&e.timeInfo.toJSON()||null,h=e.spatialReference?e.spatialReference.toJSON():null,u="feature"===e.type?e.globalIdField:null;let d;"ogc-feature"===e.type?d=e.source.getSource():B(e.source)?d=await e.source.openPorts():e.parsedUrl&&(d=a(e.parsedUrl),"dynamicDataSource"in e&&e.dynamicDataSource&&(d.query={layer:JSON.stringify({source:e.dynamicDataSource})}));const c="datesInUnknownTimezone"in this.layer&&this.layer.datesInUnknownTimezone,p=("subtypeField"in this.layer?this.layer.subtypeField:null)??null,{mode:y,featureCount:g}=await this._detectQueryMode(d);let f=this.layer.objectIdField;if("feature"===this.layer.type&&l(this.layer.orderBy)&&this.layer.orderBy.length){const e=!this.layer.orderBy[0].valueExpression&&this.layer.orderBy[0].field;e&&(f=e)}return{type:y,timeReferenceUnknownClient:c,subtypeField:p,featureCount:g,globalIdField:u,maxRecordCount:t.query.maxRecordCount,tileMaxRecordCount:t.query.tileMaxRecordCount,capabilities:t,fields:r,fullExtent:s,geometryType:n,objectIdField:i,source:d,timeInfo:o,spatialReference:h,orderByFields:f,datesInUnknownTimezone:c,dateFieldsTimeReference:("dateFieldsTimeReference"in this.layer?this.layer.dateFieldsTimeReference?.toJSON():null)||null,preferredTimeReference:("preferredTimeReference"in this.layer?this.layer.preferredTimeReference?.toJSON():null)||null,editFieldsInfo:"editFieldsInfo"in this.layer?this.layer.editFieldsInfo?.toJSON():null}}async _createMemoryServiceOptions(e){const t=await e.openPorts();return{...this._createServiceOptions(),type:"memory",source:t}}_cleanUpQuery(e){const t=F.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t}_cleanUpAggregateQuery(e){const t=F.from(e)||this.createAggregateQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(e){if(this.suspended)return void this._clearTiles();return this._validateEdit(e)?this._commandsQueue.push({type:"edit",edits:e}):void 0}async doRefresh(e){if(this.attached&&this._tileStrategy.tileKeys().length)return this.suspended&&e?void this._clearTiles():this._commandsQueue.push({type:"refresh",dataChanged:e})}_clearTiles(){this._tileStrategy.tileKeys().length&&(this._proxy.updateTiles({added:[],removed:this._tileStrategy.tileKeys()}),this._tileStrategy.clear(),this.requestUpdate(),this._commandsQueue.clear(),this._update())}_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?(n.getLogger(this.declaredClass).error(new s("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{featureEffectView:t,filter:i}=this;if(await this._updateRequiredFields(),this.destroyed)return;const{renderer:r}=this._getEffectiveRenderer();this._set("_effectiveRenderer",r);const s=this._createSchemaConfig(),a=this._createConfiguration(s,i,t.filter),o=this._lastDefinitionExpression!==a.schema.source.definitionExpression;this._lastDefinitionExpression=a.schema.source.definitionExpression;const l=a.schema.tileRenderer,h=this._createTileRendererHash(l);if("snapshot"===this._serviceOptions.type&&(a.schema.source.initialFeatureCount=this._serviceOptions.featureCount),h!==this._tileRendererHash){await this._initTileRenderer(l,r);const e=this.layer,t="stream"===e.type?await this._initServiceOptions():this._serviceOptions;this.tileRenderer.onConfigUpdate(r),"stream"!==e.type&&B(e.source)&&(t.source=await e.source.openPorts());const i={added:this._tileStrategy.tileKeys(),removed:[]};await this._proxy.startup(this.view.featuresTilingScheme,a,t,i),this.hasHighlight()&&await this._proxy.setHighlight(Array.from(this._highlightIds.keys())),await this._onceTilesUpdated(),this.tileRenderer.onConfigUpdate(r)}else{"snapshot"===this._serviceOptions.type&&o&&(a.schema.source.changedFeatureCount=await this.layer.queryFeatureCount());const t=await this._proxy.update(a);(t.mesh||t.targets?.aggregate)&&this._lockGPUUploads();try{await this._proxy.applyUpdate(t)}catch(e){y(e)||n.getLogger(this.declaredClass).error(e)}(t.mesh||t.targets?.aggregate)&&this._unlockGPUUploads(),this.tileRenderer.onConfigUpdate(r),this._updateClusterSizeVariable(),this._forceAttributeTextureUpload()}this._tileRendererHash=h,this.tileRenderer.invalidateLabels(),this.requestUpdate()}catch(e){}}async _doEdit(e){try{await this._proxy.onEdits(e)}catch(t){y(t),0}}async _doRefresh(e){this._lockGPUUploads();try{let t;e&&"snapshot"===this.queryMode&&"queryFeatureCount"in this.layer&&(t=await this.layer.queryFeatureCount()),await this._proxy.refresh({dataChanged:e,featureCount:t})}catch(t){y(t),0}this._unlockGPUUploads(),this._effectiveFeatureReduction&&this._updateClusterSizeVariable()}_updateClusterSizeVariable(){this._needsClusterSizeUpdate&&(this.tileRenderer.onConfigUpdate(this._effectiveRenderer),this._needsClusterSizeUpdate=!1)}_createUpdateClusterSizeTask(e,t){return g((()=>this._aggregateValueRanges),(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=E(e.visualVariables);if(l(r)&&"cluster_count"===r.field){const s=e.visualVariables.indexOf(r);e.visualVariables[s]=T(t,i);const a=e.clone();a.dynamicClusterSize=!0,this._set("_effectiveRenderer",a)}}}_getEffectiveRenderer(){const e=this.layer,t="renderer"in e?e.renderer:null,i=this._effectiveFeatureReduction;if(this._updateClusterSizeTask=d(this._updateClusterSizeTask),i&&"renderer"in i&&i.renderer&&!i.renderer.authoringInfo?.isAutoGenerated){const e=i.fields;if("cluster"===i.type){const{renderer:t,didInject:r}=V(i.renderer,i,this._aggregateValueRanges);return r&&(this._updateClusterSizeTask=this._createUpdateClusterSizeTask(t,i)),{renderer:t,aggregateFields:e,featureReduction:i}}return{renderer:i.renderer,aggregateFields:e,featureReduction:i}}if(i&&"cluster"===i.type&&t&&j(t)){const e=i,r=[],s=A(r,t,e,this._aggregateValueRanges,!0);return this._updateClusterSizeTask=this._createUpdateClusterSizeTask(s,e),{renderer:s,aggregateFields:r,featureReduction:i}}return{renderer:t,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,t){const i=await I(e,{layerView:this,tileInfoView:this.view.featuresTilingScheme,layer:this.layer});return this.tileRenderer&&(this._tileStrategy.clear(),this.tileRenderer.uninstall(this.container),this.tileRenderer=h(this.tileRenderer)),this.destroyed?null:(this._proxy.tileRenderer=i,this._set("tileRenderer",i),this.tileRenderer.install(this.container),this.tileRenderer.onConfigUpdate(t),this.requestUpdate(),this.tileRenderer)}_createTileRendererHash(e){return`${e.type}`}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=l(e)?e.timeExtent:null,i=l(this.timeExtent)&&l(t)?this.timeExtent.intersection(t):this.timeExtent||t;let r=null;const s="floorInfo"in this.layer&&this.layer.floorInfo;if(s){const t=l(e)?e.where:null;r=this._addFloorFilterClause(t)}if(!this._visibilityOverrides.size&&!i&&!s)return l(e)?e.toJSON():null;(e=l(e)&&e.clone()||new S).timeExtent=i,r&&(e.where=r);const a=e.toJSON();return a.hiddenIds=Array.from(this._visibilityOverrides),a}_addFloorFilterClause(e){const t=this.layer;let i=e||"";if("floorInfo"in t&&t.floorInfo){let e=this.view.floors;if(!e||!e.length)return i;t.floorInfo.viewAllLevelIds?.length&&(e=t.floorInfo.viewAllLevelIds);const r=e.filter((e=>""!==e)).map((e=>"'"+e+"'"));r.push("''");const s=t.floorInfo.floorField;let a="("+s+" IN ({ids}) OR "+s+" IS NULL)";if(a=a.replace("{ids}",r.join(", ")),l(i)&&i.includes(s)){let e=new RegExp("AND \\("+s+".*NULL\\)","g");i=i.replace(e,""),e=new RegExp("\\("+s+".*NULL\\)","g"),i=i.replace(e,""),i=i.replace(/\s+/g," ").trim()}i=""!==i?"("+i+") AND "+a:a}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:void 0,a=new Array(U),n=this._injectOverrides(t);a[0]=n,a[1]=l(i)?i.toJSON():null;const o=q(e);if(c(o))return null;const h=z("2d");return{availableFields:this.availableFields,gdbVersion:s,historicMoment:r,devicePixelRatio:window.devicePixelRatio||1,filters:a,schema:o,supportsTextureFloat:h.supportsTextureFloat,maxTextureSize:h.maxTextureSize}}_hasRequiredSupport(e){return!("renderer"in e)||O(e.renderer)}_onceTilesUpdated(){return this.requestUpdate(),f((()=>!this._pipelineIsUpdating))}_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=this.layer;return{renderer:"renderer"in e?e.renderer:null,spatialReference:e.spatialReference,timeExtent:"timeExtent"in e?e.timeExtent:null,definitionExpression:e.definitionExpression,featureReduction:this._effectiveFeatureReduction,fields:e.fields,geometryType:e.geometryType,historicMoment:"historicMoment"in e?e.historicMoment:null,labelsVisible:"labelsVisible"in e&&e.labelsVisible,labelingInfo:"labelingInfo"in e?e.labelingInfo:null,availableFields:this.availableFields,featureEffect:this.featureEffect,filter:this.filter,gdbVersion:"gdbVersion"in e?e.gdbVersion:null,pixelBuffer:0,orderBy:"orderBy"in e&&e.orderBy?e.orderBy:null,customParameters:{..."customParameters"in e?e.customParameters:void 0,token:"apiKey"in e?e.apiKey??void 0:void 0},subtypeCode:"subtypeCode"in e?e.subtypeCode:void 0,subtypeField:"subtypeField"in e?e.subtypeField: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=>{y(e)||n.getLogger(this.declaredClass).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)||n.getLogger(this.declaredClass).error(e)}))}_setLayersForFeature(e){const t=this.layer;e.layer=t,e.sourceLayer=t}_createGraphicHit(e,t){return this._setLayersForFeature(t),l(t.geometry)&&(t.geometry.spatialReference=this.view.spatialReference),{type:"graphic",graphic:t,layer:this.layer,mapPoint:e}}};e([v()],$.prototype,"_serviceOptions",void 0),e([v()],$.prototype,"_proxy",void 0),e([v()],$.prototype,"_pipelineIsUpdating",void 0),e([v()],$.prototype,"_effectiveRenderer",void 0),e([v()],$.prototype,"_effectiveFeatureReduction",null),e([v()],$.prototype,"_aggregateValueRanges",void 0),e([v()],$.prototype,"_commandsQueue",void 0),e([v()],$.prototype,"featureEffectView",void 0),e([v()],$.prototype,"labelsVisible",null),e([v({readOnly:!0})],$.prototype,"queryMode",null),e([v()],$.prototype,"renderingConfigHash",null),e([v()],$.prototype,"tileRenderer",void 0),e([v()],$.prototype,"updating",void 0),$=e([b("esri.views.2d.layers.FeatureLayerView2D")],$);const G=$;export{G 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.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{isNone as r,isSome as s}from"../../../core/maybe.js";import{watch as i}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import n from"../../../rest/support/FeatureSet.js";import c from"./FeatureLayerView2D.js";import{toJSONGeometryType as p}from"./support/util.js";function l(e,t){if(r(e)&&r(t))return null;const i={};return s(t)&&(i.geometry=t.toJSON()),s(e)&&(i.where=e),i}let d=class extends c{constructor(){super(...arguments),this._enabledDataReceived=!1,this.errorString=null,this.connectionStatus="disconnected"}initialize(){this.handles.add([i((()=>this.layer?.purgeOptions),(()=>this._update())),i((()=>this.suspended),(e=>{e?this._proxy.pauseStream():this._proxy.resumeStream()}))])}get connectionError(){if(this.errorString)return new t("stream-controller",this.errorString)}on(e,t){"data-received"===e&&(this._enabledDataReceived=!0,this._proxy.enableEvent("data-received",!0));const r=super.on(e,t),s=this;return{remove(){r.remove(),"data-received"===e&&(s._proxy.closed||s.hasEventListener("data-received")||s._proxy.enableEvent("data-received",!1))}}}queryLatestObservations(e,r){if(!(this.layer.timeInfo?.endField||this.layer.timeInfo?.startField))throw new t("streamlayer-no-timeField","queryLatestObservation can only be used with services that define a TrackIdField");return this._proxy.queryLatestObservations(this._cleanUpQuery(e),r).then((e=>{const t=n.fromJSON(e);return t.features.forEach((e=>{e.layer=this.layer,e.sourceLayer=this.layer})),t}))}detach(){super.detach(),this.connectionStatus="disconnected"}_createClientOptions(){return{...super._createClientOptions(),setProperty:e=>{this.set(e.propertyName,e.value)}}}_createTileRendererHash(e){const t=`${JSON.stringify(this.layer.purgeOptions)}.${JSON.stringify(l(this.layer.definitionExpression,this.layer.geometryDefinition))})`;return super._createTileRendererHash(e)+t}async _createServiceOptions(){const e=this.layer,{objectIdField:t}=e,r=e.fields.map((e=>e.toJSON())),s=p(e.geometryType),i=e.timeInfo&&e.timeInfo.toJSON()||null,o=e.spatialReference?e.spatialReference.toJSON():null;return{type:"stream",fields:r,geometryType:s,objectIdField:t,timeInfo:i,source:this.layer.parsedUrl,serviceFilter:l(this.layer.definitionExpression,this.layer.geometryDefinition),purgeOptions:this.layer.purgeOptions.toJSON(),enableDataReceived:this._enabledDataReceived,spatialReference:o,maxReconnectionAttempts:this.layer.maxReconnectionAttempts,maxReconnectionInterval:this.layer.maxReconnectionInterval,updateInterval:this.layer.updateInterval,customParameters:e.customParameters}}};e([o()],d.prototype,"errorString",void 0),e([o({readOnly:!0})],d.prototype,"connectionError",null),e([o()],d.prototype,"connectionStatus",void 0),d=e([a("esri.views.2d.layers.StreamLayerView2D")],d);const u=d;export{u as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{isNone as r,isSome as s}from"../../../core/maybe.js";import{watch as i}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import n from"../../../rest/support/FeatureSet.js";import c from"./FeatureLayerView2D.js";import{toJSONGeometryType as p}from"./support/util.js";function l(e,t){if(r(e)&&r(t))return null;const i={};return s(t)&&(i.geometry=t.toJSON()),s(e)&&(i.where=e),i}let d=class extends c{constructor(){super(...arguments),this._enabledDataReceived=!1,this._isUserPaused=!1,this.errorString=null,this.connectionStatus="disconnected"}initialize(){this.handles.add([this.layer?.on("send-message",(e=>this._proxy.sendMessage(e))),this.layer?.on("receive-message",(e=>this._proxy.receiveMessage(e))),i((()=>this.layer?.purgeOptions),(()=>this._update())),i((()=>this.suspended),(e=>{e?this._proxy.pauseStream():this._isUserPaused||this._proxy.resumeStream()}))])}get connectionError(){if(this.errorString)return new t("stream-controller",this.errorString)}pause(){this._isUserPaused=!0,this._proxy.pauseStream()}resume(){this._isUserPaused=!1,this._proxy.resumeStream()}on(e,t){"data-received"===e&&(this._enabledDataReceived=!0,this._proxy.enableEvent("data-received",!0));const r=super.on(e,t),s=this;return{remove(){r.remove(),"data-received"===e&&(s._proxy.closed||s.hasEventListener("data-received")||s._proxy.enableEvent("data-received",!1))}}}queryLatestObservations(e,r){if(!(this.layer.timeInfo?.endField||this.layer.timeInfo?.startField||this.layer.timeInfo?.trackIdField))throw new t("streamlayer-no-timeField","queryLatestObservation can only be used with services that define a TrackIdField");return this._proxy.queryLatestObservations(this._cleanUpQuery(e),r).then((e=>{const t=n.fromJSON(e);return t.features.forEach((e=>{e.layer=this.layer,e.sourceLayer=this.layer})),t}))}detach(){super.detach(),this.connectionStatus="disconnected"}_createClientOptions(){return{...super._createClientOptions(),setProperty:e=>{this.set(e.propertyName,e.value)}}}_createTileRendererHash(e){const t=`${JSON.stringify(this.layer.purgeOptions)}.${JSON.stringify(l(this.layer.definitionExpression,this.layer.geometryDefinition))})`;return super._createTileRendererHash(e)+t}async _createServiceOptions(){const e=this.layer,{objectIdField:t}=e,r=e.fields.map((e=>e.toJSON())),s=p(e.geometryType),i=e.timeInfo&&e.timeInfo.toJSON()||null,o=e.spatialReference?e.spatialReference.toJSON():null;return{type:"stream",fields:r,geometryType:s,objectIdField:t,timeInfo:i,source:this.layer.parsedUrl,serviceFilter:l(this.layer.definitionExpression,this.layer.geometryDefinition),purgeOptions:this.layer.purgeOptions.toJSON(),enableDataReceived:this._enabledDataReceived,spatialReference:o,maxReconnectionAttempts:this.layer.maxReconnectionAttempts,maxReconnectionInterval:this.layer.maxReconnectionInterval,updateInterval:this.layer.updateInterval,customParameters:e.customParameters}}};e([o()],d.prototype,"errorString",void 0),e([o({readOnly:!0})],d.prototype,"connectionError",null),e([o()],d.prototype,"connectionStatus",void 0),d=e([a("esri.views.2d.layers.StreamLayerView2D")],d);const u=d;export{u 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.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{HandleOwner as t}from"../../../../../core/HandleOwner.js";import has from"../../../../../core/has.js";import{isNone as r,applySome as s,isSome as i,filterNones as a}from"../../../../../core/maybe.js";import{ignoreAbortErrors as o,after as n,throwIfAborted as u,throwIfNotAbortError as g,isAbortError as h}from"../../../../../core/promiseUtils.js";import{when as d,whenOnce as c}from"../../../../../core/reactiveUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import{subclass as p}from"../../../../../core/accessorSupport/decorators/subclass.js";import{convertToGeometry as y}from"../../../../../layers/graphics/featureConversionUtils.js";import{QueryEngine as f}from"../../../../../layers/graphics/data/QueryEngine.js";import m from"../../../../../layers/support/FieldsIndex.js";import{FeatureStore2D as S}from"../FeatureStore2D.js";import{createSource as _}from"../sources/createSource.js";import v from"../support/AttributeStore.js";import{BinStore as b}from"../support/BinStore.js";import{ClusterStore as I}from"../support/ClusterStore.js";import{ComputedAttributeStorage as Q}from"../support/ComputedAttributeStorage.js";import{FeatureSetReaderJSON as w}from"../support/FeatureSetReaderJSON.js";import{UpdateToken as E}from"../support/UpdateToken.js";import{QueueProcessor as C}from"../../../../support/QueueProcessor.js";const F=5e3,j="tileRenderer.featuresView.attributeView.initialize",T="tileRenderer.featuresView.attributeView.requestUpdate",k="tileRenderer.featuresView.requestRender";function x(e){return"worker:port-closed"===e.name}function R(e){if(!h(e)&&!x(e))throw e}function A(e){return"feature"===e.type&&"snapshot"===e.mode}let U=class extends t{constructor(){super(...arguments),this._storage=new Q,this._markedIdsBufId=this._storage.createBitset(),this._lastCleanup=performance.now(),this._cleanupNeeded=!1,this._invalidated=!1,this._tileToResolver=new Map,this._didEdit=!1,this._updateVersion=1,this.tileStore=null,this.config=null,this.processor=null,this.remoteClient=null,this.service=null}initialize(){this._initStores(),this._initSource(),this._updateQueue=new C({concurrency:"geoevent"===this._source.type?1:4,process:(e,t)=>this._onTileMessage(e,{signal:t})}),this.handles.add([this.tileStore.on("update",this.onTileUpdate.bind(this)),d((()=>!this.updating),(()=>this.onIdle()))]),this._checkUpdating=setInterval((()=>this.notifyChange("updating")),300)}_initSource(){const e=this.tileStore.tileScheme,t=()=>this._updateQueue.length<50,r=(e,t)=>(this._invalidated=!0,this._patchTile(e,t));this._source=_(this.service,this.spatialReference,e,r,t,this.featureStore),this._proxyEvents()}_proxyEvents(){if("geoevent"===this._source.type){const e=this._source.events;this.handles.add([e.on("connectionStatus",(e=>this.remoteClient.invoke("setProperty",{propertyName:"connectionStatus",value:e}).catch(R))),e.on("errorString",(e=>this.remoteClient.invoke("setProperty",{propertyName:"errorString",value:e}).catch(R))),e.on("data-received",(e=>this.remoteClient.invoke("emitEvent",{name:"data-received",event:{attributes:e.attributes,centroid:e.centroid,geometry:e.geometry}}).catch(R))),e.on("updateRate",(e=>this.remoteClient.invoke("emitEvent",{name:"update-rate",event:{...e}}).catch(R)))])}}_initAttributeStore(e){this.attributeStore||(this.attributeStore=new v({type:"remote",initialize:(e,t)=>o(this.remoteClient.invoke(j,e,{signal:t}).catch(R)),update:(e,t)=>o(this.remoteClient.invoke(T,e,{signal:t}).catch(R)),render:e=>o(this.remoteClient.invoke(k,void 0,{signal:e}).catch(R))},e,(()=>this.notifyChange("updating"))))}_initStores(){const e="snapshot"===this.service.type?"snapshot":"on-demand",t={geometryInfo:{geometryType:this.service.geometryType,hasM:!1,hasZ:!1},spatialReference:this.spatialReference,fieldsIndex:this.fieldsIndex,fields:this.service.fields};this.featureStore=new S(t,this._storage,e)}_initQueryEngine(e){const t=this;this.featureQueryEngine?.destroy(),this.featureQueryEngine=new f({definitionExpression:e.schema.source.definitionExpression??void 0,fields:this.service.fields,geometryType:this.service.geometryType,objectIdField:this.service.objectIdField,hasM:!1,hasZ:!1,spatialReference:this.spatialReference.toJSON(),cacheSpatialQueries:!0,featureStore:this.featureStore,aggregateAdapter:{getFeatureObjectIds(e){if(r(t.aggregateStore))return[];return t.aggregateStore.getFeatureDisplayIdsForAggregate(e).map((e=>t.getObjectId(e)))}},timeInfo:this.service.timeInfo})}_initAggregateQueryEngine(e,t){if(this.aggregateQueryEngine?.destroy(),r(e))return;const s=t.targets.aggregate.params.fields.slice();this.aggregateQueryEngine=new f({definitionExpression:void 0,fields:s,geometryType:e.geometryInfo.geometryType,objectIdField:e.objectIdField,hasM:e.geometryInfo.hasM,hasZ:e.geometryInfo.hasZ,spatialReference:this.spatialReference.toJSON(),cacheSpatialQueries:!1,featureStore:e,aggregateAdapter:{getFeatureObjectIds:e=>[]}})}destroy(){this._updateQueue.destroy(),this._source.destroy(),this.featureQueryEngine?.destroy(),this.aggregateQueryEngine?.destroy(),this.attributeStore?.destroy();for(const e of this.tileStore.tiles)this._source.unsubscribe(e);clearInterval(this._checkUpdating)}get fieldsIndex(){return new m(this.service.fields)}get spatialReference(){return this.tileStore.tileScheme.spatialReference}get updating(){return this.isUpdating()}isUpdating(){const e=this._source.updating,t=!!this._updateQueue.length,r=!this.attributeStore||this.attributeStore.isUpdating(),s=e||t||r;return has("esri-2d-log-updating")&&console.log(`Updating FeatureController2D: ${s}\n -> updatingSource ${e}\n -> updateQueue ${t}\n -> updatingAttributeStore ${r}\n`),s}enableEvent(e){this._source.enableEvent(e.name,e.value)}pause(){this._updateQueue.pause(),this._updateQueue.clear()}resume(){this._updateQueue.resume()}pauseStream(){"geoevent"===this._source.type&&this._source.pauseStream()}resumeStream(){"geoevent"===this._source.type&&this._source.resumeStream()}_initAggregateStore(e){const t=e.schema.targets?.aggregate?.type,r=s(this.config,(e=>e.schema.targets?.aggregate?.type));if(r!==t&&(i(this.aggregateStore)&&(this.handles.remove("valueRangesChanged"),this.aggregateStore.destroy(),this.aggregateStore=null),t)){switch(t){case"cluster":{const e={geometryInfo:{geometryType:"esriGeometryPoint",hasM:!1,hasZ:!1},spatialReference:this.spatialReference,fieldsIndex:this.fieldsIndex,fields:this.service.fields};this.aggregateStore=new I(e,this.spatialReference,this._storage,this.service),this.handles.add(this.aggregateStore.events.on("valueRangesChanged",(e=>{this.remoteClient.invoke("emitEvent",{name:"valueRangesChanged",event:{valueRanges:e.valueRanges}}).catch(R)})),"valueRangesChanged");break}case"bin":{const e={geometryInfo:{geometryType:"esriGeometryPolygon",hasM:!1,hasZ:!1},spatialReference:this.spatialReference,fieldsIndex:this.fieldsIndex,fields:this.service.fields};this.aggregateStore=new b(e,this.spatialReference,this._storage,this.service);break}}this.aggregateStore.onTileUpdate({added:this.tileStore.tiles,removed:[]})}}async update(e,t){this._updateVersion++,this._initQueryEngine(t),this._initAttributeStore(t),this.pause(),await Promise.all([this._source.update(e,t.schema.source),this.featureStore.updateSchema(e,t.schema.targets.feature),this.attributeStore.update(e,t),this.attributeStore.updateFilters(e,t,this)]),this._initAggregateStore(t),i(this.aggregateStore)&&await this.aggregateStore.updateSchema(e,t.schema.targets.aggregate),this._initAggregateQueryEngine(this.aggregateStore,t.schema),has("esri-2d-update-debug")&&e.describe(),this._set("config",t)}async applyUpdate(e){e.version=this._updateVersion,has("esri-2d-update-debug")&&console.debug(`Applying update ${e.version}`),e.mesh&&this.clearTiles(),this._updateQueue.resume(),await this._source.applyUpdate(e),this.notifyChange("updating"),await c((()=>!this.updating)),i(this.aggregateStore)&&(await n(10),await c((()=>!this.updating)))}async onEdits({edits:e}){has("esri-2d-update-debug")&&console.debug("Applying Edit:",e),this._didEdit=!0;try{const t=e.removed.map((e=>e.objectId&&-1!==e.objectId?e.objectId:this._lookupObjectIdByGlobalId(e.globalId))),r=e.addOrModified.map((({objectId:e})=>e));this.featureStore.invalidate(),await this._source.edit(r,t),this.clearTiles(),this.notifyChange("updating"),i(this.aggregateStore)&&this.aggregateStore.clear(),await this._source.resend(),await c((()=>!this.updating))}catch(t){}}async refresh(e){if(!e.dataChanged){const e=E.empty();return e.storage.filters=!0,this.applyUpdate(e)}this.featureStore.invalidate(),this.clearTiles(),this._source.refresh(this._updateVersion,e),this._cleanupNeeded=!0,this.notifyChange("updating"),await c((()=>!this.updating))}clearTiles(){for(const e of this.tileStore.tiles)this.processor.onTileClear(e)}onTileUpdate(e){i(this.aggregateStore)&&this.aggregateStore.onTileUpdate(e);for(const t of e.added)this._source.subscribe(t,this._updateVersion),this._level=t.level;for(const t of e.removed)this._source.unsubscribe(t),this._cleanupNeeded=!0,this._tileToResolver.has(t.id)&&(this._tileToResolver.get(t.id).resolve(),this._tileToResolver.delete(t.id));this.notifyChange("updating")}async onIdle(){this._invalidated&&(this._invalidated=!1,(i(this.aggregateStore)||"heatmap"===this.processor.type)&&await this._repushCurrentLevelTiles()),this._markAndSweep()}async querySummaryStatistics({query:e,params:t}){return this.featureQueryEngine.executeQueryForSummaryStatistics(e,t)}async queryAggregateSummaryStatistics({query:e,params:t}){return this.aggregateQueryEngine.executeQueryForSummaryStatistics(e,t)}async queryUniqueValues({query:e,params:t}){return this.featureQueryEngine.executeQueryForUniqueValues(e,t)}async queryAggregateUniqueValues({query:e,params:t}){return this.aggregateQueryEngine.executeQueryForUniqueValues(e,t)}async queryClassBreaks({query:e,params:t}){return this.featureQueryEngine.executeQueryForClassBreaks(e,t)}async queryAggregateClassBreaks({query:e,params:t}){return this.aggregateQueryEngine.executeQueryForClassBreaks(e,t)}async queryHistogram({query:e,params:t}){return this.featureQueryEngine.executeQueryForHistogram(e,t)}async queryAggregateHistogram({query:e,params:t}){return this.aggregateQueryEngine.executeQueryForHistogram(e,t)}queryExtent(e){return this.featureQueryEngine.executeQueryForExtent(e)}queryAggregates(e){return this.aggregateQueryEngine.executeQuery(e)}queryAggregateCount(e){return this.aggregateQueryEngine.executeQueryForCount(e)}queryAggregateIds(e){return this.aggregateQueryEngine.executeQueryForIds(e)}queryFeatures(e){return this.featureQueryEngine.executeQuery(e)}async queryVisibleFeatures(e){const t=await this.featureQueryEngine.executeQuery(e),r=t.objectIdFieldName;return t.features=t.features.filter((e=>{const t=e.attributes[r],i=this.getDisplayId(t);return s(i,(e=>this.attributeStore.isVisible(e)))})),t}queryFeatureCount(e){return this.featureQueryEngine.executeQueryForCount(e)}queryLatestObservations(e){return this.featureQueryEngine.executeQueryForLatestObservations(e)}queryObjectIds(e){return this.featureQueryEngine.executeQueryForIds(e)}async queryStatistics(){return this.featureStore.storeStatistics}getObjectId(e){return this.featureStore.lookupObjectId(e,this._storage)}getDisplayId(e){if(i(this.aggregateStore)){const t=this.aggregateStore.getDisplayId(e);if(r(t)){const t=this.featureStore.lookupDisplayId(e);return this.aggregateStore.getDisplayIdForReferenceId(t)}return t}return this.featureStore.lookupDisplayId(e)}getFeatures(e){const t=[],r=[];for(const s of e){const e=i(this.aggregateStore)?this.getAggregate(s):null;if(i(e))if(i(e.attributes.referenceId)){const r=this.getFeature(e.attributes.referenceId);i(r)&&t.push(r)}else r.push(e);else{const e=this.getFeature(s);i(e)&&t.push(e)}}return{features:t,aggregates:r}}getFeature(e){const t=this.featureStore.lookupFeatureByDisplayId(e,this._storage);if(r(t))return null;const s=t.readHydratedGeometry(),i=y(s,t.geometryType,t.hasZ,t.hasM);return{attributes:t.readAttributes(),geometry:i}}getAggregate(e){return r(this.aggregateStore)?null:this.aggregateStore.getAggregate(e)}getAggregates(){return r(this.aggregateStore)?[]:this.aggregateStore.getAggregates()}async setHighlight(e){const t=a(e.map((e=>this.getDisplayId(e))));return this.attributeStore.setHighlight(e,t)}_lookupObjectIdByGlobalId(e){const t=this.service.globalIdField;if(r(t))throw new Error("Expected globalIdField to be defined");let s=null;if(this.featureStore.forEach((r=>{e===r.readAttribute(t)&&(s=r.getObjectId())})),r(s))throw new Error(`Expected to find a feature with globalId ${e}`);return s}async _repushCurrentLevelTiles(){const e=this.tileStore.tiles.filter((e=>e.level===this._level));e.map((async e=>this._patchTile({type:"append",id:e.key.id,clear:!0,addOrUpdate:null,end:!1})));const t=e.map((async e=>this._patchTile({type:"append",id:e.key.id,addOrUpdate:w.fromOptimizedFeatures([],this.service),remove:[],end:!0,isRepush:!0,status:E.empty()})));await Promise.all(t)}_maybeForceCleanup(){performance.now()-this._lastCleanup>F&&this._markAndSweep()}_patchTile(e,t){const r=this._updateQueue.push(e,t).then((()=>{this.notifyChange("updating")})).catch((e=>{this.notifyChange("updating")}));return this.notifyChange("updating"),r}async _onTileMessage(e,t){if(u(t),has("esri-2d-update-debug")){const t=s(e.addOrUpdate,(e=>e.hasFeatures));console.debug(e.id,`FeatureController:onTileMessage: [clear:${e.clear}, end:${e.end}, features: ${t}]`)}const a=this.tileStore.get(e.id);if(!a)return;if(e.clear)return this.processor.onTileClear(a);const o=e.status;this._cleanupNeeded=!0;const n=[];for(const r of e.remove??[]){const e=this.featureStore.lookupDisplayId(r);e&&n.push(e)}e.remove=n;try{if(r(e.addOrUpdate))return void this.processor.onTileMessage(a,{...e,addOrUpdate:null},i(this.aggregateStore),t).catch(g);if(e.addOrUpdate.setArcadeSpatialReference(this.spatialReference),this.featureStore.hasInstance(e.addOrUpdate.instance)&&o.targets.feature||(o.targets.feature=!0,this.featureStore.onTileData(a,e)),!o.storage.data||!o.storage.filters){o.storage.data=!0,o.storage.filters=!0,this.attributeStore.onTileData(a,e);"geoevent"===this._source.type||this._didEdit?(await this.attributeStore.sendUpdates(),u(t)):this.attributeStore.sendUpdates()}if(i(this.aggregateStore)&&!o.targets.aggregate){o.targets.aggregate=!0;const t=A(this._source)&&this._source.loading,r=!A(this._source)||t||e.end;if(this.aggregateStore.onTileData(a,e,this._storage,this.attributeStore,r),!r)return;o.mesh||(this.attributeStore.onTileData(a,e),await this.attributeStore.sendUpdates())}if(!o.mesh){o.mesh=!0;const r=i(this.aggregateStore)&&"cluster"===this.aggregateStore.type;await this.processor.onTileMessage(a,e,r,t),u(t)}this._maybeForceCleanup()}catch(h){g(h)}}_mark(e,t,r){const s=(4294901760&this._storage.getInstanceId(e))>>>16;e&&(t.add(s),r.set(e))}_markAndSweep(){this._lastCleanup=performance.now();if(!(!("feature"===this._source.type&&"snapshot"===this._source.mode)&&("geoevent"===this._source.type||this._cleanupNeeded)))return;this._cleanupNeeded=!1;const e=this._storage.getBitset(this._markedIdsBufId),t=new Set;e.clear();for(const r of this.tileStore.tiles)for(const s of this._source.readers(r.id)){const r=s.getCursor();for(;r.next();){let s=r.getDisplayId();if(!s){const e=r.getObjectId();s=this.featureStore.lookupDisplayId(e)}this._mark(s,t,e)}}"symbol"===this.processor.type&&this.processor.forEachBufferId((r=>{this._mark(r,t,e)})),this._updateQueue.forEach((r=>{for(const s of r.remove??[]){const r=this.featureStore.lookupDisplayId(s);this._mark(r,t,e)}})),i(this.aggregateStore)&&(this.aggregateStore.sweepFeatures(e,this.featureStore),"sweepAggregates"in this.aggregateStore&&this.aggregateStore.sweepAggregates(this._storage,this.attributeStore,this._level)),this.featureStore.sweepFeatures(e,this._storage,this.attributeStore),this.featureStore.sweepFeatureSets(t)}};e([l({constructOnly:!0})],U.prototype,"tileStore",void 0),e([l()],U.prototype,"config",void 0),e([l({readOnly:!0})],U.prototype,"fieldsIndex",null),e([l()],U.prototype,"processor",void 0),e([l({constructOnly:!0})],U.prototype,"remoteClient",void 0),e([l({constructOnly:!0})],U.prototype,"service",void 0),e([l()],U.prototype,"spatialReference",null),e([l()],U.prototype,"updating",null),U=e([p("esri.views.2d.layers.features.controllers.FeatureController2D")],U);const q=U;export{q as default};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{HandleOwner as t}from"../../../../../core/HandleOwner.js";import has from"../../../../../core/has.js";import{isNone as r,applySome as s,isSome as i,filterNones as a}from"../../../../../core/maybe.js";import{ignoreAbortErrors as o,after as n,throwIfAborted as u,throwIfNotAbortError as g,isAbortError as h}from"../../../../../core/promiseUtils.js";import{when as d,whenOnce as c}from"../../../../../core/reactiveUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import{subclass as p}from"../../../../../core/accessorSupport/decorators/subclass.js";import{convertToGeometry as y}from"../../../../../layers/graphics/featureConversionUtils.js";import{QueryEngine as f}from"../../../../../layers/graphics/data/QueryEngine.js";import m from"../../../../../layers/support/FieldsIndex.js";import{FeatureStore2D as S}from"../FeatureStore2D.js";import{createSource as _}from"../sources/createSource.js";import v from"../support/AttributeStore.js";import{BinStore as b}from"../support/BinStore.js";import{ClusterStore as I}from"../support/ClusterStore.js";import{ComputedAttributeStorage as Q}from"../support/ComputedAttributeStorage.js";import{FeatureSetReaderJSON as w}from"../support/FeatureSetReaderJSON.js";import{UpdateToken as E}from"../support/UpdateToken.js";import{QueueProcessor as C}from"../../../../support/QueueProcessor.js";const F=5e3,j="tileRenderer.featuresView.attributeView.initialize",k="tileRenderer.featuresView.attributeView.requestUpdate",T="tileRenderer.featuresView.requestRender";function x(e){return"worker:port-closed"===e.name}function R(e){if(!h(e)&&!x(e))throw e}function A(e){return"feature"===e.type&&"snapshot"===e.mode}let U=class extends t{constructor(){super(...arguments),this._storage=new Q,this._markedIdsBufId=this._storage.createBitset(),this._lastCleanup=performance.now(),this._cleanupNeeded=!1,this._invalidated=!1,this._tileToResolver=new Map,this._didEdit=!1,this._updateVersion=1,this.tileStore=null,this.config=null,this.processor=null,this.remoteClient=null,this.service=null}initialize(){this._initStores(),this._initSource(),this._updateQueue=new C({concurrency:"geoevent"===this._source.type?1:4,process:(e,t)=>this._onTileMessage(e,{signal:t})}),this.handles.add([this.tileStore.on("update",this.onTileUpdate.bind(this)),d((()=>!this.updating),(()=>this.onIdle()))]),this._checkUpdating=setInterval((()=>this.notifyChange("updating")),300)}_initSource(){const e=this.tileStore.tileScheme,t=()=>this._updateQueue.length<50,r=(e,t)=>(this._invalidated=!0,this._patchTile(e,t));this._source=_(this.service,this.spatialReference,e,r,t,this.featureStore),this._proxyEvents()}_proxyEvents(){if("geoevent"===this._source.type){const e=this._source.events;this.handles.add([e.on("connectionStatus",(e=>this.remoteClient.invoke("setProperty",{propertyName:"connectionStatus",value:e}).catch(R))),e.on("errorString",(e=>this.remoteClient.invoke("setProperty",{propertyName:"errorString",value:e}).catch(R))),e.on("data-received",(e=>this.remoteClient.invoke("emitEvent",{name:"data-received",event:{attributes:e.attributes,centroid:e.centroid,geometry:e.geometry}}).catch(R))),e.on("message-received",(e=>this.remoteClient.invoke("emitEvent",{name:"message-received",event:e}).catch(R))),e.on("updateRate",(e=>this.remoteClient.invoke("emitEvent",{name:"update-rate",event:{...e}}).catch(R)))])}}_initAttributeStore(e){this.attributeStore||(this.attributeStore=new v({type:"remote",initialize:(e,t)=>o(this.remoteClient.invoke(j,e,{signal:t}).catch(R)),update:(e,t)=>o(this.remoteClient.invoke(k,e,{signal:t}).catch(R)),render:e=>o(this.remoteClient.invoke(T,void 0,{signal:e}).catch(R))},e,(()=>this.notifyChange("updating"))))}_initStores(){const e="snapshot"===this.service.type?"snapshot":"on-demand",t={geometryInfo:{geometryType:this.service.geometryType,hasM:!1,hasZ:!1},spatialReference:this.spatialReference,fieldsIndex:this.fieldsIndex,fields:this.service.fields};this.featureStore=new S(t,this._storage,e)}_initQueryEngine(e){const t=this;this.featureQueryEngine?.destroy(),this.featureQueryEngine=new f({definitionExpression:e.schema.source.definitionExpression??void 0,fields:this.service.fields,geometryType:this.service.geometryType,objectIdField:this.service.objectIdField,hasM:!1,hasZ:!1,spatialReference:this.spatialReference.toJSON(),cacheSpatialQueries:!0,featureStore:this.featureStore,aggregateAdapter:{getFeatureObjectIds(e){if(r(t.aggregateStore))return[];return t.aggregateStore.getFeatureDisplayIdsForAggregate(e).map((e=>t.getObjectId(e)))}},timeInfo:this.service.timeInfo})}_initAggregateQueryEngine(e,t){if(this.aggregateQueryEngine?.destroy(),r(e))return;const s=t.targets.aggregate.params.fields.slice();this.aggregateQueryEngine=new f({definitionExpression:void 0,fields:s,geometryType:e.geometryInfo.geometryType,objectIdField:e.objectIdField,hasM:e.geometryInfo.hasM,hasZ:e.geometryInfo.hasZ,spatialReference:this.spatialReference.toJSON(),cacheSpatialQueries:!1,featureStore:e,aggregateAdapter:{getFeatureObjectIds:e=>[]}})}destroy(){this._updateQueue.destroy(),this._source.destroy(),this.featureQueryEngine?.destroy(),this.aggregateQueryEngine?.destroy(),this.attributeStore?.destroy();for(const e of this.tileStore.tiles)this._source.unsubscribe(e);clearInterval(this._checkUpdating)}get fieldsIndex(){return new m(this.service.fields)}get spatialReference(){return this.tileStore.tileScheme.spatialReference}get updating(){return this.isUpdating()}isUpdating(){const e=this._source.updating,t=!!this._updateQueue.length,r=!this.attributeStore||this.attributeStore.isUpdating(),s=e||t||r;return has("esri-2d-log-updating")&&console.log(`Updating FeatureController2D: ${s}\n -> updatingSource ${e}\n -> updateQueue ${t}\n -> updatingAttributeStore ${r}\n`),s}enableEvent(e){this._source.enableEvent(e.name,e.value)}pause(){this._updateQueue.pause(),this._updateQueue.clear()}resume(){this._updateQueue.resume()}pauseStream(){"geoevent"===this._source.type&&this._source.pauseStream()}resumeStream(){"geoevent"===this._source.type&&this._source.resumeStream()}sendMessage(e){"geoevent"===this._source.type&&this._source.sendMessage(e)}receiveMessage(e){"geoevent"===this._source.type&&this._source.receiveMessage(e)}_initAggregateStore(e){const t=e.schema.targets?.aggregate?.type,r=s(this.config,(e=>e.schema.targets?.aggregate?.type));if(r!==t&&(i(this.aggregateStore)&&(this.handles.remove("valueRangesChanged"),this.aggregateStore.destroy(),this.aggregateStore=null),t)){switch(t){case"cluster":{const e={geometryInfo:{geometryType:"esriGeometryPoint",hasM:!1,hasZ:!1},spatialReference:this.spatialReference,fieldsIndex:this.fieldsIndex,fields:this.service.fields};this.aggregateStore=new I(e,this.spatialReference,this._storage,this.service),this.handles.add(this.aggregateStore.events.on("valueRangesChanged",(e=>{this.remoteClient.invoke("emitEvent",{name:"valueRangesChanged",event:{valueRanges:e.valueRanges}}).catch(R)})),"valueRangesChanged");break}case"bin":{const e={geometryInfo:{geometryType:"esriGeometryPolygon",hasM:!1,hasZ:!1},spatialReference:this.spatialReference,fieldsIndex:this.fieldsIndex,fields:this.service.fields};this.aggregateStore=new b(e,this.spatialReference,this._storage,this.service);break}}this.aggregateStore.onTileUpdate({added:this.tileStore.tiles,removed:[]})}}async update(e,t){this._updateVersion++,this._initQueryEngine(t),this._initAttributeStore(t),this.pause(),await Promise.all([this._source.update(e,t.schema.source),this.featureStore.updateSchema(e,t.schema.targets.feature),this.attributeStore.update(e,t),this.attributeStore.updateFilters(e,t,this)]),this._initAggregateStore(t),i(this.aggregateStore)&&await this.aggregateStore.updateSchema(e,t.schema.targets.aggregate),this._initAggregateQueryEngine(this.aggregateStore,t.schema),has("esri-2d-update-debug")&&e.describe(),this._set("config",t)}async applyUpdate(e){e.version=this._updateVersion,has("esri-2d-update-debug")&&console.debug(`Applying update ${e.version}`),e.mesh&&this.clearTiles(),this._updateQueue.resume(),await this._source.applyUpdate(e),this.notifyChange("updating"),await c((()=>!this.updating)),i(this.aggregateStore)&&(await n(10),await c((()=>!this.updating)))}async onEdits({edits:e}){has("esri-2d-update-debug")&&console.debug("Applying Edit:",e),this._didEdit=!0;try{const t=e.removed.map((e=>e.objectId&&-1!==e.objectId?e.objectId:this._lookupObjectIdByGlobalId(e.globalId))),r=e.addOrModified.map((({objectId:e})=>e));this.featureStore.invalidate(),await this._source.edit(r,t),this.clearTiles(),this.notifyChange("updating"),i(this.aggregateStore)&&this.aggregateStore.clear(),await this._source.resend(),await c((()=>!this.updating))}catch(t){}}async refresh(e){if(!e.dataChanged){const e=E.empty();return e.storage.filters=!0,this.applyUpdate(e)}this.featureStore.invalidate(),this.clearTiles(),this._source.refresh(this._updateVersion,e),this._cleanupNeeded=!0,this.notifyChange("updating"),await c((()=>!this.updating))}clearTiles(){for(const e of this.tileStore.tiles)this.processor.onTileClear(e)}onTileUpdate(e){i(this.aggregateStore)&&this.aggregateStore.onTileUpdate(e);for(const t of e.added)this._source.subscribe(t,this._updateVersion),this._level=t.level;for(const t of e.removed)this._source.unsubscribe(t),this._cleanupNeeded=!0,this._tileToResolver.has(t.id)&&(this._tileToResolver.get(t.id).resolve(),this._tileToResolver.delete(t.id));this.notifyChange("updating")}async onIdle(){this._invalidated&&(this._invalidated=!1,(i(this.aggregateStore)||"heatmap"===this.processor.type)&&await this._repushCurrentLevelTiles()),this._markAndSweep()}async querySummaryStatistics({query:e,params:t}){return this.featureQueryEngine.executeQueryForSummaryStatistics(e,t)}async queryAggregateSummaryStatistics({query:e,params:t}){return this.aggregateQueryEngine.executeQueryForSummaryStatistics(e,t)}async queryUniqueValues({query:e,params:t}){return this.featureQueryEngine.executeQueryForUniqueValues(e,t)}async queryAggregateUniqueValues({query:e,params:t}){return this.aggregateQueryEngine.executeQueryForUniqueValues(e,t)}async queryClassBreaks({query:e,params:t}){return this.featureQueryEngine.executeQueryForClassBreaks(e,t)}async queryAggregateClassBreaks({query:e,params:t}){return this.aggregateQueryEngine.executeQueryForClassBreaks(e,t)}async queryHistogram({query:e,params:t}){return this.featureQueryEngine.executeQueryForHistogram(e,t)}async queryAggregateHistogram({query:e,params:t}){return this.aggregateQueryEngine.executeQueryForHistogram(e,t)}queryExtent(e){return this.featureQueryEngine.executeQueryForExtent(e)}queryAggregates(e){return this.aggregateQueryEngine.executeQuery(e)}queryAggregateCount(e){return this.aggregateQueryEngine.executeQueryForCount(e)}queryAggregateIds(e){return this.aggregateQueryEngine.executeQueryForIds(e)}queryFeatures(e){return this.featureQueryEngine.executeQuery(e)}async queryVisibleFeatures(e){const t=await this.featureQueryEngine.executeQuery(e),r=t.objectIdFieldName;return t.features=t.features.filter((e=>{const t=e.attributes[r],i=this.getDisplayId(t);return s(i,(e=>this.attributeStore.isVisible(e)))})),t}queryFeatureCount(e){return this.featureQueryEngine.executeQueryForCount(e)}queryLatestObservations(e){return this.featureQueryEngine.executeQueryForLatestObservations(e)}queryObjectIds(e){return this.featureQueryEngine.executeQueryForIds(e)}async queryStatistics(){return this.featureStore.storeStatistics}getObjectId(e){return this.featureStore.lookupObjectId(e,this._storage)}getDisplayId(e){if(i(this.aggregateStore)){const t=this.aggregateStore.getDisplayId(e);if(r(t)){const t=this.featureStore.lookupDisplayId(e);return this.aggregateStore.getDisplayIdForReferenceId(t)}return t}return this.featureStore.lookupDisplayId(e)}getFeatures(e){const t=[],r=[];for(const s of e){const e=i(this.aggregateStore)?this.getAggregate(s):null;if(i(e))if(i(e.attributes.referenceId)){const r=this.getFeature(e.attributes.referenceId);i(r)&&t.push(r)}else r.push(e);else{const e=this.getFeature(s);i(e)&&t.push(e)}}return{features:t,aggregates:r}}getFeature(e){const t=this.featureStore.lookupFeatureByDisplayId(e,this._storage);if(r(t))return null;const s=t.readHydratedGeometry(),i=y(s,t.geometryType,t.hasZ,t.hasM);return{attributes:t.readAttributes(),geometry:i}}getAggregate(e){return r(this.aggregateStore)?null:this.aggregateStore.getAggregate(e)}getAggregates(){return r(this.aggregateStore)?[]:this.aggregateStore.getAggregates()}async setHighlight(e){const t=a(e.map((e=>this.getDisplayId(e))));return this.attributeStore.setHighlight(e,t)}_lookupObjectIdByGlobalId(e){const t=this.service.globalIdField;if(r(t))throw new Error("Expected globalIdField to be defined");let s=null;if(this.featureStore.forEach((r=>{e===r.readAttribute(t)&&(s=r.getObjectId())})),r(s))throw new Error(`Expected to find a feature with globalId ${e}`);return s}async _repushCurrentLevelTiles(){const e=this.tileStore.tiles.filter((e=>e.level===this._level));e.map((async e=>this._patchTile({type:"append",id:e.key.id,clear:!0,addOrUpdate:null,end:!1})));const t=e.map((async e=>this._patchTile({type:"append",id:e.key.id,addOrUpdate:w.fromOptimizedFeatures([],this.service),remove:[],end:!0,isRepush:!0,status:E.empty()})));await Promise.all(t)}_maybeForceCleanup(){performance.now()-this._lastCleanup>F&&this._markAndSweep()}_patchTile(e,t){const r=this._updateQueue.push(e,t).then((()=>{this.notifyChange("updating")})).catch((e=>{this.notifyChange("updating")}));return this.notifyChange("updating"),r}async _onTileMessage(e,t){if(u(t),has("esri-2d-update-debug")){const t=s(e.addOrUpdate,(e=>e.hasFeatures));console.debug(e.id,`FeatureController:onTileMessage: [clear:${e.clear}, end:${e.end}, features: ${t}]`)}const a=this.tileStore.get(e.id);if(!a)return;if(e.clear)return this.processor.onTileClear(a);const o=e.status;this._cleanupNeeded=!0;const n=[];for(const r of e.remove??[]){const e=this.featureStore.lookupDisplayId(r);e&&n.push(e)}e.remove=n;try{if(r(e.addOrUpdate))return void this.processor.onTileMessage(a,{...e,addOrUpdate:null},i(this.aggregateStore),t).catch(g);if(e.addOrUpdate.setArcadeSpatialReference(this.spatialReference),this.featureStore.hasInstance(e.addOrUpdate.instance)&&o.targets.feature||(o.targets.feature=!0,this.featureStore.onTileData(a,e)),!o.storage.data||!o.storage.filters){o.storage.data=!0,o.storage.filters=!0,this.attributeStore.onTileData(a,e);"geoevent"===this._source.type||this._didEdit?(await this.attributeStore.sendUpdates(),u(t)):this.attributeStore.sendUpdates()}if(i(this.aggregateStore)&&!o.targets.aggregate){o.targets.aggregate=!0;const t=A(this._source)&&this._source.loading,r=!A(this._source)||t||e.end;if(this.aggregateStore.onTileData(a,e,this._storage,this.attributeStore,r),!r)return;o.mesh||(this.attributeStore.onTileData(a,e),await this.attributeStore.sendUpdates())}if(!o.mesh){o.mesh=!0;const r=i(this.aggregateStore)&&"cluster"===this.aggregateStore.type;await this.processor.onTileMessage(a,e,r,t),u(t)}this._maybeForceCleanup()}catch(h){g(h)}}_mark(e,t,r){const s=(4294901760&this._storage.getInstanceId(e))>>>16;e&&(t.add(s),r.set(e))}_markAndSweep(){this._lastCleanup=performance.now();if(!(!("feature"===this._source.type&&"snapshot"===this._source.mode)&&("geoevent"===this._source.type||this._cleanupNeeded)))return;this._cleanupNeeded=!1;const e=this._storage.getBitset(this._markedIdsBufId),t=new Set;e.clear();for(const r of this.tileStore.tiles)for(const s of this._source.readers(r.id)){const r=s.getCursor();for(;r.next();){let s=r.getDisplayId();if(!s){const e=r.getObjectId();s=this.featureStore.lookupDisplayId(e)}this._mark(s,t,e)}}"symbol"===this.processor.type&&this.processor.forEachBufferId((r=>{this._mark(r,t,e)})),this._updateQueue.forEach((r=>{for(const s of r.remove??[]){const r=this.featureStore.lookupDisplayId(s);this._mark(r,t,e)}})),i(this.aggregateStore)&&(this.aggregateStore.sweepFeatures(e,this.featureStore),"sweepAggregates"in this.aggregateStore&&this.aggregateStore.sweepAggregates(this._storage,this.attributeStore,this._level)),this.featureStore.sweepFeatures(e,this._storage,this.attributeStore),this.featureStore.sweepFeatureSets(t)}};e([l({constructOnly:!0})],U.prototype,"tileStore",void 0),e([l()],U.prototype,"config",void 0),e([l({readOnly:!0})],U.prototype,"fieldsIndex",null),e([l()],U.prototype,"processor",void 0),e([l({constructOnly:!0})],U.prototype,"remoteClient",void 0),e([l({constructOnly:!0})],U.prototype,"service",void 0),e([l()],U.prototype,"spatialReference",null),e([l()],U.prototype,"updating",null),U=e([p("esri.views.2d.layers.features.controllers.FeatureController2D")],U);const q=U;export{q 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.26/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import t from"../../../../core/Logger.js";import{isSome as r,unwrap as i,isNone as n,unwrapOr as s}from"../../../../core/maybe.js";import{pt2px as l}from"../../../../core/screenUtils.js";import{sqlAnd as o}from"../../../../core/sql.js";import{diff as a}from"../../../../core/accessorSupport/diffUtils.js";import{validateLabelingInfo as u}from"../../../../layers/support/labelingInfo.js";import{WGLSymbologyType as d}from"../../engine/webgl/enums.js";import{getVVType as f}from"../../engine/webgl/Utils.js";import{getTechniqueFromRenderer as p}from"../../engine/webgl/techniques/utils.js";import{getVVFlags as c}from"../../engine/webgl/util/vvFlagUtils.js";import{createSymbolSchema as y}from"./createSymbolSchema.js";import{getPtMaxVVSize as m}from"./support/pixelBuffering.js";import{getSupportedHeatmapRenderer as g,simplifyVisualVariables as b}from"./support/rendererUtils.js";import{injectDynamicLevelDependentSizeVisualVariable as x,createClusterRenderer as h}from"../support/clusterUtils.js";import{toJSONGeometryType as v}from"../support/util.js";const T=t.getLogger("esri.views.2d.layers.features.schemaUtils"),S="ValidationError";function E(e){return e}function w(e,t){let i=0,n=0,s=d.DEFAULT;if(r(e)){if(n=m(e,t),"visualVariables"in e&&(i=c(e.visualVariables||[]),"dot-density"===e.type&&(s=d.DOT_DENSITY)),"heatmap"===e.type&&(s=d.HEATMAP),"dictionary"===e.type)return{maxVVSize:n,vvFlags:i,symbologyType:d.DEFAULT};if("pie-chart"===e.type)return{maxVVSize:n,vvFlags:i,symbologyType:d.PIE_CHART};if(s!==d.DOT_DENSITY&&s!==d.HEATMAP){const t=e.getSymbols();"backgroundFillSymbol"in e&&e.backgroundFillSymbol&&t.push(e.backgroundFillSymbol);let r=!0,i=!0;for(const e of t)if("cim"===e.type&&(i=!1),"simple-fill"===e.type||"picture-fill"===e.type){const t=e.outline,n=t&&"none"!==t.style&&"solid"!==t.style,s="simple-fill"===e.type&&"none"!==e.style&&"solid"!==e.style;n&&(r=!1),("picture-fill"===e.type||s||n)&&(i=!1)}r?s=i?d.OUTLINE_FILL_SIMPLE:d.OUTLINE_FILL:i&&(s=d.SIMPLE)}}return{vvFlags:i,maxVVSize:n,symbologyType:s}}let I=null;function F(e){if(has("esri-2d-update-debug")){const t=V(e,!0);console.debug("Created new schema",t),console.debug("Schema diff",a(I,t)),I=t}return V(e)}function V(e,t=!1){try{const n=D(e,t),s=C(e),l={};n.map((t=>O(l,e,t)));const a=r(e.subtypeCode)?`${e.subtypeField} = ${e.subtypeCode}`:null,u=i(o(e.definitionExpression,a));return{source:{definitionExpression:u,fields:e.fields.map((e=>e.toJSON())),gdbVersion:e.gdbVersion,historicMoment:e.historicMoment?.getTime(),outFields:e.availableFields,pixelBuffer:e.pixelBuffer,spatialReference:e.spatialReference.toJSON(),timeExtent:e.timeExtent?.toJSON(),customParameters:e.customParameters},attributes:{fields:{},indexCount:0},processors:n,tileRenderer:s,targets:l}}catch(n){if(n.fieldName===S)return T.error(n),null;throw n}}function O(t,r,i){switch(i.target){case"feature":return void M(t,N(r),i);case"aggregate":{if(!("featureReduction"in r))return;const n=r.featureReduction;switch(n?.type){case"selection":throw new e(S,"Mapview does not support `selection` reduction type",n);case"binning":return M(t,N(r),i),void j(t,n,r.fields.map((e=>e.toJSON())),i);case"cluster":return M(t,N(r),i),void R(t,n,r.fields.map((e=>e.toJSON())),i)}}}}function z(e,t){for(const r in t){const i=t[r];if(i.target!==e.name)continue;const n=e.attributes[r];if(n?.context){const e=n.context;e.mesh=e.mesh||i.context?.mesh,e.storage=e.storage||i.context?.storage}else e.attributes[r]=i}return e}function N(e){return[i(e.filter)?.toJSON()??null,i(i(e.featureEffect)?.filter)?.toJSON()??null]}function M(e,t,r){return e.feature||(e.feature={name:"feature",input:"source",filters:t,attributes:{}}),z(e.feature,r.attributes.fields),e}function L(t,r){const{onStatisticExpression:i,onStatisticField:n,statisticType:s}=t;switch(s){case"min":case"max":case"avg":case"avg_angle":case"sum":case"count":return"esriFieldTypeDouble";case"mode":{if(i){const{returnType:r}=i;return r?"string"===r?"esriFieldTypeString":"esriFieldTypeDouble":(T.error(new e(S,"Unable to infer type of aggregateField with onStatisticExpression. ReturnType is not defined",t)),"esriFieldTypeString")}const s=r.find((e=>e.name===n));return s?s.type:(T.error(new e(S,"Unable to infer type of aggregateField with onStatisticExpression. ReturnType is not defined",t)),"esriFieldTypeString")}}}function j(e,t,r,i){return e.aggregate||(e.aggregate={name:"aggregate",type:"bin",filters:null,input:"feature",params:{fixedBinLevel:t.fixedBinLevel,fields:(t.fields??[]).map((e=>({...e.toJSON(),type:L(e,r)})))},attributes:{}}),z(e.aggregate,i.attributes.fields),e}function R(e,t,r,i){return e.aggregate||(e.aggregate={name:"aggregate",type:"cluster",input:"feature",filters:null,attributes:{},params:{clusterRadius:l(t.clusterRadius/2),clusterPixelBuffer:64*Math.ceil(l(t.clusterMaxSize)/64),fields:(t.fields??[])?.map((e=>({...e.toJSON(),type:L(e,r)})))}}),z(e.aggregate,i.attributes.fields),e}function U(e,t){return t.field?B(e,{...t,type:"field",field:t.field}):t.valueExpression?B(e,{...t,type:"expression",valueExpression:t.valueExpression}):{field:void 0,fieldIndex:void 0}}function B(e,t){switch(t.type){case"expression":{const r=E(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=E(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 D(e,t=!1){const r=new Array;let i=0;return r.push(A(e,i++,t)),r}function P(e,t,r,i,n,s=!1){const l=B(e,{type:"label-expression",target:r,context:{mesh:!0},resultType:"string",label:{labelExpression:t.labelExpression,labelExpressionInfo:t.labelExpressionInfo?{expression:t.labelExpressionInfo.expression}:null,symbol:!!t.symbol,where:t.where}}),{fieldIndex:o}=l;return{...y(t,n,s),fieldIndex:o,target:r,index:i}}function k(t,r,i){const n="featureReduction"in r&&r.featureReduction;if(!n)return{fields:[],labels:[],matcher:void 0,rendererOverride:void 0};const s="aggregate",l=[];let o=null,a=v(r.geometryType),d=[],f=null;if(n)switch(n.type){case"selection":return T.error(new e(S,"Mapview does not support `selection` reduction type",n)),{fields:[],labels:[],matcher:void 0,rendererOverride:void 0};case"cluster":case"binning":if(l.push(...n.fields??[]),"cluster"===n.type?a="esriGeometryPoint":"binning"===n.type&&(a="esriGeometryPolygon"),n.renderer&&!n.renderer.authoringInfo?.isAutoGenerated){if("cluster"===n.type){const{renderer:e}=x(n.renderer,n,null);f=e}else f=n.renderer;const e=w(n.renderer,n);o=$(null,s,n.renderer,e,i),d=n&&n.labelsVisible&&n.labelingInfo||[]}else if("cluster"===n.type){if(f=h(l,r.renderer,n,null,!0),n.symbol){const e=w(f,n);o={type:"simple",symbol:y(n.symbol,e,i),symbologyType:e.symbologyType}}d=n&&n.labelsVisible&&n.labelingInfo||[]}}_(t,l);return{labels:u(d,"binning"===n.type?"esriGeometryPolygon":a),matcher:o,fields:l,rendererOverride:f}}function A(t,i,n=!1){const s={indexCount:0,fields:{}},l="featureReduction"in t?t.featureReduction??void 0:void 0,o=l?"aggregate":"feature";if("sublayers"in t){const i={type:"subtype",subtypeField:t.subtypeField,renderers:{},symbologyType:d.DEFAULT},l={type:"subtype",mapping:{},target:"feature"},a={type:"subtype",classes:{}},u={type:"symbol",target:"feature",aggregateFields:[],attributes:s,storage:l,mesh:{matcher:i,aggregateMatcher:null,labels:a,sortKey:null}},f=new Set;let p=0;for(const{renderer:c,subtypeCode:y,labelingInfo:m,labelsVisible:g}of t.sublayers){const t={symbologyType:d.DEFAULT,vvFlags:0,maxVVSize:0},u=$(s,o,c,t,n),b=q(s,o,c),x=g&&m;if("visualVariables"in c&&c.visualVariables&&c.visualVariables.length)throw new e(S,"Visual variables are currently not supported for subtype layers");if("dictionary"===u.type)throw new e(S,"Dictionary renderer is not supported in subtype layers");if("subtype"===u.type)throw new e(S,"Nested subtype renderers is not supported");if(r(b)&&"subtype"===b.type)throw new e(S,"Nested subtype storage is not supported");if(r(b)&&r(b.attributeMapping))throw new e(S,"Non-visual-variable attributes are not supported in subtype layers");if("heatmap"===u.type)throw new e(S,"Heatmaps are not supported in subtype layers");if("pie-chart"===u.type)throw new e(S,"Pie-charts are not supported in subtype layers");if(f.has(y))throw new e(S,"Subtype codes for sublayers must be unique");f.add(y),i.renderers[y]=u,l.mapping[y]=b,x&&(a.classes[y]=x.map((e=>P(s,e,"feature",p++,t,n))))}return u}if("heatmap"===t.renderer?.type&&"raster"===g()){const{radius:e,fieldOffset:r,field:i}=t.renderer;return{type:"heatmap",aggregateFields:[],attributes:s,target:o,storage:null,mesh:{radius:e,fieldOffset:r,field:U(s,{target:o,field:i,resultType:"numeric"}).field}}}const a=k(s,t,n),f=v(t.geometryType),p=a.rendererOverride??t.renderer,c=w(p,l),y=$(s,o,p,c,n),m=q(s,o,p),b=J(s,t.orderBy,l),x=t.labelsVisible&&t.labelingInfo||[],h=u(x,f);let T=0;const E=[...h.map((e=>P(s,e,"feature",T++,c,n))),...a.labels.map((e=>P(s,e,"aggregate",T++,c,n)))];return{type:"symbol",target:o,attributes:s,aggregateFields:a.fields,storage:m,mesh:{matcher:y,labels:{type:"simple",classes:E},aggregateMatcher:a.matcher,sortKey:b}}}function C(e){return"heatmap"===e.renderer?.type&&"raster"===g()?{type:"heatmap"}:{type:"symbol"}}function J(t,i,s){if(r(s)||n(i)||!i.length)return null;i.length>1&&T.warn(`Layer rendering currently only supports ordering by 1 orderByInfo, but found ${i.length}. All but the first will be discarded`);const l=i[0],o="ascending"===l.order?"asc":"desc";if(l.field)return{field:l.field,order:o};if(l.valueExpression){return{fieldIndex:B(t,{type:"expression",target:"feature",valueExpression:l.valueExpression,resultType:"numeric"}).fieldIndex,order:o}}return T.error(new e(S,"Expected to find a field or valueExpression for OrderByInfo",l)),null}function _(e,t){const r={mesh:!0,storage:!0};for(const i of t){const{name:t,onStatisticField:n,onStatisticExpression:s,statisticType:l}=i;let o,a;const u="numeric",d="feature";if(s){a=B(e,{type:"expression",target:d,valueExpression:s.expression,resultType:u}).fieldIndex}else{o=B(e,{type:"field",target:d,field:n,resultType:u}).field}B(e,{type:"statistic",target:"aggregate",name:t,context:r,inField:o,inFieldIndex:a,statisticType:l})}}function q(e,t,r){let i;switch(r.type){case"simple":case"class-breaks":case"unique-value":case"dictionary":i={visualVariables:!0,attributes:null};break;default:i=p(r).getStorageSpec(r)}return G(e,t,i,r)}function G(e,t,i,s){if(n(i))return null;const{visualVariables:l,attributes:o}=i;let a=null;l&&"visualVariables"in s&&(a=H(e,t,s.visualVariables));const u=r(a)?4:0;let d=null;return r(o)&&(d=o.map(((r,i)=>{const{field:n,fieldIndex:s}=U(e,{valueExpression:r.valueExpression,field:r.field,resultType:"numeric",target:t});return{binding:i+u,field:n,fieldIndex:s}}))),{type:"simple",target:t,attributeMapping:d,vvMapping:a}}function H(e,t,i){if(!i||!i.length)return[];const n={storage:!0},s="numeric";return b(i).map((r=>{const i=f(r.type),{field:l,fieldIndex:o}=U(e,{target:t,valueExpression:r.valueExpression,field:r.field,context:n,resultType:s});switch(r.type){case"size":return"$view.scale"===r.valueExpression?null:{type:"size",binding:i,field:l,fieldIndex:o,normalizationField:U(e,{target:t,field:r.normalizationField,context:n,resultType:s}).field,valueRepresentation:r.valueRepresentation??null};case"color":return{type:"color",binding:i,field:l,fieldIndex:o,normalizationField:U(e,{target:t,field:r.normalizationField,context:n,resultType:s}).field};case"opacity":return{type:"opacity",binding:i,field:l,fieldIndex:o,normalizationField:U(e,{target:t,field:r.normalizationField,context:n,resultType:s}).field};case"rotation":return{type:"rotation",binding:i,field:l,fieldIndex:o}}})).filter(r)}function $(e,t,r,i,n=!1){const l=s(e,{indexCount:0,fields:{}});switch(r.type){case"simple":case"dot-density":return K(l,r,i,n);case"class-breaks":return Q(l,t,r,i,n);case"unique-value":return W(l,t,r,i,n);case"dictionary":return X(l,r,i,n);case"heatmap":return Z(l,r,i,n);case"pie-chart":return Y(l,r,i,n)}}function K(e,t,r,i=!1){const n=t.getSymbols(),s=n.length?n[0]:null;return{type:"simple",symbol:y(s,r,i),symbologyType:r.symbologyType}}function Y(e,t,r,i=!1){const n=t.getSymbols(),s=n[0],l=n.length>1?n[1]:null;return{type:"pie-chart",markerSymbol:y(s,r,i),fillSymbol:y(l,r,i),symbologyType:r.symbologyType}}function Q(e,t,r,i,n=!1){const s={mesh:!0,use:"renderer.field"},l=r.backgroundFillSymbol,{field:o,fieldIndex:a}=U(e,{target:t,field:r.field,valueExpression:r.valueExpression,resultType:"numeric",context:s}),u=r.normalizationType,d="log"===u?"esriNormalizeByLog":"percent-of-total"===u?"esriNormalizeByPercentOfTotal":"field"===u?"esriNormalizeByField":null,f=r.classBreakInfos.map((e=>({symbol:y(e.symbol,i,n),min:e.minValue,max:e.maxValue}))).sort(((e,t)=>e.min-t.min));return{type:"interval",attributes:e.fields,field:o,fieldIndex:a,backgroundFillSymbol:y(l,i,n),defaultSymbol:y(r.defaultSymbol,i,n),intervals:f,normalizationField:r.normalizationField,normalizationTotal:r.normalizationTotal,normalizationType:d,isMaxInclusive:r.isMaxInclusive,symbologyType:i.symbologyType}}function W(t,r,i,n,s=!1){const l=[],o=i.backgroundFillSymbol,a={target:r,context:{mesh:!0},resultType:"string"};if(i.field&&"string"!=typeof i.field)throw new e(S,"Expected renderer.field to be a string",i);const{field:u,fieldIndex:d}=U(t,{...a,field:i.field,valueExpression:i.valueExpression});for(const e of i.uniqueValueInfos??[])l.push({value:""+e.value,symbol:y(e.symbol,n,s)});return{type:"map",attributes:t.fields,field:u,fieldIndex:d,field2:U(t,{...a,field:i.field2}).field,field3:U(t,{...a,field:i.field3}).field,fieldDelimiter:i.fieldDelimiter??void 0,backgroundFillSymbol:y(o,n),defaultSymbol:y(i.defaultSymbol,n),map:l,symbologyType:n.symbologyType}}function X(e,t,r,i=!1){return{type:"dictionary",config:t.config,fieldMap:t.fieldMap,scaleExpression:t.scaleExpression,url:t.url,symbolOptions:r,symbologyType:r.symbologyType}}function Z(e,t,r,i=!1){const n=t.getSymbols(),s=n.length?n[0]:null;return{type:"heatmap",symbol:y(s,r,i),symbologyType:r.symbologyType}}export{_ as addAggregateFields,$ as createMatcherSchema,U as createRendererAttributeSchema,F as createSchema,y as createSymbolSchema,w as createSymbolSchemaOptions};
5
+ import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import t from"../../../../core/Logger.js";import{isSome as r,unwrap as i,isNone as n,unwrapOr as s}from"../../../../core/maybe.js";import{pt2px as l}from"../../../../core/screenUtils.js";import{sqlAnd as o}from"../../../../core/sql.js";import{diff as a}from"../../../../core/accessorSupport/diffUtils.js";import{validateLabelingInfo as u}from"../../../../layers/support/labelingInfo.js";import{WGLSymbologyType as d}from"../../engine/webgl/enums.js";import{getVVType as f}from"../../engine/webgl/Utils.js";import{getTechniqueFromRenderer as p}from"../../engine/webgl/techniques/utils.js";import{getVVFlags as c}from"../../engine/webgl/util/vvFlagUtils.js";import{createSymbolSchema as y}from"./createSymbolSchema.js";import{getPtMaxVVSize as m}from"./support/pixelBuffering.js";import{getSupportedHeatmapRenderer as g,simplifyVisualVariables as b}from"./support/rendererUtils.js";import{injectDynamicLevelDependentSizeVisualVariable as x,createClusterRenderer as h}from"../support/clusterUtils.js";import{toJSONGeometryType as v}from"../support/util.js";const T=t.getLogger("esri.views.2d.layers.features.schemaUtils"),S="ValidationError";function E(e){return e}function w(e,t){let i=0,n=0,s=d.DEFAULT;if(r(e)){if(n=m(e,t),"visualVariables"in e&&(i=c(e.visualVariables||[]),"dot-density"===e.type&&(s=d.DOT_DENSITY)),"heatmap"===e.type&&(s=d.HEATMAP),"dictionary"===e.type)return{maxVVSize:n,vvFlags:i,symbologyType:d.DEFAULT};if("pie-chart"===e.type)return{maxVVSize:n,vvFlags:i,symbologyType:d.PIE_CHART};if(s!==d.DOT_DENSITY&&s!==d.HEATMAP){const t=e.getSymbols();"backgroundFillSymbol"in e&&e.backgroundFillSymbol&&t.push(e.backgroundFillSymbol);let r=!0,i=!0;for(const e of t)if("cim"===e.type&&(i=!1),"simple-fill"===e.type||"picture-fill"===e.type){const t=e.outline,n=t&&"none"!==t.style&&"solid"!==t.style,s="simple-fill"===e.type&&"none"!==e.style&&"solid"!==e.style;n&&(r=!1),("picture-fill"===e.type||s||n)&&(i=!1)}r?s=i?d.OUTLINE_FILL_SIMPLE:d.OUTLINE_FILL:i&&(s=d.SIMPLE)}}return{vvFlags:i,maxVVSize:n,symbologyType:s}}let I=null;function F(e){if(has("esri-2d-update-debug")){const t=V(e,!0);console.debug("Created new schema",t),console.debug("Schema diff",a(I,t)),I=t}return V(e)}function V(e,t=!1){try{const n=D(e,t),s=C(e),l={};n.map((t=>O(l,e,t)));const a=r(e.subtypeCode)?`${e.subtypeField} = ${e.subtypeCode}`:null,u=i(o(e.definitionExpression,a));return{source:{definitionExpression:u,fields:e.fields.map((e=>e.toJSON())),gdbVersion:e.gdbVersion,historicMoment:e.historicMoment?.getTime(),outFields:e.availableFields,pixelBuffer:e.pixelBuffer,spatialReference:e.spatialReference.toJSON(),timeExtent:e.timeExtent?.toJSON(),customParameters:e.customParameters},attributes:{fields:{},indexCount:0},processors:n,tileRenderer:s,targets:l}}catch(n){if(n.fieldName===S)return T.error(n),null;throw n}}function O(t,r,i){switch(i.target){case"feature":return void M(t,N(r),i);case"aggregate":{if(!("featureReduction"in r))return;const n=r.featureReduction;switch(n?.type){case"selection":throw new e(S,"Mapview does not support `selection` reduction type",n);case"binning":return M(t,N(r),i),void j(t,n,r.fields.map((e=>e.toJSON())),i);case"cluster":return M(t,N(r),i),void R(t,n,r.fields.map((e=>e.toJSON())),i)}}}}function z(e,t){for(const r in t){const i=t[r];if(i.target!==e.name)continue;const n=e.attributes[r];if(n?.context){const e=n.context;e.mesh=e.mesh||i.context?.mesh,e.storage=e.storage||i.context?.storage}else e.attributes[r]=i}return e}function N(e){return[i(e.filter)?.toJSON()??null,i(i(e.featureEffect)?.filter)?.toJSON()??null]}function M(e,t,r){return e.feature||(e.feature={name:"feature",input:"source",filters:t,attributes:{}}),z(e.feature,r.attributes.fields),e}function L(t,r){const{onStatisticExpression:i,onStatisticField:n,statisticType:s}=t;switch(s){case"min":case"max":case"avg":case"avg_angle":case"sum":case"count":return"esriFieldTypeDouble";case"mode":{if(i){const{returnType:r}=i;return r?"string"===r?"esriFieldTypeString":"esriFieldTypeDouble":(T.error(new e(S,"Unable to infer type of aggregateField with onStatisticExpression. ReturnType is not defined",t)),"esriFieldTypeString")}const s=r.find((e=>e.name===n));return s?s.type:(T.error(new e(S,"Unable to infer type of aggregateField with onStatisticExpression. ReturnType is not defined",t)),"esriFieldTypeString")}}}function j(e,t,r,i){return e.aggregate||(e.aggregate={name:"aggregate",type:"bin",filters:null,input:"feature",params:{fixedBinLevel:t.fixedBinLevel,fields:(t.fields??[]).map((e=>({...e.toJSON(),type:L(e,r)})))},attributes:{}}),z(e.aggregate,i.attributes.fields),e}function R(e,t,r,i){return e.aggregate||(e.aggregate={name:"aggregate",type:"cluster",input:"feature",filters:null,attributes:{},params:{clusterRadius:l(t.clusterRadius/2),clusterPixelBuffer:64*Math.ceil(l(t.clusterMaxSize)/64),fields:(t.fields??[])?.map((e=>({...e.toJSON(),type:L(e,r)})))}}),z(e.aggregate,i.attributes.fields),e}function U(e,t){return t.field?B(e,{...t,type:"field",field:t.field}):t.valueExpression?B(e,{...t,type:"expression",valueExpression:t.valueExpression}):{field:void 0,fieldIndex:void 0}}function B(e,t){switch(t.type){case"expression":{const r=E(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=E(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 D(e,t=!1){const r=new Array;let i=0;return r.push(A(e,i++,t)),r}function P(e,t,r,i,n,s=!1){const l=B(e,{type:"label-expression",target:r,context:{mesh:!0},resultType:"string",label:{labelExpression:t.labelExpression,labelExpressionInfo:t.labelExpressionInfo?{expression:t.labelExpressionInfo.expression}:null,symbol:!!t.symbol,where:t.where}}),{fieldIndex:o}=l;return{...y(t,n,s),fieldIndex:o,target:r,index:i}}function k(t,r,i){const n="featureReduction"in r&&r.featureReduction;if(!n)return{fields:[],labels:[],matcher:void 0,rendererOverride:void 0};const s="aggregate",l=[];let o=null,a=v(r.geometryType),d=[],f=null;if(n)switch(n.type){case"selection":return T.error(new e(S,"Mapview does not support `selection` reduction type",n)),{fields:[],labels:[],matcher:void 0,rendererOverride:void 0};case"cluster":case"binning":if(l.push(...n.fields??[]),"cluster"===n.type?a="esriGeometryPoint":"binning"===n.type&&(a="esriGeometryPolygon"),n.renderer&&!n.renderer.authoringInfo?.isAutoGenerated){if("cluster"===n.type){const{renderer:e}=x(n.renderer,n,null);f=e}else f=n.renderer;const e=w(n.renderer,n);o=$(t,s,n.renderer,e,i),d=n&&n.labelsVisible&&n.labelingInfo||[]}else if("cluster"===n.type){if(f=h(l,r.renderer,n,null,!0),n.symbol){const e=w(f,n);o={type:"simple",symbol:y(n.symbol,e,i),symbologyType:e.symbologyType}}d=n&&n.labelsVisible&&n.labelingInfo||[]}}_(t,l);return{labels:u(d,"binning"===n.type?"esriGeometryPolygon":a),matcher:o,fields:l,rendererOverride:f}}function A(t,i,n=!1){const s={indexCount:0,fields:{}},l="featureReduction"in t?t.featureReduction??void 0:void 0,o=l?"aggregate":"feature";if("sublayers"in t){const i={type:"subtype",subtypeField:t.subtypeField,renderers:{},symbologyType:d.DEFAULT},l={type:"subtype",mapping:{},target:"feature"},a={type:"subtype",classes:{}},u={type:"symbol",target:"feature",aggregateFields:[],attributes:s,storage:l,mesh:{matcher:i,aggregateMatcher:null,labels:a,sortKey:null}},f=new Set;let p=0;for(const{renderer:c,subtypeCode:y,labelingInfo:m,labelsVisible:g}of t.sublayers){const t={symbologyType:d.DEFAULT,vvFlags:0,maxVVSize:0},u=$(s,o,c,t,n),b=q(s,o,c),x=g&&m;if("visualVariables"in c&&c.visualVariables&&c.visualVariables.length)throw new e(S,"Visual variables are currently not supported for subtype layers");if("dictionary"===u.type)throw new e(S,"Dictionary renderer is not supported in subtype layers");if("subtype"===u.type)throw new e(S,"Nested subtype renderers is not supported");if(r(b)&&"subtype"===b.type)throw new e(S,"Nested subtype storage is not supported");if(r(b)&&r(b.attributeMapping))throw new e(S,"Non-visual-variable attributes are not supported in subtype layers");if("heatmap"===u.type)throw new e(S,"Heatmaps are not supported in subtype layers");if("pie-chart"===u.type)throw new e(S,"Pie-charts are not supported in subtype layers");if(f.has(y))throw new e(S,"Subtype codes for sublayers must be unique");f.add(y),i.renderers[y]=u,l.mapping[y]=b,x&&(a.classes[y]=x.map((e=>P(s,e,"feature",p++,t,n))))}return u}if("heatmap"===t.renderer?.type&&"raster"===g()){const{radius:e,fieldOffset:r,field:i}=t.renderer;return{type:"heatmap",aggregateFields:[],attributes:s,target:o,storage:null,mesh:{radius:e,fieldOffset:r,field:U(s,{target:o,field:i,resultType:"numeric"}).field}}}const a=k(s,t,n),f=v(t.geometryType),p=a.rendererOverride??t.renderer,c=w(p,l),y=$(s,o,p,c,n),m=q(s,o,p),b=J(s,t.orderBy,l),x=t.labelsVisible&&t.labelingInfo||[],h=u(x,f);let T=0;const E=[...h.map((e=>P(s,e,"feature",T++,c,n))),...a.labels.map((e=>P(s,e,"aggregate",T++,c,n)))];return{type:"symbol",target:o,attributes:s,aggregateFields:a.fields,storage:m,mesh:{matcher:y,labels:{type:"simple",classes:E},aggregateMatcher:a.matcher,sortKey:b}}}function C(e){return"heatmap"===e.renderer?.type&&"raster"===g()?{type:"heatmap"}:{type:"symbol"}}function J(t,i,s){if(r(s)||n(i)||!i.length)return null;i.length>1&&T.warn(`Layer rendering currently only supports ordering by 1 orderByInfo, but found ${i.length}. All but the first will be discarded`);const l=i[0],o="ascending"===l.order?"asc":"desc";if(l.field)return{field:l.field,order:o};if(l.valueExpression){return{fieldIndex:B(t,{type:"expression",target:"feature",valueExpression:l.valueExpression,resultType:"numeric"}).fieldIndex,order:o}}return T.error(new e(S,"Expected to find a field or valueExpression for OrderByInfo",l)),null}function _(e,t){const r={mesh:!0,storage:!0};for(const i of t){const{name:t,onStatisticField:n,onStatisticExpression:s,statisticType:l}=i;let o,a;const u="numeric",d="feature";if(s){a=B(e,{type:"expression",target:d,valueExpression:s.expression,resultType:u}).fieldIndex}else{o=B(e,{type:"field",target:d,field:n,resultType:u}).field}B(e,{type:"statistic",target:"aggregate",name:t,context:r,inField:o,inFieldIndex:a,statisticType:l})}}function q(e,t,r){let i;switch(r.type){case"simple":case"class-breaks":case"unique-value":case"dictionary":i={visualVariables:!0,attributes:null};break;default:i=p(r).getStorageSpec(r)}return G(e,t,i,r)}function G(e,t,i,s){if(n(i))return null;const{visualVariables:l,attributes:o}=i;let a=null;l&&"visualVariables"in s&&(a=H(e,t,s.visualVariables));const u=r(a)?4:0;let d=null;return r(o)&&(d=o.map(((r,i)=>{const{field:n,fieldIndex:s}=U(e,{valueExpression:r.valueExpression,field:r.field,resultType:"numeric",target:t});return{binding:i+u,field:n,fieldIndex:s}}))),{type:"simple",target:t,attributeMapping:d,vvMapping:a}}function H(e,t,i){if(!i||!i.length)return[];const n={storage:!0},s="numeric";return b(i).map((r=>{const i=f(r.type),{field:l,fieldIndex:o}=U(e,{target:t,valueExpression:r.valueExpression,field:r.field,context:n,resultType:s});switch(r.type){case"size":return"$view.scale"===r.valueExpression?null:{type:"size",binding:i,field:l,fieldIndex:o,normalizationField:U(e,{target:t,field:r.normalizationField,context:n,resultType:s}).field,valueRepresentation:r.valueRepresentation??null};case"color":return{type:"color",binding:i,field:l,fieldIndex:o,normalizationField:U(e,{target:t,field:r.normalizationField,context:n,resultType:s}).field};case"opacity":return{type:"opacity",binding:i,field:l,fieldIndex:o,normalizationField:U(e,{target:t,field:r.normalizationField,context:n,resultType:s}).field};case"rotation":return{type:"rotation",binding:i,field:l,fieldIndex:o}}})).filter(r)}function $(e,t,r,i,n=!1){const l=s(e,{indexCount:0,fields:{}});switch(r.type){case"simple":case"dot-density":return K(l,r,i,n);case"class-breaks":return Q(l,t,r,i,n);case"unique-value":return W(l,t,r,i,n);case"dictionary":return X(l,r,i,n);case"heatmap":return Z(l,r,i,n);case"pie-chart":return Y(l,r,i,n)}}function K(e,t,r,i=!1){const n=t.getSymbols(),s=n.length?n[0]:null;return{type:"simple",symbol:y(s,r,i),symbologyType:r.symbologyType}}function Y(e,t,r,i=!1){const n=t.getSymbols(),s=n[0],l=n.length>1?n[1]:null;return{type:"pie-chart",markerSymbol:y(s,r,i),fillSymbol:y(l,r,i),symbologyType:r.symbologyType}}function Q(e,t,r,i,n=!1){const s={mesh:!0,use:"renderer.field"},l=r.backgroundFillSymbol,{field:o,fieldIndex:a}=U(e,{target:t,field:r.field,valueExpression:r.valueExpression,resultType:"numeric",context:s}),u=r.normalizationType,d="log"===u?"esriNormalizeByLog":"percent-of-total"===u?"esriNormalizeByPercentOfTotal":"field"===u?"esriNormalizeByField":null,f=r.classBreakInfos.map((e=>({symbol:y(e.symbol,i,n),min:e.minValue,max:e.maxValue}))).sort(((e,t)=>e.min-t.min));return{type:"interval",attributes:e.fields,field:o,fieldIndex:a,backgroundFillSymbol:y(l,i,n),defaultSymbol:y(r.defaultSymbol,i,n),intervals:f,normalizationField:r.normalizationField,normalizationTotal:r.normalizationTotal,normalizationType:d,isMaxInclusive:r.isMaxInclusive,symbologyType:i.symbologyType}}function W(t,r,i,n,s=!1){const l=[],o=i.backgroundFillSymbol,a={target:r,context:{mesh:!0},resultType:"string"};if(i.field&&"string"!=typeof i.field)throw new e(S,"Expected renderer.field to be a string",i);const{field:u,fieldIndex:d}=U(t,{...a,field:i.field,valueExpression:i.valueExpression});for(const e of i.uniqueValueInfos??[])l.push({value:""+e.value,symbol:y(e.symbol,n,s)});return{type:"map",attributes:t.fields,field:u,fieldIndex:d,field2:U(t,{...a,field:i.field2}).field,field3:U(t,{...a,field:i.field3}).field,fieldDelimiter:i.fieldDelimiter??void 0,backgroundFillSymbol:y(o,n),defaultSymbol:y(i.defaultSymbol,n),map:l,symbologyType:n.symbologyType}}function X(e,t,r,i=!1){return{type:"dictionary",config:t.config,fieldMap:t.fieldMap,scaleExpression:t.scaleExpression,url:t.url,symbolOptions:r,symbologyType:r.symbologyType}}function Z(e,t,r,i=!1){const n=t.getSymbols(),s=n.length?n[0]:null;return{type:"heatmap",symbol:y(s,r,i),symbologyType:r.symbologyType}}export{_ as addAggregateFields,$ as createMatcherSchema,U as createRendererAttributeSchema,F as createSchema,y as createSymbolSchema,w as createSymbolSchemaOptions};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../../core/has.js";import{isSome as e}from"../../../../../core/maybe.js";import{watch as t}from"../../../../../core/reactiveUtils.js";import{r as s}from"../../../../../chunks/rbush.js";import{convertFromFeature as r,quantizeOptimizedGeometry as i,quantizeX as n,quantizeY as a}from"../../../../../layers/graphics/featureConversionUtils.js";import o from"../../../../../layers/graphics/OptimizedGeometry.js";import{StreamFeatureManager as d}from"../../../../../layers/graphics/data/StreamFeatureManager.js";import{createConnection as c}from"../../../../../layers/graphics/sources/connections/createConnection.js";import{DataTileSource as h}from"./DataTileSource.js";import{FeatureSetReaderJSON as u}from"../support/FeatureSetReaderJSON.js";import{UpdateToken as p}from"../support/UpdateToken.js";const l=2500;function m(t,s){const r=t.weakClone();if(e(t.geometry)){const e=n(s,t.geometry.coords[0]),i=a(s,t.geometry.coords[1]);r.geometry=new o([],[e,i])}return r}function _(e){return"esriGeometryPoint"===e?m:(t,s)=>{const r=t.weakClone(),n=new o,a=!1,d=!1,c=i(n,t.geometry,a,d,e,s,!1,!1);return r.geometry=c,r}}function v(t){return"esriGeometryPoint"===t?t=>e(t.geometry)?{minX:t.geometry.coords[0],minY:t.geometry.coords[1],maxX:t.geometry.coords[0],maxY:t.geometry.coords[1]}:{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}:t=>{let s=1/0,r=1/0,i=-1/0,n=-1/0;return e(t.geometry)&&t.geometry.forEachVertex(((e,t)=>{s=Math.min(s,e),r=Math.min(r,t),i=Math.max(i,e),n=Math.max(n,t)})),{minX:s,minY:r,maxX:i,maxY:n}}}function f(e,t){const r=s(9,v(t));return r.load(e),r}function g(e,t){return e.search({minX:t.bounds[0],minY:t.bounds[1],maxX:t.bounds[2],maxY:t.bounds[3]})}class y{constructor(e,t){this.onUpdate=e,this._geometryType=t,this._objectIdToFeature=new Map,this._index=null}get _features(){const e=[];return this._objectIdToFeature.forEach((t=>e.push(t))),e}add(e){this._objectIdToFeature.set(e.objectId,e),this._index=null}get(e){return this._objectIdToFeature.has(e)?this._objectIdToFeature.get(e):null}forEach(e){this._objectIdToFeature.forEach(e)}search(e){return this._index||(this._index=f(this._features,this._geometryType)),g(this._index,e)}removeById(e){const t=this._objectIdToFeature.get(e);return t?(this._objectIdToFeature.delete(e),this._index=null,t):null}update(e,t){this.onUpdate(e,t)}get size(){return this._objectIdToFeature.size}}class b extends h{constructor(e){super(e),this.type="geoevent",this._updateIntervalId=0,this._dataReceiveEventEnabled=!1,this._level=0,this._updateInfo={websocket:0,client:0},this._inUpdate=!1;const{outSR:s}=e,{geometryType:r,objectIdField:i,timeInfo:n,purgeOptions:a,source:o,spatialReference:h,serviceFilter:u,maxReconnectionAttempts:p,maxReconnectionInterval:m,updateInterval:v,enableDataReceived:f,customParameters:g}=e.serviceInfo,b=new y(this._onUpdate.bind(this),r),I=new d(b,i,n,a),U=c(o,h,s,r,u,p,m,g??{});this._store=b,this._manager=I,this._connection=U,this._quantize=_(r),this._dataReceiveEventEnabled=f,this._handles=[this._connection.on("data-received",(e=>this._onFeature(e))),t((()=>U.connectionStatus),(e=>this.events.emit("connectionStatus",e))),t((()=>U.errorString),(e=>this.events.emit("errorString",e)))],this._initUpdateInterval=()=>{let t=performance.now();this._updateIntervalId=setInterval((()=>{const s=performance.now(),r=s-t;if(r>l){t=s;const e=Math.round(this._updateInfo.client/(r/1e3)),i=Math.round(this._updateInfo.websocket/(r/1e3));this._updateInfo.client=0,this._updateInfo.websocket=0,this.events.emit("updateRate",{client:e,websocket:i})}e.canAcceptRequest()&&!this._inUpdate&&this._manager.checkForUpdates()}),v)},this._initUpdateInterval()}destroy(){super.destroy(),this._clearUpdateInterval(),this._handles.forEach((e=>e.remove())),this._connection.destroy()}_fetchDataTile(){}pauseStream(){this._clearUpdateInterval()}resumeStream(){this._initUpdateInterval()}enableEvent(e,t){"data-received"===e&&(this._dataReceiveEventEnabled=t)}get updating(){return!1}subscribe(e,t){super.subscribe(e,t);const s=this._subscriptions.get(e.id);this._level=e.level;const r=this._getTileFeatures(e);this._onMessage({type:"append",id:e.key.id,addOrUpdate:r,end:!0}),s.didSend=!0}unsubscribe(e){super.unsubscribe(e)}*readers(t){const s=this._subscriptions.get(t),{tile:r}=s;yield this._getTileFeatures(r);for(const i of s.requests.stream.entries)e(i)&&e(i.addOrUpdate)&&(yield i.addOrUpdate)}createTileQuery(e){throw new Error("Service does not support tile queries")}async resend(){this._subscriptions.forEach((e=>{const{tile:t}=e,s={type:"append",id:t.id,addOrUpdate:this._getTileFeatures(t),end:!0};this._onMessage(s)}))}_getTileFeatures(e){const t=this._store.search(e).map((t=>this._quantize(t,e.transform)));return u.fromOptimizedFeatures(t,this._serviceInfo,e.transform)}_onFeature(e){this._updateInfo.websocket++;try{this._dataReceiveEventEnabled&&this.events.emit("data-received",e);const t=r(e,this._serviceInfo.geometryType,!1,!1,this._serviceInfo.objectIdField);this._manager.add(t)}catch(t){}}_clearUpdateInterval(){clearInterval(this._updateIntervalId),this._updateIntervalId=0}async _onUpdate(t,s){this._inUpdate=!0;try{e(t)&&(this._updateInfo.client+=t.length),this._subscriptions.forEach(((e,t)=>{e.didSend&&e.tile.level===this._level&&this._onMessage({type:"append",id:t,addOrUpdate:null,clear:!0,end:!1})}));const s=[];this._subscriptions.forEach(((e,t)=>{if(!e.didSend||e.tile.level!==this._level)return;const r=e.tile,i={type:"append",id:t,addOrUpdate:this._getTileFeatures(r),remove:[],end:!1,status:p.empty()};e.requests.stream.enqueue(i),s.push(this._onMessage(i))})),await Promise.all(s),this._subscriptions.forEach(((e,t)=>{e.didSend&&e.tile.level===this._level&&this._onMessage({type:"append",id:t,addOrUpdate:null,end:!0})}))}catch{}this._inUpdate=!1}}export{b as GeoEventSource};
5
+ import"../../../../../core/has.js";import{isSome as e}from"../../../../../core/maybe.js";import{watch as t}from"../../../../../core/reactiveUtils.js";import{r as s}from"../../../../../chunks/rbush.js";import{convertFromFeature as i,quantizeOptimizedGeometry as n,quantizeX as r,quantizeY as o}from"../../../../../layers/graphics/featureConversionUtils.js";import a from"../../../../../layers/graphics/OptimizedGeometry.js";import{StreamFeatureManager as c}from"../../../../../layers/graphics/data/StreamFeatureManager.js";import{createConnection as d}from"../../../../../layers/graphics/sources/connections/createConnection.js";import{DataTileSource as h}from"./DataTileSource.js";import{FeatureSetReaderJSON as u}from"../support/FeatureSetReaderJSON.js";import{UpdateToken as l}from"../support/UpdateToken.js";const p=2500;function m(t,s){const i=t.weakClone();if(e(t.geometry)){const e=r(s,t.geometry.coords[0]),n=o(s,t.geometry.coords[1]);i.geometry=new a([],[e,n])}return i}function _(e){return"esriGeometryPoint"===e?m:(t,s)=>{const i=t.weakClone(),r=new a,o=!1,c=!1,d=n(r,t.geometry,o,c,e,s,!1,!1);return i.geometry=d,i}}function v(t){return"esriGeometryPoint"===t?t=>e(t.geometry)?{minX:t.geometry.coords[0],minY:t.geometry.coords[1],maxX:t.geometry.coords[0],maxY:t.geometry.coords[1]}:{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}:t=>{let s=1/0,i=1/0,n=-1/0,r=-1/0;return e(t.geometry)&&t.geometry.forEachVertex(((e,t)=>{s=Math.min(s,e),i=Math.min(i,t),n=Math.max(n,e),r=Math.max(r,t)})),{minX:s,minY:i,maxX:n,maxY:r}}}function g(e,t){const i=s(9,v(t));return i.load(e),i}function f(e,t){return e.search({minX:t.bounds[0],minY:t.bounds[1],maxX:t.bounds[2],maxY:t.bounds[3]})}class y{constructor(e,t){this.onUpdate=e,this._geometryType=t,this._objectIdToFeature=new Map,this._index=null}get _features(){const e=[];return this._objectIdToFeature.forEach((t=>e.push(t))),e}add(e){this._objectIdToFeature.set(e.objectId,e),this._index=null}get(e){return this._objectIdToFeature.has(e)?this._objectIdToFeature.get(e):null}forEach(e){this._objectIdToFeature.forEach(e)}search(e){return this._index||(this._index=g(this._features,this._geometryType)),f(this._index,e)}clear(){this._index=null,this._objectIdToFeature.clear()}removeById(e){const t=this._objectIdToFeature.get(e);return t?(this._objectIdToFeature.delete(e),this._index=null,t):null}update(e,t){this.onUpdate(e,t)}get size(){return this._objectIdToFeature.size}}class I extends h{constructor(e){super(e),this.type="geoevent",this._updateIntervalId=0,this._dataReceiveEventEnabled=!1,this._level=0,this._updateInfo={websocket:0,client:0},this._inUpdate=!1;const{outSR:s}=e,{geometryType:i,objectIdField:n,timeInfo:r,purgeOptions:o,source:a,spatialReference:h,serviceFilter:u,maxReconnectionAttempts:l,maxReconnectionInterval:m,updateInterval:v,enableDataReceived:g,customParameters:f}=e.serviceInfo,I=new y(this._onUpdate.bind(this),i),b=new c(I,n,r,o),j=d(a,h,s,i,u,l,m,f??{});this._store=I,this._manager=b,this._connection=j,this._quantize=_(i),this._dataReceiveEventEnabled=g,this._handles=[this._connection.on("data-received",(e=>this._onFeature(e))),this._connection.on("message-received",(e=>this._onWebSocketMessage(e))),t((()=>j.connectionStatus),(e=>this.events.emit("connectionStatus",e))),t((()=>j.errorString),(e=>this.events.emit("errorString",e)))],this._initUpdateInterval=()=>{let t=performance.now();this._updateIntervalId=setInterval((()=>{const s=performance.now(),i=s-t;if(i>p){t=s;const e=Math.round(this._updateInfo.client/(i/1e3)),n=Math.round(this._updateInfo.websocket/(i/1e3));this._updateInfo.client=0,this._updateInfo.websocket=0,this.events.emit("updateRate",{client:e,websocket:n})}e.canAcceptRequest()&&!this._inUpdate&&this._manager.checkForUpdates()}),v)},this._initUpdateInterval()}destroy(){super.destroy(),this._clearUpdateInterval(),this._handles.forEach((e=>e.remove())),this._connection.destroy()}_fetchDataTile(){}pauseStream(){this._clearUpdateInterval(),this.events.emit("connectionStatus","paused")}resumeStream(){this._initUpdateInterval(),this.events.emit("connectionStatus",this._connection.connectionStatus)}sendMessage(e){this._connection.sendMessage(e)}receiveMessage(e){this._connection.receiveMessage(e)}enableEvent(e,t){"data-received"===e&&(this._dataReceiveEventEnabled=t)}get updating(){return!1}subscribe(e,t){super.subscribe(e,t);const s=this._subscriptions.get(e.id);this._level=e.level;const i=this._getTileFeatures(e);this._onMessage({type:"append",id:e.key.id,addOrUpdate:i,end:!0}),s.didSend=!0}unsubscribe(e){super.unsubscribe(e)}*readers(e){const t=this._subscriptions.get(e),{tile:s}=t;yield this._getTileFeatures(s)}createTileQuery(e){throw new Error("Service does not support tile queries")}async resend(){this._subscriptions.forEach((e=>{const{tile:t}=e,s={type:"append",id:t.id,addOrUpdate:this._getTileFeatures(t),end:!0};this._onMessage(s)}))}_getTileFeatures(e){const t=this._store.search(e).map((t=>this._quantize(t,e.transform)));return u.fromOptimizedFeatures(t,this._serviceInfo,e.transform)}_onWebSocketMessage(e){if(this.events.emit("message-received",e),"type"in e)switch(e.type){case"delete":if(e.objectIds)for(const t of e.objectIds)this._manager.removeById(t);if(e.trackIds)for(const t of e.trackIds)this._manager.removeByTrackId(t);break;case"clear":this._store.forEach((e=>this._manager.removeById(e.objectId)))}}_onFeature(e){this._updateInfo.websocket++;try{this._dataReceiveEventEnabled&&this.events.emit("data-received",e);const t=i(e,this._serviceInfo.geometryType,!1,!1,this._serviceInfo.objectIdField);this._manager.add(t)}catch(t){}}_clearUpdateInterval(){clearInterval(this._updateIntervalId),this._updateIntervalId=0}async _onUpdate(t,s){this._inUpdate=!0;try{e(t)&&(this._updateInfo.client+=t.length),this._subscriptions.forEach(((e,t)=>{e.didSend&&e.tile.level===this._level&&this._onMessage({type:"append",id:t,addOrUpdate:null,clear:!0,end:!1})}));const s=[];this._subscriptions.forEach(((e,t)=>{if(!e.didSend||e.tile.level!==this._level)return;const i=e.tile,n={type:"append",id:t,addOrUpdate:this._getTileFeatures(i),remove:[],end:!1,status:l.empty()};e.requests.stream.enqueue(n),s.push(this._onMessage(n))})),await Promise.all(s),this._subscriptions.forEach(((e,t)=>{e.didSend&&e.tile.level===this._level&&this._onMessage({type:"append",id:t,addOrUpdate:null,end:!0})}))}catch{}this._inUpdate=!1}}export{I as GeoEventSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../../geometry.js";import{ArcadeDate as e}from"../../../../../arcade/ArcadeDate.js";import{DateTimeReferenceFieldIndex as t}from"../../../../../arcade/arcadeTimeUtils.js";import has from"../../../../../core/has.js";import{isSome as r,isNone as s,unwrapOrThrow as i,unwrapOr as a}from"../../../../../core/maybe.js";import{getCentroidOptimizedGeometry as n}from"../../../../../layers/graphics/centroid.js";import{convertToGeometry as o}from"../../../../../layers/graphics/featureConversionUtils.js";import d from"../../../../../layers/graphics/OptimizedGeometry.js";import{StaticBitSet as h}from"./StaticBitSet.js";import{fromJSON as u}from"../../../../../geometry/support/jsonUtils.js";let c=0;const l=has("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],m=l[0],f=l[1],g=l[2],_=l[3],y=has("featurelayer-simplify-payload-size-factors")??[1,2,4],p=y[0],x=y[1],I=y[2],A=has("featurelayer-simplify-mobile-factor")??2,S=has("esri-mobile");class b{constructor(e,t){this.type="FeatureSetReader",this.arcadeDeclaredClass="esri.arcade.Feature",this.seen=!1,this.instance=0,this._tx=0,this._ty=0,this._sx=1,this._sy=1,this._deleted=null,this._joined=[],this._objectIdToIndex=null,this._level=0,this._datetimeMetadata=null,this.instance=e,this._layerSchema=t}static createInstance(){return c++,c=c>65535?0:c,c}get isEmpty(){return r(this._deleted)&&this._deleted.countSet()===this.getSize()}set level(e){this._level=e}getAreaSimplificationThreshold(e,t){let r=1;const s=S?A:1;t>4e6?r=I*s:t>1e6?r=x*s:t>5e5?r=p*s:t>1e5&&(r=s);let i=0;e>4e3?i=_*r:e>2e3?i=g*r:e>100?i=f:e>15&&(i=m);let a=8;return this._level<4?a=1:this._level<5?a=2:this._level<6&&(a=4),i*a}createQuantizedExtrudedQuad(e,t){return new d([5],[e-1,t,1,-1,1,1,-1,1,-1,-1])}setArcadeSpatialReference(e){this._arcadeSpatialReference=e}attachStorage(e){this._storage=e}getQuantizationTransform(){throw new Error("Unable to find transform for featureSet")}getStorage(){return this._storage}getComputedNumeric(e){return this.getComputedNumericAtIndex(0)}setComputedNumeric(e,t){return this.setComputedNumericAtIndex(t,0)}getComputedString(e){return this.getComputedStringAtIndex(0)}setComputedString(e,t){return this.setComputedStringAtIndex(0,t)}getComputedNumericAtIndex(e){return this._storage.getComputedNumericAtIndex(this.getDisplayId(),e)}setComputedNumericAtIndex(e,t){this._storage.setComputedNumericAtIndex(this.getDisplayId(),e,t)}getComputedStringAtIndex(e){return this._storage.getComputedStringAtIndex(this.getDisplayId(),e)}setComputedStringAtIndex(e,t){return this._storage.setComputedStringAtIndex(this.getDisplayId(),e,t)}transform(e,t,r,s){const i=this.copy();return i._tx+=e,i._ty+=t,i._sx*=r,i._sy*=s,i}readAttribute(e,t=!1){const r=this._readAttribute(e,t);if(void 0!==r)return r;for(const s of this._joined){s.setIndex(this.getIndex());const r=s._readAttribute(e,t);if(void 0!==r)return r}}readAttributes(){const e=this._readAttributes();for(const t of this._joined){t.setIndex(this.getIndex());const r=t._readAttributes();for(const t of Object.keys(r))e[t]=r[t]}return e}joinAttributes(e){this._joined.push(e)}readArcadeFeature(){return this}geometry(){const e=this.readHydratedGeometry(),t=o(e,this.geometryType,this.hasZ,this.hasM),r=u(t);return r&&(r.spatialReference=this._arcadeSpatialReference),r}get dateTimeReferenceFieldIndex(){return this._datetimeMetadata||(this._datetimeMetadata=t.create(this._layerSchema.fields,this._layerSchema)),this._datetimeMetadata}autocastArcadeDate(t,r){return r&&r instanceof Date?this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(r):e.dateJSToArcadeDate(r):r}isUnknownDateTimeField(e){return"unknown"===this.dateTimeReferenceFieldIndex?.fieldTimeZone(e)}fieldSourceTimeZone(e){return this.dateTimeReferenceFieldIndex?.fieldTimeZone(e)??""}get layerPreferredTimeZone(){return this.dateTimeReferenceFieldIndex?.layerPreferredTimeZone??""}field(e){if(this.hasField(e))return this.autocastArcadeDate(e,this.readAttribute(e,!0));for(const t of this._joined)if(t.setIndex(this.getIndex()),t.hasField(e)){const r=t._readAttribute(e,!0);return this.autocastArcadeDate(e,r)}throw new Error(`Field ${e} does not exist`)}setField(e,t){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.getFieldNames()}castToText(e=!1){if(!e)return JSON.stringify(this.readLegacyFeature());const t=this.readLegacyFeature();if(!t)return JSON.stringify(null);const r={geometry:t.geometry,attributes:{...t.attributes?t.attributes:{}}};for(const s in r.attributes){const e=r.attributes[s];e instanceof Date&&(r.attributes[s]=e.getTime())}return JSON.stringify(r)}gdbVersion(){return null}fullSchema(){return this._layerSchema}castAsJson(e=null){return{attributes:this._readAttributes(),geometry:!0===e?.keepGeometryType?this.geometry():this.geometry().toJSON()}}castAsJsonAsync(e=null,t=null){return Promise.resolve(this.castAsJson(t))}removeIds(e){if(s(this._objectIdToIndex)){const e=new Map,t=this.getCursor();for(;t.next();){const r=i(t.getObjectId());e.set(r,t.getIndex())}this._objectIdToIndex=e}const t=this._objectIdToIndex;for(const r of e)t.has(r)&&this.removeAtIndex(t.get(r))}removeAtIndex(e){s(this._deleted)&&(this._deleted=h.create(this.getSize())),this._deleted.set(e)}readGeometryForDisplay(){return this.readUnquantizedGeometry(!0)}readLegacyGeometryForDisplay(){return this.readLegacyGeometry(!0)}*features(){const e=this.getCursor();for(;e.next();)yield e.readOptimizedFeature()}_getExists(){return s(this._deleted)||!this._deleted.has(this.getIndex())}_computeCentroid(){if("esriGeometryPolygon"!==this.geometryType)return null;const e=this.readUnquantizedGeometry();if(!e||e.hasIndeterminateRingOrder)return null;const t=a(this.getQuantizationTransform(),null);return n(new d,e,this.hasM,this.hasZ,t)}copyInto(e){e.seen=this.seen,e._storage=this._storage,e._arcadeSpatialReference=this._arcadeSpatialReference,e._joined=this._joined,e._tx=this._tx,e._ty=this._ty,e._sx=this._sx,e._sy=this._sy,e._deleted=this._deleted,e._objectIdToIndex=this._objectIdToIndex}}export{b as FeatureSetReader};
5
+ import"../../../../../geometry.js";import{ArcadeDate as e}from"../../../../../arcade/ArcadeDate.js";import{DateTimeReferenceFieldIndex as t}from"../../../../../arcade/arcadeTimeUtils.js";import has from"../../../../../core/has.js";import{isSome as r,isNone as s,unwrapOrThrow as i,unwrapOr as a}from"../../../../../core/maybe.js";import{getCentroidOptimizedGeometry as n}from"../../../../../layers/graphics/centroid.js";import{convertToGeometry as o}from"../../../../../layers/graphics/featureConversionUtils.js";import d from"../../../../../layers/graphics/OptimizedGeometry.js";import{StaticBitSet as h}from"./StaticBitSet.js";import{fromJSON as u}from"../../../../../geometry/support/jsonUtils.js";let c=0;const l=has("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],m=l[0],f=l[1],g=l[2],_=l[3],y=has("featurelayer-simplify-payload-size-factors")??[1,2,4],p=y[0],x=y[1],I=y[2],A=has("featurelayer-simplify-mobile-factor")??2,S=has("esri-mobile");class b{constructor(e,t){this.type="FeatureSetReader",this.arcadeDeclaredClass="esri.arcade.Feature",this.seen=!1,this.instance=0,this._tx=0,this._ty=0,this._sx=1,this._sy=1,this._deleted=null,this._joined=[],this._objectIdToIndex=null,this._level=0,this._datetimeMetadata=null,this.instance=e,this._layerSchema=t}static createInstance(){return c++,c=c>65535?0:c,c}get isEmpty(){return r(this._deleted)&&this._deleted.countSet()===this.getSize()}set level(e){this._level=e}getAreaSimplificationThreshold(e,t){let r=1;const s=S?A:1;t>4e6?r=I*s:t>1e6?r=x*s:t>5e5?r=p*s:t>1e5&&(r=s);let i=0;e>4e3?i=_*r:e>2e3?i=g*r:e>100?i=f:e>15&&(i=m);let a=8;return this._level<4?a=1:this._level<5?a=2:this._level<6&&(a=4),i*a}createQuantizedExtrudedQuad(e,t){return new d([5],[e-1,t,1,-1,1,1,-1,1,-1,-1])}setArcadeSpatialReference(e){this._arcadeSpatialReference=e}attachStorage(e){this._storage=e}getQuantizationTransform(){throw new Error("Unable to find transform for featureSet")}getStorage(){return this._storage}getComputedNumeric(e){return this.getComputedNumericAtIndex(0)}setComputedNumeric(e,t){return this.setComputedNumericAtIndex(t,0)}getComputedString(e){return this.getComputedStringAtIndex(0)}setComputedString(e,t){return this.setComputedStringAtIndex(0,t)}getComputedNumericAtIndex(e){return this._storage.getComputedNumericAtIndex(this.getDisplayId(),e)}setComputedNumericAtIndex(e,t){this._storage.setComputedNumericAtIndex(this.getDisplayId(),e,t)}getComputedStringAtIndex(e){return this._storage.getComputedStringAtIndex(this.getDisplayId(),e)}setComputedStringAtIndex(e,t){return this._storage.setComputedStringAtIndex(this.getDisplayId(),e,t)}transform(e,t,r,s){const i=this.copy();return i._tx+=e,i._ty+=t,i._sx*=r,i._sy*=s,i}readAttribute(e,t=!1){const r=this._readAttribute(e,t);if(void 0!==r)return r;for(const s of this._joined){s.setIndex(this.getIndex());const r=s._readAttribute(e,t);if(void 0!==r)return r}}readAttributes(){const e=this._readAttributes();for(const t of this._joined){t.setIndex(this.getIndex());const r=t._readAttributes();for(const t of Object.keys(r))e[t]=r[t]}return e}joinAttributes(e){this._joined.push(e)}readArcadeFeature(){return this}geometry(){const e=this.readHydratedGeometry(),t=o(e,this.geometryType,this.hasZ,this.hasM),r=u(t);return r&&(r.spatialReference=this._arcadeSpatialReference),r}get dateTimeReferenceFieldIndex(){return this._datetimeMetadata||(this._datetimeMetadata=t.create(this._layerSchema.fields,this._layerSchema)),this._datetimeMetadata}autocastArcadeDate(t,r){return r&&r instanceof Date?this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(r):e.dateJSToArcadeDate(r):r}isUnknownDateTimeField(e){return"unknown"===this.dateTimeReferenceFieldIndex?.fieldTimeZone(e)}fieldSourceTimeZone(e){return this.dateTimeReferenceFieldIndex?.fieldTimeZone(e)??""}get layerPreferredTimeZone(){return this.dateTimeReferenceFieldIndex?.layerPreferredTimeZone??""}field(e){if(this.hasField(e))return this.autocastArcadeDate(e,this.readAttribute(e,!0));for(const t of this._joined)if(t.setIndex(this.getIndex()),t.hasField(e)){const r=t._readAttribute(e,!0);return this.autocastArcadeDate(e,r)}throw new Error(`Field ${e} does not exist`)}setField(e,t){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.getFieldNames()}castToText(e=!1){if(!e)return JSON.stringify(this.readLegacyFeature());const t=this.readLegacyFeature();if(!t)return JSON.stringify(null);const r={geometry:t.geometry,attributes:{...t.attributes?t.attributes:{}}};for(const s in r.attributes){const e=r.attributes[s];e instanceof Date&&(r.attributes[s]=e.getTime())}return JSON.stringify(r)}gdbVersion(){return null}fullSchema(){return this._layerSchema}castAsJson(e=null){return{attributes:this._readAttributes(),geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null}}castAsJsonAsync(e=null,t=null){return Promise.resolve(this.castAsJson(t))}removeIds(e){if(s(this._objectIdToIndex)){const e=new Map,t=this.getCursor();for(;t.next();){const r=i(t.getObjectId());e.set(r,t.getIndex())}this._objectIdToIndex=e}const t=this._objectIdToIndex;for(const r of e)t.has(r)&&this.removeAtIndex(t.get(r))}removeAtIndex(e){s(this._deleted)&&(this._deleted=h.create(this.getSize())),this._deleted.set(e)}readGeometryForDisplay(){return this.readUnquantizedGeometry(!0)}readLegacyGeometryForDisplay(){return this.readLegacyGeometry(!0)}*features(){const e=this.getCursor();for(;e.next();)yield e.readOptimizedFeature()}_getExists(){return s(this._deleted)||!this._deleted.has(this.getIndex())}_computeCentroid(){if("esriGeometryPolygon"!==this.geometryType)return null;const e=this.readUnquantizedGeometry();if(!e||e.hasIndeterminateRingOrder)return null;const t=a(this.getQuantizationTransform(),null);return n(new d,e,this.hasM,this.hasZ,t)}copyInto(e){e.seen=this.seen,e._storage=this._storage,e._arcadeSpatialReference=this._arcadeSpatialReference,e._joined=this._joined,e._tx=this._tx,e._ty=this._ty,e._sx=this._sx,e._sy=this._sy,e._deleted=this._deleted,e._objectIdToIndex=this._objectIdToIndex}}export{b as FeatureSetReader};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import{HandleOwner as t}from"../../../../core/HandleOwner.js";import i from"../../../../core/Logger.js";import{isSome as s,unwrap as r}from"../../../../core/maybe.js";import{debounce as a,isAbortError as l,eachAlways as o}from"../../../../core/promiseUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import c from"../../../../geometry/Point.js";import u from"../../../../layers/support/PixelBlock.js";import p from"../../../../layers/support/TileInfo.js";import{update as d,unregister as y,register as g,getRasterId as m}from"../../../../layers/support/rasterDatasets/RawBlockCache.js";import{extractBands as _}from"../../../../layers/support/rasterFunctions/pixelUtils.js";import{getWorldWidth as f,computeProjectedScales as b}from"../../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import"../../tiling/PagedTileQueue.js";import w from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import P from"../../tiling/TileQueue.js";import I from"../../tiling/TileStrategy.js";import{TILE_SIZE as C}from"../../engine/webgl/definitions.js";import{getWebGLCapabilities as R}from"../../../webgl/capabilities.js";import T from"../../../../geometry/Extent.js";const S=[0,0];let U=class extends t{constructor(){super(...arguments),this._emptyTilePixelBlock=null,this._tileStrategy=null,this._tileInfoView=null,this._fetchQueue=null,this._blockCacheRegistryUrl=null,this._blockCacheRegistryId=null,this._srcResolutions=[],this.previousLOD=null,this._needBlockCacheUpdate=!1,this._globalSymbolizerParams=null,this._symbolizerParams=null,this._abortController=null,this._isCustomTilingScheme=!1,this._globalUpdateRequested=!1,this.attached=!1,this.timeExtent=null,this.redrawOrRefetch=a((async(e={})=>{if(!this.previousLOD||this.layerView.suspended)return;e.reprocess&&(await this.updatingHandles.addPromise(this.layer.updateRasterFunction()),this.updateRasterFunctionParameters());return e.refetch||"raster"!==this.type&&!!e.reprocess?this.updatingHandles.addPromise(this.doRefresh()):this.updatingHandles.addPromise(this._redrawImage(e.signal))}))}get useWebGLForProcessing(){return this._get("useWebGLForProcessing")??!0}set useWebGLForProcessing(e){this._set("useWebGLForProcessing",e)}get useProgressiveUpdate(){return null==this._get("useProgressiveUpdate")||this._get("useProgressiveUpdate")}set useProgressiveUpdate(e){if(this._tileStrategy&&this.useProgressiveUpdate!==e){this._tileStrategy.destroy(),this.container.removeAllChildren();const t=this._getCacheSize(e);this._tileStrategy=new I({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._set("useProgressiveUpdate",e),this.layerView.requestUpdate()}}update(e){this._fetchQueue.pause(),this._fetchQueue.state=e.state,this._tileStrategy.update(e),this._fetchQueue.resume();const{extent:t,resolution:i,scale:s}=e.state,r=this._tileInfoView.getClosestInfoForScale(s);if(this.layer.raster){if(!this.useProgressiveUpdate||this._needBlockCacheUpdate){const e=this._srcResolutions[r.level],s=t.toJSON?t:T.fromJSON(t);d(this._blockCacheRegistryUrl,this._blockCacheRegistryId,s,i,e,this.layer.raster.ioConfig.sampling)}this._needBlockCacheUpdate=!1,this.previousLOD?.level!==r.level&&(this.previousLOD=r,null==this._symbolizerParams||this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._tileStrategy.updateCacheSize(0))}}moveEnd(){!this.layerView.hasTilingEffects&&this.useProgressiveUpdate||(this._abortController&&this._abortController.abort(),this._abortController=new AbortController,0===this._fetchQueue.length&&this._redrawImage(this._abortController.signal).then((()=>{this._globalUpdateRequested=!1,this.layerView.requestUpdate()})));const e=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy.updateCacheSize(e),this.layerView.requestUpdate()}get updating(){return this._fetchQueue?.updating||this._globalUpdateRequested||!(!this.updatingHandles||!this.updatingHandles.updating)}attach(){R("2d").supportsTextureFloat||(this.useWebGLForProcessing=!1),this._initializeTileInfo(),this._tileInfoView=new w(this.layerView.tileInfo,this.layerView.fullExtent);const e=this._computeFetchConcurrency();this._fetchQueue=new P({tileInfoView:this._tileInfoView,concurrency:e,process:(e,t)=>this._fetchTile1(e,t)});const t=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy=new I({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._updateBlockCacheRegistry()}detach(){this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._fetchQueue=this._tileStrategy=this._tileInfoView=null,y(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryUrl=this._blockCacheRegistryId=null}acquireTile(e){const t=this.container.createTile(e);return this._enqueueTileFetch(t),this.layerView.requestUpdate(),this._needBlockCacheUpdate=!0,this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,t}releaseTile(e){this._fetchQueue.abort(e.key.id),this.container.removeChild(e),e.once("detach",(()=>{e.destroy(),this.layerView.requestUpdate()})),this.layerView.requestUpdate()}createEmptyTilePixelBlock(e=null){const t=null==e||e.join(",")===this._tileInfoView.tileInfo.size.join(",");if(t&&s(this._emptyTilePixelBlock))return this._emptyTilePixelBlock;e=e||this._tileInfoView.tileInfo.size;const[i,r]=e,a=new u({width:i,height:r,pixels:[new Uint8Array(i*r)],mask:new Uint8Array(i*r),pixelType:"u8"});return t&&(this._emptyTilePixelBlock=a),a}_getBandIds(){if(!("rasterFunctionChain"in this.container)||!this.container.rasterFunctionChain)return this.layer.bandIds;const{bandIds:e,raster:t}=this.layer,i="rasterFunction"in t?t.rasterFunction.rawInputBandIds:null;return e?.length&&i?.length&&1!==t.rasterInfo.bandCount?e.map((e=>i[Math.min(e,i.length-1)])):e||i}updateRasterFunctionParameters(){}_fetchTile1(e,t){const i=s(t)?t.signal:null,a=this.canUseWebGLForProcessing(),{layerView:l}=this,{tileInfo:o}=l,n=!o.isWrappable&&s(f(l.view.spatialReference)),h=a&&this.layer.raster.hasUniqueSourceStorageInfo,c={allowPartialFill:!0,datumTransformation:l.datumTransformation,interpolation:a?"nearest":this.layer.interpolation,registryId:this._blockCacheRegistryId,requestRawData:h,skipRasterFunction:"raster"===this.type&&null!=this.container.rasterFunctionChain,signal:r(i),srcResolution:this._srcResolutions[e.level],timeExtent:l.timeExtent,tileInfo:o,disableWrapAround:n};return this.fetchTile(e,c)}_getCacheSize(e){return e?40:0}_initializeTileInfo(){const e=this.layerView.view.spatialReference,t=new c({x:this.layerView.fullExtent.xmin,y:this.layerView.fullExtent.ymax,spatialReference:e}),{scales:i,srcResolutions:s,isCustomTilingScheme:r}=b(this.layer.rasterInfo,e,C),a=p.create({spatialReference:e,size:C,scales:i});(0===a.origin.x||a.origin.x>t.x)&&(a.origin=t),this._isCustomTilingScheme=r,this.layerView.set("tileInfo",a),this._srcResolutions=s??[]}_computeFetchConcurrency(){const{blockBoundary:e}=this.layer.rasterInfo.storageInfo,t=e[e.length-1];return(t.maxCol-t.minCol+1)*(t.maxRow-t.minRow+1)>64?2:10}async _enqueueTileFetch(e,t){this.updatingHandles.addPromise(this._enqueueTileFetch1(e,t))}async _enqueueTileFetch1(e,t){if(!this._fetchQueue.has(e.key.id)){try{const t=await this._fetchQueue.push(e.key),r=this._getBandIds();let a=!this.useProgressiveUpdate||this.layerView.hasTilingEffects&&!this._globalSymbolizerParams;if(this._globalUpdateRequested&&!this.layerView.moving&&0===this._fetchQueue.length){a=!1;try{await this._redrawImage(this._abortController?.signal)}catch(s){l(s)&&i.getLogger(this.declaredClass).error(s)}this._globalUpdateRequested=!1}!this.canUseWebGLForProcessing()&&"rasterVF"!==this.type||this.layerView.hasTilingEffects||null!=this._symbolizerParams||this._updateSymbolizerParams();const o=this._tileInfoView.getTileCoords(S,e.key),n=this._tileInfoView.getTileResolution(e.key);await this.updateTileSource(e,{source:t,symbolizerParams:this._symbolizerParams,globalSymbolizerParams:this._globalSymbolizerParams,suspended:a,bandIds:r,coords:o,resolution:n}),e.once("attach",(()=>this.layerView.requestUpdate())),this.container.addChild(e)}catch(s){l(s)||i.getLogger(this.declaredClass).error(s)}this.layerView.requestUpdate()}}async _redrawImage(e){if(0===this.container.children.length)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects?await this._updateGlobalSymbolizerParams(e):(this._updateSymbolizerParams(),this._globalSymbolizerParams=null);const t=this.container.children.map((async e=>this.updateTileSymbolizerParameters(e,{local:this._symbolizerParams,global:this._globalSymbolizerParams})));await o(t),this.container.requestRender()}async _updateGlobalSymbolizerParams(e){const t={srcResolution:this._srcResolutions[this.previousLOD.level],registryId:this._blockCacheRegistryId,signal:e},i=await this.layer.fetchPixels(this.layerView.view.extent,this.layerView.view.width,this.layerView.view.height,t);if(!i||!i.pixelBlock)return;const{resolution:s}=this.previousLOD,r=this._getBandIds(),a=this.layer.symbolizer.generateWebGLParameters({pixelBlock:_(i.pixelBlock,r),isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:s,y:s},bandIds:r});!this.canUseWebGLForProcessing()&&a&&"stretch"===a.type&&this.layer.renderer&&"raster-stretch"===this.layer.renderer.type&&(a.factor=a.factor.map((e=>255*e)),a.outMin=Math.round(255*a.outMin),a.outMax=Math.round(255*a.outMax)),this._globalSymbolizerParams=a}_updateSymbolizerParams(){const{resolution:e}=this.previousLOD,t=this._getBandIds();this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null,isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:e,y:e},bandIds:t})}_updateBlockCacheRegistry(e=!1){const{layer:t,layerView:i}=this,{url:s,raster:r}=t,{multidimensionalDefinition:a}=t.normalizeRasterFetchOptions({multidimensionalDefinition:t.multidimensionalDefinition,timeExtent:i.timeExtent}),l=r.rasterInfo.multidimensionalInfo?r.getSliceIndex(a):null,o=m(s,l);if(o!==this._blockCacheRegistryUrl){if(null!=this._blockCacheRegistryUrl&&y(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryId=g(o,r.rasterInfo),e){const{view:e}=i,t=this._tileInfoView.getClosestInfoForScale(e.scale),s=this._srcResolutions[t.level];d(o,this._blockCacheRegistryId,e.extent,e.resolution,s,r.ioConfig.sampling)}this._blockCacheRegistryUrl=o}}async doRefresh(){if(!this.attached)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._updateBlockCacheRegistry(!0),this._fetchQueue.reset();const e=[];this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,this._tileStrategy.tiles.forEach((t=>e.push(this._enqueueTileFetch(t)))),await o(e)}};e([n()],U.prototype,"_fetchQueue",void 0),e([n()],U.prototype,"_globalUpdateRequested",void 0),e([n()],U.prototype,"attached",void 0),e([n()],U.prototype,"container",void 0),e([n()],U.prototype,"layer",void 0),e([n()],U.prototype,"layerView",void 0),e([n()],U.prototype,"type",void 0),e([n()],U.prototype,"useWebGLForProcessing",null),e([n()],U.prototype,"useProgressiveUpdate",null),e([n()],U.prototype,"timeExtent",void 0),e([n()],U.prototype,"updating",null),U=e([h("esri.views.2d.layers.imagery.BaseImageryTileSubView2D")],U);export{U as BaseImageryTileSubView2D};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import{HandleOwner as t}from"../../../../core/HandleOwner.js";import i from"../../../../core/Logger.js";import{isSome as s,unwrap as r}from"../../../../core/maybe.js";import{debounce as a,isAbortError as o,eachAlways as l}from"../../../../core/promiseUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import c from"../../../../geometry/Point.js";import u from"../../../../layers/support/PixelBlock.js";import p from"../../../../layers/support/TileInfo.js";import{update as d,unregister as g,register as y,getRasterId as m}from"../../../../layers/support/rasterDatasets/RawBlockCache.js";import{extractBands as _}from"../../../../layers/support/rasterFunctions/pixelUtils.js";import{getWorldWidth as f,computeProjectedScales as b}from"../../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import"../../tiling/PagedTileQueue.js";import w from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import I from"../../tiling/TileQueue.js";import P from"../../tiling/TileStrategy.js";import{TILE_SIZE as C}from"../../engine/webgl/definitions.js";import{getWebGLCapabilities as R}from"../../../webgl/capabilities.js";import T from"../../../../geometry/Extent.js";const S=[0,0];let v=class extends t{constructor(){super(...arguments),this._emptyTilePixelBlock=null,this._tileStrategy=null,this._tileInfoView=null,this._fetchQueue=null,this._blockCacheRegistryUrl=null,this._blockCacheRegistryId=null,this._srcResolutions=[],this.previousLOD=null,this._needBlockCacheUpdate=!1,this._globalSymbolizerParams=null,this._symbolizerParams=null,this._abortController=null,this._isCustomTilingScheme=!1,this._globalUpdateRequested=!1,this.attached=!1,this.timeExtent=null,this.redrawOrRefetch=a((async(e={})=>{if(!this.previousLOD||this.layerView.suspended)return;e.reprocess&&(await this.updatingHandles.addPromise(this.layer.updateRasterFunction()),this.updateRasterFunctionParameters());return e.refetch||"raster"!==this.type&&!!e.reprocess?this.updatingHandles.addPromise(this.doRefresh()):this.updatingHandles.addPromise(this._redrawImage(e.signal))}))}get useWebGLForProcessing(){return this._get("useWebGLForProcessing")??!0}set useWebGLForProcessing(e){this._set("useWebGLForProcessing",e)}get useProgressiveUpdate(){return null==this._get("useProgressiveUpdate")||this._get("useProgressiveUpdate")}set useProgressiveUpdate(e){if(this._tileStrategy&&this.useProgressiveUpdate!==e){this._tileStrategy.destroy(),this.container.removeAllChildren();const t=this._getCacheSize(e);this._tileStrategy=new P({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._set("useProgressiveUpdate",e),this.layerView.requestUpdate()}}update(e){this._fetchQueue.pause(),this._fetchQueue.state=e.state,this._tileStrategy.update(e),this._fetchQueue.resume();const{extent:t,resolution:i,scale:s}=e.state,r=this._tileInfoView.getClosestInfoForScale(s);if(this.layer.raster){if(!this.useProgressiveUpdate||this._needBlockCacheUpdate){const e=this._srcResolutions[r.level],s=t.toJSON?t:T.fromJSON(t);d(this._blockCacheRegistryUrl,this._blockCacheRegistryId,s,i,e,this.layer.raster.ioConfig.sampling)}this._needBlockCacheUpdate=!1,this.previousLOD?.level!==r.level&&(this.previousLOD=r,null==this._symbolizerParams||this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._tileStrategy.updateCacheSize(0))}}moveEnd(){!this.layerView.hasTilingEffects&&this.useProgressiveUpdate||(this._abortController&&this._abortController.abort(),this._abortController=new AbortController,0===this._fetchQueue.length&&this._redrawImage(this._abortController.signal).then((()=>{this._globalUpdateRequested=!1,this.layerView.requestUpdate()})));const e=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy.updateCacheSize(e),this.layerView.requestUpdate()}get updating(){return this._fetchQueue?.updating||this._globalUpdateRequested||!(!this.updatingHandles||!this.updatingHandles.updating)}attach(){R("2d").supportsTextureFloat||(this.useWebGLForProcessing=!1),this._initializeTileInfo(),this._tileInfoView=new w(this.layerView.tileInfo,this.layerView.fullExtent);const e=this._computeFetchConcurrency();this._fetchQueue=new I({tileInfoView:this._tileInfoView,concurrency:e,process:(e,t)=>this._fetchTile1(e,t)});const t=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy=new P({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._updateBlockCacheRegistry()}detach(){this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._fetchQueue=this._tileStrategy=this._tileInfoView=null,g(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryUrl=this._blockCacheRegistryId=null}acquireTile(e){const t=this.container.createTile(e);return this._enqueueTileFetch(t),this.layerView.requestUpdate(),this._needBlockCacheUpdate=!0,this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,t}releaseTile(e){this._fetchQueue.abort(e.key.id),this.container.removeChild(e),e.once("detach",(()=>{e.destroy(),this.layerView.requestUpdate()})),this.layerView.requestUpdate()}createEmptyTilePixelBlock(e=null){const t=null==e||e.join(",")===this._tileInfoView.tileInfo.size.join(",");if(t&&s(this._emptyTilePixelBlock))return this._emptyTilePixelBlock;e=e||this._tileInfoView.tileInfo.size;const[i,r]=e,a=new u({width:i,height:r,pixels:[new Uint8Array(i*r)],mask:new Uint8Array(i*r),pixelType:"u8"});return t&&(this._emptyTilePixelBlock=a),a}_getBandIds(){if(!("rasterFunctionChain"in this.container)||!this.container.rasterFunctionChain)return this.layer.bandIds;const{bandIds:e,raster:t}=this.layer,i="rasterFunction"in t?t.rasterFunction.rawInputBandIds:null;return e?.length&&i?.length&&1!==t.rasterInfo.bandCount?e.map((e=>i[Math.min(e,i.length-1)])):e||i}updateRasterFunctionParameters(){}_fetchTile1(e,t){const i=s(t)?t.signal:null,a=this.canUseWebGLForProcessing(),{layerView:o}=this,{tileInfo:l}=o,n=!l.isWrappable&&s(f(o.view.spatialReference)),h=a&&this.layer.raster.hasUniqueSourceStorageInfo,c={allowPartialFill:!0,datumTransformation:o.datumTransformation,interpolation:a?"nearest":this.layer.interpolation,registryId:this._blockCacheRegistryId,requestRawData:h,skipRasterFunction:"raster"===this.type&&null!=this.container.rasterFunctionChain,signal:r(i),srcResolution:this._srcResolutions[e.level],timeExtent:o.timeExtent,tileInfo:l,disableWrapAround:n};return this.fetchTile(e,c)}_getCacheSize(e){return e?40:0}_initializeTileInfo(){const{layerView:e}=this,t=e.view.spatialReference,i=new c({x:e.fullExtent.xmin,y:e.fullExtent.ymax,spatialReference:t});if(this._canUseLayerLODs()){const{lods:s}=this.layer.tileInfo,r=s.map((({scale:e})=>e)),a=p.create({spatialReference:t,size:C,scales:r}),o=t.isGeographic?.01*1e-5:.01;if(this._isCustomTilingScheme=Math.abs(a.origin.x-i.x)>o,(0===a.origin.x||a.origin.x>i.x)&&(a.origin=i),!this._isCustomTilingScheme){const e=p.create({spatialReference:t,size:C}).lods.map((({scale:e})=>e));this._isCustomTilingScheme=r.some((t=>!e.some((e=>Math.abs(e-t)<.001))))}return e.set("tileInfo",a),void(this._srcResolutions=s.map((({resolution:e})=>({x:e,y:e}))))}const{scales:s,srcResolutions:r,isCustomTilingScheme:a}=b(this.layer.rasterInfo,t,C),o=p.create({spatialReference:t,size:C,scales:s});(0===o.origin.x||o.origin.x>i.x)&&(o.origin=i),this._isCustomTilingScheme=a,e.set("tileInfo",o),this._srcResolutions=r??[]}_canUseLayerLODs(){const{layer:e,layerView:t}=this;if("Map"!==e.raster.tileType)return!1;const{lods:i}=e.tileInfo,s=t.view.constraints?.effectiveLODs;if(!(s?.length===i.length&&s.every((({scale:e},t)=>Math.abs(e-i[t].scale)<.001))))return!1;const r=[];for(let a=0;a<i.length-1;a++)r.push(Math.round(10*i[a].resolution/i[a+1].resolution)/10);return r.some((e=>e!==e[0]))}_computeFetchConcurrency(){const{blockBoundary:e}=this.layer.rasterInfo.storageInfo,t=e[e.length-1];return(t.maxCol-t.minCol+1)*(t.maxRow-t.minRow+1)>64?2:10}async _enqueueTileFetch(e,t){this.updatingHandles.addPromise(this._enqueueTileFetch1(e,t))}async _enqueueTileFetch1(e,t){if(!this._fetchQueue.has(e.key.id)){try{const t=await this._fetchQueue.push(e.key),r=this._getBandIds();let a=!this.useProgressiveUpdate||this.layerView.hasTilingEffects&&!this._globalSymbolizerParams;if(this._globalUpdateRequested&&!this.layerView.moving&&0===this._fetchQueue.length){a=!1;try{await this._redrawImage(this._abortController?.signal)}catch(s){o(s)&&i.getLogger(this.declaredClass).error(s)}this._globalUpdateRequested=!1}!this.canUseWebGLForProcessing()&&"rasterVF"!==this.type||this.layerView.hasTilingEffects||null!=this._symbolizerParams||this._updateSymbolizerParams();const l=this._tileInfoView.getTileCoords(S,e.key),n=this._tileInfoView.getTileResolution(e.key);await this.updateTileSource(e,{source:t,symbolizerParams:this._symbolizerParams,globalSymbolizerParams:this._globalSymbolizerParams,suspended:a,bandIds:r,coords:l,resolution:n}),e.once("attach",(()=>this.layerView.requestUpdate())),this.container.addChild(e)}catch(s){o(s)||i.getLogger(this.declaredClass).error(s)}this.layerView.requestUpdate()}}async _redrawImage(e){if(0===this.container.children.length)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects?await this._updateGlobalSymbolizerParams(e):(this._updateSymbolizerParams(),this._globalSymbolizerParams=null);const t=this.container.children.map((async e=>this.updateTileSymbolizerParameters(e,{local:this._symbolizerParams,global:this._globalSymbolizerParams})));await l(t),this.container.requestRender()}async _updateGlobalSymbolizerParams(e){const t={srcResolution:this._srcResolutions[this.previousLOD.level],registryId:this._blockCacheRegistryId,signal:e},i=await this.layer.fetchPixels(this.layerView.view.extent,this.layerView.view.width,this.layerView.view.height,t);if(!i||!i.pixelBlock)return;const{resolution:s}=this.previousLOD,r=this._getBandIds(),a=this.layer.symbolizer.generateWebGLParameters({pixelBlock:_(i.pixelBlock,r),isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:s,y:s},bandIds:r});!this.canUseWebGLForProcessing()&&a&&"stretch"===a.type&&this.layer.renderer&&"raster-stretch"===this.layer.renderer.type&&(a.factor=a.factor.map((e=>255*e)),a.outMin=Math.round(255*a.outMin),a.outMax=Math.round(255*a.outMax)),this._globalSymbolizerParams=a}_updateSymbolizerParams(){const{resolution:e}=this.previousLOD,t=this._getBandIds();this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null,isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:e,y:e},bandIds:t})}_updateBlockCacheRegistry(e=!1){const{layer:t,layerView:i}=this,{url:s,raster:r}=t,{multidimensionalDefinition:a}=t.normalizeRasterFetchOptions({multidimensionalDefinition:t.multidimensionalDefinition,timeExtent:i.timeExtent}),o=r.rasterInfo.multidimensionalInfo?r.getSliceIndex(a):null,l=m(s,o);if(l!==this._blockCacheRegistryUrl){if(null!=this._blockCacheRegistryUrl&&g(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryId=y(l,r.rasterInfo),e){const{view:e}=i,t=this._tileInfoView.getClosestInfoForScale(e.scale),s=this._srcResolutions[t.level];d(l,this._blockCacheRegistryId,e.extent,e.resolution,s,r.ioConfig.sampling)}this._blockCacheRegistryUrl=l}}async doRefresh(){if(!this.attached)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._updateBlockCacheRegistry(!0),this._fetchQueue.reset();const e=[];this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,this._tileStrategy.tiles.forEach((t=>e.push(this._enqueueTileFetch(t)))),await l(e)}};e([n()],v.prototype,"_fetchQueue",void 0),e([n()],v.prototype,"_globalUpdateRequested",void 0),e([n()],v.prototype,"attached",void 0),e([n()],v.prototype,"container",void 0),e([n()],v.prototype,"layer",void 0),e([n()],v.prototype,"layerView",void 0),e([n()],v.prototype,"type",void 0),e([n()],v.prototype,"useWebGLForProcessing",null),e([n()],v.prototype,"useProgressiveUpdate",null),e([n()],v.prototype,"timeExtent",void 0),e([n()],v.prototype,"updating",null),v=e([h("esri.views.2d.layers.imagery.BaseImageryTileSubView2D")],v);export{v as BaseImageryTileSubView2D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{EsriPromise as t}from"../../../../core/Promise.js";import{createResolver as r,ignoreAbortErrors as s,throwIfNotAbortError as o}from"../../../../core/promiseUtils.js";import{open as i}from"../../../../core/workers/workers.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";function c(e){return Array.isArray(e)}let u=class extends t{constructor(e){super(e),this._startupResolver=r(),this.isReady=!1}initialize(){this._controller=new AbortController,this.addResolvingPromise(this._startWorker(this._controller.signal))}destroy(){this._controller.abort(),this._connection&&this._connection.close()}set tileRenderer(e){this.client.tileRenderer=e}get closed(){return this._connection.closed}async startup(e,t,r,s){await this.when();const o=this._controller.signal,i=c(r.source)?{transferList:r.source,signal:o}:void 0,n={service:r,config:t,tileInfo:e.tileInfo.toJSON(),tiles:s};await this._connection.invoke("startup",n,i),this._startupResolver.resolve(),this._set("isReady",!0)}async updateTiles(e){return await this._startupResolver.promise,s(this._connection.invoke("updateTiles",e))}async update(e){const t={config:e};return await this._startupResolver.promise,this._connection.invoke("update",t)}async applyUpdate(e){return await this._startupResolver.promise,this._connection.invoke("applyUpdate",e)}async setHighlight(e){return await this._startupResolver.promise,s(this._connection.invoke("controller.setHighlight",e))}async stop(){if(await this._startupResolver.promise,!this.closed)return s(this._connection.invoke("stop"))}async refresh(e){return await this._startupResolver.promise,s(this._connection.invoke("controller.refresh",e))}async querySummaryStatistics(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.querySummaryStatistics",{query:e.toJSON(),params:t},r)}async queryAggregateSummaryStatistics(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateSummaryStatistics",{query:e.toJSON(),params:t},r)}async queryUniqueValues(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.queryUniqueValues",{query:e.toJSON(),params:t},r)}async queryAggregateUniqueValues(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateUniqueValues",{query:e.toJSON(),params:t},r)}async queryClassBreaks(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.queryClassBreaks",{query:e.toJSON(),params:t},r)}async queryAggregateClassBreaks(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateClassBreaks",{query:e.toJSON(),params:t},r)}async queryHistogram(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.queryHistogram",{query:e.toJSON(),params:t},r)}async queryAggregateHistogram(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateHistogram",{query:e.toJSON(),params:t},r)}async queryFeatures(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryFeatures",e?.toJSON(),t)}async queryVisibleFeatures(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryVisibleFeatures",e?.toJSON(),t)}async queryObjectIds(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryObjectIds",e?.toJSON(),t)}async queryFeatureCount(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryFeatureCount",e?.toJSON(),t)}async queryExtent(e,t){return this._connection.invoke("controller.queryExtent",e.toJSON(),t)}async queryLatestObservations(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryLatestObservations",e.toJSON(),t)}async queryStatistics(e){return await this._startupResolver.promise,this._connection.invoke("controller.queryStatistics",e)}async queryAggregates(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregates",e?.toJSON(),t)}async queryAggregateCount(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateCount",e?.toJSON(),t)}async queryAggregateIds(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateIds",e?.toJSON(),t)}async getObjectId(e){return await this._startupResolver.promise,this._connection.invoke("controller.getObjectId",e)}async getDisplayId(e){return await this._startupResolver.promise,this._connection.invoke("controller.getDisplayId",e)}async getFeatures(e){return await this._startupResolver.promise,this._connection.invoke("controller.getFeatures",e)}async getAggregates(){return await this._startupResolver.promise,this._connection.invoke("controller.getAggregates")}async getAggregateValueRanges(){return await this._startupResolver.promise,this._connection.invoke("controller.getAggregateValueRanges")}async mapValidDisplayIds(e){return await this._startupResolver.promise,this._connection.invoke("controller.mapValidDisplayIds",e)}async onEdits(e){return await this._startupResolver.promise,s(this._connection.invoke("controller.onEdits",e))}async enableEvent(e,t){return await this._startupResolver.promise,s(this._connection.invoke("controller.enableEvent",{name:e,value:t}))}pauseStream(){return s(this._connection.invoke("controller.pauseStream"))}resumeStream(){return s(this._connection.invoke("controller.resumeStream"))}async _startWorker(e){try{this._connection=await i("Pipeline",{client:this.client,strategy:"dedicated",signal:e})}catch(t){o(t)}}};e([n()],u.prototype,"isReady",void 0),e([n({constructOnly:!0})],u.prototype,"client",void 0),e([n()],u.prototype,"tileRenderer",null),u=e([a("esri.views.2d.layers.support.FeatureLayerProxy")],u);const l=u;export{l as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{EsriPromise as t}from"../../../../core/Promise.js";import{createResolver as r,ignoreAbortErrors as s,throwIfNotAbortError as o}from"../../../../core/promiseUtils.js";import{open as i}from"../../../../core/workers/workers.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";function c(e){return Array.isArray(e)}let u=class extends t{constructor(e){super(e),this._startupResolver=r(),this.isReady=!1}initialize(){this._controller=new AbortController,this.addResolvingPromise(this._startWorker(this._controller.signal))}destroy(){this._controller.abort(),this._connection&&this._connection.close()}set tileRenderer(e){this.client.tileRenderer=e}get closed(){return this._connection.closed}async startup(e,t,r,s){await this.when();const o=this._controller.signal,i=c(r.source)?{transferList:r.source,signal:o}:void 0,n={service:r,config:t,tileInfo:e.tileInfo.toJSON(),tiles:s};await this._connection.invoke("startup",n,i),this._startupResolver.resolve(),this._set("isReady",!0)}async updateTiles(e){return await this._startupResolver.promise,s(this._connection.invoke("updateTiles",e))}async update(e){const t={config:e};return await this._startupResolver.promise,this._connection.invoke("update",t)}async applyUpdate(e){return await this._startupResolver.promise,this._connection.invoke("applyUpdate",e)}async setHighlight(e){return await this._startupResolver.promise,s(this._connection.invoke("controller.setHighlight",e))}async stop(){if(await this._startupResolver.promise,!this.closed)return s(this._connection.invoke("stop"))}async refresh(e){return await this._startupResolver.promise,s(this._connection.invoke("controller.refresh",e))}async querySummaryStatistics(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.querySummaryStatistics",{query:e.toJSON(),params:t},r)}async queryAggregateSummaryStatistics(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateSummaryStatistics",{query:e.toJSON(),params:t},r)}async queryUniqueValues(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.queryUniqueValues",{query:e.toJSON(),params:t},r)}async queryAggregateUniqueValues(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateUniqueValues",{query:e.toJSON(),params:t},r)}async queryClassBreaks(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.queryClassBreaks",{query:e.toJSON(),params:t},r)}async queryAggregateClassBreaks(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateClassBreaks",{query:e.toJSON(),params:t},r)}async queryHistogram(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.queryHistogram",{query:e.toJSON(),params:t},r)}async queryAggregateHistogram(e,t,r){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateHistogram",{query:e.toJSON(),params:t},r)}async queryFeatures(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryFeatures",e?.toJSON(),t)}async queryVisibleFeatures(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryVisibleFeatures",e?.toJSON(),t)}async queryObjectIds(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryObjectIds",e?.toJSON(),t)}async queryFeatureCount(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryFeatureCount",e?.toJSON(),t)}async queryExtent(e,t){return this._connection.invoke("controller.queryExtent",e.toJSON(),t)}async queryLatestObservations(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryLatestObservations",e.toJSON(),t)}async queryStatistics(e){return await this._startupResolver.promise,this._connection.invoke("controller.queryStatistics",e)}async queryAggregates(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregates",e?.toJSON(),t)}async queryAggregateCount(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateCount",e?.toJSON(),t)}async queryAggregateIds(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateIds",e?.toJSON(),t)}async getObjectId(e){return await this._startupResolver.promise,this._connection.invoke("controller.getObjectId",e)}async getDisplayId(e){return await this._startupResolver.promise,this._connection.invoke("controller.getDisplayId",e)}async getFeatures(e){return await this._startupResolver.promise,this._connection.invoke("controller.getFeatures",e)}async getAggregates(){return await this._startupResolver.promise,this._connection.invoke("controller.getAggregates")}async getAggregateValueRanges(){return await this._startupResolver.promise,this._connection.invoke("controller.getAggregateValueRanges")}async mapValidDisplayIds(e){return await this._startupResolver.promise,this._connection.invoke("controller.mapValidDisplayIds",e)}async onEdits(e){return await this._startupResolver.promise,s(this._connection.invoke("controller.onEdits",e))}async enableEvent(e,t){return await this._startupResolver.promise,s(this._connection.invoke("controller.enableEvent",{name:e,value:t}))}async pauseStream(){return await this._startupResolver.promise,s(this._connection.invoke("controller.pauseStream"))}async resumeStream(){return await this._startupResolver.promise,s(this._connection.invoke("controller.resumeStream"))}async sendMessage(e){return await this._startupResolver.promise,s(this._connection.invoke("controller.sendMessage",e))}async receiveMessage(e){return await this._startupResolver.promise,s(this._connection.invoke("controller.receiveMessage",e))}async _startWorker(e){try{this._connection=await i("Pipeline",{client:this.client,strategy:"dedicated",signal:e})}catch(t){o(t)}}};e([n()],u.prototype,"isReady",void 0),e([n({constructOnly:!0})],u.prototype,"client",void 0),e([n()],u.prototype,"tileRenderer",null),u=e([a("esri.views.2d.layers.support.FeatureLayerProxy")],u);const l=u;export{l 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.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{lerp as s}from"../../../core/mathUtils.js";import{isSome as r,isNone as i,destroyMaybe as a}from"../../../core/maybe.js";import{when as o,syncAndInitial as n,watch as h,initial as p,sync as m}from"../../../core/reactiveUtils.js";import{Milliseconds as d}from"../../../core/time.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{l as c,c as u,h as g}from"../../../chunks/vec3.js";import{f as w}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as f}from"../../../geometry/ellipsoidUtils.js";import{isMoon as y,isEarth as v}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as P}from"../../ViewingMode.js";import{AtmosphereType as b}from"./AtmosphereType.js";import{ChapmanAtmosphere as R}from"./ChapmanAtmosphere.js";import{CloudsComposition as x}from"./CloudsComposition.js";import{FadeInStages as z,FadeInOutStages as A}from"./CloudsCompositionParameters.js";import{isReadyCloudsData as W,CloudsRenderingStages as j}from"./CloudsData.js";import{CloudsGenerator as N}from"./CloudsGenerator.js";import{cloudPresets as C}from"./CloudsPresets.js";import{Fog as E,FogParameters as T}from"./Fog.js";import{PanoramicAtmosphere as O}from"./PanoramicAtmosphere.js";import{Precipitation as S}from"./Precipitation.js";import F from"./SimpleAtmosphere.js";import{SimpleHaze as q,HazeParameters as H}from"./SimpleHaze.js";import{Stars as I}from"./Stars.js";import{weatherHeightLimit as M}from"./weather.js";import{updateWeatherFading as L,weatherfadingNeedsRender as U}from"./weatherUtils.js";import{ShaderOutput as V}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{RenderFeature as k}from"../webgl-engine/lib/RenderFeature.js";import{RenderSlot as G}from"../webgl-engine/lib/RenderSlot.js";import{Update as B}from"../webgl-engine/lib/Update.js";var D;const Q=[G.POSTPROCESSING_ENVIRONMENT_OPAQUE,G.POSTPROCESSING_ENVIRONMENT_TRANSPARENT];let J=D=class extends t{constructor(e){super(e),this._context=null,this._atmosphere=null,this._hqAtmosphere=null,this._oldWeatherParameters=new K,this._newWeatherParameters=new K,this._fadedWeatherParameters=new K,this._weatherParameters=this._newWeatherParameters}initialize(){this.view._stage.addRenderPlugin(Q,this)}destroy(){this.removeHandles(),null!=this.view?._stage&&this.view._stage.removeRenderPlugin(this),this._set("view",null)}get atmosphere(){return r(this._hqAtmosphere)&&this.view._stage.renderer.isFeatureEnabled(k.RealisticAtmosphere)?this._hqAtmosphere:this._atmosphere}get _atmosphereType(){return r(this.atmosphere)?this.atmosphere.type:b.None}get canRender(){return!!this.view.basemapTerrain?.renderer.canRender||"global"!==this.view.viewingMode}get needsLinearDepth(){return this._atmosphereType===b.Realistic}updateAnimation(e){return!!r(this._precipitation)&&this._precipitation.update(e)}get updating(){return r(this._stars)&&this._stars.updating||r(this._clouds)&&this._clouds.running}get weatherVisible(){return c(this.view.state.camera.eye)-f(this.view.spatialReference).radius<=M}get _stars(){const e=this.view,t=e.environment?.starsEnabled??!1,s=this._get("_stars");return!t||i(this._context)?(a(s),null):r(s)?s:new I({view:e,requestRender:()=>this._setNeedsRender()})}get _precipitation(){const e=this._get("_precipitation");if(!this._precipitationEnabled||i(this._context))return a(e),null;const t=this.view,s=this._context;return r(e)&&e.context===s?e:(a(e),new S({context:s,view:t}))}get _clouds(){const e=this._get("_clouds");if(!this.weatherEnabled||i(this._context))return a(e),null;if(r(e))return e;const t=this.view,s=this._context;return a(e),new N({context:s,view:t,requestRender:()=>this._setNeedsRender()})}get _cloudsComposition(){const e=this._get("_cloudsComposition");if(!this.weatherEnabled||i(this._context))return a(e),null;const t=this.view.state.viewingMode,s=this._context.renderContext.rctx,o=f(this.view.spatialReference).radius;return r(e)&&e.viewingMode===t&&e.planetRadius===o?e:(a(e),new x({rctx:s,viewingMode:t,planetRadius:o,requestRender:()=>this._setNeedsRender()}))}get _fog(){const e=this._get("_fog");if(!this.weatherEnabled||i(this._context))return a(e),null;if(r(e))return e;const t=this.view,s=this._context;return new E({context:s,view:t})}get _simpleHaze(){const e=this._get("_simpleHaze");if(!this.weatherEnabled||i(this._context))return a(e),null;if(r(e))return e;const t=this.view,s=this._context;return new q({context:s,view:t})}get weatherEnabled(){return!!this.view?.environmentManager?.weatherEnabled}get _precipitationEnabled(){return this.weatherEnabled&&("rainy"===this.view.environment.weather.type||"snowy"===this.view.environment.weather.type)}initializeRenderContext(e=null){this._context=e;const t=()=>this._setNeedsRender();this.addHandles([o((()=>this.view?.basemapTerrain),(()=>this._updateBasemapTerrain()),n),h((()=>({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled,quality:this.view.environment.atmosphere.quality})),(e=>this._updateAtmosphere(e)),n),h((()=>this._stars),t),h((()=>this._precipitation),t),h((()=>this._clouds),(()=>this._updateWeather()),p),h((()=>this._fog),(()=>this._updateFogHaze()),p),h((()=>this._simpleHaze),(()=>this._updateFogHaze()),p),h((()=>this.view.state.mode),(()=>{this._setNeedsRender()}),m),h((()=>this._atmosphereType),(()=>this._updateBasemapTerrain()),n),h((()=>this._weatherUpdateParameters),(()=>{this._updateWeather(),this._updateFogHaze()}),n)])}uninitializeRenderContext(){this._context=null,this._atmosphere=a(this._atmosphere),this._hqAtmosphere=a(this._hqAtmosphere),this._set("_stars",a(this._stars)),this._set("_precipitation",a(this._precipitation)),this._set("_clouds",a(this._clouds)),this._set("_cloudsComposition",a(this._cloudsComposition)),this._set("_fog",a(this._fog)),this._set("_simpleHaze",a(this._simpleHaze))}prepareRender(e){e.bindParameters.cloudsFade.data=W(this._clouds)?this._clouds:null,"local"!==this.view.viewingMode&&(L(e.bindParameters.cloudsFade,e.bindParameters.camera,this.view.state.mode,D.test.time||e.time,this.view.qualitySettings.fadeDuration),this._updateWeatherFading(e.bindParameters),e.bindParameters.cloudsFade.renderingStage===j.FINISHED&&r(this._clouds)&&0===this._clouds.coverage&&!1===this._clouds.running&&this._clouds.destroyFrameBufferCube())}render(e){if(e.output===V.Color)switch(e.bindParameters.slot){case G.POSTPROCESSING_ENVIRONMENT_OPAQUE:r(this._stars)&&this._stars.render(e),r(this.atmosphere)&&(this.atmosphere.render(e),r(this._cloudsComposition)&&r(e.bindParameters.cloudsFade.data)&&(this.weatherVisible&&r(this._clouds)&&this._clouds.updateWeatherTile(),this._cloudsComposition.render(e)),U(e.bindParameters.cloudsFade)&&r(this._context)&&this._context.requestRender());break;case G.POSTPROCESSING_ENVIRONMENT_TRANSPARENT:if(r(this.atmosphere)&&(this.atmosphere.renderHaze(e,this._weatherParameters.haze.amount),this._weatherParameters.haze.amount>0&&this._atmosphereType!==b.Realistic&&r(this._simpleHaze)&&this._simpleHaze.render(e,this._weatherParameters.haze),this._weatherParameters.fog.amount>0&&r(this._fog)&&this._fog.render(e,this._weatherParameters.fog),r(this._precipitation))){const t=this.view.environment.weather;"rainy"!==t.type&&"snowy"!==t.type||this._precipitation.render(e,t.precipitation,t.type)}}}updateLightSources(e,t,s,i){if(r(this._context)){const r=this._context.renderContext;r.bindParameters.oldLighting.copyFrom(r.bindParameters.lighting),r.bindParameters.newLighting.noonFactor=t,r.bindParameters.newLighting.globalFactor=s,r.bindParameters.newLighting.set(e);i===B.Faded||r.bindParameters.weatherFading?r.bindParameters.fadeLighting(0):r.bindParameters.fadeLighting(1),this._context.requestRender()}}get _weatherUpdateParameters(){const e=this.weatherEnabled?this.view.environment.weather:null;return i(e)?null:"rainy"===e.type||"snowy"===e.type?{type:e.type,weatherAdjustment:e.cloudCover,effect:e.precipitation}:{type:e.type,weatherAdjustment:"foggy"===e.type?e.fogStrength:e.cloudCover}}_updateWeatherFading(e){if(!e.weatherFading)return;const t=e.cloudsFade;return t.fadeIn.stage===z.FADE_IN?(e.fadeLighting(t.fadeIn.factor),void this._fadeWeather(t.fadeIn.factor)):t.fadeInOut.stage===A.FADE_IN?(e.fadeLighting(t.fadeInOut.factor),void this._fadeWeather(t.fadeInOut.factor)):t.crossFade.enabled?(e.fadeLighting(t.crossFade.factor),void this._fadeWeather(t.crossFade.factor)):(e.fadeLighting(0),void this._fadeWeather(0))}_fadeWeather(e){const{_newWeatherParameters:t,_oldWeatherParameters:s}=this;e>=1?this._weatherParameters=t:(this._fadedWeatherParameters.lerp(s,t,e),this._weatherParameters=this._fadedWeatherParameters)}_updateWeather(){const e=this._weatherUpdateParameters;i(e)||i(this._clouds)||(this._clouds.applyPreset(C[e.type],e.weatherAdjustment),this._setNeedsRender())}_setNeedsRender(){r(this._context)&&this._context.requestRender()}_updateFogHaze(){const e=this._weatherUpdateParameters;if(i(this._fog)||i(this._simpleHaze)||i(e)||i(this._context))return;const t=this._context.renderContext.bindParameters;switch(this._oldWeatherParameters.copyFrom(this._weatherParameters),e.type){case"foggy":this._newWeatherParameters.fog.strength=s(3e-5,.005,e.weatherAdjustment**3),u(this._newWeatherParameters.fog.color,Y),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.haze.strength=0,this._newWeatherParameters.haze.amount=this._atmosphereType===b.Realistic?1:0,this._setNeedsRender();break;case"rainy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),u(this._newWeatherParameters.fog.color,X),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.haze.strength=0,this._newWeatherParameters.haze.amount=0,this._setNeedsRender();break;case"snowy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),u(this._newWeatherParameters.fog.color,Y),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.haze.strength=0,this._newWeatherParameters.haze.amount=this._atmosphereType===b.Realistic?1:0,this._setNeedsRender();break;default:this._newWeatherParameters.fog.strength=0,this._newWeatherParameters.fog.amount=0,this._newWeatherParameters.haze.strength=4e-6,this._newWeatherParameters.haze.amount=1,this._setNeedsRender()}t.weatherFading?this._fadeWeather(0):this._fadeWeather(1)}_updateAtmosphere(e){const t=this._selectAtmosphereType(e);if(r(this._atmosphere)?this._atmosphere.type===t:t===b.None)return;this._atmosphere=a(this._atmosphere),this._hqAtmosphere=a(this._hqAtmosphere);const s=this._getAtmosphereClass(t);s&&r(this._context)&&(this._atmosphere=new s(this.view),this._atmosphere.initializeRenderContext(this._context),t===b.Simple&&(this._hqAtmosphere=new R(this.view),this._hqAtmosphere.initializeRenderContext(this._context))),this._setNeedsRender(),this._updateBasemapTerrain()}_getAtmosphereClass(e){switch(e){case b.Realistic:return R;case b.Panoramic:return O;case b.Simple:return F;default:case b.None:return null}}_selectAtmosphereType(e){const{enabled:t,quality:s,viewingMode:i}=e;return!t||y(this.view.spatialReference)?b.None:i===P.Local?b.Panoramic:r(this._context)&&"high"===s&&R.isSupported(this._context)&&v(this.view.spatialReference)?b.Realistic:b.Simple}_updateBasemapTerrain(){this.view.basemapTerrain&&(this.view.basemapTerrain.velvetOverground=this._atmosphereType===b.Simple)}get test(){return{atmosphere:this._atmosphere,clouds:this._clouds,selectAtmosphereType:()=>this._selectAtmosphereType({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled,quality:this.view.environment.atmosphere.quality}),stubGetAtmosphereClass:e=>{Z=D.prototype._getAtmosphereClass,D.prototype._getAtmosphereClass=e},restoreGetAtmosphereClass:()=>{D.prototype._getAtmosphereClass=Z}}}};J.test={time:d(0)},e([l({constructOnly:!0})],J.prototype,"view",void 0),e([l({readOnly:!0})],J.prototype,"atmosphere",null),e([l({readOnly:!0})],J.prototype,"_atmosphereType",null),e([l({type:Boolean,readOnly:!0})],J.prototype,"updating",null),e([l({readOnly:!0})],J.prototype,"weatherVisible",null),e([l()],J.prototype,"_context",void 0),e([l()],J.prototype,"_atmosphere",void 0),e([l()],J.prototype,"_hqAtmosphere",void 0),e([l({readOnly:!0})],J.prototype,"_stars",null),e([l({readOnly:!0})],J.prototype,"_precipitation",null),e([l({readOnly:!0})],J.prototype,"_clouds",null),e([l({readOnly:!0})],J.prototype,"_cloudsComposition",null),e([l({readOnly:!0})],J.prototype,"_fog",null),e([l({readOnly:!0})],J.prototype,"_simpleHaze",null),e([l({readOnly:!0})],J.prototype,"weatherEnabled",null),e([l({readOnly:!0})],J.prototype,"_precipitationEnabled",null),e([l({readOnly:!0})],J.prototype,"_weatherUpdateParameters",null),J=D=e([_("esri.views.3d.environment.EnvironmentRenderer")],J);class K{constructor(){this.fog=new T,this.haze=new H}copyFrom(e){this.fog.amount=e.fog.amount,this.haze.amount=e.haze.amount,this.fog.strength=e.fog.strength,this.haze.strength=e.haze.strength,u(this.fog.color,e.fog.color)}lerp(e,t,r){this.fog.amount=s(e.fog.amount,t.fog.amount,r),this.haze.amount=s(e.haze.amount,t.haze.amount,r),this.fog.strength=s(e.fog.strength,t.fog.strength,r),this.haze.strength=s(e.haze.strength,t.haze.strength,r),g(this.fog.color,e.fog.color,t.fog.color,r)}}const X=w(.5,.5,.5),Y=w(1.5,1.5,1.5);let Z;export{J as EnvironmentRenderer,K as WeatherParameters};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{lerp as s}from"../../../core/mathUtils.js";import{isSome as r,isNone as i,destroyMaybe as a}from"../../../core/maybe.js";import{when as o,syncAndInitial as n,watch as h,initial as p,sync as m}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{l as _,c,h as u}from"../../../chunks/vec3.js";import{f as g}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as w}from"../../../geometry/ellipsoidUtils.js";import{isMoon as f,isEarth as y}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as v}from"../../ViewingMode.js";import{AtmosphereType as P}from"./AtmosphereType.js";import{ChapmanAtmosphere as b}from"./ChapmanAtmosphere.js";import{CloudsComposition as R}from"./CloudsComposition.js";import{FadeInStages as x,FadeInOutStages as z}from"./CloudsCompositionParameters.js";import{isReadyCloudsData as A,CloudsRenderingStages as W}from"./CloudsData.js";import{CloudsGenerator as N}from"./CloudsGenerator.js";import{cloudPresets as j}from"./CloudsPresets.js";import{Fog as C,FogParameters as E}from"./Fog.js";import{PanoramicAtmosphere as T}from"./PanoramicAtmosphere.js";import{Precipitation as O}from"./Precipitation.js";import S from"./SimpleAtmosphere.js";import{SimpleHaze as F,HazeParameters as q}from"./SimpleHaze.js";import{Stars as H}from"./Stars.js";import{weatherHeightLimit as I}from"./weather.js";import{updateWeatherFading as M,weatherfadingNeedsRender as L}from"./weatherUtils.js";import{ShaderOutput as U}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{RenderFeature as V}from"../webgl-engine/lib/RenderFeature.js";import{RenderSlot as k}from"../webgl-engine/lib/RenderSlot.js";import{Update as G}from"../webgl-engine/lib/Update.js";var B;const D=[k.POSTPROCESSING_ENVIRONMENT_OPAQUE,k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT];let Q=B=class extends t{constructor(e){super(e),this._context=null,this._atmosphere=null,this._hqAtmosphere=null,this._oldWeatherParameters=new J,this._newWeatherParameters=new J,this._fadedWeatherParameters=new J,this._weatherParameters=this._newWeatherParameters}initialize(){this.view._stage.addRenderPlugin(D,this)}destroy(){this.removeHandles(),null!=this.view?._stage&&this.view._stage.removeRenderPlugin(this),this._set("view",null)}get atmosphere(){return r(this._hqAtmosphere)&&this.view._stage.renderer.isFeatureEnabled(V.RealisticAtmosphere)?this._hqAtmosphere:this._atmosphere}get _atmosphereType(){return r(this.atmosphere)?this.atmosphere.type:P.None}get canRender(){return!!this.view.basemapTerrain?.renderer.canRender||"global"!==this.view.viewingMode}get needsLinearDepth(){return this._atmosphereType===P.Realistic}updateAnimation(e){return!!r(this._precipitation)&&this._precipitation.update(e)}get updating(){return r(this._stars)&&this._stars.updating||r(this._clouds)&&this._clouds.running}get weatherVisible(){return _(this.view.state.camera.eye)-w(this.view.spatialReference).radius<=I}get _stars(){const e=this.view,t=e.environment?.starsEnabled??!1,s=this._get("_stars");return!t||i(this._context)?(a(s),null):r(s)?s:new H({view:e,requestRender:()=>this._setNeedsRender()})}get _precipitation(){const e=this._get("_precipitation");if(!this._precipitationEnabled||i(this._context))return a(e),null;const t=this.view,s=this._context;return r(e)&&e.context===s?e:(a(e),new O({context:s,view:t}))}get _clouds(){const e=this._get("_clouds");if(!this.weatherEnabled||i(this._context))return a(e),null;if(r(e))return e;const t=this.view,s=this._context;return a(e),new N({context:s,view:t,requestRender:()=>this._setNeedsRender()})}get _cloudsComposition(){const e=this._get("_cloudsComposition");if(!this.weatherEnabled||i(this._context))return a(e),null;const t=this.view.state.viewingMode,s=this._context.renderContext.rctx,o=w(this.view.spatialReference).radius;return r(e)&&e.viewingMode===t&&e.planetRadius===o?e:(a(e),new R({rctx:s,viewingMode:t,planetRadius:o,requestRender:()=>this._setNeedsRender()}))}get _fog(){const e=this._get("_fog");if(!this.weatherEnabled||i(this._context))return a(e),null;if(r(e))return e;const t=this.view,s=this._context;return new C({context:s,view:t})}get _simpleHaze(){const e=this._get("_simpleHaze");if(!this.weatherEnabled||i(this._context))return a(e),null;if(r(e))return e;const t=this.view,s=this._context;return new F({context:s,view:t})}get weatherEnabled(){return!!this.view?.environmentManager?.weatherEnabled}get _precipitationEnabled(){return this.weatherEnabled&&("rainy"===this.view.environment.weather.type||"snowy"===this.view.environment.weather.type)}initializeRenderContext(e=null){this._context=e;const t=()=>this._setNeedsRender();this.addHandles([o((()=>this.view?.basemapTerrain),(()=>this._updateBasemapTerrain()),n),h((()=>({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled,quality:this.view.environment.atmosphere.quality})),(e=>this._updateAtmosphere(e)),n),h((()=>this._stars),t),h((()=>this._precipitation),t),h((()=>this._clouds),(()=>this._updateWeather()),p),h((()=>this._fog),(()=>this._updateFogHaze()),p),h((()=>this._simpleHaze),(()=>this._updateFogHaze()),p),h((()=>this.view.state.mode),(()=>{this._setNeedsRender()}),m),h((()=>this._atmosphereType),(()=>this._updateBasemapTerrain()),n),h((()=>this._weatherUpdateParameters),(()=>{this._updateWeather(),this._updateFogHaze()}),n)])}uninitializeRenderContext(){this._context=null,this._atmosphere=a(this._atmosphere),this._hqAtmosphere=a(this._hqAtmosphere),this._set("_stars",a(this._stars)),this._set("_precipitation",a(this._precipitation)),this._set("_clouds",a(this._clouds)),this._set("_cloudsComposition",a(this._cloudsComposition)),this._set("_fog",a(this._fog)),this._set("_simpleHaze",a(this._simpleHaze))}prepareRender(e){e.bindParameters.cloudsFade.data=A(this._clouds)?this._clouds:null,"local"!==this.view.viewingMode&&(M(e.bindParameters.cloudsFade,e.bindParameters.camera,this.view.state.mode,e.time,this.view.qualitySettings.fadeDuration),this._updateWeatherFading(e.bindParameters),e.bindParameters.cloudsFade.renderingStage===W.FINISHED&&r(this._clouds)&&0===this._clouds.coverage&&!1===this._clouds.running&&this._clouds.destroyFrameBufferCube())}render(e){if(e.output===U.Color)switch(e.bindParameters.slot){case k.POSTPROCESSING_ENVIRONMENT_OPAQUE:r(this._stars)&&this._stars.render(e),r(this.atmosphere)&&(this.atmosphere.render(e),r(this._cloudsComposition)&&r(e.bindParameters.cloudsFade.data)&&(this.weatherVisible&&r(this._clouds)&&this._clouds.updateWeatherTile(),this._cloudsComposition.render(e)),L(e.bindParameters.cloudsFade)&&r(this._context)&&this._context.requestRender());break;case k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT:if(r(this.atmosphere)&&(this.atmosphere.renderHaze(e,this._weatherParameters.haze.amount),this._weatherParameters.haze.amount>0&&this._atmosphereType!==P.Realistic&&r(this._simpleHaze)&&this._simpleHaze.render(e,this._weatherParameters.haze),this._weatherParameters.fog.amount>0&&r(this._fog)&&this._fog.render(e,this._weatherParameters.fog),r(this._precipitation))){const t=this.view.environment.weather;"rainy"!==t.type&&"snowy"!==t.type||this._precipitation.render(e,t.precipitation,t.type)}}}updateLightSources(e,t,s,i){if(r(this._context)){const r=this._context.renderContext;r.bindParameters.oldLighting.copyFrom(r.bindParameters.lighting),r.bindParameters.newLighting.noonFactor=t,r.bindParameters.newLighting.globalFactor=s,r.bindParameters.newLighting.set(e);i===G.Faded||r.bindParameters.weatherFading?r.bindParameters.fadeLighting(0):r.bindParameters.fadeLighting(1),this._context.requestRender()}}get _weatherUpdateParameters(){const e=this.weatherEnabled?this.view.environment.weather:null;return i(e)?null:"rainy"===e.type||"snowy"===e.type?{type:e.type,weatherAdjustment:e.cloudCover,effect:e.precipitation}:{type:e.type,weatherAdjustment:"foggy"===e.type?e.fogStrength:e.cloudCover}}_updateWeatherFading(e){if(!e.weatherFading)return;const t=e.cloudsFade;return t.fadeIn.stage===x.FADE_IN?(e.fadeLighting(t.fadeIn.factor),void this._fadeWeather(t.fadeIn.factor)):t.fadeInOut.stage===z.FADE_IN?(e.fadeLighting(t.fadeInOut.factor),void this._fadeWeather(t.fadeInOut.factor)):t.crossFade.enabled?(e.fadeLighting(t.crossFade.factor),void this._fadeWeather(t.crossFade.factor)):(e.fadeLighting(0),void this._fadeWeather(0))}_fadeWeather(e){const{_newWeatherParameters:t,_oldWeatherParameters:s}=this;e>=1?this._weatherParameters=t:(this._fadedWeatherParameters.lerp(s,t,e),this._weatherParameters=this._fadedWeatherParameters)}_updateWeather(){const e=this._weatherUpdateParameters;i(e)||i(this._clouds)||(this._clouds.applyPreset(j[e.type],e.weatherAdjustment),this._setNeedsRender())}_setNeedsRender(){r(this._context)&&this._context.requestRender()}_updateFogHaze(){const e=this._weatherUpdateParameters;if(i(this._fog)||i(this._simpleHaze)||i(e)||i(this._context))return;const t=this._context.renderContext.bindParameters;switch(this._oldWeatherParameters.copyFrom(this._weatherParameters),e.type){case"foggy":this._newWeatherParameters.fog.strength=s(3e-5,.005,e.weatherAdjustment**3),c(this._newWeatherParameters.fog.color,X),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.haze.strength=0,this._newWeatherParameters.haze.amount=this._atmosphereType===P.Realistic?1:0,this._setNeedsRender();break;case"rainy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),c(this._newWeatherParameters.fog.color,K),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.haze.strength=0,this._newWeatherParameters.haze.amount=0,this._setNeedsRender();break;case"snowy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),c(this._newWeatherParameters.fog.color,X),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.haze.strength=0,this._newWeatherParameters.haze.amount=this._atmosphereType===P.Realistic?1:0,this._setNeedsRender();break;default:this._newWeatherParameters.fog.strength=0,this._newWeatherParameters.fog.amount=0,this._newWeatherParameters.haze.strength=4e-6,this._newWeatherParameters.haze.amount=1,this._setNeedsRender()}t.weatherFading?this._fadeWeather(0):this._fadeWeather(1)}_updateAtmosphere(e){const t=this._selectAtmosphereType(e);if(r(this._atmosphere)?this._atmosphere.type===t:t===P.None)return;this._atmosphere=a(this._atmosphere),this._hqAtmosphere=a(this._hqAtmosphere);const s=this._getAtmosphereClass(t);s&&r(this._context)&&(this._atmosphere=new s(this.view),this._atmosphere.initializeRenderContext(this._context),t===P.Simple&&(this._hqAtmosphere=new b(this.view),this._hqAtmosphere.initializeRenderContext(this._context))),this._setNeedsRender(),this._updateBasemapTerrain()}_getAtmosphereClass(e){switch(e){case P.Realistic:return b;case P.Panoramic:return T;case P.Simple:return S;default:case P.None:return null}}_selectAtmosphereType(e){const{enabled:t,quality:s,viewingMode:i}=e;return!t||f(this.view.spatialReference)?P.None:i===v.Local?P.Panoramic:r(this._context)&&"high"===s&&b.isSupported(this._context)&&y(this.view.spatialReference)?P.Realistic:P.Simple}_updateBasemapTerrain(){this.view.basemapTerrain&&(this.view.basemapTerrain.velvetOverground=this._atmosphereType===P.Simple)}get test(){return{atmosphere:this._atmosphere,clouds:this._clouds,selectAtmosphereType:()=>this._selectAtmosphereType({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled,quality:this.view.environment.atmosphere.quality}),stubGetAtmosphereClass:e=>{Y=B.prototype._getAtmosphereClass,B.prototype._getAtmosphereClass=e},restoreGetAtmosphereClass:()=>{B.prototype._getAtmosphereClass=Y}}}};e([d({constructOnly:!0})],Q.prototype,"view",void 0),e([d({readOnly:!0})],Q.prototype,"atmosphere",null),e([d({readOnly:!0})],Q.prototype,"_atmosphereType",null),e([d({type:Boolean,readOnly:!0})],Q.prototype,"updating",null),e([d({readOnly:!0})],Q.prototype,"weatherVisible",null),e([d()],Q.prototype,"_context",void 0),e([d()],Q.prototype,"_atmosphere",void 0),e([d()],Q.prototype,"_hqAtmosphere",void 0),e([d({readOnly:!0})],Q.prototype,"_stars",null),e([d({readOnly:!0})],Q.prototype,"_precipitation",null),e([d({readOnly:!0})],Q.prototype,"_clouds",null),e([d({readOnly:!0})],Q.prototype,"_cloudsComposition",null),e([d({readOnly:!0})],Q.prototype,"_fog",null),e([d({readOnly:!0})],Q.prototype,"_simpleHaze",null),e([d({readOnly:!0})],Q.prototype,"weatherEnabled",null),e([d({readOnly:!0})],Q.prototype,"_precipitationEnabled",null),e([d({readOnly:!0})],Q.prototype,"_weatherUpdateParameters",null),Q=B=e([l("esri.views.3d.environment.EnvironmentRenderer")],Q);class J{constructor(){this.fog=new E,this.haze=new q}copyFrom(e){this.fog.amount=e.fog.amount,this.haze.amount=e.haze.amount,this.fog.strength=e.fog.strength,this.haze.strength=e.haze.strength,c(this.fog.color,e.fog.color)}lerp(e,t,r){this.fog.amount=s(e.fog.amount,t.fog.amount,r),this.haze.amount=s(e.haze.amount,t.haze.amount,r),this.fog.strength=s(e.fog.strength,t.fog.strength,r),this.haze.strength=s(e.haze.strength,t.haze.strength,r),u(this.fog.color,e.fog.color,t.fog.color,r)}}const K=g(.5,.5,.5),X=g(1.5,1.5,1.5);let Y;export{Q as EnvironmentRenderer,J as WeatherParameters};