@arcgis/core 4.27.0-next.20230419 → 4.27.0-next.20230421

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 (203) hide show
  1. package/WebMap.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/arcade/arcadeAsyncRuntime.js +1 -1
  4. package/arcade/arcadeCompiler.js +1 -1
  5. package/arcade/arcadeRuntime.js +1 -1
  6. package/arcade/executionError.js +1 -1
  7. package/assets/esri/core/workers/RemoteClient.js +1 -1
  8. package/assets/esri/core/workers/chunks/{f64f95623d9296a91f95.js → 059ec6fd9b971de4b4c1.js} +1 -1
  9. package/assets/esri/core/workers/chunks/0d805fd9cd9ff3a636ca.js +1 -0
  10. package/assets/esri/core/workers/chunks/{1fe31a412479815e5e2d.js → 10770939900946feb20d.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{5252f3cc244204edc299.js → 1216e939d363f96b6cc6.js} +1 -1
  12. package/assets/esri/core/workers/chunks/156dad2b7fed6749bae7.js +1 -0
  13. package/assets/esri/core/workers/chunks/15a97d3e42b00ac42984.js +1 -0
  14. package/assets/esri/core/workers/chunks/{d72c0c97cc4e30f1e4f2.js → 18704903814b9d73c708.js} +1 -1
  15. package/assets/esri/core/workers/chunks/1db5e4c8244dbc21590c.js +1 -0
  16. package/assets/esri/core/workers/chunks/2a1a5a1969e80a10dcca.js +1 -0
  17. package/assets/esri/core/workers/chunks/33b735faa582e6f39e9a.js +1 -0
  18. package/assets/esri/core/workers/chunks/34025ac04ca02531923a.js +1 -0
  19. package/assets/esri/core/workers/chunks/3e9f3479fd8558d9e3e3.js +1 -0
  20. package/assets/esri/core/workers/chunks/{d59274ac695dfcff1143.js → 46090b69e9161bc05141.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{f7aa972cb3903847b3bf.js → 47bf38d910e71ac39bb8.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{3978f4f68ada540ee3a3.js → 4f8a09b61267e5e26712.js} +1 -1
  23. package/assets/esri/core/workers/chunks/5183ecab7eddae7b70e8.js +1 -0
  24. package/assets/esri/core/workers/chunks/{a5c33b24b7ee042cb473.js → 51a0d1dabe7415515c77.js} +2 -2
  25. package/assets/esri/core/workers/chunks/541e6efc3b491e507410.js +1 -0
  26. package/assets/esri/core/workers/chunks/588256e65685ff21d2e9.js +1 -0
  27. package/assets/esri/core/workers/chunks/5c64fd3bf057a1a5527f.js +1 -0
  28. package/assets/esri/core/workers/chunks/6047bdaf4855506f8fdb.js +1 -0
  29. package/assets/esri/core/workers/chunks/6adb58f1bffc5d1c03bd.js +1 -0
  30. package/assets/esri/core/workers/chunks/770940417e6ddbdbb9d6.js +1 -0
  31. package/assets/esri/core/workers/chunks/{1c1d8be85297c483a606.js → 77c98121223a144170e3.js} +1 -1
  32. package/assets/esri/core/workers/chunks/80117007d86be4eb3bc3.js +1 -0
  33. package/assets/esri/core/workers/chunks/812cba53143565a825f1.js +1 -0
  34. package/assets/esri/core/workers/chunks/838849b751805615833a.js +1 -0
  35. package/assets/esri/core/workers/chunks/{9ca395f7bc8d397b5240.js → 88197520501fcc20b6e8.js} +1 -1
  36. package/assets/esri/core/workers/chunks/88f9dededcf60fd011ef.js +1 -0
  37. package/assets/esri/core/workers/chunks/88fdd288ef799a7ac48a.js +1 -0
  38. package/assets/esri/core/workers/chunks/8ae7fea9f7fda38dd207.js +1 -0
  39. package/assets/esri/core/workers/chunks/{0d080dd1ca6a71597409.js → 9265d4e9cfab2c7bbce5.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{8d41305509fedb3603ac.js → 94041a9ced04aa281d40.js} +1 -1
  41. package/assets/esri/core/workers/chunks/98540791fcef86069e44.js +1 -0
  42. package/assets/esri/core/workers/chunks/9c1b2f82877ff79969f5.js +1 -0
  43. package/assets/esri/core/workers/chunks/a7b3cd537c9127b5e65e.js +1 -0
  44. package/assets/esri/core/workers/chunks/{3d1c697182237807ab49.js → abea316f2eac0f3086ab.js} +1 -1
  45. package/assets/esri/core/workers/chunks/ad85ade6a2cfb56cf328.js +1 -0
  46. package/assets/esri/core/workers/chunks/b833b4ea2973bb16792e.js +1 -0
  47. package/assets/esri/core/workers/chunks/be4aa835a7abfc809126.js +1 -0
  48. package/assets/esri/core/workers/chunks/c2ec6e904f96173a7b83.js +1 -0
  49. package/assets/esri/core/workers/chunks/{c25aa08b869f2777dc26.js → c4488a8d857c765da30e.js} +1 -1
  50. package/assets/esri/core/workers/chunks/c5c56b6d99db96a6755a.js +2 -0
  51. package/assets/esri/core/workers/chunks/{7f3b0856f594df2b044e.js → c727d38f71e52bee17e1.js} +1 -1
  52. package/assets/esri/core/workers/chunks/cf315d255f0dc8d50f21.js +1 -0
  53. package/assets/esri/core/workers/chunks/cf7676fdc09ad4835680.js +1 -0
  54. package/assets/esri/core/workers/chunks/cfad34c949cbe8a31ef8.js +1 -0
  55. package/assets/esri/core/workers/chunks/{edb4568fe281b5609092.js → d244e50c981146f018d2.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{a2c9cb23f3e35e88da1d.js → d399b1b9cbf0737d1735.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{df7dcd035997881cf2ef.js → d5c8119d6d34628d3126.js} +1 -1
  58. package/assets/esri/core/workers/chunks/d6b6bb8aecc85d2a3f6b.js +1 -0
  59. package/assets/esri/core/workers/chunks/{8dfa32cc8453f85faab0.js → dd1f8bade9c5c3b7929b.js} +1 -1
  60. package/assets/esri/core/workers/chunks/e11e60759821746259c6.js +1 -0
  61. package/assets/esri/core/workers/chunks/{e4b65c5a4575a5c1c49f.js → e356c576f9a7521a49b3.js} +1 -1
  62. package/assets/esri/core/workers/chunks/f02edf71645eb33bf92f.js +1 -0
  63. package/assets/esri/core/workers/chunks/f1a4165c2710ca90e5ea.js +1 -0
  64. package/assets/esri/core/workers/chunks/f57a3ee17869ced3dd33.js +1 -0
  65. package/assets/esri/core/workers/chunks/fc07f6e103d7f69a9909.js +1 -0
  66. package/chunks/WaterSurface.glsl.js +35 -20
  67. package/chunks/index.js +1 -1
  68. package/core/Loadable.js +1 -1
  69. package/core/Promise.js +1 -1
  70. package/core/accessorSupport/ensureType.js +1 -1
  71. package/core/accessorSupport/watch.js +1 -1
  72. package/core/accessorSupport/write.js +1 -1
  73. package/core/promiseUtils.js +1 -1
  74. package/core/watchUtils.js +1 -1
  75. package/core/workers/Connection.js +1 -1
  76. package/core/workers/RemoteClient.js +1 -1
  77. package/core/workers/workerFactory.js +1 -1
  78. package/geometry/support/geodesicUtils.js +1 -1
  79. package/geometry/support/meshUtils/External.js +1 -1
  80. package/geometry/support/meshUtils/Metadata.js +1 -1
  81. package/intl/messages.js +1 -1
  82. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  83. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  84. package/layers/graphics/data/attributeSupport.js +1 -1
  85. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  86. package/layers/mixins/ArcGISMapService.js +1 -1
  87. package/layers/support/PromiseQueue.js +1 -1
  88. package/layers/support/Sublayer.js +1 -1
  89. package/layers/support/TileKey.js +1 -1
  90. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  91. package/networks/Network.js +1 -1
  92. package/package.json +1 -1
  93. package/portal/schemas/definitions.js +1 -1
  94. package/renderers/support/RasterSymbolizer.js +1 -1
  95. package/renderers/support/rasterRendererChecks.js +5 -0
  96. package/renderers/support/rasterRendererHelper.js +1 -1
  97. package/request.js +1 -1
  98. package/rest/query/operations/query.js +1 -1
  99. package/smartMapping/raster/renderers/uniqueValue.js +1 -1
  100. package/support/featureFlags.js +1 -1
  101. package/support/revision.js +1 -1
  102. package/symbols/support/previewSymbol3D.js +1 -1
  103. package/symbols/support/styleUtils.js +1 -1
  104. package/symbols/support/symbolLayerUtils.js +1 -1
  105. package/symbols/support/utils.js +1 -1
  106. package/symbols/support/webStyleSymbolUtils.js +1 -1
  107. package/views/2d/engine/webgl/TextureManager.js +1 -1
  108. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  109. package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
  110. package/views/2d/layers/features/sources/DataTileSource.js +1 -1
  111. package/views/2d/layers/features/sources/DataTileSubscription.js +1 -1
  112. package/views/2d/layers/features/sources/DrillDownFeatureSource.js +1 -1
  113. package/views/2d/layers/features/sources/PagedFeatureSource.js +1 -1
  114. package/views/2d/layers/features/support/FeatureSetReaderPBFHeader.js +1 -1
  115. package/views/2d/layers/features/tileRenderers/HeatmapTileRenderer.js +1 -1
  116. package/views/2d/layers/features/tileRenderers/SymbolTileRenderer.js +1 -1
  117. package/views/2d/layers/features/tileRenderers.js +1 -1
  118. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  119. package/views/2d/layers/support/webStyleUtils.js +1 -1
  120. package/views/3d/input/SceneInputManager.js +1 -1
  121. package/views/3d/interactive/manipulatorUtils.js +1 -1
  122. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  123. package/views/3d/layers/GraphicsView3D.js +1 -1
  124. package/views/3d/layers/I3SMeshView3D.js +1 -1
  125. package/views/3d/layers/graphics/ElevationQuery.js +1 -1
  126. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  127. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  128. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  129. package/views/3d/layers/graphics/polygonUtils.js +1 -1
  130. package/views/3d/layers/graphics/symbolComplexity.js +1 -1
  131. package/views/3d/layers/graphics/webStyleUtils.js +5 -0
  132. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  133. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  134. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  135. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  136. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  137. package/views/3d/webgl-engine/shaders/WaterSurface.glsl.js +1 -1
  138. package/views/LayerViewManager.js +1 -1
  139. package/views/PopupView.js +1 -1
  140. package/views/SceneView.js +1 -1
  141. package/views/ViewAnimation.js +1 -1
  142. package/views/input/BrowserEventSource.js +1 -1
  143. package/views/input/InputManager.js +1 -1
  144. package/views/interactive/coordinateHelper.js +1 -1
  145. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  146. package/views/layers/support/MapServiceLayerViewHelper.js +1 -1
  147. package/views/support/QueueProcessor.js +1 -1
  148. package/views/ui/DefaultUI.js +1 -1
  149. package/views/ui/UI.js +1 -1
  150. package/widgets/BasemapGallery/support/PortalBasemapsSource.js +1 -1
  151. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  152. package/widgets/Editor/Upload.js +1 -1
  153. package/widgets/Editor/deprecationUtils.js +1 -1
  154. package/widgets/Editor/modelUploadUtils.js +1 -1
  155. package/widgets/Editor.js +1 -1
  156. package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
  157. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  158. package/widgets/Feature/FeatureViewModel.js +1 -1
  159. package/widgets/Feature/support/featureUtils.js +1 -1
  160. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  161. package/widgets/Popup.js +1 -1
  162. package/widgets/support/decorators/accessibleHandler.js +1 -1
  163. package/assets/esri/core/workers/chunks/0948a40569b2408edefb.js +0 -1
  164. package/assets/esri/core/workers/chunks/192e3eeed50768c77c65.js +0 -1
  165. package/assets/esri/core/workers/chunks/1d1b9856f2f44d0c2144.js +0 -1
  166. package/assets/esri/core/workers/chunks/203115cc836e7b364eec.js +0 -1
  167. package/assets/esri/core/workers/chunks/20ad44b1a7adfed4c6c4.js +0 -1
  168. package/assets/esri/core/workers/chunks/27353056c3e4e8d8b8d3.js +0 -1
  169. package/assets/esri/core/workers/chunks/41ae9037c70461d5fdc7.js +0 -1
  170. package/assets/esri/core/workers/chunks/4b6a903d4aeeb4eeb615.js +0 -1
  171. package/assets/esri/core/workers/chunks/4bf9bc8b52d618f395c5.js +0 -1
  172. package/assets/esri/core/workers/chunks/5ec4fedbbcbb0053cf74.js +0 -2
  173. package/assets/esri/core/workers/chunks/60e29d172a2dcf45e8d0.js +0 -1
  174. package/assets/esri/core/workers/chunks/68a15cc7c51645d31572.js +0 -1
  175. package/assets/esri/core/workers/chunks/6b065e581bcf743079cf.js +0 -1
  176. package/assets/esri/core/workers/chunks/6c54579981a7bd483f1a.js +0 -1
  177. package/assets/esri/core/workers/chunks/778ecf61f07dafc51bbc.js +0 -1
  178. package/assets/esri/core/workers/chunks/7da1fd3629362b81b43c.js +0 -1
  179. package/assets/esri/core/workers/chunks/80d335bec34d60b7bbdc.js +0 -1
  180. package/assets/esri/core/workers/chunks/810da30f13151b72a293.js +0 -1
  181. package/assets/esri/core/workers/chunks/81485a5056aed94b3d8d.js +0 -1
  182. package/assets/esri/core/workers/chunks/8374d89e995f0d15c042.js +0 -1
  183. package/assets/esri/core/workers/chunks/8ebda132068f6b962dd9.js +0 -1
  184. package/assets/esri/core/workers/chunks/8f553ae2f1aba4e0371f.js +0 -1
  185. package/assets/esri/core/workers/chunks/8fec9979ae2b0e3a878f.js +0 -1
  186. package/assets/esri/core/workers/chunks/979ea2e3b1b164334634.js +0 -1
  187. package/assets/esri/core/workers/chunks/a0e92dd27c8f6b642dbf.js +0 -1
  188. package/assets/esri/core/workers/chunks/a6240bf258b3886a6661.js +0 -1
  189. package/assets/esri/core/workers/chunks/b059cd03f31ead61abb4.js +0 -1
  190. package/assets/esri/core/workers/chunks/b1a8024bf8cdd0cd3884.js +0 -1
  191. package/assets/esri/core/workers/chunks/b366e0db9b5f27dd53a3.js +0 -1
  192. package/assets/esri/core/workers/chunks/b976d5599672665561ec.js +0 -1
  193. package/assets/esri/core/workers/chunks/c260ac058e63a5c0cf60.js +0 -1
  194. package/assets/esri/core/workers/chunks/c646dc9da08b509e39d6.js +0 -1
  195. package/assets/esri/core/workers/chunks/db5598944b691e43f13e.js +0 -1
  196. package/assets/esri/core/workers/chunks/eb163a2ddeb27c690308.js +0 -1
  197. package/assets/esri/core/workers/chunks/eec12b5666819bf2119d.js +0 -1
  198. package/assets/esri/core/workers/chunks/ef05496c1faf08d247f1.js +0 -1
  199. package/assets/esri/core/workers/chunks/f05634909c9449533193.js +0 -1
  200. package/assets/esri/core/workers/chunks/fcebd70b089dea833c75.js +0 -1
  201. package/views/layers/GraphicsView.js +0 -5
  202. /package/assets/esri/core/workers/chunks/{a5c33b24b7ee042cb473.js.LICENSE.txt → 51a0d1dabe7415515c77.js.LICENSE.txt} +0 -0
  203. /package/assets/esri/core/workers/chunks/{5ec4fedbbcbb0053cf74.js.LICENSE.txt → c5c56b6d99db96a6755a.js.LICENSE.txt} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{toHSV as t}from"../../core/colorUtils.js";import{JSONSupport as r}from"../../core/JSONSupport.js";import s from"../../core/Logger.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import n from"../../layers/support/RasterInfo.js";import{colorize as i,remapColor as l,lookupPixels as u,createColormapLUT as c,isValidPixelBlock as p}from"../../layers/support/rasterFunctions/pixelUtils.js";import{stretch as d,getStretchCutoff as h,createStretchLUT as m,computeGammaValues as f,createHistogramEqualizationLUT as y}from"../../layers/support/rasterFunctions/stretchUtils.js";import{hillshade as b,tintHillshade as g,calculateHillshadeParams as S}from"../../layers/support/rasterFunctions/surfaceUtils.js";import{convertColorRampToColormap as k}from"./colorRampUtils.js";function x(e,t){const{attributeTable:r,bandCount:s}=e;if(null==r||s>1)return!1;if(t){if(null==r.fields.find((e=>e.name.toLowerCase()===t.toLowerCase())))return!1}return!0}function R(e){const{bandCount:t,dataType:r,pixelType:s}=e;return"elevation"===r||"generic"===r&&1===t&&("s16"===s||"f32"===s||"f64"===s)}function I(e){const{bandCount:t,colormap:r}=e;return null!=r&&r.length>0&&1===t}let C=class extends r{constructor(e){super(e)}bind(){const{rendererJSON:e}=this;if(!e)return{success:!1};let t;switch(this.lookup={rendererJSON:{}},e.type){case"uniqueValue":t=this._updateUVRenderer(e);break;case"rasterColormap":t=this._updateColormapRenderer(e);break;case"rasterStretch":t=this._updateStretchRenderer(e);break;case"classBreaks":t=this._updateClassBreaksRenderer(e);break;case"rasterShadedRelief":t=this._updateShadedReliefRenderer(e);break;case"vectorField":t=this._updateVectorFieldRenderer();break;case"flowRenderer":t=this._updateFlowRenderer()}return t}symbolize(e){let t=e&&e.pixelBlock;if(!L(t))return t;if(e.simpleStretchParams&&"rasterStretch"===this.rendererJSON.type)return this.simpleStretch(t,e.simpleStretchParams);try{let r;switch(t.pixels.length>3&&(t=t.extractBands([0,1,2])),this.rendererJSON.type){case"uniqueValue":case"rasterColormap":r=this._symbolizeColormap(t);break;case"classBreaks":r=this._symbolizeClassBreaks(t);break;case"rasterStretch":r=this._symbolizeStretch(t,e.bandIds);break;case"rasterShadedRelief":{const s=e.extent,a=s.spatialReference.isGeographic,o={x:(s.xmax-s.xmin)/t.width,y:(s.ymax-s.ymin)/t.height};r=this._symbolizeShadedRelief(t,{isGCS:a,resolution:o});break}}return r}catch(r){return s.getLogger(this.declaredClass).error("symbolize",r.message),t}}simpleStretch(e,t){if(!L(e))return e;try{return e.pixels.length>3&&(e=e.extractBands([0,1,2])),d(e,{...t,isRenderer:!0})}catch(r){return s.getLogger(this.declaredClass).error("symbolize",r.message),e}}generateWebGLParameters(e){if(["uniqueValue","rasterColormap","classBreaks"].includes(this.rendererJSON.type)){const{indexedColormap:e,offset:t}=this.lookup.colormapLut||{};return{colormap:e,colormapOffset:t,type:"lut"}}const{pixelBlock:t,isGCS:r,resolution:s,bandIds:a}=e,{rendererJSON:o}=this;return"rasterStretch"===o.type?this._generateStretchWebGLParams(t,o,a):"rasterShadedRelief"===o.type?this._generateShadedReliefWebGLParams(o,r,s??void 0):"vectorField"===o.type?this._generateVectorFieldWebGLParams(o):null}_isLUTChanged(e){if(!this.lookup||!this.lookup.rendererJSON)return!0;if("colorRamp"in this.rendererJSON){const t=this.rendererJSON.colorRamp;return e?JSON.stringify(t)!==JSON.stringify(this.lookup.rendererJSON.colorRamp):(this.rendererJSON,this.lookup.rendererJSON,JSON.stringify(this.rendererJSON)!==JSON.stringify(this.lookup.rendererJSON))}return JSON.stringify(this.rendererJSON)!==JSON.stringify(this.lookup.rendererJSON)}_symbolizeColormap(e){if(this._isLUTChanged()){if(!this.bind().success)return e}return i(e,this.lookup.colormapLut)}_symbolizeClassBreaks(e){const{canUseIndexedLUT:t}=this._analyzeClassBreaks(this.rendererJSON);if(this._isLUTChanged()){if(!this.bind().success)return e}return t?i(e,this.lookup.colormapLut):l(e,this.lookup.remapLut??[])}_symbolizeStretch(e,t){const{rasterInfo:r}=this,{pixelType:s,bandCount:a}=r,o=this.rendererJSON,n=["u8","u16","s8","s16"].includes(s);let l,c;const{dra:p}=o,{gamma:f}=this.lookup;if("histogramEqualization"===o.stretchType){const s=p?null:this.lookup?.histogramLut,a=h(o,{rasterInfo:r,pixelBlock:e,bandIds:t,returnHistogramLut:!s}),n=d(e,{...a,gamma:f,isRenderer:!0});c=u(n,{lut:p?a.histogramLut:s,offset:0})}else if(n){if(p){const a=h(o,{rasterInfo:r,pixelBlock:e,bandIds:t});l=m({pixelType:s,...a,gamma:f,rounding:"floor"})}else if(this._isLUTChanged()){if(!this.bind().success)return e;l=this.lookup?this.lookup.stretchLut:null}else l=this.lookup?this.lookup.stretchLut:null;if(!l)return e;a>1&&null!=t&&t.length===e?.pixels.length&&l?.lut.length===a&&(l={lut:t.map((e=>l.lut[e])),offset:l.offset}),c=u(e,l)}else{const s=h(o,{rasterInfo:r,pixelBlock:e,bandIds:t});c=d(e,{...s,gamma:f,isRenderer:!0})}if(o.colorRamp){if(this._isLUTChanged(!0)){if(!this.bind().success)return e}c=i(c,this.lookup?.colormapLut)}return c}_symbolizeShadedRelief(e,t){const r=this.rendererJSON,s={...r,...t},a=b(e,s);if(!r.colorRamp)return a;let o;if(this._isLUTChanged(!0)){if(!this.bind().success)return a;o=this.lookup?this.lookup.hsvMap:null}else o=this.lookup?this.lookup.hsvMap:null;if(!o)return a;const n=this.rasterInfo.statistics?.[0]??{min:0,max:8e3};return g(a,e,o,n),a}_isVectorFieldData(){const{bandCount:e,dataType:t}=this.rasterInfo;return 2===e&&("vector-magdir"===t||"vector-uv"===t)}_updateVectorFieldRenderer(){return this._isVectorFieldData()?{success:!0}:{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; VectorFieldRenderer only supports "vector-magdir" and "vector-uv".`}}_updateFlowRenderer(){return this._isVectorFieldData()?{success:!0}:{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; FlowRenderer only supports "vector-magdir" and "vector-uv".`}}_updateUVRenderer(e){const{bandCount:t,attributeTable:r,pixelType:s}=this.rasterInfo,a=e.field1;if(!a)return{success:!1,error:"Unsupported renderer; missing UniqueValueRenderer.field."};const o=e.defaultSymbol,n=1===t&&["u8","s8"].includes(s);if(!x(this.rasterInfo,a)&&!n)return{success:!1,error:"Unsupported data; UniqueValueRenderer is only supported on single band data with a valid raster attribute table."};const i=[];if(null!=r){const t=r.fields.find((e=>"value"===e.name.toLowerCase()));if(!t)return{success:!1,error:"Unsupported data; the data's raster attribute table does not have a value field."};r.features.forEach((r=>{const s=e.uniqueValueInfos?.find((e=>String(e.value)===String(r.attributes[a]))),n=s?.symbol?.color;n?i.push([r.attributes[t.name]].concat(n)):o&&i.push([r.attributes[t.name]].concat(o.color))}))}else{if("value"!==a.toLowerCase())return{success:!1,error:'Unsupported renderer; UniqueValueRenderer.field must be "Value" when raster attribute table is not availalbe.'};e.uniqueValueInfos?.forEach((e=>{const t=e?.symbol?.color;t?i.push([parseInt(""+e.value,10)].concat(t)):o&&i.push([parseInt(""+e.value,10)].concat(o?.color))}))}if(0===i.length)return{success:!1,error:"Invalid UniqueValueRenderer. Cannot find matching records in the raster attribute table."};const l=c({colormap:i});return this.lookup={rendererJSON:e,colormapLut:l},this.canRenderInWebGL=!0,{success:!0}}_updateColormapRenderer(e){if(!I(this.rasterInfo))return{success:!1,error:"Unsupported data; the data source does not have a colormap."};const t=e.colormapInfos.map((e=>[e.value].concat(e.color))).sort(((e,t)=>e[0]-t[0]));if(!t||0===t.length)return{success:!1,error:"Unsupported renderer; ColormapRenderer must have meaningful colormapInfos."};const r=c({colormap:t});return this.lookup={rendererJSON:e,colormapLut:r},this.canRenderInWebGL=!0,{success:!0}}_updateShadedReliefRenderer(e){if(!R(this.rasterInfo))return{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; ShadedReliefRenderer only supports "elevation", or single band float/s16 data.`};if(e.colorRamp){const r=k(e.colorRamp,{interpolateAlpha:!0}),s=c({colormap:r}),a=[],o=s.indexedColormap;for(let e=0;e<o.length;e+=4){const r=t({r:o[e],g:o[e+1],b:o[e+2]});a.push([r.h/60,r.s/100,255*r.v/100])}this.lookup={rendererJSON:e,colormapLut:s,hsvMap:a}}else this.lookup=null;return this.canRenderInWebGL=!0,{success:!0}}_analyzeClassBreaks(e){const{attributeTable:t,pixelType:r}=this.rasterInfo,s=null!=t?t.fields.find((e=>"value"===e.name.toLowerCase())):null,a=null!=t?t.fields.find((t=>t.name.toLowerCase()===e.field.toLowerCase())):null,o=null!=s&&null!==a;return{canUseIndexedLUT:["u8","u16","s8","s16"].includes(r)||o,tableValueField:s,tableBreakField:a}}_updateClassBreaksRenderer(e){const{attributeTable:t}=this.rasterInfo,{canUseIndexedLUT:r,tableValueField:s,tableBreakField:a}=this._analyzeClassBreaks(e),o=e.classBreakInfos;if(!o?.length)return{success:!1,error:"Unsupported renderer; missing or invalid ClassBreaksRenderer.classBreakInfos."};const n=o.sort(((e,t)=>e.classMaxValue-t.classMaxValue)),i=n[n.length-1];let l=e.minValue;if(!r){const t=[];for(let e=0;e<n.length;e++)t.push({value:n[e].classMinValue??l,mappedColor:n[e].symbol.color}),l=n[e].classMaxValue;return t.push({value:i.classMaxValue,mappedColor:i.symbol.color}),this.lookup={rendererJSON:e,remapLut:t},this.canRenderInWebGL=!1,{success:!0}}const u=[];if(null!=t&&null!=s&&null!==a&&s!==a){const r=s.name,o=a.name,i=n[n.length-1],{classMaxValue:c}=i;l=e.minValue;for(const e of t.features){const t=e.attributes[r],s=e.attributes[o],a=s===c?i:s<l?null:n.find((({classMaxValue:e})=>e>s));a&&u.push([t].concat(a.symbol.color))}}else{l=Math.floor(e.minValue);for(let e=0;e<n.length;e++){const t=n[e];for(let e=l;e<t.classMaxValue;e++)u.push([e].concat(t.symbol.color));l=Math.ceil(t.classMaxValue)}i.classMaxValue===l&&u.push([i.classMaxValue].concat(i.symbol.color))}const p=c({colormap:u,fillUnspecified:!1});return this.lookup={rendererJSON:e,colormapLut:p},this.canRenderInWebGL=!0,{success:!0}}_isHistogramRequired(e){return"percentClip"===e||"histogramEqualization"===e}_isValidRasterStatistics(e){return null!=e&&e.length>0&&null!=e[0].min&&null!=e[0].max}_updateStretchRenderer(e){let{stretchType:t,dra:r}=e;if(!("none"===t||e.statistics?.length||this._isValidRasterStatistics(this.rasterInfo.statistics)||r))return{success:!1,error:"Unsupported renderer; StretchRenderer.statistics is required when dynamic range adjustment is not used."};const s=e.histograms||this.rasterInfo.histograms;!this._isHistogramRequired(e.stretchType)||s?.length||r||(t="minMax");const{computeGamma:a,useGamma:o,colorRamp:n}=e;let{gamma:i}=e;if(o&&a&&!i?.length){const t=e.statistics?.length?e.statistics:this.rasterInfo.statistics;i=f(this.rasterInfo.pixelType,t)}const l=this.rasterInfo.pixelType,u=!r&&["u8","u16","s8","s16"].includes(l);if("histogramEqualization"===t){const t=s.map((e=>y(e)));this.lookup={rendererJSON:e,histogramLut:t}}else if(u){const t=h(e,{rasterInfo:this.rasterInfo}),r=m({pixelType:l,...t,gamma:o?i:null,rounding:"floor"});this.lookup={rendererJSON:e,stretchLut:r}}if(n){const t=k(n,{interpolateAlpha:!0});this.lookup||(this.lookup={rendererJSON:e}),this.lookup.colormapLut=c({colormap:t}),this.lookup.rendererJSON=e}return this.lookup.gamma=o&&i?.length?i:null,this.canRenderInWebGL=!0,{success:!0}}_generateStretchWebGLParams(e,t,r){let s=null,a=null;const o=this.lookup&&this.lookup.colormapLut;t.colorRamp&&o&&(s=o.indexedColormap,a=o.offset),"histogramEqualization"===t.stretchType&&(t={...t,stretchType:"minMax"});const{gamma:n}=this.lookup,i=!!(t.useGamma&&n&&n.some((e=>1!==e))),{minCutOff:l,maxCutOff:u,outMin:c,outMax:p}=h(t,{rasterInfo:this.rasterInfo,pixelBlock:e,bandIds:r});let d=0;null!=e&&(d=e.getPlaneCount(),2===d&&((e=e.clone()).statistics=[e.statistics[0]],e.pixels=[e.pixels[0]]));const{bandCount:m}=this.rasterInfo,f=Math.min(3,r?.length||d||m,m),y=new Float32Array(f),b=s||i?1:255;let g;for(g=0;g<l.length;g++)y[g]=u[g]===l[g]?0:(p-c)/(u[g]-l[g])/b;const S=new Float32Array(f);if(i&&n)for(g=0;g<f;g++)n[g]>1?n[g]>2?S[g]=6.5+(n[g]-2)**2.5:S[g]=6.5+100*(2-n[g])**4:S[g]=1;return{bandCount:f,outMin:c/b,outMax:p/b,minCutOff:l,maxCutOff:u,factor:y,useGamma:i,gamma:i?n:[1,1,1],gammaCorrection:i?S:[1,1,1],colormap:s,colormapOffset:a,stretchType:t.stretchType,type:"stretch"}}_generateShadedReliefWebGLParams(e,t=!1,r={x:0,y:0}){let s=null,a=null;const o=this.lookup&&this.lookup.colormapLut;e.colorRamp&&o&&(s=o.indexedColormap,a=o.offset);const n={...e,isGCS:t,resolution:r},i=S(n),l=this.rasterInfo.statistics?.[0];return{...i,minValue:l?.min??0,maxValue:l?.max??8e3,hillshadeType:"traditional"===e.hillshadeType?0:1,type:"hillshade",colormap:s,colormapOffset:a}}_generateVectorFieldWebGLParams(e){const{style:t,inputUnit:r,outputUnit:s,visualVariables:a,symbolTileSize:o,flowRepresentation:n}=e;let i;const l=this.rasterInfo.statistics?.[0].min??0,u=this.rasterInfo.statistics?.[0].max??50,c=a?.find((e=>"sizeInfo"===e.type))??{type:"sizeInfo",field:"Magnitude",maxDataValue:u,maxSize:.8*o,minDataValue:l,minSize:.2*o},p=c.minDataValue??l,d=c.maxDataValue??u,h=null!=c.maxSize&&null!=c.minSize?[c.minSize/o,c.maxSize/o]:[.2,.8];if("wind_speed"===t){const e=(h[0]+h[1])/2;h[0]=h[1]=e}const m=null!=p&&null!=d?[p,d]:null;if("classified_arrow"===t)if(null!=p&&null!=d&&null!=c){i=[];const e=(c.maxDataValue-c.minDataValue)/5;for(let t=0;t<6;t++)i.push(c.minDataValue+e*t)}else i=[0,1e-6,3.5,7,10.5,14];const f="flow_to"===n===("ocean_current_kn"===t||"ocean_current_m"===t)?0:Math.PI,y=a?.find((e=>"rotationInfo"===e.type));return{breakValues:i,dataRange:m,inputUnit:r,outputUnit:s,symbolTileSize:o,symbolPercentRange:h,style:t||"single_arrow",rotation:f,rotationType:this.rasterInfo.storageInfo?.tileInfo&&"vector-uv"===this.rasterInfo.dataType?"geographic":y?.rotationType||e.rotationType,type:"vectorField"}}};function L(e){return p(e)&&0!==e.validPixelCount}e([a({json:{write:!0}})],C.prototype,"rendererJSON",void 0),e([a({type:n,json:{write:!0}})],C.prototype,"rasterInfo",void 0),e([a({json:{write:!0}})],C.prototype,"lookup",void 0),e([a()],C.prototype,"canRenderInWebGL",void 0),C=e([o("esri.renderers.support.RasterSymbolizer")],C);const _=C;export{_ as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{toHSV as t}from"../../core/colorUtils.js";import{JSONSupport as r}from"../../core/JSONSupport.js";import s from"../../core/Logger.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import n from"../../layers/support/RasterInfo.js";import{colorize as i,remapColor as l,lookupPixels as u,createColormapLUT as c,isValidPixelBlock as p}from"../../layers/support/rasterFunctions/pixelUtils.js";import{stretch as d,getStretchCutoff as h,createStretchLUT as m,computeGammaValues as f,createHistogramEqualizationLUT as y}from"../../layers/support/rasterFunctions/stretchUtils.js";import{hillshade as g,tintHillshade as b,calculateHillshadeParams as S}from"../../layers/support/rasterFunctions/surfaceUtils.js";import{convertColorRampToColormap as k}from"./colorRampUtils.js";import{isUVRendererSupported as R,isColormapRendererSupported as x,isShadedReliefRendererSupported as I}from"./rasterRendererChecks.js";let C=class extends r{constructor(e){super(e)}bind(){const{rendererJSON:e}=this;if(!e)return{success:!1};let t;switch(this.lookup={rendererJSON:{}},e.type){case"uniqueValue":t=this._updateUVRenderer(e);break;case"rasterColormap":t=this._updateColormapRenderer(e);break;case"rasterStretch":t=this._updateStretchRenderer(e);break;case"classBreaks":t=this._updateClassBreaksRenderer(e);break;case"rasterShadedRelief":t=this._updateShadedReliefRenderer(e);break;case"vectorField":t=this._updateVectorFieldRenderer();break;case"flowRenderer":t=this._updateFlowRenderer()}return t}symbolize(e){let t=e&&e.pixelBlock;if(!_(t))return t;if(e.simpleStretchParams&&"rasterStretch"===this.rendererJSON.type)return this.simpleStretch(t,e.simpleStretchParams);try{let r;switch(t.pixels.length>3&&(t=t.extractBands([0,1,2])),this.rendererJSON.type){case"uniqueValue":case"rasterColormap":r=this._symbolizeColormap(t);break;case"classBreaks":r=this._symbolizeClassBreaks(t);break;case"rasterStretch":r=this._symbolizeStretch(t,e.bandIds);break;case"rasterShadedRelief":{const s=e.extent,a=s.spatialReference.isGeographic,o={x:(s.xmax-s.xmin)/t.width,y:(s.ymax-s.ymin)/t.height};r=this._symbolizeShadedRelief(t,{isGCS:a,resolution:o});break}}return r}catch(r){return s.getLogger(this.declaredClass).error("symbolize",r.message),t}}simpleStretch(e,t){if(!_(e))return e;try{return e.pixels.length>3&&(e=e.extractBands([0,1,2])),d(e,{...t,isRenderer:!0})}catch(r){return s.getLogger(this.declaredClass).error("symbolize",r.message),e}}generateWebGLParameters(e){if(["uniqueValue","rasterColormap","classBreaks"].includes(this.rendererJSON.type)){const{indexedColormap:e,offset:t}=this.lookup.colormapLut||{};return{colormap:e,colormapOffset:t,type:"lut"}}const{pixelBlock:t,isGCS:r,resolution:s,bandIds:a}=e,{rendererJSON:o}=this;return"rasterStretch"===o.type?this._generateStretchWebGLParams(t,o,a):"rasterShadedRelief"===o.type?this._generateShadedReliefWebGLParams(o,r,s??void 0):"vectorField"===o.type?this._generateVectorFieldWebGLParams(o):null}_isLUTChanged(e){if(!this.lookup||!this.lookup.rendererJSON)return!0;if("colorRamp"in this.rendererJSON){const t=this.rendererJSON.colorRamp;return e?JSON.stringify(t)!==JSON.stringify(this.lookup.rendererJSON.colorRamp):(this.rendererJSON,this.lookup.rendererJSON,JSON.stringify(this.rendererJSON)!==JSON.stringify(this.lookup.rendererJSON))}return JSON.stringify(this.rendererJSON)!==JSON.stringify(this.lookup.rendererJSON)}_symbolizeColormap(e){if(this._isLUTChanged()){if(!this.bind().success)return e}return i(e,this.lookup.colormapLut)}_symbolizeClassBreaks(e){const{canUseIndexedLUT:t}=this._analyzeClassBreaks(this.rendererJSON);if(this._isLUTChanged()){if(!this.bind().success)return e}return t?i(e,this.lookup.colormapLut):l(e,this.lookup.remapLut??[])}_symbolizeStretch(e,t){const{rasterInfo:r}=this,{pixelType:s,bandCount:a}=r,o=this.rendererJSON,n=["u8","u16","s8","s16"].includes(s);let l,c;const{dra:p}=o,{gamma:f}=this.lookup;if("histogramEqualization"===o.stretchType){const s=p?null:this.lookup?.histogramLut,a=h(o,{rasterInfo:r,pixelBlock:e,bandIds:t,returnHistogramLut:!s}),n=d(e,{...a,gamma:f,isRenderer:!0});c=u(n,{lut:p?a.histogramLut:s,offset:0})}else if(n){if(p){const a=h(o,{rasterInfo:r,pixelBlock:e,bandIds:t});l=m({pixelType:s,...a,gamma:f,rounding:"floor"})}else if(this._isLUTChanged()){if(!this.bind().success)return e;l=this.lookup?this.lookup.stretchLut:null}else l=this.lookup?this.lookup.stretchLut:null;if(!l)return e;a>1&&null!=t&&t.length===e?.pixels.length&&l?.lut.length===a&&(l={lut:t.map((e=>l.lut[e])),offset:l.offset}),c=u(e,l)}else{const s=h(o,{rasterInfo:r,pixelBlock:e,bandIds:t});c=d(e,{...s,gamma:f,isRenderer:!0})}if(o.colorRamp){if(this._isLUTChanged(!0)){if(!this.bind().success)return e}c=i(c,this.lookup?.colormapLut)}return c}_symbolizeShadedRelief(e,t){const r=this.rendererJSON,s={...r,...t},a=g(e,s);if(!r.colorRamp)return a;let o;if(this._isLUTChanged(!0)){if(!this.bind().success)return a;o=this.lookup?this.lookup.hsvMap:null}else o=this.lookup?this.lookup.hsvMap:null;if(!o)return a;const n=this.rasterInfo.statistics?.[0]??{min:0,max:8e3};return b(a,e,o,n),a}_isVectorFieldData(){const{bandCount:e,dataType:t}=this.rasterInfo;return 2===e&&("vector-magdir"===t||"vector-uv"===t)}_updateVectorFieldRenderer(){return this._isVectorFieldData()?{success:!0}:{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; VectorFieldRenderer only supports "vector-magdir" and "vector-uv".`}}_updateFlowRenderer(){return this._isVectorFieldData()?{success:!0}:{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; FlowRenderer only supports "vector-magdir" and "vector-uv".`}}_updateUVRenderer(e){const{bandCount:t,attributeTable:r,pixelType:s}=this.rasterInfo,a=e.field1;if(!a)return{success:!1,error:"Unsupported renderer; missing UniqueValueRenderer.field."};const o=e.defaultSymbol,n=1===t&&["u8","s8"].includes(s);if(!R(this.rasterInfo,a)&&!n)return{success:!1,error:"Unsupported data; UniqueValueRenderer is only supported on single band data with a valid raster attribute table."};const i=[];if(null!=r){const t=r.fields.find((e=>"value"===e.name.toLowerCase()));if(!t)return{success:!1,error:"Unsupported data; the data's raster attribute table does not have a value field."};r.features.forEach((r=>{const s=e.uniqueValueInfos?.find((e=>String(e.value)===String(r.attributes[a]))),n=s?.symbol?.color;n?i.push([r.attributes[t.name]].concat(n)):o&&i.push([r.attributes[t.name]].concat(o.color))}))}else{if("value"!==a.toLowerCase())return{success:!1,error:'Unsupported renderer; UniqueValueRenderer.field must be "Value" when raster attribute table is not availalbe.'};e.uniqueValueInfos?.forEach((e=>{const t=e?.symbol?.color;t?i.push([parseInt(""+e.value,10)].concat(t)):o&&i.push([parseInt(""+e.value,10)].concat(o?.color))}))}if(0===i.length)return{success:!1,error:"Invalid UniqueValueRenderer. Cannot find matching records in the raster attribute table."};const l=c({colormap:i});return this.lookup={rendererJSON:e,colormapLut:l},this.canRenderInWebGL=!0,{success:!0}}_updateColormapRenderer(e){if(!x(this.rasterInfo))return{success:!1,error:"Unsupported data; the data source does not have a colormap."};const t=e.colormapInfos.map((e=>[e.value].concat(e.color))).sort(((e,t)=>e[0]-t[0]));if(!t||0===t.length)return{success:!1,error:"Unsupported renderer; ColormapRenderer must have meaningful colormapInfos."};const r=c({colormap:t});return this.lookup={rendererJSON:e,colormapLut:r},this.canRenderInWebGL=!0,{success:!0}}_updateShadedReliefRenderer(e){if(!I(this.rasterInfo))return{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; ShadedReliefRenderer only supports "elevation", or single band float/s16 data.`};if(e.colorRamp){const r=k(e.colorRamp,{interpolateAlpha:!0}),s=c({colormap:r}),a=[],o=s.indexedColormap;for(let e=0;e<o.length;e+=4){const r=t({r:o[e],g:o[e+1],b:o[e+2]});a.push([r.h/60,r.s/100,255*r.v/100])}this.lookup={rendererJSON:e,colormapLut:s,hsvMap:a}}else this.lookup=null;return this.canRenderInWebGL=!0,{success:!0}}_analyzeClassBreaks(e){const{attributeTable:t,pixelType:r}=this.rasterInfo,s=null!=t?t.fields.find((e=>"value"===e.name.toLowerCase())):null,a=null!=t?t.fields.find((t=>t.name.toLowerCase()===e.field.toLowerCase())):null,o=null!=s&&null!==a;return{canUseIndexedLUT:["u8","u16","s8","s16"].includes(r)||o,tableValueField:s,tableBreakField:a}}_updateClassBreaksRenderer(e){const{attributeTable:t}=this.rasterInfo,{canUseIndexedLUT:r,tableValueField:s,tableBreakField:a}=this._analyzeClassBreaks(e),o=e.classBreakInfos;if(!o?.length)return{success:!1,error:"Unsupported renderer; missing or invalid ClassBreaksRenderer.classBreakInfos."};const n=o.sort(((e,t)=>e.classMaxValue-t.classMaxValue)),i=n[n.length-1];let l=e.minValue;if(!r){const t=[];for(let e=0;e<n.length;e++)t.push({value:n[e].classMinValue??l,mappedColor:n[e].symbol.color}),l=n[e].classMaxValue;return t.push({value:i.classMaxValue,mappedColor:i.symbol.color}),this.lookup={rendererJSON:e,remapLut:t},this.canRenderInWebGL=!1,{success:!0}}const u=[];if(null!=t&&null!=s&&null!==a&&s!==a){const r=s.name,o=a.name,i=n[n.length-1],{classMaxValue:c}=i;l=e.minValue;for(const e of t.features){const t=e.attributes[r],s=e.attributes[o],a=s===c?i:s<l?null:n.find((({classMaxValue:e})=>e>s));a&&u.push([t].concat(a.symbol.color))}}else{l=Math.floor(e.minValue);for(let e=0;e<n.length;e++){const t=n[e];for(let e=l;e<t.classMaxValue;e++)u.push([e].concat(t.symbol.color));l=Math.ceil(t.classMaxValue)}i.classMaxValue===l&&u.push([i.classMaxValue].concat(i.symbol.color))}const p=c({colormap:u,fillUnspecified:!1});return this.lookup={rendererJSON:e,colormapLut:p},this.canRenderInWebGL=!0,{success:!0}}_isHistogramRequired(e){return"percentClip"===e||"histogramEqualization"===e}_isValidRasterStatistics(e){return null!=e&&e.length>0&&null!=e[0].min&&null!=e[0].max}_updateStretchRenderer(e){let{stretchType:t,dra:r}=e;if(!("none"===t||e.statistics?.length||this._isValidRasterStatistics(this.rasterInfo.statistics)||r))return{success:!1,error:"Unsupported renderer; StretchRenderer.statistics is required when dynamic range adjustment is not used."};const s=e.histograms||this.rasterInfo.histograms;!this._isHistogramRequired(e.stretchType)||s?.length||r||(t="minMax");const{computeGamma:a,useGamma:o,colorRamp:n}=e;let{gamma:i}=e;if(o&&a&&!i?.length){const t=e.statistics?.length?e.statistics:this.rasterInfo.statistics;i=f(this.rasterInfo.pixelType,t)}const l=this.rasterInfo.pixelType,u=!r&&["u8","u16","s8","s16"].includes(l);if("histogramEqualization"===t){const t=s.map((e=>y(e)));this.lookup={rendererJSON:e,histogramLut:t}}else if(u){const t=h(e,{rasterInfo:this.rasterInfo}),r=m({pixelType:l,...t,gamma:o?i:null,rounding:"floor"});this.lookup={rendererJSON:e,stretchLut:r}}if(n){const t=k(n,{interpolateAlpha:!0});this.lookup||(this.lookup={rendererJSON:e}),this.lookup.colormapLut=c({colormap:t}),this.lookup.rendererJSON=e}return this.lookup.gamma=o&&i?.length?i:null,this.canRenderInWebGL=!0,{success:!0}}_generateStretchWebGLParams(e,t,r){let s=null,a=null;const o=this.lookup&&this.lookup.colormapLut;t.colorRamp&&o&&(s=o.indexedColormap,a=o.offset),"histogramEqualization"===t.stretchType&&(t={...t,stretchType:"minMax"});const{gamma:n}=this.lookup,i=!!(t.useGamma&&n&&n.some((e=>1!==e))),{minCutOff:l,maxCutOff:u,outMin:c,outMax:p}=h(t,{rasterInfo:this.rasterInfo,pixelBlock:e,bandIds:r});let d=0;null!=e&&(d=e.getPlaneCount(),2===d&&((e=e.clone()).statistics=[e.statistics[0]],e.pixels=[e.pixels[0]]));const{bandCount:m}=this.rasterInfo,f=Math.min(3,r?.length||d||m,m),y=new Float32Array(f),g=s||i?1:255;let b;for(b=0;b<l.length;b++)y[b]=u[b]===l[b]?0:(p-c)/(u[b]-l[b])/g;const S=new Float32Array(f);if(i&&n)for(b=0;b<f;b++)n[b]>1?n[b]>2?S[b]=6.5+(n[b]-2)**2.5:S[b]=6.5+100*(2-n[b])**4:S[b]=1;return{bandCount:f,outMin:c/g,outMax:p/g,minCutOff:l,maxCutOff:u,factor:y,useGamma:i,gamma:i?n:[1,1,1],gammaCorrection:i?S:[1,1,1],colormap:s,colormapOffset:a,stretchType:t.stretchType,type:"stretch"}}_generateShadedReliefWebGLParams(e,t=!1,r={x:0,y:0}){let s=null,a=null;const o=this.lookup&&this.lookup.colormapLut;e.colorRamp&&o&&(s=o.indexedColormap,a=o.offset);const n={...e,isGCS:t,resolution:r},i=S(n),l=this.rasterInfo.statistics?.[0];return{...i,minValue:l?.min??0,maxValue:l?.max??8e3,hillshadeType:"traditional"===e.hillshadeType?0:1,type:"hillshade",colormap:s,colormapOffset:a}}_generateVectorFieldWebGLParams(e){const{style:t,inputUnit:r,outputUnit:s,visualVariables:a,symbolTileSize:o,flowRepresentation:n}=e;let i;const l=this.rasterInfo.statistics?.[0].min??0,u=this.rasterInfo.statistics?.[0].max??50,c=a?.find((e=>"sizeInfo"===e.type))??{type:"sizeInfo",field:"Magnitude",maxDataValue:u,maxSize:.8*o,minDataValue:l,minSize:.2*o},p=c.minDataValue??l,d=c.maxDataValue??u,h=null!=c.maxSize&&null!=c.minSize?[c.minSize/o,c.maxSize/o]:[.2,.8];if("wind_speed"===t){const e=(h[0]+h[1])/2;h[0]=h[1]=e}const m=null!=p&&null!=d?[p,d]:null;if("classified_arrow"===t)if(null!=p&&null!=d&&null!=c){i=[];const e=(c.maxDataValue-c.minDataValue)/5;for(let t=0;t<6;t++)i.push(c.minDataValue+e*t)}else i=[0,1e-6,3.5,7,10.5,14];const f="flow_to"===n===("ocean_current_kn"===t||"ocean_current_m"===t)?0:Math.PI,y=a?.find((e=>"rotationInfo"===e.type));return{breakValues:i,dataRange:m,inputUnit:r,outputUnit:s,symbolTileSize:o,symbolPercentRange:h,style:t||"single_arrow",rotation:f,rotationType:this.rasterInfo.storageInfo?.tileInfo&&"vector-uv"===this.rasterInfo.dataType?"geographic":y?.rotationType||e.rotationType,type:"vectorField"}}};function _(e){return p(e)&&0!==e.validPixelCount}e([a({json:{write:!0}})],C.prototype,"rendererJSON",void 0),e([a({type:n,json:{write:!0}})],C.prototype,"rasterInfo",void 0),e([a({json:{write:!0}})],C.prototype,"lookup",void 0),e([a()],C.prototype,"canRenderInWebGL",void 0),C=e([o("esri.renderers.support.RasterSymbolizer")],C);const L=C;export{L as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
+ */
5
+ function n(n){return["u8","s8"].includes(n.pixelType)&&null!=n.statistics?.[0]?.min&&null!=n.statistics[0]?.max&&1===n.bandCount}function t(t,e){const{attributeTable:u,bandCount:r}=t;if(null==u&&n(t))return!0;if(null==u||r>1)return!1;if(e){if(null==u.fields.find((n=>n.name.toLowerCase()===e.toLowerCase())))return!1}return!0}function e(n){const{bandCount:t,dataType:e,pixelType:u}=n;return"elevation"===e||"generic"===e&&1===t&&("s16"===u||"s32"===u||"f32"===u||"f64"===u)}function u(n,t=!1){const{bandCount:e,colormap:u,pixelType:r}=n;return 1===e&&(!!u?.length||!t&&"u8"===r)}function r(n,t=!1){const{attributeTable:e,bandCount:u}=n;return 1===u&&(!t||null!=e||null!=n.histograms)}function o(n){const{dataType:t}=n;return"vector-uv"===t||"vector-magdir"===t}function i(n){const{dataType:t}=n;return"vector-uv"===t||"vector-magdir"===t}export{r as isClassBreaksSupported,u as isColormapRendererSupported,i as isFlowRendererSupported,e as isShadedReliefRendererSupported,n as isSingleBand8BitRasterWithStats,t as isUVRendererSupported,o as isVectorFieldRendererSupported};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Color.js";import"../../rasterRenderers.js";import{getMetersPerUnitForSR as t}from"../../core/unitUtils.js";import n from"../../layers/support/Field.js";import a from"../../layers/support/RasterInfo.js";import l from"../FlowRenderer.js";import r from"./AuthoringInfo.js";import s from"./ClassBreakInfo.js";import{PREDEFINED_JSON_COLOR_RAMPS as o,convertColorRampToColormap as i}from"./colorRampUtils.js";import u from"./UniqueValueInfo.js";import m from"../../rest/support/ClassBreaksDefinition.js";import{createGenerateRendererClassBreaks as c}from"../../rest/support/generateRendererUtils.js";import f from"../../rest/support/MultipartColorRamp.js";import p from"../RasterStretchRenderer.js";import d from"../UniqueValueRenderer.js";import b from"../RasterColormapRenderer.js";import h from"../RasterShadedReliefRenderer.js";import g from"../ClassBreaksRenderer.js";import y from"../VectorFieldRenderer.js";const v=.25,C=f.fromJSON({type:"multipart",colorRamps:[{fromColor:[0,0,255],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]}]}),w=f.fromJSON(o[0]),x=new Set(["scientific","standard-time","vector-uv","vector-magdir","vector-u","vector-v","vector-magnitude","vector-direction"]);function M(e,t){const{attributeTable:n,colormap:a}=e;if(G(e)){const t=K(e);if(null!=t)return t}if(null!=a){const t=N(e);if(null!=t)return t}if(null!=n){const t=B(e);if(null!=t)return t}return j(e,t)}function T(e,t=!1){const n=["raster-stretch"];return W(e)&&n.push("raster-colormap"),z(e)&&n.push("unique-value"),D(e,t)&&n.push("class-breaks"),O(e)&&n.push("raster-shaded-relief"),G(e)&&n.push("vector-field"),_(e)&&n.push("flow"),n}function R(e,t,n){const a=["nearest","bilinear","cubic","majority"].find((e=>e===n?.toLowerCase()));if("Map"===t)return a??"bilinear";if("standard-time"===e.dataType)return a??"nearest";return"thematic"===e.dataType||e.attributeTable||e.colormap?"nearest"===a||"majority"===a?a:"nearest":a??"bilinear"}function j(e,t){e=I(e,t?.variableName);const{bandCount:n}=e;let{bandIds:a,stretchType:l}=t||{};a?.some((e=>e>=n))&&(a=null);let r=e.statistics,s=e.histograms;n>1?(a=a?.length?a:V(e),r=null==r?null:a?.map((e=>r[e])),s=null==s?null:a?.map((e=>s[e]))):a=[0],null==l&&(l=L(e));let o=!1;switch(l){case"none":o=!1;break;case"percent-clip":o=!s?.length;break;default:o=!r?.length}const{dataType:i}=e,u=1===a?.length&&x.has(i)?C:null,m=new p({stretchType:l,dynamicRangeAdjustment:o,colorRamp:u,outputMin:0,outputMax:255,gamma:1===a?.length?[1]:[1,1,1],useGamma:!1});return"percent-clip"===l?m.maxPercent=m.minPercent=v:"standard-deviation"===l&&(m.numberOfStandardDeviations=2),o||null==e.multidimensionalInfo&&!t?.includeStatisticsInStretch||("percent-clip"===l?m.histograms=s:"min-max"!==l&&"standard-deviation"!==l||(m.statistics=r)),m}function I(e,t){if(!t)return e;let n=e.statistics,l=e.histograms;const{multidimensionalInfo:r}=e;if(t&&null!=r){const e=r.variables.find((e=>e.name===t));if(e){const{statistics:t,histograms:a}=e;t?.length&&(n=t),a?.length&&(l=a)}}return a.fromJSON({...e.toJSON(),statistics:n,histograms:l})}function V(e){const t=e.bandCount;if(1===t)return null;if(2===t)return[0];const{bandInfos:n}=e;let a;if(n.length===t){const{red:e,green:t,blue:l,nir:r}=S(n);null!=e&&null!=t&&null!=l?a=[e,t,l]:null!=r&&null!=e&&null!=t&&(a=[r,e,t])}return!a&&t>=3&&(a=[0,1,2]),a}function k(e,t){const n=e.bandInfos.map((({name:e})=>e));return t?.length?t.map((e=>n[e])):n}function S(e){const t={};for(let n=0;n<e.length;n++){const a=e[n],l=a.name.toLowerCase();if("red"===l)t.red=n;else if("green"===l)t.green=n;else if("blue"===l)t.blue=n;else if("nearinfrared"===l||"nearinfrared_1"===l||"nir"===l)t.nir=n;else if(a.maxWavelength&&a.minWavelength){const e=a.minWavelength,l=a.maxWavelength;null==t.blue&&e>=410&&e<=480&&l>=480&&l<=540?t.blue=n:null==t.green&&e>=490&&e<=560&&l>=560&&l<=610?t.green=n:null==t.red&&e>=595&&e<=670&&l>=660&&l<=730?t.red=n:null==t.nir&&e>=700&&e<=860&&l>=800&&l<=950&&(t.nir=n)}}return t}function L(e){let t="percent-clip";const{pixelType:n,dataType:a,histograms:l,statistics:r,multidimensionalInfo:s}=e,o=x.has(a)||"generic"===a&&null!=s;return"u8"!==n||"processed"!==a&&null!=l&&null!=r?"u8"===n||"elevation"===a||o?t="min-max":null!=l?t="percent-clip":null!=r&&(t="min-max"):t="none",t}function B(t,n,a,l){if(!z(t,n))return null;const{attributeTable:s,statistics:o}=t,m=E(s,n),c=F(s,"red"),f=F(s,"green"),p=F(s,"blue"),b=new r,h=[],g=new Set,y=!!(c&&f&&p);if(null!=s)s.features.forEach((t=>{const n=t.attributes[m.name];if(!g.has(t.attributes[m.name])&&null!=n){g.add(n);const a=y&&("single"===c.type||"double"===c.type)&&("single"===f.type||"double"===f.type)&&("single"===p.type||"double"===p.type)&&!s.features.some((e=>e.attributes[c.name]>1||e.attributes[f.name]>1||e.attributes[p.name]>1)),l=a?255:1;h.push(new u({value:t.attributes[m.name],label:t.attributes[m.name]+"",symbol:{type:"simple-fill",style:"solid",outline:null,color:new e(y?[t.attributes[c.name]*l,t.attributes[f.name]*l,t.attributes[p.name]*l,1]:[0,0,0,0])}}))}}));else if(o?.[0])for(let r=o[0].min;r<=o[0].max;r++)h.push(new u({value:r,label:r.toString(),symbol:{type:"simple-fill",style:"solid",outline:null,color:new e([0,0,0,0])}}));if(h.sort(((e,t)=>e.value&&"string"==typeof e.value.valueOf()?0:e.value>t.value?1:-1)),!y){const t=i(w,{numColors:h.length});h.forEach(((n,a)=>n.symbol.color=new e(t[a].slice(1,4)))),b.colorRamp=w}if(a||l){const t=a||i(l,{numColors:h.length}).map((e=>e.slice(1)));h.forEach(((n,a)=>n.symbol.color=new e(t[a]))),b.colorRamp=l}return new d({field:m.name,uniqueValueInfos:h,authoringInfo:b})}function E(e,t,a){let l;return null!=e?(l=t?e.fields.find((e=>t.toLowerCase()===e.name.toLowerCase())):q(e.fields),l||(a||(l=e.fields.find((e=>"string"===e.type))),l||(l=F(e,"value")))):l=new n({name:"value"}),l}function q(e){let t;for(let n=0;n<e.length;n++){const a=e[n].name.toLowerCase();if("string"===e[n].type){if(a.startsWith("class")){t=e[n];break}null==t&&(a.endsWith("name")||a.endsWith("type"))&&(t=e[n])}}return t}function F(e,t){return null==e?null:e.fields.find((e=>e.name.toLowerCase()===t))}function z(e,t){const{attributeTable:n,bandCount:a}=e;if(null==n&&P(e))return!0;if(null==n||a>1)return!1;if(t){if(null==n.fields.find((e=>e.name.toLowerCase()===t.toLowerCase())))return!1}return!0}function W(e){const{bandCount:t,colormap:n}=e;return null!=n&&n.length>0&&1===t}function N(e){if(!W(e))return null;let t;const{attributeTable:n,colormap:a}=e;if(null!=n){const e=F(n,"value"),a=E(n,null,!0);"string"===a.type&&(t={},n.features.forEach((n=>{const l=n.attributes;t[l[e.name]]=a?l[a.name]:l[e.name]})))}return b.createFromColormap(a,t)}function O(e){const{bandCount:t,dataType:n,pixelType:a}=e;return"elevation"===n||"generic"===n&&1===t&&("s16"===a||"s32"===a||"f32"===a||"f64"===a)}function U(e,n="traditional"){if(!O(e))return null;const{extent:a}=e,l=a.width*t(a.spatialReference);return new h({hillshadeType:n,scalingType:l>5e6?"adjusted":"none"})}function D(e,t=!1){const{attributeTable:n,bandCount:a}=e;return 1===a&&(!t||null!=n||null!=e.histograms)}function J(e,t){e=I(e,t?.variableName);const{attributeTable:n}=e;if(!D(e))return null;const a=null!=e.histograms?e.histograms[0]:null,l=null!=t?.numClasses&&isFinite(t?.numClasses)?t.numClasses:5,o=new r({classificationMethod:t?.classificationMethod,colorRamp:t?.colorRamp});let u=t?.field||"value";const f=[],p=[],d=1e3,b=null!=n,h=b&&n.fields.find((e=>"count"===e.name.toLowerCase())),y=b?n.fields.find((e=>e.name.toLowerCase()===u.toLowerCase())):void 0;if(y&&b){u=y.name;const e=n.features.length;let t=0;n.features.forEach((n=>t+=(h?n.attributes[h.name]:50)/e)),n.features.forEach((n=>{const a=n.attributes[y.name],l=h?n.attributes[h.name]:50;if(l>0){p.push(l);const n=Math.max(1,Math.round(l/e/t*d));for(let e=0;e<n;e++)f.push(a)}}))}else{const{pixelType:t}=e,l=(a.max-a.min)/a.size,r=t.includes("s")||t.includes("u"),s=r&&1===l?Math.floor(a.min+.5):a.min,o=r&&1===l?Math.floor(a.max-.5):a.max,i=a.size;let u,m=0;a.counts.forEach((e=>m+=e/i)),a.counts.forEach(((e,t)=>{if(e>0){p.push(e);const r=Math.max(1,Math.round(e/i/m*d));u=b?n.features[t].attributes[y.name]:0===t?s:t===i-1?o:a.min+l*(t+.5);for(let e=0;e<r;e++)f.push(u)}}))}const v=t?.classificationMethod||"natural-breaks";let w=t?.definedInterval;"defined-interval"!==v||w||(w=A(e,y,l));const x=c({values:f,valueFrequency:p,normalizationTotal:null,definition:new m({classificationMethod:v,breakCount:l,definedInterval:w})});let M=t?.colors;if(!M){const e=t?.colorRamp||C;o.colorRamp=e;const n=i(e,{numColors:x.classBreaks.length,interpolateAlpha:!0});M=n.map((e=>e.slice(1)))}const T=x.classBreaks.map(((e,t)=>new s({minValue:e.minValue,maxValue:e.maxValue,label:e.label,symbol:{type:"simple-fill",color:M[t]}})));return new g({field:u,classBreakInfos:T,authoringInfo:o})}function A(e,t,n){let a=0,l=0;if(null!=e.attributeTable){const n=e.attributeTable;a=l=n.features[0].attributes[t.name],n.features.forEach((e=>{const n=e.attributes[t.name];n<a&&(a=n),n>l&&(l=n)}))}else if(null!=e.histograms){const t=e.histograms;a=t[0].min,l=t[0].max}return(l-a)/n}function P(e){return["u8","s8"].includes(e.pixelType)&&null!=e.statistics?.[0]?.min&&null!=e.statistics[0]?.max&&1===e.bandCount}function G(e){const{dataType:t}=e;return"vector-uv"===t||"vector-magdir"===t}function _(e){const{dataType:t}=e;return"vector-uv"===t||"vector-magdir"===t}const H=new Map([["m/s","meter-per-second"],["km/h","kilometer-per-hour"],["knots","knots"],["ft/s","feet-per-second"],["mph","mile-per-hour"]]);function K(e){if(!G(e))return null;let t;if(null!=e.statistics&&e.statistics.length&&("vector-magdir"===e.dataType||"vector-uv"===e.dataType)){const{minMagnitude:n,maxMagnitude:a}=Z(e.dataType,e.statistics);t=[{type:"size",field:"Magnitude",minSize:10,maxSize:40,minDataValue:n,maxDataValue:a}]}const n=null!=e.multidimensionalInfo?H.get(e.multidimensionalInfo.variables[0].unit):null,a=new y({visualVariables:t,inputUnit:n,rotationType:"geographic"});return a.visualVariables=[...a.sizeVariables,...a.rotationVariables],a}function Q(e){return{color:e.symbolLayers[0].material?.color,type:"esriSFS",style:"esriSFSSolid"}}function X(e){if("uniqueValue"===e.type){const t=e.uniqueValueInfos,n=t?.[0].symbol;return n?.symbolLayers?.length&&(e.uniqueValueInfos=t?.map((e=>({value:e.value,label:e.label,symbol:e.symbol?Q(e.symbol):null})))),e}if("classBreaks"===e.type){const t=e.classBreakInfos,n=t[0].symbol;return n?.symbolLayers?.length&&(e.classBreakInfos=t.map((e=>({classMinValue:e.classMinValue,classMaxValue:e.classMaxValue,label:e.label,symbol:e.symbol?Q(e.symbol):null})))),e}return e}function Y(e){if(!_(e))return null;let t;if(null!=e.statistics&&e.statistics.length>0&&("vector-magdir"===e.dataType||"vector-uv"===e.dataType)){const{minMagnitude:n,maxMagnitude:a}=Z(e.dataType,e.statistics);t=[{type:"color",field:"Magnitude",stops:[{value:n,color:"#1020C0"},{value:a,color:"#C02010"}]}]}return new l({visualVariables:t})}function Z(e,t){let n,a;if("vector-magdir"===e)n=t[0].min,a=t[0].max;else{const e=t[0].min,l=t[0].max,r=t[1].min,s=t[1].max;n=0,a=Math.max(Math.abs(e),Math.abs(r),Math.abs(l),Math.abs(s))}return{minMagnitude:n,maxMagnitude:a}}export{J as createClassBreaksRenderer,N as createColormapRenderer,M as createDefaultRenderer,Y as createFlowRenderer,U as createShadedReliefRenderer,j as createStretchRenderer,B as createUVRenderer,K as createVectorFieldRenderer,Z as estimateMagnitudeRange,k as getBandNames,E as getClassField,V as getDefaultBandCombination,R as getDefaultInterpolation,A as getDefinedInterval,F as getField,T as getSupportedRendererTypes,I as getVariableRasterInfo,S as getWellKnownBandIndexes,D as isClassBreaksSupported,W as isColormapRendererSupported,_ as isFlowRendererSupported,O as isShadedReliefRendererSupported,P as isSingleBand8BitRasterWithStats,z as isUVRendererSupported,G as isVectorFieldRendererSupported,X as normalizeRendererJSON};
5
+ import e from"../../Color.js";import"../../rasterRenderers.js";import{getMetersPerUnitForSR as t}from"../../core/unitUtils.js";import n from"../../layers/support/Field.js";import a from"../../layers/support/RasterInfo.js";import l from"../FlowRenderer.js";import r from"./AuthoringInfo.js";import s from"./ClassBreakInfo.js";import{PREDEFINED_JSON_COLOR_RAMPS as i,convertColorRampToColormap as o}from"./colorRampUtils.js";import{isVectorFieldRendererSupported as u,isColormapRendererSupported as m,isUVRendererSupported as c,isClassBreaksSupported as f,isShadedReliefRendererSupported as p,isFlowRendererSupported as d}from"./rasterRendererChecks.js";import h from"./UniqueValueInfo.js";import b from"../../rest/support/ClassBreaksDefinition.js";import{createGenerateRendererClassBreaks as g}from"../../rest/support/generateRendererUtils.js";import y from"../../rest/support/MultipartColorRamp.js";import v from"../RasterStretchRenderer.js";import C from"../UniqueValueRenderer.js";import w from"../RasterColormapRenderer.js";import M from"../RasterShadedReliefRenderer.js";import x from"../ClassBreaksRenderer.js";import R from"../VectorFieldRenderer.js";const T=.25,j=y.fromJSON({type:"multipart",colorRamps:[{fromColor:[0,0,255],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]}]}),I=y.fromJSON(i[0]),V=new Set(["scientific","standard-time","vector-uv","vector-magdir","vector-u","vector-v","vector-magnitude","vector-direction"]);function k(e,t){const{attributeTable:n,colormap:a}=e;if(u(e)){const t=H(e);if(null!=t)return t}if(null!=a){const t=J(e);if(null!=t)return t}if(null!=n){const t=N(e);if(null!=t)return t}return B(e,t)}function S(e,t=!1){const n=["raster-stretch"];return m(e,t)&&n.push("raster-colormap"),c(e)&&n.push("unique-value"),f(e,t)&&n.push("class-breaks"),p(e)&&n.push("raster-shaded-relief"),u(e)&&n.push("vector-field"),d(e)&&n.push("flow"),n}function L(e,t,n){const a=["nearest","bilinear","cubic","majority"].find((e=>e===n?.toLowerCase()));if("Map"===t)return a??"bilinear";if("standard-time"===e.dataType)return a??"nearest";return"thematic"===e.dataType||e.attributeTable||e.colormap?"nearest"===a||"majority"===a?a:"nearest":a??"bilinear"}function B(e,t){e=E(e,t?.variableName);const{bandCount:n}=e;let{bandIds:a,stretchType:l}=t||{};a?.some((e=>e>=n))&&(a=null);let r=e.statistics,s=e.histograms;n>1?(a=a?.length?a:q(e),r=null==r?null:a?.map((e=>r[e])),s=null==s?null:a?.map((e=>s[e]))):a=[0],null==l&&(l=W(e));let i=!1;switch(l){case"none":i=!1;break;case"percent-clip":i=!s?.length;break;default:i=!r?.length}const{dataType:o}=e,u=1===a?.length&&V.has(o)?j:null,m=new v({stretchType:l,dynamicRangeAdjustment:i,colorRamp:u,outputMin:0,outputMax:255,gamma:1===a?.length?[1]:[1,1,1],useGamma:!1});return"percent-clip"===l?m.maxPercent=m.minPercent=T:"standard-deviation"===l&&(m.numberOfStandardDeviations=2),i||null==e.multidimensionalInfo&&!t?.includeStatisticsInStretch||("percent-clip"===l?m.histograms=s:"min-max"!==l&&"standard-deviation"!==l||(m.statistics=r)),m}function E(e,t){if(!t)return e;let n=e.statistics,l=e.histograms;const{multidimensionalInfo:r}=e;if(t&&null!=r){const e=r.variables.find((e=>e.name===t));if(e){const{statistics:t,histograms:a}=e;t?.length&&(n=t),a?.length&&(l=a)}}return a.fromJSON({...e.toJSON(),statistics:n,histograms:l})}function q(e){const t=e.bandCount;if(1===t)return null;if(2===t)return[0];const{bandInfos:n}=e;let a;if(n.length===t){const{red:e,green:t,blue:l,nir:r}=z(n);null!=e&&null!=t&&null!=l?a=[e,t,l]:null!=r&&null!=e&&null!=t&&(a=[r,e,t])}return!a&&t>=3&&(a=[0,1,2]),a}function F(e,t){const n=e.bandInfos.map((({name:e})=>e));return t?.length?t.map((e=>n[e])):n}function z(e){const t={};for(let n=0;n<e.length;n++){const a=e[n],l=a.name.toLowerCase();if("red"===l)t.red=n;else if("green"===l)t.green=n;else if("blue"===l)t.blue=n;else if("nearinfrared"===l||"nearinfrared_1"===l||"nir"===l)t.nir=n;else if(a.maxWavelength&&a.minWavelength){const e=a.minWavelength,l=a.maxWavelength;null==t.blue&&e>=410&&e<=480&&l>=480&&l<=540?t.blue=n:null==t.green&&e>=490&&e<=560&&l>=560&&l<=610?t.green=n:null==t.red&&e>=595&&e<=670&&l>=660&&l<=730?t.red=n:null==t.nir&&e>=700&&e<=860&&l>=800&&l<=950&&(t.nir=n)}}return t}function W(e){let t="percent-clip";const{pixelType:n,dataType:a,histograms:l,statistics:r,multidimensionalInfo:s}=e,i=V.has(a)||"generic"===a&&null!=s;return"u8"!==n||"processed"!==a&&null!=l&&null!=r?"u8"===n||"elevation"===a||i?t="min-max":null!=l?t="percent-clip":null!=r&&(t="min-max"):t="none",t}function N(t,n,a,l){if(!c(t,n))return null;const{attributeTable:s,statistics:i}=t,u=O(s,n),m=D(s,"red"),f=D(s,"green"),p=D(s,"blue"),d=new r,b=[],g=new Set,y=!!(m&&f&&p);if(null!=s)s.features.forEach((t=>{const n=t.attributes[u.name];if(!g.has(t.attributes[u.name])&&null!=n){g.add(n);const a=y&&("single"===m.type||"double"===m.type)&&("single"===f.type||"double"===f.type)&&("single"===p.type||"double"===p.type)&&!s.features.some((e=>e.attributes[m.name]>1||e.attributes[f.name]>1||e.attributes[p.name]>1)),l=a?255:1;b.push(new h({value:t.attributes[u.name],label:t.attributes[u.name]+"",symbol:{type:"simple-fill",style:"solid",outline:null,color:new e(y?[t.attributes[m.name]*l,t.attributes[f.name]*l,t.attributes[p.name]*l,1]:[0,0,0,0])}}))}}));else if(i?.[0])for(let r=i[0].min;r<=i[0].max;r++)b.push(new h({value:r,label:r.toString(),symbol:{type:"simple-fill",style:"solid",outline:null,color:new e([0,0,0,0])}}));if(b.sort(((e,t)=>e.value&&"string"==typeof e.value.valueOf()?0:e.value>t.value?1:-1)),!y){const t=o(I,{numColors:b.length});b.forEach(((n,a)=>n.symbol.color=new e(t[a].slice(1,4)))),d.colorRamp=I}if(a||l){const t=a||o(l,{numColors:b.length}).map((e=>e.slice(1)));b.forEach(((n,a)=>n.symbol.color=new e(t[a]))),d.colorRamp=l}return new C({field:u.name,uniqueValueInfos:b,authoringInfo:d})}function O(e,t,a){let l;return null!=e?(l=t?e.fields.find((e=>t.toLowerCase()===e.name.toLowerCase())):U(e.fields),l||(a||(l=e.fields.find((e=>"string"===e.type))),l||(l=D(e,"value")))):l=new n({name:"value"}),l}function U(e){let t;for(let n=0;n<e.length;n++){const a=e[n].name.toLowerCase();if("string"===e[n].type){if(a.startsWith("class")){t=e[n];break}null==t&&(a.endsWith("name")||a.endsWith("type"))&&(t=e[n])}}return t}function D(e,t){return null==e?null:e.fields.find((e=>e.name.toLowerCase()===t))}function J(e){if(!m(e))return null;let t;const{attributeTable:n,colormap:a}=e;if(null!=n){const e=D(n,"value"),a=O(n,null,!0);"string"===a.type&&(t={},n.features.forEach((n=>{const l=n.attributes;t[l[e.name]]=a?l[a.name]:l[e.name]})))}return w.createFromColormap(a,t)}function A(e,n="traditional"){if(!p(e))return null;const{extent:a}=e,l=a.width*t(a.spatialReference);return new M({hillshadeType:n,scalingType:l>5e6?"adjusted":"none"})}function P(e,t){e=E(e,t?.variableName);const{attributeTable:n}=e;if(!f(e))return null;const a=null!=e.histograms?e.histograms[0]:null,l=null!=t?.numClasses&&isFinite(t?.numClasses)?t.numClasses:5,i=new r({classificationMethod:t?.classificationMethod,colorRamp:t?.colorRamp});let u=t?.field||"value";const m=[],c=[],p=1e3,d=null!=n,h=d&&n.fields.find((e=>"count"===e.name.toLowerCase())),y=d?n.fields.find((e=>e.name.toLowerCase()===u.toLowerCase())):void 0;if(y&&d){u=y.name;const e=n.features.length;let t=0;n.features.forEach((n=>t+=(h?n.attributes[h.name]:50)/e)),n.features.forEach((n=>{const a=n.attributes[y.name],l=h?n.attributes[h.name]:50;if(l>0){c.push(l);const n=Math.max(1,Math.round(l/e/t*p));for(let e=0;e<n;e++)m.push(a)}}))}else{const{pixelType:t}=e,l=(a.max-a.min)/a.size,r=t.includes("s")||t.includes("u"),s=r&&1===l?Math.floor(a.min+.5):a.min,i=r&&1===l?Math.floor(a.max-.5):a.max,o=a.size;let u,f=0;a.counts.forEach((e=>f+=e/o)),a.counts.forEach(((e,t)=>{if(e>0){c.push(e);const r=Math.max(1,Math.round(e/o/f*p));u=d?n.features[t].attributes[y.name]:0===t?s:t===o-1?i:a.min+l*(t+.5);for(let e=0;e<r;e++)m.push(u)}}))}const v=t?.classificationMethod||"natural-breaks";let C=t?.definedInterval;"defined-interval"!==v||C||(C=G(e,y,l));const w=g({values:m,valueFrequency:c,normalizationTotal:null,definition:new b({classificationMethod:v,breakCount:l,definedInterval:C})});let M=t?.colors;if(!M){const e=t?.colorRamp||j;i.colorRamp=e;const n=o(e,{numColors:w.classBreaks.length,interpolateAlpha:!0});M=n.map((e=>e.slice(1)))}const R=w.classBreaks.map(((e,t)=>new s({minValue:e.minValue,maxValue:e.maxValue,label:e.label,symbol:{type:"simple-fill",color:M[t]}})));return new x({field:u,classBreakInfos:R,authoringInfo:i})}function G(e,t,n){let a=0,l=0;if(null!=e.attributeTable){const n=e.attributeTable;a=l=n.features[0].attributes[t.name],n.features.forEach((e=>{const n=e.attributes[t.name];n<a&&(a=n),n>l&&(l=n)}))}else if(null!=e.histograms){const t=e.histograms;a=t[0].min,l=t[0].max}return(l-a)/n}const _=new Map([["m/s","meter-per-second"],["km/h","kilometer-per-hour"],["knots","knots"],["ft/s","feet-per-second"],["mph","mile-per-hour"]]);function H(e){if(!u(e))return null;let t;if(null!=e.statistics&&e.statistics.length&&("vector-magdir"===e.dataType||"vector-uv"===e.dataType)){const{minMagnitude:n,maxMagnitude:a}=Y(e.dataType,e.statistics);t=[{type:"size",field:"Magnitude",minSize:10,maxSize:40,minDataValue:n,maxDataValue:a}]}const n=null!=e.multidimensionalInfo?_.get(e.multidimensionalInfo.variables[0].unit):null,a=new R({visualVariables:t,inputUnit:n,rotationType:"geographic"});return a.visualVariables=[...a.sizeVariables,...a.rotationVariables],a}function K(e){return{color:e.symbolLayers[0].material?.color,type:"esriSFS",style:"esriSFSSolid"}}function Q(e){if("uniqueValue"===e.type){const t=e.uniqueValueInfos,n=t?.[0].symbol;return n?.symbolLayers?.length&&(e.uniqueValueInfos=t?.map((e=>({value:e.value,label:e.label,symbol:e.symbol?K(e.symbol):null})))),e}if("classBreaks"===e.type){const t=e.classBreakInfos,n=t[0].symbol;return n?.symbolLayers?.length&&(e.classBreakInfos=t.map((e=>({classMinValue:e.classMinValue,classMaxValue:e.classMaxValue,label:e.label,symbol:e.symbol?K(e.symbol):null})))),e}return e}function X(e){if(!d(e))return null;let t;if(null!=e.statistics&&e.statistics.length>0&&("vector-magdir"===e.dataType||"vector-uv"===e.dataType)){const{minMagnitude:n,maxMagnitude:a}=Y(e.dataType,e.statistics);t=[{type:"color",field:"Magnitude",stops:[{value:n,color:"#1020C0"},{value:a,color:"#C02010"}]}]}return new l({visualVariables:t})}function Y(e,t){let n,a;if("vector-magdir"===e)n=t[0].min,a=t[0].max;else{const e=t[0].min,l=t[0].max,r=t[1].min,s=t[1].max;n=0,a=Math.max(Math.abs(e),Math.abs(r),Math.abs(l),Math.abs(s))}return{minMagnitude:n,maxMagnitude:a}}export{P as createClassBreaksRenderer,J as createColormapRenderer,k as createDefaultRenderer,X as createFlowRenderer,A as createShadedReliefRenderer,B as createStretchRenderer,N as createUVRenderer,H as createVectorFieldRenderer,Y as estimateMagnitudeRange,F as getBandNames,O as getClassField,q as getDefaultBandCombination,L as getDefaultInterpolation,G as getDefinedInterval,D as getField,S as getSupportedRendererTypes,E as getVariableRasterInfo,z as getWellKnownBandIndexes,Q as normalizeRendererJSON};
package/request.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"./config.js";import{id as t}from"./kernel.js";import r from"./core/Error.js";import has from"./core/has.js";import{clone as s}from"./core/lang.js";import{onAbort as o,isAbortError as a,createAbortError as n,isAborted as i}from"./core/promiseUtils.js";import{isDataProtocol as l,isBlobProtocol as u,normalize as c,getInterceptor as d,isTrustedServer as p,getOrigin as h,toHTTPS as m,addQueryParameter as f,objectToQuery as y,getProxyRule as w,getProxyUrl as g,addQueryParameters as b,hasSameOrigin as q,getAppUrl as T,addProxyRule as k}from"./core/urlUtils.js";import{isSecureProxyService as S}from"./portal/support/urlUtils.js";import{supportsApiKey as O}from"./support/apiKeyUtils.js";import{registerNoCorsDomains as C,isNoCorsRequestRequired as v,sendNoCorsRequest as x,loadImageAsync as E}from"./support/requestUtils.js";async function L(e,t){const r=l(e),s=u(e);s||r||(e=c(e));const a={url:e,requestOptions:{...t}};let n=d(e);if(n){const e=await W(n,a);if(null!=e)return{data:e,getHeader:I,httpStatus:200,requestOptions:a.requestOptions,url:a.url};n.after||n.error||(n=null)}if(e=a.url,"image"===(t=a.requestOptions).responseType&&(has("host-webworker")||has("host-node")))throw H("request:invalid-parameters",new Error("responseType 'image' is not supported in Web Workers or Node environment"),a);if("head"===t.method){if(t.body)throw H("request:invalid-parameters",new Error("body parameter cannot be set when method is 'head'"),a);if(r||s)throw H("request:invalid-parameters",new Error("data and blob URLs are not supported for method 'head'"),a)}if(await N(),U)return U.execute(e,t);const i=new AbortController;o(t,(()=>i.abort()));const p={controller:i,credential:void 0,credentialToken:void 0,fetchOptions:void 0,hasToken:!1,interceptor:n,params:a,redoRequest:!1,useIdentity:j.useIdentity,useProxy:!1,useSSL:!1,withCredentials:!1},h=await X(p);return n?.after?.(h),h}let U;const j=e.request,P="FormData"in globalThis,D=[499,498,403,401],_=["COM_0056","COM_0057","SB_0008"],F=[/\/arcgis\/tokens/i,/\/sharing(\/rest)?\/generatetoken/i,/\/rest\/info/i],I=()=>null,M=Symbol();function A(e){const t=h(e);t&&!L._corsServers.includes(t)&&L._corsServers.push(t)}function R(e){const t=h(e);return!t||t.endsWith(".arcgis.com")||L._corsServers.includes(t)||p(t)}function H(e,t,o,i){let l="Error";const u={url:o.url,requestOptions:o.requestOptions,getHeader:I,ssl:!1};if(t instanceof r)return t.details?(t.details=s(t.details),t.details.url=o.url,t.details.requestOptions=o.requestOptions):t.details=u,t;if(t){const e=i&&(e=>i.headers.get(e)),r=i&&i.status,s=t.message;s&&(l=s),e&&(u.getHeader=e),u.httpStatus=(null!=t.httpCode?t.httpCode:t.code)||r||0,u.subCode=t.subcode,u.messageCode=t.messageCode,"string"==typeof t.details?u.messages=[t.details]:u.messages=t.details,u.raw=M in t?t[M]:t}return a(t)?n():new r(e,l,u)}async function N(){has("host-webworker")?U||(U=await import("./core/workers/request.js")):L._abortableFetch||(L._abortableFetch=globalThis.fetch.bind(globalThis))}async function B(){t||await import("./identity/IdentityManager.js")}async function $(r){const s=r.params.url,o=r.params.requestOptions,a=r.controller.signal,n=o.body;let l=null,u=null;if(P&&"HTMLFormElement"in globalThis&&(n instanceof FormData?l=n:n instanceof HTMLFormElement&&(l=new FormData(n))),"string"==typeof n&&(u=n),r.fetchOptions={cache:o.cacheBust&&!L._abortableFetch.polyfill?"no-cache":"default",credentials:"same-origin",headers:o.headers||{},method:"head"===o.method?"HEAD":"GET",mode:"cors",priority:j.priority,redirect:"follow",signal:a},(l||u)&&(r.fetchOptions.body=l||u),"anonymous"===o.authMode&&(r.useIdentity=!1),r.hasToken=!!(/token=/i.test(s)||o.query?.token||l?.get("token")),!r.hasToken&&e.apiKey&&O(s)&&(o.query||(o.query={}),o.query.token=e.apiKey,r.hasToken=!0),r.useIdentity&&!r.hasToken&&!r.credentialToken&&!z(s)&&!i(a)){let e;"immediate"===o.authMode?(await B(),e=await t.getCredential(s,{signal:a}),r.credential=e):"no-prompt"===o.authMode?(await B(),e=await t.getCredential(s,{prompt:!1,signal:a}).catch((()=>{})),r.credential=e):t&&(e=t.findCredential(s)),e&&(r.credentialToken=e.token,r.useSSL=!!e.ssl)}}function z(e){return F.some((t=>t.test(e)))}async function K(e){let r=e.params.url;const s=e.params.requestOptions,o=e.fetchOptions??{},a=u(r)||l(r),i=s.responseType||"json",c=a?0:null!=s.timeout?s.timeout:j.timeout;let d=!1;if(!a){e.useSSL&&(r=m(r)),s.cacheBust&&"default"===o.cache&&(r=f(r,"request.preventCache",Date.now()));let a={...s.query};e.credentialToken&&(a.token=e.credentialToken);let n=y(a);has("esri-url-encodes-apostrophe")&&(n=n.replace(/'/g,"%27"));const i=r.length+1+n.length;let l;d="delete"===s.method||"post"===s.method||"put"===s.method||!!s.body||i>j.maxUrlLength;const u=s.useProxy||!!w(r);if(u){const e=g(r);l=e.path,!d&&l.length+1+i>j.maxUrlLength&&(d=!0),e.query&&(a={...e.query,...a})}if("HEAD"===o.method&&(d||u)){if(d){if(i>j.maxUrlLength)throw H("request:invalid-parameters",new Error("URL exceeds maximum length"),e.params);throw H("request:invalid-parameters",new Error("cannot use POST request when method is 'head'"),e.params)}if(u)throw H("request:invalid-parameters",new Error("cannot use proxy when method is 'head'"),e.params)}if(d?(o.method="delete"===s.method?"DELETE":"put"===s.method?"PUT":"POST",s.body?r=b(r,a):(o.body=y(a),o.headers||(o.headers={}),o.headers["Content-Type"]="application/x-www-form-urlencoded")):r=b(r,a),u&&(e.useProxy=!0,r=`${l}?${r}`),a.token&&P&&o.body instanceof FormData&&!S(r)&&o.body.set("token",a.token),s.hasOwnProperty("withCredentials"))e.withCredentials=s.withCredentials;else if(!q(r,T()))if(p(r))e.withCredentials=!0;else if(t){const s=t.findServerInfo(r);s&&s.webTierAuth&&(e.withCredentials=!0)}e.withCredentials&&(o.credentials="include",v(r)&&await x(d?b(r,a):r))}let O,C,E=0,U=!1;c>0&&(E=setTimeout((()=>{U=!0,e.controller.abort()}),c));try{if("native-request-init"===s.responseType)C=o,C.url=r;else if("image"!==s.responseType||"default"!==o.cache||"GET"!==o.method||d||G(s.headers)||!a&&!e.useProxy&&j.proxyUrl&&!R(r)){if(O=await L._abortableFetch(r,o),e.useProxy||A(r),"native"===s.responseType)C=O;else if("HEAD"!==o.method)if(O.ok){switch(i){case"array-buffer":C=await O.arrayBuffer();break;case"blob":case"image":C=await O.blob();break;default:C=await O.text()}if(E&&(clearTimeout(E),E=0),"json"===i||"xml"===i||"document"===i)if(C)switch(i){case"json":C=JSON.parse(C);break;case"xml":C=J(C,"application/xml");break;case"document":C=J(C,"text/html")}else C=null;if(C){if("array-buffer"===i||"blob"===i){const e=O.headers.get("Content-Type");if(e&&/application\/json|text\/plain/i.test(e)&&C["blob"===i?"size":"byteLength"]<=750)try{const e=await new Response(C).json();e.error&&(C=e)}catch{}}"image"===i&&C instanceof Blob&&(C=await V(URL.createObjectURL(C),e,!0))}}else C=await O.text()}else C=await V(r,e)}catch(D){if("AbortError"===D.name){if(U)throw new Error("Timeout exceeded");throw n("Request canceled")}if(!(!O&&D instanceof TypeError&&j.proxyUrl)||s.body||"delete"===s.method||"head"===s.method||"post"===s.method||"put"===s.method||e.useProxy||R(r))throw D;e.redoRequest=!0,k({proxyUrl:j.proxyUrl,urlPrefix:h(r)??""})}finally{E&&clearTimeout(E)}return[O,C]}async function W(e,t){if(null!=e.responseData)return e.responseData;if(e.headers&&(t.requestOptions.headers={...t.requestOptions.headers,...e.headers}),e.query&&(t.requestOptions.query={...t.requestOptions.query,...e.query}),e.before){let o,a;try{a=await e.before(t)}catch(s){o=H("request:interceptor",s,t)}if((a instanceof Error||a instanceof r)&&(o=H("request:interceptor",a,t)),o)throw e.error&&e.error(o),o;return a}}function G(e){if(e)for(const t of Object.getOwnPropertyNames(e))if(e[t])return!0;return!1}function J(e,t){let r;try{r=(new DOMParser).parseFromString(e,t)}catch{}if(!r||r.getElementsByTagName("parsererror").length)throw new SyntaxError("XML Parse error");return r}async function X(e){let r,s;await $(e);try{do{[r,s]=await K(e)}while(!await Q(e,r,s))}catch(n){const t=H("request:server",n,e.params,r);throw t.details.ssl=e.useSSL,e.interceptor&&e.interceptor.error&&e.interceptor.error(t),t}const o=e.params.url;if(s&&/\/sharing\/rest\/(accounts|portals)\/self/i.test(o)){if(!e.hasToken&&!e.credentialToken&&s.user?.username&&!p(o)){const e=h(o,!0);e&&j.trustedServers.push(e)}Array.isArray(s.authorizedCrossOriginNoCorsDomains)&&C(s.authorizedCrossOriginNoCorsDomains)}const a=e.credential;if(a&&t){const e=t.findServerInfo(a.server);let r=e&&e.owningSystemUrl;if(r){r=r.replace(/\/?$/,"/sharing");const e=t.findCredential(r,a.userId);e&&-1===t._getIdenticalSvcIdx(r,e)&&e.resources.unshift(r)}}return{data:s,getHeader:r?e=>r?.headers.get(e):I,httpStatus:r?.status??200,requestOptions:e.params.requestOptions,ssl:e.useSSL,url:e.params.url}}async function Q(e,r,s){if(e.redoRequest)return e.redoRequest=!1,!1;const o=e.params.requestOptions;if(!r||"native"===o.responseType||"native-request-init"===o.responseType)return!0;let a,n;if(!r.ok)throw a=new Error(`Unable to load ${r.url} status: ${r.status}`),a[M]=s,a;s&&(s.error?a=s.error:"error"===s.status&&Array.isArray(s.messages)&&(a={...s},a[M]=s,a.details=s.messages));let i,l=null;a&&(n=Number(a.code),l=a.hasOwnProperty("subcode")?Number(a.subcode):null,i=a.messageCode,i=i&&i.toUpperCase());const u=o.authMode;if(403===n&&(4===l||a.message&&a.message.toLowerCase().includes("ssl")&&!a.message.toLowerCase().includes("permission"))){if(!e.useSSL)return e.useSSL=!0,!1}else if(!e.hasToken&&e.useIdentity&&("no-prompt"!==u||498===n)&&void 0!==n&&D.includes(n)&&!z(e.params.url)&&(403!==n||i&&!_.includes(i)&&(null==l||2===l&&e.credentialToken))){await B();try{const r=await t.getCredential(e.params.url,{error:H("request:server",a,e.params),prompt:"no-prompt"!==u,signal:e.controller.signal,token:e.credentialToken});return e.credential=r,e.credentialToken=r.token,e.useSSL=e.useSSL||r.ssl,!1}catch(c){if("no-prompt"===u)return e.credential=void 0,e.credentialToken=void 0,!1;a=c}}if(a)throw a;return!0}function V(e,t,r=!1){const s=t.controller.signal,o=new Image;return t.withCredentials?o.crossOrigin="use-credentials":o.crossOrigin="anonymous",o.alt="",o.fetchPriority=j.priority,o.src=e,E(o,e,r,s)}L._abortableFetch=null,L._corsServers=["https://server.arcgisonline.com","https://services.arcgisonline.com"];export{L as default};
5
+ import e from"./config.js";import{id as t}from"./kernel.js";import r from"./core/Error.js";import has from"./core/has.js";import{clone as s}from"./core/lang.js";import{onAbort as o,isAbortError as a,createAbortError as n,isAborted as i}from"./core/promiseUtils.js";import{isDataProtocol as l,isBlobProtocol as u,normalize as c,getInterceptor as d,isTrustedServer as p,getOrigin as h,toHTTPS as m,addQueryParameter as f,objectToQuery as y,getProxyRule as w,getProxyUrl as g,addQueryParameters as b,hasSameOrigin as q,getAppUrl as T,addProxyRule as k}from"./core/urlUtils.js";import{isSecureProxyService as S}from"./portal/support/urlUtils.js";import{supportsApiKey as O}from"./support/apiKeyUtils.js";import{registerNoCorsDomains as C,isNoCorsRequestRequired as v,sendNoCorsRequest as x,loadImageAsync as E}from"./support/requestUtils.js";async function L(e,t){const r=l(e),s=u(e);s||r||(e=c(e));const a={url:e,requestOptions:{...t}};let n=d(e);if(n){const e=await W(n,a);if(null!=e)return{data:e,getHeader:I,httpStatus:200,requestOptions:a.requestOptions,url:a.url};n.after||n.error||(n=null)}if(e=a.url,"image"===(t=a.requestOptions).responseType&&(has("host-webworker")||has("host-node")))throw H("request:invalid-parameters",new Error("responseType 'image' is not supported in Web Workers or Node environment"),a);if("head"===t.method){if(t.body)throw H("request:invalid-parameters",new Error("body parameter cannot be set when method is 'head'"),a);if(r||s)throw H("request:invalid-parameters",new Error("data and blob URLs are not supported for method 'head'"),a)}if(await N(),U)return U.execute(e,t);const i=new AbortController;o(t,(()=>i.abort()));const p={controller:i,credential:void 0,credentialToken:void 0,fetchOptions:void 0,hasToken:!1,interceptor:n,params:a,redoRequest:!1,useIdentity:j.useIdentity,useProxy:!1,useSSL:!1,withCredentials:!1},h=await X(p);return n?.after?.(h),h}let U;const j=e.request,P="FormData"in globalThis,D=[499,498,403,401],_=["COM_0056","COM_0057","SB_0008"],F=[/\/arcgis\/tokens/i,/\/sharing(\/rest)?\/generatetoken/i,/\/rest\/info/i],I=()=>null,M=Symbol();function A(e){const t=h(e);t&&!L._corsServers.includes(t)&&L._corsServers.push(t)}function R(e){const t=h(e);return!t||t.endsWith(".arcgis.com")||L._corsServers.includes(t)||p(t)}function H(e,t,o,i){let l="Error";const u={url:o.url,requestOptions:o.requestOptions,getHeader:I,ssl:!1};if(t instanceof r)return t.details?(t.details=s(t.details),t.details.url=o.url,t.details.requestOptions=o.requestOptions):t.details=u,t;if(t){const e=i&&(e=>i.headers.get(e)),r=i&&i.status,s=t.message;s&&(l=s),e&&(u.getHeader=e),u.httpStatus=(null!=t.httpCode?t.httpCode:t.code)||r||0,u.subCode=t.subcode,u.messageCode=t.messageCode,"string"==typeof t.details?u.messages=[t.details]:u.messages=t.details,u.raw=M in t?t[M]:t}return a(t)?n():new r(e,l,u)}async function N(){has("host-webworker")?U||(U=await import("./core/workers/request.js")):L._abortableFetch||(L._abortableFetch=globalThis.fetch.bind(globalThis))}async function B(){t||await import("./identity/IdentityManager.js")}async function $(r){const s=r.params.url,o=r.params.requestOptions,a=r.controller.signal,n=o.body;let l=null,u=null;if(P&&"HTMLFormElement"in globalThis&&(n instanceof FormData?l=n:n instanceof HTMLFormElement&&(l=new FormData(n))),"string"==typeof n&&(u=n),r.fetchOptions={cache:o.cacheBust&&!("polyfill"in L._abortableFetch)?"no-cache":"default",credentials:"same-origin",headers:o.headers||{},method:"head"===o.method?"HEAD":"GET",mode:"cors",priority:j.priority,redirect:"follow",signal:a},(l||u)&&(r.fetchOptions.body=l||u),"anonymous"===o.authMode&&(r.useIdentity=!1),r.hasToken=!!(/token=/i.test(s)||o.query?.token||l?.get("token")),!r.hasToken&&e.apiKey&&O(s)&&(o.query||(o.query={}),o.query.token=e.apiKey,r.hasToken=!0),r.useIdentity&&!r.hasToken&&!r.credentialToken&&!z(s)&&!i(a)){let e;"immediate"===o.authMode?(await B(),e=await t.getCredential(s,{signal:a}),r.credential=e):"no-prompt"===o.authMode?(await B(),e=await t.getCredential(s,{prompt:!1,signal:a}).catch((()=>{})),r.credential=e):t&&(e=t.findCredential(s)),e&&(r.credentialToken=e.token,r.useSSL=!!e.ssl)}}function z(e){return F.some((t=>t.test(e)))}async function K(e){let r=e.params.url;const s=e.params.requestOptions,o=e.fetchOptions??{},a=u(r)||l(r),i=s.responseType||"json",c=a?0:null!=s.timeout?s.timeout:j.timeout;let d=!1;if(!a){e.useSSL&&(r=m(r)),s.cacheBust&&"default"===o.cache&&(r=f(r,"request.preventCache",Date.now()));let a={...s.query};e.credentialToken&&(a.token=e.credentialToken);let n=y(a);has("esri-url-encodes-apostrophe")&&(n=n.replace(/'/g,"%27"));const i=r.length+1+n.length;let l;d="delete"===s.method||"post"===s.method||"put"===s.method||!!s.body||i>j.maxUrlLength;const u=s.useProxy||!!w(r);if(u){const e=g(r);l=e.path,!d&&l.length+1+i>j.maxUrlLength&&(d=!0),e.query&&(a={...e.query,...a})}if("HEAD"===o.method&&(d||u)){if(d){if(i>j.maxUrlLength)throw H("request:invalid-parameters",new Error("URL exceeds maximum length"),e.params);throw H("request:invalid-parameters",new Error("cannot use POST request when method is 'head'"),e.params)}if(u)throw H("request:invalid-parameters",new Error("cannot use proxy when method is 'head'"),e.params)}if(d?(o.method="delete"===s.method?"DELETE":"put"===s.method?"PUT":"POST",s.body?r=b(r,a):(o.body=y(a),o.headers||(o.headers={}),o.headers["Content-Type"]="application/x-www-form-urlencoded")):r=b(r,a),u&&(e.useProxy=!0,r=`${l}?${r}`),a.token&&P&&o.body instanceof FormData&&!S(r)&&o.body.set("token",a.token),s.hasOwnProperty("withCredentials"))e.withCredentials=s.withCredentials;else if(!q(r,T()))if(p(r))e.withCredentials=!0;else if(t){const s=t.findServerInfo(r);s&&s.webTierAuth&&(e.withCredentials=!0)}e.withCredentials&&(o.credentials="include",v(r)&&await x(d?b(r,a):r))}let O,C,E=0,U=!1;c>0&&(E=setTimeout((()=>{U=!0,e.controller.abort()}),c));try{if("native-request-init"===s.responseType)C=o,C.url=r;else if("image"!==s.responseType||"default"!==o.cache||"GET"!==o.method||d||G(s.headers)||!a&&!e.useProxy&&j.proxyUrl&&!R(r)){if(O=await L._abortableFetch(r,o),e.useProxy||A(r),"native"===s.responseType)C=O;else if("HEAD"!==o.method)if(O.ok){switch(i){case"array-buffer":C=await O.arrayBuffer();break;case"blob":case"image":C=await O.blob();break;default:C=await O.text()}if(E&&(clearTimeout(E),E=0),"json"===i||"xml"===i||"document"===i)if(C)switch(i){case"json":C=JSON.parse(C);break;case"xml":C=J(C,"application/xml");break;case"document":C=J(C,"text/html")}else C=null;if(C){if("array-buffer"===i||"blob"===i){const e=O.headers.get("Content-Type");if(e&&/application\/json|text\/plain/i.test(e)&&C["blob"===i?"size":"byteLength"]<=750)try{const e=await new Response(C).json();e.error&&(C=e)}catch{}}"image"===i&&C instanceof Blob&&(C=await V(URL.createObjectURL(C),e,!0))}}else C=await O.text()}else C=await V(r,e)}catch(D){if("AbortError"===D.name){if(U)throw new Error("Timeout exceeded");throw n("Request canceled")}if(!(!O&&D instanceof TypeError&&j.proxyUrl)||s.body||"delete"===s.method||"head"===s.method||"post"===s.method||"put"===s.method||e.useProxy||R(r))throw D;e.redoRequest=!0,k({proxyUrl:j.proxyUrl,urlPrefix:h(r)??""})}finally{E&&clearTimeout(E)}return[O,C]}async function W(e,t){if(null!=e.responseData)return e.responseData;if(e.headers&&(t.requestOptions.headers={...t.requestOptions.headers,...e.headers}),e.query&&(t.requestOptions.query={...t.requestOptions.query,...e.query}),e.before){let o,a;try{a=await e.before(t)}catch(s){o=H("request:interceptor",s,t)}if((a instanceof Error||a instanceof r)&&(o=H("request:interceptor",a,t)),o)throw e.error&&e.error(o),o;return a}}function G(e){if(e)for(const t of Object.getOwnPropertyNames(e))if(e[t])return!0;return!1}function J(e,t){let r;try{r=(new DOMParser).parseFromString(e,t)}catch{}if(!r||r.getElementsByTagName("parsererror").length)throw new SyntaxError("XML Parse error");return r}async function X(e){let r,s;await $(e);try{do{[r,s]=await K(e)}while(!await Q(e,r,s))}catch(n){const t=H("request:server",n,e.params,r);throw t.details.ssl=e.useSSL,e.interceptor&&e.interceptor.error&&e.interceptor.error(t),t}const o=e.params.url;if(s&&/\/sharing\/rest\/(accounts|portals)\/self/i.test(o)){if(!e.hasToken&&!e.credentialToken&&s.user?.username&&!p(o)){const e=h(o,!0);e&&j.trustedServers.push(e)}Array.isArray(s.authorizedCrossOriginNoCorsDomains)&&C(s.authorizedCrossOriginNoCorsDomains)}const a=e.credential;if(a&&t){const e=t.findServerInfo(a.server);let r=e&&e.owningSystemUrl;if(r){r=r.replace(/\/?$/,"/sharing");const e=t.findCredential(r,a.userId);e&&-1===t._getIdenticalSvcIdx(r,e)&&e.resources.unshift(r)}}return{data:s,getHeader:r?e=>r?.headers.get(e):I,httpStatus:r?.status??200,requestOptions:e.params.requestOptions,ssl:e.useSSL,url:e.params.url}}async function Q(e,r,s){if(e.redoRequest)return e.redoRequest=!1,!1;const o=e.params.requestOptions;if(!r||"native"===o.responseType||"native-request-init"===o.responseType)return!0;let a,n;if(!r.ok)throw a=new Error(`Unable to load ${r.url} status: ${r.status}`),a[M]=s,a;s&&(s.error?a=s.error:"error"===s.status&&Array.isArray(s.messages)&&(a={...s},a[M]=s,a.details=s.messages));let i,l=null;a&&(n=Number(a.code),l=a.hasOwnProperty("subcode")?Number(a.subcode):null,i=a.messageCode,i=i&&i.toUpperCase());const u=o.authMode;if(403===n&&(4===l||a.message&&a.message.toLowerCase().includes("ssl")&&!a.message.toLowerCase().includes("permission"))){if(!e.useSSL)return e.useSSL=!0,!1}else if(!e.hasToken&&e.useIdentity&&("no-prompt"!==u||498===n)&&void 0!==n&&D.includes(n)&&!z(e.params.url)&&(403!==n||i&&!_.includes(i)&&(null==l||2===l&&e.credentialToken))){await B();try{const r=await t.getCredential(e.params.url,{error:H("request:server",a,e.params),prompt:"no-prompt"!==u,signal:e.controller.signal,token:e.credentialToken});return e.credential=r,e.credentialToken=r.token,e.useSSL=e.useSSL||r.ssl,!1}catch(c){if("no-prompt"===u)return e.credential=void 0,e.credentialToken=void 0,!1;a=c}}if(a)throw a;return!0}function V(e,t,r=!1){const s=t.controller.signal,o=new Image;return t.withCredentials?o.crossOrigin="use-credentials":o.crossOrigin="anonymous",o.alt="",o.fetchPriority=j.priority,o.src=e,E(o,e,r,s)}L._abortableFetch=null,L._corsServers=["https://server.arcgisonline.com","https://services.arcgisonline.com"];export{L as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../request.js";import{urlToObject as e,join as n}from"../../../core/urlUtils.js";import{getJsonType as r}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as i}from"../../../geometry/support/normalizeUtils.js";import{mapParameters as a}from"../../operations/urlUtils.js";import{parsePBFFeatureQuery as o}from"./pbfQueryUtils.js";import{applyFeatureSetZUnitScaling as u}from"./queryZScale.js";const s="Layer does not support extent calculation.";function l(t,e){if(e&&"extent"===t.type)return`${t.xmin},${t.ymin},${t.xmax},${t.ymax}`;if(e&&"point"===t.type)return`${t.x},${t.y}`;const n=t.toJSON();return delete n.spatialReference,JSON.stringify(n)}function y(t,e){const n=t.geometry,i=t.toJSON();delete i.compactGeometryEnabled,delete i.defaultSpatialReferenceEnabled;const a=i;let o,u,s;if(null!=n&&(u=n.spatialReference,s=n.spatialReference.wkid||JSON.stringify(n.spatialReference),a.geometryType=r(n),a.geometry=l(n,t.compactGeometryEnabled),a.inSR=s),i.groupByFieldsForStatistics&&(a.groupByFieldsForStatistics=i.groupByFieldsForStatistics.join(",")),i.objectIds&&(a.objectIds=i.objectIds.join(",")),i.orderByFields&&(a.orderByFields=i.orderByFields.join(",")),!i.outFields||!i.returnDistinctValues&&(e?.returnCountOnly||e?.returnExtentOnly||e?.returnIdsOnly)?delete a.outFields:i.outFields.includes("*")?a.outFields="*":a.outFields=i.outFields.join(","),i.outSR?(a.outSR=i.outSR.wkid||JSON.stringify(i.outSR),o=t.outSpatialReference):n&&(i.returnGeometry||i.returnCentroid)&&(a.outSR=a.inSR,o=u),i.returnGeometry&&delete i.returnGeometry,i.outStatistics&&(a.outStatistics=JSON.stringify(i.outStatistics)),i.fullText&&(a.fullText=JSON.stringify(i.fullText)),i.pixelSize&&(a.pixelSize=JSON.stringify(i.pixelSize)),i.quantizationParameters&&(t.defaultSpatialReferenceEnabled&&null!=u&&null!=t.quantizationParameters&&null!=t.quantizationParameters.extent&&u.equals(t.quantizationParameters.extent.spatialReference)&&delete i.quantizationParameters.extent.spatialReference,a.quantizationParameters=JSON.stringify(i.quantizationParameters)),i.parameterValues&&(a.parameterValues=JSON.stringify(i.parameterValues)),i.rangeValues&&(a.rangeValues=JSON.stringify(i.rangeValues)),i.dynamicDataSource&&(a.layer=JSON.stringify({source:i.dynamicDataSource}),delete i.dynamicDataSource),i.timeExtent){const t=i.timeExtent,{start:e,end:n}=t;null==e&&null==n||(a.time=e===n?e:`${e??"null"},${n??"null"}`),delete i.timeExtent}return t.defaultSpatialReferenceEnabled&&null!=u&&null!=o&&u.equals(o)&&(a.defaultSR=a.inSR,delete a.inSR,delete a.outSR),a}async function m(t,e,n,r){const i=null!=e.timeExtent&&e.timeExtent.isEmpty?{data:{features:[]}}:await x(t,e,"json",r);return u(e,n,i.data),i}async function c(t,e,n,r){if(null!=e.timeExtent&&e.timeExtent.isEmpty)return{data:n.createFeatureResult()};const i=await d(t,e,r),a=i;return a.data=o(i.data,n),a}function d(t,e,n){return x(t,e,"pbf",n)}function f(t,e,n){return null!=e.timeExtent&&e.timeExtent.isEmpty?Promise.resolve({data:{objectIds:[]}}):x(t,e,"json",n,{returnIdsOnly:!0})}function p(t,e,n){return null!=e.timeExtent&&e.timeExtent.isEmpty?Promise.resolve({data:{count:0}}):x(t,e,"json",n,{returnIdsOnly:!0,returnCountOnly:!0})}async function S(t,e,n){if(null!=e.timeExtent&&e.timeExtent.isEmpty)return{data:{count:0,extent:null}};const r=await x(t,e,"json",n,{returnExtentOnly:!0,returnCountOnly:!0}),i=r.data;if(i.hasOwnProperty("extent"))return r;if(i.features)throw new Error(s);if(i.hasOwnProperty("count"))throw new Error(s);return r}async function x(r,o,u,s={},l={}){const m="string"==typeof r?e(r):r,c=o.geometry?[o.geometry]:[];s.responseType="pbf"===u?"array-buffer":"json";const d=await i(c,null,s),f=d&&d[0];null!=f&&((o=o.clone()).geometry=f);const p=a({...m.query,f:u,...l,...y(o,l)});return t(n(m.path,o.is3D?"query3d":"query"),{...s,query:{...p,...s.query}})}export{l as encodeGeometry,m as executeQuery,p as executeQueryForCount,S as executeQueryForExtent,f as executeQueryForIds,c as executeQueryPBF,d as executeQueryPBFBuffer,y as queryToQueryStringParameters,x as runQuery};
5
+ import t from"../../../request.js";import{urlToObject as e,join as n}from"../../../core/urlUtils.js";import{getJsonType as r}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as i}from"../../../geometry/support/normalizeUtils.js";import{mapParameters as a}from"../../operations/urlUtils.js";import{parsePBFFeatureQuery as o}from"./pbfQueryUtils.js";import{applyFeatureSetZUnitScaling as u}from"./queryZScale.js";const l="Layer does not support extent calculation.";function s(t,e){if(e&&"extent"===t.type)return`${t.xmin},${t.ymin},${t.xmax},${t.ymax}`;if(e&&"point"===t.type)return`${t.x},${t.y}`;const n=t.toJSON();return delete n.spatialReference,JSON.stringify(n)}function y(t,e){const n=t.geometry,i=t.toJSON();delete i.compactGeometryEnabled,delete i.defaultSpatialReferenceEnabled;const a=i;let o,u,l;if(null!=n&&(u=n.spatialReference,l=n.spatialReference.wkid||JSON.stringify(n.spatialReference),a.geometryType=r(n),a.geometry=s(n,t.compactGeometryEnabled),a.inSR=l),i.groupByFieldsForStatistics&&(a.groupByFieldsForStatistics=i.groupByFieldsForStatistics.join(",")),i.objectIds&&(a.objectIds=i.objectIds.join(",")),i.orderByFields&&(a.orderByFields=i.orderByFields.join(",")),!i.outFields||!i.returnDistinctValues&&(e?.returnCountOnly||e?.returnExtentOnly||e?.returnIdsOnly)?delete a.outFields:i.outFields.includes("*")?a.outFields="*":a.outFields=i.outFields.join(","),i.outSR?(a.outSR=i.outSR.wkid||JSON.stringify(i.outSR),o=t.outSpatialReference):n&&(i.returnGeometry||i.returnCentroid)&&(a.outSR=a.inSR,o=u),i.returnGeometry&&delete i.returnGeometry,i.outStatistics&&(a.outStatistics=JSON.stringify(i.outStatistics)),i.fullText&&(a.fullText=JSON.stringify(i.fullText)),i.pixelSize&&(a.pixelSize=JSON.stringify(i.pixelSize)),i.quantizationParameters&&(t.defaultSpatialReferenceEnabled&&null!=u&&null!=t.quantizationParameters&&null!=t.quantizationParameters.extent&&u.equals(t.quantizationParameters.extent.spatialReference)&&delete i.quantizationParameters.extent.spatialReference,a.quantizationParameters=JSON.stringify(i.quantizationParameters)),i.parameterValues&&(a.parameterValues=JSON.stringify(i.parameterValues)),i.rangeValues&&(a.rangeValues=JSON.stringify(i.rangeValues)),i.dynamicDataSource&&(a.layer=JSON.stringify({source:i.dynamicDataSource}),delete i.dynamicDataSource),i.timeExtent){const t=i.timeExtent,{start:e,end:n}=t;null==e&&null==n||(a.time=e===n?e:`${e??"null"},${n??"null"}`),delete i.timeExtent}return t.defaultSpatialReferenceEnabled&&null!=u&&null!=o&&u.equals(o)&&(a.defaultSR=a.inSR,delete a.inSR,delete a.outSR),a}async function m(t,e,n,r){const i=null!=e.timeExtent&&e.timeExtent.isEmpty?{data:{features:[]}}:await x(t,e,"json",r);return u(e,n,i.data),i}async function c(t,e,n,r){if(null!=e.timeExtent&&e.timeExtent.isEmpty)return{data:n.createFeatureResult()};const i=await f(t,e,r),a=i;return a.data=o(i.data,n),a}function f(t,e,n){return x(t,e,"pbf",n)}function d(t,e,n){return null!=e.timeExtent&&e.timeExtent.isEmpty?Promise.resolve({data:{objectIds:[]}}):x(t,e,"json",n,{returnIdsOnly:!0})}function p(t,e,n){return null!=e.timeExtent&&e.timeExtent.isEmpty?Promise.resolve({data:{count:0}}):x(t,e,"json",n,{returnIdsOnly:!0,returnCountOnly:!0})}async function S(t,e,n){if(null!=e.timeExtent&&e.timeExtent.isEmpty)return{data:{count:0,extent:null}};const r=await x(t,e,"json",n,{returnExtentOnly:!0,returnCountOnly:!0}),i=r.data;if(i.hasOwnProperty("extent"))return r;if(i.features)throw new Error(l);if(i.hasOwnProperty("count"))throw new Error(l);return r}async function x(r,o,u,l={},s={}){const m="string"==typeof r?e(r):r,c=o.geometry?[o.geometry]:[];l.responseType="pbf"===u?"array-buffer":"json";const f=await i(c,null,l),d=f&&f[0];null!=d&&((o=o.clone()).geometry=d);const p=a({...m.query,f:u,...s,...y(o,s)});return t(n(m.path,E(o,s)?"query3d":"query"),{...l,query:{...p,...l.query}})}function E(t,e){return null!=t.formatOf3DObjects&&!(e.returnCountOnly||e.returnExtentOnly||e.returnIdsOnly)}export{s as encodeGeometry,m as executeQuery,p as executeQueryForCount,S as executeQueryForExtent,d as executeQueryForIds,c as executeQueryPBF,f as executeQueryPBFBuffer,y as queryToQueryStringParameters,x as runQuery};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";import{createUVRenderer as r,isSingleBand8BitRasterWithStats as a,getClassField as s}from"../../../renderers/support/rasterRendererHelper.js";import{processRasterRendererParameters as t}from"../support/utils.js";async function o(r){r=await t(r);const{rasterInfo:o}=r.layer;if(o.bandCount>1)throw new e("raster-class-breaks-renderer:not-supported","Multiband raster is not supported");const{attributeTable:n}=o;if(null==n){if(a(o))return r.classFieldName=r.classFieldName||"value",r;throw new e("raster-unique-value-renderer:not-supported","The source raster does not have an attribute table")}const i=r.classFieldName?.toLowerCase();if(i&&!n.fields.some((e=>e.name.toLowerCase()===i)))throw new e("raster-unique-value-renderer:invalid-parameters","A valid 'classfieldName' is required");return i||(r.classFieldName=s(n)?.name),r}async function n(a){a=await o(a);const{classFieldName:s,colors:t,colorRamp:n}=a,i=r(a.layer.rasterInfo,s,t,n);if(null==i)throw new e("raster-unique-value-renderer:not-supported","UniqueValueRenderer is not supported on the provided data source");return{renderer:i,classFieldName:s}}export{n as createRenderer};
5
+ import e from"../../../core/Error.js";import{isSingleBand8BitRasterWithStats as r}from"../../../renderers/support/rasterRendererChecks.js";import{createUVRenderer as s,getClassField as t}from"../../../renderers/support/rasterRendererHelper.js";import{processRasterRendererParameters as a}from"../support/utils.js";async function o(s){s=await a(s);const{rasterInfo:o}=s.layer;if(o.bandCount>1)throw new e("raster-class-breaks-renderer:not-supported","Multiband raster is not supported");const{attributeTable:n}=o;if(null==n){if(r(o))return s.classFieldName=s.classFieldName||"value",s;throw new e("raster-unique-value-renderer:not-supported","The source raster does not have an attribute table")}const i=s.classFieldName?.toLowerCase();if(i&&!n.fields.some((e=>e.name.toLowerCase()===i)))throw new e("raster-unique-value-renderer:invalid-parameters","A valid 'classfieldName' is required");return i||(s.classFieldName=t(n)?.name),s}async function n(r){r=await o(r);const{classFieldName:t,colors:a,colorRamp:n}=r,i=s(r.layer.rasterInfo,t,a,n);if(null==i)throw new e("raster-unique-value-renderer:not-supported","UniqueValueRenderer is not supported on the provided data source");return{renderer:i,classFieldName:t}}export{n as createRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import has from"../core/has.js";const e=()=>!!has("enable-feature:force-wosr"),a=()=>!!has("enable-feature:direct-3d-object-feature-layer-display"),r=()=>has.add("enable-feature:direct-3d-object-feature-layer-display",!0,!0,!0),t=()=>has.add("enable-feature:direct-3d-object-feature-layer-display",!1,!0,!0),i=()=>!!has("enable-i3s-patching"),d=()=>has.add("enable-i3s-patching",!0,!0,!0),n=()=>has.add("enable-i3s-patching",!1,!0,!0),c=()=>!!has("enable-feature:SceneLayer-editing"),l=(e="feature-layer-view")=>{switch(n(),t(),has.add("enable-feature:SceneLayer-editing",!0,!0,!0),e){case"feature-layer-view":r();break;case"i3s-patching":console.warn("Displaying SceneLayer 3DOFL features using I3S patching."),d()}},s=()=>has.add("disable-feature:idb-cache",!1,!0,!0);l();export{a as direct3DObjectFeatureLayerDisplayEnabled,t as disableDirect3DObjectFeatureLayerDisplay,n as disableI3SPatching,s as disableIDBCache,r as enableDirect3DObjectFeatureLayerDisplay,d as enableI3SPatching,l as enableSceneLayerEditing,e as enableWebStyleForceWOSR,i as i3sPatchingEnabled,c as sceneLayerEditingEnabled};
5
+ import has from"../core/has.js";const e=()=>!!has("enable-feature:force-wosr"),a=()=>!!has("enable-feature:direct-3d-object-feature-layer-display"),t=()=>has.add("enable-feature:direct-3d-object-feature-layer-display",!0,!0,!0),i=()=>has.add("enable-feature:direct-3d-object-feature-layer-display",!1,!0,!0),r=()=>!!has("enable-i3s-patching"),d=()=>has.add("enable-i3s-patching",!0,!0,!0),c=()=>has.add("enable-i3s-patching",!1,!0,!0),n=()=>!!has("enable-feature:SceneLayer-editing"),l=(e="i3s-patching")=>{switch(c(),i(),has.add("enable-feature:SceneLayer-editing",!0,!0,!0),e){case"feature-layer-view":t();break;case"i3s-patching":d()}},s=()=>has.add("disable-feature:idb-cache",!0,!0,!0);l("i3s-patching");export{a as direct3DObjectFeatureLayerDisplayEnabled,i as disableDirect3DObjectFeatureLayerDisplay,c as disableI3SPatching,s as disableIDBCache,t as enableDirect3DObjectFeatureLayerDisplay,d as enableI3SPatching,l as enableSceneLayerEditing,e as enableWebStyleForceWOSR,r as i3sPatchingEnabled,n as sceneLayerEditingEnabled};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- const b="20230419",e="50ddba901a45e62f105cab619e467711e0bb9954";export{b as buildDate,e as commitHash};
5
+ const d="20230421",c="38552c33b71c0331f028d842d657f7d1dea3a585";export{d as buildDate,c 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.27/esri/copyright.txt for details.
4
4
  */
5
- import{getAssetUrl as e}from"../../assets.js";import{toHSV as t,toRGB as s}from"../../core/colorUtils.js";import"../../core/has.js";import l from"../../core/Error.js";import r from"../../core/Logger.js";import{unwrapOrThrow as n}from"../../core/maybe.js";import{eachAlways as a}from"../../core/promiseUtils.js";import{pt2px as o}from"../../core/screenUtils.js";import{defaultThematicColor as i,getPatternUrlWithColor as c,dekebabifyLineStyle as p}from"./gfxUtils.js";import{defaultPrimitive as u}from"./IconSymbol3DLayerResource.js";import{defaultPrimitive as h}from"./ObjectSymbol3DLayerResource.js";import{SymbolSizeDefaults as m,adjustColorComponentBrightness as f,getPathSymbolShapes as y,shapes as d,getExtrudeSymbolShapes as b,getTetrahedronShapes as v,getDiamondShapes as g,getCylinderShapes as k,getCubeShapes as w,getInvertedConeShapes as x,getConeShapes as M,getWaterSymbolShapes as j}from"./previewUtils.js";import{tintImageWithColor as L,renderSymbol as z}from"./renderUtils.js";import{isVolumetricSymbol as S,getIconHref as P}from"./utils.js";import{resolveWebStyleSymbol as U}from"./webStyleSymbolUtils.js";const D=m.size,O=m.maxSize,C=m.maxOutlineSize,I=m.lineWidth,R=m.tallSymbolWidth;function E(e){const t=e.outline,s=null!=e.material?e.material.color:null,l=null!=s?s.toHex():null;if(null==t||"pattern"in t&&null!=t.pattern&&"style"===t.pattern.type&&"none"===t.pattern.style)return"fill"===e.type&&"#ffffff"===l?{color:"#bdc3c7",width:.75}:null;const r=o(t.size)||0;return{color:"rgba("+(null!=t.color?t.color.toRgba():"255,255,255,1")+")",width:Math.min(r,C),style:"pattern"in t&&null!=t.pattern&&"style"===t.pattern.type?p(t.pattern.style):null,join:"butt",cap:"patternCap"in t?t.patternCap:"butt"}}function Z(t,s){const l=s&&s.resource,r=l&&l.href;if(t.thumbnail&&t.thumbnail.url)return Promise.resolve(t.thumbnail.url);if(r&&"object"!==s.type)return Promise.resolve(P(s));const n=e("esri/images/Legend/legend3dsymboldefault.png");return t.styleOrigin&&(t.styleOrigin.styleName||t.styleOrigin.styleUrl)?U(t.styleOrigin,{portal:t.styleOrigin.portal},"webRef").catch((e=>e)).then((e=>e?.thumbnail?.url||n)):Promise.resolve(n)}function q(e,l=1){const r=e.a,n=t(e),a=n.h,o=n.s/l,i=100-(100-n.v)/l,{r:c,g:p,b:u}=s({h:a,s:o,v:i});return[c,p,u,r]}function A(e){return"water"===e.type?null==e.color?null:e.color:null==e.material||null==e.material.color?null:e.material.color}function H(e,t=0){const s=A(e);if(!s){if("fill"===e.type)return null;const s=i.r,l=f(s,t);return[l,l,l,100]}const l=s.toRgba();for(let r=0;r<3;r++)l[r]=f(l[r],t);return l}async function N(t,s){const l=t.style;if("none"===l)return null;return{type:"pattern",x:0,y:0,src:await c(e(`esri/symbols/patterns/${l}.png`),s.toCss(!0)),width:5,height:5}}function T(e){return e.outline?E(e):{color:"rgba(0, 0, 0, 1)",width:1.5}}function W(e,t){const s=A(e);if(!s)return null;let l="rgba(";return l+=f(s.r,t)+",",l+=f(s.g,t)+",",l+=f(s.b,t)+",",l+s.a+");"}function $(e,t){const s=W(e,t);if(!s)return{};if("pattern"in e&&null!=e.pattern&&"style"===e.pattern.type&&"none"===e.pattern.style)return null;return{color:s,width:Math.min(e.size?o(e.size):.75,C),style:"pattern"in e&&null!=e.pattern&&"style"===e.pattern.type?p(e.pattern.style):null,cap:"cap"in e?e.cap:null,join:"join"in e?"miter"===e.join?o(2):e.join:null}}function B(e,t,s){const l=null!=s?.75*s:0;return{type:"linear",x1:l?.25*l:0,y1:l?.5*l:0,x2:l||4,y2:l?.5*l:4,colors:[{color:e,offset:0},{color:t,offset:1}]}}function F(e){const t=e.depth,s=e.height,l=e.width;return 0!==l&&0!==t&&0!==s&&l===t&&null!=l&&null!=s&&l<s}function G(e,t,s){const l=[];if(!e)return l;switch(e.type){case"icon":{const s=0,r=0,n=t,a=t;switch(e.resource&&e.resource.primitive||u){case"circle":l.push({shape:{type:"circle",cx:0,cy:0,r:.5*t},fill:H(e,0),stroke:E(e)});break;case"square":l.push({shape:{type:"path",path:[{command:"M",values:[s,a]},{command:"L",values:[s,r]},{command:"L",values:[n,r]},{command:"L",values:[n,a]},{command:"Z",values:[]}]},fill:H(e,0),stroke:E(e)});break;case"triangle":l.push({shape:{type:"path",path:[{command:"M",values:[s,a]},{command:"L",values:[.5*n,r]},{command:"L",values:[n,a]},{command:"Z",values:[]}]},fill:H(e,0),stroke:E(e)});break;case"cross":l.push({shape:{type:"path",path:[{command:"M",values:[.5*n,r]},{command:"L",values:[.5*n,a]},{command:"M",values:[s,.5*a]},{command:"L",values:[n,.5*a]}]},stroke:T(e)});break;case"x":l.push({shape:{type:"path",path:[{command:"M",values:[s,r]},{command:"L",values:[n,a]},{command:"M",values:[n,r]},{command:"L",values:[s,a]}]},stroke:T(e)});break;case"kite":l.push({shape:{type:"path",path:[{command:"M",values:[s,.5*a]},{command:"L",values:[.5*n,r]},{command:"L",values:[n,.5*a]},{command:"L",values:[.5*n,a]},{command:"Z",values:[]}]},fill:H(e,0),stroke:E(e)})}break}case"object":switch(e.resource&&e.resource.primitive||h){case"cone":{const r=B(H(e,0),H(e,-.6),s?R:t),n=M(t,s);l.push({shape:n[0],fill:r}),l.push({shape:n[1],fill:r});break}case"inverted-cone":{const s=H(e,0),r=B(s,H(e,-.6),t),n=x(t);l.push({shape:n[0],fill:r}),l.push({shape:n[1],fill:s});break}case"cube":{const r=w(t,s);l.push({shape:r[0],fill:H(e,0)}),l.push({shape:r[1],fill:H(e,-.3)}),l.push({shape:r[2],fill:H(e,-.5)});break}case"cylinder":{const r=B(H(e,0),H(e,-.6),s?R:t),n=k(t,s);l.push({shape:n[0],fill:r}),l.push({shape:n[1],fill:r}),l.push({shape:n[2],fill:H(e,0)});break}case"diamond":{const s=g(t);l.push({shape:s[0],fill:H(e,-.3)}),l.push({shape:s[1],fill:H(e,0)}),l.push({shape:s[2],fill:H(e,-.3)}),l.push({shape:s[3],fill:H(e,-.7)});break}case"sphere":{const s=B(H(e,0),H(e,-.6));s.x1=0,s.y1=0,s.x2=.25*t,s.y2=.25*t,l.push({shape:{type:"circle",cx:0,cy:0,r:.5*t},fill:s});break}case"tetrahedron":{const s=v(t);l.push({shape:s[0],fill:H(e,-.3)}),l.push({shape:s[1],fill:H(e,0)}),l.push({shape:s[2],fill:H(e,-.6)});break}}break}return l}function J(e){const t="number"==typeof e?.size?e?.size:null;return t?o(t):null}function K(e){return"icon"===e.type?"multiply":"tint"}function Q(e,t){const s=J(t),l=t?.maxSize?o(t.maxSize):null,n=t?.disableUpsampling??!1,i=e.symbolLayers,c=[];let p=0,u=0;const h=i.getItemAt(i.length-1);let m;return h&&"icon"===h.type&&(m=h.size&&o(h.size)),i.forEach((r=>{if("icon"!==r.type&&"object"!==r.type)return;const a="icon"===r.type?r.size&&o(r.size):0,i=s||a?Math.ceil(Math.min(s||a,l||O)):D;if(r&&r.resource&&r.resource.href){const t=Z(e,r).then((e=>{const t=r.get("material.color"),s=K(r);return L(e,i,t,s,n)})).then((e=>{const t=e.width,s=e.height;return p=Math.max(p,t),u=Math.max(u,s),[{shape:{type:"image",x:0,y:0,width:t,height:s,src:e.url},fill:null,stroke:null}]}));c.push(t)}else{let e=i;"icon"===r.type&&m&&s&&(e=i*(a/m));const l="tall"===t?.symbolConfig||t?.symbolConfig?.isTall||"object"===r.type&&F(r);p=Math.max(p,l?R:e),u=Math.max(u,e),c.push(Promise.resolve(G(r,e,l)))}})),a(c).then((e=>{const s=[];return e.forEach((e=>{e.value?s.push(e.value):e.error&&r.getLogger("esri.symbols.support.previewSymbol3D").warn("error while building swatchInfo!",e.error)})),z(s,[p,u],{node:t&&t.node,scale:!1,opacity:t&&t.opacity})}))}function V(e,t){const s=e.symbolLayers,l=[],r=S(e),n=J(t),a=(t&&t.maxSize?o(t.maxSize):null)||C;let i,c=0,p=0;return s.forEach(((e,t)=>{if(!e)return;if("line"!==e.type&&"path"!==e.type)return;const s=[];switch(e.type){case"line":{const l=$(e,0);if(null==l)break;const r=l&&l.width||0;0===t&&(i=r);const o=Math.min(n||r,a),u=0===t?o:n?o*(r/i):o,h=u>I/2?2*u:I;p=Math.max(p,u),c=Math.max(c,h),l.width=u,s.push({shape:{type:"path",path:[{command:"M",values:[0,.5*p]},{command:"L",values:[c,.5*p]}]},stroke:l});break}case"path":{const t=Math.min(n||D,a),l=H(e,0),r=H(e,-.2),o=W(e,-.4),i=o?{color:o,width:1}:{};if("quad"===e.profile){const t=e.width,n=e.height,a=y(t&&n?t/n:1,0===n,0===t),o={...i,join:"bevel"};s.push({shape:a[0],fill:r,stroke:o}),s.push({shape:a[1],fill:r,stroke:o}),s.push({shape:a[2],fill:l,stroke:o})}else s.push({shape:d.pathSymbol3DLayer[0],fill:r,stroke:i}),s.push({shape:d.pathSymbol3DLayer[1],fill:l,stroke:i});p=Math.max(p,t),c=p}}l.push(s)})),Promise.resolve(z(l,[c,p],{node:t&&t.node,scale:r,opacity:t&&t.opacity}))}async function X(e,t){const s="mesh-3d"===e.type,l=e.symbolLayers,r=J(t),a=t&&t.maxSize?o(t.maxSize):null,i=r||D,c=[];let p=0,u=0,h=!1;for(let o=0;o<l.length;o++){const e=l.getItemAt(o),t=[];if(s&&"fill"!==e.type)continue;const r=d.fill[0];switch(e.type){case"fill":{const l=E(e),n=Math.min(i,a||O);p=Math.max(p,n),u=Math.max(u,n),h=!0;let o=H(e,0);const c="pattern"in e?e.pattern:null,m=A(e);!s&&null!=c&&"style"===c.type&&"solid"!==c.style&&m&&(o=await N(c,m)),t.push({shape:r,fill:o,stroke:l});break}case"line":{const s=$(e,0);if(null==s)break;const l={stroke:s,shape:r};p=Math.max(p,D),u=Math.max(u,D),t.push(l);break}case"extrude":{const s={join:"round",width:1,...$(e,-.4)},l=H(e,0),r=H(e,-.2),n=Math.min(i,a||O),o=b(n);s.width=1,t.push({shape:o[0],fill:r,stroke:s}),t.push({shape:o[1],fill:r,stroke:s}),t.push({shape:o[2],fill:l,stroke:s});const c=D,h=.7*D+.5*n;p=Math.max(p,c),u=Math.max(u,h);break}case"water":{const s=n(A(e)),l=q(s),r=q(s,2),o=q(s,3),c=j();h=!0,t.push({shape:c[0],fill:l}),t.push({shape:c[1],fill:r}),t.push({shape:c[2],fill:o});const m=Math.min(i,a||O);p=Math.max(p,m),u=Math.max(u,m);break}}c.push(t)}return z(c,[p,u],{node:t&&t.node,scale:h,opacity:t&&t.opacity})}function Y(e,t){if(0===e.symbolLayers.length)return Promise.reject(new l("symbolPreview: renderPreviewHTML3D","No symbolLayers in the symbol."));switch(e.type){case"point-3d":return Q(e,t);case"line-3d":return V(e,t);case"polygon-3d":case"mesh-3d":return X(e,t)}return Promise.reject(new l("symbolPreview: swatchInfo3D","symbol not supported."))}export{N as getPatternDescriptor,J as getSizeFromOptions,H as getSymbolLayerFill,Y as previewSymbol3D};
5
+ import{getAssetUrl as e}from"../../assets.js";import{toHSV as t,toRGB as s}from"../../core/colorUtils.js";import"../../core/has.js";import l from"../../core/Error.js";import n from"../../core/Logger.js";import{unwrapOrThrow as r}from"../../core/maybe.js";import{eachAlways as a}from"../../core/promiseUtils.js";import{pt2px as o}from"../../core/screenUtils.js";import{defaultThematicColor as i,getPatternUrlWithColor as c,dekebabifyLineStyle as p}from"./gfxUtils.js";import{defaultPrimitive as u}from"./IconSymbol3DLayerResource.js";import{defaultPrimitive as h}from"./ObjectSymbol3DLayerResource.js";import{SymbolSizeDefaults as m,adjustColorComponentBrightness as f,getPathSymbolShapes as y,shapes as d,getExtrudeSymbolShapes as b,getTetrahedronShapes as g,getDiamondShapes as k,getCylinderShapes as v,getCubeShapes as w,getInvertedConeShapes as x,getConeShapes as M,getWaterSymbolShapes as j}from"./previewUtils.js";import{tintImageWithColor as L,renderSymbol as z}from"./renderUtils.js";import{isVolumetricSymbol as S,getIconHref as U}from"./utils.js";import{resolveWebStyleSymbol as P}from"./webStyleSymbolUtils.js";const D=m.size,O=m.maxSize,C=m.maxOutlineSize,I=m.lineWidth,R=m.tallSymbolWidth;function E(e){const t=e.outline,s=null!=e.material?e.material.color:null,l=null!=s?s.toHex():null;if(null==t||"pattern"in t&&null!=t.pattern&&"style"===t.pattern.type&&"none"===t.pattern.style)return"fill"===e.type&&"#ffffff"===l?{color:"#bdc3c7",width:.75}:null;const n=o(t.size)||0;return{color:"rgba("+(null!=t.color?t.color.toRgba():"255,255,255,1")+")",width:Math.min(n,C),style:"pattern"in t&&null!=t.pattern&&"style"===t.pattern.type?p(t.pattern.style):null,join:"butt",cap:"patternCap"in t?t.patternCap:"butt"}}async function Z(t,s){if(t.thumbnail?.url)return t.thumbnail.url;if("icon"===s.type){const e=s?.resource?.href;if(e)return U(s)}const l=e("esri/images/Legend/legend3dsymboldefault.png");if(t.styleOrigin&&(t.styleOrigin.styleName||t.styleOrigin.styleUrl)){const e=await P(t.styleOrigin,{portal:t.styleOrigin.portal},"webRef").catch((()=>null));if(e&&"thumbnail"in e&&e.thumbnail?.url)return e.thumbnail.url}return l}function q(e,l=1){const n=e.a,r=t(e),a=r.h,o=r.s/l,i=100-(100-r.v)/l,{r:c,g:p,b:u}=s({h:a,s:o,v:i});return[c,p,u,n]}function A(e){return"water"===e.type?null==e.color?null:e.color:null==e.material||null==e.material.color?null:e.material.color}function H(e,t=0){const s=A(e);if(!s){if("fill"===e.type)return null;const s=i.r,l=f(s,t);return[l,l,l,100]}const l=s.toRgba();for(let n=0;n<3;n++)l[n]=f(l[n],t);return l}async function N(t,s){const l=t.style;if("none"===l)return null;return{type:"pattern",x:0,y:0,src:await c(e(`esri/symbols/patterns/${l}.png`),s.toCss(!0)),width:5,height:5}}function T(e){return e.outline?E(e):{color:"rgba(0, 0, 0, 1)",width:1.5}}function W(e,t){const s=A(e);if(!s)return null;let l="rgba(";return l+=f(s.r,t)+",",l+=f(s.g,t)+",",l+=f(s.b,t)+",",l+s.a+");"}function $(e,t){const s=W(e,t);if(!s)return{};if("pattern"in e&&null!=e.pattern&&"style"===e.pattern.type&&"none"===e.pattern.style)return null;return{color:s,width:Math.min(e.size?o(e.size):.75,C),style:"pattern"in e&&null!=e.pattern&&"style"===e.pattern.type?p(e.pattern.style):null,cap:"cap"in e?e.cap:null,join:"join"in e?"miter"===e.join?o(2):e.join:null}}function B(e,t,s){const l=null!=s?.75*s:0;return{type:"linear",x1:l?.25*l:0,y1:l?.5*l:0,x2:l||4,y2:l?.5*l:4,colors:[{color:e,offset:0},{color:t,offset:1}]}}function F(e){const t=e.depth,s=e.height,l=e.width;return 0!==l&&0!==t&&0!==s&&l===t&&null!=l&&null!=s&&l<s}function G(e,t,s){const l=[];if(!e)return l;switch(e.type){case"icon":{const s=0,n=0,r=t,a=t;switch(e.resource&&e.resource.primitive||u){case"circle":l.push({shape:{type:"circle",cx:0,cy:0,r:.5*t},fill:H(e,0),stroke:E(e)});break;case"square":l.push({shape:{type:"path",path:[{command:"M",values:[s,a]},{command:"L",values:[s,n]},{command:"L",values:[r,n]},{command:"L",values:[r,a]},{command:"Z",values:[]}]},fill:H(e,0),stroke:E(e)});break;case"triangle":l.push({shape:{type:"path",path:[{command:"M",values:[s,a]},{command:"L",values:[.5*r,n]},{command:"L",values:[r,a]},{command:"Z",values:[]}]},fill:H(e,0),stroke:E(e)});break;case"cross":l.push({shape:{type:"path",path:[{command:"M",values:[.5*r,n]},{command:"L",values:[.5*r,a]},{command:"M",values:[s,.5*a]},{command:"L",values:[r,.5*a]}]},stroke:T(e)});break;case"x":l.push({shape:{type:"path",path:[{command:"M",values:[s,n]},{command:"L",values:[r,a]},{command:"M",values:[r,n]},{command:"L",values:[s,a]}]},stroke:T(e)});break;case"kite":l.push({shape:{type:"path",path:[{command:"M",values:[s,.5*a]},{command:"L",values:[.5*r,n]},{command:"L",values:[r,.5*a]},{command:"L",values:[.5*r,a]},{command:"Z",values:[]}]},fill:H(e,0),stroke:E(e)})}break}case"object":switch(e.resource&&e.resource.primitive||h){case"cone":{const n=B(H(e,0),H(e,-.6),s?R:t),r=M(t,s);l.push({shape:r[0],fill:n}),l.push({shape:r[1],fill:n});break}case"inverted-cone":{const s=H(e,0),n=B(s,H(e,-.6),t),r=x(t);l.push({shape:r[0],fill:n}),l.push({shape:r[1],fill:s});break}case"cube":{const n=w(t,s);l.push({shape:n[0],fill:H(e,0)}),l.push({shape:n[1],fill:H(e,-.3)}),l.push({shape:n[2],fill:H(e,-.5)});break}case"cylinder":{const n=B(H(e,0),H(e,-.6),s?R:t),r=v(t,s);l.push({shape:r[0],fill:n}),l.push({shape:r[1],fill:n}),l.push({shape:r[2],fill:H(e,0)});break}case"diamond":{const s=k(t);l.push({shape:s[0],fill:H(e,-.3)}),l.push({shape:s[1],fill:H(e,0)}),l.push({shape:s[2],fill:H(e,-.3)}),l.push({shape:s[3],fill:H(e,-.7)});break}case"sphere":{const s=B(H(e,0),H(e,-.6));s.x1=0,s.y1=0,s.x2=.25*t,s.y2=.25*t,l.push({shape:{type:"circle",cx:0,cy:0,r:.5*t},fill:s});break}case"tetrahedron":{const s=g(t);l.push({shape:s[0],fill:H(e,-.3)}),l.push({shape:s[1],fill:H(e,0)}),l.push({shape:s[2],fill:H(e,-.6)});break}}break}return l}function J(e){const t="number"==typeof e?.size?e?.size:null;return t?o(t):null}function K(e){return"icon"===e.type?"multiply":"tint"}function Q(e,t){const s=J(t),l=t?.maxSize?o(t.maxSize):null,r=t?.disableUpsampling??!1,i=e.symbolLayers,c=[];let p=0,u=0;const h=i.getItemAt(i.length-1);let m;return h&&"icon"===h.type&&(m=h.size&&o(h.size)),i.forEach((n=>{if("icon"!==n.type&&"object"!==n.type)return;const a="icon"===n.type?n.size&&o(n.size):0,i=s||a?Math.ceil(Math.min(s||a,l||O)):D;if(n&&n.resource&&n.resource.href){const t=Z(e,n).then((e=>{const t=n.get("material.color"),s=K(n);return L(e,i,t,s,r)})).then((e=>{const t=e.width,s=e.height;return p=Math.max(p,t),u=Math.max(u,s),[{shape:{type:"image",x:0,y:0,width:t,height:s,src:e.url},fill:null,stroke:null}]}));c.push(t)}else{let e=i;"icon"===n.type&&m&&s&&(e=i*(a/m));const l="tall"===t?.symbolConfig||t?.symbolConfig?.isTall||"object"===n.type&&F(n);p=Math.max(p,l?R:e),u=Math.max(u,e),c.push(Promise.resolve(G(n,e,l)))}})),a(c).then((e=>{const s=[];return e.forEach((e=>{e.value?s.push(e.value):e.error&&n.getLogger("esri.symbols.support.previewSymbol3D").warn("error while building swatchInfo!",e.error)})),z(s,[p,u],{node:t&&t.node,scale:!1,opacity:t&&t.opacity})}))}function V(e,t){const s=e.symbolLayers,l=[],n=S(e),r=J(t),a=(t&&t.maxSize?o(t.maxSize):null)||C;let i,c=0,p=0;return s.forEach(((e,t)=>{if(!e)return;if("line"!==e.type&&"path"!==e.type)return;const s=[];switch(e.type){case"line":{const l=$(e,0);if(null==l)break;const n=l&&l.width||0;0===t&&(i=n);const o=Math.min(r||n,a),u=0===t?o:r?o*(n/i):o,h=u>I/2?2*u:I;p=Math.max(p,u),c=Math.max(c,h),l.width=u,s.push({shape:{type:"path",path:[{command:"M",values:[0,.5*p]},{command:"L",values:[c,.5*p]}]},stroke:l});break}case"path":{const t=Math.min(r||D,a),l=H(e,0),n=H(e,-.2),o=W(e,-.4),i=o?{color:o,width:1}:{};if("quad"===e.profile){const t=e.width,r=e.height,a=y(t&&r?t/r:1,0===r,0===t),o={...i,join:"bevel"};s.push({shape:a[0],fill:n,stroke:o}),s.push({shape:a[1],fill:n,stroke:o}),s.push({shape:a[2],fill:l,stroke:o})}else s.push({shape:d.pathSymbol3DLayer[0],fill:n,stroke:i}),s.push({shape:d.pathSymbol3DLayer[1],fill:l,stroke:i});p=Math.max(p,t),c=p}}l.push(s)})),Promise.resolve(z(l,[c,p],{node:t&&t.node,scale:n,opacity:t&&t.opacity}))}async function X(e,t){const s="mesh-3d"===e.type,l=e.symbolLayers,n=J(t),a=t&&t.maxSize?o(t.maxSize):null,i=n||D,c=[];let p=0,u=0,h=!1;for(let o=0;o<l.length;o++){const e=l.getItemAt(o),t=[];if(s&&"fill"!==e.type)continue;const n=d.fill[0];switch(e.type){case"fill":{const l=E(e),r=Math.min(i,a||O);p=Math.max(p,r),u=Math.max(u,r),h=!0;let o=H(e,0);const c="pattern"in e?e.pattern:null,m=A(e);!s&&null!=c&&"style"===c.type&&"solid"!==c.style&&m&&(o=await N(c,m)),t.push({shape:n,fill:o,stroke:l});break}case"line":{const s=$(e,0);if(null==s)break;const l={stroke:s,shape:n};p=Math.max(p,D),u=Math.max(u,D),t.push(l);break}case"extrude":{const s={join:"round",width:1,...$(e,-.4)},l=H(e,0),n=H(e,-.2),r=Math.min(i,a||O),o=b(r);s.width=1,t.push({shape:o[0],fill:n,stroke:s}),t.push({shape:o[1],fill:n,stroke:s}),t.push({shape:o[2],fill:l,stroke:s});const c=D,h=.7*D+.5*r;p=Math.max(p,c),u=Math.max(u,h);break}case"water":{const s=r(A(e)),l=q(s),n=q(s,2),o=q(s,3),c=j();h=!0,t.push({shape:c[0],fill:l}),t.push({shape:c[1],fill:n}),t.push({shape:c[2],fill:o});const m=Math.min(i,a||O);p=Math.max(p,m),u=Math.max(u,m);break}}c.push(t)}return z(c,[p,u],{node:t&&t.node,scale:h,opacity:t&&t.opacity})}function Y(e,t){if(0===e.symbolLayers.length)return Promise.reject(new l("symbolPreview: renderPreviewHTML3D","No symbolLayers in the symbol."));switch(e.type){case"point-3d":return Q(e,t);case"line-3d":return V(e,t);case"polygon-3d":case"mesh-3d":return X(e,t)}return Promise.reject(new l("symbolPreview: swatchInfo3D","symbol not supported."))}export{N as getPatternDescriptor,J as getSizeFromOptions,H as getSymbolLayerFill,Y as previewSymbol3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../request.js";import t from"../../core/Error.js";import{throwIfAbortError as r}from"../../core/promiseUtils.js";import{normalize as o,removeFile as s}from"../../core/urlUtils.js";import n from"../../portal/Portal.js";import l from"../../portal/PortalQueryParams.js";import{enableWebStyleForceWOSR as a}from"../../support/featureFlags.js";let u={};async function f(e,t){try{return{data:(await b(e,t)).data,baseUrl:s(e),styleUrl:e}}catch(o){return r(o),null}}function i(e,t,r){const o=null!=t.portal?t.portal:n.getDefault();let s;const l=`${o.url} - ${o.user&&o.user.username} - ${e}`;return u[l]||(u[l]=y(e,o,r).then((e=>(s=e,e.fetchData()))).then((t=>({data:t,baseUrl:s.itemUrl??"",styleName:e})))),u[l]}function m(){u&&(u={})}function y(e,r,o){return r.load(o).then((()=>{const t=new l({disableExtraQuery:!0,query:`owner:${h} AND type:${j} AND typekeywords:"${e}"`});return r.queryItems(t,o)})).then((({results:r})=>{let s=null;const n=e.toLowerCase();if(r&&Array.isArray(r))for(const e of r){const t=e.typeKeywords?.some((e=>e.toLowerCase()===n));if(t&&e.type===j&&e.owner===h){s=e;break}}if(!s)throw new t("symbolstyleutils:style-not-found",`The style '${e}' could not be found`,{styleName:e});return s.load(o)}))}function c(e,r,o){return e&&null!=e.styleUrl?f(e.styleUrl,o):e&&null!=e.styleName?i(e.styleName,r,o):Promise.reject(new t("symbolstyleutils:style-url-and-name-missing","Either styleUrl or styleName is required to resolve a style"))}function p(e){return null===e||"CIMSymbolReference"===e.type?e:{type:"CIMSymbolReference",symbol:e}}function d(e,t){if("cimRef"===t)return e.cimRef;if(e.formatInfos&&!a())for(const r of e.formatInfos)if("gltf"===r.type)return r.href;return e.webRef}function b(t,r){const s={responseType:"json",query:{f:"json"},...r};return e(o(t),s)}const h="esri_en",j="Style",w="https://cdn.arcgis.com/sharing/rest/content/items/220936cc6ed342c9937abd8f180e7d1e/resources/styles/cim/{SymbolName}.json?f=json";export{w as Style2DUrlTemplate,u as cachedStyles,m as cleanupStyleUtilsCache,c as fetchStyle,p as makeCIMSymbolRef,b as requestJSON,d as symbolUrlFromStyleItem};
5
+ import e from"../../request.js";import t from"../../core/Error.js";import{throwIfAbortError as r}from"../../core/promiseUtils.js";import{normalize as o,removeFile as s}from"../../core/urlUtils.js";import n from"../../portal/Portal.js";import l from"../../portal/PortalQueryParams.js";import{enableWebStyleForceWOSR as a}from"../../support/featureFlags.js";let u={};async function f(e,t){try{return{data:(await b(e,t)).data,baseUrl:s(e),styleUrl:e}}catch(o){return r(o),null}}function i(e,t,r){const o=null!=t.portal?t.portal:n.getDefault();let s;const l=`${o.url} - ${o.user&&o.user.username} - ${e}`;return u[l]||(u[l]=y(e,o,r).then((e=>(s=e,e.fetchData()))).then((t=>({data:t,baseUrl:s.itemUrl??"",styleName:e})))),u[l]}function m(){u&&(u={})}function y(e,r,o){return r.load(o).then((()=>{const t=new l({disableExtraQuery:!0,query:`owner:${h} AND type:${j} AND typekeywords:"${e}"`});return r.queryItems(t,o)})).then((({results:r})=>{let s=null;const n=e.toLowerCase();if(r&&Array.isArray(r))for(const e of r){const t=e.typeKeywords?.some((e=>e.toLowerCase()===n));if(t&&e.type===j&&e.owner===h){s=e;break}}if(!s)throw new t("symbolstyleutils:style-not-found",`The style '${e}' could not be found`,{styleName:e});return s.load(o)}))}function c(e,r,o){return e&&null!=e.styleUrl?f(e.styleUrl,o):e&&null!=e.styleName?i(e.styleName,r,o):Promise.reject(new t("symbolstyleutils:style-url-and-name-missing","Either styleUrl or styleName is required to resolve a style"))}function p(e){return null===e||"CIMSymbolReference"===e.type?e:{type:"CIMSymbolReference",symbol:e}}function d(e,t,r=["gltf"]){if("cimRef"===t)return e.cimRef;if(e.formatInfos&&!a())for(const o of r){const t=e.formatInfos.find((e=>e.type===o));if(t)return t.href}return e.webRef}function b(t,r){const s={responseType:"json",query:{f:"json"},...r};return e(o(t),s)}const h="esri_en",j="Style",w="https://cdn.arcgis.com/sharing/rest/content/items/220936cc6ed342c9937abd8f180e7d1e/resources/styles/cim/{SymbolName}.json?f=json";export{w as Style2DUrlTemplate,u as cachedStyles,m as cleanupStyleUtilsCache,c as fetchStyle,p as makeCIMSymbolRef,b as requestJSON,d as symbolUrlFromStyleItem};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../request.js";import r from"../../core/Error.js";import o from"../../core/ItemCache.js";import{unwrapOrThrow as t}from"../../core/maybe.js";import{size as n,create as i}from"../../geometry/support/aaBoundingBox.js";import{objectSymbolLayerSizeWithResourceSize as s,objectSymbolLayerPrimitiveBoundingBox as u}from"./symbolLayerUtils3D.js";let c=l();function l(){return new o(50)}function a(){c=l()}function m(e,o){if("icon"===e.type)return f(e,o);if("object"===e.type)return b(e,o);throw new r("symbol3d:unsupported-symbol-layer","computeLayerSize only works with symbol layers of type Icon and Object")}async function y(e,o){if("icon"===e.type)return p(e,o);if("object"===e.type)return d(e,o);throw new r("symbol3d:unsupported-symbol-layer","computeLayerSize only works with symbol layers of type Icon and Object")}async function f(e,o){if(e.resource?.href)return h(e.resource.href).then((e=>[e.width,e.height]));if(e.resource?.primitive)return null!=o?[o,o]:[256,256];throw new r("symbol3d:invalid-symbol-layer","symbol layers of type Icon must have either an href or a primitive resource")}function p(e,r){return f(e,r).then((r=>{if(null==e.size)return r;const o=r[0]/r[1];return o>1?[e.size,e.size/o]:[e.size*o,e.size]}))}function h(r){return e(r,{responseType:"image"}).then((e=>e.data))}function b(e,r){return w(e,r).then((e=>n(e)))}async function d(e,r){const o=await b(e,r);return s(o,e)}async function w(e,o){if(!e.isPrimitive){const r=t(e.resource?.href),o=c.get(r);if(void 0!==o)return o;const n=await import("../../views/3d/layers/graphics/objectResourceUtils.js"),i=await n.fetch(r,{disableTextures:!0});return c.put(r,i.referenceBoundingBox),i.referenceBoundingBox}let n=null;if(e.resource&&e.resource.primitive&&(n=i(u(e.resource.primitive)),null!=o))for(let r=0;r<n.length;r++)n[r]*=o;return n?Promise.resolve(n):Promise.reject(new r("symbol:invalid-resource","The symbol does not have a valid resource"))}export{a as clearBoundingBoxCache,f as computeIconLayerResourceSize,m as computeLayerResourceSize,y as computeLayerSize,b as computeObjectLayerResourceSize};
5
+ import e from"../../request.js";import r from"../../core/Error.js";import o from"../../core/ItemCache.js";import{c as t}from"../../chunks/vec3f64.js";import{size as i,create as n}from"../../geometry/support/aaBoundingBox.js";import{objectSymbolLayerSizeWithResourceSize as s,objectSymbolLayerPrimitiveBoundingBox as u}from"./symbolLayerUtils3D.js";let c=a();function a(){return new o(50)}function l(){c=a()}async function f(e,o){if(e.resource?.href)return h(e.resource.href).then((e=>[e.width,e.height]));if(e.resource?.primitive)return null!=o?[o,o]:[256,256];throw new r("symbol3d:invalid-symbol-layer","symbol layers of type Icon must have either an href or a primitive resource")}function m(e,r=null){return f(e,r).then((r=>{if(null==e.size)return r;const o=r[0]/r[1];return o>1?[e.size,e.size/o]:[e.size*o,e.size]}))}function h(r){return e(r,{responseType:"image"}).then((e=>e.data))}async function p(e,r=null){const o=await y(e,r);return s(o,e)}async function y(e,o=null){if(!e.isPrimitive){const o=e.resource.href;if(!o)throw new r("symbol:invalid-resource","The symbol does not have a valid resource");const n=c.get(o);if(void 0!==n)return n;const s=await import("../../views/3d/layers/graphics/objectResourceUtils.js"),u=await s.fetch(o,{disableTextures:!0}),a=i(u.referenceBoundingBox,t());return c.put(o,a),a}if(!e.resource?.primitive)throw new r("symbol:invalid-resource","The symbol does not have a valid resource");const s=n(u(e.resource.primitive));if(null!=o)for(let r=0;r<s.length;r++)s[r]*=o;return i(s,t())}export{l as clearBoundingBoxCache,f as computeIconLayerResourceSize,m as computeIconLayerSize,y as computeObjectLayerResourceSize,p as computeObjectLayerSize};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Color.js";import{isSymbol3D as t,isSymbol2D as o}from"../../symbols.js";import{forEach as n}from"../../core/asyncUtils.js";import"../../core/has.js";import{unwrapOrThrow as r}from"../../core/maybe.js";import{px2pt as l}from"../../core/screenUtils.js";import{O as i}from"../../chunks/vec3f64.js";import{effectFunctionsFromJSON as s}from"../../layers/effects/jsonUtils.js";import{getStroke as c}from"./gfxUtils.js";import{Symbol3DMaterial as u}from"./Symbol3DMaterial.js";const a=new e("white");function f(e){const t=e.symbolLayers&&e.symbolLayers.length;if(!t)return;const o=e.symbolLayers.getItemAt(t-1);return"outline"in o?o?.outline?.size:void 0}function y(e){if(!e)return 0;if(t(e)){const t=f(e);return null!=t?t:0}return l(c(e)?.width)}function m(e){if(null==e||!("symbolLayers"in e)||null==e.symbolLayers)return!1;switch(e.type){case"point-3d":return e.symbolLayers.some((e=>"object"===e.type));case"line-3d":return e.symbolLayers.some((e=>"path"===e.type));case"polygon-3d":return e.symbolLayers.some((e=>"object"===e.type||"extrude"===e.type));default:return!1}}function p(e){return r(e.resource).href}function h(n,r){if(!n)return null;let l=null;return t(n)?l=b(n):o(n)&&(l=n.color?new e(n.color):null),l?w(l,r):null}function b(t){const o=t.symbolLayers;if(!o)return null;let n=null;return o.forEach((e=>{"object"===e.type&&null!=e.resource?.href||(n="water"===e.type?e.color:null!=e.material?e.material.color:null)})),n?new e(n):null}function w(t,o){if(null==o||null==t)return t;const n=t.toRgba();return n[3]=n[3]*o,new e(n)}function d(e,t,o){const n=e.symbolLayers;if(!n)return;const r=e=>w(t=t??(null!=e?e:null)??(null!=o?a:null),o);n.forEach((e=>{if("object"!==e.type||null==e.resource?.href||t)if("water"===e.type)e.color=r(e.color);else{const t=null!=e.material?e.material.color:null,n=r(t);null==e.material?e.material=new u({color:n}):e.material.color=n,null!=o&&"outline"in e&&null!=e.outline&&null!=e.outline.color&&(e.outline.color=w(e.outline.color,o))}}))}function j(e,t,o){(t=t??e.color)&&(e.color=w(t,o)),null!=o&&"outline"in e&&e.outline&&e.outline.color&&(e.outline.color=w(e.outline.color,o))}function g(n,r,l){n&&(r||null!=l)&&(r&&(r=new e(r)),t(n)?d(n,r,l):o(n)&&j(n,r,l))}async function k(e,t){const o=e.symbolLayers;o&&await n(o,(async e=>L(e,t)))}async function L(e,t){switch(e.type){case"extrude":x(e,t);break;case"icon":case"line":case"text":z(e,t);break;case"path":U(e,t);break;case"object":await v(e,t)}}function z(e,t){const o=S(t);null!=o&&(e.size=o)}function S(e){for(const t of e)if("number"==typeof t)return t;return null}function x(e,t){e.size="number"==typeof t[2]?t[2]:0}async function v(e,t){const{resourceSize:o,symbolSize:n}=await O(e),r=E(t,o,n);e.width=C(t[0],n[0],o[0],r),e.depth=C(t[1],n[1],o[1],r),e.height=C(t[2],n[2],o[2],r)}function U(e,t){const o=E(t,i,[e.width,void 0,e.height]);e.width=C(t[0],e.width,1,o),e.height=C(t[2],e.height,1,o)}function E(e,t,o){for(let n=0;n<3;n++){const r=e[n];switch(r){case"symbol-value":{const e=o[n];return null!=e?e/t[n]:1}case"proportional":break;default:if(r&&t[n])return r/t[n]}}return 1}async function O(e){const t=await import("./symbolLayerUtils.js"),o=await t.computeObjectLayerResourceSize(e,10),{width:n,height:r,depth:l}=e,i=[n,l,r];let s=1;for(let c=0;c<3;c++){const e=i[c];if(null!=e){s=e/o[c];break}}for(let c=0;c<3;c++)null==i[c]&&(i[c]=o[c]*s);return{resourceSize:o,symbolSize:i}}function C(e,t,o,n){switch(e){case"proportional":return o*n;case"symbol-value":return null!=t?t:o;default:return e}}function I(e,t){const o=S(t);if(null!=o)switch(e.type){case"simple-marker":e.size=o;break;case"picture-marker":{const t=e.width/e.height;t>1?(e.width=o,e.height=o*t):(e.width=o*t,e.height=o);break}case"simple-line":e.width=o;break;case"text":e.font.size=o}}async function M(e,n){if(e&&n)return t(e)?k(e,n):void(o(e)&&I(e,n))}function R(e,n,r){if(e&&null!=n)if(t(e)){const t=e.symbolLayers;t&&t.forEach((e=>{if(e&&"object"===e.type)switch(r){case"tilt":e.tilt=n;break;case"roll":e.roll=n;break;default:e.heading=n}}))}else o(e)&&("simple-marker"!==e.type&&"picture-marker"!==e.type&&"text"!==e.type||(e.angle=n))}function A(e){if(!e)return null;const t=e.effects.filter((e=>"bloom"!==e.type)).map((e=>e.toJSON()));return s(t)}function D(e){return null!=e&&"polygon-3d"===e.type&&e.symbolLayers.some((e=>"extrude"===e.type))}async function J(e,t){const o=await e.fetchSymbol(t);return o||e.fetchCIMSymbol(t)}export{g as applyColorToSymbol,w as applyOpacityToColor,R as applyRotationToSymbol,M as applySizesToSymbol,J as fetchWebStyleSymbol,A as getCSSFilterFromEffectList,h as getColorFromSymbol,p as getIconHref,y as getSymbolOutlineSize,m as isVolumetricSymbol,D as symbolHasExtrudeSymbolLayer};
5
+ import e from"../../Color.js";import{isSymbol3D as t,isSymbol2D as o}from"../../symbols.js";import{forEach as n}from"../../core/asyncUtils.js";import"../../core/has.js";import{unwrapOrThrow as r}from"../../core/maybe.js";import{px2pt as l}from"../../core/screenUtils.js";import{O as i}from"../../chunks/vec3f64.js";import{effectFunctionsFromJSON as s}from"../../layers/effects/jsonUtils.js";import{getStroke as c}from"./gfxUtils.js";import{Symbol3DMaterial as u}from"./Symbol3DMaterial.js";const a=new e("white");function f(e){const t=e.symbolLayers&&e.symbolLayers.length;if(!t)return;const o=e.symbolLayers.getItemAt(t-1);return"outline"in o?o?.outline?.size:void 0}function y(e){if(!e)return 0;if(t(e)){const t=f(e);return null!=t?t:0}return l(c(e)?.width)}function m(e){if(null==e||!("symbolLayers"in e)||null==e.symbolLayers)return!1;switch(e.type){case"point-3d":return e.symbolLayers.some((e=>"object"===e.type));case"line-3d":return e.symbolLayers.some((e=>"path"===e.type));case"polygon-3d":return e.symbolLayers.some((e=>"object"===e.type||"extrude"===e.type));default:return!1}}function p(e){return r(e.resource).href}function h(n,r){if(!n)return null;let l=null;return t(n)?l=b(n):o(n)&&(l=n.color?new e(n.color):null),l?w(l,r):null}function b(t){const o=t.symbolLayers;if(!o)return null;let n=null;return o.forEach((e=>{"object"===e.type&&e.resource?.href||(n="water"===e.type?e.color:e.material?e.material.color:null)})),n?new e(n):null}function w(t,o){if(null==o||null==t)return t;const n=t.toRgba();return n[3]=n[3]*o,new e(n)}function d(e,t,o){const n=e.symbolLayers;if(!n)return;const r=e=>w(t=t??e??(null!=o?a:null),o);n.forEach((e=>{if("object"!==e.type||!e.resource?.href||t)if("water"===e.type)e.color=r(e.color);else{const t=null!=e.material?e.material.color:null,n=r(t);null==e.material?e.material=new u({color:n}):e.material.color=n,null!=o&&"outline"in e&&null!=e.outline&&null!=e.outline.color&&(e.outline.color=w(e.outline.color,o))}}))}function j(e,t,o){(t=t??e.color)&&(e.color=w(t,o)),null!=o&&"outline"in e&&e.outline&&e.outline.color&&(e.outline.color=w(e.outline.color,o))}function g(n,r,l){n&&(r||null!=l)&&(r&&(r=new e(r)),t(n)?d(n,r,l):o(n)&&j(n,r,l))}async function k(e,t){const o=e.symbolLayers;o&&await n(o,(async e=>L(e,t)))}async function L(e,t){switch(e.type){case"extrude":x(e,t);break;case"icon":case"line":case"text":z(e,t);break;case"path":U(e,t);break;case"object":await v(e,t)}}function z(e,t){const o=S(t);null!=o&&(e.size=o)}function S(e){for(const t of e)if("number"==typeof t)return t;return null}function x(e,t){e.size="number"==typeof t[2]?t[2]:0}async function v(e,t){const{resourceSize:o,symbolSize:n}=await O(e),r=E(t,o,n);e.width=C(t[0],n[0],o[0],r),e.depth=C(t[1],n[1],o[1],r),e.height=C(t[2],n[2],o[2],r)}function U(e,t){const o=E(t,i,[e.width,void 0,e.height]);e.width=C(t[0],e.width,1,o),e.height=C(t[2],e.height,1,o)}function E(e,t,o){for(let n=0;n<3;n++){const r=e[n];switch(r){case"symbol-value":{const e=o[n];return null!=e?e/t[n]:1}case"proportional":break;default:if(r&&t[n])return r/t[n]}}return 1}async function O(e){const t=await import("./symbolLayerUtils.js"),o=await t.computeObjectLayerResourceSize(e,10),{width:n,height:r,depth:l}=e,i=[n,l,r];let s=1;for(let c=0;c<3;c++){const e=i[c];if(null!=e){s=e/o[c];break}}for(let c=0;c<3;c++)null==i[c]&&(i[c]=o[c]*s);return{resourceSize:o,symbolSize:i}}function C(e,t,o,n){switch(e){case"proportional":return o*n;case"symbol-value":return null!=t?t:o;default:return e}}function I(e,t){const o=S(t);if(null!=o)switch(e.type){case"simple-marker":e.size=o;break;case"picture-marker":{const t=e.width/e.height;t>1?(e.width=o,e.height=o*t):(e.width=o*t,e.height=o);break}case"simple-line":e.width=o;break;case"text":e.font.size=o}}async function M(e,n){if(e&&n)return t(e)?k(e,n):void(o(e)&&I(e,n))}function R(e,n,r){if(e&&null!=n)if(t(e)){const t=e.symbolLayers;t&&t.forEach((e=>{if(e&&"object"===e.type)switch(r){case"tilt":e.tilt=n;break;case"roll":e.roll=n;break;default:e.heading=n}}))}else o(e)&&("simple-marker"!==e.type&&"picture-marker"!==e.type&&"text"!==e.type||(e.angle=n))}function A(e){if(!e)return null;const t=e.effects.filter((e=>"bloom"!==e.type)).map((e=>e.toJSON()));return s(t)}function D(e){return null!=e&&"polygon-3d"===e.type&&e.symbolLayers.some((e=>"extrude"===e.type))}async function J(e,t){const o=await e.fetchSymbol(t);return o||e.fetchCIMSymbol(t)}export{g as applyColorToSymbol,w as applyOpacityToColor,R as applyRotationToSymbol,M as applySizesToSymbol,J as fetchWebStyleSymbol,A as getCSSFilterFromEffectList,h as getColorFromSymbol,p as getIconHref,y as getSymbolOutlineSize,m as isVolumetricSymbol,D as symbolHasExtrudeSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{isSymbol3D as t}from"../../symbols.js";import{isDevEnvironment as e,adjustStaticAGOUrl as r}from"../../core/devEnvironmentUtils.js";import l from"../../core/Error.js";import{unwrapOrThrow as o}from"../../core/maybe.js";import{urlToObject as n,removeFile as s}from"../../core/urlUtils.js";import m from"../../portal/Portal.js";import{f as i}from"../../chunks/persistableUrlUtils.js";import{fromJSON as a}from"./jsonUtils.js";import u from"./StyleOrigin.js";import{fetchStyle as p,symbolUrlFromStyleItem as f,requestJSON as y,makeCIMSymbolRef as c,Style2DUrlTemplate as b}from"./styleUtils.js";import{Thumbnail as g}from"./Thumbnail.js";function j(t,e,r,n){const s=t.name;return null==s?Promise.reject(new l("symbolstyleutils:style-symbol-reference-name-missing","Missing name in style symbol reference")):t.styleName&&"Esri2DPointSymbolsStyle"===t.styleName?d(s,e,n):p(t,e,n).then((t=>h(o(t),s,e,r,n)))}function h(o,p,b,j,h){const d=o.data,U=b&&null!=b.portal?b.portal:m.getDefault(),N={portal:U,url:n(o.baseUrl),origin:"portal-item"},w=d.items.find((t=>t.name===p));if(!w){const t=`The symbol name '${p}' could not be found`;return Promise.reject(new l("symbolstyleutils:symbol-name-not-found",t,{symbolName:p}))}let S=i(f(w,j),N),D=w.thumbnail?.href??null;const O=w.thumbnail&&w.thumbnail.imageData;e()&&(S=r(S)??"",D=r(D));const P={portal:U,url:n(s(S)),origin:"portal-item"};return y(S,h).then((e=>{const r="cimRef"===j?c(e.data):e.data,l=a(r,P);if(l&&t(l)){if(D){const t=i(D,N);l.thumbnail=new g({url:t})}else O&&(l.thumbnail=new g({url:`data:image/png;base64,${O}`}));o.styleUrl?l.styleOrigin=new u({portal:b.portal,styleUrl:o.styleUrl,name:p}):o.styleName&&(l.styleOrigin=new u({portal:b.portal,styleName:o.styleName,name:p}))}return l}))}function d(t,e,r){const l=b.replace(/\{SymbolName\}/gi,t),o=null!=e.portal?e.portal:m.getDefault();return y(l,r).then((t=>{const e=c(t.data);return a(e,{portal:o,url:n(s(l)),origin:"portal-item"})}))}export{h as fetchSymbolFromStyle,j as resolveWebStyleSymbol};
5
+ import{isSymbol3D as t}from"../../symbols.js";import{isDevEnvironment as e,adjustStaticAGOUrl as r}from"../../core/devEnvironmentUtils.js";import l from"../../core/Error.js";import{unwrapOrThrow as o}from"../../core/maybe.js";import{urlToObject as n,removeFile as s}from"../../core/urlUtils.js";import m from"../../portal/Portal.js";import{f as i}from"../../chunks/persistableUrlUtils.js";import{fromJSON as a}from"./jsonUtils.js";import u from"./StyleOrigin.js";import{fetchStyle as p,requestJSON as f,makeCIMSymbolRef as y,Style2DUrlTemplate as c,symbolUrlFromStyleItem as b}from"./styleUtils.js";import{Thumbnail as g}from"./Thumbnail.js";function j(t,e,r,n){const s=t.name;return null==s?Promise.reject(new l("symbolstyleutils:style-symbol-reference-name-missing","Missing name in style symbol reference")):t.styleName&&"Esri2DPointSymbolsStyle"===t.styleName?U(s,e,n):p(t,e,n).then((t=>d(o(t),s,e,r,b,n)))}function h(t,e){return e.items.find((e=>e.name===t))}function d(o,p,c,b,j,d){const U=c&&null!=c.portal?c.portal:m.getDefault(),N={portal:U,url:n(o.baseUrl),origin:"portal-item"},w=h(p,o.data);if(!w){const t=`The symbol name '${p}' could not be found`;return Promise.reject(new l("symbolstyleutils:symbol-name-not-found",t,{symbolName:p}))}let S=i(j(w,b),N),D=w.thumbnail?.href??null;const O=w.thumbnail&&w.thumbnail.imageData;e()&&(S=r(S)??"",D=r(D));const P={portal:U,url:n(s(S)),origin:"portal-item"};return f(S,d).then((e=>{const r="cimRef"===b?y(e.data):e.data,l=a(r,P);if(l&&t(l)){if(D){const t=i(D,N);l.thumbnail=new g({url:t})}else O&&(l.thumbnail=new g({url:`data:image/png;base64,${O}`}));o.styleUrl?l.styleOrigin=new u({portal:c.portal,styleUrl:o.styleUrl,name:p}):o.styleName&&(l.styleOrigin=new u({portal:c.portal,styleName:o.styleName,name:p}))}return l}))}function U(t,e,r){const l=c.replace(/\{SymbolName\}/gi,t),o=null!=e.portal?e.portal:m.getDefault();return f(l,r).then((t=>{const e=y(t.data);return a(e,{portal:o,url:n(s(l)),origin:"portal-item"})}))}export{d as fetchSymbolFromStyle,h as getStyleItemFromStyle,j as resolveWebStyleSymbol};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/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 o from"../../../../core/Logger.js";import{nextPowerOfTwo as n}from"../../../../core/mathUtils.js";import{throwIfAborted as a,isAbortError as h}from"../../../../core/promiseUtils.js";import{pt2px as c}from"../../../../core/screenUtils.js";import{s as u}from"../../../../chunks/vec2.js";import{c as d}from"../../../../chunks/vec2f32.js";import l from"../../../../symbols/cim/Rasterizer.js";import{SDF_TEXTURE_SIZE as m,TEXTURE_BINDING_GLYPH_ATLAS as p,TEXTURE_BINDING_SPRITE_ATLAS as g,SPRITE_PADDING as f,PATTERN_FILL_RASTERIZATION_SCALE as _}from"./definitions.js";import{MosaicType as w}from"./enums.js";import y from"./GlyphMosaic.js";import M from"./GlyphSource.js";import I from"./SDFConverter.js";import z from"./SpriteMosaic.js";import{is3D as T,charCodes as R,isSimple as v,isSVGResource as j,isImageResource as x,isMarkerPlacementInsidePolygon as S,shouldRepeat as b,getUrl as P,getPMSResourceSize as U,isGIF as B,isPNG as G,isSVGImage as C}from"./Utils.js";import{AnimatableTextureResource as A}from"./animatedFormats/AnimatableTextureResource.js";import{resize as q}from"./animatedFormats/utils.js";import{ok as E}from"./util/Result.js";import{keyFromSymbol as F}from"./util/symbolUtils.js";import{QueueProcessor as L}from"../../../support/QueueProcessor.js";import{TextureSamplingMode as N}from"../../../webgl/enums.js";const $=d(),k="arial-unicode-ms-regular",H=o.getLogger("esri.views.2d.engine.webgl.TextureManager");function O(e,t){const i=Math.round(c(t)*window.devicePixelRatio),s=i>=128?2:4;return Math.min(e,i*s)}const Q=(e,t,i)=>H.error(new s(e,t,i));class V{static fromMosaic(e,t){return new V(e,t.page,t.sdf)}constructor(e,t,i){this.mosaicType=e,this.page=t,this.sdf=i}}class Y{constructor(i,r,o){this._requestRender=i,this.resourceManager=r,this._allowNonPowerOfTwo=o,this._invalidFontsMap=new Map,this._sdfConverter=new I(m),this._bindingInfos=new Array,this._hashToBindingIndex=new Map,this._ongoingRasterizations=new Map,this._imageRequestQueue=new L({concurrency:10,process:async(e,i)=>{a(i);try{return await t(e,{responseType:"image",signal:i})}catch(r){if(!h(r))throw new s("mapview-invalid-resource",`Could not fetch requested resource at ${e}`,r);throw r}}}),this._spriteMosaic=new z(2048,2048,500),this._glyphSource=new M(`${e.fontsUrl}/{fontstack}/{range}.pbf`),this._glyphMosaic=new y(1024,1024,this._glyphSource),this._rasterizer=new l(r)}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}get sprites(){return this._spriteMosaic}get glyphs(){return this._glyphMosaic}async rasterizeItem(e,t,i,s){if(null==e)return Q("mapview-null-resource","Unable to rasterize null resource"),null;switch(e.type){case"text":case"esriTS":{const t=await this._rasterizeText(e,i,s);return t.forEach((e=>this._setTextureBinding(w.GLYPH,e))),{glyphMosaicItems:t}}default:{if(T(e))return Q("mapview-invalid-type",`MapView does not support symbol type: ${e.type}`,e),null;const i=await this._rasterizeSpriteSymbol(e,t,s);return E(i)&&i&&this._setTextureBinding(w.SPRITE,i),{spriteMosaicItem:i}}}}bindTextures(e,t,i,s=!1){if(0===i.textureBinding)return;const r=this._bindingInfos[i.textureBinding-1],o=r.page,n=s?N.LINEAR_MIPMAP_LINEAR:N.LINEAR;switch(r.mosaicType){case w.SPRITE:{const i=this.sprites.getWidth(o),s=this.sprites.getHeight(o),r=u($,i,s);return this._spriteMosaic.bind(e,n,o,g),t.setUniform1i("u_texture",g),void t.setUniform2fv("u_mosaicSize",r)}case w.GLYPH:{const i=this.glyphs.width,s=this.glyphs.height,r=u($,i,s);return this._glyphMosaic.bind(e,n,o,p),t.setUniform1i("u_texture",p),void t.setUniform2fv("u_mosaicSize",r)}default:H.error("mapview-texture-manager",`Cannot handle unknown type ${r.mosaicType}`)}}_hashMosaic(e,t){return 1|e<<1|(t.sdf?1:0)<<2|t.page<<3}_setTextureBinding(e,t){const i=this._hashMosaic(e,t);if(!this._hashToBindingIndex.has(i)){const s=V.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,s){let o,n;if("cim"in e){const t=e;o=t.fontName,n=t.text}else{const t=e;o=r(t.font),n=t.text}const a=this._invalidFontsMap.has(o),h=t||R(i(n)[0]);try{const e=a?k:o;return has("esri-2d-stabilize-glyphs")&&await this._glyphMosaic.preloadASCIIGlyphCache(e),await this._glyphMosaic.getGlyphItems(e,h,s)}catch(c){return Q("mapview-invalid-resource",`Couldn't find font ${o}. Falling back to Arial Unicode MS Regular`),this._invalidFontsMap.set(o,!0),this._glyphMosaic.getGlyphItems(k,h,s)}}async _rasterizeSpriteSymbol(e,t,i){if(v(e))return;const r=F(e);if(this._spriteMosaic.has(r))return this._spriteMosaic.getSpriteItem(r);if(j(e)||x(e)&&!S(e))return this._handleAsyncResource(r,e,i);const o=_,n=this._rasterizer.rasterizeJSONResource(e,o);if(n){const{size:t,image:i,sdf:s,simplePattern:o,rasterizationScale:a}=n;return this._addItemToMosaic(r,t,{type:"static",data:i},b(e),s,o,a)}return new s("TextureManager","unrecognized or null rasterized image")}async _handleAsyncResource(e,t,i){if(this._ongoingRasterizations.has(e))return this._ongoingRasterizations.get(e);let s;s=j(t)?this._handleSVG(t,e,i):this._handleImage(t,e,i),this._ongoingRasterizations.set(e,s);try{await s,this._ongoingRasterizations.delete(e)}catch{this._ongoingRasterizations.delete(e)}return s}async _handleSVG(e,t,i){const s=[m,m],r=await this._sdfConverter.draw(e.path,i);return this._addItemToMosaic(t,s,{type:"static",data:new Uint32Array(r.buffer)},!1,!0,!0)}async _handleGIFOrPNG(e,t,i){const r=P(e);await this.resourceManager.fetchResource(r,i);let o=this.resourceManager.getResource(r);if(null==o)return new s("mapview-invalid-resource",`Could not fetch requested resource at ${r}.`);let a=o.width,h=o.height;if(o instanceof HTMLImageElement){"esriPMS"===e.type&&(a=Math.round(O(o.width,U(e))),h=Math.round(o.height*(a/o.width)));const i="cim"in e?e.cim.colorSubstitutions:void 0,{size:s,sdf:r,image:n}=this._rasterizer.rasterizeImageResource(a,h,o,i);return this._addItemToMosaic(t,s,{type:"static",data:n},b(e),r,!1)}this._allowNonPowerOfTwo||(a=n(o.width+2*f)-2*f,h=n(o.height+2*f)-2*f),a===o.width&&h===o.height||(o=q(o,a,h));const c=e.animatedSymbolProperties||{},u=e.objectId,d=new A(o,this._requestRender,c,u);return this._addItemToMosaic(t,[d.width,d.height],{type:"animated",data:d},b(e),!1,!1)}async _handleImage(e,t,i){if(B(e)||G(e))return this._handleGIFOrPNG(e,t,i);const r=P(e);try{let s;const o=this.resourceManager.getResource(r);if(null!=o&&o instanceof HTMLImageElement)s=o;else{const{data:e}=await this._imageRequestQueue.push(r,{...i});s=e}if(C(r))if("width"in e&&"height"in e)s.width=c(e.width),s.height=c(e.height);else if("cim"in e){const t=e.cim;s.width=c(t.width??t.scaleX*t.size),s.height=c(t.size)}if(!s.width||!s.height)return null;let n=s.width,a=s.height;"esriPMS"===e.type&&(n=Math.round(O(s.width,U(e))),a=Math.round(s.height*(n/s.width)));const h="cim"in e?e.cim.colorSubstitutions:void 0,{size:u,sdf:d,image:l}=this._rasterizer.rasterizeImageResource(n,a,s,h);return this._addItemToMosaic(t,u,{type:"static",data:l},b(e),d,!1)}catch(o){if(!h(o))return new s("mapview-invalid-resource",`Could not fetch requested resource at ${r}. ${o.message}`)}}_addItemToMosaic(e,t,i,s,r,o,n){return this._spriteMosaic.addSpriteItem(e,t,i,s,r,o,n)}}export{Y 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 o from"../../../../core/Logger.js";import{nextPowerOfTwo as n}from"../../../../core/mathUtils.js";import{throwIfAborted as a,isAbortError as h}from"../../../../core/promiseUtils.js";import{pt2px as c}from"../../../../core/screenUtils.js";import{s as u}from"../../../../chunks/vec2.js";import{c as d}from"../../../../chunks/vec2f32.js";import l from"../../../../symbols/cim/Rasterizer.js";import{SDF_TEXTURE_SIZE as m,TEXTURE_BINDING_GLYPH_ATLAS as p,TEXTURE_BINDING_SPRITE_ATLAS as g,SPRITE_PADDING as f,PATTERN_FILL_RASTERIZATION_SCALE as _}from"./definitions.js";import{MosaicType as w}from"./enums.js";import y from"./GlyphMosaic.js";import M from"./GlyphSource.js";import I from"./SDFConverter.js";import z from"./SpriteMosaic.js";import{is3D as T,charCodes as R,isSimple as v,isSVGResource as j,isImageResource as x,isMarkerPlacementInsidePolygon as S,shouldRepeat as b,getUrl as P,getPMSResourceSize as U,isGIF as B,isPNG as G,isSVGImage as C}from"./Utils.js";import{AnimatableTextureResource as A}from"./animatedFormats/AnimatableTextureResource.js";import{resize as q}from"./animatedFormats/utils.js";import{ok as E}from"./util/Result.js";import{keyFromSymbol as F}from"./util/symbolUtils.js";import{QueueProcessor as L}from"../../../support/QueueProcessor.js";import{TextureSamplingMode as N}from"../../../webgl/enums.js";const $=d(),k="arial-unicode-ms-regular",H=o.getLogger("esri.views.2d.engine.webgl.TextureManager");function O(e,t){const i=Math.round(c(t)*window.devicePixelRatio),s=i>=128?2:4;return Math.min(e,i*s)}const Q=(e,t,i)=>H.error(new s(e,t,i));class V{static fromMosaic(e,t){return new V(e,t.page,t.sdf)}constructor(e,t,i){this.mosaicType=e,this.page=t,this.sdf=i}}class Y{constructor(i,r,o){this._requestRender=i,this.resourceManager=r,this._allowNonPowerOfTwo=o,this._invalidFontsMap=new Map,this._sdfConverter=new I(m),this._bindingInfos=new Array,this._hashToBindingIndex=new Map,this._ongoingRasterizations=new Map,this._imageRequestQueue=new L({concurrency:10,process:async(e,i)=>{a(i);try{return await t(e,{responseType:"image",signal:i})}catch(r){if(!h(r))throw new s("mapview-invalid-resource",`Could not fetch requested resource at ${e}`,r);throw r}}}),this._spriteMosaic=new z(2048,2048,500),this._glyphSource=new M(`${e.fontsUrl}/{fontstack}/{range}.pbf`),this._glyphMosaic=new y(1024,1024,this._glyphSource),this._rasterizer=new l(r)}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}get sprites(){return this._spriteMosaic}get glyphs(){return this._glyphMosaic}async rasterizeItem(e,t,i,s){if(null==e)return Q("mapview-null-resource","Unable to rasterize null resource"),null;switch(e.type){case"text":case"esriTS":{const t=await this._rasterizeText(e,i,s);return t.forEach((e=>this._setTextureBinding(w.GLYPH,e))),{glyphMosaicItems:t}}default:{if(T(e))return Q("mapview-invalid-type",`MapView does not support symbol type: ${e.type}`,e),null;const i=await this._rasterizeSpriteSymbol(e,t,s);return E(i)&&i&&this._setTextureBinding(w.SPRITE,i),{spriteMosaicItem:i}}}}bindTextures(e,t,i,s=!1){if(0===i.textureBinding)return;const r=this._bindingInfos[i.textureBinding-1],o=r.page,n=s?N.LINEAR_MIPMAP_LINEAR:N.LINEAR;switch(r.mosaicType){case w.SPRITE:{const i=this.sprites.getWidth(o),s=this.sprites.getHeight(o),r=u($,i,s);return this._spriteMosaic.bind(e,n,o,g),t.setUniform1i("u_texture",g),void t.setUniform2fv("u_mosaicSize",r)}case w.GLYPH:{const i=this.glyphs.width,s=this.glyphs.height,r=u($,i,s);return this._glyphMosaic.bind(e,n,o,p),t.setUniform1i("u_texture",p),void t.setUniform2fv("u_mosaicSize",r)}default:H.error("mapview-texture-manager",`Cannot handle unknown type ${r.mosaicType}`)}}_hashMosaic(e,t){return 1|e<<1|(t.sdf?1:0)<<2|t.page<<3}_setTextureBinding(e,t){const i=this._hashMosaic(e,t);if(!this._hashToBindingIndex.has(i)){const s=V.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,s){let o,n;if("cim"in e){const t=e;o=t.fontName,n=t.text}else{const t=e;o=r(t.font),n=t.text}const a=this._invalidFontsMap.has(o),h=t||R(i(n)[0]);try{const e=a?k:o;return has("esri-2d-stabilize-glyphs")&&await this._glyphMosaic.preloadASCIIGlyphCache(e),await this._glyphMosaic.getGlyphItems(e,h,s)}catch(c){return Q("mapview-invalid-resource",`Couldn't find font ${o}. Falling back to Arial Unicode MS Regular`),this._invalidFontsMap.set(o,!0),this._glyphMosaic.getGlyphItems(k,h,s)}}async _rasterizeSpriteSymbol(e,t,i){if(v(e))return;const r=F(e);if(this._spriteMosaic.has(r))return this._spriteMosaic.getSpriteItem(r);if(j(e)||x(e)&&!S(e))return this._handleAsyncResource(r,e,i);const o=_,n=this._rasterizer.rasterizeJSONResource(e,o);if(n){const{size:t,image:i,sdf:s,simplePattern:o,rasterizationScale:a}=n;return this._addItemToMosaic(r,t,{type:"static",data:i},b(e),s,o,a)}return new s("TextureManager","unrecognized or null rasterized image")}async _handleAsyncResource(e,t,i){if(this._ongoingRasterizations.has(e))return this._ongoingRasterizations.get(e);let s;s=j(t)?this._handleSVG(t,e,i):this._handleImage(t,e,i),this._ongoingRasterizations.set(e,s);try{await s,this._ongoingRasterizations.delete(e)}catch{this._ongoingRasterizations.delete(e)}return s}async _handleSVG(e,t,i){const s=[m,m],r=await this._sdfConverter.draw(e.path,i);return this._addItemToMosaic(t,s,{type:"static",data:new Uint32Array(r.buffer)},!1,!0,!0)}async _handleGIFOrPNG(e,t,i){const r=P(e);await this.resourceManager.fetchResource(r,i);let o=this.resourceManager.getResource(r);if(null==o)return new s("mapview-invalid-resource",`Could not fetch requested resource at ${r}.`);let a=o.width,h=o.height;if(o instanceof HTMLImageElement){"esriPMS"===e.type&&(a=Math.round(O(o.width,U(e))),h=Math.round(o.height*(a/o.width)));const i="cim"in e?e.cim.colorSubstitutions:void 0,{size:s,sdf:r,image:n}=this._rasterizer.rasterizeImageResource(a,h,o,i);return this._addItemToMosaic(t,s,{type:"static",data:n},b(e),r,!1)}this._allowNonPowerOfTwo||(a=n(o.width+2*f)-2*f,h=n(o.height+2*f)-2*f),a===o.width&&h===o.height||(o=q(o,a,h));const c=e.animatedSymbolProperties||{},u=e.objectId,d=new A(o,this._requestRender,c,u);return this._addItemToMosaic(t,[d.width,d.height],{type:"animated",data:d},b(e),!1,!1)}async _handleImage(e,t,i){if(B(e)||G(e))return this._handleGIFOrPNG(e,t,i);const r=P(e);try{let s;const o=this.resourceManager.getResource(r);if(null!=o&&o instanceof HTMLImageElement)s=o;else{const{data:e}=await this._imageRequestQueue.push(r,{...i});s=e}if(C(r))if("width"in e&&"height"in e)s.width=c(e.width),s.height=c(e.height);else if("cim"in e){const t=e.cim;s.width=c(t.width??t.scaleX*t.size),s.height=c(t.size)}if(!s.width||!s.height)return null;let n=s.width,a=s.height;"esriPMS"===e.type&&(n=Math.round(O(s.width,U(e))),a=Math.round(s.height*(n/s.width)));const h="cim"in e?e.cim.colorSubstitutions:void 0,{size:u,sdf:d,image:l}=this._rasterizer.rasterizeImageResource(n,a,s,h);return this._addItemToMosaic(t,u,{type:"static",data:l},b(e),d,!1)}catch(Q){if(!h(Q))return new s("mapview-invalid-resource",`Could not fetch requested resource at ${r}. ${Q.message}`)}}_addItemToMosaic(e,t,i,s,r,o,n){return this._spriteMosaic.addSpriteItem(e,t,i,s,r,o,n)}}export{Y as default};