@arcgis/core 4.32.0-next.20250205 → 4.32.0-next.20250207

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 (184) hide show
  1. package/arcade/treeAnalysis.js +1 -1
  2. package/arcade.js +1 -1
  3. package/assets/components/assets/icon/dualImageArea16.json +1 -0
  4. package/assets/components/assets/icon/dualImageArea24.json +1 -0
  5. package/assets/components/assets/icon/dualImageArea32.json +1 -0
  6. package/assets/components/assets/icon/dualImageDistance16.json +1 -0
  7. package/assets/components/assets/icon/dualImageDistance24.json +1 -0
  8. package/assets/components/assets/icon/dualImageDistance32.json +1 -0
  9. package/assets/components/assets/icon/dualImageLocation16.json +1 -0
  10. package/assets/components/assets/icon/dualImageLocation24.json +1 -0
  11. package/assets/components/assets/icon/dualImageLocation32.json +1 -0
  12. package/assets/esri/core/workers/RemoteClient.js +1 -1
  13. package/assets/esri/core/workers/chunks/{24a86c52c8bdd0b5eb4d.js → 09a99c556089c166d1f8.js} +1 -1
  14. package/assets/esri/core/workers/chunks/0a8e388e96af44deeabb.js +1 -0
  15. package/assets/esri/core/workers/chunks/12d6baeffd55a98a7c75.js +1 -0
  16. package/assets/esri/core/workers/chunks/143a193fa3a6e645c8ac.js +1 -0
  17. package/assets/esri/core/workers/chunks/{9b4f471fcd8a3b5e089f.js → 192569dfa7c0ea8dd864.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{ad215219e5eef8598745.js → 28dbbfc44cc2bdcd221d.js} +1 -1
  19. package/assets/esri/core/workers/chunks/308ec51ff4a66f7fcb0d.js.LICENSE.txt +1 -1
  20. package/assets/esri/core/workers/chunks/{72cf9192292e5c85c6df.js → 32d3657dcae89b740f8b.js} +2 -2
  21. package/assets/esri/core/workers/chunks/{72cf9192292e5c85c6df.js.LICENSE.txt → 32d3657dcae89b740f8b.js.LICENSE.txt} +1 -1
  22. package/assets/esri/core/workers/chunks/333091ab2e267652ed56.js +1 -0
  23. package/assets/esri/core/workers/chunks/354531dc2f0dea2ad96f.js.LICENSE.txt +1 -1
  24. package/assets/esri/core/workers/chunks/35e4af82a08b4eadbfab.js +1 -0
  25. package/assets/esri/core/workers/chunks/369a2b8484a8807bde38.js +1 -0
  26. package/assets/esri/core/workers/chunks/4040158835f9036967cd.js +2 -0
  27. package/assets/esri/core/workers/chunks/{1a2e1a414e651e988435.js.LICENSE.txt → 4040158835f9036967cd.js.LICENSE.txt} +1 -6
  28. package/assets/esri/core/workers/chunks/{8a1e4f65fc81aba7a704.js → 4122d10bc910e888eee1.js} +1 -1
  29. package/assets/esri/core/workers/chunks/433576983754f690bcc7.js +1 -0
  30. package/assets/esri/core/workers/chunks/459af0c3d62c3ed11c19.js +1 -0
  31. package/assets/esri/core/workers/chunks/53810519ff5922b42cd2.js +1 -0
  32. package/assets/esri/core/workers/chunks/5721557a1d8eab23a55b.js +1 -0
  33. package/assets/esri/core/workers/chunks/594d923400fd74881833.js +1 -0
  34. package/assets/esri/core/workers/chunks/{7a0415db78c68d31733f.js → 6039da57a2adedd3b83f.js} +1 -1
  35. package/assets/esri/core/workers/chunks/62a1d60ad4bf6469c4dd.js +1 -0
  36. package/assets/esri/core/workers/chunks/{81aa8cc289fd02ca4da6.js → 7058001bf66f9f3d5d45.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{e8ae8a11d8439e2a66ad.js → 706f867a9034d62a8ef7.js} +1 -1
  38. package/assets/esri/core/workers/chunks/77764ca90bdd13ee2167.js.LICENSE.txt +1 -1
  39. package/assets/esri/core/workers/chunks/{1ab83753d9eec0463461.js → 7b367bb0ed9c218ca595.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{723a9fba144e2fa6d017.js → 7cb09e58bcc537ec1f7a.js} +1 -1
  41. package/assets/esri/core/workers/chunks/8191dd3d7451b2e7b95e.js +1 -0
  42. package/assets/esri/core/workers/chunks/842db06ce62758fab1e7.js +1 -0
  43. package/assets/esri/core/workers/chunks/8c32cee395da0a7b9a8e.js +1 -0
  44. package/assets/esri/core/workers/chunks/{48ecc5a74fecbb2b9c6f.js → 8d8f5f08d730270e1165.js} +1 -1
  45. package/assets/esri/core/workers/chunks/94225d92afbdb10dfedb.js +1 -0
  46. package/assets/esri/core/workers/chunks/94490937dca566fe2640.js +1 -0
  47. package/assets/esri/core/workers/chunks/{d3d1dcb440588a295eba.js → 9a237b396518b1c67f19.js} +1 -1
  48. package/assets/esri/core/workers/chunks/9d61590c4d21c7421925.js +1 -0
  49. package/assets/esri/core/workers/chunks/{610b33b7291cffcc4e5d.js → a42ae5d5e5f66d120b4d.js} +1 -1
  50. package/assets/esri/core/workers/chunks/a5e9ea13e844a62b2a7f.js +1 -0
  51. package/assets/esri/core/workers/chunks/b21b152fa15896577242.js.LICENSE.txt +1 -1
  52. package/assets/esri/core/workers/chunks/b43d88b6e7dc4ab13599.js +1 -0
  53. package/assets/esri/core/workers/chunks/{6d5bfcc7856cafe7b043.js → b765670b47d209d7655a.js} +2 -2
  54. package/assets/esri/core/workers/chunks/{6d5bfcc7856cafe7b043.js.LICENSE.txt → b765670b47d209d7655a.js.LICENSE.txt} +1 -1
  55. package/assets/esri/core/workers/chunks/c26ffbff1115e76bcb0f.js +1 -0
  56. package/assets/esri/core/workers/chunks/d29c3bf29fcd7fa31f1a.js +1 -0
  57. package/assets/esri/core/workers/chunks/d339dee99c4820b63f39.js +1 -0
  58. package/assets/esri/core/workers/chunks/{9c5c6ecaf5be24279fa5.js → ddc30044f61a2c2df3fe.js} +1 -1
  59. package/assets/esri/core/workers/chunks/de1f3c4b8000c2d73013.js +1 -0
  60. package/assets/esri/core/workers/chunks/e4b3f2d5c43518b0cde7.js +1 -0
  61. package/assets/esri/core/workers/chunks/e5e3b6d00d27b5bb354f.js +1 -0
  62. package/assets/esri/core/workers/chunks/ef6279f5c63ab1e88c71.js +1 -0
  63. package/assets/esri/core/workers/chunks/{0711d3ad4d403bcfdcad.js → f117a89d1f4001a1f9f0.js} +1 -1
  64. package/assets/esri/core/workers/chunks/f14b318bab5efcf43419.js +1 -0
  65. package/assets/esri/core/workers/chunks/f32ca4381e804cc3481e.js +1 -0
  66. package/assets/esri/core/workers/chunks/f9070edd8e0b2a57af79.js +1 -0
  67. package/assets/esri/core/workers/chunks/f9e48205178a5a804d38.js +1 -0
  68. package/assets/esri/themes/base/widgets/_ItemList.scss +6 -0
  69. package/assets/esri/themes/dark/main.css +1 -1
  70. package/assets/esri/themes/light/main.css +1 -1
  71. package/assets/esri/themes/light/view.css +1 -1
  72. package/chunks/WaterSurface.glsl.js +2 -2
  73. package/geometry/support/meshUtils/elevation.js +1 -1
  74. package/interfaces.d.ts +121 -84
  75. package/layers/FeatureLayer.js +1 -1
  76. package/layers/Layer.js +1 -1
  77. package/layers/SubtypeGroupLayer.js +1 -1
  78. package/layers/WCSLayer.js +1 -1
  79. package/layers/graphics/data/FeatureStore.js +1 -1
  80. package/layers/graphics/data/QueryEngineCapabilities.js +1 -1
  81. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  82. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  83. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  84. package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
  85. package/layers/graphics/sources/support/sourceUtils.js +1 -1
  86. package/layers/mixins/BlendLayer.js +1 -1
  87. package/layers/mixins/FeatureLayerBase.js +1 -1
  88. package/layers/mixins/OperationalLayer.js +1 -1
  89. package/layers/mixins/operationalLayerModuleMap.js +1 -1
  90. package/layers/support/SubtypeSublayer.js +1 -1
  91. package/layers/support/arcadeUtils.js +1 -1
  92. package/layers/support/commonProperties.js +1 -1
  93. package/layers/support/layersCreator.js +1 -1
  94. package/layers/support/rasterFunctionUtils.d.ts +2 -1
  95. package/layers/support/rasterFunctionUtils.js +1 -1
  96. package/layers/support/rasterFunctions/creators/createDataManagementFunctions.js +1 -1
  97. package/package.json +2 -2
  98. package/portal/support/layersLoader.js +1 -1
  99. package/portal/support/loadUtils.js +1 -1
  100. package/rest/imageService.js +1 -1
  101. package/rest/support/ImageSampleParameters.js +1 -1
  102. package/rest/support/ImageSampleResult.js +1 -1
  103. package/rest/support/ImageVolumeResult.js +1 -1
  104. package/smartMapping/support/adapters/InMemoryLayerAdapter.js +1 -1
  105. package/smartMapping/support/adapters/support/histogramUtils.js +1 -1
  106. package/support/TablesMixin.js +1 -1
  107. package/support/arcadeUtils.js +1 -1
  108. package/support/revision.js +1 -1
  109. package/symbols/cim/CIMSymbolRasterizer.js +1 -1
  110. package/symbols/cim/cimAnalyzer.js +1 -1
  111. package/symbols/cim/fitVectorMarker.js +5 -0
  112. package/symbols/support/previewCIMSymbol.js +1 -1
  113. package/views/2d/engine/webgl/TextureManager.js +1 -1
  114. package/views/2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapResources.js +1 -1
  115. package/views/2d/layers/features/schema/SourceSchema.js +1 -1
  116. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  117. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  118. package/views/2d/layers/features/sources/strategies/DrillDownTileLoadStrategy.js +1 -1
  119. package/views/2d/layers/features/sources/strategies/PagedTileLoadStrategy.js +1 -1
  120. package/views/2d/layers/features/sources/strategies/ParquetLoadStrategy.js +1 -1
  121. package/views/2d/layers/features/sources/strategies/SnapshotLoadStrategy.js +1 -1
  122. package/views/2d/layers/features/sources/strategies/StreamLoadStrategy.js +1 -1
  123. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  124. package/views/3d/layers/MediaLayerView3D.js +1 -1
  125. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  126. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  127. package/views/3d/terrain/OverlayManager.js +1 -1
  128. package/views/3d/terrain/OverlayRenderer.js +1 -1
  129. package/views/3d/terrain/TerrainSurface.js +1 -1
  130. package/views/3d/webgl-engine/Stage.js +1 -1
  131. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  132. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  133. package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
  134. package/views/LayerViewManager.js +1 -1
  135. package/views/SceneView.js +1 -1
  136. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  137. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileCache.js +1 -1
  138. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
  139. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  140. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  141. package/widgets/Editor/EditorViewModel.js +1 -1
  142. package/widgets/Editor/UpdateWorkflow.js +1 -1
  143. package/widgets/Editor/VisibleElements.js +1 -1
  144. package/widgets/Editor/components/FeatureList.js +1 -1
  145. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  146. package/widgets/Editor/workflowUtils.js +1 -1
  147. package/widgets/Editor.js +1 -1
  148. package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
  149. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  150. package/widgets/OrientedImageryViewer/components/ImageLocationWidget.js +1 -1
  151. package/widgets/Sketch.js +1 -1
  152. package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
  153. package/assets/esri/core/workers/chunks/07bff9e742f3e5877f3f.js +0 -1
  154. package/assets/esri/core/workers/chunks/1a2e1a414e651e988435.js +0 -2
  155. package/assets/esri/core/workers/chunks/287362f9af132fafe4de.js +0 -1
  156. package/assets/esri/core/workers/chunks/2ea5e5e6c4660a06b516.js +0 -1
  157. package/assets/esri/core/workers/chunks/380d37ceb8cf52bad190.js +0 -1
  158. package/assets/esri/core/workers/chunks/3984bf01f055fc42bfbf.js +0 -1
  159. package/assets/esri/core/workers/chunks/39e38aab86dcee3f79be.js +0 -1
  160. package/assets/esri/core/workers/chunks/41cd1a5c99ab3bbd1fb4.js +0 -1
  161. package/assets/esri/core/workers/chunks/5e7f16b312077ca8c18d.js +0 -1
  162. package/assets/esri/core/workers/chunks/6ec108bd955e064256b5.js +0 -1
  163. package/assets/esri/core/workers/chunks/6ef2514a6b7bbfb8e37d.js +0 -1
  164. package/assets/esri/core/workers/chunks/7e4d72279cc599b7029c.js +0 -1
  165. package/assets/esri/core/workers/chunks/82d26884127ed772cc4b.js +0 -1
  166. package/assets/esri/core/workers/chunks/8438fba57e82e4cc7c11.js +0 -1
  167. package/assets/esri/core/workers/chunks/858b191c078d04232342.js +0 -1
  168. package/assets/esri/core/workers/chunks/918bdba41fa470cf77fd.js +0 -1
  169. package/assets/esri/core/workers/chunks/91d2bdfa6e34c10b7f50.js +0 -1
  170. package/assets/esri/core/workers/chunks/92155d112ebb6a4c6c6e.js +0 -1
  171. package/assets/esri/core/workers/chunks/991e0f619f1f81f94d56.js +0 -1
  172. package/assets/esri/core/workers/chunks/9a27824d94df702e6e28.js +0 -1
  173. package/assets/esri/core/workers/chunks/b33122adfd1fb68f7c0f.js +0 -1
  174. package/assets/esri/core/workers/chunks/bbbe5d6cb8b737811c84.js +0 -1
  175. package/assets/esri/core/workers/chunks/bf26f58210755875748c.js +0 -1
  176. package/assets/esri/core/workers/chunks/c1fd87af3129873369fd.js +0 -1
  177. package/assets/esri/core/workers/chunks/c4c2b94e5cee7b824093.js +0 -1
  178. package/assets/esri/core/workers/chunks/c85374360ac5e169af16.js +0 -1
  179. package/assets/esri/core/workers/chunks/c94ec324ecad77c53a87.js +0 -1
  180. package/assets/esri/core/workers/chunks/d175953337fa655dc6b0.js +0 -1
  181. package/assets/esri/core/workers/chunks/d8c762ca94e3a11b125d.js +0 -1
  182. package/assets/esri/core/workers/chunks/dbc447413ab40a79ba87.js +0 -1
  183. package/assets/esri/core/workers/chunks/e26dc0c1654316bb1558.js +0 -1
  184. package/assets/esri/core/workers/chunks/e410a09650530d7aad10.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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{pickRandom as t}from"../../../core/arrayUtils.js";import r from"../../../core/Error.js";import a from"../../../core/Logger.js";import{assertIsSome as i}from"../../../core/maybe.js";import{timeout as s,throwIfAborted as o}from"../../../core/promiseUtils.js";import{whenOnce as n}from"../../../core/reactiveUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{toQuantizationTransform as m}from"../../../geometry/support/quantizationUtils.js";import{kebabDict as p}from"../../../layers/support/fieldType.js";import{isTimeOnlyField as y}from"../../../layers/support/fieldUtils.js";import c from"../../../rest/support/QuantizationParameters.js";import{getArcadeForPredominantCategory as f}from"../../statistics/support/predominanceUtils.js";import{summaryStatistics as d,uniqueValues as h,histogram as w,classBreaks as g,heatmapStatistics as F}from"../../statistics/support/statsWorker.js";import{mergeWhereClauses as S}from"../../statistics/support/utils.js";import{WorkerClient as v}from"../../statistics/support/WorkerClient.js";import{getFieldsList as q,isAnyDateField as V,fieldDelimiter as x}from"../utils.js";import z from"./LayerAdapter.js";import{getAttributeBinsQuery as _,processQueryAttributeBinsResult as T}from"./support/histogramUtils.js";import{ensureFeaturesJSON as N,getSummaryStatsQuery as M,getSummaryStatisticsFromFeatureSet as E,getViewInfoParams as L,getMissingFields as C,updateQueryWithFeatureFilter as j,getUVQuery as I,getUniqueValuesFromFeatureSet as b,getBins as O,getDomainsForFields as k,getPredominantCategoriesFromUVInfos as Q}from"./support/utils.js";import{processSummaryStatisticsResult as B,createUVResult as J,resolveCBResult as P}from"../../../statistics/utils.js";import{loadArcade as U}from"../../../support/arcadeOnDemand.js";const A=5;let $=null,G=class extends z{constructor(){super(...arguments),this._hasLocalSource=!1,this.adapterName="in-memory-layer-adapter"}destroy(){this.workerClient?.destroy()}async _waitForLayerViewUpdate(e){if(!e)throw new r(`${this.adapterName}:insufficient-data", "layerView is required to fetch the features`);const t=new AbortController,i=n((()=>!e.updating),t.signal);await s(i,5e3,t).catch((e=>{throw a.getLogger(this).warn("LayerView is taking too long to update. Aborting fetch from layerView."),e}))}async _fetchFeatureSetFromMemory(e,t,a){const i=this.layer;if(this._hasLocalSource&&"queryFeatures"in i)return i.queryFeatures(e);if(!t)throw new r(`${this.adapterName}:insufficient-data`,"view is required to fetch the features from layerView");const s=await t.whenLayerView(this.layer);return await this._waitForLayerViewUpdate(s),s.queryFeatures(e,{signal:a})}async _fetchFeaturesFromMemory(e,t,a,i){const s=this.layer,o="json"===i;if(this._hasLocalSource&&"queryFeatures"in s){const e=await s.queryFeatures(t);return o?N(e.features):e.features}if(await this._waitForLayerViewUpdate(e),o&&"queryFeaturesJSON"in e&&e.queryFeaturesJSON){const{features:r}=await e.queryFeaturesJSON(t,{signal:a});return r}if(!("queryFeatures"in e))throw new r(`${this.adapterName}:not-supported`,"'queryFeatures' is not supported on the layerView");const n=await e.queryFeatures(t,{signal:a});return o?N(n.features):n.features}_fetchFeaturesForStats(e,t){return q({field:e.field,field2:e.field2,field3:e.field3,normalizationField:e.normalizationField,valueExpression:e.valueExpression}).then((r=>this.getSampleFeatures({sampleSize:-1,view:e.view,returnGeometry:e.returnGeometry,filter:e.filter,requiredFields:r,signal:e.signal},t)))}async _summaryStatsFromClientQuery(e,t){const{view:r,signal:a}=e,i=M(this,e,t),s=await this._fetchFeatureSetFromMemory(i,r,a),o=E(s,V(t)||y(t));return B(o,e.outStatisticTypes)}async _getNormalizationTotalFromMemory(e,t,a){const{featuresJSON:i,graphics:s,layerView:o,query:n}=t,l={include:["sum"]},u=(!i&&!s&&o&&"querySummaryStatistics"in o?await o.querySummaryStatistics(n,{field:e},{signal:a}):i?await this.workerClient.summaryStatistics({field:e,outStatisticTypes:l},i):await d({attribute:{field:e,outStatisticTypes:l},features:s??[]})).sum;if(null==u)throw new r(`${this.adapterName}:invalid`,"invalid normalizationTotal");return u}async _summaryStatsFromMemory(e,t){const{view:r,field:a,valueExpression:i,normalizationType:s,signal:o}=e,n={field:a,valueExpression:i,normalizationType:s,normalizationField:e.normalizationField,normalizationTotal:e.normalizationTotal,minValue:e.minValue,maxValue:e.maxValue,outStatisticTypes:e.outStatisticTypes},{featuresJSON:l,graphics:u,layerView:m,query:y,fieldInfos:c}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"querySummaryStatistics"});return i&&r&&(l||u)&&(n.fieldType=t?.type?p.toJSON(t.type):null,n.viewInfoParams=L(r),n.timeZone=r.timeZone,n.fieldInfos=c),"percent-of-total"===s&&null==e.normalizationTotal&&(n.normalizationTotal=await this._getNormalizationTotalFromMemory(a,{featuresJSON:l,graphics:u,layerView:m,query:y},o)),!l&&!u&&m&&"querySummaryStatistics"in m?m.querySummaryStatistics(y,n,{signal:o}):l?this.workerClient.summaryStatistics(n,l):d({attribute:n,features:u})}async _getFilteredFeatures(e,t){let r=[];if("intersects"===t?.spatialRelationship){const{intersect:a}=await import("../../../geometry/geometryEngineAsync.js"),i=null!=t.geometry?t.geometry:null;for(const t of e){const e=null!=t.geometry?t.geometry:null;if(e&&i){await a(e,i)&&r.push(t)}}}else r=e;return e.length&&"declaredClass"in e[0]&&"esri.Graphic"===e[0].declaredClass?{graphics:r}:{featuresJSON:r}}async _processStatsFromMemoryParams(e){const{features:t,filter:r}=e;if(t?.length)return this._getFilteredFeatures(t,r);const{view:a,field:i,field2:s,field3:o,normalizationField:n,valueExpression:l,layerViewFunc:u,signal:m}=e;let p=e.returnGeometry;if(null==p&&l){if(!$){const{arcadeUtils:e}=await U();$=e}const e=$.hasGeometryOperations(l);e&&await $.enableGeometryOperations(),p=e}let y=null,c=null,f=null,d=null,h=null;if(a)try{const e="subtype-sublayer"===this.layer.type?this.layer.parent:this.layer;y=await a.whenLayerView(e),c=null!=u&&u in y&&"function"==typeof y[u]}catch{c=!1}if(c)try{await this._waitForLayerViewUpdate(y);const e=await q({field:i,field2:s,field3:o,normalizationField:n,valueExpression:l});C(this,e,y).length?c=!1:(f=this.layer.createQuery(),f.outFields=e,f.returnGeometry=!1,j(f,r)),y.suspended&&(c=!1)}catch{c=!1}return c||(d=await this._fetchFeaturesForStats({field:i,field2:s,field3:o,valueExpression:l,normalizationField:n,returnGeometry:p,filter:r,view:a,signal:m},"json"),h=(await q({valueExpression:l})).map((e=>this.getField(e)?.toJSON())).filter(Boolean)),{layerView:y,query:f,featuresJSON:d,fieldInfos:h}}async _uvFromClientQuery(e,t){const{view:r,signal:a}=e,i=I(this,e),s=await this._fetchFeatureSetFromMemory(i,r,a),o=await b(s,{layer:this,field:e.field,field2:e.field2,field3:e.field3,fieldDelimiter:x,view:e.view,signal:e.signal});return J(o,t,e.returnAllCodedValues,x)}async _uvFromMemory(e,t){const{view:r,field:a,valueExpression:i,returnAllCodedValues:s,signal:o}=e,{featuresJSON:n,graphics:l,layerView:u,query:m,fieldInfos:p}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"queryUniqueValues"}),y={field:a,field2:e.field2,field3:e.field3,fieldDelimiter:x,valueExpression:i,domains:t,returnAllCodedValues:s};return i&&r&&(n||l)&&(y.viewInfoParams=L(r),y.timeZone=r.timeZone,y.fieldInfos=p),!n&&!l&&u&&"queryUniqueValues"in u?u.queryUniqueValues(m,y,{signal:o}):n?this.workerClient.uniqueValues(y,n):h({attribute:y,features:l})}_histogramForField(e){let t=null;return t=null!=e.minValue&&null!=e.maxValue?Promise.resolve({min:e.minValue,max:e.maxValue}):this.summaryStatistics({...e,outStatisticTypes:{include:["min","max","count"]}}).then((e=>{if(!e.count)throw new r(`${this.adapterName}:insufficient-data`,"Either the layer has no features or none of the features have data for the field");return{min:e.min,max:e.max}})),t.then((t=>O(this,{min:t.min,max:t.max},e.field,e.numBins??void 0,e.view,e.filter,e.signal)))}async _histogramFromQueryAttributeBinsFromMemory(e){const{field:t,normalizationType:a,signal:i}=e,{featuresJSON:s,graphics:o,layerView:n,query:l}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"queryAttributeBins"});if(!n||!("queryAttributeBins"in n)||s)throw new r(`${this.adapterName}:not-supported`,"'queryAttributeBins' is not supported on the layerView");const u="percent-of-total"===a?e.normalizationTotal??await this._getNormalizationTotalFromMemory(t,{featuresJSON:s,graphics:o,layerView:n,query:l},i):null,{query:m,min:p,max:y}=await _(e,this,u,l?.where);if(!m)return{bins:[],minValue:p,maxValue:y,normalizationTotal:u};const c=await n.queryAttributeBins(m,{signal:i});return T(c,t?this.getField(t):null,{minValue:p,maxValue:y,normalizationTotal:u})}async _histogramFromMemory(e){const{view:t,field:r,valueExpression:a,signal:i}=e,{featuresJSON:s,graphics:o,layerView:n,query:l,fieldInfos:u}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"queryHistogram"}),m={field:r,valueExpression:a,normalizationType:e.normalizationType,normalizationField:e.normalizationField,normalizationTotal:e.normalizationTotal,minValue:e.minValue,maxValue:e.maxValue,standardDeviationInterval:e.standardDeviationInterval,classificationMethod:e.classificationMethod,numBins:e.numBins};return a&&t&&(s||o)&&(m.viewInfoParams=L(t),m.timeZone=t.timeZone,m.fieldInfos=u),"percent-of-total"===e.normalizationType&&null==e.normalizationTotal&&(m.normalizationTotal=await this._getNormalizationTotalFromMemory(r,{featuresJSON:s,graphics:o,layerView:n,query:l},i)),!s&&!o&&n&&"queryHistogram"in n?n.queryHistogram(l,m,{signal:i}):s?this.workerClient.histogram(m,s):w({attribute:m,features:o})}_classBreaksFromInterpolation(e){const{minValue:t,maxValue:r}=e,a=e.numClasses||A,i=[],s=(r-t)/a;for(let l=0;l<a;l++){const e=t+l*s;i.push({minValue:e,maxValue:e+s})}i[a-1].maxValue=r;const o={classBreaks:i,normalizationTotal:e.normalizationTotal},n=P(o,e.classificationMethod);return Promise.resolve(n)}async _classBreaksFromMemory(e){const{view:t,field:r,valueExpression:a,signal:i}=e,{featuresJSON:s,graphics:o,layerView:n,query:l,fieldInfos:u}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"queryClassBreaks"}),m={field:r,valueExpression:a,normalizationType:e.normalizationType,normalizationField:e.normalizationField,normalizationTotal:e.normalizationTotal,minValue:e.minValue,maxValue:e.maxValue,standardDeviationInterval:e.standardDeviationInterval,classificationMethod:e.classificationMethod,numClasses:e.numClasses};return a&&t&&(s||o)&&(m.viewInfoParams=L(t),m.timeZone=t.timeZone,m.fieldInfos=u),"percent-of-total"===e.normalizationType&&null==e.normalizationTotal&&(m.normalizationTotal=await this._getNormalizationTotalFromMemory(r,{featuresJSON:s,graphics:o,layerView:n,query:l},i)),!s&&!o&&n&&"queryClassBreaks"in n?n.queryClassBreaks(l,m,{signal:i}):s?this.workerClient.classBreaks(m,s):g({attribute:m,features:o})}async _heatmapStatsFromMemory(e){const{view:t,field:r,radius:a,signal:s}=e;i(t,"InMemoryLayerAdapter: must have a view");try{const r=await t.whenLayerView(this.layer);if("queryHeatmapStatistics"in r&&!r.updating&&!e.filter)return await r.queryHeatmapStatistics({field:e.field,radius:e.radius})}catch{o(s)}const{featuresJSON:n,graphics:l}=await this._processStatsFromMemoryParams({...e,returnGeometry:!0}),u=new c({extent:t.extent,tolerance:"2d"===t.type?t.state.resolution:t.pixelSizeAt?.(t.center)}),p={field:r,radius:a,transform:m(u),spatialReference:t.spatialReference?.toJSON(),size:t.size};return n?.length||l?.length?n?this.workerClient.heatmapStatistics(p,n):F({attribute:p,features:l}):{min:null,max:null}}getField(e=""){return this.layer.getField(e)}getFieldUsageInfo(e){return this.getField(e)?{supportsLabelingInfo:!0,supportsRenderer:!0,supportsPopupTemplate:!0,supportsLayerQuery:!0,supportsStatistics:!0}:null}getFieldDomain(e,t){return this.layer.getFieldDomain(e,t)}createQuery(){return this.layer.createQuery()}async summaryStatistics(e){const{field:t,valueExpression:a,sqlExpression:i,features:s,view:o}=e,n=t?this.getField(t):null,l=!!a,u="3d"===o?.type;if(!a&&i&&!this.supportsSQLExpression)throw new r(`${this.adapterName}:not-supported`,"Layer does not support standardized SQL expression for queries");return l||s||u?this._summaryStatsFromMemory(e,n):this._summaryStatsFromClientQuery(e,n)}async uniqueValues(e){const{valueExpression:t,sqlExpression:a,features:i,view:s}=e,o=await k(e,this),n=!!t,l="3d"===s?.type;if(!t&&a&&!this.supportsSQLExpression)throw new r(`${this.adapterName}:not-supported`,"Layer does not support standardized SQL expression for queries");return n||i||l?this._uvFromMemory(e,o):this._uvFromClientQuery(e,o)}async histogram(e){const{features:t,valueExpression:a,normalizationType:i,sqlExpression:s}=e,o=t||!!a;if(!a&&s&&!this.supportsSQLExpression)throw new r(`${this.adapterName}:not-supported`,"Layer does not support standardized SQL expression for queries");return o||i?this._histogramFromMemory(e):this._histogramForField(e)}async classBreaks(e){return!1!==e.analyzeData?this._classBreaksFromMemory(e):this._classBreaksFromInterpolation(e)}async queryFeatureCount(e){const{whereClause:t,view:a,signal:i}=e;if(!a)throw new r(`${this.adapterName}:insufficient-data`,"view is required to fetch the features from layerView");const s=this.layer.createQuery();s.where=S(s.where,t);const o=await a.whenLayerView(this.layer);return await n((()=>!o.updating),i),o.queryFeatureCount(s,{signal:i})}async generateRenderer(e,t){throw new r(`${this.adapterName}:not-supported`,"Layer does not support generateRenderer operation")}async predominantCategories(e){const{fields:t,view:r,signal:a,filter:i}=e,s=f(t),o=await this._uvFromMemory({valueExpression:s,view:r,signal:a,filter:i});return Q(o.uniqueValueInfos,t)}async heatmapStatistics(e){return this._heatmapStatsFromMemory(e)}async getSampleFeatures(e,a){const{view:i,sampleSize:s,requiredFields:o,returnGeometry:n,filter:l,signal:u}=e,m=this.layer.createQuery(),p=1;if(m.outSpatialReference=i?.spatialReference,m.returnGeometry=!!n,m.outFields=o,j(m,l),!i)throw new r(`${this.adapterName}:not-supported`,"view is required to get sample features for Layer");const y=await i.whenLayerView(this.layer);if(C(this,o,y).length)throw new r(`${this.adapterName}:not-supported`,"Required fields need to be passed in the outFields for Layer");const c=await this._fetchFeaturesFromMemory(y,m,u,a),f=null!=s&&s>0&&s<=c.length?s:c.length;return t(c,f,p)}load(e){const t=this.layer.load(e).then((async t=>{this.geometryType=t.geometryType,this.objectIdField=t.objectIdField,this.supportsSQLExpression="stream"===t.type||!!t.capabilities?.query?.supportsSqlExpression,this.minScale=t.minScale,this.maxScale=t.maxScale,this.fullExtent="fullExtent"in t?t.fullExtent:t.parent?.fullExtent,this._hasLocalSource=!1,this.hasQueryEngine=!0,this.workerClient=v.getInstance(),await this.workerClient.open(e.signal)}));return this.addResolvingPromise(t),Promise.resolve(this)}};e([l({readOnly:!0})],G.prototype,"adapterName",void 0),e([l({constructOnly:!0})],G.prototype,"layer",void 0),G=e([u("esri.smartMapping.support.adapters.InMemoryLayerAdapter")],G);const D=G;export{D as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{pickRandom as t}from"../../../core/arrayUtils.js";import r from"../../../core/Error.js";import a from"../../../core/Logger.js";import{assertIsSome as i}from"../../../core/maybe.js";import{timeout as s,throwIfAborted as o}from"../../../core/promiseUtils.js";import{whenOnce as n}from"../../../core/reactiveUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{toQuantizationTransform as m}from"../../../geometry/support/quantizationUtils.js";import{kebabDict as p}from"../../../layers/support/fieldType.js";import{isTimeOnlyField as y}from"../../../layers/support/fieldUtils.js";import c from"../../../rest/support/QuantizationParameters.js";import{getArcadeForPredominantCategory as f}from"../../statistics/support/predominanceUtils.js";import{summaryStatistics as d,uniqueValues as h,histogram as w,classBreaks as g,heatmapStatistics as F}from"../../statistics/support/statsWorker.js";import{mergeWhereClauses as S}from"../../statistics/support/utils.js";import{WorkerClient as v}from"../../statistics/support/WorkerClient.js";import{getFieldsList as q,isAnyDateField as V,fieldDelimiter as x}from"../utils.js";import _ from"./LayerAdapter.js";import{getHistogramAttributeDefinition as z,getAttributeBinsQuery as T,processQueryAttributeBinsResult as N}from"./support/histogramUtils.js";import{ensureFeaturesJSON as M,getSummaryStatsQuery as L,getSummaryStatisticsFromFeatureSet as E,getViewInfoParams as C,getMissingFields as j,updateQueryWithFeatureFilter as b,getUVQuery as k,getUniqueValuesFromFeatureSet as I,getBins as O,getDomainsForFields as Q,getPredominantCategoriesFromUVInfos as J}from"./support/utils.js";import{processSummaryStatisticsResult as B,createUVResult as P,resolveCBResult as U}from"../../../statistics/utils.js";import{loadArcade as A}from"../../../support/arcadeOnDemand.js";const $=5;let G=null,R=class extends _{constructor(){super(...arguments),this._hasLocalSource=!1,this.adapterName="in-memory-layer-adapter"}destroy(){this.workerClient?.destroy()}async _waitForLayerViewUpdate(e){if(!e)throw new r(`${this.adapterName}:insufficient-data", "layerView is required to fetch the features`);const t=new AbortController,i=n((()=>!e.updating),t.signal);await s(i,5e3,t).catch((e=>{throw a.getLogger(this).warn("LayerView is taking too long to update. Aborting fetch from layerView."),e}))}async _fetchFeatureSetFromMemory(e,t,a){const i=this.layer;if(this._hasLocalSource&&"queryFeatures"in i)return i.queryFeatures(e);if(!t)throw new r(`${this.adapterName}:insufficient-data`,"view is required to fetch the features from layerView");const s=await t.whenLayerView(this.layer);return await this._waitForLayerViewUpdate(s),s.queryFeatures(e,{signal:a})}async _fetchFeaturesFromMemory(e,t,a,i){const s=this.layer,o="json"===i;if(this._hasLocalSource&&"queryFeatures"in s){const e=await s.queryFeatures(t);return o?M(e.features):e.features}if(await this._waitForLayerViewUpdate(e),o&&"queryFeaturesJSON"in e&&e.queryFeaturesJSON){const{features:r}=await e.queryFeaturesJSON(t,{signal:a});return r}if(!("queryFeatures"in e))throw new r(`${this.adapterName}:not-supported`,"'queryFeatures' is not supported on the layerView");const n=await e.queryFeatures(t,{signal:a});return o?M(n.features):n.features}_fetchFeaturesForStats(e,t){return q({field:e.field,field2:e.field2,field3:e.field3,normalizationField:e.normalizationField,valueExpression:e.valueExpression}).then((r=>this.getSampleFeatures({sampleSize:-1,view:e.view,returnGeometry:e.returnGeometry,filter:e.filter,requiredFields:r,signal:e.signal},t)))}async _summaryStatsFromClientQuery(e,t){const{view:r,signal:a}=e,i=L(this,e,t),s=await this._fetchFeatureSetFromMemory(i,r,a),o=E(s,V(t)||y(t));return B(o,e.outStatisticTypes)}async _getNormalizationTotalFromMemory(e,t,a){const{featuresJSON:i,graphics:s,layerView:o,query:n}=t,l={include:["sum"]},u=(!i&&!s&&o&&"querySummaryStatistics"in o?await o.querySummaryStatistics(n,{field:e},{signal:a}):i?await this.workerClient.summaryStatistics({field:e,outStatisticTypes:l},i):await d({attribute:{field:e,outStatisticTypes:l},features:s??[]})).sum;if(null==u)throw new r(`${this.adapterName}:invalid`,"invalid normalizationTotal");return u}async _summaryStatsFromMemory(e,t){const{view:r,field:a,valueExpression:i,normalizationType:s,signal:o}=e,n={field:a,valueExpression:i,normalizationType:s,normalizationField:e.normalizationField,normalizationTotal:e.normalizationTotal,minValue:e.minValue,maxValue:e.maxValue,outStatisticTypes:e.outStatisticTypes},{featuresJSON:l,graphics:u,layerView:m,query:y,fieldInfos:c}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"querySummaryStatistics"});return i&&r&&(l||u)&&(n.fieldType=t?.type?p.toJSON(t.type):null,n.viewInfoParams=C(r),n.timeZone=r.timeZone,n.fieldInfos=c),"percent-of-total"===s&&null==e.normalizationTotal&&(n.normalizationTotal=await this._getNormalizationTotalFromMemory(a,{featuresJSON:l,graphics:u,layerView:m,query:y},o)),!l&&!u&&m&&"querySummaryStatistics"in m?m.querySummaryStatistics(y,n,{signal:o}):l?this.workerClient.summaryStatistics(n,l):d({attribute:n,features:u})}async _getFilteredFeatures(e,t){let r=[];if("intersects"===t?.spatialRelationship){const{intersect:a}=await import("../../../geometry/geometryEngineAsync.js"),i=null!=t.geometry?t.geometry:null;for(const t of e){const e=null!=t.geometry?t.geometry:null;if(e&&i){await a(e,i)&&r.push(t)}}}else r=e;return e.length&&"declaredClass"in e[0]&&"esri.Graphic"===e[0].declaredClass?{graphics:r}:{featuresJSON:r}}async _processStatsFromMemoryParams(e){const{features:t,filter:r}=e;if(t?.length)return this._getFilteredFeatures(t,r);const{view:a,field:i,field2:s,field3:o,normalizationField:n,valueExpression:l,layerViewFunc:u,signal:m}=e;let p=e.returnGeometry;if(null==p&&l){if(!G){const{arcadeUtils:e}=await A();G=e}const e=G.hasGeometryOperations(l);e&&await G.enableGeometryOperations(),p=e}let y=null,c=null,f=null,d=null,h=null;if(a)try{const e="subtype-sublayer"===this.layer.type?this.layer.parent:this.layer;y=await a.whenLayerView(e),c=null!=u&&u in y&&"function"==typeof y[u]}catch{c=!1}if(c)try{await this._waitForLayerViewUpdate(y);const e=await q({field:i,field2:s,field3:o,normalizationField:n,valueExpression:l});j(this,e,y).length?c=!1:(f=this.layer.createQuery(),f.outFields=e,f.returnGeometry=!1,b(f,r)),y.suspended&&(c=!1)}catch{c=!1}return c||(d=await this._fetchFeaturesForStats({field:i,field2:s,field3:o,valueExpression:l,normalizationField:n,returnGeometry:p,filter:r,view:a,signal:m},"json"),h=(await q({valueExpression:l})).map((e=>this.getField(e)?.toJSON())).filter(Boolean)),{layerView:y,query:f,featuresJSON:d,fieldInfos:h}}async _uvFromClientQuery(e,t){const{view:r,signal:a}=e,i=k(this,e),s=await this._fetchFeatureSetFromMemory(i,r,a),o=await I(s,{layer:this,field:e.field,field2:e.field2,field3:e.field3,fieldDelimiter:x,view:e.view,signal:e.signal});return P(o,t,e.returnAllCodedValues,x)}async _uvFromMemory(e,t){const{view:r,field:a,valueExpression:i,returnAllCodedValues:s,signal:o}=e,{featuresJSON:n,graphics:l,layerView:u,query:m,fieldInfos:p}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"queryUniqueValues"}),y={field:a,field2:e.field2,field3:e.field3,fieldDelimiter:x,valueExpression:i,domains:t,returnAllCodedValues:s};return i&&r&&(n||l)&&(y.viewInfoParams=C(r),y.timeZone=r.timeZone,y.fieldInfos=p),!n&&!l&&u&&"queryUniqueValues"in u?u.queryUniqueValues(m,y,{signal:o}):n?this.workerClient.uniqueValues(y,n):h({attribute:y,features:l})}_histogramForField(e){let t=null;return t=null!=e.minValue&&null!=e.maxValue?Promise.resolve({min:e.minValue,max:e.maxValue}):this.summaryStatistics({...e,outStatisticTypes:{include:["min","max","count"]}}).then((e=>{if(!e.count)throw new r(`${this.adapterName}:insufficient-data`,"Either the layer has no features or none of the features have data for the field");return{min:e.min,max:e.max}})),t.then((t=>O(this,{min:t.min,max:t.max},e.field,e.numBins??void 0,e.view,e.filter,e.signal)))}async _histogramFromQueryAttributeBinsFromMemory(e){const{field:t,normalizationType:r,signal:a}=e,i=await this._processStatsFromMemoryParams({...e,layerViewFunc:"queryAttributeBins"}),{featuresJSON:s,graphics:o,layerView:n,query:l}=i,u="percent-of-total"===r?e.normalizationTotal??await this._getNormalizationTotalFromMemory(t,i,a):void 0;if(!n||!("queryAttributeBins"in n)||s||o){const t=z(e,i,u);return s?this.workerClient.histogram(t,s):w({attribute:t,features:o})}const{query:m,min:p,max:y}=await T(e,this,u,l?.where);if(!m)return{bins:[],minValue:p,maxValue:y,normalizationTotal:u};const c=await n.queryAttributeBins(m,{signal:a});return N(c,t?this.getField(t):null,{minValue:p,maxValue:y,normalizationTotal:u})}async _histogramFromMemory(e){const{field:t,signal:r}=e,a=await this._processStatsFromMemoryParams({...e,layerViewFunc:"queryHistogram"}),{featuresJSON:i,graphics:s,layerView:o,query:n}=a,l="percent-of-total"===e.normalizationType?e.normalizationTotal??await this._getNormalizationTotalFromMemory(t,a,r):void 0,u=z(e,a,l);return!i&&!s&&o&&"queryHistogram"in o?o.queryHistogram(n,u,{signal:r}):i?this.workerClient.histogram(u,i):w({attribute:u,features:s})}_classBreaksFromInterpolation(e){const{minValue:t,maxValue:r}=e,a=e.numClasses||$,i=[],s=(r-t)/a;for(let l=0;l<a;l++){const e=t+l*s;i.push({minValue:e,maxValue:e+s})}i[a-1].maxValue=r;const o={classBreaks:i,normalizationTotal:e.normalizationTotal},n=U(o,e.classificationMethod);return Promise.resolve(n)}async _classBreaksFromMemory(e){const{view:t,field:r,valueExpression:a,signal:i}=e,{featuresJSON:s,graphics:o,layerView:n,query:l,fieldInfos:u}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"queryClassBreaks"}),m={field:r,valueExpression:a,normalizationType:e.normalizationType,normalizationField:e.normalizationField,normalizationTotal:e.normalizationTotal,minValue:e.minValue,maxValue:e.maxValue,standardDeviationInterval:e.standardDeviationInterval,classificationMethod:e.classificationMethod,numClasses:e.numClasses};return a&&t&&(s||o)&&(m.viewInfoParams=C(t),m.timeZone=t.timeZone,m.fieldInfos=u),"percent-of-total"===e.normalizationType&&null==e.normalizationTotal&&(m.normalizationTotal=await this._getNormalizationTotalFromMemory(r,{featuresJSON:s,graphics:o,layerView:n,query:l},i)),!s&&!o&&n&&"queryClassBreaks"in n?n.queryClassBreaks(l,m,{signal:i}):s?this.workerClient.classBreaks(m,s):g({attribute:m,features:o})}async _heatmapStatsFromMemory(e){const{view:t,field:r,radius:a,signal:s}=e;i(t,"InMemoryLayerAdapter: must have a view");try{const r=await t.whenLayerView(this.layer);if("queryHeatmapStatistics"in r&&!r.updating&&!e.filter)return await r.queryHeatmapStatistics({field:e.field,radius:e.radius})}catch{o(s)}const{featuresJSON:n,graphics:l}=await this._processStatsFromMemoryParams({...e,returnGeometry:!0}),u=new c({extent:t.extent,tolerance:"2d"===t.type?t.state.resolution:t.pixelSizeAt?.(t.center)}),p={field:r,radius:a,transform:m(u),spatialReference:t.spatialReference?.toJSON(),size:t.size};return n?.length||l?.length?n?this.workerClient.heatmapStatistics(p,n):F({attribute:p,features:l}):{min:null,max:null}}getField(e=""){return this.layer.getField(e)}getFieldUsageInfo(e){return this.getField(e)?{supportsLabelingInfo:!0,supportsRenderer:!0,supportsPopupTemplate:!0,supportsLayerQuery:!0,supportsStatistics:!0}:null}getFieldDomain(e,t){return this.layer.getFieldDomain(e,t)}createQuery(){return this.layer.createQuery()}async summaryStatistics(e){const{field:t,valueExpression:a,sqlExpression:i,features:s,view:o}=e,n=t?this.getField(t):null,l=!!a,u="3d"===o?.type;if(!a&&i&&!this.supportsSQLExpression)throw new r(`${this.adapterName}:not-supported`,"Layer does not support standardized SQL expression for queries");return l||s||u?this._summaryStatsFromMemory(e,n):this._summaryStatsFromClientQuery(e,n)}async uniqueValues(e){const{valueExpression:t,sqlExpression:a,features:i,view:s}=e,o=await Q(e,this),n=!!t,l="3d"===s?.type;if(!t&&a&&!this.supportsSQLExpression)throw new r(`${this.adapterName}:not-supported`,"Layer does not support standardized SQL expression for queries");return n||i||l?this._uvFromMemory(e,o):this._uvFromClientQuery(e,o)}async histogram(e){const{features:t,valueExpression:a,normalizationType:i,sqlExpression:s}=e,o=t||!!a;if(!a&&s&&!this.supportsSQLExpression)throw new r(`${this.adapterName}:not-supported`,"Layer does not support standardized SQL expression for queries");return o||i?this._histogramFromMemory(e):this._histogramForField(e)}async classBreaks(e){return!1!==e.analyzeData?this._classBreaksFromMemory(e):this._classBreaksFromInterpolation(e)}async queryFeatureCount(e){const{whereClause:t,view:a,signal:i}=e;if(!a)throw new r(`${this.adapterName}:insufficient-data`,"view is required to fetch the features from layerView");const s=this.layer.createQuery();s.where=S(s.where,t);const o=await a.whenLayerView(this.layer);return await n((()=>!o.updating),i),o.queryFeatureCount(s,{signal:i})}async generateRenderer(e,t){throw new r(`${this.adapterName}:not-supported`,"Layer does not support generateRenderer operation")}async predominantCategories(e){const{fields:t,view:r,signal:a,filter:i}=e,s=f(t),o=await this._uvFromMemory({valueExpression:s,view:r,signal:a,filter:i});return J(o.uniqueValueInfos,t)}async heatmapStatistics(e){return this._heatmapStatsFromMemory(e)}async getSampleFeatures(e,a){const{view:i,sampleSize:s,requiredFields:o,returnGeometry:n,filter:l,signal:u}=e,m=this.layer.createQuery(),p=1;if(m.outSpatialReference=i?.spatialReference,m.returnGeometry=!!n,m.outFields=o,b(m,l),!i)throw new r(`${this.adapterName}:not-supported`,"view is required to get sample features for Layer");const y=await i.whenLayerView(this.layer);if(j(this,o,y).length)throw new r(`${this.adapterName}:not-supported`,"Required fields need to be passed in the outFields for Layer");const c=await this._fetchFeaturesFromMemory(y,m,u,a),f=null!=s&&s>0&&s<=c.length?s:c.length;return t(c,f,p)}load(e){const t=this.layer.load(e).then((async t=>{this.geometryType=t.geometryType,this.objectIdField=t.objectIdField,this.supportsSQLExpression="stream"===t.type||!!t.capabilities?.query?.supportsSqlExpression,this.minScale=t.minScale,this.maxScale=t.maxScale,this.fullExtent="fullExtent"in t?t.fullExtent:t.parent?.fullExtent,this._hasLocalSource=!1,this.hasQueryEngine=!0,this.workerClient=v.getInstance(),await this.workerClient.open(e.signal)}));return this.addResolvingPromise(t),Promise.resolve(this)}};e([l({readOnly:!0})],R.prototype,"adapterName",void 0),e([l({constructOnly:!0})],R.prototype,"layer",void 0),R=e([u("esri.smartMapping.support.adapters.InMemoryLayerAdapter")],R);const D=R;export{D 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.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import{resolveTimeZone as i}from"../../../../intl/date.js";import{isTimeOnlyField as n,isDateField as t,isTimestampOffsetField as a,isDateOnlyField as r}from"../../../../layers/support/fieldUtils.js";import o from"../../../../rest/support/AttributeBinsQuery.js";import l from"../../../../rest/support/AutoIntervalBinParameters.js";import s from"../../../../rest/support/DateBinParameters.js";import u from"../../../../rest/support/FixedBoundariesBinParameters.js";import m from"../../../../rest/support/FixedIntervalBinParameters.js";import d from"../../../../rest/support/GenerateRendererParameters.js";import p from"../../../../rest/support/StatisticDefinition.js";import{getSQLFilterForNormalization as f,mergeWhereClauses as c,getRangeExpr as y}from"../../../statistics/support/utils.js";import{isAnyDateField as z}from"../../utils.js";import{getSQLExpressionForDateOrTimeField as x,getFieldExpr as v,defaultNumBins as w,generateBinParams as T,updateQueryWithFeatureFilter as h}from"./utils.js";import{createClassBreaksDefinition as F}from"../../../../statistics/utils.js";const B="countOFExpr",j="lowerBoundary",q="upperBoundary";function V(e,i,t){const a=e.valueExpression||e.sqlExpression,r=e.signal;if(!a){const{field:a,normalizationType:o,normalizationField:l}=e,s=a?i.getField(a):null,u=z(s)||n(s),m={field:a,normalizationType:o,normalizationField:l,normalizationTotal:t,layer:i};return{sqlExpression:u?x(i,s):v(m),sqlWhere:u?null:e.sqlWhere||f({field:a,normalizationType:o,normalizationField:l}),filter:e.filter,signal:r}}return{valueExpression:e.valueExpression,sqlExpression:e.sqlExpression,sqlWhere:e.sqlWhere,filter:e.filter,signal:r}}async function g(e,i,n){const{field:t,normalizationType:a,normalizationField:r,signal:o}=e,l=f({field:t,normalizationType:a,normalizationField:r}),s=new d({classificationDefinition:F({field:t,normalizationType:a,normalizationField:r,classificationMethod:e.classificationMethod,standardDeviationInterval:e.standardDeviationInterval,definedInterval:e.definedInterval,breakCount:e.numBins||w}),where:c(l,n)});return i.generateRenderer(s,o).then((e=>{const{normalizationTotal:n,classBreaks:o}=e;return T({field:t,normalizationType:a,normalizationField:r,normalizationTotal:n,classBreaks:o,where:l,layer:i})}))}async function M(i,t,a,o,d){const{field:p,sqlExpression:f,normalizationField:c,classificationMethod:z,normalizationType:x}=i,T=p?t.getField(p):null,h=n(T),F=r(T)||h,B=i.numBins||w;if(F){if(x||z)throw new e(`${t.adapterName}:not-supported`,"NormalizationType and classificationMethod are not supported for date-only and time-only fields");const i=(o-a)/B/1e3,n=i/86400;return new s({field:p,expression:f,interval:{unit:h?"seconds":"days",value:Math.ceil(h?i:n)},start:a,end:o})}if("defined-interval"===z)return new m({field:p,expression:f,normalizationField:c,normalizationTotal:d,normalizationType:x,interval:i.definedInterval??Math.ceil((o-a)/B),start:x?null:a,end:x?null:o,normalizationMinValue:x?a:null,normalizationMaxValue:x?o:null});if("manual"===z)throw new e(`${t.adapterName}:not-supported`,"Layer does not support manual classificationMethod");if("natural-breaks"===z||"quantile"===z||"standard-deviation"===z){const n=v({field:p,normalizationField:c,normalizationTotal:d,normalizationType:x,layer:t}),r=null!==i.minValue&&null!==i.maxValue?y(n,i.minValue,i.maxValue):void 0,o=await g(i,t,r);if(!o.intervals)throw new e(`${t.adapterName}:invalid`,"Invalid intervals returned from generate renderer");const l=[a,...o.intervals.map((e=>e[1]))];return new u({field:x?null:p,expression:x?n:f,boundaries:l})}return new l({field:p,normalizationField:c,normalizationTotal:d,normalizationType:x,expression:f,numBins:B,start:x?null:a,end:x?null:o,normalizationMinValue:x?a:null,normalizationMaxValue:x?o:null})}function b(e,i,n,t){return null!=n&&null!=t?Promise.resolve({min:n,max:t}):i.summaryStatistics({...e,outStatisticTypes:{include:["min","max"]}}).then((e=>({min:e.min,max:e.max})))}async function E(e,n,r,l){const{field:s,minValue:u,maxValue:m,filter:d,view:f}=e,y=s?n.getField(s):null,z=t(y)||a(y),x=V(e,n,r),{min:v,max:w}=await b(x,n,u,m);if(null==v||null==w)return{query:null,min:v,max:w};const T=new p({statisticType:"count",outStatisticFieldName:B,onStatisticField:"1"}),F=c(l,x.sqlWhere),j="lowerBoundary",q="upperBoundary",g=new o({binParameters:await M(e,n,v,w,r),outStatistics:[T],binOrder:e.sortOrder,where:F,lowerBoundaryAlias:j,upperBoundaryAlias:q,outTimeZone:f?.timeZone&&z?i(f.timeZone):null});return h(g,d),{query:g,min:v,max:w}}function I(e,i=!1){if("string"!=typeof e)return e;return(i?new Date(`1970-01-01T${e}Z`):new Date(e)).getTime()}function D(e,i,t){const a=n(i);return{...t,bins:e.features.map((e=>({minValue:I(e.attributes[j],a),maxValue:I(e.attributes[q],a),count:e.attributes[B]})))}}export{g as binParamsFromGenRend,I as formatHistogramBinValue,E as getAttributeBinsQuery,b as getDataRange,V as getQueryParamsForExpr,D as processQueryAttributeBinsResult};
5
+ import i from"../../../../core/Error.js";import{resolveTimeZone as e}from"../../../../intl/date.js";import{isTimeOnlyField as n,isDateField as t,isTimestampOffsetField as a,isDateOnlyField as r}from"../../../../layers/support/fieldUtils.js";import o from"../../../../rest/support/AttributeBinsQuery.js";import l from"../../../../rest/support/AutoIntervalBinParameters.js";import s from"../../../../rest/support/DateBinParameters.js";import u from"../../../../rest/support/FixedBoundariesBinParameters.js";import m from"../../../../rest/support/FixedIntervalBinParameters.js";import d from"../../../../rest/support/GenerateRendererParameters.js";import p from"../../../../rest/support/StatisticDefinition.js";import{getSQLFilterForNormalization as f,mergeWhereClauses as c,getRangeExpr as y}from"../../../statistics/support/utils.js";import{isAnyDateField as z}from"../../utils.js";import{getSQLExpressionForDateOrTimeField as v,getFieldExpr as x,defaultNumBins as w,generateBinParams as T,updateQueryWithFeatureFilter as h,getViewInfoParams as F}from"./utils.js";import{createClassBreaksDefinition as B}from"../../../../statistics/utils.js";const V="countOFExpr",j="lowerBoundary",q="upperBoundary";function I(i,e,t){const a=i.valueExpression||i.sqlExpression,r=i.signal;if(!a){const{field:a,normalizationType:o,normalizationField:l}=i,s=a?e.getField(a):null,u=z(s)||n(s),m={field:a,normalizationType:o,normalizationField:l,normalizationTotal:t,layer:e};return{sqlExpression:u?v(e,s):x(m),sqlWhere:u?null:i.sqlWhere||f({field:a,normalizationType:o,normalizationField:l}),filter:i.filter,signal:r}}return{valueExpression:i.valueExpression,sqlExpression:i.sqlExpression,sqlWhere:i.sqlWhere,filter:i.filter,signal:r}}async function M(i,e,n){const{field:t,normalizationType:a,normalizationField:r,signal:o}=i,l=f({field:t,normalizationType:a,normalizationField:r}),s=new d({classificationDefinition:B({field:t,normalizationType:a,normalizationField:r,classificationMethod:i.classificationMethod,standardDeviationInterval:i.standardDeviationInterval,definedInterval:i.definedInterval,breakCount:i.numBins||w}),where:c(l,n)});return e.generateRenderer(s,o).then((i=>{const{normalizationTotal:n,classBreaks:o}=i;return T({field:t,normalizationType:a,normalizationField:r,normalizationTotal:n,classBreaks:o,where:l,layer:e})}))}async function g(e,t,a,o,d){const{field:p,sqlExpression:f,normalizationField:c,classificationMethod:z,normalizationType:v}=e,T=p?t.getField(p):null,h=n(T),F=r(T)||h,B=e.numBins||w;if(F){if(v||z)throw new i(`${t.adapterName}:not-supported`,"NormalizationType and classificationMethod are not supported for date-only and time-only fields");const e=(o-a)/B/1e3,n=e/86400;return new s({field:p,expression:f,interval:{unit:h?"seconds":"days",value:Math.ceil(h?e:n)},start:a,end:o})}if("defined-interval"===z)return new m({field:p,expression:f,normalizationField:c,normalizationTotal:d,normalizationType:v,interval:e.definedInterval??Math.ceil((o-a)/B),start:v?null:a,end:v?null:o,normalizationMinValue:v?a:null,normalizationMaxValue:v?o:null});if("manual"===z)throw new i(`${t.adapterName}:not-supported`,"Layer does not support manual classificationMethod");if("natural-breaks"===z||"quantile"===z||"standard-deviation"===z){const n=x({field:p,normalizationField:c,normalizationTotal:d,normalizationType:v,layer:t}),r=null!==e.minValue&&null!==e.maxValue?y(n,e.minValue,e.maxValue):void 0,o=await M(e,t,r);if(!o.intervals)throw new i(`${t.adapterName}:invalid`,"Invalid intervals returned from generate renderer");const l=[a,...o.intervals.map((i=>i[1]))];return new u({field:v?null:p,expression:v?n:f,boundaries:l})}return new l({field:p,normalizationField:c,normalizationTotal:d,normalizationType:v,expression:f,numBins:B,start:v?null:a,end:v?null:o,normalizationMinValue:v?a:null,normalizationMaxValue:v?o:null})}function E(i,e,n,t){return null!=n&&null!=t?Promise.resolve({min:n,max:t}):e.summaryStatistics({...i,outStatisticTypes:{include:["min","max"]}}).then((i=>({min:i.min,max:i.max})))}async function b(i,n,r,l){const{field:s,minValue:u,maxValue:m,filter:d,view:f}=i,y=s?n.getField(s):null,z=t(y)||a(y),v=I(i,n,r),{min:x,max:w}=await E(v,n,u,m);if(null==x||null==w)return{query:null,min:x,max:w};const T=new p({statisticType:"count",outStatisticFieldName:V,onStatisticField:"1"}),F=c(l,v.sqlWhere),B="lowerBoundary",j="upperBoundary",q=new o({binParameters:await g(i,n,x,w,r),outStatistics:[T],binOrder:i.sortOrder,where:F,lowerBoundaryAlias:B,upperBoundaryAlias:j,outTimeZone:f?.timeZone&&z?e(f.timeZone):null});return h(q,d),{query:q,min:x,max:w}}function D(i,e=!1){if("string"!=typeof i)return i;return(e?new Date(`1970-01-01T${i}Z`):new Date(i)).getTime()}function P(i,e,t){const a=n(e);return{...t,bins:i.features.map((i=>({minValue:D(i.attributes[j],a),maxValue:D(i.attributes[q],a),count:i.attributes[V]})))}}function S(i,e,n){const{valueExpression:t,view:a}=i,{featuresJSON:r,graphics:o,fieldInfos:l}=e,s={field:i.field,valueExpression:t,normalizationType:i.normalizationType,normalizationField:i.normalizationField,normalizationTotal:n,minValue:i.minValue,maxValue:i.maxValue,standardDeviationInterval:i.standardDeviationInterval,classificationMethod:i.classificationMethod,numBins:i.numBins};return t&&a&&(r||o)&&(s.viewInfoParams=F(a),s.timeZone=a.timeZone,s.fieldInfos=l),s}export{M as binParamsFromGenRend,D as formatHistogramBinValue,b as getAttributeBinsQuery,E as getDataRange,S as getHistogramAttributeDefinition,I as getQueryParamsForExpr,P as processQueryAttributeBinsResult};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../chunks/tslib.es6.js";import e from"../core/Collection.js";import{referenceSetter as r}from"../core/collectionUtils.js";import s from"../core/Logger.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";function a(t,e,r){if(t)for(let s=0,o=t.length;s<o;s++){const o=t.at(s);if(o[e]===r)return o;if("group"===o?.type){const t=a(o.tables,e,r);if(t)return t}}}const n=n=>{let l=class extends n{constructor(...t){super(...t),this.tables=new e,this.addHandles([this.tables.on("after-add",(t=>{const e=t.item;e.parent&&e.parent!==this&&"tables"in e.parent&&e.parent.tables.remove(e),e.parent=this,"feature"!==e.type&&s.getLogger(this).error(`Layer 'title:${e.title}, id:${e.id}' of type '${e.type}' is not supported as a table and will therefore be ignored.`)})),this.tables.on("after-remove",(t=>{t.item.parent=null}))])}destroy(){const t=this.tables.toArray();for(const e of t)e.destroy();this.tables.destroy()}set tables(t){this._set("tables",r(t,this._get("tables")))}findTableById(t){return a(this.tables,"id",t)}findTableByUid(t){return a(this.tables,"uid",t)}};return t([o()],l.prototype,"tables",null),l=t([i("esri.support.TablesMixin")],l),l};export{n as TablesMixin};
5
+ import{_ as t}from"../chunks/tslib.es6.js";import e from"../core/Collection.js";import{referenceSetter as r}from"../core/collectionUtils.js";import s from"../core/Logger.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";const a=new Set(["feature","subtype-group"]);function n(t,e,r){if(t)for(let s=0,o=t.length;s<o;s++){const o=t.at(s);if(o[e]===r)return o;if("group"===o?.type){const t=n(o.tables,e,r);if(t)return t}}}const l=l=>{let p=class extends l{constructor(...t){super(...t),this.tables=new e,this.addHandles([this.tables.on("after-add",(t=>{const e=t.item;e.parent&&e.parent!==this&&"tables"in e.parent&&e.parent.tables.remove(e),e.parent=this,a.has(e.type)||s.getLogger(this).error(`Layer 'title:${e.title}, id:${e.id}' of type '${e.type}' is not supported as a table and will therefore be ignored.`)})),this.tables.on("after-remove",(t=>{t.item.parent=null}))])}destroy(){const t=this.tables.toArray();for(const e of t)e.destroy();this.tables.destroy()}set tables(t){this._set("tables",r(t,this._get("tables")))}findTableById(t){return n(this.tables,"id",t)}findTableByUid(t){return n(this.tables,"uid",t)}};return t([o()],p.prototype,"tables",null),p=t([i("esri.support.TablesMixin")],p),p};export{l as TablesMixin};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{p as e,c as n,e as r,a as t,r as o,l,b as a,d as i,f as u,s,g as c}from"../chunks/arcade.js";export{h as arcade}from"../chunks/arcade.js";import{ArcadeDate as f}from"../arcade/ArcadeDate.js";import p from"../arcade/Dictionary.js";import m from"../arcade/Feature.js";import{m as d,g as y,n as v,p as g,o as x}from"../chunks/languageUtils.js";export{Voxel}from"../arcade/Voxel.js";import{clone as j}from"../core/lang.js";import{DateOnly as S}from"../core/sql/DateOnly.js";import{TimeOnly as w}from"../core/sql/TimeOnly.js";import E from"../geometry/Extent.js";import A from"../geometry/Multipoint.js";import b from"../geometry/Point.js";import F from"../geometry/Polygon.js";import $ from"../geometry/Polyline.js";import{isArray as P,isString as R,isBoolean as C,isNumber as D}from"./guards.js";const T=/^\$(feature|aggregatedFeatures)\./i,z={vars:{$feature:"any",$view:"any"},spatialReference:null};function I(e){return e.replaceAll(/[|\\{}()[\]^$+*?.]/g,"\\$&")}function M(e){return null==e?null:P(e)||d(e)?"array":y(e)?"date":R(e)?"text":C(e)?"boolean":D(e)?"number":e instanceof p?"dictionary":v(e)?"feature":e instanceof b?"point":e instanceof F?"polygon":e instanceof $?"polyline":e instanceof A?"multipoint":e instanceof E?"extent":e instanceof S?"dateOnly":e instanceof w?"time":g(e)?"featureSet":x(e)?"featureSetCollection":null}function k(n){if(!n)return null;try{return e(n)}catch(r){}return null}function J(e,r){const t="string"==typeof e?k(e):e;if(!t)return null;try{return r=r||j(z),n(t,r)}catch(o){}return null}function V(e,n,r){return{vars:{$feature:null==e?new m:m.createFromGraphic(e,r),$view:n?.view},spatialReference:n?.sr,timeZone:r??null}}function O(e,n,r){return m.createFromGraphicLikeObject(n,e,r,null)}function Z(e,n){null!=e.vars&&(e.vars.$feature=n)}function q(e,n){let t;try{t=r(e,n)}catch(o){t=null}return t}function G(e,n){let r;try{r=e?e(n):null}catch(t){r=null}return r}function L(e,n){try{return e?e(n):Promise.resolve(null)}catch(r){return Promise.resolve(null)}}function U(e,n){if(!e)return[];const r="string"==typeof e?k(e):e;if(!r)return[];const o=t(r);let l=new Array;o.forEach((e=>{T.test(e)&&(e=e.replace(T,""),l.push(e))}));const a=l.filter((e=>e.includes("*")));return l=l.filter((e=>!a.includes(e))),n&&a.forEach((e=>{const r=new RegExp(`^${e.split(/\*+/).map(I).join(".*")}$`,"i");n.forEach((e=>r.test(e)?l.push(e):null))})),[...new Set(l.sort())]}function B(e){return o(e,"$view")}function H(e,n){return!!e&&o(e,n)}function K(e){if(!e||null==e.spatialReference&&(null==e.scale||null==e.viewingMode))return;let n,r;const{timeProperties:t,timeZone:o}=e;if(null!=t){const{currentStart:e,currentEnd:l}=t;null!=o?(n=null!=e?f.dateJSAndZoneToArcadeDate(e,o):null,r=null!=l?f.dateJSAndZoneToArcadeDate(l,o):null):(n=null!=e?f.dateJSToArcadeDate(e):null,r=null!=l?f.dateJSToArcadeDate(l):null)}return{view:e.viewingMode&&null!=e.scale?new p({viewingMode:e.viewingMode,scale:e.scale,timeProperties:null!=n||null!=r?new p({currentStart:n,currentEnd:r,startIncluded:!0,endIncluded:!0}):null}):null,sr:e.spatialReference}}function N({url:e,spatialReference:n,lrucache:r,interceptor:t}){const o=u();return o?o.createFeatureSetCollectionFromService(e,n,r,t):null}function Q({layer:e,spatialReference:n,outFields:r,returnGeometry:t,lrucache:o,interceptor:l}){if(null===e)return null;const a=u();return a?a.constructFeatureSet(e,n,r,t??!0,o,l):null}function W(e){if(null===e?.map)return null;const n=u();return n?n.createFeatureSetCollectionFromMap(e.map,e.spatialReference,e.lrucache,e.interceptor):null}function X(e,n){return p.convertJsonToArcade(e,n)}function Y(e,n,r=[]){return l(e,n,r)}function _(){return a()}function ee(){return i()}function ne(e){return"type"in e&&("class-breaks"===e.type||"dictionary"===e.type||"dot-density"===e.type||"pie-chart"===e.type||"simple"===e.type||"unique-value"===e.type)}function re(e){return"esri.layers.support.LabelClass"===e.declaredClass}function te(e){return"esri.PopupTemplate"===e.declaredClass}function oe(e,n){if(!e)return!1;if("string"==typeof e)return n(e);const r=e;if(ne(r)){if("dot-density"===r.type){const e=r.attributes?.some((e=>n(e.valueExpression)));if(e)return e}const e=r.visualVariables,t=!!e&&e.some((e=>{let r=n(e.valueExpression);return"size"===e.type&&(se(e.minSize)&&(r=r||n(e.minSize.valueExpression)),se(e.maxSize)&&(r=r||n(e.maxSize.valueExpression))),r}));return!(!("valueExpression"in r)||!n(r.valueExpression))||t}if(re(r)){const e=r.labelExpressionInfo?.expression;return!(!e||!n(e))||!1}return!!te(r)&&(!!r.expressionInfos&&r.expressionInfos.some((e=>n(e.expression)))||Array.isArray(r.content)&&r.content.some((e=>"expression"===e.type&&n(e.expressionInfo?.expression))))}function le(e){const n=k(e);return!!n&&s(n)}function ae(e){return oe(e,le)}function ie(e){const n=k(e);return!!n&&c(n)}function ue(e){return oe(e,ie)}function se(e){return e&&"esri.renderers.visualVariables.SizeVariable"===e.declaredClass}export{p as Dictionary,m as arcadeFeature,Q as convertFeatureLayerToFeatureSet,X as convertJsonToArcade,W as convertMapToFeatureSetCollection,N as convertServiceUrlToWorkspace,V as createExecContext,O as createFeature,J as createFunction,k as createSyntaxTree,B as dependsOnView,ee as enableFeatureSetOperations,_ as enableGeometryOperations,q as evalSyntaxTree,L as executeAsyncFunction,G as executeFunction,U as extractFieldNames,M as getArcadeType,K as getViewInfo,ae as hasGeometryFunctions,ue as hasGeometryOperations,H as hasVariable,Y as loadScriptDependencies,Z as updateExecContext};
5
+ import{p as e,c as n,e as r,a as t,r as o,l as a,b as i,d as l,f as u,s,g as c}from"../chunks/arcade.js";export{h as arcade}from"../chunks/arcade.js";import{ArcadeDate as f}from"../arcade/ArcadeDate.js";import{toSymbolId as p}from"../arcade/arcadeEnvironment.js";import m from"../arcade/Dictionary.js";import d from"../arcade/Feature.js";import{m as y,g as v,n as x,p as g,o as j}from"../chunks/languageUtils.js";export{Voxel}from"../arcade/Voxel.js";import{clone as S}from"../core/lang.js";import{DateOnly as w}from"../core/sql/DateOnly.js";import{TimeOnly as $}from"../core/sql/TimeOnly.js";import b from"../geometry/Extent.js";import E from"../geometry/Multipoint.js";import A from"../geometry/Point.js";import F from"../geometry/Polygon.js";import P from"../geometry/Polyline.js";import{isArray as C,isString as R,isBoolean as D,isNumber as I}from"./guards.js";const M={vars:{$feature:"any",$view:"any"},spatialReference:null};function T(e){return e.replaceAll(/[|\\{}()[\]^$+*?.]/g,"\\$&")}function z(e){return null==e?null:C(e)||y(e)?"array":v(e)?"date":R(e)?"text":D(e)?"boolean":I(e)?"number":e instanceof m?"dictionary":x(e)?"feature":e instanceof A?"point":e instanceof F?"polygon":e instanceof P?"polyline":e instanceof E?"multipoint":e instanceof b?"extent":e instanceof w?"dateOnly":e instanceof $?"time":g(e)?"featureSet":j(e)?"featureSetCollection":null}function k(n){if(!n)return null;try{return e(n)}catch(r){}return null}function J(e,r){const t="string"==typeof e?k(e):e;if(!t)return null;try{return r=r||S(M),n(t,r)}catch(o){}return null}function V(e,n,r){return{vars:{$feature:null==e?new d:d.createFromGraphic(e,r),$view:n?.view},spatialReference:n?.sr,timeZone:r??null}}function O(e,n,r){return d.createFromGraphicLikeObject(n,e,r,null)}function Z(e,n){null!=e.vars&&(e.vars.$feature=n)}function q(e,n){let t;try{t=r(e,n)}catch(o){t=null}return t}function G(e,n){let r;try{r=e?e(n):null}catch(t){r=null}return r}function L(e,n){try{return e?e(n):Promise.resolve(null)}catch(r){return Promise.resolve(null)}}const N=new Set(["$feature","$aggregatedFeatures","$voxel"].map((e=>p(e))));function U(e,n){if(!e)return[];const r="string"==typeof e?k(e):e;if(!r)return[];const o=t(r).filter((({varId:e})=>N.has(e))).map((({memberNamePattern:e})=>e)).flatMap((e=>{if(e.includes("*")){if(null==n)return[];const r=new RegExp(`^${e.split(/\*+/).map(T).join(".*")}$`,"i");return n.filter((e=>r.test(e)))}return e.toLowerCase()}));return[...new Set(o.sort())]}function B(e){return o(e,"$view")}function H(e,n){return!!e&&o(e,n)}function K(e){if(!e||null==e.spatialReference&&(null==e.scale||null==e.viewingMode))return;let n,r;const{timeProperties:t,timeZone:o}=e;if(null!=t){const{currentStart:e,currentEnd:a}=t;null!=o?(n=null!=e?f.dateJSAndZoneToArcadeDate(e,o):null,r=null!=a?f.dateJSAndZoneToArcadeDate(a,o):null):(n=null!=e?f.dateJSToArcadeDate(e):null,r=null!=a?f.dateJSToArcadeDate(a):null)}return{view:e.viewingMode&&null!=e.scale?new m({viewingMode:e.viewingMode,scale:e.scale,timeProperties:null!=n||null!=r?new m({currentStart:n,currentEnd:r,startIncluded:!0,endIncluded:!0}):null}):null,sr:e.spatialReference}}function Q({url:e,spatialReference:n,lrucache:r,interceptor:t}){const o=u();return o?o.createFeatureSetCollectionFromService(e,n,r,t):null}function W({layer:e,spatialReference:n,outFields:r,returnGeometry:t,lrucache:o,interceptor:a}){if(null===e)return null;const i=u();return i?i.constructFeatureSet(e,n,r,t??!0,o,a):null}function X(e){if(null===e?.map)return null;const n=u();return n?n.createFeatureSetCollectionFromMap(e.map,e.spatialReference,e.lrucache,e.interceptor):null}function Y(e,n){return m.convertJsonToArcade(e,n)}function _(e,n,r=[]){return a(e,n,r)}function ee(){return i()}function ne(){return l()}function re(e){return"type"in e&&("class-breaks"===e.type||"dictionary"===e.type||"dot-density"===e.type||"pie-chart"===e.type||"simple"===e.type||"unique-value"===e.type)}function te(e){return"esri.layers.support.LabelClass"===e.declaredClass}function oe(e){return"esri.PopupTemplate"===e.declaredClass}function ae(e,n){if(!e)return!1;if("string"==typeof e)return n(e);const r=e;if(re(r)){if("dot-density"===r.type){const e=r.attributes?.some((e=>n(e.valueExpression)));if(e)return e}const e=r.visualVariables,t=!!e&&e.some((e=>{let r=n(e.valueExpression);return"size"===e.type&&(ce(e.minSize)&&(r=r||n(e.minSize.valueExpression)),ce(e.maxSize)&&(r=r||n(e.maxSize.valueExpression))),r}));return!(!("valueExpression"in r)||!n(r.valueExpression))||t}if(te(r)){const e=r.labelExpressionInfo?.expression;return!(!e||!n(e))||!1}return!!oe(r)&&(!!r.expressionInfos&&r.expressionInfos.some((e=>n(e.expression)))||Array.isArray(r.content)&&r.content.some((e=>"expression"===e.type&&n(e.expressionInfo?.expression))))}function ie(e){const n=k(e);return!!n&&s(n)}function le(e){return ae(e,ie)}function ue(e){const n=k(e);return!!n&&c(n)}function se(e){return ae(e,ue)}function ce(e){return e&&"esri.renderers.visualVariables.SizeVariable"===e.declaredClass}export{m as Dictionary,d as arcadeFeature,W as convertFeatureLayerToFeatureSet,Y as convertJsonToArcade,X as convertMapToFeatureSetCollection,Q as convertServiceUrlToWorkspace,V as createExecContext,O as createFeature,J as createFunction,k as createSyntaxTree,B as dependsOnView,ne as enableFeatureSetOperations,ee as enableGeometryOperations,q as evalSyntaxTree,L as executeAsyncFunction,G as executeFunction,U as extractFieldNames,z as getArcadeType,K as getViewInfo,le as hasGeometryFunctions,se as hasGeometryOperations,H as hasVariable,_ as loadScriptDependencies,Z as updateExecContext};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- const c="20250205",a="8ca740ed187dfaced96f6d44fc8af03010c73a31";export{c as buildDate,a as commitHash};
5
+ const a="20250207",d="cde1f1e7b0f6faa0bfad1141e544d8d9c9a62206";export{a as buildDate,d as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"./CIMResourceManager.js";import{Transformation as t,CanvasDrawHelper as i}from"./CIMSymbolDrawHelper.js";import{CIMSymbolHelper as r}from"./CIMSymbolHelper.js";import{OverrideHelper as a}from"./OverrideHelper.js";import{mapCIMSymbolToGeometryType as s}from"./utils.js";const n=96/72;class h{constructor(t){this._spatialReference=t,this._imageDataCanvas=null,this._cimResourceManager=new e}get _canvas(){return this._imageDataCanvas||(this._imageDataCanvas=document.createElement("canvas")),this._imageDataCanvas}get resourceManager(){return this._cimResourceManager}async rasterizeCIMSymbolAsync(e,t,i,n,h,l,c,m,g){if(!e)return null;const{data:y}=e;if(!y||"CIMSymbolReference"!==y.type||!y.symbol)return null;const{symbol:d}=y;l||(l=s(d));const u=await a.resolveSymbolOverrides(y,t,this._spatialReference,h,l,c,m),w=this._cimResourceManager,p=[];r.fetchResources(u,w,p),r.fetchFonts(u,w,p),p.length>0&&await Promise.all(p);const{width:b,height:f}=i,M=o(l,b,f,n),C=r.getEnvelope(u,M,w);if(!C)return null;C.x===1/0&&(C.x=b+2),C.y===1/0&&(C.y=-f/2),C.width===-1/0&&(C.width=b),C.height===-1/0&&(C.height=f);let R=1,v=0,x=0;switch(d.type){case"CIMPointSymbol":case"CIMTextSymbol":{let e=1;C.width>b&&(e=b/C.width);let t=1;C.height>f&&(t=f/C.height),"preview"===n&&(C.width<b&&(e=b/C.width),C.height<f&&(t=f/C.height)),R=Math.min(e,t),v=C.x+C.width/2,x=C.y+C.height/2}break;case"CIMLineSymbol":{(g||C.height>f)&&(R=f/C.height),x=C.y+C.height/2;const e=C.x*R+b/2,t=(C.x+C.width)*R+b/2,{paths:i}=M;i[0][0][0]-=e/R,i[0][2][0]-=(t-b)/R}break;case"CIMPolygonSymbol":{v=C.x+C.width/2,x=C.y+C.height/2;const e=C.x*R+b/2,t=(C.x+C.width)*R+b/2,i=C.y*R+f/2,r=(C.y+C.height)*R+f/2,{rings:a}=M;e<0&&(a[0][0][0]-=e,a[0][3][0]-=e,a[0][4][0]-=e),i<0&&(a[0][0][1]+=i,a[0][1][1]+=i,a[0][4][1]+=i),t>b&&(a[0][1][0]-=t-b,a[0][2][0]-=t-b),r>f&&(a[0][2][1]+=r-f,a[0][3][1]+=r-f)}}const I={type:"cim",data:{type:"CIMSymbolReference",symbol:u}};return this.rasterize(I,b,f,v,x,R,l,1,M)}rasterize(e,r,a,h,l,c,m,g=0,y=null){const{data:d}=e;if(!d||"CIMSymbolReference"!==d.type||!d.symbol)return null;const{symbol:u}=d,w=this._canvas,p=(window.devicePixelRatio||1)*n;w.width=r*p,w.height=a*p,m||(m=s(u)),y||(y=o(m,r,a,"legend")),w.width+=2*g,w.height+=2*g;const b=w.getContext("2d",{willReadFrequently:!0}),f=t.createIdentity();f.translate(-h,-l),f.scale(c*p,-c*p),f.translate(r*p/2+g,a*p/2+g),b.clearRect(0,0,w.width,w.height);return new i(b,this._cimResourceManager,f,!0).drawSymbol(u,y),b.getImageData(0,0,w.width,w.height)}}function o(e,t,i,r){const a=1,s=-t/2+a,n=t/2-a,h=i/2-a,o=-i/2+a;switch(e){case"esriGeometryPoint":return{x:0,y:0};case"esriGeometryPolyline":return{paths:[[[s,0],[0,0],[n,0]]]};default:return"legend"===r?{rings:[[[s,h],[n,0],[n,o],[s,o],[s,h]]]}:{rings:[[[s,h],[n,h],[n,o],[s,o],[s,h]]]}}}export{h as CIMSymbolRasterizer};
5
+ import e from"./CIMResourceManager.js";import{Transformation as t,CanvasDrawHelper as i}from"./CIMSymbolDrawHelper.js";import{CIMSymbolHelper as r}from"./CIMSymbolHelper.js";import{OverrideHelper as a}from"./OverrideHelper.js";import{mapCIMSymbolToGeometryType as s}from"./utils.js";const n=96/72;class h{constructor(t){this._spatialReference=t,this._imageDataCanvas=null,this._cimResourceManager=new e}get _canvas(){return this._imageDataCanvas||(this._imageDataCanvas=document.createElement("canvas")),this._imageDataCanvas}get resourceManager(){return this._cimResourceManager}async rasterizeCIMSymbolAsync(e,t,i,n,h,l,c,m,g){if(!e)return null;const{data:y}=e;if(!y||"CIMSymbolReference"!==y.type||!y.symbol)return null;const{symbol:d}=y;l||(l=s(d));const u=await a.resolveSymbolOverrides(y,t,this._spatialReference,h,l,c,m),w=this._cimResourceManager,p=[];r.fetchResources(u,w,p),r.fetchFonts(u,w,p),p.length>0&&await Promise.all(p);const{width:b,height:f}=i,M=o(l,b,f,n),C=r.getEnvelope(u,M,w);if(!C)return null;C.x===1/0&&(C.x=b+2),C.y===1/0&&(C.y=-f/2),C.width===-1/0&&(C.width=b),C.height===-1/0&&(C.height=f);let R=1,v=0,x=0;switch(d.type){case"CIMPointSymbol":case"CIMTextSymbol":{let e=1;C.width>b&&(e=b/C.width);let t=1;C.height>f&&(t=f/C.height),"preview"===n&&(C.width<b&&(e=b/C.width),C.height<f&&(t=f/C.height)),R=Math.min(e,t),v=C.x+C.width/2,x=C.y+C.height/2}break;case"CIMLineSymbol":{(g||C.height>f)&&(R=f/C.height),x=C.y+C.height/2;const e=C.x*R+b/2,t=(C.x+C.width)*R+b/2,{paths:i}=M;i[0][0][0]-=e/R,i[0][2][0]-=(t-b)/R}break;case"CIMPolygonSymbol":{v=C.x+C.width/2,x=C.y+C.height/2;const e=C.x*R+b/2,t=(C.x+C.width)*R+b/2,i=C.y*R+f/2,r=(C.y+C.height)*R+f/2,{rings:a}=M;e<0&&(a[0][0][0]-=e,a[0][3][0]-=e,a[0][4][0]-=e),i<0&&(a[0][0][1]+=i,a[0][1][1]+=i,a[0][4][1]+=i),t>b&&(a[0][1][0]-=t-b,a[0][2][0]-=t-b),r>f&&(a[0][2][1]+=r-f,a[0][3][1]+=r-f)}}const I={type:"cim",data:{type:"CIMSymbolReference",symbol:u}};return this.rasterize(I,b,f,v,x,R,l,1,M)}rasterize(e,r,a,h,l,c,m,g=0,y=null,d=window.devicePixelRatio||1){const{data:u}=e;if(!u||"CIMSymbolReference"!==u.type||!u.symbol)return null;const{symbol:w}=u,p=this._canvas,b=d*n;p.width=r*b,p.height=a*b,m||(m=s(w)),y||(y=o(m,r,a,"legend")),p.width+=2*g,p.height+=2*g;const f=p.getContext("2d",{willReadFrequently:!0}),M=t.createIdentity();M.translate(-h,-l),M.scale(c*b,-c*b),M.translate(r*b/2+g,a*b/2+g),f.clearRect(0,0,p.width,p.height);return new i(f,this._cimResourceManager,M,!0).drawSymbol(w,y),f.getImageData(0,0,p.width,p.height)}}function o(e,t,i,r){const a=1,s=-t/2+a,n=t/2-a,h=i/2-a,o=-i/2+a;switch(e){case"esriGeometryPoint":return{x:0,y:0};case"esriGeometryPolyline":return{paths:[[[s,0],[0,0],[n,0]]]};default:return"legend"===r?{rings:[[[s,h],[n,0],[n,o],[s,o],[s,h]]]}:{rings:[[[s,h],[n,h],[n,o],[s,o],[s,h]]]}}}export{h as CIMSymbolRasterizer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{isRGB as e}from"../../core/colorUtils.js";import{getFontFamily as r}from"../../core/fontUtils.js";import{clone as t}from"../../core/lang.js";import i from"../../core/Logger.js";import{pt2px as o,px2pt as a}from"../../core/screenUtils.js";import{numericHash as s}from"../../core/string.js";import{checkForAnimations as l,getAnimationParams as n,handleAbsoluteAnchor as p,handleMarker as c,handleRelativeAnchor as m,getFrameTranslation as y,translate as d,getStaticParam as h,shouldUseAnimatedPath as f}from"./animationUtils.js";import{CIMSymbolHelper as u}from"./CIMSymbolHelper.js";import{defaultCIMValues as v}from"./defaultCIMValues.js";import{Alignment as O,SymbolUnits as g}from"./enums.js";import{OverrideHelper as _}from"./OverrideHelper.js";import{getExtent as S,getSDFMetrics as M,getSDFDimensions as k}from"./SDFHelper.js";import{colorToArray as b,normalizeAlpha as C,getSize as P,isCIMMarkerStrokePlacement as z,getTintColor as x,getNumericValue as E,normalizePrimitiveOverrideProps as I,getDefaultCIMValue as L,getEnum as V,getStrokeWidth as N,getFillColor as R,getStrokeColor as A,fromCIMFontDecoration as w,fromCIMFontStyle as G,fromCIMHorizontalAlignment as F,fromCIMVerticalAlignment as T,isValidCIMValue as X,uncapitalize as Y}from"./utils.js";import{CIMEffectHelper as j}from"./effects/CIMEffectHelper.js";import{rasterizedVectorMarkerMinSize as W,randomInsidePolygonTextureSize as U}from"../../views/2d/engine/webgl/definitions.js";const D=()=>i.getLogger("esri.symbols.cim.cimAnalyzer");function H(e){const r=e.markerPlacement;return r&&r.angleToLine?O.MAP:O.SCREEN}class J{constructor(e){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[],e&&(this._resourceManager=e)}analyzeSymbolReference(r,t,i){if(this._cimLayers=i??[],!r)return this._cimLayers;if(this._reset(),r.primitiveOverrides){this._primitiveOverrides=r.primitiveOverrides;for(const r of this._primitiveOverrides){const t=r.valueExpressionInfo;if(t)this._setPoMap(r.primitiveName,r.propertyName,t);else if(null!=r.value){let t=r.value;r.propertyName.includes("Color")&&(e(t)&&(t=b(t)),t=C(t)),this._setPoMap(r.primitiveName,r.propertyName,t)}}}return this._analyzeSymbol(r.symbol,t),this._cimLayers}_reset(){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[]}_analyzeSymbol(e,r){switch(e?.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this._analyzeMultiLayerSymbol(e,r)}}_analyzeMultiLayerSymbol(e,r){const t=e?.symbolLayers;if(!t)return;const i=e.effects;let o=O.SCREEN;const a=P(e)??0;"CIMPointSymbol"===e.type&&"Map"===e.angleAlignment&&(o=O.MAP);let s={transform:[0,0,0,1],fromColor:[1,1,1,1],toColor:[1,1,1,1],colorMix:[0,0,0,0],toOpacity:[1,1,1,1],opacityMix:[0,0,0,0],hasAnimations:l(e)};s=n(this._poMap,e,s);const p="CIMPolygonSymbol"===e.type;let c=t.length;for(;c--;){const l=t[c];if(!l||!1===l.enable)continue;let n;i?.length&&(n=[...i]);const m=l.effects;m?.length&&(i?n.push(...m):n=[...m]);let y=null;if(n){y=[];for(const e of n){const r=_.findEffectOverrides(e,this._primitiveOverrides);r&&y.push(r)}}const d=[];switch(_.findApplicableOverrides(l,this._primitiveOverrides,d),l.type){case"CIMSolidFill":this._analyzeSolidFill(l,y);break;case"CIMPictureFill":this._analyzePictureFill(l,y);break;case"CIMHatchFill":this._analyzeHatchFill(l,y);break;case"CIMGradientFill":this._analyzeGradientFill(l,y);break;case"CIMSolidStroke":this._analyzeSolidStroke(l,y,p,a);break;case"CIMPictureStroke":this._analyzePictureStroke(l,y,p,a);break;case"CIMGradientStroke":this._analyzeGradientStroke(l,y,p,a);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":{"CIMLineSymbol"!==e.type&&"CIMPolygonSymbol"!==e.type||(o=H(l));const t=[],i=l.primitiveName;i&&t.push(i);const n=p&&z(l.markerPlacement);this._analyzeMarker(l,y,null,t,o,a,r,[],s,!1,n);break}default:D().error("Cannot analyze CIM layer",l.type)}}}_analyzeSolidFill(e,r){const{primitiveName:t,type:i}=e,o=C(e.color);this._cimLayers.push({type:"fill",spriteRasterizationParam:null,colorLocked:!!e.colorLocked,color:this._getValueOrOverrideExpression(i,t,"Color",o),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:r,applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!1})}_analyzePictureFill(e,r){const{primitiveName:t,type:i}=e,o=x(e),a=E(e.height,v.CIMPictureFill.height);let s=E(e.scaleX,1);if("width"in e&&"number"==typeof e.width){const r=e.width;let t=1;const i=this._resourceManager.getResource(e.url);null!=i&&(t=i.width/i.height),s/=t*(a/r)}const l={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(t,i)};this._cimLayers.push({type:"fill",spriteRasterizationParam:l,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(i,t,"TintColor",o),height:this._getValueOrOverrideExpression(i,t,"Height",a),scaleX:this._getValueOrOverrideExpression(i,t,"ScaleX",s),angle:this._getValueOrOverrideExpression(i,t,"Rotation",E(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,t,"OffsetX",E(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,t,"OffsetY",E(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!1,hasUnresolvedReplacementColor:!1})}_analyzeHatchFill(e,r){const{primitiveName:t,type:i}=e,o=this._analyzeMaterialOverrides(t,["Rotation","OffsetX","OffsetY"]),a=I(o);let s=[255,255,255,1],l=!1;if(e.lineSymbol?.symbolLayers)for(const p of e.lineSymbol.symbolLayers){if("CIMSolidStroke"!==p.type)continue;const e=p.primitiveName??t;l||!e||p.colorLocked||null==this._poMap[e]?.Color&&null==this._poMap[e]?.StrokeColor||(s=C(p.color),s=this._maybeGetValueOrOverrideExpression(e,"StrokeColor")??this._getValueOrOverrideExpression(i,e,"Color",s),l=!0);const r=this._maybeGetValueOrOverrideExpression(e,"StrokeWidth");if(r){let t=null,o=null;"number"==typeof r?t=r:o=r.valueExpressionInfo;let s=a.find((e=>"strokeWidth"===e.propertyName));s?s.propertyName="width":(s={type:"CIMPrimitiveOverride",primitiveName:e,propertyName:"width",valueExpressionInfo:o,value:t,defaultValue:L(i,"width")},a.push(s))}}const n={type:"sprite-rasterization-param",resource:e,overrides:a};this._cimLayers.push({type:"fill",spriteRasterizationParam:n,colorLocked:!!e.colorLocked,effects:r,color:s,height:this._getValueOrOverrideExpression(i,t,"Separation",E(e.separation,v.CIMHatchFill.separation)),scaleX:1,angle:this._getValueOrOverrideExpression(i,t,"Rotation",E(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,t,"OffsetX",E(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,t,"OffsetY",E(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!l})}_analyzeGradientFill(e,r){const{angle:t,gradientMethod:i,gradientSize:o,gradientSizeUnits:a,gradientType:s,interval:l,primitiveName:n,type:p}=e,c=v.CIMGradientFill,m=e.colorRamp;this._cimLayers.push({type:"gradientFill",spriteRasterizationParam:{type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(n,p)},colorLocked:!1,effects:r,color:[255,255,255,1],gradientMethod:this._getValueOrOverrideExpression(p,n,"GradientMethod",i??"Linear"),angle:this._getValueOrOverrideExpression(p,n,"Angle",E(t,c.angle)),gradientType:this._getValueOrOverrideExpression(p,n,"GradientType",s??c.gradientType),interval:this._getValueOrOverrideExpression(p,n,"Interval",E(l,"CIMFixedColorRamp"===m.type?m.colors.length:c.interval)),gradientSize:this._getValueOrOverrideExpression(p,n,"GradientSize",E(o,c.gradientSize)),gradientSizeUnits:"Absolute"===a?g.Absolute:"Relative"===a?g.Relative:c.gradientSizeUnits})}_analyzeSolidStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=C(e.color),l=E(e.width,v.CIMSolidStroke.width),n=V(e.capStyle,v.CIMSolidStroke.capstyle),p=V(e.joinStyle,v.CIMSolidStroke.joinstyle),c=e.miterLimit;let m,y,d,h,f=[];if(this._analyzePrimitiveOverrides(o,r,null,null)&&(f=this._getPrimitiveMaterialOverrides(o,a)),r&&Array.isArray(r)&&r.length>0){const e=r[r.length-1].effect;e&&"CIMGeometricEffectDashes"===e.type&&"NoConstraint"===e.lineDashEnding&&(m=e.dashTemplate,y=e.scaleDash,d=e.offsetAlongLine,h=e.primitiveName,(r=[...r]).pop())}null!=h&&f.push(...this._getPrimitiveMaterialOverrides(h,a).filter((e=>"dashTemplate"===e.propertyName)));const u=void 0!==m?{type:"sprite-rasterization-param",resource:{type:"dash",dashTemplate:m,primitiveName:h},overrides:f}:null;this._cimLayers.push({type:"line",spriteRasterizationParam:u,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(a,o,"Color",s),width:this._getValueOrOverrideExpression(a,o,"Width",l),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",n),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",p),miterLimit:c&&this._getValueOrOverrideExpression(a,o,"MiterLimit",c),referenceWidth:i,zOrder:q(e.name),dashTemplate:this._maybeGetValueOrOverrideExpression(h,"DashTemplate")??m,offsetAlongLine:this._getValueOrOverrideExpression(a,h,"OffsetAlongLine",d??0),scaleDash:y,sampleAlphaOnly:!0})}_analyzePictureStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=x(e),l=E(e.width,v.CIMPictureStroke.width),n=V(e.capStyle,v.CIMPictureStroke.capstyle),p=V(e.joinStyle,v.CIMPictureStroke.joinstyle),c=e.miterLimit,m={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(o,a)};this._cimLayers.push({type:"line",spriteRasterizationParam:m,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(a,o,"TintColor",s),width:this._getValueOrOverrideExpression(a,o,"Width",l),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",n),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",p),miterLimit:c&&this._getValueOrOverrideExpression(a,o,"MiterLimit",c),referenceWidth:i,zOrder:q(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}_analyzeGradientStroke(e,r,t,i){const{gradientMethod:o,gradientSize:a,gradientSizeUnits:s,gradientType:l,interval:n,primitiveName:p,type:c}=e,m=v.CIMGradientStroke,y=E(e.width,m.width),d=V(e.capStyle,m.capstyle),h=V(e.joinStyle,m.joinstyle),f=e.miterLimit,u=e.colorRamp;this._cimLayers.push({type:"gradientStroke",spriteRasterizationParam:{type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(p,c)},colorLocked:!!e.colorLocked,effects:r,color:[255,255,255,1],width:this._getValueOrOverrideExpression(c,p,"Width",y),cap:this._getValueOrOverrideExpression(c,p,"CapStyle",d),join:this._getValueOrOverrideExpression(c,p,"JoinStyle",h),miterLimit:f&&this._getValueOrOverrideExpression(c,p,"MiterLimit",f),referenceWidth:i,isOutline:t,gradientMethod:this._getValueOrOverrideExpression(c,p,"GradientMethod",o??m.gradientMethod),gradientType:this._getValueOrOverrideExpression(c,p,"GradientType",l??m.gradientType),interval:this._getValueOrOverrideExpression(c,p,"Interval",E(n,"CIMFixedColorRamp"===u.type?u.colors.length:m.interval)),gradientSize:this._getValueOrOverrideExpression(c,p,"GradientSize",E(a,m.gradientSize)),gradientSizeUnits:"Absolute"===s?g.Absolute:"Relative"===s?g.Relative:m.gradientSizeUnits})}_analyzeMarker(e,r,t,i,o,a,s,l,y,d=!1,h=!1){if(d||=!!e.colorLocked,this._analyzeMarkerInsidePolygon(e,r,d))return;const f=E(e.size,v.CIMVectorMarker.size),u=E(e.rotation),O=E(e.offsetX),g=E(e.offsetY),{primitiveName:_,type:S}=e,M=this._getValueOrOverrideExpression(S,_,"Size",f),k=this._getValueOrOverrideExpression(S,_,"Rotation",u),b=this._getValueOrOverrideExpression(S,_,"OffsetX",O),C=this._getValueOrOverrideExpression(S,_,"OffsetY",g);let P=y;switch(P=p(e,P),P=c(this._poMap,e,P),P=m(e,P),P=n(this._poMap,e,P),e.type){case"CIMPictureMarker":this._analyzePictureMarker(e,r,t,i,o,a,M,k,b,C,l,P,d,h);break;case"CIMVectorMarker":this._analyzeVectorMarker(e,r,t,i,o,a,M,k,b,C,l,P,s,d,h)}}_analyzeMarkerInsidePolygon(e,r,t){const{markerPlacement:i,type:o}=e;if(!i||"CIMMarkerPlacementInsidePolygon"!==i.type)return!1;if("CIMVectorMarker"===o||"CIMPictureMarker"===o){const t=e.primitiveName;if(t&&this._analyzePrimitiveOverrides([t],r,null,null))return!1;const a=i.primitiveName;if(a&&this._analyzePrimitiveOverrides([a],r,null,null))return!1;if("CIMVectorMarker"===o){const{markerGraphics:r}=e;if(r)for(const e of r){const{symbol:r}=e;if("CIMPolygonSymbol"===r?.type&&r.symbolLayers){const{symbolLayers:e}=r;for(const r of e)if("CIMSolidStroke"===r.type)return!1}}}else{const{animatedSymbolProperties:r}=e;if(r)return!1}}const s=Math.abs(i.stepX),l=Math.abs(i.stepY);if(0===s||0===l)return!0;let n,p;if("Random"===i.gridType){const e=a(U),r=Math.max(Math.floor(e/s),1);n=l*Math.max(Math.floor(e/l),1);p=r*s/n}else i.shiftOddRows?(n=2*l,p=s/l*.5):(n=l,p=s/l);const c=x(e),m="CIMCharacterMarker"===e.type?null:{type:"sprite-rasterization-param",resource:e,overrides:[]};return this._cimLayers.push({type:"fill",spriteRasterizationParam:m,colorLocked:t,effects:r,color:c,height:n,scaleX:p,angle:i.gridAngle,offsetX:E(i.offsetX),offsetY:E(i.offsetY),applyRandomOffset:"Random"===i.gridType,sampleAlphaOnly:"CIMPictureMarker"!==e.type,hasUnresolvedReplacementColor:!0}),!0}_analyzePictureMarker(e,r,i,o,a,l,n,p,c,m,y,d,h,f){const{animatedSymbolProperties:u,primitiveName:v,type:O}=e;let g=E(e.scaleX,1);const _=x(e);i||(i=this._createMarkerPlacementOverrideExpression(e.markerPlacement));const S=this._createGIFAnimatedSymbolPropertiesOverrideExpression(u),M=e.anchorPoint??{x:0,y:0};if("width"in e&&"number"==typeof e.width){const r=e.width;let t=1;const i=this._resourceManager.getResource(e.url);null!=i&&(t=i.width/i.height);g/=t*(E(e.size)/r)}const k=[...o];let b;e.primitiveName&&k.push(e.primitiveName),u||S?b={type:"animated",url:e.url,urlHash:"H"+s(e.url),playAnimation:e.animatedSymbolProperties?.playAnimation,reverseAnimation:e.animatedSymbolProperties?.reverseAnimation,randomizeStartTime:e.animatedSymbolProperties?.randomizeStartTime,randomizeStartSeed:e.animatedSymbolProperties?.randomizeStartSeed,startTimeOffset:e.animatedSymbolProperties?.startTimeOffset,duration:e.animatedSymbolProperties?.duration,repeatType:e.animatedSymbolProperties?.repeatType,repeatDelay:e.animatedSymbolProperties?.repeatDelay}:(b=t(e),b.markerPlacement=null);const C={type:"sprite-rasterization-param",resource:b,overrides:this._getMaterialOverrides(k,O)};S&&C.overrides.push(...S.overrides);const P=n;this._cimLayers.push({type:"marker",spriteRasterizationParam:C,colorLocked:h,effects:r,scaleSymbolsProportionally:!1,alignment:a,size:n,scaleX:this._getValueOrOverrideExpression(O,v,"ScaleX",g),rotation:p,offsetX:c,offsetY:m,transform:{type:"cim-marker-transform-param",params:y},color:this._getValueOrOverrideExpression(O,v,"TintColor",_),anchorPoint:{x:M.x,y:M.y},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,outlineColor:[0,0,0,0],outlineWidth:0,frameHeight:0,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:1,isOutline:f,markerPlacement:i,animationParams:re(d),baseSize:P})}_analyzeVectorMarker(e,r,t,i,o,a,s,l,p,c,m,f,u,v,O){const g=e.markerGraphics;if(!g)return;const _=e.frame;let S=0;S=_?_.ymax-_.ymin:a;const M=!!e.scaleSymbolsProportionally;if(S){const r={offsetX:p,offsetY:c,rotation:l,size:s,frameHeight:S,rotateClockWise:!!e.rotateClockwise,absoluteAnchorPoint:!1,scaleSymbolsProportionally:M};m=[...m,r]}t||(t=this._createMarkerPlacementOverrideExpression(e.markerPlacement));for(const k of g)if(k){const s=k.symbol;if(!s)continue;const l=k.primitiveName;l&&i.push(l);let p,c=f;if(("CIMPointSymbol"===s.type||"CIMTextSymbol"===s.type)&&_){let r=0,t=0;const i=k.geometry;"x"in i&&"y"in i&&(r+=i.x-.5*(_.xmin+_.xmax),t+=i.y-.5*(_.ymin+_.ymax));const o=e.anchorPoint;let a=!1;o&&("Absolute"===e.anchorPointUnits?(r-=o.x,t-=o.y,a=!0):_&&(r-=(_.xmax-_.xmin)*o.x,t-=(_.ymax-_.ymin)*o.y));const s={offsetX:r,offsetY:t,rotation:0,size:0,frameHeight:0,rotateClockWise:!1,absoluteAnchorPoint:a,scaleSymbolsProportionally:M};p=[...m,s]}const g=k.geometry,[b,C]=y(g,_);switch(0===b&&0===C||(c=d(c,b,C)),"CIMPointSymbol"===s.type&&(c=n(this._poMap,s,c)),s.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":u||Z(s)?(c={...c,transform:{type:"AnimatedTransform",relativeTranslation:!1,absoluteScale:!0,translation:h([0,0]),rotation:h(0),scale:h(S),parent:f.transform}},this._analyzeMultiLayerGraphicNonSDF(e,r,t,k,i,o,a,p??m,c,S,v,O)):this._analyzeMultiLayerGraphic(e,r,t,k,i,o,a,p??m,c,S,v,O);break;case"CIMTextSymbol":this._analyzeTextGraphic(r,t,k,i,o,a,p??m,v)}l&&i.pop()}}_analyzeMultiLayerGraphic(e,r,t,i,o,a,s,l,n,p,c,m){const y=i.symbol.symbolLayers;y&&(!Q(y)||f(n)?$(y)?this._analyzeMultiLayerGraphicNonSDF(e,r,t,i,o,a,s,l,n,p,!!c,m):this._analyzeMarkerGraphicSymbolLayers(e,r,t,i,o,a,s,l,n,p,c,m):this._analyzeCompositeMarkerGraphic(e,r,t,i,y,a,s,l,p,c,m))}_analyzeMarkerGraphicSymbolLayers(e,r,t,i,o,a,s,l,p,c,m,y){const d=i.symbol,h=d.symbolLayers;if(!h)return;const f=this._resourceManager.geometryEngine,u=j.applyEffects(d.effects,i.geometry,f);if(!u)return;let O=h.length;for(;O--;){const d=h[O];if(!d||!1===d.enable)continue;const g=d.primitiveName;switch(g&&o.push(g),d.type){case"CIMSolidFill":case"CIMSolidStroke":{const o=j.applyEffects(d.effects,u,f),h=S(o);if(!h)continue;const O="Relative"!==e.anchorPointUnits,_=N(d)??0,{frameSizeRatio:b,anchorX:P,anchorY:z,widthRatio:x,sdfPaddingRatio:I}=M(h,e.frame,e.size,e.anchorPoint,O,_,e.scaleSymbolsProportionally),L="CIMSolidFill"===d.type,V={type:"sdf",geom:o,sdfPaddingRatio:I,asFill:L},{path:w}=d,G=L?C(R(d)):null==w?C(A(d)):[0,0,0,0],F=L?[0,0,0,0]:C(A(d));if(!L&&!_)break;const T=i.primitiveName;let X=null;L&&!d.colorLocked&&(X=this._maybeGetValueOrOverrideExpression(T,"FillColor"));let Y=null;L||d.colorLocked||(Y=this._maybeGetValueOrOverrideExpression(T,"StrokeColor"));const W=X??this._getValueOrOverrideExpression(d.type,g,"Color",G),U=Y??this._getValueOrOverrideExpression(d.type,g,"Color",F),D=this._maybeGetValueOrOverrideExpression(T,"StrokeWidth")??this._getValueOrOverrideExpression(d.type,g,"Width",_),H=w?{type:"sprite-rasterization-param",resource:{type:"path",path:w,asFill:L},overrides:[]}:{type:"sprite-rasterization-param",resource:V,overrides:[]},J=n(this._poMap,d,p),B=E(e.size,v.CIMVectorMarker.size),q=this._getValueOrOverrideExpression(e.type,e.primitiveName,"Size",B);this._cimLayers.push({type:"marker",spriteRasterizationParam:H,colorLocked:!!d.colorLocked||!!m,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:P,y:z},isAbsoluteAnchorPoint:O,size:c,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:c,widthRatio:x,rotateClockwise:!1,referenceSize:s,sizeRatio:b,color:W,outlineColor:U,outlineWidth:D,isOutline:y,markerPlacement:t,animationParams:re(J),isStroke:"CIMSolidFill"!==d.type,baseSize:q,...k(o,I)});break}case"CIMPictureMarker":case"CIMVectorMarker":if(d.markerPlacement){D().error("Error analyzing CIM, got unexpected marker placement");break}this._analyzeMarker(d,r,t,o,a,s,!1,l,p,m,y)}g&&o.pop()}}_analyzeTextGraphic(e,t,i,o,a,s,l,n){const p=[];_.findApplicableOverrides(i,this._primitiveOverrides,p);const c=i.geometry;if(!("x"in c)||!("y"in c))return;const m=i.symbol,y=w(m),d=G(m.fontStyleName),h=r(m.fontFamilyName);m.font={family:h,decoration:y,...d};const f=E(m.height,v.CIMTextSymbol.height),u=E(m.angle),O=E(m.offsetX),g=E(m.offsetY),{haloSymbol:S}=m,M=E(m.haloSize,0);let k=[0,0,0,0];if(S?.symbolLayers?.length){const e=S.symbolLayers;for(const r of e)if(r.color){k=this._getValueOrOverrideExpression(m?.haloSymbol?.type??"CIMPolygonSymbol",r.primitiveName,"Color",C(r.color));break}}const b=i.primitiveName;let P=[0,0,0,1],z=[0,0,0,0],x=0,I=!1;if(m.symbol?.symbolLayers)for(const r of m.symbol.symbolLayers){const e=r.primitiveName;if("CIMSolidStroke"===r.type)z=this._getValueOrOverrideExpression("CIMSolidStroke",e,"Color",C(r.color)),x=this._getValueOrOverrideExpression("CIMSolidStroke",e,"Width",N(r)??0);else if("CIMSolidFill"===r.type){const t=C(r.color);I=I??!!r.colorLocked,P=this._getValueOrOverrideExpression("CIMSolidFill",e??b,"Color",t)}}let L=null,V=null,R=null,A=null,X=null;b&&(L=this._maybeGetValueOrOverrideExpression(b,"TextSize"),V=this._maybeGetValueOrOverrideExpression(b,"TextAngle"),R=this._maybeGetValueOrOverrideExpression(b,"TextOffsetX"),A=this._maybeGetValueOrOverrideExpression(b,"TextOffsetY"),I||(X=this._maybeGetValueOrOverrideExpression(b,"FillColor")));const Y=X??P;let j=null,W=null,U=0;if(m.callout&&"CIMBackgroundCallout"===m.callout.type){const e=m.callout;if(e.backgroundSymbol){const r=e.backgroundSymbol.symbolLayers;if(r)for(const e of r)"CIMSolidFill"===e.type?j=C(e.color):"CIMSolidStroke"===e.type&&(W=C(e.color),U=E(e.width,v.CIMSolidStroke.width))}}const D=this._getValueOrOverrideExpression(m.type,i.primitiveName,"TextString",i.textString??"");if(null==D)return;const{fontStyleName:H}=m,J=h+(H?"-"+H.toLowerCase():"-regular"),B=this._getMaterialOverrides(o,m.type);B.push(...this._getPrimitiveMaterialOverrides(i.primitiveName,m.type));const q={type:"text-rasterization-param",resource:{type:"text",textString:i.textString??"",font:m.font,symbol:m,primitiveName:i.primitiveName},overrides:B};this._cimLayers.push({type:"text",lineWidth:m.lineWidth,textRasterizationParam:q,colorLocked:!!n||!!I,effects:e,alignment:a,anchorPoint:{x:0,y:0},isAbsoluteAnchorPoint:!1,fontName:J,decoration:y,haloSize:M,haloColor:k,weight:d.weight,style:d.style,size:L??f,angle:V??u,offsetX:R??O,offsetY:A??g,transform:{type:"cim-marker-transform-param",params:l},horizontalAlignment:F(m.horizontalAlignment),verticalAlignment:T(m.verticalAlignment),text:D,color:Y,outlineColor:z,outlineSize:x,backgroundColor:j,borderLineColor:W,borderLineWidth:U,referenceSize:s,sizeRatio:1,markerPlacement:t})}_analyzeMultiLayerGraphicNonSDF(e,r,t,i,a,s,l,n,p,c,m,y){const d=B(e,i),h=e.primitiveName,f=this._analyzeMaterialOverrides(h,["Rotation","OffsetX","OffsetY"]),O=I(f),[g,_,S]=u.getTextureAnchor(d,this._resourceManager,W),M=this._getMaterialOverrides(a,e.type);M.push(...O);const k={type:"sprite-rasterization-param",resource:{...d,avoidSDFRasterization:!0},overrides:M},b=E(e.size,v.CIMVectorMarker.size),C=this._getValueOrOverrideExpression(e.type,h,"Size",b);this._cimLayers.push({type:"marker",spriteRasterizationParam:k,colorLocked:m,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:g,y:_},isAbsoluteAnchorPoint:!1,size:c,rotation:0,offsetX:0,offsetY:0,transform:{type:"cim-marker-transform-param",params:n},color:[255,255,255,1],outlineColor:[0,0,0,0],outlineWidth:0,scaleX:1,frameHeight:c,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:S/o(e.size),isOutline:y,markerPlacement:t,animationParams:re(p),baseSize:C})}_createMarkerPlacementOverrideExpression(e){if(!e)return null;const r=[];return _.findApplicableOverrides(e,this._primitiveOverrides,r),{type:"cim-marker-placement-param",placement:e,overrides:ee(r)}}_createGIFAnimatedSymbolPropertiesOverrideExpression(e){if(!e)return null;const r=[];return _.findApplicableOverrides(e,this._primitiveOverrides,r),{type:"cim-gif-animation-params",animation:e,overrides:ee(r)}}_analyzeCompositeMarkerGraphic(e,r,t,i,o,a,s,l,n,p,c){const m=i.geometry,y=o[0],d=o[1],h=S(m);if(!h)return;const f="Relative"!==e.anchorPointUnits,u=E(y.width,v.CIMSolidStroke.width),{frameSizeRatio:O,anchorX:g,anchorY:_,widthRatio:k,sdfPaddingRatio:b}=M(h,e.frame,e.size,e.anchorPoint,f,u,e.scaleSymbolsProportionally),{path:P}=d,z=d.primitiveName,x=y.primitiveName,I=i.primitiveName;let L=null;d.colorLocked||p||(L=this._maybeGetValueOrOverrideExpression(I,"FillColor"));const V=L??this._getValueOrOverrideExpression(d.type,z,"Color",C(d.color));let N=null;y.colorLocked||p||(N=this._maybeGetValueOrOverrideExpression(I,"StrokeColor"));const R=N??this._getValueOrOverrideExpression(y.type,x,"Color",C(y.color)),A=this._maybeGetValueOrOverrideExpression(I,"StrokeWidth")??this._getValueOrOverrideExpression(y.type,x,"Width",u),w={type:"sprite-rasterization-param",resource:P?{type:"path",path:P,asFill:!0}:{type:"sdf",geom:m,sdfPaddingRatio:b,asFill:!0},overrides:[]};this._cimLayers.push({type:"marker",spriteRasterizationParam:w,colorLocked:p,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:g,y:_},isAbsoluteAnchorPoint:f,size:n,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:n,widthRatio:k,rotateClockwise:!1,referenceSize:s,sizeRatio:O,color:V,outlineColor:R,outlineWidth:A,isOutline:c,markerPlacement:t})}_setPoMap(e,r,t){let i;this._poMap[e]?i=this._poMap[e]:(i={},this._poMap[e]=i),i[r]=t}_maybeGetValueOrOverrideExpression(e,r,t){return this._getValueOrOverrideExpression("",e,r,t,!1)}_getValueOrOverrideExpression(e,r,t,i,o=!0){if(o&&!X(i)&&(i=L(e,t.toLowerCase())),null==r)return i;const a=this._poMap[r];if(null==a)return i;const s=a[t];return"string"==typeof s||"number"==typeof s||Array.isArray(s)?s:s?{valueExpressionInfo:s,defaultValue:i}:i}_analyzePrimitiveOverrides(e,r,t,i){if(null==e)return!1;"string"==typeof e&&(e=[e]);for(const o of this._primitiveOverrides)if(e.includes(o.primitiveName)&&o.valueExpressionInfo)return!0;if(null!=r)for(const o of r)if(o?.overrides.length>0)return!0;if(null!=t)for(const o of t)if(o?.overrides.length>0)return!0;if(null!=i)for(const o of i)if(o?.overrides.length>0)return!0;return!1}_getMaterialOverrides(e,r){if(!e)return[];const t=[];for(const i of e)t.push(...this._getPrimitiveMaterialOverrides(i,r));return t}_getPrimitiveMaterialOverrides(e,r){if(!e)return[];const t=I(this._primitiveOverrides.filter((r=>r.primitiveName===e)));return t.forEach((e=>e.defaultValue=L(r,e.propertyName.toLowerCase()))),t}_analyzeMaterialOverrides(e,r){return this._primitiveOverrides.filter((t=>t.primitiveName!==e||!r.includes(t.propertyName)))}}function B(e,r){return{type:e.type,enable:!0,name:e.name,colorLocked:e.colorLocked,primitiveName:e.primitiveName,anchorPoint:e.anchorPoint,anchorPointUnits:e.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:e.rotateClockwise,rotation:0,size:e.size,billboardMode3D:e.billboardMode3D,depth3D:e.depth3D,frame:e.frame,markerGraphics:[r],scaleSymbolsProportionally:e.scaleSymbolsProportionally,respectFrame:e.respectFrame,clippingPath:e.clippingPath}}function q(e){if(e&&0===e.indexOf("Level_")){const r=parseInt(e.slice(6),10);if(!isNaN(r))return r}return 0}function K(e,r){if(!r||0===r.length)return e;const i=t(e);return _.applyOverrides(i,r),i}const Q=e=>e&&2===e.length&&e[0].enable&&e[1].enable&&"CIMSolidStroke"===e[0].type&&"CIMSolidFill"===e[1].type&&null==e[0].path&&null==e[1].path&&!e[0].effects&&!e[1].effects&&!e[0].animations&&!e[1].animations;function Z(e){const r=e.symbolLayers;if(!r)return!1;const t=r.find((e=>e.effects?.find((e=>"CIMGeometricEffectDashes"===e.type&&null!=e.dashTemplate)))),i=r.find((e=>e.effects?.find((e=>"CIMGeometricEffectAddControlPoints"===e.type))));return!!t||!!i}function $(e){return e.some((e=>"CIMSolidFill"!==e.type&&"CIMSolidStroke"!==e.type&&("CIMVectorMarker"!==e.type&&"CIMPictureMarker"!==e.type||null!=e.markerPlacement)))}function ee(e){return t(e).map((e=>({...e,propertyName:Y(e.propertyName)})))}function re(e){return f(e)?{type:"animation-params",params:e}:null}export{J as CIMAnalyzer,K as analyzeCIMResource};
5
+ import{isRGB as e}from"../../core/colorUtils.js";import{getFontFamily as r}from"../../core/fontUtils.js";import{clone as t}from"../../core/lang.js";import i from"../../core/Logger.js";import{pt2px as o,px2pt as a}from"../../core/screenUtils.js";import{numericHash as s}from"../../core/string.js";import{checkForAnimations as l,getAnimationParams as n,handleAbsoluteAnchor as p,handleMarker as c,handleRelativeAnchor as m,getFrameTranslation as y,translate as d,getStaticParam as h,shouldUseAnimatedPath as f}from"./animationUtils.js";import{CIMSymbolHelper as u}from"./CIMSymbolHelper.js";import{defaultCIMValues as v}from"./defaultCIMValues.js";import{Alignment as O,SymbolUnits as g}from"./enums.js";import{fitVectorMarker as _}from"./fitVectorMarker.js";import{OverrideHelper as M}from"./OverrideHelper.js";import{getExtent as S,getSDFMetrics as k,getSDFDimensions as b}from"./SDFHelper.js";import{colorToArray as C,normalizeAlpha as P,getSize as z,isCIMMarkerStrokePlacement as x,getTintColor as E,getNumericValue as I,normalizePrimitiveOverrideProps as L,getDefaultCIMValue as V,getEnum as N,getStrokeWidth as R,getFillColor as A,getStrokeColor as w,fromCIMFontDecoration as G,fromCIMFontStyle as F,fromCIMHorizontalAlignment as T,fromCIMVerticalAlignment as X,isValidCIMValue as Y,uncapitalize as j}from"./utils.js";import{CIMEffectHelper as W}from"./effects/CIMEffectHelper.js";import{rasterizedVectorMarkerMinSize as U,randomInsidePolygonTextureSize as D}from"../../views/2d/engine/webgl/definitions.js";const H=()=>i.getLogger("esri.symbols.cim.cimAnalyzer");function J(e){const r=e.markerPlacement;return r&&r.angleToLine?O.MAP:O.SCREEN}class B{constructor(e){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[],e&&(this._resourceManager=e)}analyzeSymbolReference(r,t,i){if(this._cimLayers=i??[],!r)return this._cimLayers;if(this._reset(),r.primitiveOverrides){this._primitiveOverrides=r.primitiveOverrides;for(const r of this._primitiveOverrides){const t=r.valueExpressionInfo;if(t)this._setPoMap(r.primitiveName,r.propertyName,t);else if(null!=r.value){let t=r.value;r.propertyName.includes("Color")&&(e(t)&&(t=C(t)),t=P(t)),this._setPoMap(r.primitiveName,r.propertyName,t)}}}return this._analyzeSymbol(r.symbol,t),this._cimLayers}_reset(){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[]}_analyzeSymbol(e,r){switch(e?.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this._analyzeMultiLayerSymbol(e,r)}}_analyzeMultiLayerSymbol(e,r){const t=e?.symbolLayers;if(!t)return;for(let l=0;l<t.length;l++){const e=t[l];"CIMVectorMarker"===e.type&&(t[l]=_(e,this._resourceManager.geometryEngine))}const i=e.effects;let o=O.SCREEN;const a=z(e)??0;"CIMPointSymbol"===e.type&&"Map"===e.angleAlignment&&(o=O.MAP);let s={transform:[0,0,0,1],fromColor:[1,1,1,1],toColor:[1,1,1,1],colorMix:[0,0,0,0],toOpacity:[1,1,1,1],opacityMix:[0,0,0,0],hasAnimations:l(e)};s=n(this._poMap,e,s);const p="CIMPolygonSymbol"===e.type;let c=t.length;for(;c--;){const l=t[c];if(!l||!1===l.enable)continue;let n;i?.length&&(n=[...i]);const m=l.effects;m?.length&&(i?n.push(...m):n=[...m]);let y=null;if(n){y=[];for(const e of n){const r=M.findEffectOverrides(e,this._primitiveOverrides);r&&y.push(r)}}const d=[];switch(M.findApplicableOverrides(l,this._primitiveOverrides,d),l.type){case"CIMSolidFill":this._analyzeSolidFill(l,y);break;case"CIMPictureFill":this._analyzePictureFill(l,y);break;case"CIMHatchFill":this._analyzeHatchFill(l,y);break;case"CIMGradientFill":this._analyzeGradientFill(l,y);break;case"CIMSolidStroke":this._analyzeSolidStroke(l,y,p,a);break;case"CIMPictureStroke":this._analyzePictureStroke(l,y,p,a);break;case"CIMGradientStroke":this._analyzeGradientStroke(l,y,p,a);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":{"CIMLineSymbol"!==e.type&&"CIMPolygonSymbol"!==e.type||(o=J(l));const t=[],i=l.primitiveName;i&&t.push(i);const n=p&&x(l.markerPlacement);this._analyzeMarker(l,y,null,t,o,a,r,[],s,!1,n);break}default:H().error("Cannot analyze CIM layer",l.type)}}}_analyzeSolidFill(e,r){const{primitiveName:t,type:i}=e,o=P(e.color);this._cimLayers.push({type:"fill",spriteRasterizationParam:null,colorLocked:!!e.colorLocked,color:this._getValueOrOverrideExpression(i,t,"Color",o),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:r,applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!1})}_analyzePictureFill(e,r){const{primitiveName:t,type:i}=e,o=E(e),a=I(e.height,v.CIMPictureFill.height);let s=I(e.scaleX,1);if("width"in e&&"number"==typeof e.width){const r=e.width;let t=1;const i=this._resourceManager.getResource(e.url);null!=i&&(t=i.width/i.height),s/=t*(a/r)}const l={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(t,i)};this._cimLayers.push({type:"fill",spriteRasterizationParam:l,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(i,t,"TintColor",o),height:this._getValueOrOverrideExpression(i,t,"Height",a),scaleX:this._getValueOrOverrideExpression(i,t,"ScaleX",s),angle:this._getValueOrOverrideExpression(i,t,"Rotation",I(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,t,"OffsetX",I(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,t,"OffsetY",I(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!1,hasUnresolvedReplacementColor:!1})}_analyzeHatchFill(e,r){const{primitiveName:t,type:i}=e,o=this._analyzeMaterialOverrides(t,["Rotation","OffsetX","OffsetY"]),a=L(o);let s=[255,255,255,1],l=!1;if(e.lineSymbol?.symbolLayers)for(const p of e.lineSymbol.symbolLayers){if("CIMSolidStroke"!==p.type)continue;const e=p.primitiveName??t;l||!e||p.colorLocked||null==this._poMap[e]?.Color&&null==this._poMap[e]?.StrokeColor||(s=P(p.color),s=this._maybeGetValueOrOverrideExpression(e,"StrokeColor")??this._getValueOrOverrideExpression(i,e,"Color",s),l=!0);const r=this._maybeGetValueOrOverrideExpression(e,"StrokeWidth");if(r){let t=null,o=null;"number"==typeof r?t=r:o=r.valueExpressionInfo;let s=a.find((e=>"strokeWidth"===e.propertyName));s?s.propertyName="width":(s={type:"CIMPrimitiveOverride",primitiveName:e,propertyName:"width",valueExpressionInfo:o,value:t,defaultValue:V(i,"width")},a.push(s))}}const n={type:"sprite-rasterization-param",resource:e,overrides:a};this._cimLayers.push({type:"fill",spriteRasterizationParam:n,colorLocked:!!e.colorLocked,effects:r,color:s,height:this._getValueOrOverrideExpression(i,t,"Separation",I(e.separation,v.CIMHatchFill.separation)),scaleX:1,angle:this._getValueOrOverrideExpression(i,t,"Rotation",I(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,t,"OffsetX",I(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,t,"OffsetY",I(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!l})}_analyzeGradientFill(e,r){const{angle:t,gradientMethod:i,gradientSize:o,gradientSizeUnits:a,gradientType:s,interval:l,primitiveName:n,type:p}=e,c=v.CIMGradientFill,m=e.colorRamp;this._cimLayers.push({type:"gradientFill",spriteRasterizationParam:{type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(n,p)},colorLocked:!1,effects:r,color:[255,255,255,1],gradientMethod:this._getValueOrOverrideExpression(p,n,"GradientMethod",i??"Linear"),angle:this._getValueOrOverrideExpression(p,n,"Angle",I(t,c.angle)),gradientType:this._getValueOrOverrideExpression(p,n,"GradientType",s??c.gradientType),interval:this._getValueOrOverrideExpression(p,n,"Interval",I(l,"CIMFixedColorRamp"===m.type?m.colors.length:c.interval)),gradientSize:this._getValueOrOverrideExpression(p,n,"GradientSize",I(o,c.gradientSize)),gradientSizeUnits:"Absolute"===a?g.Absolute:"Relative"===a?g.Relative:c.gradientSizeUnits})}_analyzeSolidStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=P(e.color),l=I(e.width,v.CIMSolidStroke.width),n=N(e.capStyle,v.CIMSolidStroke.capstyle),p=N(e.joinStyle,v.CIMSolidStroke.joinstyle),c=e.miterLimit;let m,y,d,h,f=[];if(this._analyzePrimitiveOverrides(o,r,null,null)&&(f=this._getPrimitiveMaterialOverrides(o,a)),r&&Array.isArray(r)&&r.length>0){const e=r[r.length-1].effect;e&&"CIMGeometricEffectDashes"===e.type&&"NoConstraint"===e.lineDashEnding&&(m=e.dashTemplate,y=e.scaleDash,d=e.offsetAlongLine,h=e.primitiveName,(r=[...r]).pop())}null!=h&&f.push(...this._getPrimitiveMaterialOverrides(h,a).filter((e=>"dashTemplate"===e.propertyName)));const u=void 0!==m?{type:"sprite-rasterization-param",resource:{type:"dash",dashTemplate:m,primitiveName:h},overrides:f}:null;this._cimLayers.push({type:"line",spriteRasterizationParam:u,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(a,o,"Color",s),width:this._getValueOrOverrideExpression(a,o,"Width",l),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",n),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",p),miterLimit:c&&this._getValueOrOverrideExpression(a,o,"MiterLimit",c),referenceWidth:i,zOrder:K(e.name),dashTemplate:this._maybeGetValueOrOverrideExpression(h,"DashTemplate")??m,offsetAlongLine:this._getValueOrOverrideExpression(a,h,"OffsetAlongLine",d??0),scaleDash:y,sampleAlphaOnly:!0})}_analyzePictureStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=E(e),l=I(e.width,v.CIMPictureStroke.width),n=N(e.capStyle,v.CIMPictureStroke.capstyle),p=N(e.joinStyle,v.CIMPictureStroke.joinstyle),c=e.miterLimit,m={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(o,a)};this._cimLayers.push({type:"line",spriteRasterizationParam:m,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(a,o,"TintColor",s),width:this._getValueOrOverrideExpression(a,o,"Width",l),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",n),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",p),miterLimit:c&&this._getValueOrOverrideExpression(a,o,"MiterLimit",c),referenceWidth:i,zOrder:K(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}_analyzeGradientStroke(e,r,t,i){const{gradientMethod:o,gradientSize:a,gradientSizeUnits:s,gradientType:l,interval:n,primitiveName:p,type:c}=e,m=v.CIMGradientStroke,y=I(e.width,m.width),d=N(e.capStyle,m.capstyle),h=N(e.joinStyle,m.joinstyle),f=e.miterLimit,u=e.colorRamp;this._cimLayers.push({type:"gradientStroke",spriteRasterizationParam:{type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(p,c)},colorLocked:!!e.colorLocked,effects:r,color:[255,255,255,1],width:this._getValueOrOverrideExpression(c,p,"Width",y),cap:this._getValueOrOverrideExpression(c,p,"CapStyle",d),join:this._getValueOrOverrideExpression(c,p,"JoinStyle",h),miterLimit:f&&this._getValueOrOverrideExpression(c,p,"MiterLimit",f),referenceWidth:i,isOutline:t,gradientMethod:this._getValueOrOverrideExpression(c,p,"GradientMethod",o??m.gradientMethod),gradientType:this._getValueOrOverrideExpression(c,p,"GradientType",l??m.gradientType),interval:this._getValueOrOverrideExpression(c,p,"Interval",I(n,"CIMFixedColorRamp"===u.type?u.colors.length:m.interval)),gradientSize:this._getValueOrOverrideExpression(c,p,"GradientSize",I(a,m.gradientSize)),gradientSizeUnits:"Absolute"===s?g.Absolute:"Relative"===s?g.Relative:m.gradientSizeUnits})}_analyzeMarker(e,r,t,i,o,a,s,l,y,d=!1,h=!1){if(d||=!!e.colorLocked,this._analyzeMarkerInsidePolygon(e,r,d))return;const f=I(e.size,v.CIMVectorMarker.size),u=I(e.rotation),O=I(e.offsetX),g=I(e.offsetY),{primitiveName:_,type:M}=e,S=this._getValueOrOverrideExpression(M,_,"Size",f),k=this._getValueOrOverrideExpression(M,_,"Rotation",u),b=this._getValueOrOverrideExpression(M,_,"OffsetX",O),C=this._getValueOrOverrideExpression(M,_,"OffsetY",g);let P=y;switch(P=p(e,P),P=c(this._poMap,e,P),P=m(e,P),P=n(this._poMap,e,P),e.type){case"CIMPictureMarker":this._analyzePictureMarker(e,r,t,i,o,a,S,k,b,C,l,P,d,h);break;case"CIMVectorMarker":this._analyzeVectorMarker(e,r,t,i,o,a,S,k,b,C,l,P,s,d,h)}}_analyzeMarkerInsidePolygon(e,r,t){const{markerPlacement:i,type:o}=e;if(!i||"CIMMarkerPlacementInsidePolygon"!==i.type)return!1;if("CIMVectorMarker"===o||"CIMPictureMarker"===o){const t=e.primitiveName;if(t&&this._analyzePrimitiveOverrides([t],r,null,null))return!1;const a=i.primitiveName;if(a&&this._analyzePrimitiveOverrides([a],r,null,null))return!1;if("CIMVectorMarker"===o){const{markerGraphics:r}=e;if(r)for(const e of r){const{symbol:r}=e;if("CIMPolygonSymbol"===r?.type&&r.symbolLayers){const{symbolLayers:e}=r;for(const r of e)if("CIMSolidStroke"===r.type)return!1}}}else{const{animatedSymbolProperties:r}=e;if(r)return!1}}const s=Math.abs(i.stepX),l=Math.abs(i.stepY);if(0===s||0===l)return!0;let n,p;if("Random"===i.gridType){const e=a(D),r=Math.max(Math.floor(e/s),1);n=l*Math.max(Math.floor(e/l),1);p=r*s/n}else i.shiftOddRows?(n=2*l,p=s/l*.5):(n=l,p=s/l);const c=E(e),m="CIMCharacterMarker"===e.type?null:{type:"sprite-rasterization-param",resource:e,overrides:[]};return this._cimLayers.push({type:"fill",spriteRasterizationParam:m,colorLocked:t,effects:r,color:c,height:n,scaleX:p,angle:i.gridAngle,offsetX:I(i.offsetX),offsetY:I(i.offsetY),applyRandomOffset:"Random"===i.gridType,sampleAlphaOnly:"CIMPictureMarker"!==e.type,hasUnresolvedReplacementColor:!0}),!0}_analyzePictureMarker(e,r,i,o,a,l,n,p,c,m,y,d,h,f){const{animatedSymbolProperties:u,primitiveName:v,type:O}=e;let g=I(e.scaleX,1);const _=E(e);i||(i=this._createMarkerPlacementOverrideExpression(e.markerPlacement));const M=this._createGIFAnimatedSymbolPropertiesOverrideExpression(u),S=e.anchorPoint??{x:0,y:0};if("width"in e&&"number"==typeof e.width){const r=e.width;let t=1;const i=this._resourceManager.getResource(e.url);null!=i&&(t=i.width/i.height);g/=t*(I(e.size)/r)}const k=[...o];let b;e.primitiveName&&k.push(e.primitiveName),u||M?b={type:"animated",url:e.url,urlHash:"H"+s(e.url),playAnimation:e.animatedSymbolProperties?.playAnimation,reverseAnimation:e.animatedSymbolProperties?.reverseAnimation,randomizeStartTime:e.animatedSymbolProperties?.randomizeStartTime,randomizeStartSeed:e.animatedSymbolProperties?.randomizeStartSeed,startTimeOffset:e.animatedSymbolProperties?.startTimeOffset,duration:e.animatedSymbolProperties?.duration,repeatType:e.animatedSymbolProperties?.repeatType,repeatDelay:e.animatedSymbolProperties?.repeatDelay}:(b=t(e),b.markerPlacement=null);const C={type:"sprite-rasterization-param",resource:b,overrides:this._getMaterialOverrides(k,O)};M&&C.overrides.push(...M.overrides);const P=n;this._cimLayers.push({type:"marker",spriteRasterizationParam:C,colorLocked:h,effects:r,scaleSymbolsProportionally:!1,alignment:a,size:n,scaleX:this._getValueOrOverrideExpression(O,v,"ScaleX",g),rotation:p,offsetX:c,offsetY:m,transform:{type:"cim-marker-transform-param",params:y},color:this._getValueOrOverrideExpression(O,v,"TintColor",_),anchorPoint:{x:S.x,y:S.y},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,outlineColor:[0,0,0,0],outlineWidth:0,frameHeight:0,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:1,isOutline:f,markerPlacement:i,animationParams:te(d),baseSize:P})}_analyzeVectorMarker(e,r,t,i,o,a,s,l,p,c,m,f,u,v,O){const g=e.markerGraphics;if(!g)return;const _=e.frame;let M=0;M=_?_.ymax-_.ymin:a;const S=!!e.scaleSymbolsProportionally;if(M){const r={offsetX:p,offsetY:c,rotation:l,size:s,frameHeight:M,rotateClockWise:!!e.rotateClockwise,absoluteAnchorPoint:!1,scaleSymbolsProportionally:S};m=[...m,r]}t||(t=this._createMarkerPlacementOverrideExpression(e.markerPlacement));for(const k of g)if(k){const s=k.symbol;if(!s)continue;const l=k.primitiveName;l&&i.push(l);let p,c=f;if(("CIMPointSymbol"===s.type||"CIMTextSymbol"===s.type)&&_){let r=0,t=0;const i=k.geometry;"x"in i&&"y"in i&&(r+=i.x-.5*(_.xmin+_.xmax),t+=i.y-.5*(_.ymin+_.ymax));const o=e.anchorPoint;let a=!1;o&&("Absolute"===e.anchorPointUnits?(r-=o.x,t-=o.y,a=!0):_&&(r-=(_.xmax-_.xmin)*o.x,t-=(_.ymax-_.ymin)*o.y));const s={offsetX:r,offsetY:t,rotation:0,size:0,frameHeight:0,rotateClockWise:!1,absoluteAnchorPoint:a,scaleSymbolsProportionally:S};p=[...m,s]}const g=k.geometry,[b,C]=y(g,_);switch(0===b&&0===C||(c=d(c,b,C)),"CIMPointSymbol"===s.type&&(c=n(this._poMap,s,c)),s.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":u||$(s)?(c={...c,transform:{type:"AnimatedTransform",relativeTranslation:!1,absoluteScale:!0,translation:h([0,0]),rotation:h(0),scale:h(M),parent:f.transform}},this._analyzeMultiLayerGraphicNonSDF(e,r,t,k,i,o,a,p??m,c,M,v,O)):this._analyzeMultiLayerGraphic(e,r,t,k,i,o,a,p??m,c,M,v,O);break;case"CIMTextSymbol":this._analyzeTextGraphic(r,t,k,i,o,a,p??m,v)}l&&i.pop()}}_analyzeMultiLayerGraphic(e,r,t,i,o,a,s,l,n,p,c,m){const y=i.symbol.symbolLayers;y&&(!Z(y)||f(n)?ee(y)?this._analyzeMultiLayerGraphicNonSDF(e,r,t,i,o,a,s,l,n,p,!!c,m):this._analyzeMarkerGraphicSymbolLayers(e,r,t,i,o,a,s,l,n,p,c,m):this._analyzeCompositeMarkerGraphic(e,r,t,i,y,a,s,l,p,c,m))}_analyzeMarkerGraphicSymbolLayers(e,r,t,i,o,a,s,l,p,c,m,y){const d=i.symbol,h=d.symbolLayers;if(!h)return;const f=this._resourceManager.geometryEngine,u=W.applyEffects(d.effects,i.geometry,f);if(!u)return;let O=h.length;for(;O--;){const d=h[O];if(!d||!1===d.enable)continue;const g=d.primitiveName;switch(g&&o.push(g),d.type){case"CIMSolidFill":case"CIMSolidStroke":{const o=W.applyEffects(d.effects,u,f),h=S(o);if(!h)continue;const O="Relative"!==e.anchorPointUnits,_=R(d)??0,{frameSizeRatio:M,anchorX:C,anchorY:z,widthRatio:x,sdfPaddingRatio:E}=k(h,e.frame,e.size,e.anchorPoint,O,_,e.scaleSymbolsProportionally),L="CIMSolidFill"===d.type,V={type:"sdf",geom:o,sdfPaddingRatio:E,asFill:L},{path:N}=d,G=L?P(A(d)):null==N?P(w(d)):[0,0,0,0],F=L?[0,0,0,0]:P(w(d));if(!L&&!_)break;const T=i.primitiveName;let X=null;L&&!d.colorLocked&&(X=this._maybeGetValueOrOverrideExpression(T,"FillColor"));let Y=null;L||d.colorLocked||(Y=this._maybeGetValueOrOverrideExpression(T,"StrokeColor"));const j=X??this._getValueOrOverrideExpression(d.type,g,"Color",G),U=Y??this._getValueOrOverrideExpression(d.type,g,"Color",F),D=this._maybeGetValueOrOverrideExpression(T,"StrokeWidth")??this._getValueOrOverrideExpression(d.type,g,"Width",_),H=N?{type:"sprite-rasterization-param",resource:{type:"path",path:N,asFill:L},overrides:[]}:{type:"sprite-rasterization-param",resource:V,overrides:[]},J=n(this._poMap,d,p),B=I(e.size,v.CIMVectorMarker.size),q=this._getValueOrOverrideExpression(e.type,e.primitiveName,"Size",B);this._cimLayers.push({type:"marker",spriteRasterizationParam:H,colorLocked:!!d.colorLocked||!!m,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:C,y:z},isAbsoluteAnchorPoint:O,size:c,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:c,widthRatio:x,rotateClockwise:!1,referenceSize:s,sizeRatio:M,color:j,outlineColor:U,outlineWidth:D,isOutline:y,markerPlacement:t,animationParams:te(J),isStroke:"CIMSolidFill"!==d.type,baseSize:q,...b(o,E)});break}case"CIMPictureMarker":case"CIMVectorMarker":if(d.markerPlacement){H().error("Error analyzing CIM, got unexpected marker placement");break}this._analyzeMarker(d,r,t,o,a,s,!1,l,p,m,y)}g&&o.pop()}}_analyzeTextGraphic(e,t,i,o,a,s,l,n){const p=[];M.findApplicableOverrides(i,this._primitiveOverrides,p);const c=i.geometry;if(!("x"in c)||!("y"in c))return;const m=i.symbol,y=G(m),d=F(m.fontStyleName),h=r(m.fontFamilyName);m.font={family:h,decoration:y,...d};const f=I(m.height,v.CIMTextSymbol.height),u=I(m.angle),O=I(m.offsetX),g=I(m.offsetY),{haloSymbol:_}=m,S=I(m.haloSize,0);let k=[0,0,0,0];if(_?.symbolLayers?.length){const e=_.symbolLayers;for(const r of e)if(r.color){k=this._getValueOrOverrideExpression(m?.haloSymbol?.type??"CIMPolygonSymbol",r.primitiveName,"Color",P(r.color));break}}const b=i.primitiveName;let C=[0,0,0,1],z=[0,0,0,0],x=0,E=!1;if(m.symbol?.symbolLayers)for(const r of m.symbol.symbolLayers){const e=r.primitiveName;if("CIMSolidStroke"===r.type)z=this._getValueOrOverrideExpression("CIMSolidStroke",e,"Color",P(r.color)),x=this._getValueOrOverrideExpression("CIMSolidStroke",e,"Width",R(r)??0);else if("CIMSolidFill"===r.type){const t=P(r.color);E=E??!!r.colorLocked,C=this._getValueOrOverrideExpression("CIMSolidFill",e??b,"Color",t)}}let L=null,V=null,N=null,A=null,w=null;b&&(L=this._maybeGetValueOrOverrideExpression(b,"TextSize"),V=this._maybeGetValueOrOverrideExpression(b,"TextAngle"),N=this._maybeGetValueOrOverrideExpression(b,"TextOffsetX"),A=this._maybeGetValueOrOverrideExpression(b,"TextOffsetY"),E||(w=this._maybeGetValueOrOverrideExpression(b,"FillColor")));const Y=w??C;let j=null,W=null,U=0;if(m.callout&&"CIMBackgroundCallout"===m.callout.type){const e=m.callout;if(e.backgroundSymbol){const r=e.backgroundSymbol.symbolLayers;if(r)for(const e of r)"CIMSolidFill"===e.type?j=P(e.color):"CIMSolidStroke"===e.type&&(W=P(e.color),U=I(e.width,v.CIMSolidStroke.width))}}const D=this._getValueOrOverrideExpression(m.type,i.primitiveName,"TextString",i.textString??"");if(null==D)return;const{fontStyleName:H}=m,J=h+(H?"-"+H.toLowerCase():"-regular"),B=this._getMaterialOverrides(o,m.type);B.push(...this._getPrimitiveMaterialOverrides(i.primitiveName,m.type));const q={type:"text-rasterization-param",resource:{type:"text",textString:i.textString??"",font:m.font,symbol:m,primitiveName:i.primitiveName},overrides:B};this._cimLayers.push({type:"text",lineWidth:m.lineWidth,textRasterizationParam:q,colorLocked:!!n||!!E,effects:e,alignment:a,anchorPoint:{x:0,y:0},isAbsoluteAnchorPoint:!1,fontName:J,decoration:y,haloSize:S,haloColor:k,weight:d.weight,style:d.style,size:L??f,angle:V??u,offsetX:N??O,offsetY:A??g,transform:{type:"cim-marker-transform-param",params:l},horizontalAlignment:T(m.horizontalAlignment),verticalAlignment:X(m.verticalAlignment),text:D,color:Y,outlineColor:z,outlineSize:x,backgroundColor:j,borderLineColor:W,borderLineWidth:U,referenceSize:s,sizeRatio:1,markerPlacement:t})}_analyzeMultiLayerGraphicNonSDF(e,r,t,i,a,s,l,n,p,c,m,y){const d=q(e,i),h=e.primitiveName,f=this._analyzeMaterialOverrides(h,["Rotation","OffsetX","OffsetY"]),O=L(f),[g,_,M]=u.getTextureAnchor(d,this._resourceManager,U),S=this._getMaterialOverrides(a,e.type);S.push(...O);const k={type:"sprite-rasterization-param",resource:{...d,avoidSDFRasterization:!0},overrides:S},b=I(e.size,v.CIMVectorMarker.size),C=this._getValueOrOverrideExpression(e.type,h,"Size",b);this._cimLayers.push({type:"marker",spriteRasterizationParam:k,colorLocked:m,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:g,y:_},isAbsoluteAnchorPoint:!1,size:c,rotation:0,offsetX:0,offsetY:0,transform:{type:"cim-marker-transform-param",params:n},color:[255,255,255,1],outlineColor:[0,0,0,0],outlineWidth:0,scaleX:1,frameHeight:c,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:M/o(e.size),isOutline:y,markerPlacement:t,animationParams:te(p),baseSize:C})}_createMarkerPlacementOverrideExpression(e){if(!e)return null;const r=[];return M.findApplicableOverrides(e,this._primitiveOverrides,r),{type:"cim-marker-placement-param",placement:e,overrides:re(r)}}_createGIFAnimatedSymbolPropertiesOverrideExpression(e){if(!e)return null;const r=[];return M.findApplicableOverrides(e,this._primitiveOverrides,r),{type:"cim-gif-animation-params",animation:e,overrides:re(r)}}_analyzeCompositeMarkerGraphic(e,r,t,i,o,a,s,l,n,p,c){const m=i.geometry,y=o[0],d=o[1],h=S(m);if(!h)return;const f="Relative"!==e.anchorPointUnits,u=I(y.width,v.CIMSolidStroke.width),{frameSizeRatio:O,anchorX:g,anchorY:_,widthRatio:M,sdfPaddingRatio:b}=k(h,e.frame,e.size,e.anchorPoint,f,u,e.scaleSymbolsProportionally),{path:C}=d,z=d.primitiveName,x=y.primitiveName,E=i.primitiveName;let L=null;d.colorLocked||p||(L=this._maybeGetValueOrOverrideExpression(E,"FillColor"));const V=L??this._getValueOrOverrideExpression(d.type,z,"Color",P(d.color));let N=null;y.colorLocked||p||(N=this._maybeGetValueOrOverrideExpression(E,"StrokeColor"));const R=N??this._getValueOrOverrideExpression(y.type,x,"Color",P(y.color)),A=this._maybeGetValueOrOverrideExpression(E,"StrokeWidth")??this._getValueOrOverrideExpression(y.type,x,"Width",u),w={type:"sprite-rasterization-param",resource:C?{type:"path",path:C,asFill:!0}:{type:"sdf",geom:m,sdfPaddingRatio:b,asFill:!0},overrides:[]};this._cimLayers.push({type:"marker",spriteRasterizationParam:w,colorLocked:p,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:g,y:_},isAbsoluteAnchorPoint:f,size:n,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:n,widthRatio:M,rotateClockwise:!1,referenceSize:s,sizeRatio:O,color:V,outlineColor:R,outlineWidth:A,isOutline:c,markerPlacement:t})}_setPoMap(e,r,t){let i;this._poMap[e]?i=this._poMap[e]:(i={},this._poMap[e]=i),i[r]=t}_maybeGetValueOrOverrideExpression(e,r,t){return this._getValueOrOverrideExpression("",e,r,t,!1)}_getValueOrOverrideExpression(e,r,t,i,o=!0){if(o&&!Y(i)&&(i=V(e,t.toLowerCase())),null==r)return i;const a=this._poMap[r];if(null==a)return i;const s=a[t];return"string"==typeof s||"number"==typeof s||Array.isArray(s)?s:s?{valueExpressionInfo:s,defaultValue:i}:i}_analyzePrimitiveOverrides(e,r,t,i){if(null==e)return!1;"string"==typeof e&&(e=[e]);for(const o of this._primitiveOverrides)if(e.includes(o.primitiveName)&&o.valueExpressionInfo)return!0;if(null!=r)for(const o of r)if(o?.overrides.length>0)return!0;if(null!=t)for(const o of t)if(o?.overrides.length>0)return!0;if(null!=i)for(const o of i)if(o?.overrides.length>0)return!0;return!1}_getMaterialOverrides(e,r){if(!e)return[];const t=[];for(const i of e)t.push(...this._getPrimitiveMaterialOverrides(i,r));return t}_getPrimitiveMaterialOverrides(e,r){if(!e)return[];const t=L(this._primitiveOverrides.filter((r=>r.primitiveName===e)));return t.forEach((e=>e.defaultValue=V(r,e.propertyName.toLowerCase()))),t}_analyzeMaterialOverrides(e,r){return this._primitiveOverrides.filter((t=>t.primitiveName!==e||!r.includes(t.propertyName)))}}function q(e,r){return{type:e.type,enable:!0,name:e.name,colorLocked:e.colorLocked,primitiveName:e.primitiveName,anchorPoint:e.anchorPoint,anchorPointUnits:e.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:e.rotateClockwise,rotation:0,size:e.size,billboardMode3D:e.billboardMode3D,depth3D:e.depth3D,frame:e.frame,markerGraphics:[r],scaleSymbolsProportionally:e.scaleSymbolsProportionally,respectFrame:e.respectFrame,clippingPath:e.clippingPath}}function K(e){if(e&&0===e.indexOf("Level_")){const r=parseInt(e.slice(6),10);if(!isNaN(r))return r}return 0}function Q(e,r){if(!r||0===r.length)return e;const i=t(e);return M.applyOverrides(i,r),i}const Z=e=>e&&2===e.length&&e[0].enable&&e[1].enable&&"CIMSolidStroke"===e[0].type&&"CIMSolidFill"===e[1].type&&null==e[0].path&&null==e[1].path&&!e[0].effects&&!e[1].effects&&!e[0].animations&&!e[1].animations;function $(e){const r=e.symbolLayers;if(!r)return!1;const t=r.find((e=>e.effects?.find((e=>"CIMGeometricEffectDashes"===e.type&&null!=e.dashTemplate)))),i=r.find((e=>e.effects?.find((e=>"CIMGeometricEffectAddControlPoints"===e.type))));return!!t||!!i}function ee(e){return e.some((e=>"CIMSolidFill"!==e.type&&"CIMSolidStroke"!==e.type&&("CIMVectorMarker"!==e.type&&"CIMPictureMarker"!==e.type||null!=e.markerPlacement)))}function re(e){return t(e).map((e=>({...e,propertyName:j(e.propertyName)})))}function te(e){return f(e)?{type:"animation-params",params:e}:null}export{B as CIMAnalyzer,Q as analyzeCIMResource};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
+ */
5
+ import{clone as m}from"../../core/lang.js";import{getExtent as e}from"./SDFHelper.js";import{CIMEffectHelper as r}from"./effects/CIMEffectHelper.js";const a=.01;function t(t,f){if(!t.frame)return t;const{markerGraphics:n}=t;if(!n||0===n.length)return t;let o=0,s=0,i=0,x=0;for(const m of n){const{geometry:a,symbol:t}=m;if(!a||!t||!("symbolLayers"in t))continue;const{symbolLayers:n}=t;if(n)for(const m of n){const{effects:t}=m,n=r.applyEffects(t,a,f),c=e(n);c&&(o=Math.min(o,c[0]),s=Math.min(s,c[1]),i=Math.max(i,c[2]),x=Math.max(x,c[3]))}}const{xmin:c,ymin:y,xmax:p,ymax:h}=t.frame,l=(p-c)/2,M=(h-y)/2,u=(p+c)/2,b=(h+y)/2,g=(u-o)/l,j=(i-u)/l,E=(b-s)/M,F=(x-b)/M,H=Math.max(Math.max(g,j),Math.max(E,F));return H<=1+a?t:(t=m(t)).frame?(t.frame.xmin=(t.frame.xmin-u)*H+u,t.frame.ymin=(t.frame.ymin-b)*H+b,t.frame.xmax=(t.frame.xmax-u)*H+u,t.frame.ymax=(t.frame.ymax-b)*H+b,!1!==t.respectFrame&&(t.size*=H),t):t}export{t as fitVectorMarker};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{px2pt as e,pt2px as t}from"../../core/screenUtils.js";import{CIMSymbolHelper as i}from"../cim/CIMSymbolHelper.js";import{CIMSymbolRasterizer as l}from"../cim/CIMSymbolRasterizer.js";import{OverrideHelper as r}from"../cim/OverrideHelper.js";import{mapCIMSymbolToGeometryType as n}from"../cim/utils.js";import{SymbolSizeDefaults as a}from"./previewUtils.js";import{renderSymbol as o}from"./renderUtils.js";const s=new l(null),c=e(a.size),m=e(a.maxSize),u=e(a.lineWidth),f=1;async function h(e,t,i){const l=t?.size;let r=null!=l&&"object"==typeof l&&"width"in l?l.width:l,n=null!=l&&"object"==typeof l&&"height"in l?l.height:l;if(null==r||null==n)if("esriGeometryPolygon"===i)r=c,n=c;else{const l=await y(e,t,i);l&&(r=l.width,n=l.height),"esriGeometryPolyline"===i&&(r=u),r=null!=r&&isFinite(r)?Math.min(r,m):c,n=null!=n&&isFinite(n)?Math.max(Math.min(n,m),f):c}return"legend"===t.style&&"esriGeometryPolyline"===i&&(r=u),{width:r,height:n}}async function y(e,t,l){const{feature:n,fieldMap:a,viewParams:o}=t.cimOptions||t,c=await r.resolveSymbolOverrides(e.data,n,null,a,l,null,o);if(!c)return null;(e=e.clone()).data={type:"CIMSymbolReference",symbol:c},e.data.primitiveOverrides=void 0;const m=[];return i.fetchResources(c,s.resourceManager,m),i.fetchFonts(c,s.resourceManager,m),m.length>0&&await Promise.all(m),i.getEnvelope(c,null,s.resourceManager)}async function p(e,i={}){const{node:l,opacity:r,symbolConfig:a}=i,c=null!=a&&"object"==typeof a&&"isSquareFill"in a&&a.isSquareFill,m=i.cimOptions||i,u=m.geometryType||n(e?.data?.symbol),f=await h(e,i,u),{feature:y,fieldMap:p}=m,d=c||"esriGeometryPolygon"!==u?"preview":"legend",g=await s.rasterizeCIMSymbolAsync(e,y,f,d,p,u,null,m.viewParams,m.allowScalingUp);if(!g)return null;const{width:w,height:b}=g,v=document.createElement("canvas");v.width=w,v.height=b;v.getContext("2d").putImageData(g,0,0);const M=t(f.width),j=t(f.height),S=new Image(M,j);S.src=v.toDataURL(),S.ariaLabel=i.ariaLabel??null,S.alt=i.ariaLabel??"",null!=r&&(S.style.opacity=`${r}`);let C=S;if(null!=i.effectView){const e={shape:{type:"image",x:0,y:0,width:M,height:j,src:S.src},fill:null,stroke:null,offset:[0,0]};C=o([[e]],[M,j],{effectView:i.effectView,ariaLabel:i.ariaLabel})}return l&&C&&l.appendChild(C),C}export{p as previewCIMSymbol};
5
+ import{px2pt as e,pt2px as i}from"../../core/screenUtils.js";import{CIMSymbolHelper as t}from"../cim/CIMSymbolHelper.js";import{CIMSymbolRasterizer as l}from"../cim/CIMSymbolRasterizer.js";import{OverrideHelper as a}from"../cim/OverrideHelper.js";import{mapCIMSymbolToGeometryType as r}from"../cim/utils.js";import{SymbolSizeDefaults as n}from"./previewUtils.js";import{renderSymbol as o}from"./renderUtils.js";const s=new l(null),m=e(n.size),c=e(n.maxSize),u=e(n.lineWidth),f=1;async function h(e,i,t){const l=i?.size;let a=null!=l&&"object"==typeof l&&"width"in l?l.width:l,r=null!=l&&"object"==typeof l&&"height"in l?l.height:l;if(null==a||null==r)if("esriGeometryPolygon"===t)a=r=i.maxSize?Math.min(i.maxSize,m):m;else{const l=await y(e,i,t);l&&(a=l.width,r=l.height),"esriGeometryPolyline"===t&&(a=i.maxSize?Math.min(i.maxSize,u):u),a=null!=a&&isFinite(a)?Math.min(a,c):m,r=null!=r&&isFinite(r)?Math.max(Math.min(r,c),f):m}return"legend"===i.style&&"esriGeometryPolyline"===t&&(a=u),{width:a,height:r}}async function y(e,i,l){const{feature:r,fieldMap:n,viewParams:o}=i.cimOptions||i,m=await a.resolveSymbolOverrides(e.data,r,null,n,l,null,o);if(!m)return null;(e=e.clone()).data={type:"CIMSymbolReference",symbol:m},e.data.primitiveOverrides=void 0;const c=[];return t.fetchResources(m,s.resourceManager,c),t.fetchFonts(m,s.resourceManager,c),c.length>0&&await Promise.all(c),t.getEnvelope(m,null,s.resourceManager)}async function p(e,t={}){const{node:l,opacity:a,symbolConfig:n}=t,m=null!=n&&"object"==typeof n&&"isSquareFill"in n&&n.isSquareFill,c=t.cimOptions||t,u=c.geometryType||r(e?.data?.symbol),f=await h(e,t,u),{feature:y,fieldMap:p}=c,d=m||"esriGeometryPolygon"!==u?"preview":"legend",g=await s.rasterizeCIMSymbolAsync(e,y,f,d,p,u,null,c.viewParams,c.allowScalingUp);if(!g)return null;const{width:w,height:b}=g,M=document.createElement("canvas");M.width=w,M.height=b;M.getContext("2d").putImageData(g,0,0);const S=i(f.width),v=i(f.height),j=new Image(S,v);j.src=M.toDataURL(),j.ariaLabel=t.ariaLabel??null,j.alt=t.ariaLabel??"",null!=a&&(j.style.opacity=`${a}`);let x=j;if(null!=t.effectView){const e={shape:{type:"image",x:0,y:0,width:S,height:v,src:j.src},fill:null,stroke:null,offset:[0,0]};x=o([[e]],[S,v],{effectView:t.effectView,ariaLabel:t.ariaLabel})}return l&&x&&l.appendChild(x),x}export{p as previewCIMSymbol};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../config.js";import t from"../../../../request.js";import{bidiText as i}from"../../../../core/BidiText.js";import s from"../../../../core/Error.js";import{getFullyQualifiedFontName as r}from"../../../../core/fontUtils.js";import has from"../../../../core/has.js";import a from"../../../../core/Logger.js";import{throwIfAborted as n,isAbortError as o}from"../../../../core/promiseUtils.js";import{QueueProcessor as c}from"../../../../core/QueueProcessor.js";import{pt2px as h}from"../../../../core/screenUtils.js";import{numericHash as l}from"../../../../core/string.js";import u from"../../../../symbols/cim/CIMResourceManager.js";import{CIMSymbolHelper as p}from"../../../../symbols/cim/CIMSymbolHelper.js";import m from"../../../../symbols/cim/Rasterizer.js";import{normalizeDashTemplate as d}from"../../../../symbols/cim/utils.js";import{svgSdfTextureInnerSize as g,textureBindingSpriteAtlas as f,textureBindingGlyphAtlas as y}from"./definitions.js";import{MosaicType as M}from"./enums.js";import _ from"./GlyphMosaic.js";import I from"./GlyphSource.js";import w from"./Rect.js";import S from"./SDFConverter.js";import z from"./SpriteMosaic.js";import{charCodes as R,discardUrlIfHasUrlHash as T,isSVGImage as C}from"./Utils.js";import{AnimatableTextureResource as P}from"./animatedFormats/AnimatableTextureResource.js";import{AnimationStore as x}from"./animations/store/AnimationStore.js";import{TextureSamplingMode as b}from"../../../webgl/enums.js";const j="arial-unicode-ms-regular",v=()=>a.getLogger("esri.views.2d.engine.webgl.TextureManager"),$=(e,t,i)=>v().error(new s(e,t,i));class k{static fromMosaic(e,t){return new k(e,t.page,t.sdf,t.samplingMode)}constructor(e,t,i,s){this.mosaicType=e,this.page=t,this.sdf=i,this.samplingMode=s}}class A{constructor(i){this._requestRender=i,this._resourceManager=new u,this._invalidFontsMap=new Map,this._sdfConverter=new S(g),this._bindingInfos=new Array,this._hashToBindingIndex=new Map,this._ongoingRasterizations=new Map,this._imageRequestQueue=new c({concurrency:10,process:async(e,i)=>{n(i);try{return await t(e,{responseType:"image",signal:i})}catch(r){if(!o(r))throw new s("mapview-invalid-resource",`Could not fetch requested resource at ${e}`,r);throw r}}}),this.animationStore=new x,this._spriteMosaic=new z(2048,2048,500),this._glyphSource=new I(`${e.fontsUrl}/{fontstack}/{range}.pbf`),this._glyphMosaic=new _(1024,1024,this._glyphSource),this._rasterizer=new m(this.resourceManager)}dispose(){this._spriteMosaic.dispose(),this._glyphMosaic.dispose(),this._rasterizer.dispose(),this._sdfConverter.dispose(),this._spriteMosaic=null,this._glyphMosaic=null,this._sdfConverter=null,this._hashToBindingIndex.clear(),this._hashToBindingIndex=null,this._bindingInfos=null,this._ongoingRasterizations.clear(),this._ongoingRasterizations=null,this._imageRequestQueue.clear(),this._imageRequestQueue=null,this._resourceManager.destroy(),this.animationStore.destroy()}get sprites(){return this._spriteMosaic}get glyphs(){return this._glyphMosaic}get resourceManager(){return this._resourceManager}async rasterizeItem(e,t){if(null==e)return $("mapview-null-resource","Unable to rasterize null resource"),null;if("animation-info"===e.type){const{resource:t}=e,i=this.animationStore.add(t),{location:s}=i;return{rect:new w(s.column,s.row,t.length,1),page:s.page,type:"sprite",width:t.length,height:1,rasterizationScale:1,sdfPaddingRatio:.5,samplingMode:"Linear",sdfDecodeCoeff:1,simplePattern:!1}}if("cim-rasterization-info"!==e.type)return $("mapview-unexpected-resource","Unable to rasterize resource"),null;const{resource:i}=e;if("text"===i.type){const e=await this._rasterizeText(i,t);for(const t of e.glyphs)this._setTextureBinding(M.GLYPH,t);return e}const s=await this._rasterizeSprite(i,t);return s&&this._setTextureBinding(M.SPRITE,s),s}getMosaicInfo(e,t,i=!1){const s=this._getTextureBindingInfo(e,t,i);return s?{size:s.size,texture:{texture:s.texture,unit:"sprite"===s.type?f:y}}:($("mapview-invalid-resource",`Unable to find resource for ${t}`),{size:[0,0],texture:{texture:null,unit:0}})}_getTextureBindingInfo(e,t,i){const s=this._bindingInfos[t-1],r=s.page,a="Nearest"===s.samplingMode?b.NEAREST:i?b.LINEAR_MIPMAP_LINEAR:b.LINEAR;switch(s.mosaicType){case M.SPRITE:{const t=[this.sprites.getWidth(r),this.sprites.getHeight(r)],i=this._spriteMosaic.getTexture(e,r);return i.setSamplingMode(a),{type:"sprite",texture:i,size:t}}case M.GLYPH:{const t=[this.glyphs.width,this.glyphs.height],i=this._glyphMosaic.getTexture(e,r);return this._glyphMosaic.bind(e,a,r,y),i.setSamplingMode(a),{type:"glyph",texture:i,size:t}}default:return $("mapview-texture-manager",`Cannot handle unknown type ${s.mosaicType}`),null}}_hashMosaic(e,t){return 1|e<<1|(t.sdf?1:0)<<2|("Nearest"===t.samplingMode?1:0)<<3|t.page<<4}_setTextureBinding(e,t){const i=this._hashMosaic(e,t);if(!this._hashToBindingIndex.has(i)){const s=k.fromMosaic(e,t),r=this._bindingInfos.length+1;this._hashToBindingIndex.set(i,r),this._bindingInfos.push(s)}t.textureBinding=this._hashToBindingIndex.get(i)}async _rasterizeText(e,t){const{font:s,textString:a}=e,n=r(s),o=this._invalidFontsMap.has(n),[c,h]=i(a),l=R(c);try{const e=o?j:n;has("esri-2d-stabilize-glyphs")&&await this._glyphMosaic.preloadASCIIGlyphCache(e);return{type:"glyphs",glyphs:await this._glyphMosaic.getGlyphItems(e,l,t),isRightToLeft:h}}catch(u){$("mapview-invalid-resource",`Couldn't find font ${n}. Falling back to Arial Unicode MS Regular`),this._invalidFontsMap.set(n,!0);return{type:"glyphs",glyphs:await this._glyphMosaic.getGlyphItems(j,l,t),isRightToLeft:h}}}_hashSpriteResource(e){switch(e.type){case"path":return`path:${e.path}.${e.asFill?1:0}`;case"CIMPictureMarker":return`${e.type}:${e.url}:${e.size}`;case"CIMPictureFill":return`${e.type}:${e.url}:${e.height}`;case"CIMPictureStroke":return`${e.type}:${e.url}:${e.width}`;case"dash":return`dash:${e.capStyle}.${d(e.dashTemplate).join("")}`;case"sdf":return`sdf:${JSON.stringify(e.geom)}.${e.asFill?1:0}`;case"fill-style":return`fill_style:${e.style}`;case"animated":return JSON.stringify(T(e));case"CIMGradientFill":case"CIMGradientStroke":return`gradient:${JSON.stringify(e.colorRamp)}.${e.gradientType}.${e.interval}`;case"CIMHatchFill":case"CIMVectorMarker":return JSON.stringify(e)}}async _rasterizeSprite(e,t){if(!e)return null;const i=l(this._hashSpriteResource(e));if(this._spriteMosaic.has(i))return this._spriteMosaic.getSpriteItem(i);if("url"in e&&e.url||"CIMPictureFill"===e.type||"CIMPictureStroke"===e.type||"CIMPictureMarker"===e.type||"CIMVectorMarker"===e.type){const t=[];p.fetchResources({type:"CIMPointSymbol",symbolLayers:[e]},this._resourceManager,t),t.length>0&&await Promise.all(t)}switch(e.type){case"CIMPictureMarker":return"CIMMarkerPlacementInsidePolygon"===e.markerPlacement?.type?this._rasterizeJSONResource(i,e):this._handleAsyncResource(i,e,t);case"animated":case"CIMPictureFill":case"CIMPictureStroke":case"path":return this._handleAsyncResource(i,e,t);case"CIMGradientFill":case"CIMGradientStroke":case"CIMHatchFill":case"CIMVectorMarker":case"dash":case"fill-style":case"sdf":return this._rasterizeJSONResource(i,e)}}_rasterizeJSONResource(e,t){const i=this._rasterizer.rasterizeJSONResource(t);if(i){const{size:s,image:r,sdf:a,simplePattern:n,rasterizationScale:o,samplingMode:c,sdfPaddingRatio:h,sdfDecodeCoeff:l}=i;return this._addItemToMosaic(e,s,{type:"static",data:r},F(t),a,n,o,c,h,l)}return null}async _handleAsyncResource(e,t,i){if(this._ongoingRasterizations.has(e))return this._ongoingRasterizations.get(e);let s;return s="path"===t.type?this._handleSVG(t,e,i):this._handleImage(t,e,i),this._ongoingRasterizations.set(e,s),s.finally((()=>this._ongoingRasterizations.delete(e))),s}async _handleSVG(e,t,i){const s=[g,g],{asFill:r}=e,a=await this._sdfConverter.draw(e.path,r,i);return this._addItemToMosaic(t,s,{type:"static",data:new Uint32Array(a.buffer)},!1,!0,!0)}async _handleGIFOrPNG(e,t,i){const s=e.url,r=this.resourceManager.getResource(s);if(null==r)return null;const{width:a,height:n}=r;if(r instanceof HTMLImageElement){if("animated"===e.type)return $("mapview-unexpected-resource","Attempt to configure animations for a non-animated image."),null;const i="colorSubstitutions"in e?e.colorSubstitutions:void 0,{size:s,sdf:o,image:c}=this._rasterizer.rasterizeImageResource(a,n,r,i);return this._addItemToMosaic(t,s,{type:"static",data:c},F(e),o,!1)}let o,c,h;"animated"===e.type?(o=!1,c={type:"CIMAnimatedSymbolProperties",playAnimation:e.playAnimation,reverseAnimation:e.reverseAnimation,randomizeStartTime:e.randomizeStartTime,randomizeStartSeed:e.randomizeStartSeed,startTimeOffset:e.startTimeOffset,duration:e.duration,repeatType:e.repeatType,repeatDelay:e.repeatDelay},h=e.startGroup||0):(o=F(e),c={type:"CIMAnimatedSymbolProperties"},h=0);const l=new P(r,this._requestRender,c,h);return this._addItemToMosaic(t,[l.width,l.height],{type:"animated",data:l},o,!1,!1)}async _handleImage(e,t,i){const r=e.url;if(N(r)||L(r))return this._handleGIFOrPNG(e,t,i);if("animated"===e.type)return $("mapview-unexpected-resource","Attempt to configure animations for a non-animated image."),null;try{let s;const a=this.resourceManager.getResource(r);if(null!=a&&a instanceof HTMLImageElement)s=a;else{const{data:e}=await this._imageRequestQueue.push(r,{...i});s=e}if(C(r))if("width"in e&&"height"in e)s.width=h(e.width),s.height=h(e.height);else if("cim"in e){const t=e;s.width=h(t.width??t.scaleX*t.size),s.height=h(t.size)}if(!s.width||!s.height)return null;const n=s.width,o=s.height,c="colorSubstitutions"in e?e.colorSubstitutions:void 0,{size:l,sdf:u,image:p}=this._rasterizer.rasterizeImageResource(n,o,s,c);return this._addItemToMosaic(t,l,{type:"static",data:p},F(e),u,!1)}catch($){if(!o($))throw new s("mapview-invalid-resource",`Could not fetch requested resource at ${r}. ${$.message}`);throw $}}_addItemToMosaic(e,t,i,s,r,a,n,o,c,h){return this._spriteMosaic.addSpriteItem(e,t,i,s,r,a,n,o,c,h)}}function F(e){switch(e.type){case"CIMVectorMarker":case"CIMPictureMarker":return O(e);default:return!0}}const G=e=>null!=e&&e.startsWith("data:image/gif"),N=e=>e&&(e.includes(".gif")||G(e)),B=e=>null!=e&&e.startsWith("data:image/png"),L=e=>e&&(e.includes(".png")||B(e)),O=e=>e&&"markerPlacement"in e&&e.markerPlacement&&"CIMMarkerPlacementInsidePolygon"===e.markerPlacement.type;export{A as default};
5
+ import e from"../../../../config.js";import t from"../../../../request.js";import{bidiText as i}from"../../../../core/BidiText.js";import s from"../../../../core/Error.js";import{getFullyQualifiedFontName as r}from"../../../../core/fontUtils.js";import has from"../../../../core/has.js";import a from"../../../../core/Logger.js";import{throwIfAborted as n,isAbortError as o}from"../../../../core/promiseUtils.js";import{QueueProcessor as c}from"../../../../core/QueueProcessor.js";import{pt2px as h}from"../../../../core/screenUtils.js";import{numericHash as l}from"../../../../core/string.js";import u from"../../../../symbols/cim/CIMResourceManager.js";import{CIMSymbolHelper as p}from"../../../../symbols/cim/CIMSymbolHelper.js";import m from"../../../../symbols/cim/Rasterizer.js";import{normalizeDashTemplate as d}from"../../../../symbols/cim/utils.js";import{svgSdfTextureInnerSize as g,textureBindingSpriteAtlas as f,textureBindingGlyphAtlas as y}from"./definitions.js";import{MosaicType as M}from"./enums.js";import _ from"./GlyphMosaic.js";import I from"./GlyphSource.js";import w from"./Rect.js";import S from"./SDFConverter.js";import z from"./SpriteMosaic.js";import{charCodes as R,discardUrlIfHasUrlHash as T,isSVGImage as C}from"./Utils.js";import{AnimatableTextureResource as P}from"./animatedFormats/AnimatableTextureResource.js";import{AnimationStore as x}from"./animations/store/AnimationStore.js";import{TextureSamplingMode as b}from"../../../webgl/enums.js";const j="arial-unicode-ms-regular",v=()=>a.getLogger("esri.views.MapView"),$=(e,t,i)=>v().error(new s(e,t,i)),A=(e,t="")=>v().warnOnce(e,t);class k{static fromMosaic(e,t){return new k(e,t.page,t.sdf,t.samplingMode)}constructor(e,t,i,s){this.mosaicType=e,this.page=t,this.sdf=i,this.samplingMode=s}}class F{constructor(i){this._requestRender=i,this._resourceManager=new u,this._invalidFontsMap=new Map,this._sdfConverter=new S(g),this._bindingInfos=new Array,this._hashToBindingIndex=new Map,this._ongoingRasterizations=new Map,this._imageRequestQueue=new c({concurrency:10,process:async(e,i)=>{n(i);try{return await t(e,{responseType:"image",signal:i})}catch(r){if(!o(r))throw new s("mapview-invalid-resource",`Could not fetch requested resource at ${e}`,r);throw r}}}),this.animationStore=new x,this._spriteMosaic=new z(2048,2048,500),this._glyphSource=new I(`${e.fontsUrl}/{fontstack}/{range}.pbf`),this._glyphMosaic=new _(1024,1024,this._glyphSource),this._rasterizer=new m(this.resourceManager)}dispose(){this._spriteMosaic.dispose(),this._glyphMosaic.dispose(),this._rasterizer.dispose(),this._sdfConverter.dispose(),this._spriteMosaic=null,this._glyphMosaic=null,this._sdfConverter=null,this._hashToBindingIndex.clear(),this._hashToBindingIndex=null,this._bindingInfos=null,this._ongoingRasterizations.clear(),this._ongoingRasterizations=null,this._imageRequestQueue.clear(),this._imageRequestQueue=null,this._resourceManager.destroy(),this.animationStore.destroy()}get sprites(){return this._spriteMosaic}get glyphs(){return this._glyphMosaic}get resourceManager(){return this._resourceManager}async rasterizeItem(e,t){if(null==e)return $("mapview-null-resource","Unable to rasterize null resource"),null;if("animation-info"===e.type){const{resource:t}=e,i=this.animationStore.add(t),{location:s}=i;return{rect:new w(s.column,s.row,t.length,1),page:s.page,type:"sprite",width:t.length,height:1,rasterizationScale:1,sdfPaddingRatio:.5,samplingMode:"Linear",sdfDecodeCoeff:1,simplePattern:!1}}if("cim-rasterization-info"!==e.type)return $("mapview-unexpected-resource","Unable to rasterize resource"),null;const{resource:i}=e;if("text"===i.type){const e=await this._rasterizeText(i,t);for(const t of e.glyphs)this._setTextureBinding(M.GLYPH,t);return e}const s=await this._rasterizeSprite(i,t);return s&&this._setTextureBinding(M.SPRITE,s),s}getMosaicInfo(e,t,i=!1){const s=this._getTextureBindingInfo(e,t,i);return s?{size:s.size,texture:{texture:s.texture,unit:"sprite"===s.type?f:y}}:($("mapview-invalid-resource",`Unable to find resource for ${t}`),{size:[0,0],texture:{texture:null,unit:0}})}_getTextureBindingInfo(e,t,i){const s=this._bindingInfos[t-1],r=s.page,a="Nearest"===s.samplingMode?b.NEAREST:i?b.LINEAR_MIPMAP_LINEAR:b.LINEAR;switch(s.mosaicType){case M.SPRITE:{const t=[this.sprites.getWidth(r),this.sprites.getHeight(r)],i=this._spriteMosaic.getTexture(e,r);return i.setSamplingMode(a),{type:"sprite",texture:i,size:t}}case M.GLYPH:{const t=[this.glyphs.width,this.glyphs.height],i=this._glyphMosaic.getTexture(e,r);return this._glyphMosaic.bind(e,a,r,y),i.setSamplingMode(a),{type:"glyph",texture:i,size:t}}default:return $("mapview-texture-manager",`Cannot handle unknown type ${s.mosaicType}`),null}}_hashMosaic(e,t){return 1|e<<1|(t.sdf?1:0)<<2|("Nearest"===t.samplingMode?1:0)<<3|t.page<<4}_setTextureBinding(e,t){const i=this._hashMosaic(e,t);if(!this._hashToBindingIndex.has(i)){const s=k.fromMosaic(e,t),r=this._bindingInfos.length+1;this._hashToBindingIndex.set(i,r),this._bindingInfos.push(s)}t.textureBinding=this._hashToBindingIndex.get(i)}async _rasterizeText(e,t){const{font:s,textString:a}=e,n=r(s),o=this._invalidFontsMap.has(n),[c,h]=i(a),l=R(c);try{const e=o?j:n;has("esri-2d-stabilize-glyphs")&&await this._glyphMosaic.preloadASCIIGlyphCache(e);return{type:"glyphs",glyphs:await this._glyphMosaic.getGlyphItems(e,l,t),isRightToLeft:h}}catch(u){A(`Font ${n} is not available on the web, using "Arial Unicode MS Regular"`),this._invalidFontsMap.set(n,!0);return{type:"glyphs",glyphs:await this._glyphMosaic.getGlyphItems(j,l,t),isRightToLeft:h}}}_hashSpriteResource(e){switch(e.type){case"path":return`path:${e.path}.${e.asFill?1:0}`;case"CIMPictureMarker":return`${e.type}:${e.url}:${e.size}`;case"CIMPictureFill":return`${e.type}:${e.url}:${e.height}`;case"CIMPictureStroke":return`${e.type}:${e.url}:${e.width}`;case"dash":return`dash:${e.capStyle}.${d(e.dashTemplate).join("")}`;case"sdf":return`sdf:${JSON.stringify(e.geom)}.${e.asFill?1:0}`;case"fill-style":return`fill_style:${e.style}`;case"animated":return JSON.stringify(T(e));case"CIMGradientFill":case"CIMGradientStroke":return`gradient:${JSON.stringify(e.colorRamp)}.${e.gradientType}.${e.interval}`;case"CIMHatchFill":case"CIMVectorMarker":return JSON.stringify(e)}}async _rasterizeSprite(e,t){if(!e)return null;const i=l(this._hashSpriteResource(e));if(this._spriteMosaic.has(i))return this._spriteMosaic.getSpriteItem(i);if("url"in e&&e.url||"CIMPictureFill"===e.type||"CIMPictureStroke"===e.type||"CIMPictureMarker"===e.type||"CIMVectorMarker"===e.type){const t=[];p.fetchResources({type:"CIMPointSymbol",symbolLayers:[e]},this._resourceManager,t),t.length>0&&await Promise.all(t)}switch(e.type){case"CIMPictureMarker":return"CIMMarkerPlacementInsidePolygon"===e.markerPlacement?.type?this._rasterizeJSONResource(i,e):this._handleAsyncResource(i,e,t);case"animated":case"CIMPictureFill":case"CIMPictureStroke":case"path":return this._handleAsyncResource(i,e,t);case"CIMGradientFill":case"CIMGradientStroke":case"CIMHatchFill":case"CIMVectorMarker":case"dash":case"fill-style":case"sdf":return this._rasterizeJSONResource(i,e)}}_rasterizeJSONResource(e,t){const i=this._rasterizer.rasterizeJSONResource(t);if(i){const{size:s,image:r,sdf:a,simplePattern:n,rasterizationScale:o,samplingMode:c,sdfPaddingRatio:h,sdfDecodeCoeff:l}=i;return this._addItemToMosaic(e,s,{type:"static",data:r},G(t),a,n,o,c,h,l)}return null}async _handleAsyncResource(e,t,i){if(this._ongoingRasterizations.has(e))return this._ongoingRasterizations.get(e);let s;return s="path"===t.type?this._handleSVG(t,e,i):this._handleImage(t,e,i),this._ongoingRasterizations.set(e,s),s.finally((()=>this._ongoingRasterizations.delete(e))),s}async _handleSVG(e,t,i){const s=[g,g],{asFill:r}=e,a=await this._sdfConverter.draw(e.path,r,i);return this._addItemToMosaic(t,s,{type:"static",data:new Uint32Array(a.buffer)},!1,!0,!0)}async _handleGIFOrPNG(e,t,i){const s=e.url,r=this.resourceManager.getResource(s);if(null==r)return null;const{width:a,height:n}=r;if(r instanceof HTMLImageElement){if("animated"===e.type)return $("mapview-unexpected-resource","Attempt to configure animations for a non-animated image."),null;const i="colorSubstitutions"in e?e.colorSubstitutions:void 0,{size:s,sdf:o,image:c}=this._rasterizer.rasterizeImageResource(a,n,r,i);return this._addItemToMosaic(t,s,{type:"static",data:c},G(e),o,!1)}let o,c,h;"animated"===e.type?(o=!1,c={type:"CIMAnimatedSymbolProperties",playAnimation:e.playAnimation,reverseAnimation:e.reverseAnimation,randomizeStartTime:e.randomizeStartTime,randomizeStartSeed:e.randomizeStartSeed,startTimeOffset:e.startTimeOffset,duration:e.duration,repeatType:e.repeatType,repeatDelay:e.repeatDelay},h=e.startGroup||0):(o=G(e),c={type:"CIMAnimatedSymbolProperties"},h=0);const l=new P(r,this._requestRender,c,h);return this._addItemToMosaic(t,[l.width,l.height],{type:"animated",data:l},o,!1,!1)}async _handleImage(e,t,i){const r=e.url;if(B(r)||O(r))return this._handleGIFOrPNG(e,t,i);if("animated"===e.type)return $("mapview-unexpected-resource","Attempt to configure animations for a non-animated image."),null;try{let s;const a=this.resourceManager.getResource(r);if(null!=a&&a instanceof HTMLImageElement)s=a;else{const{data:e}=await this._imageRequestQueue.push(r,{...i});s=e}if(C(r))if("width"in e&&"height"in e)s.width=h(e.width),s.height=h(e.height);else if("cim"in e){const t=e;s.width=h(t.width??t.scaleX*t.size),s.height=h(t.size)}if(!s.width||!s.height)return null;const n=s.width,o=s.height,c="colorSubstitutions"in e?e.colorSubstitutions:void 0,{size:l,sdf:u,image:p}=this._rasterizer.rasterizeImageResource(n,o,s,c);return this._addItemToMosaic(t,l,{type:"static",data:p},G(e),u,!1)}catch($){if(!o($))throw new s("mapview-invalid-resource",`Could not fetch requested resource at ${r}. ${$.message}`);throw $}}_addItemToMosaic(e,t,i,s,r,a,n,o,c,h){return this._spriteMosaic.addSpriteItem(e,t,i,s,r,a,n,o,c,h)}}function G(e){switch(e.type){case"CIMVectorMarker":case"CIMPictureMarker":return E(e);default:return!0}}const N=e=>null!=e&&e.startsWith("data:image/gif"),B=e=>e&&(e.includes(".gif")||N(e)),L=e=>null!=e&&e.startsWith("data:image/png"),O=e=>e&&(e.includes(".png")||L(e)),E=e=>e&&"markerPlacement"in e&&e.markerPlacement&&"CIMMarkerPlacementInsidePolygon"===e.markerPlacement.type;export{F 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.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../../../core/Logger.js";import{disposeMaybe as r}from"../../../../../../../core/maybe.js";import{PixelType as t,TextureWrapMode as a,RenderbufferFormat as i}from"../../../../../../webgl/enums.js";import{FramebufferObject as s}from"../../../../../../webgl/FramebufferObject.js";import{loadHeatmapTextureConfiguration as u}from"../../../../../../webgl/heatmapTextureUtils.js";import{RenderbufferDescriptor as l}from"../../../../../../webgl/RenderbufferDescriptor.js";import{Texture as o}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as n}from"../../../../../../webgl/TextureDescriptor.js";const m=()=>e.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.heatmap.HeatmapResources");class f{destroy(){this._accumulateFramebuffer=r(this._accumulateFramebuffer),this._resolveGradientTexture=r(this._resolveGradientTexture),this._prevGradientHash=null,this._qualityProfile=null}get initialized(){return null!=this._accumulateFramebuffer&&null!=this._resolveGradientTexture}get accumulateFramebuffer(){return this._accumulateFramebuffer}get resolveGradientTexture(){return this._resolveGradientTexture}loadQualityProfile(e){if(null==this._qualityProfile){const r=u(e,m());this._qualityProfile={...r,defines:{usesHalfFloatPrecision:r.dataType!==t.FLOAT}}}return this._qualityProfile}ensureAccumulateFBO(e,r,t){if(null==this._accumulateFramebuffer){const{dataType:u,samplingMode:o,pixelFormat:m,internalFormat:f}=this.loadQualityProfile(e),h=new n(r,t);h.pixelFormat=m,h.internalFormat=f,h.dataType=u,h.samplingMode=o,h.wrapMode=a.CLAMP_TO_EDGE;const c=new l(i.DEPTH_STENCIL,r,t);this._accumulateFramebuffer=new s(e,h,c)}else{const{width:e,height:a}=this._accumulateFramebuffer;e===r&&a===t||this._accumulateFramebuffer.resize(r,t)}return this._accumulateFramebuffer}ensureResolveGradientTexture(e,r,t){if(null==this._resolveGradientTexture){const r=new n;r.wrapMode=a.CLAMP_TO_EDGE,this._resolveGradientTexture=new o(e,r)}else this._prevGradientHash!==r&&(this._resolveGradientTexture.resize(t.length/4,1),this._resolveGradientTexture.setData(t),this._prevGradientHash=r);return this._resolveGradientTexture}}export{f as HeatmapResources};
5
+ import e from"../../../../../../../core/Logger.js";import{disposeMaybe as r}from"../../../../../../../core/maybe.js";import{PixelType as t,TextureWrapMode as a,RenderbufferFormat as i}from"../../../../../../webgl/enums.js";import{FramebufferObject as s}from"../../../../../../webgl/FramebufferObject.js";import{loadHeatmapTextureConfiguration as u}from"../../../../../../webgl/heatmapTextureUtils.js";import{RenderbufferDescriptor as l}from"../../../../../../webgl/RenderbufferDescriptor.js";import{Texture as o}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as n}from"../../../../../../webgl/TextureDescriptor.js";const m=()=>e.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.heatmap.HeatmapResources");class f{destroy(){this._accumulateFramebuffer=r(this._accumulateFramebuffer),this._resolveGradientTexture=r(this._resolveGradientTexture),this._prevGradientHash=null,this._qualityProfile=null}get initialized(){return null!=this._accumulateFramebuffer&&null!=this._resolveGradientTexture}get accumulateFramebuffer(){return this._accumulateFramebuffer}get resolveGradientTexture(){return this._resolveGradientTexture}loadQualityProfile(e){if(null==this._qualityProfile){const r=u(e,m());this._qualityProfile={...r,defines:{usesHalfFloatPrecision:r.dataType!==t.FLOAT}}}return this._qualityProfile}ensureAccumulateFBO(e,r,t){if(null==this._accumulateFramebuffer){const{dataType:u,samplingMode:o,pixelFormat:m,internalFormat:f}=this.loadQualityProfile(e),h=new n(r,t);h.pixelFormat=m,h.internalFormat=f,h.dataType=u,h.samplingMode=o,h.wrapMode=a.CLAMP_TO_EDGE;const c=new l(i.DEPTH_STENCIL,r,t);this._accumulateFramebuffer=new s(e,h,c)}else{const{width:e,height:a}=this._accumulateFramebuffer;e===r&&a===t||this._accumulateFramebuffer.resize(r,t)}return this._accumulateFramebuffer}ensureResolveGradientTexture(e,r,t){if(null==this._resolveGradientTexture){const r=new n;r.wrapMode=a.CLAMP_TO_EDGE,this._resolveGradientTexture=new o(e,r),this._prevGradientHash=null}return this._prevGradientHash!==r&&(this._resolveGradientTexture.resize(t.length/4,1),this._resolveGradientTexture.setData(t),this._prevGradientHash=r),this._resolveGradientTexture}}export{f as HeatmapResources};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{sqlAnd as e}from"../../../../../core/sql.js";function t(t,i,s,l){const o=null!=t.subtypeCode?`${t.subtypeField} = ${t.subtypeCode}`:null,r=e(t.definitionExpression,o),n=t.customParameters??{},a=i.displayFilterEnabled&&t.displayFilterInfo?t.displayFilterInfo.toJSON():null;return l&&(n.token=l),{type:"feature",mutable:{sourceRefreshVersion:s,availableFields:i.availableFields,dataFilter:{definitionExpression:r,displayFilter:a,customParameters:n,gdbVersion:t.gdbVersion,historicMoment:t.historicMoment?.getTime(),queryScaleRanges:t.queryScaleRanges??[],timeExtent:t.timeExtent?.toJSON()}}}}export{t as createFeatureSourceSchema};
5
+ import{sqlAnd as e}from"../../../../../core/sql.js";function t(t,i,s,l){const o=null!=t.subtypeCode?`${t.subtypeField} = ${t.subtypeCode}`:null,r=e(t.definitionExpression,o),n=t.customParameters??{},a=i.displayFilterEnabled&&t.displayFilterInfo?t.displayFilterInfo.toJSON():null;return l&&(n.token=l),{type:"feature",mutable:{sourceRefreshVersion:s,availableFields:i.availableFields,displayFilter:a,dataFilter:{definitionExpression:r,customParameters:n,gdbVersion:t.gdbVersion,historicMoment:t.historicMoment?.getTime(),queryScaleRanges:t.queryScaleRanges??[],timeExtent:t.timeExtent?.toJSON()}}}}export{t as createFeatureSourceSchema};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../request.js";import has from"../../../../../core/has.js";import{ignoreAbortErrors as t,throwIfNotAbortError as s}from"../../../../../core/promiseUtils.js";import{diff as r,hasRootDiffOnly as a,hasRootDiff as i}from"../../../../../core/accessorSupport/diffUtils.js";import{OptimizedFeature as n}from"../../../../../layers/graphics/OptimizedFeature.js";import{QueryEngine as o}from"../../../../../layers/graphics/data/QueryEngine.js";import{executeQueryForCount as d}from"../../../../../rest/query/operations/query.js";import{FeatureStoreStatistics as h}from"../FeatureStoreStatistics.js";import{FeatureSourceQueryInfo as u}from"./FeatureSourceQueryInfo.js";import{StreamMessenger as c}from"./StreamMessenger.js";import{DrillDownTileLoadStrategy as m}from"./strategies/DrillDownTileLoadStrategy.js";import{PagedTileLoadStrategy as p}from"./strategies/PagedTileLoadStrategy.js";import{ParquetLoadStrategy as l}from"./strategies/ParquetLoadStrategy.js";import{SnapshotLoadStrategy as y}from"./strategies/SnapshotLoadStrategy.js";import{StreamLoadStrategy as _}from"./strategies/StreamLoadStrategy.js";import{FeatureSourceChunkStore as g}from"./strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as f}from"../support/FeatureMetadata.js";import{UpdateTracking2D as v}from"../../support/UpdateTracking2D.js";class S{constructor(e,t,s,r){this.service=e,this._aggregateAdapter=t,this._subscriptions=s,this._connection=r,this._updateTracking=new v({debugName:"FeatureSource"}),this._didInvalidateData=!1,this._metadata=f.createFeature(e.metadata),this._store=new g(this._metadata)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy(),"memory"===this.service.type&&this.service.source.map((e=>e.close()))}get metadata(){if(!this._metadata)throw new Error("InternalError: Metadata not defined. Was update called?");return this._metadata}get store(){return this._store}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return h.from(this._store)}get updateTracking(){return this._updateTracking}get queryEngine(){if(!this._queryEngine){if(!this._schema)return null;const{dataFilter:e}=this._schema.mutable,t=this._schema.mutable.availableFields,s=this._metadata;this._queryEngine=new o({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,objectIdField:s.objectIdField,hasM:!1,hasZ:!1,spatialReference:this.service.outSpatialReference,aggregateAdapter:this._aggregateAdapter,timeInfo:s.timeInfo,definitionExpression:e.definitionExpression,availableFields:t})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}chunks(){return Array.from(this._store.chunks())}cleanupRemovedChunks(){return this._store.cleanupRemovedChunks()}onSubscribe(e){this._connection.onEvent({type:"subscribe",tile:e.tile.id});const t=this._strategy?.load(e);t&&(t.then((()=>this._connection.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._connection.onEvent({type:"error",tile:e.tile.id,error:t}))),this._updateTracking.addPromise(t))}onResume(e){this._updateTracking.addPromise(t(this._strategy?.load(e)))}onUnsubscribe(e){this._connection.onEvent({type:"unsubscribe",tile:e.tile.id}),this._strategy?.unload(e)}applyOverride(e){this._didInvalidateData=!0,this._store.applyOverride(e)}takeOverrideUpdate(){return this._store.takeOverrideUpdate()}async update(e,t){const s=e.source,n=r(this._schema?.mutable,s.mutable);if(!n)return!1;if(has("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.update`,{changes:n}),this._schema=s,this._queryEngine?.destroy(),this._queryEngine=null,"feature-service"===this.service.type&&null!=this.service.queryMetadata.lastEditDate&&(this._lastEditDate=this.service.queryMetadata.lastEditDate),null==this._streamMessenger&&"stream"===this._schema.type&&this._initStreamMessenger(),a(n,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if(("feature"===s.type||"parquet"===s.type)&&a(n,"availableFields")){if(await this._queryLastEditDateChanged()||this._didInvalidateData)this._didInvalidateData=!1,await this._updateStrategy(t);else{this._connection.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._connection.onEvent({type:"updateFieldsEnd"})}catch(o){this._connection.onEvent({type:"updateFieldsError",error:o})}}return!1}return!(!i(n,"dataFilter")&&!i(n,"sourceRefreshVersion"))&&(await this._updateStrategy(t),!0)}async addParquetFile(e){this._strategy.addParquetFile(e)}unsafeSetQueryHistoricMoment(e){"feature"===this._schema.type&&(this._schema.mutable.dataFilter.historicMoment=e,this._strategy.unsafeSetQueryHistoricMoment(new Date(e)))}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new c(this._connection))}async normalizeOverrides(e){const t={historicMoment:e.historicMoment,commands:{updateWeak:e.commands.updateWeak.map(n.fromJSON),removeWeak:e.commands.removeWeak,update:e.commands.update.map(n.fromJSON),remove:e.commands.remove,release:e.commands.release}},s=e.commands.updateByIdWeak,r=await this._queryOptimizedFeatures(s);return t.commands.updateWeak.push(...r),t}async _queryOptimizedFeatures(e){if(0===e.length)return[];const t=[],s=(await this._strategy.queryByObjectId(e)).getCursor();for(;s.next();)t.push(s.readOptimizedFeatureWorldSpace());return t}getObjectIdsFromGlobalIds(e){const t=new Set(e),s=this.metadata.globalIdField;if(null==s)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");const r=[];return this._store.forEachUnsafe((e=>{const a=e.readAttribute(s);if(t.has(a)){const t=e.getObjectId();null!=t&&r.push(t)}})),r}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const t=this.service.source,s={...t.query,f:"json"},r=(await e(t.path,{query:s,responseType:"json"})).data.editingInfo.lastEditDate;return r!==this._lastEditDate&&(this._lastEditDate=r,!0)}async _createStrategy(){const e="isSourceHosted"in this.service&&this.service.isSourceHosted,t=Array.isArray(this.service.source),s=this.service.source&&"collection"in this.service.source,r=e||t||s;if("stream"===this._schema.type){const e=new _(this.service,this._schema.mutable.dataFilter,this._store,{outSR:this.service.outSpatialReference},this.metadata);return this._streamMessenger.strategy=e,e}if("parquet"===this._schema.type){const e=this.service;return new l(e,this._metadata,this._schema,this._store)}const a=this.service,i=u.fromSchema(a,this._schema,this._metadata),n=await this._supportSnapshotMode(a,i);return n?new y(a,i,this._store,n.featureCount,this.metadata,this._connection):r?new p(a,i,this._store,this.metadata,this._connection):new m(a,i,this._store,this.metadata,this._connection)}async _updateStrategy(e){const t=await this._createStrategy();this._connection.onEvent({type:"updateStrategyStart",about:t.about});const r=!!this._strategy;this._store.clear(),this._strategy?.destroy(),this._strategy=t,has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategy`,{strategy:t});const a=Array.from(this._subscriptions.values());if(!a.length)return void this._connection.onEvent({type:"updateStrategyEnd"});const i=Promise.all(a.map((e=>this._strategy.load(e).then((()=>this._connection.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._connection.onEvent({type:"error",tile:e.tile.id,error:t}))))));this._updateTracking.addPromise(i);try{r&&await i}catch(n){s(n)}this._connection.onEvent({type:"updateStrategyEnd"}),has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategyEnd`,{strategy:t})}async _supportSnapshotMode(e,t){const{queryMetadata:s}=e,r=s.snapshotInfo;if(!r||!r.supportsSnapshotMinThreshold||!r.snapshotCountThresholds)return null;const a=e.source,i=t.createQuery();i.inner.orderByFields=[],i.inner.returnGeometry=!1;const n=(await d(a,i.inner,{query:i.customParameters})).data.count,{min:o,max:h}=r.snapshotCountThresholds;return n<=o||r.supportsSnapshotMaxThreshold&&n<h?{featureCount:n}:null}}export{S as FeatureSource};
5
+ import e from"../../../../../request.js";import has from"../../../../../core/has.js";import{ignoreAbortErrors as t,throwIfNotAbortError as s}from"../../../../../core/promiseUtils.js";import{diff as r,hasRootDiffOnly as a,hasRootDiff as i}from"../../../../../core/accessorSupport/diffUtils.js";import{OptimizedFeature as n}from"../../../../../layers/graphics/OptimizedFeature.js";import{QueryEngine as o}from"../../../../../layers/graphics/data/QueryEngine.js";import{executeQueryForCount as d}from"../../../../../rest/query/operations/query.js";import{FeatureStoreStatistics as h}from"../FeatureStoreStatistics.js";import{FeatureSourceQueryInfo as u}from"./FeatureSourceQueryInfo.js";import{StreamMessenger as c}from"./StreamMessenger.js";import{DrillDownTileLoadStrategy as m}from"./strategies/DrillDownTileLoadStrategy.js";import{PagedTileLoadStrategy as p}from"./strategies/PagedTileLoadStrategy.js";import{ParquetLoadStrategy as l}from"./strategies/ParquetLoadStrategy.js";import{SnapshotLoadStrategy as y}from"./strategies/SnapshotLoadStrategy.js";import{StreamLoadStrategy as _}from"./strategies/StreamLoadStrategy.js";import{FeatureSourceChunkStore as g}from"./strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as f}from"../support/FeatureMetadata.js";import{UpdateTracking2D as v}from"../../support/UpdateTracking2D.js";class S{constructor(e,t,s,r){this.service=e,this._aggregateAdapter=t,this._subscriptions=s,this._connection=r,this._updateTracking=new v({debugName:"FeatureSource"}),this._didInvalidateData=!1,this._metadata=f.createFeature(e.metadata),this._store=new g(this._metadata)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy(),"memory"===this.service.type&&this.service.source.map((e=>e.close()))}get metadata(){if(!this._metadata)throw new Error("InternalError: Metadata not defined. Was update called?");return this._metadata}get store(){return this._store}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return h.from(this._store)}get updateTracking(){return this._updateTracking}get queryEngine(){if(!this._queryEngine){if(!this._schema)return null;const{dataFilter:e}=this._schema.mutable,t=this._schema.mutable.availableFields,s=this._metadata;this._queryEngine=new o({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,objectIdField:s.objectIdField,hasM:!1,hasZ:!1,spatialReference:this.service.outSpatialReference,aggregateAdapter:this._aggregateAdapter,timeInfo:s.timeInfo,definitionExpression:e.definitionExpression,availableFields:t})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}chunks(){return Array.from(this._store.chunks())}cleanupRemovedChunks(){return this._store.cleanupRemovedChunks()}onSubscribe(e){this._connection.onEvent({type:"subscribe",tile:e.tile.id});const t=this._strategy?.load(e);t&&(t.then((()=>this._connection.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._connection.onEvent({type:"error",tile:e.tile.id,error:t}))),this._updateTracking.addPromise(t))}onResume(e){this._updateTracking.addPromise(t(this._strategy?.load(e)))}onUnsubscribe(e){this._connection.onEvent({type:"unsubscribe",tile:e.tile.id}),this._strategy?.unload(e)}applyOverride(e){this._didInvalidateData=!0,this._store.applyOverride(e)}takeOverrideUpdate(){return this._store.takeOverrideUpdate()}async update(e,t){const s=e.source,n=r(this._schema?.mutable,s.mutable);if(!n)return!1;if(has("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.update`,{changes:n}),this._schema=s,this._queryEngine?.destroy(),this._queryEngine=null,"feature-service"===this.service.type&&null!=this.service.queryMetadata.lastEditDate&&(this._lastEditDate=this.service.queryMetadata.lastEditDate),null==this._streamMessenger&&"stream"===this._schema.type&&this._initStreamMessenger(),a(n,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if(("feature"===s.type||"parquet"===s.type)&&a(n,"availableFields")){if(await this._queryLastEditDateChanged()||this._didInvalidateData)this._didInvalidateData=!1,await this._updateStrategy(t);else{this._connection.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._connection.onEvent({type:"updateFieldsEnd"})}catch(o){this._connection.onEvent({type:"updateFieldsError",error:o})}}return!1}return!!(i(n,"dataFilter")||i(n,"sourceRefreshVersion")||this._strategy.about.supportsDisplayFilter&&i(n,"displayFilter"))&&(await this._updateStrategy(t),!0)}async addParquetFile(e){this._strategy.addParquetFile(e)}unsafeSetQueryHistoricMoment(e){"feature"===this._schema.type&&(this._schema.mutable.dataFilter.historicMoment=e,this._strategy.unsafeSetQueryHistoricMoment(new Date(e)))}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new c(this._connection))}async normalizeOverrides(e){const t={historicMoment:e.historicMoment,commands:{updateWeak:e.commands.updateWeak.map(n.fromJSON),removeWeak:e.commands.removeWeak,update:e.commands.update.map(n.fromJSON),remove:e.commands.remove,release:e.commands.release}},s=e.commands.updateByIdWeak,r=await this._queryOptimizedFeatures(s);return t.commands.updateWeak.push(...r),t}async _queryOptimizedFeatures(e){if(0===e.length)return[];const t=[],s=(await this._strategy.queryByObjectId(e)).getCursor();for(;s.next();)t.push(s.readOptimizedFeatureWorldSpace());return t}getObjectIdsFromGlobalIds(e){const t=new Set(e),s=this.metadata.globalIdField;if(null==s)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");const r=[];return this._store.forEachUnsafe((e=>{const a=e.readAttribute(s);if(t.has(a)){const t=e.getObjectId();null!=t&&r.push(t)}})),r}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const t=this.service.source,s={...t.query,f:"json"},r=(await e(t.path,{query:s,responseType:"json"})).data.editingInfo.lastEditDate;return r!==this._lastEditDate&&(this._lastEditDate=r,!0)}async _createStrategy(){const e="isSourceHosted"in this.service&&this.service.isSourceHosted,t=Array.isArray(this.service.source),s=this.service.source&&"collection"in this.service.source,r=e||t||s;if("stream"===this._schema.type){const e=new _(this.service,this._schema.mutable.dataFilter,this._store,{outSR:this.service.outSpatialReference},this.metadata);return this._streamMessenger.strategy=e,e}if("parquet"===this._schema.type){const e=this.service;return new l(e,this._metadata,this._schema,this._store)}const a=this.service,i=u.fromSchema(a,this._schema,this._metadata),n=await this._supportSnapshotMode(a,i);return n?new y(a,i,this._store,n.featureCount,this.metadata,this._connection):r?new p(a,i,this._store,this.metadata,this._connection):new m(a,i,this._store,this.metadata,this._connection)}async _updateStrategy(e){const t=await this._createStrategy();this._connection.onEvent({type:"updateStrategyStart",about:t.about});const r=!!this._strategy;this._store.clear(),this._strategy?.destroy(),this._strategy=t,has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategy`,{strategy:t});const a=Array.from(this._subscriptions.values());if(!a.length)return void this._connection.onEvent({type:"updateStrategyEnd"});const i=Promise.all(a.map((e=>this._strategy.load(e).then((()=>this._connection.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._connection.onEvent({type:"error",tile:e.tile.id,error:t}))))));this._updateTracking.addPromise(i);try{r&&await i}catch(n){s(n)}this._connection.onEvent({type:"updateStrategyEnd"}),has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategyEnd`,{strategy:t})}async _supportSnapshotMode(e,t){const{queryMetadata:s}=e,r=s.snapshotInfo;if(!r||!r.supportsSnapshotMinThreshold||!r.snapshotCountThresholds)return null;const a=e.source,i=t.createQuery();i.inner.orderByFields=[],i.inner.returnGeometry=!1;const n=(await d(a,i.inner,{query:i.customParameters})).data.count,{min:o,max:h}=r.snapshotCountThresholds;return n<=o||r.supportsSnapshotMaxThreshold&&n<h?{featureCount:n}:null}}export{S as FeatureSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../../core/has.js";import{sqlAnd as e}from"../../../../../core/sql.js";import t from"../../../../../geometry/SpatialReference.js";import{isHostedAgolService as r}from"../../../../../layers/support/arcgisLayerUrl.js";import{getClauseForScaleRange as a}from"../../../../../layers/support/displayFilterUtils.js";import i from"../../../../../rest/support/Query.js";import s from"../../../../../time/TimeExtent.js";const o=4;function n(e,a,i){const o=e.orderByFields??i.objectIdField+" ASC",n=e.source,l={returnCentroid:!(null!==n&&"object"==typeof n&&"path"in n&&r(n.path))&&"esriGeometryPolygon"===i.serviceGeometryType,returnGeometry:!0,timeReferenceUnknownClient:i.timeReferenceUnknownClient??void 0,outSpatialReference:t.fromJSON(e.outSpatialReference),orderByFields:"memory"===e.type?[]:[o],where:a.mutable.dataFilter.definitionExpression??"1=1",outFields:a.mutable.availableFields,multipatchOption:"esriGeometryMultiPatch"===i.serviceGeometryType?"xyFootprint":null};if("feature"===a.type){const{gdbVersion:e,historicMoment:t,timeExtent:r}=a.mutable.dataFilter;return{...l,gdbVersion:e,historicMoment:t?new Date(t):null,timeExtent:r?s.fromJSON(r):null,outFields:a.mutable.availableFields}}return l}class l{static fromSchema(e,t,r){const a="feature"===t.type?t.mutable.dataFilter.queryScaleRanges:[],i=t.mutable.dataFilter.displayFilter;return new l(n(e,t,r),i,a,r.subtypeField,t.mutable.dataFilter.customParameters,r.geometryType,e.queryMetadata)}constructor(e,t,r,a,i,s,o){this._queryParams=e,this._displayFilter=t,this._queryScaleRanges=r,this._subtypeField=a,this._customParameters=i,this._geometryType=s,this._queryMetadata=o}get pageSize(){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support paged queries");const e=this._queryMetadata.supportsMaxRecordCountFactor?o:null,t=(this._queryMetadata.maxRecordCount??8e3)*(e??1);return Math.min(8e3,t)}updateHistoricMoment(e){this._queryParams.historicMoment=e}updateFields(e){this._queryParams.outFields=e}createPatchFieldsQuery(e,t,r){if(!t.getSize())return null;const a=e.clone();if("*"===this._queryParams.outFields[0]){if("*"===(a.outFields??[])[0])return null;a.outFields=this._queryParams.outFields}else{const e=new Set(this._queryParams.outFields),r=[];for(const a of e)t.hasField(a)||r.push(a);if(0===r.length)return null;a.outFields=r}a.returnGeometry=!1,a.returnCentroid=!1,a.quantizationParameters=null,a.cacheHint=!0;const i={inner:a,customParameters:this._customParameters};if(has("esri-tiles-debug")&&null!=r){const e=r.chunkId.toString().replaceAll("/",".");i.customParameters=i.customParameters?{...i.customParameters,chunkId:e}:{chunkId:e}}return i}createQuery(e={}){if(!this._queryParams)throw new Error("InternalError: queryInfo should be defined");return{inner:new i({...this._queryParams,...e}),customParameters:this._customParameters}}createTileQuery(t,r){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support tile queries");const i=this.createQuery(r),s=i.inner;if(this._queryScaleRanges.length){const r=this._queryScaleRanges.filter((e=>(!e.minScale||e.minScale>=t.maxScale)&&(!e.maxScale||e.maxScale<=t.minScale))).map((e=>e.subtypeCode));if(r.length){const t=`${this._subtypeField} IN (${r})`;s.where=e(s.where,t)}}if(this._displayFilter&&(s.where=e(s.where,a(this._displayFilter,t.minScale,t.maxScale))),s.quantizationParameters=r.quantizationParameters??t.getQuantizationParameters(),s.resultType="tile",s.geometry=t.extent,this._queryMetadata.supportsQuantization?"esriGeometryPolyline"===this._geometryType&&(s.maxAllowableOffset=t.resolution*has("feature-polyline-generalization-factor")):"esriGeometryPolyline"!==this._geometryType&&"esriGeometryPolygon"!==this._geometryType||(s.maxAllowableOffset=t.resolution,"esriGeometryPolyline"===this._geometryType&&(s.maxAllowableOffset*=has("feature-polyline-generalization-factor"))),s.defaultSpatialReferenceEnabled=this._queryMetadata.supportsDefaultSpatialReference,s.compactGeometryEnabled=this._queryMetadata.supportsCompactGeometry,this._queryMetadata.supportsMaxRecordCountFactor&&(s.maxRecordCountFactor=o),has("esri-tiles-debug")){const e=t.id.replaceAll("/",".");i.customParameters=i.customParameters?{...i.customParameters,tileId:e}:{tileId:e}}return i}createPagedTileQuery(e,t){const r=this.pageSize;return this.createTileQuery(e,{start:r*t,num:r,returnExceededLimitFeatures:!0})}createPagedQuery(e){const t=this.pageSize;return this.createQuery({start:t*e,num:t,returnExceededLimitFeatures:!0,maxRecordCountFactor:o,cacheHint:!0})}}export{l as FeatureSourceQueryInfo};
5
+ import has from"../../../../../core/has.js";import{sqlAnd as e}from"../../../../../core/sql.js";import t from"../../../../../geometry/SpatialReference.js";import{isHostedAgolService as r}from"../../../../../layers/support/arcgisLayerUrl.js";import{getClauseForScaleRange as a}from"../../../../../layers/support/displayFilterUtils.js";import i from"../../../../../rest/support/Query.js";import s from"../../../../../time/TimeExtent.js";const o=4;function n(e,a,i){const o=e.orderByFields??i.objectIdField+" ASC",n=e.source,l={returnCentroid:!(null!==n&&"object"==typeof n&&"path"in n&&r(n.path))&&"esriGeometryPolygon"===i.serviceGeometryType,returnGeometry:!0,timeReferenceUnknownClient:i.timeReferenceUnknownClient??void 0,outSpatialReference:t.fromJSON(e.outSpatialReference),orderByFields:"memory"===e.type?[]:[o],where:a.mutable.dataFilter.definitionExpression??"1=1",outFields:a.mutable.availableFields,multipatchOption:"esriGeometryMultiPatch"===i.serviceGeometryType?"xyFootprint":null};if("feature"===a.type){const{gdbVersion:e,historicMoment:t,timeExtent:r}=a.mutable.dataFilter;return{...l,gdbVersion:e,historicMoment:t?new Date(t):null,timeExtent:r?s.fromJSON(r):null,outFields:a.mutable.availableFields}}return l}class l{static fromSchema(e,t,r){const a="feature"===t.type?t.mutable.dataFilter.queryScaleRanges:[],i=t.mutable.displayFilter;return new l(n(e,t,r),i,a,r.subtypeField,t.mutable.dataFilter.customParameters,r.geometryType,e.queryMetadata)}constructor(e,t,r,a,i,s,o){this._queryParams=e,this._displayFilter=t,this._queryScaleRanges=r,this._subtypeField=a,this._customParameters=i,this._geometryType=s,this._queryMetadata=o}get pageSize(){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support paged queries");const e=this._queryMetadata.supportsMaxRecordCountFactor?o:null,t=(this._queryMetadata.maxRecordCount??8e3)*(e??1);return Math.min(8e3,t)}updateHistoricMoment(e){this._queryParams.historicMoment=e}updateFields(e){this._queryParams.outFields=e}createPatchFieldsQuery(e,t,r){if(!t.getSize())return null;const a=e.clone();if("*"===this._queryParams.outFields[0]){if("*"===(a.outFields??[])[0])return null;a.outFields=this._queryParams.outFields}else{const e=new Set(this._queryParams.outFields),r=[];for(const a of e)t.hasField(a)||r.push(a);if(0===r.length)return null;a.outFields=r}a.returnGeometry=!1,a.returnCentroid=!1,a.quantizationParameters=null,a.cacheHint=!0;const i={inner:a,customParameters:this._customParameters};if(has("esri-tiles-debug")&&null!=r){const e=r.chunkId.toString().replaceAll("/",".");i.customParameters=i.customParameters?{...i.customParameters,chunkId:e}:{chunkId:e}}return i}createQuery(e={}){if(!this._queryParams)throw new Error("InternalError: queryInfo should be defined");return{inner:new i({...this._queryParams,...e}),customParameters:this._customParameters}}createTileQuery(t,r){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support tile queries");const i=this.createQuery(r),s=i.inner;if(this._queryScaleRanges.length){const r=this._queryScaleRanges.filter((e=>(!e.minScale||e.minScale>=t.maxScale)&&(!e.maxScale||e.maxScale<=t.minScale))).map((e=>e.subtypeCode));if(r.length){const t=`${this._subtypeField} IN (${r})`;s.where=e(s.where,t)}}if(this._displayFilter&&(s.where=e(s.where,a(this._displayFilter,t.minScale,t.maxScale))),s.quantizationParameters=r.quantizationParameters??t.getQuantizationParameters(),s.resultType="tile",s.geometry=t.extent,this._queryMetadata.supportsQuantization?"esriGeometryPolyline"===this._geometryType&&(s.maxAllowableOffset=t.resolution*has("feature-polyline-generalization-factor")):"esriGeometryPolyline"!==this._geometryType&&"esriGeometryPolygon"!==this._geometryType||(s.maxAllowableOffset=t.resolution,"esriGeometryPolyline"===this._geometryType&&(s.maxAllowableOffset*=has("feature-polyline-generalization-factor"))),s.defaultSpatialReferenceEnabled=this._queryMetadata.supportsDefaultSpatialReference,s.compactGeometryEnabled=this._queryMetadata.supportsCompactGeometry,this._queryMetadata.supportsMaxRecordCountFactor&&(s.maxRecordCountFactor=o),has("esri-tiles-debug")){const e=t.id.replaceAll("/",".");i.customParameters=i.customParameters?{...i.customParameters,tileId:e}:{tileId:e}}return i}createPagedTileQuery(e,t){const r=this.pageSize;return this.createTileQuery(e,{start:r*t,num:r,returnExceededLimitFeatures:!0})}createPagedQuery(e){const t=this.pageSize;return this.createQuery({start:t*e,num:t,returnExceededLimitFeatures:!0,maxRecordCountFactor:o,cacheHint:!0})}}export{l as FeatureSourceQueryInfo};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{handlesGroup as t}from"../../../../../../core/handleUtils.js";import has from"../../../../../../core/has.js";import{throwIfAborted as e,onAbort as s}from"../../../../../../core/promiseUtils.js";import{ATileLoadStrategy as o}from"./ATileLoadStrategy.js";import{DrillDownTileSourceChunk as r}from"./chunks/DrillDownTileSourceChunk.js";import{FeatureSetReaderJSON as i}from"../../support/FeatureSetReaderJSON.js";class l{constructor(e,o){this.subscription=e,this._tileIdToResult=new Map,this._controller=new AbortController,this._handles=t([s(e.signal,(()=>this._controller.abort())),s(o,(()=>this._controller.abort()))])}destroy(){this._controller.abort(),this._handles.remove()}get(t){return this._tileIdToResult.get(t)}set(t,e){this._tileIdToResult.set(t,e)}get options(){return{signal:this._controller.signal}}}class a extends o{constructor(){super(...arguments),this._loadStates=new Map}destroy(){super.destroy();for(const t of this._loadStates.values())t.destroy();this._loadStates.clear()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new l(t,this._options));const s=this._loadStates.get(t.key.id);let o;try{for await(const o of this._fetchChunkInfos(s,t.tile,0)){const{queryJSON:t,reader:i,sourceTile:l,sourceTileDepth:a,tile:n}=o,h=new r(i,t,n,l,a,!1);e(s.options),this._addChunk(h)}}catch(n){o=n}const a=new r(i.empty(this._metadata),null,t.tile,null,-1,!0);if(this._addChunk(a),o)throw o}unload(t){super.unload(t),this._loadStates.get(t.key.id)?.destroy(),this._loadStates.delete(t.key.id)}async*_fetchChunkInfos(t,e,s){let o=t.get(e.id);const r=!!o;if(o||(o=await this._fetchChunkInfo(t,e,s),t.set(e.id,o)),o.reader.exceededTransferLimit&&s<has("featurelayer-query-max-depth"))for(const i of e.createChildTiles())yield*this._fetchChunkInfos(t,i,s+1);else r||(yield o)}async _fetchChunkInfo(t,e,s){const o=t.subscription.tile.getQuantizationParameters(),r=this._queryInfo.createTileQuery(e,{returnExceededLimitFeatures:!1,quantizationParameters:o});return{reader:await this._fetch(r,t.options,{chunkId:e.id}),queryJSON:r.inner.toJSON(),tile:t.subscription.tile,sourceTile:e,sourceTileDepth:s}}}export{a as DrillDownTileLoadStrategy};
5
+ import{handlesGroup as t}from"../../../../../../core/handleUtils.js";import has from"../../../../../../core/has.js";import{throwIfAborted as e,onAbort as s}from"../../../../../../core/promiseUtils.js";import{ATileLoadStrategy as o}from"./ATileLoadStrategy.js";import{DrillDownTileSourceChunk as r}from"./chunks/DrillDownTileSourceChunk.js";import{FeatureSetReaderJSON as i}from"../../support/FeatureSetReaderJSON.js";class l{constructor(e,o){this.subscription=e,this._tileIdToResult=new Map,this._controller=new AbortController,this._handles=t([s(e.signal,(()=>this._controller.abort())),s(o,(()=>this._controller.abort()))])}destroy(){this._controller.abort(),this._handles.remove()}get(t){return this._tileIdToResult.get(t)}set(t,e){this._tileIdToResult.set(t,e)}get options(){return{signal:this._controller.signal}}}class a extends o{constructor(){super(...arguments),this._loadStates=new Map}destroy(){super.destroy();for(const t of this._loadStates.values())t.destroy();this._loadStates.clear()}get about(){return{supportsDisplayFilter:!0,willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new l(t,this._options));const s=this._loadStates.get(t.key.id);let o;try{for await(const o of this._fetchChunkInfos(s,t.tile,0)){const{queryJSON:t,reader:i,sourceTile:l,sourceTileDepth:a,tile:n}=o,h=new r(i,t,n,l,a,!1);e(s.options),this._addChunk(h)}}catch(n){o=n}const a=new r(i.empty(this._metadata),null,t.tile,null,-1,!0);if(this._addChunk(a),o)throw o}unload(t){super.unload(t),this._loadStates.get(t.key.id)?.destroy(),this._loadStates.delete(t.key.id)}async*_fetchChunkInfos(t,e,s){let o=t.get(e.id);const r=!!o;if(o||(o=await this._fetchChunkInfo(t,e,s),t.set(e.id,o)),o.reader.exceededTransferLimit&&s<has("featurelayer-query-max-depth"))for(const i of e.createChildTiles())yield*this._fetchChunkInfos(t,i,s+1);else r||(yield o)}async _fetchChunkInfo(t,e,s){const o=t.subscription.tile.getQuantizationParameters(),r=this._queryInfo.createTileQuery(e,{returnExceededLimitFeatures:!1,quantizationParameters:o});return{reader:await this._fetch(r,t.options,{chunkId:e.id}),queryJSON:r.inner.toJSON(),tile:t.subscription.tile,sourceTile:e,sourceTileDepth:s}}}export{a as DrillDownTileLoadStrategy};