@arcgis/core 4.22.0-next.20211206 → 4.22.2

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 (150) hide show
  1. package/PopupTemplate.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/0146455a237a1d237525.js +1 -0
  4. package/assets/esri/core/workers/chunks/{44ccee36f8c74f4f134e.js → 025df54bafc05c183182.js} +1 -1
  5. package/assets/esri/core/workers/chunks/0677ed519c51710d7629.js +1 -0
  6. package/assets/esri/core/workers/chunks/{6a1ce00bcb689ea95bcb.js → 26111da2277612ba0e38.js} +1 -1
  7. package/assets/esri/core/workers/chunks/28f9b48b59bf1347facd.js +1 -0
  8. package/assets/esri/core/workers/chunks/360bb187a91c8cadcb8b.js +1 -0
  9. package/assets/esri/core/workers/chunks/{96a62dc1e07f3ef20a30.js → 3981c2e5b88c93d63793.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{44145763617ea985cce4.js → 3ccb827134eb2ad54ff2.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{4417dfcb2ba50ac9f199.js → 487713de9462be6b5202.js} +1 -1
  12. package/assets/esri/core/workers/chunks/53c05fb7fed21c815ee9.js +1 -0
  13. package/assets/esri/core/workers/chunks/{6e736a6717e09bf6c1fc.js → 5f87aea9f42c40c51b6f.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{d7f77fe32bb2d69b5714.js → 606b99f366517ca9d577.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{f3da8b797c8e1fcb1c21.js → 63161320a58a0b1702a2.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{8bc4ea821be16a752226.js → 88fd591d45e8b4542f82.js} +1 -1
  17. package/assets/esri/core/workers/chunks/8cdaa07b09d5c2b1ccc5.js +1 -0
  18. package/assets/esri/core/workers/chunks/{fd874267d81bc0b2be50.js → a4c58e301ded79fe827d.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{23af0b02208e20d5c07e.js → ab067b1b6a2af26decc5.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{6210b23872c362f51b12.js → ac9f18daa7236446c9c8.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{bc0b85bc1e5116836ba4.js → b6e150686198dec02a27.js} +1 -1
  22. package/assets/esri/core/workers/chunks/d06d4b76625afc309a55.js +1 -0
  23. package/assets/esri/core/workers/chunks/{5f2718cd77cbd5ba7920.js → da62f8159ec2fdbdeb58.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{52aa3b44bddb10caa343.js → e07f78db820375e105c0.js} +1 -1
  25. package/assets/esri/core/workers/chunks/f1b3f84ddf34a13c9d8e.js +1 -0
  26. package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
  27. package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
  28. package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
  29. package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
  30. package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
  31. package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
  32. package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
  33. package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
  34. package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
  35. package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
  36. package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
  37. package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
  38. package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
  39. package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
  40. package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
  41. package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
  42. package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
  43. package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
  44. package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
  45. package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
  46. package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
  47. package/assets/esri/widgets/Editor/t9n/Editor_nb.json +1 -1
  48. package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
  49. package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
  50. package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
  51. package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
  52. package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
  53. package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
  54. package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
  55. package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
  56. package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
  57. package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
  58. package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
  59. package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
  60. package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
  61. package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
  62. package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
  63. package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
  64. package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
  65. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ar.json +1 -1
  66. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_bg.json +1 -1
  67. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_bs.json +1 -1
  68. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ca.json +1 -1
  69. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_cs.json +1 -1
  70. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_da.json +1 -1
  71. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_de.json +1 -1
  72. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_el.json +1 -1
  73. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_es.json +1 -1
  74. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_et.json +1 -1
  75. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_fi.json +1 -1
  76. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_fr.json +1 -1
  77. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_he.json +1 -1
  78. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_hr.json +1 -1
  79. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_hu.json +1 -1
  80. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_id.json +1 -1
  81. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_it.json +1 -1
  82. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ja.json +1 -1
  83. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ko.json +1 -1
  84. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_lt.json +1 -1
  85. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_lv.json +1 -1
  86. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_nb.json +1 -1
  87. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_nl.json +1 -1
  88. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pl.json +1 -1
  89. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pt-BR.json +1 -1
  90. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pt-PT.json +1 -1
  91. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ro.json +1 -1
  92. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ru.json +1 -1
  93. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sk.json +1 -1
  94. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sl.json +1 -1
  95. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sr.json +1 -1
  96. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sv.json +1 -1
  97. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_th.json +1 -1
  98. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_tr.json +1 -1
  99. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_uk.json +1 -1
  100. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_vi.json +1 -1
  101. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-CN.json +1 -1
  102. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-HK.json +1 -1
  103. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-TW.json +1 -1
  104. package/assets/esri/widgets/support/t9n/timezone_bg.json +1 -1
  105. package/chunks/Clouds.glsl.js +4 -4
  106. package/config.js +1 -1
  107. package/interfaces.d.ts +138 -41
  108. package/layers/CSVLayer.js +1 -1
  109. package/layers/GeoJSONLayer.js +1 -1
  110. package/layers/mixins/ArcGISImageService.js +1 -1
  111. package/package.json +1 -1
  112. package/renderers/VectorFieldRenderer.js +1 -1
  113. package/renderers/support/RasterSymbolizer.js +1 -1
  114. package/renderers/support/rasterRendererHelper.js +1 -1
  115. package/rest/query/operations/query.js +1 -1
  116. package/smartMapping/raster/renderers/classBreaks.js +1 -1
  117. package/support/arcadeUtils.js +1 -1
  118. package/support/revision.js +1 -1
  119. package/symbols/cim/CIMSymbolHelper.js +1 -1
  120. package/symbols/cim/cimAnalyzer.js +1 -1
  121. package/views/2d/MapViewConstraints.js +1 -1
  122. package/views/2d/constraints/ZoomConstraint.js +1 -1
  123. package/views/2d/engine/Stage.js +1 -1
  124. package/views/2d/engine/webgl/collisions/CollisionEngine.js +1 -1
  125. package/views/2d/engine/webgl/collisions/CollisionGrid.js +1 -1
  126. package/views/2d/engine/webgl/mesh/templates/WGLDynamicMeshTemplate.js +1 -1
  127. package/views/2d/engine/webgl/mesh/templates/WGLDynamicTextTemplate.js +1 -1
  128. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  129. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  130. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  131. package/views/2d/layers/graphics/GraphicBoundsRenderer.js +1 -1
  132. package/views/2d/layers/graphics/GraphicStore.js +1 -1
  133. package/views/3d/environment/Clouds.glsl.js +1 -1
  134. package/views/3d/environment/CloudsGenerator.js +1 -1
  135. package/views/3d/environment/NoiseTextureAtlas.js +1 -1
  136. package/views/MapView.js +1 -1
  137. package/views/webgl/Program.js +1 -1
  138. package/widgets/Histogram.js +1 -1
  139. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  140. package/widgets/Sketch/SketchViewModel.js +1 -1
  141. package/widgets/TimeSlider/TimeSliderViewModel.js +1 -1
  142. package/widgets/UtilityNetworkTrace.js +1 -1
  143. package/assets/esri/core/workers/chunks/22d1bead2fe51ab81bea.js +0 -1
  144. package/assets/esri/core/workers/chunks/49bb222ee07a768e998d.js +0 -1
  145. package/assets/esri/core/workers/chunks/650f04de72c173beaebc.js +0 -1
  146. package/assets/esri/core/workers/chunks/aa57f2c380132c746730.js +0 -1
  147. package/assets/esri/core/workers/chunks/af6251cc7973b43a1523.js +0 -1
  148. package/assets/esri/core/workers/chunks/deba37055be7c2d7da26.js +0 -1
  149. package/assets/esri/core/workers/chunks/e02a3d456525e76ddb60.js +0 -1
  150. package/assets/esri/core/workers/chunks/e3d43cdc72fa4c58e183.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import{b as t,m as e,c as s,d as r,r as i}from"../../../../chunks/mat3.js";import{c as o}from"../../../../chunks/mat3f32.js";import{f as a}from"../../../../chunks/vec2f32.js";import{f as n}from"../../../../chunks/vec3f32.js";import{normalizeMapX as f}from"../../../../geometry/support/normalizeUtils.js";import l from"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import{Program as m}from"../../../webgl/Program.js";import"../../../webgl/enums.js";import"../../../webgl/Texture.js";import u from"../../../webgl/VertexArrayObject.js";import{DisplayObject as c}from"../../engine/DisplayObject.js";import{createProgramDescriptor as h}from"../../engine/webgl/Utils.js";const d=Math.PI/180,p=4;class _ extends c{constructor(t){super(),this._dvsMat3=o(),this._localOrigin={x:0,y:0},this._getBounds=t}destroy(){this._vao&&(this._vao.dispose(!0),this._vao=null,this._vertexBuffer=null,this._indexBuffer=null),this._program&&(this._program.dispose(),this._program=null)}doRender(t){const{context:e}=t,s=this._getBounds();if(s.length<1)return;this._createShaderProgram(e),this._updateMatricesAndLocalOrigin(t),this._updateBufferData(e,s),e.setBlendingEnabled(!0),e.setDepthTestEnabled(!1),e.setStencilWriteMask(0),e.setStencilTestEnabled(!1),e.setBlendFunction(1,771),e.setColorMask(!0,!0,!0,!0);const r=this._program;e.bindVAO(this._vao),e.useProgram(r),r.setUniformMatrix3fv("u_dvsMat3",this._dvsMat3),e.gl.lineWidth(1),e.drawElements(1,8*s.length,5125,0),e.bindVAO()}_createTransforms(){return{dvs:o()}}_createShaderProgram(t){if(this._program)return;const e="precision highp float;\n uniform mat3 u_dvsMat3;\n\n attribute vec2 a_position;\n\n void main() {\n mediump vec3 pos = u_dvsMat3 * vec3(a_position, 1.0);\n gl_Position = vec4(pos.xy, 0.0, 1.0);\n }",s="precision mediump float;\n void main() {\n gl_FragColor = vec4(0.75, 0.0, 0.0, 0.75);\n }";this._program=new m(t,e,s,g().attributes)}_updateMatricesAndLocalOrigin(o){const{state:l}=o,{displayMat3:m,size:u,resolution:c,pixelRatio:h,rotation:p,viewpoint:_}=l,g=d*p,{x:v,y:b}=_.targetGeometry,x=f(v,l.spatialReference);this._localOrigin.x=x,this._localOrigin.y=b;const j=h*u[0],y=h*u[1],B=c*j,w=c*y,M=t(this._dvsMat3);e(M,M,m),s(M,M,a(j/2,y/2)),r(M,M,n(u[0]/B,-y/w,1)),i(M,M,-g)}_updateBufferData(t,e){const{x:s,y:r}=this._localOrigin,i=2*p*e.length,o=new Float32Array(i),a=new Uint32Array(8*e.length);let n=0,f=0;for(const l of e)o[2*n+0]=l[0]-s,o[2*n+1]=l[1]-r,o[2*n+2]=l[0]-s,o[2*n+3]=l[3]-r,o[2*n+4]=l[2]-s,o[2*n+5]=l[3]-r,o[2*n+6]=l[2]-s,o[2*n+7]=l[1]-r,a[f+0]=n+0,a[f+1]=n+3,a[f+2]=n+3,a[f+3]=n+2,a[f+4]=n+2,a[f+5]=n+1,a[f+6]=n+1,a[f+7]=n+0,n+=4,f+=8;if(this._vertexBuffer?this._vertexBuffer.setData(o.buffer):this._vertexBuffer=l.createVertex(t,35048,o.buffer),this._indexBuffer?this._indexBuffer.setData(a):this._indexBuffer=l.createIndex(t,35048,a),!this._vao){const e=g();this._vao=new u(t,e.attributes,e.bufferLayouts,{geometry:this._vertexBuffer},this._indexBuffer)}}}const g=()=>h("bounds",{geometry:[{location:0,name:"a_position",count:2,type:5126}]});export{_ as default};
5
+ import{b as t,m as e,c as s,d as r,r as i}from"../../../../chunks/mat3.js";import{c as o}from"../../../../chunks/mat3f32.js";import{f as a}from"../../../../chunks/vec2f32.js";import{f as n}from"../../../../chunks/vec3f32.js";import{normalizeMapX as f}from"../../../../geometry/support/normalizeUtils.js";import l from"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import{Program as m}from"../../../webgl/Program.js";import"../../../webgl/enums.js";import"../../../webgl/Texture.js";import u from"../../../webgl/VertexArrayObject.js";import{DisplayObject as c}from"../../engine/DisplayObject.js";import{createProgramDescriptor as h}from"../../engine/webgl/Utils.js";const d=Math.PI/180,p=4;class _ extends c{constructor(t){super(),this._dvsMat3=o(),this._localOrigin={x:0,y:0},this._getBounds=t}destroy(){this._vao&&(this._vao.dispose(!0),this._vao=null,this._vertexBuffer=null,this._indexBuffer=null),this._program&&(this._program.dispose(),this._program=null)}doRender(t){const{context:e}=t,s=this._getBounds();if(s.length<1)return;this._createShaderProgram(e),this._updateMatricesAndLocalOrigin(t),this._updateBufferData(e,s),e.setBlendingEnabled(!0),e.setDepthTestEnabled(!1),e.setStencilWriteMask(0),e.setStencilTestEnabled(!1),e.setBlendFunction(1,771),e.setColorMask(!0,!0,!0,!0);const r=this._program;e.bindVAO(this._vao),e.useProgram(r),r.setUniformMatrix3fv("u_dvsMat3",this._dvsMat3),e.gl.lineWidth(1),e.drawElements(1,8*s.length,5125,0),e.bindVAO()}_createTransforms(){return{dvs:o()}}_createShaderProgram(t){if(this._program)return;const e="precision highp float;\n uniform mat3 u_dvsMat3;\n\n attribute vec2 a_position;\n\n void main() {\n mediump vec3 pos = u_dvsMat3 * vec3(a_position, 1.0);\n gl_Position = vec4(pos.xy, 0.0, 1.0);\n }",s="precision mediump float;\n void main() {\n gl_FragColor = vec4(0.75, 0.0, 0.0, 0.75);\n }";this._program=new m(t,e,s,g().attributes)}_updateMatricesAndLocalOrigin(o){const{state:l}=o,{displayMat3:m,size:u,resolution:c,pixelRatio:h,rotation:p,viewpoint:_}=l,g=d*p,{x:v,y:b}=_.targetGeometry,x=f(v,l.spatialReference);this._localOrigin.x=x,this._localOrigin.y=b;const j=h*u[0],y=h*u[1],B=c*j,w=c*y,M=t(this._dvsMat3);e(M,M,m),s(M,M,a(j/2,y/2)),r(M,M,n(u[0]/B,-y/w,1)),i(M,M,-g)}_updateBufferData(t,e){const{x:s,y:r}=this._localOrigin,i=2*p*e.length,o=new Float32Array(i),a=new Uint32Array(8*e.length);let n=0,f=0;for(const l of e)l&&(o[2*n+0]=l[0]-s,o[2*n+1]=l[1]-r,o[2*n+2]=l[0]-s,o[2*n+3]=l[3]-r,o[2*n+4]=l[2]-s,o[2*n+5]=l[3]-r,o[2*n+6]=l[2]-s,o[2*n+7]=l[1]-r,a[f+0]=n+0,a[f+1]=n+3,a[f+2]=n+3,a[f+3]=n+2,a[f+4]=n+2,a[f+5]=n+1,a[f+6]=n+1,a[f+7]=n+0,n+=4,f+=8);if(this._vertexBuffer?this._vertexBuffer.setData(o.buffer):this._vertexBuffer=l.createVertex(t,35048,o.buffer),this._indexBuffer?this._indexBuffer.setData(a):this._indexBuffer=l.createIndex(t,35048,a),!this._vao){const e=g();this._vao=new u(t,e.attributes,e.bufferLayouts,{geometry:this._vertexBuffer},this._indexBuffer)}}}const g=()=>h("bounds",{geometry:[{location:0,name:"a_position",count:2,type:5126}]});export{_ 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.22/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as e,isSome as t}from"../../../../core/maybe.js";import{pt2px as r}from"../../../../core/screenUtils.js";import{r as i}from"../../../../chunks/rbush.js";import{create as s,intersects as o,clone as n}from"../../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as h}from"../../../../geometry/support/boundsUtils.js";import{normalizeMapX as a}from"../../../../geometry/support/normalizeUtils.js";import{getSpatialReferenceMinMaxX as u}from"../../../../geometry/support/normalizeUtilsCommon.js";import{HittestDrawHelper as l}from"../../../../symbols/cim/CIMSymbolDrawHelper.js";import{CIMSimbolInflatedSizeHelper as c}from"../../../../symbols/cim/CIMSymbolHelper.js";import m from"./GraphicStoreItem.js";import{PIXEL_BUFFER as d,graphicGeometryToNumber as p}from"./graphicsUtils.js";const g={minX:0,minY:0,maxX:0,maxY:0},f=s(),_=1e-5;function b(e,t,r,i,s){return g.minX=t,g.minY=r,g.maxX=i,g.maxY=s,e.search(g)}function y(e){return{minX:e.bounds[0],minY:e.bounds[1],maxX:e.bounds[2],maxY:e.bounds[3]}}class I{constructor(e,t,r,s,o,n,h){this._graphics=s,this._onAdd=o,this._onRemove=n,this._hashToCIM=h,this._index=i(9,y),this._itemByGraphic=new Map,this._inflatedSizeHelper=new c,this._tileInfoView=e,this._uidFieldName=r;const a=e.getClosestInfoForScale(t);a&&(this._resolution=this._tileInfoView.getTileResolution(a.level))}setResourceManager(e){this._cimResourceManager=e,this._hittestDrawHelper=new l(e)}hitTest(e,t,r,i,n){e=a(e,this._tileInfoView.spatialReference);const h=.5*i*window.devicePixelRatio*r;f[0]=e-h,f[1]=t-h,f[2]=e+h,f[3]=t+h;const u=.5*i*(r+d),l=b(this._index,e-u,t-u,e+u,t+u);if(!l||0===l.length)return[];const c=[],m=s(),p=s();for(const s of l){const{geometry:e,symbolResource:t}=s;this._getSymbolBounds(m,t,e,p,n),p[3]=p[2]=p[1]=p[0]=0,o(m,f)&&s.graphic.visible&&c.push(s)}if(0===c.length)return[];const g=this._hittestDrawHelper,_=[];for(const s of c){const{geometry:e,symbolResource:t}=s,{hash:r,textInfo:o}=t,h=this._hashToCIM.get(r);h&&(g.hitTest(f,h.symbol,e,o,n,i)&&_.push(s))}return _.sort(z),_.map((e=>e.graphic))}getGraphicsData(e,t,r){const i=this._searchForItems(t);if(0===i.length||0===r.length)return[];i.sort(((e,t)=>e.zorder-t.zorder)),i[0].insertAfter=-1;for(let l=1;l<i.length;l++)i[l].insertAfter=i[l-1].graphic.uid;i.sort(((e,t)=>e.graphic.uid-t.graphic.uid)),r.sort(((e,t)=>e.uid-t.uid));let s,o=0,n=0;const h=t.resolution,a=[],u={originPosition:"upperLeft",scale:[h,h],translate:[t.bounds[0],t.bounds[3]]};for(const l of r){for(n=-2;o<i.length;)if(s=i[o],o++,l.uid===s.graphic.uid){n=s.insertAfter;break}if(!s.geometry||-2===n)continue;const r=s.getGeometryQuantized(u,t.bounds,this._tileInfoView.spatialReference,h),c={...s.graphic.attributes};c[this._uidFieldName]=l.uid,null==s.groupId&&(s.groupId=e.createTemplateGroup(s.symbol,null)),a.push({centroid:m.getCentroidQuantized(s,u),geometry:r,attributes:c,symbol:s.symbol,groupId:s.groupId,insertAfter:n,zorder:s.zorder})}return a.sort(((e,t)=>e.zorder-t.zorder)),a}queryTileData(e,t){if(0===this._graphics.length)return[];const{bounds:r,resolution:i}=t,s=this._searchForItems(t),o=[];return 0===s.length||this._createTileGraphics(o,e,s,{originPosition:"upperLeft",scale:[i,i],translate:[r[0],r[3]]},t),o}has(e){return this._itemByGraphic.has(e)}getBounds(e){const t=this._itemByGraphic.get(e);return t?t.bounds:null}getAllBounds(){return Array.from(this._itemByGraphic.values()).filter((e=>e.graphic.visible)).map((e=>e.bounds))}addOrModify(r,i,s){if(!r||e(i))return;this.has(r)&&this.remove(r),this._onAdd(r);const o=[0,0,0,0],n=this._getSymbolBounds(null,i,s,o,0),h=m.acquire(r,i,s,t(n)?n:null,o);return this._itemByGraphic.set(r,h),s&&this._index.insert(h),h.bounds}remove(e){if(!this._itemByGraphic.has(e))return;this._onRemove(e);const t=this._itemByGraphic.get(e);this._index.remove(t),this._itemByGraphic.delete(e)}updateZ(){const e=this._graphics.items;let t,r;for(let i=0;i<e.length;i++)r=e[i],t=this._itemByGraphic.get(r),t&&(t.zorder=i)}update(e,r,i){const s=this._itemByGraphic.get(e);s.groupId=null;const o=n(s.bounds);this._index.remove(s);const h=this._getSymbolBounds(s.bounds,r,i,s.size,0);return t(h)&&s.set(e,r,i,h,s.size),i&&this._index.insert(s),{oldBounds:o,newBounds:s.bounds}}updateLevel(e){if(this._resolution===e)return;this._resolution=e,this._index.clear();const r=this._itemByGraphic,i=[];for(const[s,o]of r){const e=this._getSymbolBounds(o.bounds,o.symbolResource,o.geometry,o.size,0);o.geometry&&t(e)&&(o.bounds=e,i.push(o))}this._index.load(i)}clear(){this._itemByGraphic.clear(),this._index.clear()}_createTileGraphics(e,t,r,i,s){const o=this._uidFieldName,n=this._tileInfoView.spatialReference,{bounds:h,resolution:a}=s;let u,l,c,d;r.sort(((e,t)=>e.zorder-t.zorder));for(let p=0;p<r.length;p++){c=r[p],u=c.graphic,l=c.getGeometryQuantized(i,h,n,a),d=0===p?-1:r[p-1].graphic.uid;const s={...c.graphic.attributes};s[o]=u.uid,null==c.groupId&&(c.groupId=t.createTemplateGroup(c.symbol,null)),e.push({centroid:m.getCentroidQuantized(c,i),geometry:l,attributes:s,symbol:c.symbol,groupId:c.groupId,insertAfter:d,zorder:c.zorder})}}_searchForItems(e){const t=this._tileInfoView.spatialReference,r=e.bounds;if(t.isWrappable){const[i,o]=u(t),n=Math.abs(r[2]-o)<_,h=Math.abs(r[0]-i)<_;if((!n||!h)&&(n||h)){const t=e.resolution;let h;h=s(n?[i,r[1],i+t*d,r[3]]:[o-t*d,r[1],o,r[3]]);const a=b(this._index,r[0],r[1],r[2],r[3]),u=b(this._index,h[0],h[1],h[2],h[3]);return[...new Set([...a,...u])]}}return b(this._index,r[0],r[1],r[2],r[3])}_getSymbolBounds(e,t,i,o,n){if(!t||!t.symbol)return null;if(e||(e=s()),h(e,i),!o||0===o[0]&&0===o[1]&&0===o[2]&&0===o[3]){const{hash:e,textInfo:i}=t,s=this._hashToCIM.get(e);if(!s)return null;o||(o=[0,0,0,0]);const h=this._inflatedSizeHelper.getSymbolInflateSize(o,s.symbol,this._cimResourceManager,n,i);o[0]=r(h[0]),o[1]=r(h[1]),o[2]=r(h[2]),o[3]=r(h[3])}const a=this._resolution,u=c.SafeSize(o);return e[0]-=u*a,e[1]-=u*a,e[2]+=u*a,e[3]+=u*a,e}}const z=(e,t)=>{const r=p(e.graphic),i=p(t.graphic);return r===i?t.zorder-e.zorder:r-i};export{I as default};
5
+ import{isNone as e,isSome as t}from"../../../../core/maybe.js";import{pt2px as r}from"../../../../core/screenUtils.js";import{r as i}from"../../../../chunks/rbush.js";import{create as s,intersects as o,clone as n}from"../../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as h}from"../../../../geometry/support/boundsUtils.js";import{normalizeMapX as u}from"../../../../geometry/support/normalizeUtils.js";import{getSpatialReferenceMinMaxX as a}from"../../../../geometry/support/normalizeUtilsCommon.js";import{HittestDrawHelper as l}from"../../../../symbols/cim/CIMSymbolDrawHelper.js";import{CIMSimbolInflatedSizeHelper as c}from"../../../../symbols/cim/CIMSymbolHelper.js";import m from"./GraphicStoreItem.js";import{PIXEL_BUFFER as d,graphicGeometryToNumber as p}from"./graphicsUtils.js";const g={minX:0,minY:0,maxX:0,maxY:0},f=s(),_=1e-5;function b(e,t,r,i,s){return g.minX=t,g.minY=r,g.maxX=i,g.maxY=s,e.search(g)}function y(e){return{minX:e.bounds[0],minY:e.bounds[1],maxX:e.bounds[2],maxY:e.bounds[3]}}class I{constructor(e,t,r,s,o,n,h){this._graphics=s,this._onAdd=o,this._onRemove=n,this._hashToCIM=h,this._index=i(9,y),this._itemByGraphic=new Map,this._inflatedSizeHelper=new c,this._tileInfoView=e,this._uidFieldName=r;const u=e.getClosestInfoForScale(t);u&&(this._resolution=this._tileInfoView.getTileResolution(u.level))}setResourceManager(e){this._cimResourceManager=e,this._hittestDrawHelper=new l(e)}hitTest(e,t,r,i,n){e=u(e,this._tileInfoView.spatialReference);const h=.5*i*window.devicePixelRatio*r;f[0]=e-h,f[1]=t-h,f[2]=e+h,f[3]=t+h;const a=.5*i*(r+d),l=b(this._index,e-a,t-a,e+a,t+a);if(!l||0===l.length)return[];const c=[],m=s(),p=s();for(const s of l){const{geometry:e,symbolResource:t}=s;this._getSymbolBounds(m,t,e,p,n),p[3]=p[2]=p[1]=p[0]=0,o(m,f)&&s.graphic.visible&&c.push(s)}if(0===c.length)return[];const g=this._hittestDrawHelper,_=[];for(const s of c){const{geometry:e,symbolResource:t}=s,{hash:r,textInfo:o}=t,h=this._hashToCIM.get(r);h&&(g.hitTest(f,h.symbol,e,o,n,i)&&_.push(s))}return _.sort(z),_.map((e=>e.graphic))}getGraphicsData(e,t,r){const i=this._searchForItems(t);if(0===i.length||0===r.length)return[];i.sort(((e,t)=>e.zorder-t.zorder)),i[0].insertAfter=-1;for(let l=1;l<i.length;l++)i[l].insertAfter=i[l-1].graphic.uid;i.sort(((e,t)=>e.graphic.uid-t.graphic.uid)),r.sort(((e,t)=>e.uid-t.uid));let s,o=0,n=0;const h=t.resolution,u=[],a={originPosition:"upperLeft",scale:[h,h],translate:[t.bounds[0],t.bounds[3]]};for(const l of r){for(n=-2;o<i.length;)if(s=i[o],o++,l.uid===s.graphic.uid){n=s.insertAfter;break}if(!s.geometry||-2===n)continue;const r=s.getGeometryQuantized(a,t.bounds,this._tileInfoView.spatialReference,h),c={...s.graphic.attributes};c[this._uidFieldName]=l.uid,null==s.groupId&&(s.groupId=e.createTemplateGroup(s.symbol,null)),u.push({centroid:m.getCentroidQuantized(s,a),geometry:r,attributes:c,symbol:s.symbol,groupId:s.groupId,insertAfter:n,zorder:s.zorder})}return u.sort(((e,t)=>e.zorder-t.zorder)),u}queryTileData(e,t){if(0===this._graphics.length)return[];const{bounds:r,resolution:i}=t,s=this._searchForItems(t),o=[];return 0===s.length||this._createTileGraphics(o,e,s,{originPosition:"upperLeft",scale:[i,i],translate:[r[0],r[3]]},t),o}has(e){return this._itemByGraphic.has(e)}getBounds(e){const t=this._itemByGraphic.get(e);return t?t.bounds:null}getAllBounds(){return Array.from(this._itemByGraphic.values()).filter((e=>e.graphic.visible)).map((e=>e.bounds))}addOrModify(r,i,s){if(!r||e(i))return;this.has(r)&&this.remove(r),this._onAdd(r);const o=[0,0,0,0],n=this._getSymbolBounds(null,i,s,o,0),h=m.acquire(r,i,s,t(n)?n:null,o);return this._itemByGraphic.set(r,h),s&&this._index.insert(h),h.bounds}remove(e){if(!this._itemByGraphic.has(e))return;this._onRemove(e);const t=this._itemByGraphic.get(e);t.bounds&&this._index.remove(t),this._itemByGraphic.delete(e)}updateZ(){const e=this._graphics.items;let t,r;for(let i=0;i<e.length;i++)r=e[i],t=this._itemByGraphic.get(r),t&&(t.zorder=i)}update(e,r,i){const s=this._itemByGraphic.get(e);s.groupId=null;const o=n(s.bounds);this._index.remove(s);const h=this._getSymbolBounds(s.bounds,r,i,s.size,0);return t(h)&&s.set(e,r,i,h,s.size),i&&this._index.insert(s),{oldBounds:o,newBounds:s.bounds}}updateLevel(e){if(this._resolution===e)return;this._resolution=e,this._index.clear();const r=this._itemByGraphic,i=[];for(const[s,o]of r){const e=this._getSymbolBounds(o.bounds,o.symbolResource,o.geometry,o.size,0);o.geometry&&t(e)&&(o.bounds=e,i.push(o))}this._index.load(i)}clear(){this._itemByGraphic.clear(),this._index.clear()}_createTileGraphics(e,t,r,i,s){const o=this._uidFieldName,n=this._tileInfoView.spatialReference,{bounds:h,resolution:u}=s;let a,l,c,d;r.sort(((e,t)=>e.zorder-t.zorder));for(let p=0;p<r.length;p++){c=r[p],a=c.graphic,l=c.getGeometryQuantized(i,h,n,u),d=0===p?-1:r[p-1].graphic.uid;const s={...c.graphic.attributes};s[o]=a.uid,null==c.groupId&&(c.groupId=t.createTemplateGroup(c.symbol,null)),e.push({centroid:m.getCentroidQuantized(c,i),geometry:l,attributes:s,symbol:c.symbol,groupId:c.groupId,insertAfter:d,zorder:c.zorder})}}_searchForItems(e){const t=this._tileInfoView.spatialReference,r=e.bounds;if(t.isWrappable){const[i,o]=a(t),n=Math.abs(r[2]-o)<_,h=Math.abs(r[0]-i)<_;if((!n||!h)&&(n||h)){const t=e.resolution;let h;h=s(n?[i,r[1],i+t*d,r[3]]:[o-t*d,r[1],o,r[3]]);const u=b(this._index,r[0],r[1],r[2],r[3]),a=b(this._index,h[0],h[1],h[2],h[3]);return[...new Set([...u,...a])]}}return b(this._index,r[0],r[1],r[2],r[3])}_getSymbolBounds(e,t,i,o,n){if(!t||!t.symbol||!i)return null;if(e||(e=s()),h(e,i),!o||0===o[0]&&0===o[1]&&0===o[2]&&0===o[3]){const{hash:e,textInfo:i}=t,s=this._hashToCIM.get(e);if(!s)return null;o||(o=[0,0,0,0]);const h=this._inflatedSizeHelper.getSymbolInflateSize(o,s.symbol,this._cimResourceManager,n,i);o[0]=r(h[0]),o[1]=r(h[1]),o[2]=r(h[2]),o[3]=r(h[3])}const u=this._resolution,a=c.SafeSize(o);return e[0]-=a*u,e[1]-=a*u,e[2]+=a*u,e[3]+=a*u,e}}const z=(e,t)=>{const r=p(e.graphic),i=p(t.graphic);return r===i?t.zorder-e.zorder:r-i};export{I 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.22/esri/copyright.txt for details.
4
4
  */
5
- import"../webgl-engine/core/shaderModules/interfaces.js";import"../webgl-engine/core/shaderModules/ShaderBuilder.js";export{b as build}from"../../../chunks/Clouds.glsl.js";
5
+ import"./NoiseTextureAtlas.js";import"../webgl-engine/core/shaderModules/interfaces.js";import"../webgl-engine/core/shaderModules/ShaderBuilder.js";export{b as build}from"../../../chunks/Clouds.glsl.js";
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import s from"../../../core/has.js";import{lerp as i}from"../../../core/mathUtils.js";import{removeMaybe as r,releaseMaybe as o,disposeMaybe as h,destroyMaybe as a,isNone as n}from"../../../core/maybe.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{f as m}from"../../../chunks/mat3.js";import{c as d}from"../../../chunks/mat3f64.js";import{q as p}from"../../../chunks/mat4.js";import{c as l}from"../../../chunks/mat4f64.js";import{f,z as _}from"../../../chunks/vec3f32.js";import{getReferenceEllipsoid as g}from"../../../geometry/projectionEllipsoid.js";import{CloudsTechniqueConfiguration as y,CloudsTechnique as b}from"./CloudsTechnique.js";import{NoiseTextureAtlas as S}from"./NoiseTextureAtlas.js";import{createQuadVAO as v}from"../webgl-engine/lib/glUtil3D.js";import{TaskPriority as x}from"../../support/Scheduler.js";import w from"../../webgl/FramebufferObject.js";let T=class extends t{constructor(e){super(e),this._frameTask=null,this._techniques=[],this._techniqueConfiguration=new y,this._cubeMapSize=s("esri-mobile")?1024:2048,this._viewMat3=d(),this._eye=_(),this._didRenderFaces=!1,this._raymarchingStepType=0,this._cloudRadius=0,this._viewMatrix=l();const t=j.sunny;this.coverage=i(t.coverage[1],t.coverage[0],.5),this.density=i(t.density[1],t.density[0],.5),this.absorption=i(t.absorption[1],t.absorption[0],.5),this.cloudSize=i(t.cloudSize[1],t.cloudSize[0],.5),this.detailSize=i(t.detailSize[1],t.detailSize[0],.5),this.smoothness=i(t.smoothness[1],t.smoothness[0],.5),this.cloudHeight=i(t.cloudHeight[1],t.cloudHeight[0],.5),this.raymarchingStepType=t.raymarchingStepType}_getTechnique(e){const t=this._techniques[e];return t||(this._techniqueConfiguration.steps=e,this._techniques[e]=new b({rctx:this.rctx,viewingMode:this.view.state.viewingMode},this._techniqueConfiguration),this._techniques[e])}initialize(){this._vao=v(this.rctx);const e=g(this.view.spatialReference);this._cloudRadius=.5*e.radius,this.resetRenderFlags(),this._frameTask=this.view.resourceController.scheduler.registerTask(x.CLOUDS_GENERATOR,this)}destroy(){this._frameTask=r(this._frameTask),this._techniques.forEach((e=>o(e))),this._techniques=null,this._frameBufferCube=h(this._frameBufferCube),this._vao=h(this._vao),this._noiseTextureAtlas=a(this._noiseTextureAtlas)}set coverage(e){this._coverage=e,this.resetRenderFlags()}get coverage(){return this._coverage}set density(e){this._density=this.remap(e,0,1,0,.3),this.resetRenderFlags()}set cloudSize(e){this._cloudSize=this.remap(Math.max(.01,1-e),0,1,0,.02),this.resetRenderFlags()}set detailSize(e){this._detailSize=this.remap(Math.max(.01,1-e),0,1,0,.2),this.resetRenderFlags()}set smoothness(e){this._smoothness=this.remap(1-e,0,1,0,.5),this.resetRenderFlags()}set absorption(e){this._sigmaE=1+e,this._power=this.remap(e,0,1,35,120),this.resetRenderFlags()}get absorption(){return this._sigmaE-1}set cloudHeight(e){this._cloudHeight=this.remap(e,0,1,0,1500),this.resetRenderFlags()}get cloudHeight(){return this._cloudHeight}set raymarchingStepType(e){this._raymarchingStepType=e,this.resetRenderFlags()}get noiseTextureAtlas(){return n(this._noiseTextureAtlas)&&(this._noiseTextureAtlas=new S(this.rctx,this.view),this._noiseTextureAtlas.render(128,this.rctx)),this._noiseTextureAtlas}get frameBufferCube(){if(n(this._frameBufferCube)){const e={target:34067,pixelFormat:6408,dataType:5121,wrapMode:33071,samplingMode:9729,hasMipmap:!1,width:this._cubeMapSize,height:this._cubeMapSize};this._frameBufferCube=new w(this.rctx,{colorTarget:2,width:this._cubeMapSize,height:this._cubeMapSize},e)}return this._frameBufferCube}get cubeMap(){return this._frameBufferCube}resetRenderFlags(){this._didRenderFaces=!1}remap(e,t,s,i,r){return i+(e-t)*(r-i)/(s-t)}get running(){return!this._didRenderFaces}runTask(e){if(0===this.coverage||n(this._vao))return void(this._didRenderFaces=!0);const t=this.rctx.getViewport();this.rctx.setViewport(0,0,this._cubeMapSize,this._cubeMapSize),this.rctx.bindFramebuffer(this.frameBufferCube,!1,34069);const s=this._getTechnique(this._raymarchingStepType),i=s.program;this.rctx.useProgram(i),i.bindTexture(this.noiseTextureAtlas.textureAtlas,"cloudShapeTexture"),i.setUniform1f("cloudRadius",this._cloudRadius),i.setUniform1f("halfCubeMapSize",.5*this._cubeMapSize),i.setUniform1f("power",this._power),i.setUniform1f("sigmaE",this._sigmaE),i.setUniform1f("density",this._density),i.setUniform1f("cloudSize",this._cloudSize),i.setUniform1f("detailSize",this._detailSize),i.setUniform1f("smoothness",this._smoothness),i.setUniform1f("cloudHeight",this._cloudHeight),i.setUniform1f("coverage",this._coverage),this.rctx.bindVAO(this._vao),i.assertCompatibleVertexAttributeLocations(this._vao),s.bindPipelineState(this.rctx);for(let r=0;r<5;r++){const e=z[r],t=R[r];p(this._viewMatrix,this._eye,e,t),m(this._viewMat3,this._viewMatrix),i.setUniformMatrix3fv("viewMatrix",this._viewMat3);const s=34069+r;this.frameBufferCube.framebufferTexture2D(this.frameBufferCube.colorAttachment.glName,this.rctx.gl,36064,s),this.rctx.gl.drawArrays(this.rctx.gl.TRIANGLE_STRIP,0,4),this.rctx.gl.flush()}this._didRenderFaces=!0,this.rctx.setViewport(t.x,t.y,t.width,t.height),e.madeProgress(),this.requestRender()}get test(){return{coverage:this._coverage,density:this.remap(this._density,0,.3,0,1),absorption:this._sigmaE-1,cloudSize:1-this.remap(this._cloudSize,0,.02,0,1),detailSize:1-this.remap(this._detailSize,0,.2,0,1),smoothness:1-this.remap(this._smoothness,0,.5,0,1),cloudHeight:this.remap(this._cloudHeight,0,1500,0,1)}}};e([c({constructOnly:!0})],T.prototype,"rctx",void 0),e([c({constructOnly:!0})],T.prototype,"view",void 0),e([c({constructOnly:!0})],T.prototype,"requestRender",void 0),e([c()],T.prototype,"_frameTask",void 0),e([c()],T.prototype,"_didRenderFaces",void 0),e([c({readOnly:!0})],T.prototype,"running",null),T=e([u("esri.views.3d.environment.CloudsGenerator")],T);const z=[f(1,0,0),f(-1,0,0),f(0,1,0),f(0,-1,0),f(0,0,1)],R=[f(0,1,0),f(0,1,0),f(0,0,-1),f(0,0,1),f(0,1,0)];class M{constructor(e,t,s,i,r,o,h,a,n=.5){this.coverage=e,this.density=t,this.absorption=s,this.cloudSize=i,this.detailSize=r,this.smoothness=o,this.cloudHeight=h,this.raymarchingStepType=a,this.median=n}}const j={sunny:new M([.1,.7],[.02,.02],[0,0],[.86,.86],[.8,.8],[.5,.5],[.05,.05],0),cloudy:new M([.24,.7],[.135,.2],[0,0],[.5,.5],[.65,.7],[.3,.3],[1,1],2),rainy:new M([.5,.9],[.2,.5],[.3,.6],[.4,.4],[.7,.7],[.5,.5],[1,1],2),foggy:new M([.8,.8],[.5,.5],[0,0],[.85,.85],[.75,.75],[.8,.8],[.3,.3],1)};export{T as CloudsGenerator,j as cloudPresets};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import s from"../../../core/has.js";import{lerp as i}from"../../../core/mathUtils.js";import{removeMaybe as r,releaseMaybe as o,disposeMaybe as h,destroyMaybe as a,isNone as n}from"../../../core/maybe.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{f as m}from"../../../chunks/mat3.js";import{c as d}from"../../../chunks/mat3f64.js";import{q as p}from"../../../chunks/mat4.js";import{c as f}from"../../../chunks/mat4f64.js";import{f as l,z as _}from"../../../chunks/vec3f32.js";import{getReferenceEllipsoid as g}from"../../../geometry/projectionEllipsoid.js";import{CloudsTechniqueConfiguration as y,CloudsTechnique as b}from"./CloudsTechnique.js";import{NoiseTextureAtlas as v}from"./NoiseTextureAtlas.js";import{createQuadVAO as S}from"../webgl-engine/lib/glUtil3D.js";import{TaskPriority as x}from"../../support/Scheduler.js";import w from"../../webgl/FramebufferObject.js";let T=class extends t{constructor(e){super(e),this._frameTask=null,this._techniques=[],this._techniqueConfiguration=new y,this._cubeMapSize=s("esri-mobile")?1024:2048,this._viewMat3=d(),this._eye=_(),this._didRenderFaces=!1,this._raymarchingStepType=0,this._cloudRadius=0,this._viewMatrix=f();const t=j.sunny;this.coverage=i(t.coverage[1],t.coverage[0],.5),this.density=i(t.density[1],t.density[0],.5),this.absorption=i(t.absorption[1],t.absorption[0],.5),this.cloudSize=i(t.cloudSize[1],t.cloudSize[0],.5),this.detailSize=i(t.detailSize[1],t.detailSize[0],.5),this.smoothness=i(t.smoothness[1],t.smoothness[0],.5),this.cloudHeight=i(t.cloudHeight[1],t.cloudHeight[0],.5),this.raymarchingStepType=t.raymarchingStepType}_getTechnique(e){const t=this._techniques[e];return t||(this._techniqueConfiguration.steps=e,this._techniques[e]=new b({rctx:this.rctx,viewingMode:this.view.state.viewingMode},this._techniqueConfiguration),this._techniques[e])}initialize(){this._vao=S(this.rctx);const e=g(this.view.spatialReference);this._cloudRadius=.5*e.radius,this.resetRenderFlags(),this._frameTask=this.view.resourceController.scheduler.registerTask(x.CLOUDS_GENERATOR,this)}destroy(){this._frameTask=r(this._frameTask),this._techniques.forEach((e=>o(e))),this._techniques=null,this._frameBufferCube=h(this._frameBufferCube),this._vao=h(this._vao),this._noiseTexture=a(this._noiseTexture)}set coverage(e){this._coverage=e,this.resetRenderFlags()}get coverage(){return this._coverage}set density(e){this._density=this.remap(e,0,1,0,.3),this.resetRenderFlags()}set cloudSize(e){this._cloudSize=this.remap(Math.max(.01,1-e),0,1,0,.02),this.resetRenderFlags()}set detailSize(e){this._detailSize=this.remap(Math.max(.01,1-e),0,1,0,.2),this.resetRenderFlags()}set smoothness(e){this._smoothness=this.remap(1-e,0,1,0,.5),this.resetRenderFlags()}set absorption(e){this._sigmaE=1+e,this._power=this.remap(e,0,1,35,120),this.resetRenderFlags()}get absorption(){return this._sigmaE-1}set cloudHeight(e){this._cloudHeight=this.remap(e,0,1,0,1500),this.resetRenderFlags()}get cloudHeight(){return this._cloudHeight}set raymarchingStepType(e){this._raymarchingStepType=e,this.resetRenderFlags()}_ensureNoiseTexture(){return n(this._noiseTexture)&&(this._noiseTexture=new v(this.rctx,this.view),this._noiseTexture.render(this.rctx)),this._noiseTexture}get frameBufferCube(){if(n(this._frameBufferCube)){const e={target:34067,pixelFormat:6408,dataType:5121,wrapMode:33071,samplingMode:9729,hasMipmap:!1,width:this._cubeMapSize,height:this._cubeMapSize};this._frameBufferCube=new w(this.rctx,{colorTarget:2,width:this._cubeMapSize,height:this._cubeMapSize},e)}return this._frameBufferCube}get cubeMap(){return this._frameBufferCube}resetRenderFlags(){this._didRenderFaces=!1}remap(e,t,s,i,r){return i+(e-t)*(r-i)/(s-t)}get running(){return!this._didRenderFaces}runTask(e){if(0===this.coverage||n(this._vao))return void(this._didRenderFaces=!0);const t=this._ensureNoiseTexture().textureAtlas;if(n(t))return void(this._didRenderFaces=!0);const s=this.rctx.getViewport();this.rctx.setViewport(0,0,this._cubeMapSize,this._cubeMapSize),this.rctx.bindFramebuffer(this.frameBufferCube,!1,34069);const i=this._getTechnique(this._raymarchingStepType),r=i.program;this.rctx.useProgram(r),r.bindTexture(t,"cloudShapeTexture"),r.setUniform1f("cloudRadius",this._cloudRadius),r.setUniform1f("halfCubeMapSize",.5*this._cubeMapSize),r.setUniform1f("power",this._power),r.setUniform1f("sigmaE",this._sigmaE),r.setUniform1f("density",this._density),r.setUniform1f("cloudSize",this._cloudSize),r.setUniform1f("detailSize",this._detailSize),r.setUniform1f("smoothness",this._smoothness),r.setUniform1f("cloudHeight",this._cloudHeight),r.setUniform1f("coverage",this._coverage),this.rctx.bindVAO(this._vao),r.assertCompatibleVertexAttributeLocations(this._vao),i.bindPipelineState(this.rctx);for(let o=0;o<5;o++){const e=z[o],t=R[o];p(this._viewMatrix,this._eye,e,t),m(this._viewMat3,this._viewMatrix),r.setUniformMatrix3fv("viewMatrix",this._viewMat3);const s=34069+o;this.frameBufferCube.framebufferTexture2D(this.frameBufferCube.colorAttachment.glName,this.rctx.gl,36064,s),this.rctx.gl.drawArrays(this.rctx.gl.TRIANGLE_STRIP,0,4),this.rctx.gl.flush()}this.rctx.setViewport(s.x,s.y,s.width,s.height),this.requestRender(),this._didRenderFaces=!0,e.madeProgress()}get test(){return{coverage:this._coverage,density:this.remap(this._density,0,.3,0,1),absorption:this._sigmaE-1,cloudSize:1-this.remap(this._cloudSize,0,.02,0,1),detailSize:1-this.remap(this._detailSize,0,.2,0,1),smoothness:1-this.remap(this._smoothness,0,.5,0,1),cloudHeight:this.remap(this._cloudHeight,0,1500,0,1)}}};e([c({constructOnly:!0})],T.prototype,"rctx",void 0),e([c({constructOnly:!0})],T.prototype,"view",void 0),e([c({constructOnly:!0})],T.prototype,"requestRender",void 0),e([c()],T.prototype,"_frameTask",void 0),e([c()],T.prototype,"_didRenderFaces",void 0),e([c({readOnly:!0})],T.prototype,"running",null),T=e([u("esri.views.3d.environment.CloudsGenerator")],T);const z=[l(1,0,0),l(-1,0,0),l(0,1,0),l(0,-1,0),l(0,0,1)],R=[l(0,1,0),l(0,1,0),l(0,0,-1),l(0,0,1),l(0,1,0)];class M{constructor(e,t,s,i,r,o,h,a,n=.5){this.coverage=e,this.density=t,this.absorption=s,this.cloudSize=i,this.detailSize=r,this.smoothness=o,this.cloudHeight=h,this.raymarchingStepType=a,this.median=n}}const j={sunny:new M([.1,.7],[.02,.02],[0,0],[.86,.86],[.8,.8],[.5,.5],[.05,.05],0),cloudy:new M([.24,.7],[.135,.2],[0,0],[.5,.5],[.65,.7],[.3,.3],[1,1],2),rainy:new M([.5,.9],[.2,.5],[.3,.6],[.4,.4],[.7,.7],[.5,.5],[1,1],2),foggy:new M([.8,.8],[.5,.5],[0,0],[.85,.85],[.75,.75],[.8,.8],[.3,.3],1)};export{T as CloudsGenerator,j as cloudPresets};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import{releaseMaybe as e,disposeMaybe as t,isNone as i}from"../../../core/maybe.js";import"../../webgl/BufferObject.js";import r from"../../webgl/FramebufferObject.js";import"../../../core/has.js";import"../../webgl/checkWebGLError.js";import"../../webgl/enums.js";import"../../../chunks/builtins.js";import s from"../../webgl/Texture.js";import"../../webgl/VertexArrayObject.js";import{NoiseTextureAtlasTechnique as o}from"./NoiseTextureAtlasTechnique.js";import{createQuadVAO as h}from"../webgl-engine/lib/glUtil3D.js";class a{constructor(e,t){this._shapeTextureDescriptor={target:3553,pixelFormat:6408,dataType:5121,wrapMode:33071,samplingMode:9729,hasMipmap:!1,width:1,height:1},this._tileSize=1,this._tileRows=1,this._frameBuffer=new r(e,{colorTarget:0}),this._vao=h(e),this.textureAtlas=new s(e,this._shapeTextureDescriptor,null),this._technique=new o({rctx:e,viewingMode:t.state.viewingMode},null)}destroy(){this._technique=e(this._technique),this._frameBuffer=t(this._frameBuffer),this._vao=t(this._vao),this.textureAtlas=t(this.textureAtlas)}render(e,t){if(i(this._vao)||i(this.textureAtlas))return!1;this._tileSize=e,this._tileRows=Math.ceil(Math.sqrt(this._tileSize));const r=(e+2)*this._tileRows;this._frameBuffer.resize(r,r),this.textureAtlas.resize(r,r),this._frameBuffer.attachColorTexture(this.textureAtlas),t.bindFramebuffer(this._frameBuffer);const s=this._technique.program;t.bindVAO(this._vao),s.assertCompatibleVertexAttributeLocations(this._vao),this._technique.bindPipelineState(t),t.useProgram(s),s.setUniform1f("tileSize",this._tileSize),s.setUniform1f("tileRows",this._tileRows);const o=t.getViewport();return t.setViewport(0,0,r,r),t.gl.drawArrays(t.gl.TRIANGLE_STRIP,0,4),this._frameBuffer.detachColorTexture(),t.setViewport(o.x,o.y,o.width,o.height),!0}}export{a as NoiseTextureAtlas};
5
+ import e from"../../../core/has.js";import{releaseMaybe as t,disposeMaybe as r,isNone as i}from"../../../core/maybe.js";import"../../webgl/BufferObject.js";import s from"../../webgl/FramebufferObject.js";import"../../webgl/checkWebGLError.js";import"../../webgl/enums.js";import"../../../chunks/builtins.js";import o from"../../webgl/Texture.js";import"../../webgl/VertexArrayObject.js";import{NoiseTextureAtlasTechnique as a}from"./NoiseTextureAtlasTechnique.js";import{createQuadVAO as h}from"../webgl-engine/lib/glUtil3D.js";const f=e("esri-mobile")?64:128,u=Math.ceil(Math.sqrt(f)),m=(f+2)*u;class l{constructor(e,t){this._shapeTextureDescriptor={target:3553,pixelFormat:6408,dataType:5121,wrapMode:33071,samplingMode:9729,hasMipmap:!1,width:1,height:1},this._frameBuffer=new s(e,{colorTarget:0}),this._vao=h(e),this.textureAtlas=new o(e,this._shapeTextureDescriptor,null),this._technique=new a({rctx:e,viewingMode:t.state.viewingMode},null)}destroy(){this._technique=t(this._technique),this._frameBuffer=r(this._frameBuffer),this._vao=r(this._vao),this.textureAtlas=r(this.textureAtlas)}render(e){if(i(this._vao)||i(this.textureAtlas))return!1;this._frameBuffer.resize(m,m),this.textureAtlas.resize(m,m),this._frameBuffer.attachColorTexture(this.textureAtlas),e.bindFramebuffer(this._frameBuffer);const t=this._technique.program;e.bindVAO(this._vao),t.assertCompatibleVertexAttributeLocations(this._vao),this._technique.bindPipelineState(e),e.useProgram(t),t.setUniform1f("tileSize",f),t.setUniform1f("tileRows",u);const r=e.getViewport();return e.setViewport(0,0,m,m),e.gl.drawArrays(e.gl.TRIANGLE_STRIP,0,4),this._frameBuffer.detachColorTexture(),e.setViewport(r.x,r.y,r.width,r.height),!0}}export{m as ATLAS_SIZE,l as NoiseTextureAtlas,u as TILE_ROWS,f as TILE_SIZE};
package/views/MapView.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.22/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import i from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import s from"../core/Error.js";import a from"../core/has.js";import{isIterable as n}from"../core/iteratorUtils.js";import o from"../core/Logger.js";import{isSome as h}from"../core/maybe.js";import{init as l}from"../core/watchUtils.js";import{initialize as p}from"../core/workers/workers.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{BreakpointsOwner as u}from"./BreakpointsOwner.js";import{DOMContainer as g}from"./DOMContainer.js";import m from"./MapViewBase.js";import w from"./2d/input/MapViewInputManager.js";import f from"./2d/support/HighlightOptions.js";import y from"./support/createScreenshotPlan.js";import{getMaximumResolutionScale as v,getFormatAndQuality as V}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as b,createScreenPointFromSupportedEvent as _}from"./support/screenUtils.js";import{check as M}from"./support/WebGLRequirements.js";import j from"./ui/2d/DefaultUI2D.js";import L from"../webmap/background/ColorBackground.js";const O=o.getLogger("esri.views.MapView");let S,C,k,E,x,N;async function W(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:r,MagnifierView2D:s,Stage:a}]=await Promise.all([import("./webgl.js"),import("./2d/mapViewDeps.js")]);C=e,k=t,E=i,x=r,N=s,S=a}let P=class extends(u(g(m))){constructor(e){super(e),this._magnifierView=null,this._stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>{var e,t;return[null==(e=this.basemapView)?void 0:e.baseLayerViews,this.layerViews,null==(t=this.basemapView)?void 0:t.referenceLayerViews]},getChildrenFunction:()=>null}),this.floors=new i,this.graphicsView=null,this.highlightOptions=new f,this.inputManager=new w({view:this}),this.mapViewNavigation=null,this.supersampleScreenshotsEnabled=!1,this.ui=new j,this.rendering=!1,p()}destroy(){this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get background(){return this.get("map.initialViewProperties.background")||null}set background(e){void 0===e?this._clearOverride("background"):this._override("background",e)}get textureManager(){return this._stage.painter.textureManager}get navigating(){return!(!this.mapViewNavigation||!this.mapViewNavigation.interacting)}toMap(e){if(b(e)){const t=_(this,e);return super.toMap(t)}return super.toMap(e)}async hitTest(e,t){const i=b(e)?_(this,e):e;if(!this.ready||isNaN(i.x)||isNaN(i.y))return{screenPoint:i,results:[]};let r=new Set,s=!1,a=null,n=null;null!=t&&t.include?q(t.include,U(this,(e=>r.add(e)),(e=>{a||(a=new Set),a.add(e)}),(e=>r.add(e)),(()=>s=!0))):(s=!0,r=new Set(this.allLayerViews)),null!=t&&t.exclude&&q(t.exclude,U(this,(e=>r.delete(e)),(e=>{n||(n=new Set),n.add(e)})));const o=this.allLayerViews.filter((e=>!e.suspended&&r.has(e))).reverse(),l=this.toMap(i);let p=(await Promise.all([s?this.graphicsView.hitTest(l):null,...o.map((e=>e.hitTest(l,i)))])).filter(h).flat();return a&&(p=p.filter((e=>a.has(G(e))))),n&&(p=p.filter((e=>!n.has(G(e))))),{screenPoint:i,results:p.map((e=>({mapPoint:l,graphic:e})))}}takeScreenshot(e){e=e||{};const t=this.supersampleScreenshotsEnabled?Math.min(4,v(this.size,Math.min(4096,this._stage.context.parameters.maxTextureSize))):1;let i;e.layers?(i=[],e.layers.forEach((e=>{const t=this.allLayerViews.find((t=>t.layer.id===e.id));t&&"container"in t&&t.container&&i.push(t.container)}))):i=this._stage.children;const{format:r,quality:s}=V(e.format,e.quality),a=y(e,t,this.size,this.padding,r,s,i,e.rotation);return this._stage.takeScreenshot(a)}on(e,t,i,r){const s=this.inputManager&&this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}forceDOMReadyCycle(){this.forceReadyCycle()}validate(){let e=M({checkMajorWebPerformanceCaveat:!1});return a("safari")&&a("safari")<9&&(e=new s("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:a("safari")})),h(e)?(O.warn("#validate()",e.message),Promise.reject(e)):W()}_startup(){this.timeline.begin("MapView Startup"),super._startup(),this.graphics.owner=this;const e={disabledExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions},t=new S(this.surface,{canvas:this.renderCanvas,supersampleScreenshots:this.supersampleScreenshotsEnabled,contextOptions:e,renderingOptions:this.renderingOptions,timeline:this.timeline}),i=new C({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new k(this.featuresTilingScheme)}),r=new x({view:this,animationManager:this.animationManager}),s=new E({view:this});this._magnifierView=new N,this._magnifierView.magnifier=this.magnifier,this._stage=t,this.frameTask.graphicsView=i,this._set("graphicsView",i),this._set("mapViewNavigation",r),this._set("labelManager",s),this.handles.add([this.rootLayerViews.on("change",(()=>this._updateStageChildren())),t.on("post-render",(()=>this._set("rendering",t.renderRequested))),t.on("will-render",(()=>this._set("rendering",t.renderRequested))),t.on("webgl-error",(e=>this.fatalError=e.error)),l(this,"stationary",(e=>t.stationary=e),!0),l(this,"state.id",(()=>t.state=this.state),!0),l(this,"background",(e=>{t.background=e,this._magnifierView.background=e}),!0),l(this,"magnifier",(e=>this._magnifierView.magnifier=e),!0),l(this,"renderingOptions",(e=>t.renderingOptions=e),!0),l(this,"highlightOptions",(()=>t.highlightOptions=this.highlightOptions),!0)],"map-view"),t.state=this.state,this._updateStageChildren();const a=this._resolveWhenReady;this._resolveWhenReady=[],a.forEach((e=>e(this))),this.timeline.end("MapView Startup")}_teardown(){this.handles.remove("map-view"),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._stage.destroy();this.graphicsView.destroy(),this.mapViewNavigation.destroy(),this._stage=null,this._set("graphicsView",null),this._magnifierView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,super._teardown()}_updateStageChildren(){this._stage.removeAllChildren(),this.rootLayerViews.forEach((e=>{this._stage.addChild(e.container)}));const e=this.graphicsView;this._stage.addChild(e.container),this._stage.addChild(this._magnifierView)}};e([d({type:L})],P.prototype,"background",null),e([d()],P.prototype,"floors",void 0),e([d()],P.prototype,"graphicsView",void 0),e([d({type:f})],P.prototype,"highlightOptions",void 0),e([d({readOnly:!0})],P.prototype,"inputManager",void 0),e([d({readOnly:!0})],P.prototype,"textureManager",null),e([d({readOnly:!0})],P.prototype,"mapViewNavigation",void 0),e([d({type:Boolean})],P.prototype,"navigating",null),e([d({type:Boolean,constructOnly:!0})],P.prototype,"supersampleScreenshotsEnabled",void 0),e([d({type:j})],P.prototype,"ui",void 0),e([d({readOnly:!0})],P.prototype,"rendering",void 0),e([d({constructOnly:!0})],P.prototype,"renderCanvas",void 0),e([d({constructOnly:!0})],P.prototype,"deactivatedWebGLExtensions",void 0),e([d({constructOnly:!0})],P.prototype,"debugWebGLExtensions",void 0),P=e([c("esri.views.MapView")],P);const R=P;function G(e){const t=e.getObjectId();var i,r,s,a;return t?`${null!=(i=null!=(r=null==(s=e.layer)?void 0:s.uid)?r:null==(a=e.sourceLayer)?void 0:a.uid)?i:"MapView"}/${t}`:`"MapView/${e.uid}`}function U(e,i,r,s,a){return n=>{if(n instanceof t){if(n.layer===e)null==a||a();else{const t=e.allLayerViews.find((e=>e.layer===n.layer));t&&(null==s||s(t))}r(G(n))}else{const t=e.allLayerViews.find((e=>e.layer===n));t&&i(t)}}}function q(e,t){if(e)if(n(e))for(const i of e)if(n(i))for(const e of i)t(e);else t(i);else t(e)}export{R as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import i from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import s from"../core/Error.js";import a from"../core/has.js";import{isIterable as n}from"../core/iteratorUtils.js";import o from"../core/Logger.js";import{isSome as h}from"../core/maybe.js";import{init as l}from"../core/watchUtils.js";import{initialize as p}from"../core/workers/workers.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{BreakpointsOwner as u}from"./BreakpointsOwner.js";import{DOMContainer as g}from"./DOMContainer.js";import m from"./MapViewBase.js";import w from"./2d/input/MapViewInputManager.js";import y from"./2d/support/HighlightOptions.js";import f from"./support/createScreenshotPlan.js";import{getMaximumResolutionScale as v,getFormatAndQuality as V}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as b,createScreenPointFromSupportedEvent as _}from"./support/screenUtils.js";import{check as M}from"./support/WebGLRequirements.js";import j from"./ui/2d/DefaultUI2D.js";import L from"../webmap/background/ColorBackground.js";const O=o.getLogger("esri.views.MapView");let S,C,k,E,x,N;async function W(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:r,MagnifierView2D:s,Stage:a}]=await Promise.all([import("./webgl.js"),import("./2d/mapViewDeps.js")]);C=e,k=t,E=i,x=r,N=s,S=a}let P=class extends(u(g(m))){constructor(e){super(e),this._magnifierView=null,this._stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>{var e,t;return[null==(e=this.basemapView)?void 0:e.baseLayerViews,this.layerViews,null==(t=this.basemapView)?void 0:t.referenceLayerViews]},getChildrenFunction:()=>null}),this.floors=new i,this.graphicsView=null,this.highlightOptions=new y,this.inputManager=new w({view:this}),this.mapViewNavigation=null,this.supersampleScreenshotsEnabled=!1,this.ui=new j,this.rendering=!1,p()}destroy(){this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get background(){return this.get("map.initialViewProperties.background")||null}set background(e){void 0===e?this._clearOverride("background"):this._override("background",e)}get resourceManager(){return this._stage.resourceManager}get textureManager(){return this._stage.painter.textureManager}get navigating(){return!(!this.mapViewNavigation||!this.mapViewNavigation.interacting)}toMap(e){if(b(e)){const t=_(this,e);return super.toMap(t)}return super.toMap(e)}async hitTest(e,t){const i=b(e)?_(this,e):e;if(!this.ready||isNaN(i.x)||isNaN(i.y))return{screenPoint:i,results:[]};let r=new Set,s=!1,a=null,n=null;null!=t&&t.include?q(t.include,U(this,(e=>r.add(e)),(e=>{a||(a=new Set),a.add(e)}),(e=>r.add(e)),(()=>s=!0))):(s=!0,r=new Set(this.allLayerViews)),null!=t&&t.exclude&&q(t.exclude,U(this,(e=>r.delete(e)),(e=>{n||(n=new Set),n.add(e)})));const o=this.allLayerViews.filter((e=>!e.suspended&&r.has(e))).reverse(),l=this.toMap(i);let p=(await Promise.all([s?this.graphicsView.hitTest(l):null,...o.map((e=>e.hitTest(l,i)))])).filter(h).flat();return a&&(p=p.filter((e=>a.has(G(e))))),n&&(p=p.filter((e=>!n.has(G(e))))),{screenPoint:i,results:p.map((e=>({mapPoint:l,graphic:e})))}}takeScreenshot(e){e=e||{};const t=this.supersampleScreenshotsEnabled?Math.min(4,v(this.size,Math.min(4096,this._stage.context.parameters.maxTextureSize))):1;let i;e.layers?(i=[],e.layers.forEach((e=>{const t=this.allLayerViews.find((t=>t.layer.id===e.id));t&&"container"in t&&t.container&&i.push(t.container)}))):i=this._stage.children;const{format:r,quality:s}=V(e.format,e.quality),a=f(e,t,this.size,this.padding,r,s,i,e.rotation);return this._stage.takeScreenshot(a)}on(e,t,i,r){const s=this.inputManager&&this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}forceDOMReadyCycle(){this.forceReadyCycle()}validate(){let e=M({checkMajorWebPerformanceCaveat:!1});return a("safari")&&a("safari")<9&&(e=new s("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:a("safari")})),h(e)?(O.warn("#validate()",e.message),Promise.reject(e)):W()}_startup(){this.timeline.begin("MapView Startup"),super._startup(),this.graphics.owner=this;const e={disabledExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions},t=new S(this.surface,{canvas:this.renderCanvas,supersampleScreenshots:this.supersampleScreenshotsEnabled,contextOptions:e,renderingOptions:this.renderingOptions,timeline:this.timeline}),i=new C({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new k(this.featuresTilingScheme)}),r=new x({view:this,animationManager:this.animationManager}),s=new E({view:this});this._magnifierView=new N,this._magnifierView.magnifier=this.magnifier,this._stage=t,this.frameTask.graphicsView=i,this._set("graphicsView",i),this._set("mapViewNavigation",r),this._set("labelManager",s),this.handles.add([this.rootLayerViews.on("change",(()=>this._updateStageChildren())),t.on("post-render",(()=>this._set("rendering",t.renderRequested))),t.on("will-render",(()=>this._set("rendering",t.renderRequested))),t.on("webgl-error",(e=>this.fatalError=e.error)),l(this,"stationary",(e=>t.stationary=e),!0),l(this,"state.id",(()=>t.state=this.state),!0),l(this,"background",(e=>{t.background=e,this._magnifierView.background=e}),!0),l(this,"magnifier",(e=>this._magnifierView.magnifier=e),!0),l(this,"renderingOptions",(e=>t.renderingOptions=e),!0),l(this,"highlightOptions",(()=>t.highlightOptions=this.highlightOptions),!0)],"map-view"),t.state=this.state,this._updateStageChildren();const a=this._resolveWhenReady;this._resolveWhenReady=[],a.forEach((e=>e(this))),this.timeline.end("MapView Startup")}_teardown(){this.handles.remove("map-view"),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._stage.destroy();this.graphicsView.destroy(),this.mapViewNavigation.destroy(),this._stage=null,this._set("graphicsView",null),this._magnifierView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,super._teardown()}_updateStageChildren(){this._stage.removeAllChildren(),this.rootLayerViews.forEach((e=>{this._stage.addChild(e.container)}));const e=this.graphicsView;this._stage.addChild(e.container),this._stage.addChild(this._magnifierView)}};e([d({type:L})],P.prototype,"background",null),e([d()],P.prototype,"floors",void 0),e([d()],P.prototype,"graphicsView",void 0),e([d({type:y})],P.prototype,"highlightOptions",void 0),e([d({readOnly:!0})],P.prototype,"inputManager",void 0),e([d({readOnly:!0})],P.prototype,"resourceManager",null),e([d({readOnly:!0})],P.prototype,"textureManager",null),e([d({readOnly:!0})],P.prototype,"mapViewNavigation",void 0),e([d({type:Boolean})],P.prototype,"navigating",null),e([d({type:Boolean,constructOnly:!0})],P.prototype,"supersampleScreenshotsEnabled",void 0),e([d({type:j})],P.prototype,"ui",void 0),e([d({readOnly:!0})],P.prototype,"rendering",void 0),e([d({constructOnly:!0})],P.prototype,"renderCanvas",void 0),e([d({constructOnly:!0})],P.prototype,"deactivatedWebGLExtensions",void 0),e([d({constructOnly:!0})],P.prototype,"debugWebGLExtensions",void 0),P=e([c("esri.views.MapView")],P);const R=P;function G(e){const t=e.getObjectId();var i,r,s,a;return t?`${null!=(i=null!=(r=null==(s=e.layer)?void 0:s.uid)?r:null==(a=e.sourceLayer)?void 0:a.uid)?i:"MapView"}/${t}`:`"MapView/${e.uid}`}function U(e,i,r,s,a){return n=>{if(n instanceof t){if(n.layer===e)null==a||a();else{const t=e.allLayerViews.find((e=>e.layer===n.layer));t&&(null==s||s(t))}r(G(n))}else{const t=e.allLayerViews.find((e=>e.layer===n));t&&i(t)}}}function q(e,t){if(e)if(n(e))for(const i of e)if(n(i))for(const e of i)t(e);else t(i);else t(e)}export{R 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.22/esri/copyright.txt for details.
4
4
  */
5
- import"../../core/has.js";import{isSome as t,isNone as o}from"../../core/maybe.js";import{webglValidateShadersEnabled as i}from"./checkWebGLError.js";import{ResourceType as r}from"./enums.js";import{transpileShader as n}from"./ShaderTranspiler.js";class e{constructor(t,o,i,n){this._context=t,this._locations=n,this._nameToUniformLocation={},this._nameToUniform1={},this._nameToUniform1v={},this._nameToUniform2={},this._nameToUniform3={},this._nameToUniform4={},this._nameToUniformMatrix3={},this._nameToUniformMatrix4={},t||console.error("RenderingContext isn't initialized!"),0===o.length&&console.error("Shaders source should not be empty!"),this._vShader=m(this._context,35633,o),this._fShader=m(this._context,35632,i),this._vShader&&this._fShader||console.error("Error loading shaders!"),this._context.instanceCounter.increment(r.VertexShader,this),this._context.instanceCounter.increment(r.FragmentShader,this)}get glName(){if(t(this._glName))return this._glName;if(o(this._vShader))return null;const n=this._context.gl,e=n.createProgram();return n.attachShader(e,this._vShader),n.attachShader(e,this._fShader),this._locations.forEach(((t,o)=>n.bindAttribLocation(e,t,o))),n.linkProgram(e),i()&&!n.getProgramParameter(e,n.LINK_STATUS)&&console.error("Could not initialize shader\nVALIDATE_STATUS: "+n.getProgramParameter(e,n.VALIDATE_STATUS)+", gl error ["+n.getError()+"]infoLog: "+n.getProgramInfoLog(e)),this._glName=e,this._context.instanceCounter.increment(r.Program,this),e}dispose(){const t=this._context.gl;this._vShader&&(t.deleteShader(this._vShader),this._vShader=null,this._context.instanceCounter.decrement(r.VertexShader,this)),this._fShader&&(t.deleteShader(this._fShader),this._fShader=null,this._context.instanceCounter.decrement(r.FragmentShader,this)),this._glName&&(t.deleteProgram(this._glName),this._glName=null,this._context.instanceCounter.decrement(r.Program,this))}_getUniformLocation(t){return void 0===this._nameToUniformLocation[t]&&(this._nameToUniformLocation[t]=this._context.gl.getUniformLocation(this.glName,t)),this._nameToUniformLocation[t]}hasUniform(t){return null!==this._getUniformLocation(t)}setUniform1i(t,o){const i=this._nameToUniform1[t];if(void 0===i||o!==i){this._context.useProgram(this);this._context.gl.uniform1i(this._getUniformLocation(t),o),this._nameToUniform1[t]=o}}setUniform1iv(t,o){const i=this._nameToUniform1v[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform1iv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform1v[t]=Array.from(o):f(o,i)}}setUniform2iv(t,o){const i=this._nameToUniform2[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform2iv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform2[t]=Array.from(o):f(o,i)}}setUniform3iv(t,o){const i=this._nameToUniform3[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform3iv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform3[t]=Array.from(o):f(o,i)}}setUniform4iv(t,o){const i=this._nameToUniform4[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform4iv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform4[t]=Array.from(o):f(o,i)}}setUniform1f(t,o){const i=this._nameToUniform1[t];if(void 0===i||o!==i){this._context.useProgram(this);this._context.gl.uniform1f(this._getUniformLocation(t),o),this._nameToUniform1[t]=o}}setUniform1fv(t,o){const i=this._nameToUniform1v[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform1fv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform1v[t]=Array.from(o):f(o,i)}}setUniform2f(t,o,i){const r=this._nameToUniform2[t];if(void 0===r||o!==r[0]||i!==r[1]){this._context.useProgram(this);this._context.gl.uniform2f(this._getUniformLocation(t),o,i),void 0===r?this._nameToUniform2[t]=[o,i]:(r[0]=o,r[1]=i)}}setUniform2fv(t,o){const i=this._nameToUniform2[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform2fv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform2[t]=Array.from(o):f(o,i)}}setUniform3f(t,o,i,r){const n=this._nameToUniform3[t];if(void 0===n||o!==n[0]||i!==n[1]||r!==n[2]){this._context.useProgram(this);this._context.gl.uniform3f(this._getUniformLocation(t),o,i,r),void 0===n?this._nameToUniform3[t]=[o,i,r]:(n[0]=o,n[1]=i,n[2]=r)}}setUniform3fv(t,o){const i=this._nameToUniform3[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform3fv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform3[t]=Array.from(o):f(o,i)}}setUniform4f(t,o,i,r,n){const e=this._nameToUniform4[t];if(void 0===e||o!==e[0]||i!==e[1]||r!==e[2]||n!==e[3]){this._context.useProgram(this);this._context.gl.uniform4f(this._getUniformLocation(t),o,i,r,n),void 0===e?this._nameToUniform4[t]=[o,i,r,n]:(e[0]=o,e[1]=i,e[2]=r,e[3]=n)}}setUniform4fv(t,o){const i=this._nameToUniform4[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform4fv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform4[t]=Array.from(o):f(o,i)}}setUniformMatrix3fv(t,o,i=!1,r=!1){const n=this._nameToUniformMatrix3[t];if(r?n!==o:c(n,o)){this._context.useProgram(this);this._context.gl.uniformMatrix3fv(this._getUniformLocation(t),i,o),void 0===n?this._nameToUniformMatrix3[t]=Array.from(o):f(o,n)}}setUniformMatrix4fv(t,o,i=!1){const r=this._nameToUniformMatrix4[t];if(_(r,o)){this._context.useProgram(this);this._context.gl.uniformMatrix4fv(this._getUniformLocation(t),i,o),void 0===r?this._nameToUniformMatrix4[t]=Array.from(o):f(o,r)}}assertCompatibleVertexAttributeLocations(t){t.locations!==this._locations&&console.error("VertexAttributeLocations are incompatible")}stop(){}}function s(t,i){if(o(t)||t.length!==i.length)return!0;for(let o=0;o<t.length;++o)if(t[o]!==i[o])return!0;return!1}function m(t,o,r){const e="webgl2"===t.webglVersion?n(r,o):r,s=t.gl,m=s.createShader(o);return s.shaderSource(m,e),s.compileShader(m),i()&&!s.getShaderParameter(m,s.COMPILE_STATUS)&&(console.error("Compile error in ".concat(35633===o?"vertex":"fragment"," shader")),console.error(s.getShaderInfoLog(m)),console.error(a(e)),"webgl2"===t.webglVersion&&(console.log("Shader source before transpilation:"),console.log(r))),m}function a(t){let o=2;return t.replace(/\n/g,(()=>"\n"+h(o++)+":"))}function h(t){return t>=1e3?t.toString():(" "+t).slice(-3)}function f(t,o){for(let i=0;i<t.length;++i)o[i]=t[i]}function c(t,i){return!!o(t)||(9!==t.length?s(t,i):9!==t.length||t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||t[3]!==i[3]||t[4]!==i[4]||t[5]!==i[5]||t[6]!==i[6]||t[7]!==i[7]||t[8]!==i[8])}function _(t,i){return!!o(t)||(16!==t.length?s(t,i):16!==t.length||t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||t[3]!==i[3]||t[4]!==i[4]||t[5]!==i[5]||t[6]!==i[6]||t[7]!==i[7]||t[8]!==i[8]||t[9]!==i[9]||t[10]!==i[10]||t[11]!==i[11]||t[12]!==i[12]||t[13]!==i[13]||t[14]!==i[14]||t[15]!==i[15])}export{e as Program};
5
+ import"../../core/has.js";import{isSome as t,isNone as o}from"../../core/maybe.js";import{webglValidateShadersEnabled as i}from"./checkWebGLError.js";import{ResourceType as r}from"./enums.js";import{transpileShader as e}from"./ShaderTranspiler.js";class n{constructor(t,o,i,e){this._context=t,this._locations=e,this._nameToUniformLocation={},this._nameToUniform1={},this._nameToUniform1v={},this._nameToUniform2={},this._nameToUniform3={},this._nameToUniform4={},this._nameToUniformMatrix3={},this._nameToUniformMatrix4={},t||console.error("RenderingContext isn't initialized!"),0===o.length&&console.error("Shaders source should not be empty!"),this._vShader=m(this._context,35633,o),this._fShader=m(this._context,35632,i),this._vShader&&this._fShader||console.error("Error loading shaders!"),this._context.instanceCounter.increment(r.VertexShader,this),this._context.instanceCounter.increment(r.FragmentShader,this)}get glName(){if(t(this._glName))return this._glName;if(o(this._vShader))return null;const e=this._context.gl,n=e.createProgram();return e.attachShader(n,this._vShader),e.attachShader(n,this._fShader),this._locations.forEach(((t,o)=>e.bindAttribLocation(n,t,o))),e.linkProgram(n),i()&&!e.getProgramParameter(n,e.LINK_STATUS)&&console.error(`Could not link shader\nvalidated: ${e.getProgramParameter(n,e.VALIDATE_STATUS)}, gl error ${e.getError()}, vertex: ${e.getShaderParameter(this._vShader,e.COMPILE_STATUS)}, fragment: ${e.getShaderParameter(this._fShader,e.COMPILE_STATUS)}, info log: ${e.getProgramInfoLog(n)}`),this._glName=n,this._context.instanceCounter.increment(r.Program,this),n}dispose(){const t=this._context.gl;this._vShader&&(t.deleteShader(this._vShader),this._vShader=null,this._context.instanceCounter.decrement(r.VertexShader,this)),this._fShader&&(t.deleteShader(this._fShader),this._fShader=null,this._context.instanceCounter.decrement(r.FragmentShader,this)),this._glName&&(t.deleteProgram(this._glName),this._glName=null,this._context.instanceCounter.decrement(r.Program,this))}_getUniformLocation(t){return void 0===this._nameToUniformLocation[t]&&(this._nameToUniformLocation[t]=this._context.gl.getUniformLocation(this.glName,t)),this._nameToUniformLocation[t]}hasUniform(t){return null!==this._getUniformLocation(t)}setUniform1i(t,o){const i=this._nameToUniform1[t];if(void 0===i||o!==i){this._context.useProgram(this);this._context.gl.uniform1i(this._getUniformLocation(t),o),this._nameToUniform1[t]=o}}setUniform1iv(t,o){const i=this._nameToUniform1v[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform1iv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform1v[t]=Array.from(o):f(o,i)}}setUniform2iv(t,o){const i=this._nameToUniform2[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform2iv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform2[t]=Array.from(o):f(o,i)}}setUniform3iv(t,o){const i=this._nameToUniform3[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform3iv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform3[t]=Array.from(o):f(o,i)}}setUniform4iv(t,o){const i=this._nameToUniform4[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform4iv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform4[t]=Array.from(o):f(o,i)}}setUniform1f(t,o){const i=this._nameToUniform1[t];if(void 0===i||o!==i){this._context.useProgram(this);this._context.gl.uniform1f(this._getUniformLocation(t),o),this._nameToUniform1[t]=o}}setUniform1fv(t,o){const i=this._nameToUniform1v[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform1fv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform1v[t]=Array.from(o):f(o,i)}}setUniform2f(t,o,i){const r=this._nameToUniform2[t];if(void 0===r||o!==r[0]||i!==r[1]){this._context.useProgram(this);this._context.gl.uniform2f(this._getUniformLocation(t),o,i),void 0===r?this._nameToUniform2[t]=[o,i]:(r[0]=o,r[1]=i)}}setUniform2fv(t,o){const i=this._nameToUniform2[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform2fv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform2[t]=Array.from(o):f(o,i)}}setUniform3f(t,o,i,r){const e=this._nameToUniform3[t];if(void 0===e||o!==e[0]||i!==e[1]||r!==e[2]){this._context.useProgram(this);this._context.gl.uniform3f(this._getUniformLocation(t),o,i,r),void 0===e?this._nameToUniform3[t]=[o,i,r]:(e[0]=o,e[1]=i,e[2]=r)}}setUniform3fv(t,o){const i=this._nameToUniform3[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform3fv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform3[t]=Array.from(o):f(o,i)}}setUniform4f(t,o,i,r,e){const n=this._nameToUniform4[t];if(void 0===n||o!==n[0]||i!==n[1]||r!==n[2]||e!==n[3]){this._context.useProgram(this);this._context.gl.uniform4f(this._getUniformLocation(t),o,i,r,e),void 0===n?this._nameToUniform4[t]=[o,i,r,e]:(n[0]=o,n[1]=i,n[2]=r,n[3]=e)}}setUniform4fv(t,o){const i=this._nameToUniform4[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform4fv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform4[t]=Array.from(o):f(o,i)}}setUniformMatrix3fv(t,o,i=!1,r=!1){const e=this._nameToUniformMatrix3[t];if(r?e!==o:c(e,o)){this._context.useProgram(this);this._context.gl.uniformMatrix3fv(this._getUniformLocation(t),i,o),void 0===e?this._nameToUniformMatrix3[t]=Array.from(o):f(o,e)}}setUniformMatrix4fv(t,o,i=!1){const r=this._nameToUniformMatrix4[t];if(_(r,o)){this._context.useProgram(this);this._context.gl.uniformMatrix4fv(this._getUniformLocation(t),i,o),void 0===r?this._nameToUniformMatrix4[t]=Array.from(o):f(o,r)}}assertCompatibleVertexAttributeLocations(t){t.locations!==this._locations&&console.error("VertexAttributeLocations are incompatible")}stop(){}}function s(t,i){if(o(t)||t.length!==i.length)return!0;for(let o=0;o<t.length;++o)if(t[o]!==i[o])return!0;return!1}function m(t,o,r){const n="webgl2"===t.webglVersion?e(r,o):r,s=t.gl,m=s.createShader(o);return s.shaderSource(m,n),s.compileShader(m),i()&&!s.getShaderParameter(m,s.COMPILE_STATUS)&&(console.error("Compile error in ".concat(35633===o?"vertex":"fragment"," shader")),console.error(s.getShaderInfoLog(m)),console.error(a(n)),"webgl2"===t.webglVersion&&(console.log("Shader source before transpilation:"),console.log(r))),m}function a(t){let o=2;return t.replace(/\n/g,(()=>"\n"+h(o++)+":"))}function h(t){return t>=1e3?t.toString():(" "+t).slice(-3)}function f(t,o){for(let i=0;i<t.length;++i)o[i]=t[i]}function c(t,i){return!!o(t)||(9!==t.length?s(t,i):9!==t.length||t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||t[3]!==i[3]||t[4]!==i[4]||t[5]!==i[5]||t[6]!==i[6]||t[7]!==i[7]||t[8]!==i[8])}function _(t,i){return!!o(t)||(16!==t.length?s(t,i):16!==t.length||t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||t[3]!==i[3]||t[4]!==i[4]||t[5]!==i[5]||t[6]!==i[6]||t[7]!==i[7]||t[8]!==i[8]||t[9]!==i[9]||t[10]!==i[10]||t[11]!==i[11]||t[12]!==i[12]||t[13]!==i[13]||t[14]!==i[14]||t[15]!==i[15])}export{n as Program};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/maybe.js";import{aliasOf as i}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{R as a}from"../chunks/ResizeObserver.js";import n from"./Widget.js";import o from"./Histogram/HistogramViewModel.js";import"./support/widgetUtils.js";import{messageBundle as l}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{tsx as d}from"./support/jsxFactory.js";import{substitute as h}from"../intl/substitute.js";var u;const c={base:"esri-histogram",horizontalLayout:"esri-histogram--horizontal",verticalLayout:"esri-histogram--vertical",content:"esri-histogram__content",svg:"esri-histogram__svg",bar:"esri-histogram__bar",bars:"esri-histogram__bars",label:"esri-histogram__label",dataLines:"esri-histogram__data-lines",dataLinesSubgroup:"esri-histogram__data-lines-subgroup",dataLine:"esri-histogram__data-line",averageLabel:"esri-histogram__average-label",averageDataLine:"esri-histogram__average-data-line",averageSymbol:"esri-histogram__average-symbol",esriWidget:"esri-widget",widgetIcon:"esri-icon-edit",disabled:"esri-disabled"};let g=u=class extends n{constructor(e,t){super(e,t),this._bgFillId=null,this._containerNode=null,this._containerOffsetHeight=0,this._containerOffsetWidth=0,this._defaultBarColor="#d8d8d8",this._observer=null,this.average=null,this.barCreatedFunction=null,this.bins=null,this.dataLines=null,this.dataLineCreatedFunction=null,this.dataLineUpdatedFunction=null,this.label=void 0,this.labelFormatFunction=null,this.max=null,this.messages=null,this.min=null,this.state=null,this.viewModel=new o,this._observer=new a((()=>this._storeContainerDimensions())),this._bgFillId=`${this.id}-bg-fill`}destroy(){this._containerNode&&this._observer.unobserve(this._containerNode)}set layout(e){"vertical"!==e&&(e="horizontal"),this._set("layout",e)}static fromHistogramResult(e){const{bins:t,maxValue:i,minValue:s}=e;return new u({bins:t,max:i,min:s})}render(){const{label:e,layout:t,state:i}=this,s=this.classes(c.base,c.esriWidget,"horizontal"===t?c.horizontalLayout:c.verticalLayout,"disabled"===i?c.disabled:null);return d("div",{"aria-label":e,afterCreate:this._afterContainerNodeCreate,bind:this,class:s,"data-node-ref":"_containerNode"},"ready"===i?this.renderContent():null)}renderContent(){if(!this._containerNode)return;const e=this._bgFillId,t=`clip-path: url(#${e})`;return d("div",{class:c.content},d("svg",{class:c.svg,xmlns:"http://www.w3.org/2000/svg"},d("defs",null,this.renderFillDefinition(e)),d("g",{style:t},this.renderBarsGroup()),this.renderLinesGroup()))}renderBarsGroup(){return d("g",{class:this.classes(c.bars)},this.renderBars())}renderBars(){const{layout:e,viewModel:{binRange:t,range:i}}=this;if(!t||!i)return;const s=t/i,[r,a]=this._getContainerDimensions();if(0===r&&0===a)return;if(0===r&&0!==a)return void this.scheduleRender();const[n,o]="vertical"===e?[r*s,a]:[r,a*s];return this._getBarDimensions(n,o).map((([e,t],i)=>this.renderBar(i,e,t)))}renderBar(e,t,i){const{bins:s,layout:r,max:a,messages:n,viewModel:{range:o}}=this,[l,u]=this._getContainerDimensions(),g=s.slice()[e],{count:p,maxValue:m,minValue:b}=g,_=a-m,[v,f]="vertical"===r?[0,_*(l/o)]:[u-i-_*(u/o),l-t],L=h(n.barLabel,{count:p,maxValue:m,minValue:b});return d("rect",{"aria-label":L,afterCreate:this._afterBarCreate,bind:this,class:c.bar,"data-index":e,fill:this._defaultBarColor,height:t,role:"img","shape-rendering":"crispEdges","stroke-width":"0",width:i,x:v,y:f})}renderLinesGroup(){return d("g",{class:this.classes(c.dataLines)},this.renderAverageLine(),this.renderCustomLines())}renderAverageLine(){const{average:e}=this;if(!t(e))return;const i=[d("tspan",{class:this.classes(c.averageSymbol)},"x̄ "),d("tspan",{class:this.classes(c.averageLabel)},this.labelFormatFunction?this.labelFormatFunction(e,"average"):e)];return d("g",{afterCreate:this._afterLinesSubgroupCreate,afterUpdate:this._afterLinesSubgroupUpdate,bind:this,class:this.classes(c.dataLinesSubgroup)},d("title",{key:"title"},e),this.renderLine(e,this.classes(c.averageDataLine)),this.renderLabel(e,i))}renderCustomLines(){if(this.dataLines&&this.dataLines.length)return this.dataLines.map((({value:e,label:t},i)=>this.renderLineSubgroup(i,e,t)))}renderLineSubgroup(e,t,i){return d("g",{afterCreate:this._afterLinesSubgroupCreate,afterUpdate:this._afterLinesSubgroupUpdate,bind:this,class:this.classes(c.dataLinesSubgroup),"data-index":e},d("title",{key:"title"},t),this.renderLine(t),this.renderLabel(t,i))}renderLine(e,t){const[i,s,r,a]=this._getLinePosition(e);return d("line",{class:this.classes(c.dataLine,t),x1:i,x2:s,y1:r,y2:a,"shape-rendering":"crispEdges"})}renderLabel(e,t,i){const[s,r]=this._getLabelPosition(e),a=2;return d("text",{class:this.classes(c.label,i),"text-anchor":"end",transform:"horizontal"===this.layout?"rotate(270)":null,x:s,y:r-a},t)}renderFillDefinition(e){const[t,i]=this._getContainerDimensions();return d("clipPath",{id:e},d("rect",{x:"0",y:"0",width:i,height:t}))}_afterContainerNodeCreate(e){this._containerNode&&this._observer.unobserve(this._containerNode),this._containerNode=e,this._observer.observe(this._containerNode),this._storeContainerDimensions()}_afterBarCreate(e){if(this.barCreatedFunction){const t=e.dataset?parseInt(e.dataset.index,10):e.getAttribute("data-index")?parseInt(e.getAttribute("data-index"),10):null;this.barCreatedFunction(isNaN(t)?null:t,e)}}_afterLinesSubgroupCreate(e){if(this.dataLineCreatedFunction){const t=e.dataset?parseInt(e.dataset.index,10):e.getAttribute("data-index")?parseInt(e.getAttribute("data-index"),10):null,i=e.childNodes[0],s=e.childNodes[1]?e.childNodes[1]:null;this.dataLineCreatedFunction(i,s,isNaN(t)?null:t)}}_afterLinesSubgroupUpdate(e){if(this.dataLineUpdatedFunction){const t=e.dataset?parseInt(e.dataset.index,10):e.getAttribute("data-index")?parseInt(e.getAttribute("data-index"),10):null,i=e.childNodes[0],s=e.childNodes[1]?e.childNodes[1]:null;this.dataLineUpdatedFunction(i,s,isNaN(t)?null:t)}}_storeContainerDimensions(){const{_containerNode:e}=this;e&&(this._containerOffsetHeight=e.offsetHeight,this._containerOffsetWidth=e.offsetWidth)}_getContainerDimensions(){return[this._containerOffsetHeight,this._containerOffsetWidth]}_getBarDimensions(e,t){const{bins:i,layout:s}=this,r=i?i.map((e=>e.count)):[],a=Math.max.apply(Math,r);return r.map((i=>"vertical"===s?[e/r.length,0!==a?i/a*t:0]:[0!==a?i/a*e:0,t/r.length]))}_getLinePosition(e){const{layout:t,min:i,viewModel:{range:s}}=this,r=Math.round((e-i)/s*100)/100,[a,n]=this._getContainerDimensions(),[o,l]=[r*n||1,a-r*a||1];return"vertical"===t?[0,"100%",l,l]:[o,o,"100%",0]}_getLabelPosition(e){const{layout:t,min:i,viewModel:{range:s}}=this,r=Math.round((e-i)/s*100)/100,[a,n]=this._getContainerDimensions();return"vertical"===t?[n,a-r*a]:[0,r*n]}};e([s()],g.prototype,"_containerOffsetHeight",void 0),e([s()],g.prototype,"_containerOffsetWidth",void 0),e([i("viewModel.average")],g.prototype,"average",void 0),e([s()],g.prototype,"barCreatedFunction",void 0),e([i("viewModel.bins")],g.prototype,"bins",void 0),e([s()],g.prototype,"dataLines",void 0),e([s()],g.prototype,"dataLineCreatedFunction",void 0),e([s()],g.prototype,"dataLineUpdatedFunction",void 0),e([s({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],g.prototype,"label",void 0),e([i("viewModel.labelFormatFunction")],g.prototype,"labelFormatFunction",void 0),e([s({value:"horizontal"})],g.prototype,"layout",null),e([i("viewModel.max")],g.prototype,"max",void 0),e([s(),l("esri/widgets/Histogram/t9n/Histogram")],g.prototype,"messages",void 0),e([i("viewModel.min")],g.prototype,"min",void 0),e([i("viewModel.state")],g.prototype,"state",void 0),e([s()],g.prototype,"viewModel",void 0),g=u=e([r("esri.widgets.Histogram")],g);const p=g;export{p as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/maybe.js";import{aliasOf as i}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{R as a}from"../chunks/ResizeObserver.js";import n from"./Widget.js";import o from"./Histogram/HistogramViewModel.js";import"./support/widgetUtils.js";import{messageBundle as l}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{tsx as d}from"./support/jsxFactory.js";import{substitute as h}from"../intl/substitute.js";var u;const c={base:"esri-histogram",horizontalLayout:"esri-histogram--horizontal",verticalLayout:"esri-histogram--vertical",content:"esri-histogram__content",svg:"esri-histogram__svg",bar:"esri-histogram__bar",bars:"esri-histogram__bars",label:"esri-histogram__label",dataLines:"esri-histogram__data-lines",dataLinesSubgroup:"esri-histogram__data-lines-subgroup",dataLine:"esri-histogram__data-line",averageLabel:"esri-histogram__average-label",averageDataLine:"esri-histogram__average-data-line",averageSymbol:"esri-histogram__average-symbol",esriWidget:"esri-widget",widgetIcon:"esri-icon-edit",disabled:"esri-disabled"};let g=u=class extends n{constructor(e,t){super(e,t),this._bgFillId=null,this._containerNode=null,this._containerOffsetHeight=0,this._containerOffsetWidth=0,this._defaultBarColor="#d8d8d8",this._observer=null,this.average=null,this.barCreatedFunction=null,this.bins=null,this.dataLines=null,this.dataLineCreatedFunction=null,this.dataLineUpdatedFunction=null,this.label=void 0,this.labelFormatFunction=null,this.max=null,this.messages=null,this.min=null,this.state=null,this.viewModel=new o,this._observer=new a((()=>{this._storeContainerDimensions(),this.scheduleRender()})),this._bgFillId=`${this.id}-bg-fill`}destroy(){this._containerNode&&this._observer.unobserve(this._containerNode)}set layout(e){"vertical"!==e&&(e="horizontal"),this._set("layout",e)}static fromHistogramResult(e){const{bins:t,maxValue:i,minValue:s}=e;return new u({bins:t,max:i,min:s})}render(){const{label:e,layout:t,state:i}=this,s=this.classes(c.base,c.esriWidget,"horizontal"===t?c.horizontalLayout:c.verticalLayout,"disabled"===i?c.disabled:null);return d("div",{"aria-label":e,afterCreate:this._afterContainerNodeCreate,bind:this,class:s,"data-node-ref":"_containerNode"},"ready"===i?this.renderContent():null)}renderContent(){if(!this._containerNode)return;const e=this._bgFillId,t=`clip-path: url(#${e})`;return d("div",{class:c.content},d("svg",{class:c.svg,xmlns:"http://www.w3.org/2000/svg"},d("defs",null,this.renderFillDefinition(e)),d("g",{style:t},this.renderBarsGroup()),this.renderLinesGroup()))}renderBarsGroup(){return d("g",{class:this.classes(c.bars)},this.renderBars())}renderBars(){const{layout:e,viewModel:{binRange:t,range:i}}=this;if(!t||!i)return;const s=t/i,[r,a]=this._getContainerDimensions();if(0===r&&0===a)return;if(0===r&&0!==a)return void this.scheduleRender();const[n,o]="vertical"===e?[r*s,a]:[r,a*s];return this._getBarDimensions(n,o).map((([e,t],i)=>this.renderBar(i,e,t)))}renderBar(e,t,i){const{bins:s,layout:r,max:a,messages:n,viewModel:{range:o}}=this,[l,u]=this._getContainerDimensions(),g=s.slice()[e],{count:p,maxValue:m,minValue:b}=g,_=a-m,[v,f]="vertical"===r?[0,_*(l/o)]:[u-i-_*(u/o),l-t],L=h(n.barLabel,{count:p,maxValue:m,minValue:b});return d("rect",{"aria-label":L,afterCreate:this._afterBarCreate,bind:this,class:c.bar,"data-index":e,fill:this._defaultBarColor,height:t,role:"img","shape-rendering":"crispEdges","stroke-width":"0",width:i,x:v,y:f})}renderLinesGroup(){return d("g",{class:this.classes(c.dataLines)},this.renderAverageLine(),this.renderCustomLines())}renderAverageLine(){const{average:e}=this;if(!t(e))return;const i=[d("tspan",{class:this.classes(c.averageSymbol)},"x̄ "),d("tspan",{class:this.classes(c.averageLabel)},this.labelFormatFunction?this.labelFormatFunction(e,"average"):e)];return d("g",{afterCreate:this._afterLinesSubgroupCreate,afterUpdate:this._afterLinesSubgroupUpdate,bind:this,class:this.classes(c.dataLinesSubgroup)},d("title",{key:"title"},e),this.renderLine(e,this.classes(c.averageDataLine)),this.renderLabel(e,i))}renderCustomLines(){if(this.dataLines&&this.dataLines.length)return this.dataLines.map((({value:e,label:t},i)=>this.renderLineSubgroup(i,e,t)))}renderLineSubgroup(e,t,i){return d("g",{afterCreate:this._afterLinesSubgroupCreate,afterUpdate:this._afterLinesSubgroupUpdate,bind:this,class:this.classes(c.dataLinesSubgroup),"data-index":e},d("title",{key:"title"},t),this.renderLine(t),this.renderLabel(t,i))}renderLine(e,t){const[i,s,r,a]=this._getLinePosition(e);return d("line",{class:this.classes(c.dataLine,t),x1:i,x2:s,y1:r,y2:a,"shape-rendering":"crispEdges"})}renderLabel(e,t,i){const[s,r]=this._getLabelPosition(e),a=2;return d("text",{class:this.classes(c.label,i),"text-anchor":"end",transform:"horizontal"===this.layout?"rotate(270)":null,x:s,y:r-a},t)}renderFillDefinition(e){const[t,i]=this._getContainerDimensions();return d("clipPath",{id:e},d("rect",{x:"0",y:"0",width:i,height:t}))}_afterContainerNodeCreate(e){this._containerNode&&this._observer.unobserve(this._containerNode),this._containerNode=e,this._observer.observe(this._containerNode),this._storeContainerDimensions()}_afterBarCreate(e){if(this.barCreatedFunction){const t=e.dataset?parseInt(e.dataset.index,10):e.getAttribute("data-index")?parseInt(e.getAttribute("data-index"),10):null;this.barCreatedFunction(isNaN(t)?null:t,e)}}_afterLinesSubgroupCreate(e){if(this.dataLineCreatedFunction){const t=e.dataset?parseInt(e.dataset.index,10):e.getAttribute("data-index")?parseInt(e.getAttribute("data-index"),10):null,i=e.childNodes[0],s=e.childNodes[1]?e.childNodes[1]:null;this.dataLineCreatedFunction(i,s,isNaN(t)?null:t)}}_afterLinesSubgroupUpdate(e){if(this.dataLineUpdatedFunction){const t=e.dataset?parseInt(e.dataset.index,10):e.getAttribute("data-index")?parseInt(e.getAttribute("data-index"),10):null,i=e.childNodes[0],s=e.childNodes[1]?e.childNodes[1]:null;this.dataLineUpdatedFunction(i,s,isNaN(t)?null:t)}}_storeContainerDimensions(){const{_containerNode:e}=this;e&&(this._containerOffsetHeight=e.offsetHeight,this._containerOffsetWidth=e.offsetWidth)}_getContainerDimensions(){return[this._containerOffsetHeight,this._containerOffsetWidth]}_getBarDimensions(e,t){const{bins:i,layout:s}=this,r=i?i.map((e=>e.count)):[],a=Math.max.apply(Math,r);return r.map((i=>"vertical"===s?[e/r.length,0!==a?i/a*t:0]:[0!==a?i/a*e:0,t/r.length]))}_getLinePosition(e){const{layout:t,min:i,viewModel:{range:s}}=this,r=Math.round((e-i)/s*100)/100,[a,n]=this._getContainerDimensions(),[o,l]=[r*n||1,a-r*a||1];return"vertical"===t?[0,"100%",l,l]:[o,o,"100%",0]}_getLabelPosition(e){const{layout:t,min:i,viewModel:{range:s}}=this,r=Math.round((e-i)/s*100)/100,[a,n]=this._getContainerDimensions();return"vertical"===t?[n,a-r*a]:[0,r*n]}};e([s()],g.prototype,"_containerOffsetHeight",void 0),e([s()],g.prototype,"_containerOffsetWidth",void 0),e([i("viewModel.average")],g.prototype,"average",void 0),e([s()],g.prototype,"barCreatedFunction",void 0),e([i("viewModel.bins")],g.prototype,"bins",void 0),e([s()],g.prototype,"dataLines",void 0),e([s()],g.prototype,"dataLineCreatedFunction",void 0),e([s()],g.prototype,"dataLineUpdatedFunction",void 0),e([s({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],g.prototype,"label",void 0),e([i("viewModel.labelFormatFunction")],g.prototype,"labelFormatFunction",void 0),e([s({value:"horizontal"})],g.prototype,"layout",null),e([i("viewModel.max")],g.prototype,"max",void 0),e([s(),l("esri/widgets/Histogram/t9n/Histogram")],g.prototype,"messages",void 0),e([i("viewModel.min")],g.prototype,"min",void 0),e([i("viewModel.state")],g.prototype,"state",void 0),e([s()],g.prototype,"viewModel",void 0),g=u=e([r("esri.widgets.Histogram")],g);const p=g;export{p 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.22/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import{addTokenParameter as l}from"../../../kernel.js";import s from"../../../request.js";import"../../../symbols.js";import r from"../../../core/Accessor.js";import i from"../../../core/Collection.js";import n from"../../../core/Handles.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{unwrap as u,isSome as c}from"../../../core/maybe.js";import{eachAlways as d,debounce as y}from"../../../core/promiseUtils.js";import{px2pt as h}from"../../../core/screenUtils.js";import{addQueryParameters as m}from"../../../core/urlUtils.js";import{on as p,init as f,whenFalseOnce as g,watch as b}from"../../../core/watchUtils.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import v from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as w}from"../../../layers/effects/jsonUtils.js";import{ExportImageParameters as L}from"../../../layers/support/ExportImageParameters.js";import{isDateField as E}from"../../../layers/support/fieldUtils.js";import{fromJSON as I}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as C}from"../../../renderers/support/rendererConversion.js";import F from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{applyCIMSymbolColor as R}from"../../../symbols/support/cimSymbolUtils.js";import{renderSymbol as V}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as T,renderDotDensityPreviewHTML as z,renderPreviewHTML as x}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as j}from"../../../symbols/support/utils.js";import{getClusterSizeVariable as O}from"./clusterUtils.js";import{getColorFromPointCloudStops as M,getRampStopsForPointCloud as D,getStrectchRampStops as P,getRampStops as A}from"./colorRampUtils.js";import{getHeatmapRampStops as U}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as B,getRelationshipRampElement as k}from"./relationshipRampUtils.js";import{getRampStops as N,REAL_WORLD_MAX_SIZE as q,REAL_WORLD_MIN_SIZE as W}from"./sizeRampUtils.js";import{SPECIAL_CHARS_LESS_THAN as $,SPECIAL_CHARS_GREATER_THAN as G,RGB_IMG_SOURCE as J}from"./utils.js";import{formatNumberLabel as Q}from"../../smartMapping/support/utils.js";import H from"../../../symbols/SimpleMarkerSymbol.js";import X from"../../../symbols/SimpleFillSymbol.js";const K=o.getLogger("esri.widgets.Legend.support.ActiveLayerInfo"),Y="https://utility.arcgis.com/sharing/tools/legend",Z="esri.layers.ImageryLayer",ee="esri.layers.ImageryTileLayer",te="esri.layers.WCSLayer",le=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,se=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),re={u1:[0,1],u2:[0,3],u4:[0,15],u8:[0,255],s8:[-128,127],u16:[0,65535],s16:[-32768,32767],u32:[0,4294967295],s32:[-2147483648,2147483647],f32:[-34e38,34e38],f64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ie=new H({size:6,outline:{color:[128,128,128,.5],width:.5}}),ne=new X({style:"solid"});function ae(e){return"vector-field"===e.type}function oe(e){return"raster-colormap"===e.type}function ue(e){return"raster-stretch"===e.type}function ce(e){return"raster-shaded-relief"===e.type}function de(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function ye(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function he(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function me(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function pe(e){return ge(e)||be(e)||Se(e)||fe(e)}function fe(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function ge(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function be(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function Se(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function _e(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function ve(e,t){return de(e)||ye(e)||he(e)||me(e)||_e(e)?"2d"===t.type||C(e):ue(e)||oe(e)||ce(e)||ge(e)||be(e)||Se(e)||ae(e)}function we(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Le(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Ee(e){return"esri.layers.WMSLayer"===e.declaredClass}function Ie(e){return"esri.layers.WMTSLayer"===e.declaredClass}function Ce(e){return"esri.layers.MapImageLayer"===e.declaredClass}function Fe(e){return"esri.layers.TileLayer"===e.declaredClass}function Re(e){return"esri.layers.FeatureLayer"===e.declaredClass}function Ve(e){return e.declaredClass===Z}function Te(e){return e.declaredClass===ee}function ze(e){return e.declaredClass===te}function xe(e){return"stretch-ramp"===e.type}function je(e){const t="authoringInfo"in e&&(null==e?void 0:e.authoringInfo);return"univariate-color-size"===(null==t?void 0:t.type)}function Oe(e){const t="authoringInfo"in e&&(null==e?void 0:e.authoringInfo);return"univariate-color-size"===(null==t?void 0:t.type)&&"above-and-below"===(null==t?void 0:t.univariateTheme)}const Me=new H({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let De={},Pe=class extends r{constructor(e){super(e),this._handles=new n,this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._hasClusterSizeVariable=!1,this.children=new i,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this._handles.add([p(this,"children","change",(t=>{const{added:l,removed:s}=t,r=this._handles;l.forEach((t=>{const l=`activeLayerInfo-ready-watcher-${t.layer.uid}`;r.add(f(t,"ready",e),l)})),s.forEach((e=>r.remove(e.layer.uid))),e()}))]),this.keepCacheOnDestroy||(De={})}destroy(){this._handles.destroy(),this._handles=null,this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(De=null)}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new v,t.effect=e.effect,t.end(),t.scale=this.scale),t}get opacity(){var e;const t=this.layer.opacity,l=null==(e=this.parent)?void 0:e.opacity,s=this.layer.parent,r=s&&"uid"in s?this._getParentLayerOpacity(s):null;return null!=l?l*t:null!=r?r*t:t}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view&&this.view.scale}get isScaleDriven(){const e=this.layer;if(null===e)return!1;if("effect"in e&&e.effect&&Array.isArray(e.effect))return!0;if("featureReduction"in e&&e.featureReduction&&"cluster"===e.featureReduction.type)return!0;if("renderer"in e&&e.renderer){if("dot-density"===e.renderer.type)return!0;const t=e.get("renderer.valueExpression");if(le.test(t))return!0;const l=e.get("renderer.visualVariables");if(l)return l.some((e=>this._isScaleDrivenSizeVariable(e)))}return this._isLayerScaleDriven(this.layer)}get version(){return this._get("version")+1}async buildLegendElementsForFeatureCollections(e){if(!(!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView()))return this.legendElements=[],void this.notifyChange("ready");const t=Array.from(e,(e=>{if(Re(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet&&e.featureSet.features.length){const t=e.layerDefinition,l=t&&t.drawingInfo,s=l&&I(l.renderer),r=se.read(t.geometryType);return s?this._getRendererLegendElements(s,{title:e.name,geometryType:r}):(K.warn("drawingInfo not available!"),null)}return null}));try{const e=[];await d(t).then((t=>{t.forEach((({value:t})=>t&&e.push(...t)))})),this.legendElements=e,this.notifyChange("ready")}catch(l){K.warn("error while building legend for layer!",l)}}async buildLegendElementsForRenderer(e){try{const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getRendererLegendElements(e):[],this.notifyChange("ready")}catch(t){K.warn("error while building legend for layer!",t)}}async buildLegendElementsForTools(){const e=this.layer;if(Le(e))this._constructLegendElementsForVoxellayer();else if(Ie(e))this._constructLegendElementsForWMTSlayer();else if(Ee(e))await this._constructLegendElementsForWMSSublayers();else if(we(e))await this._constructLegendElementsForBuildingSceneLayer();else if(Ce(e)||Fe(e)||we(e))await this._constructLegendElementsForSublayers();else{this._handles.remove("imageryLayers-watcher");let s="default";if(Ve(e)){var t,l;const r=e;s=((null==r||null==(t=r.renderingRule)?void 0:t.functionName)||"default")+"_"+(null!=(l=e.bandIds)&&l.length?e.bandIds.join(""):"###")}await this._getLegendLayers(`${e.uid}-${s}`).then((async t=>{this.legendElements=[],this.notifyChange("ready");const l=t.map((async t=>{if(Ve(e)||Te(e)){const t=e.watch(["renderingRule","bandIds"],(()=>y((async()=>{De.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()}))()));this._handles.add(t,"imageryLayers-watcher")}const l=this._generateSymbolTableElementForLegendLayer(t);l&&l.infos.length&&(Ve(e)&&(l.title=e.title),this.legendElements.push(l)),this.notifyChange("ready")}));await d(l)})).catch((e=>{K.warn("Request to server for legend has failed!",e)}))}}async _isLayerInCurrentView(){const e=this.layer,t=this.layerView,l=t&&"createQuery"in t&&"queryFeatureCount"in t;if(!l&&!(t&&"createQuery"in e&&"queryFeatureCount"in e))return!0;await g(t,"updating");const s=l?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();s.geometry=this.view.extent;return 0!==(l?"queryFeatureCount"in t&&await t.queryFeatureCount(s):"queryFeatureCount"in e&&await e.queryFeatureCount(s))}_getParentLayerOpacity(e){let t=1;const l=e.parent;return l&&"uid"in l&&(t=this._getParentLayerOpacity(l)),e.opacity*t}_isGroupActive(){const e=this.children;return!!e.length&&e.some((e=>e.ready))}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,l=t.minSize,s=t.maxSize;return"object"==typeof l&&l?this._isScaleDrivenSizeVariable(l):"object"==typeof s&&s?this._isScaleDrivenSizeVariable(s):!!t.expression||le.test(t.valueExpression)}_isLayerScaleDriven(e){if("minScale"in e&&e.minScale>0||"maxScale"in e&&e.maxScale>0)return!0;if("sublayers"in e&&e.sublayers)return e.sublayers.some((e=>this._isLayerScaleDriven(e)));const t=e.parent;if(!1===e.loaded&&t&&Ce(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const l of t.sourceJSON.layers)if(l.id===e.source.mapLayerId&&(l.minScale>0||l.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxellayer(){this.legendElements=[],this._handles.remove("voxel-style-watcher");const e=this.layer;this._handles.add(b(e,"style",(()=>this._constructLegendElementsForVoxellayer())),"voxel-style-watcher");const t=u(e.getVariableStyle(null)),l=[];var s;if(t)if(null!=(s=t.uniqueValues)&&s.length){const e=[];t.uniqueValues.forEach((t=>{t.enabled&&e.push({label:t.label||`${t.value}`,value:t.value,symbol:new X({color:t.color,outline:null})})})),e.length&&l.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:s}=t.transferFunction,r=e.toArray().reverse(),i=s.map(((e,t)=>`${0===t?$:G} ${Q(e)}`)).reverse(),n=r.map((e=>({color:e.color,value:null,label:null})));n[0].label=i[0],n[n.length-1].label=i[1],l.push({type:"color-ramp",title:t.label,infos:n,preview:T(r.map((e=>e.color)))})}const r=e.opacity,i=l.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!(null==e||!e.symbol))).map((e=>this._getSymbolPreview(e,r)));await d(i),this.legendElements=l,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this._handles.remove("wmts-activeLayer-watcher");const e=this.layer.activeLayer;if(this._handles.add(b(this.layer,"activeLayer",(()=>this._constructLegendElementsForWMTSlayer())),"wmts-activeLayer-watcher"),e.styleId&&e.styles){let t=null;e.styles.some((l=>e.styleId===l.id&&(t=l.legendUrl,!0))),t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}])}this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this.legendElements=[],this._handles.remove("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this._handles.add(b(this.layer,"sublayers",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher"),this.legendElements=await this._generateLegendElementsForWMSSublayers(e.sublayers,t),this.notifyChange("ready")}async _generateLegendElementsForWMSSublayers(e,t){const l=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher");const s=e.toArray();for(const r of s){const e=r.watch(["title","visible","legendEnabled"],(()=>this._constructLegendElementsForWMSSublayers()));if(this._handles.add(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e&&e.infos.length&&l.unshift(e)}}return l}async _generateSymbolTableElementForWMSSublayer(e,t){if(!e.legendUrl&&e.sublayers){const l=(await this._generateLegendElementsForWMSSublayers(e.sublayers,t)).filter((e=>e));return{type:"symbol-table",title:e.title,infos:l}}return this._generateSymbolTableElementForLegendUrl(e,t)}async _generateSymbolTableElementForLegendUrl(e,t){var l;let r=e.legendUrl;if(!r)return;const i={type:"symbol-table",title:e.title||e.name||e.id&&e.id+"",infos:[]};t&&(r=m(r,t));let n=null;const a=null==(l=e.layer)?void 0:l.opacity;try{n=(await s(r,{responseType:"image"})).data,n&&(n.style.opacity=a)}catch{}return i.infos.push({src:r,preview:n,opacity:a}),i}_getLegendLayers(e,t){const l=De&&De[e];return l?Promise.resolve(l):this._legendRequest(t).then((t=>{const l=t.layers;return De[e]=l,l}))}_legendRequest(e){const t=this.layer;let l={f:"json",dynamicLayers:e};if(Ve(t)){const e=t.exportImageServiceParameters.renderingRule;if(e&&(l.renderingRule=JSON.stringify(e.toJSON())),t.bandIds&&(l.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:s,customParameters:r}=t;l={raster:e,viewId:s,...l,...r}}}let r=t.url.replace(/(\/)+$/,"");if("version"in t&&t.version>=10.01){const e=r.indexOf("?");e>-1?r=r.substring(0,e)+"/legend"+r.substring(e):r+="/legend"}else{const e=r.toLowerCase().indexOf("/rest/"),t=r.substring(0,e)+r.substring(e+5,r.length);r=Y+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return s(r,{query:l}).then((e=>e.data))}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this._handles.remove("sublayers-watcher");const e=this.layer;this._handles.add(b(e,"sublayers",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){K.warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForBuildingSublayers(e,t){let l=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");const s=e.toArray();for(const r of s){const e=r.watch(["renderer","opacity","title","visible"],(()=>this._constructLegendElementsForBuildingSceneLayer()));if(this._handles.add(e,"sublayers-watcher"),!this.respectLayerVisibility||r.visible){const e=r&&null!=r.opacity?r.opacity:null,s=null!=e?e*t:t;if("building-group"===r.type){const e={type:"symbol-table",title:r.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(r.sublayers,s);e.infos.push(...t),l=[e,...l]}else if(r.renderer){l=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:s,sublayer:r}),...l]}}}return l.filter((e=>!!e&&(!("infos"in e)||e.infos.length>0)))}async _constructLegendElementsForSublayers(){this.legendElements=[],this._handles.remove("sublayers-watcher");const e=this.layer;this._handles.add(b(e,"sublayers",(()=>this._constructLegendElementsForSublayers)),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){K.warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForSublayers(e,t,l){const s=this.layer;let r=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForSublayers())),"sublayers-watcher");let i=e.toArray();!l&&this.sublayerIds&&this.sublayerIds.length&&(i=this.sublayerIds.map((e=>s.findSublayerById(e))).filter(Boolean));for(const n of i){const e=n.watch("renderer, opacity, title, visible, legendEnabled",(()=>this._constructLegendElementsForSublayers()));if(this._handles.add(e,"sublayers-watcher"),!this.respectLayerVisibility||n.visible&&n.legendEnabled&&this._isSublayerInScale(n)){const e=n&&null!=n.opacity?n.opacity:null,s=null!=e?e*t:t;if(n.renderer&&!n.sublayers&&n.originIdOf("renderer")>2){await n.load();r=[...await this._getRendererLegendElements(n.renderer,{title:n.title,opacity:s,sublayer:n}),...r]}else{const e=await this._generateSymbolTableElementForSublayer(n,s,l);e&&r.unshift(e)}}}return r.filter((e=>!!e&&(!("infos"in e)||e.infos.length>0)))}async _generateSymbolTableElementForSublayer(e,t,l){if(!l){l=new Map;const t=this.layer,s=e.source;let r=null;if(!(!s||"map-layer"===s.type&&s.mapLayerId===e.id&&(!s.gdbVersion||s.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>2||e.originIdOf("labelingInfo")>2||e.originIdOf("labelsVisible")>2){const e=new L({layer:this.layer});r=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const i=r||`${t.uid}-default`;(await this._getLegendLayers(i,r)).forEach((e=>l.set(e.layerId,e)))}const s=l.get(e.id);if(!s&&e.sublayers){const s=await this._generateLegendElementsForSublayers(e.sublayers,t,l);return{type:"symbol-table",title:e.title,infos:s}}return this._generateSymbolTableElementForLegendLayer(s,e,t)}_generateSymbolTableElementForLegendLayer(e,t,l){var s;if(!e||!e.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const r=null==t?void 0:t.renderer;let i=(null==t?void 0:t.title)||e.layerName;if(r&&(!t||(null==t?void 0:t.originIdOf("renderer"))>2)){const e=(null==t?void 0:t.title)||this._getRendererTitle(r,t);e&&(i&&"string"!=typeof e&&"title"in e&&(e.title=i),i=e)}const n={type:"symbol-table",title:i,legendType:e.legendType?e.legendType:null,infos:[]},a=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return(null==(s=e.legendGroups)?void 0:s.length)>0?e.legendGroups.forEach((t=>{var s;const r={type:"symbol-table",title:t.heading,legendType:e.legendType?e.legendType:null,infos:this._generateSymbolTableElementInfosForLegendLayer(a.filter((e=>e.groupId===t.id)),e.layerId,l)};(null==(s=r.infos)?void 0:s.length)>0&&n.infos.push(r)})):n.infos=this._generateSymbolTableElementInfosForLegendLayer(a,e.layerId,l),n.infos.length>0?n:null}_generateSymbolTableElementInfosForLegendLayer(e,t,s){return e.map((e=>{let r=e.url;if(e.imageData&&e.imageData.length>0)r=`data:image/png;base64,${e.imageData}`;else{if(0===r.indexOf("http"))return null;r=l(`${this.layer.url}/${t}/images/${r}`)}return{label:e.label,src:r,opacity:null==s?this.opacity:s,width:e.width,height:e.height}})).filter((e=>!!e))}_isSublayerInScale(e){const t=e.minScale||0,l=e.maxScale||0;return!(t>0&&t<this.scale||l>this.scale)}_isLegendLayerInScale(e,t){const l=t||this.layer;let s=null,r=null,i=!0;return!l.minScale&&0!==l.minScale||!l.maxScale&&0!==l.maxScale?(0===e.minScale&&l.tileInfo&&(s=l.tileInfo.lods[0].scale),0===e.maxScale&&l.tileInfo&&(r=l.tileInfo.lods[l.tileInfo.lods.length-1].scale)):(s=Math.min(l.minScale,e.minScale)||l.minScale||e.minScale,r=Math.max(l.maxScale,e.maxScale)),(s>0&&s<this.scale||r>this.scale)&&(i=!1),i}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&this.layer.version<10.1||0===e.length)return e;const l=t.renderer,s=e.some((e=>e.values));let r=null,i=null;return s&&e.some(((e,t)=>(e.values||(r=t,i=e,i.label||(i.label="others")),null!=i))),l?"unique-value"===l.type?i&&(e.splice(r,1),e.push(i)):"class-breaks"===l.type&&(i&&e.splice(r,1),e.reverse(),i&&e.push(i)):i&&(e.splice(r,1),e.push(i)),e}async _getRendererLegendElements(e,t={}){return ve(e,this.view)?pe(e)?this._constructPointCloudRendererLegendElements(e,t):_e(e)?this._constructDotDensityRendererLegendElements(e):this._constructRendererLegendElements(e,t):(K.warn(`Renderer of type '${e.type}' not supported!`),[])}_getPointCloudRendererTitle(e){return e.legendOptions&&e.legendOptions.title||e.field}_constructPointCloudRendererLegendElements(e,t={}){const l=t.title,s=[];let r=null,i=null;if(ge(e))r={type:"symbol-table",title:l||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach((e=>{r.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(ie,e.color)})}));else if(be(e)){const t=e.stops;let s=null;if(t.length&&(1===t.length&&(s=t[0].color),!s)){const e=t[0].value,l=t[t.length-1].value;if(null!=e&&null!=l){s=M(e+(l-e)/2,t)}}r={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(ie,s||ie.color)}]};const n=D(e.stops);i={type:"color-ramp",title:l||this._getPointCloudRendererTitle(e),infos:n,preview:T(n.map((e=>e.color)))}}else Se(e)&&(r={type:"symbol-table",title:l||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos.forEach((e=>{r.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(ie,e.color)})})));r&&r.infos.length&&s.push(r),i&&i.infos.length&&s.push(i);const n=s.reduce(((e,t)=>e.concat(t.infos)),[]).filter((e=>!!e.symbol)).map((t=>this._getSymbolPreview(t,this.opacity,{symbolConfig:{applyColorModulation:!!e.colorModulation}})));return d(n).then((()=>s))}_getElementInfoForDotDensity(e,t){const{backgroundColor:l,outline:s,dotSize:r}=e,i=this.effectList,n=null==i?void 0:i.effects.map((e=>e.toJSON())),a=w(n),o=r+"-"+t+"-"+l+"-"+(s&&JSON.stringify(s.toJSON()))+"-"+a,u=this._dotDensityUrlCache,c=u.has(o)?u.get(o):z(e,t);u.set(o,c);const d={shape:{type:"image",x:0,y:0,width:c.width,height:c.height,src:c.src},fill:null,stroke:null,offset:[0,0]},y=V([[d]],[c.width,c.height],{effectView:this.effectList});return{opacity:1,src:c.src,preview:y,width:c.width,height:c.height}}_constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),l=e.legendOptions&&e.legendOptions.unit,s={type:"symbol-table",title:{value:t&&Math.round(t),unit:l||""},infos:[]};return e.attributes.forEach((t=>{const l=this._getElementInfoForDotDensity(e,t.color);l.label=t.label||t.valueExpressionTitle||t.field,s.infos.push(l)})),Promise.resolve([s])}async _constructRendererLegendElements(e,t={}){const{title:l,sublayer:s}=t,r=s||this.layer;let i=await this._loadRenderer(e);this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const n=await this._getVisualVariableLegendElements(i,r)||[],a={type:"symbol-table",title:l||this._getRendererTitle(i,r),infos:[]};let o=null,c=!1;const y=new Set;if(je(i)){let e=l;const t=Oe(i)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",s=n.findIndex((e=>"color-ramp"===e.type)),r=-1!==s?n.splice(s,1)[0]:null,a=n.findIndex((e=>"size-ramp"===e.type)),o=-1!==a?n.splice(a,1)[0]:null,u=[];r&&(e=r.title,u.push(r)),o&&(e=o.title,u.push(o)),u.length>0&&n.push({type:t,title:e,infos:u})}else if(me(i)){const e=U(i);n.push({type:"heatmap-ramp",title:l,infos:e,preview:T(e.map((e=>e.color)),{effectList:this.effectList})})}else if(he(i)){const e=i&&i.authoringInfo;if(e&&"relationship"===e.type){const{focus:t,numClasses:l,field1:s,field2:o}=e;if(l&&s&&o){const e=[s,o];let u=B(t)||0;for(const t of e){const{field:e,normalizationField:l,label:s}=t,i=s||{field:this._getFieldAlias(e,r),normField:l&&this._getFieldAlias(l,r)},n=Me.clone();n.angle=u,a.infos.push({label:i,symbol:n}),y.add(n),u+=90}const c=k({focus:t,numClasses:l,infos:i.uniqueValueInfos});n.unshift(c)}}else{const e=i.field;i.uniqueValueInfos.forEach((t=>{t.symbol&&a.infos.push({label:t.label||this._getDomainName(e,t.value,r)||t.value,value:t.value,symbol:t.symbol})}))}i.defaultSymbol&&(a.infos.push({label:i.defaultLabel||"others",symbol:i.defaultSymbol}),c=!0)}else if(ye(i)){o=this._isUnclassedRenderer(i);(!o||!this._hasSizeRamp)&&(i.classBreakInfos.forEach((e=>{e.symbol&&a.infos.unshift({label:e.label||(o?null:e.minValue+" - "+e.maxValue),value:[e.minValue,e.maxValue],symbol:e.symbol})})),o&&(a.title=null),this._updateInfosforClassedSizeRenderer(i,a.infos)),i.defaultSymbol&&!o&&(a.infos.push({label:i.defaultLabel||"others",symbol:i.defaultSymbol}),c=!0)}else if(ue(i))if(Te(this.layer)||ze(this.layer)){const e=this._constructTileImageryStretchRendererElements(i);xe(e)?n.push(e):a.infos=e}else{const e=this.layer;let t,l;var h,m;if(i.statistics&&i.statistics.length)t=null!=i.statistics[0].min?i.statistics[0].min:i.statistics[0][0],l=null!=i.statistics[0].max?i.statistics[0].max:i.statistics[0][1];else t=null==(h=i)?void 0:h.outputMin,l=null==(m=i)?void 0:m.outputMax;let s=[];const r=u(e.renderingRule?await e.generateRasterInfo(e.renderingRule):e.serviceRasterInfo),o=r.keyProperties.BandProperties;1===r.bandCount?(t=null!=t?t:r.statistics&&r.statistics[0].min,l=null!=l?l:r.statistics&&r.statistics[0].max,t||l?n.push(this._getStretchLegendElements(i,{min:t,max:l})):this._getServerSideLegend()):e.bandIds&&1===e.bandIds.length?(t=null!=t?t:r.statistics&&r.statistics[e.bandIds[0]].min,l=null!=l?l:r.statistics&&r.statistics[e.bandIds[0]].max,t||l?n.push(this._getStretchLegendElements(i,{min:t,max:l})):this._getServerSideLegend()):r.bandCount>=3?o&&o.length>=r.bandCount?e.bandIds&&3===e.bandIds.length?(s=e.bandIds.map((e=>o[e].BandName)),a.infos=this._createSymbolTableElementMultiBand(s)):"lerc"===e.format?(s=[0,1,2].map((e=>o[e].BandName)),a.infos=this._createSymbolTableElementMultiBand(s)):this._getServerSideLegend():"lerc"===e.format?(s=["band1","band2","band3"],a.infos=this._createSymbolTableElementMultiBand(s)):this._getServerSideLegend():this._getServerSideLegend()}else if(oe(i))i.colormapInfos.forEach((e=>{a.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(ne,e.color)})}));else if(de(i)){let e=i.symbol;switch(t.geometryType){case"point":e="pointSymbol"in r&&r.pointSymbol;break;case"polyline":e="lineSymbol"in r&&r.lineSymbol;break;case"polygon":e="polygonSymbol"in r&&r.polygonSymbol}i.symbol&&!this._hasSizeRamp&&a.infos.push({label:i.label,symbol:e})}else if(ae(i)){i.outputUnit&&(this.title="("+i.toJSON().outputUnit+")"),a.title=i.attributeField;const e=i.getClassBreakInfos();null!=e&&e.length?e.forEach((e=>{a.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})})):a.infos.push({label:i.attributeField,symbol:i.getDefaultSymbol()})}else ce(i)&&n.push(this._getStretchLegendElements(i,{min:0,max:255}));const p=i.defaultSymbol;!p||c||de(i)||o&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||n.push({type:"symbol-table",infos:[{label:i.defaultLabel||"others",symbol:p}]}),a.infos.length&&n.unshift(a);const f=null==t.opacity?this.opacity:t.opacity,g=this._isTallSymbol("visualVariables"in i&&i.visualVariables),b=Ve(this.layer)||Te(this.layer),S=n.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!(null==e||!e.symbol))).map((e=>this._getSymbolPreview(e,f,{isDefault:e.symbol===p,applyScaleDrivenSize:!y.has(e.symbol),symbolConfig:{isTall:g,isSquareFill:b},effectList:y.has(e.symbol)?null:this.effectList})));return i=null,await d(S),n}_getServerSideLegend(){setTimeout((()=>this.buildLegendElementsForTools()),0)}_getAllInfos(e){const t=null==e?void 0:e.infos;return t?t.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]):[e]}_constructTileImageryStretchRendererElements(e){var t,l;const s=this.layer,r=s.rasterInfo,i=r.bandCount||e.statistics.length;let n,a,o=[];const u=r.keyProperties&&r.keyProperties.BandProperties,c=null!=e&&null!=(t=e.statistics)&&t.length?e.statistics:null==r?void 0:r.statistics;if(c)n=void 0!==c[0].min?c[0].min:c[0][0],a=c[0].max||c[0][1];else{const e=re[s.rasterInfo.pixelType.toLowerCase()];n=e[0],a=e[1]}if(s.hasStandardTime()&&(n=s.getStandardTimeValue(n),a=s.getStandardTimeValue(a)),1===r.bandCount||1===(null==(l=s.bandIds)?void 0:l.length))return this._getStretchLegendElements(e,{min:n,max:a});function d(e){var t;const l=(null!=s&&null!=(t=s.bandIds)&&t.length?s.bandIds:Array.from(Array(Math.min(r.bandCount,3)).keys())).map((t=>e&&e[t]&&e[t].BandName||"band"+(t+1)));return l.length<3?l.push(l[1]):l.length>3&&l.splice(3),l}return o=u&&u.length>=i?d(u):d(),this._createSymbolTableElementMultiBand(o)}_getStretchLegendElements(e,t){const l=e.colorRamp,s=P(l,t);return{type:"stretch-ramp",title:"",infos:s,preview:T(s.map((e=>e.color)))}}_createSymbolTableElementMultiBand(e){const t=[],l=["red","green","blue"];return e.forEach(((e,s)=>{t.push({label:{colorName:l[s],bandName:e},src:J[s],opacity:1})})),t}_updateInfosforClassedSizeRenderer(e,t){const l=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,s=e.classBreakInfos.some((e=>j(e.symbol)));if(l&&s){const l=q,s=W,r=e.classBreakInfos.length,i=(l-s)/(r>1?r-1:r);t.forEach(((e,t)=>{e.size=l-i*t}))}}_isTallSymbol(e){let t=!1,l=!1;if(e)for(let s=0;s<e.length&&(!t||!l);s++){const r=e[s];"size"===r.type&&("height"===r.axis&&(t=!0),"width-and-depth"===r.axis&&(l=!0))}return t&&l}async _getSymbolPreview(e,t,l){let s=null!=l&&l.isDefault||null!=e.size||!this._hasSizeRamp?e.size:h(22);if(this._scaleDrivenSizeVariable&&null!=l&&l.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");s=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}return x(e.symbol,{size:s,opacity:t,scale:!1,symbolConfig:null==l?void 0:l.symbolConfig,effectView:null==l?void 0:l.effectList}).then((t=>(e.preview=t,e))).catch((()=>(e.preview=null,e)))}async _loadRenderer(e){var t,l;const s=[],r=this.layer;e=e.clone(),this._hasClusterSizeVariable=!1;const i="visualVariables"in e&&(null==(t=e.visualVariables)?void 0:t.some((e=>"size"===e.type&&"outline"!==e.target&&!le.test(e.valueExpression))));if(e&&"visualVariables"in e&&!i&&"featureReduction"in r&&"cluster"===(null==(l=r.featureReduction)?void 0:l.type)){const t=this.layerView._effectiveRenderer,l=u(O(t,this.view));if(l){const t=r.featureReduction;if("clusterMinSize"in t&&"clusterMaxSize"in t){const{clusterMinSize:e,clusterMaxSize:s}=t;l.legendOptions=new F({showLegend:e!==s})}const s=e.visualVariables||[];e.visualVariables=s.concat([l]),this._hasClusterSizeVariable=!0}}const n=await this._getMedianColor(e);if(ye(e)||he(e)){const t=(e.classBreakInfos||e.uniqueValueInfos).map((e=>this._fetchSymbol(e.symbol,n).then((t=>{e.symbol=t})).catch((()=>{e.symbol=null}))));Array.prototype.push.apply(s,t)}return s.push(this._fetchSymbol(e.symbol||e.defaultSymbol,e.defaultSymbol?null:n).then((t=>{this._applySymbolToRenderer(e,t,de(e))})).catch((()=>{this._applySymbolToRenderer(e,null,de(e))}))),d(s).then((()=>e))}_applySymbolToRenderer(e,t,l){l?e.symbol=t:e.defaultSymbol=t}async _getMedianColor(e){if(!("visualVariables"in e)||!e.visualVariables)return null;const t=e.visualVariables.find((e=>"color"===e.type));if(!t)return null;let l=null,s=null;if(t.stops){if(1===t.stops.length)return t.stops[0].color;l=t.stops[0].value,s=t.stops[t.stops.length-1].value}const r=l+(s-l)/2,{getColor:i}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");return i(t,r)}_fetchSymbol(e,t){if(!e)return Promise.reject();if("web-style"===e.type){const l=e.portal,s=l&&l.url,r=l&&l.user&&l.user.username,i=e.name+"-"+e.styleName+"-"+e.styleUrl+"-"+s+"-"+r,n=this._webStyleSymbolCache;return n.has(i)||("2d"===this.view.type?n.set(i,e.fetchCIMSymbol()):n.set(i,e.fetchSymbol())),n.get(i).then((e=>this._getAppliedCloneSymbol(e,t))).catch((()=>(K.warn("Fetching web-style failed!"),Promise.reject())))}return Promise.resolve(this._getAppliedCloneSymbol(e,t))}_getAppliedCloneSymbol(e,l){if(!e||!l)return e;const s=e.clone(),r=l&&l.toRgba();return s.type.indexOf("3d")>-1?this._applyColorTo3dSymbol(s,r):"cim"===s.type?R(s,l):s.color&&(s.color=new t(r||s.color)),s}_applyColorTo3dSymbol(e,l){l&&e.symbolLayers.forEach((e=>{e&&(e.material||(e.material={}),e.material.color=new t(l))}))}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||!e.visualVariables||"vector-field"===e.type)return null;const l=e.visualVariables,s=[],r=[],i=[];for(const c of l)"color"===c.type?s.push(c):"size"===c.type?r.push(c):"opacity"===c.type&&i.push(c);const n=[...s,...r,...i];let a,o;if(0===s.length&&ye(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];a=t&&t.symbol}if(0===s.length&&de(e)&&(a=e.symbol),a)if(a.type.indexOf("3d")>-1){const e=a.symbolLayers.getItemAt(0);"water"===e.type?c(e.color)&&(o=e.color):c(e.material)&&c(e.material.color)&&(o=e.material.color)}else a.url||(o=a.color);const u=this.effectList;return(await Promise.all(n.map((async l=>{if(!l.legendOptions||!1!==l.legendOptions.showLegend){const s=this._getRampTitle(l,t);let r=null;const i="getField"in t&&t.getField&&t.getField(l.field),n=i&&E(i);if("color"===l.type){const e=await A(l,null,n);r={type:"color-ramp",title:s,infos:e,preview:T(e.map((e=>e.color)),{effectList:u})},this._hasColorRamp||(this._hasColorRamp=!(null==r.infos||!r.infos.length))}else if("size"===l.type&&"outline"!==l.target)le.test(l.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=l):(r={type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(l):s,infos:await N(e,l,await this._getMedianColor(e),this.scale,this.view.type,n)},this._hasSizeRamp||(this._hasSizeRamp=!(null==r.infos||!r.infos.length)));else if("opacity"===l.type){const e=await A(l,o,n);r={type:"opacity-ramp",title:s,infos:e,preview:T(e.map((e=>e.color)),{effectList:u})},this._hasOpacityRamp||(this._hasOpacityRamp=!(null==r.infos||!r.infos.length))}return r&&r.infos?r:null}})))).filter((e=>!!e))}_getDomainName(e,t,l){if(e&&"function"!=typeof e){const s="getField"in l&&l.getField&&l.getField(e),r=s&&"getFieldDomain"in l&&l.getFieldDomain?l.getFieldDomain(s.name):null;return r&&"coded-value"===r.type?r.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,l=e.field;if("featureReduction"in t&&t.featureReduction&&"cluster"===t.featureReduction.type){const e=t.featureReduction,s="popupTemplate"in e&&e.popupTemplate,r=s&&s.fieldInfos;if(r)for(const t of r)if(t.fieldName===l)return"cluster_count"===l?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let l=e.field,s=e.normalizationField,r=!1,i=!1,n=!1,a=null;l="function"==typeof l?null:l,s="function"==typeof s?null:s;const o=e.legendOptions&&e.legendOptions.title;if(null!=o)a=o;else if(e.valueExpressionTitle)a=e.valueExpressionTitle;else{if("renderer"in t&&t.renderer&&"authoringInfo"in t.renderer&&t.renderer.authoringInfo&&t.renderer.authoringInfo.visualVariables){const e=t.renderer.authoringInfo.visualVariables;for(let t=0;t<e.length;t++){const l=e[t];if("color"===l.type){if("ratio"===l.style){r=!0;break}if("percent"===l.style){i=!0;break}if("percent-of-total"===l.style){n=!0;break}}}}a={field:l&&this._getFieldAlias(l,t),normField:s&&this._getFieldAlias(s,t),ratio:r,ratioPercent:i,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const l=e;if(l.legendOptions&&l.legendOptions.title)return l.legendOptions.title;if(l.valueExpressionTitle)return l.valueExpressionTitle;let s=l.field,r=null,i=null;ye(l)&&(r=l.normalizationField,i="percent-of-total"===l.normalizationType),s="function"==typeof s?null:s,r="function"==typeof r?null:r;let n=null;return(s||r)&&(n={field:s&&this._getFieldAlias(s,t),normField:r&&this._getFieldAlias(r,t),normByPct:i}),n}_getFieldAlias(e,t){const l="popupTemplate"in t&&t.popupTemplate,s=l&&l.fieldInfos;let r=null;s&&s.some((t=>e===t.fieldName&&(r=t,!0)));let i=null;"getField"in t&&t.getField?i=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(i=t.fieldsIndex.get(e));const n=r||i;let a=null;return n&&(a=r&&r.label||i&&i.alias||"name"in n&&n.name||"fieldName"in n&&n.fieldName),a}_isUnclassedRenderer(e){const t=e.visualVariables;let l=!1;return ye(e)&&e.classBreakInfos&&1===e.classBreakInfos.length&&t&&(l=e.field?t.some((t=>!(!t||e.field!==t.field||(e.normalizationField||t.normalizationField)&&e.normalizationField!==t.normalizationField))):!!t.length),l}};e([S()],Pe.prototype,"children",void 0),e([S({readOnly:!0})],Pe.prototype,"effectList",null),e([S()],Pe.prototype,"layerView",void 0),e([S()],Pe.prototype,"layer",void 0),e([S()],Pe.prototype,"legendElements",void 0),e([S({readOnly:!0})],Pe.prototype,"opacity",null),e([S()],Pe.prototype,"parent",void 0),e([S({readOnly:!0,dependsOn:[]})],Pe.prototype,"ready",null),e([S()],Pe.prototype,"hideLayersNotInCurrentView",void 0),e([S()],Pe.prototype,"keepCacheOnDestroy",void 0),e([S()],Pe.prototype,"respectLayerVisibility",void 0),e([S({readOnly:!0})],Pe.prototype,"scale",null),e([S()],Pe.prototype,"sublayerIds",void 0),e([S({readOnly:!0})],Pe.prototype,"isScaleDriven",null),e([S()],Pe.prototype,"title",void 0),e([S({readOnly:!0,dependsOn:["ready"],value:0})],Pe.prototype,"version",null),e([S()],Pe.prototype,"view",void 0),Pe=e([_("esri.widgets.Legend.support.ActiveLayerInfo")],Pe);const Ae=Pe;export{Ae as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import{addTokenParameter as l}from"../../../kernel.js";import s from"../../../request.js";import"../../../symbols.js";import r from"../../../core/Accessor.js";import n from"../../../core/Collection.js";import i from"../../../core/Handles.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{unwrap as u,isSome as c}from"../../../core/maybe.js";import{eachAlways as d,debounce as y}from"../../../core/promiseUtils.js";import{px2pt as h}from"../../../core/screenUtils.js";import{addQueryParameters as m}from"../../../core/urlUtils.js";import{on as p,init as f,whenFalseOnce as g,watch as b}from"../../../core/watchUtils.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import v from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as w}from"../../../layers/effects/jsonUtils.js";import{ExportImageParameters as L}from"../../../layers/support/ExportImageParameters.js";import{isDateField as E}from"../../../layers/support/fieldUtils.js";import{fromJSON as I}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as C}from"../../../renderers/support/rendererConversion.js";import F from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{applyCIMSymbolColor as R}from"../../../symbols/support/cimSymbolUtils.js";import{renderSymbol as V}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as T,renderDotDensityPreviewHTML as z,renderPreviewHTML as x}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as j}from"../../../symbols/support/utils.js";import{getClusterSizeVariable as O}from"./clusterUtils.js";import{getColorFromPointCloudStops as D,getRampStopsForPointCloud as M,getStrectchRampStops as P,getRampStops as A}from"./colorRampUtils.js";import{getHeatmapRampStops as U}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as B,getRelationshipRampElement as k}from"./relationshipRampUtils.js";import{getRampStops as N,REAL_WORLD_MAX_SIZE as q,REAL_WORLD_MIN_SIZE as W}from"./sizeRampUtils.js";import{SPECIAL_CHARS_LESS_THAN as $,SPECIAL_CHARS_GREATER_THAN as G,RGB_IMG_SOURCE as J}from"./utils.js";import{formatNumberLabel as Q}from"../../smartMapping/support/utils.js";import H from"../../../symbols/SimpleMarkerSymbol.js";import X from"../../../symbols/SimpleFillSymbol.js";const K=o.getLogger("esri.widgets.Legend.support.ActiveLayerInfo"),Y="https://utility.arcgis.com/sharing/tools/legend",Z="esri.layers.ImageryLayer",ee="esri.layers.ImageryTileLayer",te="esri.layers.WCSLayer",le=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,se=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),re={u1:[0,1],u2:[0,3],u4:[0,15],u8:[0,255],s8:[-128,127],u16:[0,65535],s16:[-32768,32767],u32:[0,4294967295],s32:[-2147483648,2147483647],f32:[-34e38,34e38],f64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ne=new H({size:6,outline:{color:[128,128,128,.5],width:.5}}),ie=new X({style:"solid"});function ae(e){return"vector-field"===e.type}function oe(e){return"raster-colormap"===e.type}function ue(e){return"raster-stretch"===e.type}function ce(e){return"raster-shaded-relief"===e.type}function de(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function ye(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function he(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function me(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function pe(e){return ge(e)||be(e)||Se(e)||fe(e)}function fe(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function ge(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function be(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function Se(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function _e(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function ve(e,t){return de(e)||ye(e)||he(e)||me(e)||_e(e)?"2d"===t.type||C(e):ue(e)||oe(e)||ce(e)||ge(e)||be(e)||Se(e)||ae(e)}function we(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Le(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Ee(e){return"esri.layers.WMSLayer"===e.declaredClass}function Ie(e){return"esri.layers.WMTSLayer"===e.declaredClass}function Ce(e){return"esri.layers.MapImageLayer"===e.declaredClass}function Fe(e){return"esri.layers.TileLayer"===e.declaredClass}function Re(e){return"esri.layers.FeatureLayer"===e.declaredClass}function Ve(e){return e.declaredClass===Z}function Te(e){return e.declaredClass===ee}function ze(e){return e.declaredClass===te}function xe(e){return"stretch-ramp"===e.type}function je(e){const t="authoringInfo"in e&&(null==e?void 0:e.authoringInfo);return"univariate-color-size"===(null==t?void 0:t.type)}function Oe(e){const t="authoringInfo"in e&&(null==e?void 0:e.authoringInfo);return"univariate-color-size"===(null==t?void 0:t.type)&&"above-and-below"===(null==t?void 0:t.univariateTheme)}const De=new H({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let Me={},Pe=class extends r{constructor(e){super(e),this._handles=new i,this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._hasClusterSizeVariable=!1,this.children=new n,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this._handles.add([p(this,"children","change",(t=>{const{added:l,removed:s}=t,r=this._handles;l.forEach((t=>{const l=`activeLayerInfo-ready-watcher-${t.layer.uid}`;r.add(f(t,"ready",e),l)})),s.forEach((e=>r.remove(e.layer.uid))),e()}))]),this.keepCacheOnDestroy||(Me={})}destroy(){this._handles.destroy(),this._handles=null,this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(Me=null)}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new v,t.effect=e.effect,t.end(),t.scale=this.scale),t}get opacity(){var e;const t=this.layer.opacity,l=null==(e=this.parent)?void 0:e.opacity,s=this.layer.parent,r=s&&"uid"in s?this._getParentLayerOpacity(s):null;return null!=l?l*t:null!=r?r*t:t}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view&&this.view.scale}get isScaleDriven(){const e=this.layer;if(null===e)return!1;if("effect"in e&&e.effect&&Array.isArray(e.effect))return!0;if("featureReduction"in e&&e.featureReduction&&"cluster"===e.featureReduction.type)return!0;if("renderer"in e&&e.renderer){if("dot-density"===e.renderer.type)return!0;const t=e.get("renderer.valueExpression");if(le.test(t))return!0;const l=e.get("renderer.visualVariables");if(l)return l.some((e=>this._isScaleDrivenSizeVariable(e)))}return this._isLayerScaleDriven(this.layer)}get version(){return this._get("version")+1}async buildLegendElementsForFeatureCollections(e){if(!(!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView()))return this.legendElements=[],void this.notifyChange("ready");const t=Array.from(e,(e=>{if(Re(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet&&e.featureSet.features.length){const t=e.layerDefinition,l=t&&t.drawingInfo,s=l&&I(l.renderer),r=se.read(t.geometryType);return s?this._getRendererLegendElements(s,{title:e.name,geometryType:r}):(K.warn("drawingInfo not available!"),null)}return null}));try{const e=[];await d(t).then((t=>{t.forEach((({value:t})=>t&&e.push(...t)))})),this.legendElements=e,this.notifyChange("ready")}catch(l){K.warn("error while building legend for layer!",l)}}async buildLegendElementsForRenderer(e){try{const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getRendererLegendElements(e):[],this.notifyChange("ready")}catch(t){K.warn("error while building legend for layer!",t)}}async buildLegendElementsForTools(){const e=this.layer;if(Le(e))this._constructLegendElementsForVoxellayer();else if(Ie(e))this._constructLegendElementsForWMTSlayer();else if(Ee(e))await this._constructLegendElementsForWMSSublayers();else if(we(e))await this._constructLegendElementsForBuildingSceneLayer();else if(Ce(e)||Fe(e)||we(e))await this._constructLegendElementsForSublayers();else{this._handles.remove("imageryLayers-watcher");let s="default";if(Ve(e)){var t,l;const r=e;s=((null==r||null==(t=r.renderingRule)?void 0:t.functionName)||"default")+"_"+(null!=(l=e.bandIds)&&l.length?e.bandIds.join(""):"###")}await this._getLegendLayers(`${e.uid}-${s}`).then((async t=>{this.legendElements=[],this.notifyChange("ready");const l=t.map((async t=>{if(Ve(e)||Te(e)){const t=e.watch(["renderingRule","bandIds"],(()=>y((async()=>{Me.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()}))()));this._handles.add(t,"imageryLayers-watcher")}const l=this._generateSymbolTableElementForLegendLayer(t);l&&l.infos.length&&(Ve(e)&&(l.title=e.title),this.legendElements.push(l)),this.notifyChange("ready")}));await d(l)})).catch((e=>{K.warn("Request to server for legend has failed!",e)}))}}async _isLayerInCurrentView(){const e=this.layer,t=this.layerView,l=t&&"createQuery"in t&&"queryFeatureCount"in t;if(!l&&!(t&&"createQuery"in e&&"queryFeatureCount"in e))return!0;await g(t,"updating");const s=l?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();s.geometry=this.view.extent;return 0!==(l?"queryFeatureCount"in t&&await t.queryFeatureCount(s):"queryFeatureCount"in e&&await e.queryFeatureCount(s))}_getParentLayerOpacity(e){let t=1;const l=e.parent;return l&&"uid"in l&&(t=this._getParentLayerOpacity(l)),e.opacity*t}_isGroupActive(){const e=this.children;return!!e.length&&e.some((e=>e.ready))}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,l=t.minSize,s=t.maxSize;return"object"==typeof l&&l?this._isScaleDrivenSizeVariable(l):"object"==typeof s&&s?this._isScaleDrivenSizeVariable(s):!!t.expression||le.test(t.valueExpression)}_isLayerScaleDriven(e){if("minScale"in e&&e.minScale>0||"maxScale"in e&&e.maxScale>0)return!0;if("sublayers"in e&&e.sublayers)return e.sublayers.some((e=>this._isLayerScaleDriven(e)));const t=e.parent;if(!1===e.loaded&&t&&Ce(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const l of t.sourceJSON.layers)if(l.id===e.source.mapLayerId&&(l.minScale>0||l.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxellayer(){this.legendElements=[],this._handles.remove("voxel-style-watcher");const e=this.layer;this._handles.add(b(e,"style",(()=>this._constructLegendElementsForVoxellayer())),"voxel-style-watcher");const t=u(e.getVariableStyle(null)),l=[];var s;if(t)if(null!=(s=t.uniqueValues)&&s.length){const e=[];t.uniqueValues.forEach((t=>{t.enabled&&e.push({label:t.label||`${t.value}`,value:t.value,symbol:new X({color:t.color,outline:null})})})),e.length&&l.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:s}=t.transferFunction,r=e.toArray().reverse(),n=s.map(((e,t)=>`${0===t?$:G} ${Q(e)}`)).reverse(),i=r.map((e=>({color:e.color,value:null,label:null})));i[0].label=n[0],i[i.length-1].label=n[1],l.push({type:"color-ramp",title:t.label,infos:i,preview:T(r.map((e=>e.color)))})}const r=e.opacity,n=l.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!(null==e||!e.symbol))).map((e=>this._getSymbolPreview(e,r)));await d(n),this.legendElements=l,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this._handles.remove("wmts-activeLayer-watcher");const e=this.layer.activeLayer;if(this._handles.add(b(this.layer,"activeLayer",(()=>this._constructLegendElementsForWMTSlayer())),"wmts-activeLayer-watcher"),e.styleId&&e.styles){let t=null;e.styles.some((l=>e.styleId===l.id&&(t=l.legendUrl,!0))),t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}])}this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this.legendElements=[],this._handles.remove("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this._handles.add(b(this.layer,"sublayers",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher"),this.legendElements=await this._generateLegendElementsForWMSSublayers(e.sublayers,t),this.notifyChange("ready")}async _generateLegendElementsForWMSSublayers(e,t){const l=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher");const s=e.toArray();for(const r of s){const e=r.watch(["title","visible","legendEnabled"],(()=>this._constructLegendElementsForWMSSublayers()));if(this._handles.add(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e&&e.infos.length&&l.unshift(e)}}return l}async _generateSymbolTableElementForWMSSublayer(e,t){if(!e.legendUrl&&e.sublayers){const l=(await this._generateLegendElementsForWMSSublayers(e.sublayers,t)).filter((e=>e));return{type:"symbol-table",title:e.title,infos:l}}return this._generateSymbolTableElementForLegendUrl(e,t)}async _generateSymbolTableElementForLegendUrl(e,t){var l;let r=e.legendUrl;if(!r)return;const n={type:"symbol-table",title:e.title||e.name||e.id&&e.id+"",infos:[]};t&&(r=m(r,t));let i=null;const a=null==(l=e.layer)?void 0:l.opacity;try{i=(await s(r,{responseType:"image"})).data,i&&(i.style.opacity=a)}catch{}return n.infos.push({src:r,preview:i,opacity:a}),n}_getLegendLayers(e,t){const l=Me&&Me[e];return l?Promise.resolve(l):this._legendRequest(t).then((t=>{const l=t.layers;return Me[e]=l,l}))}_legendRequest(e){const t=this.layer;let l={f:"json",dynamicLayers:e};if(Ve(t)){const e=t.exportImageServiceParameters.renderingRule;if(e&&(l.renderingRule=JSON.stringify(e.toJSON())),t.bandIds&&(l.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:s,customParameters:r}=t;l={raster:e,viewId:s,...l,...r}}}let r=t.url.replace(/(\/)+$/,"");if("version"in t&&t.version>=10.01){const e=r.indexOf("?");e>-1?r=r.substring(0,e)+"/legend"+r.substring(e):r+="/legend"}else{const e=r.toLowerCase().indexOf("/rest/"),t=r.substring(0,e)+r.substring(e+5,r.length);r=Y+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return s(r,{query:l}).then((e=>e.data))}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this._handles.remove("sublayers-watcher");const e=this.layer;this._handles.add(b(e,"sublayers",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){K.warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForBuildingSublayers(e,t){let l=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");const s=e.toArray();for(const r of s){const e=r.watch(["renderer","opacity","title","visible"],(()=>this._constructLegendElementsForBuildingSceneLayer()));if(this._handles.add(e,"sublayers-watcher"),!this.respectLayerVisibility||r.visible){const e=r&&null!=r.opacity?r.opacity:null,s=null!=e?e*t:t;if("building-group"===r.type){const e={type:"symbol-table",title:r.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(r.sublayers,s);e.infos.push(...t),l=[e,...l]}else if(r.renderer){l=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:s,sublayer:r}),...l]}}}return l.filter((e=>!!e&&(!("infos"in e)||e.infos.length>0)))}async _constructLegendElementsForSublayers(){this.legendElements=[],this._handles.remove("sublayers-watcher");const e=this.layer;this._handles.add(b(e,"sublayers",(()=>this._constructLegendElementsForSublayers)),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){K.warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForSublayers(e,t,l){const s=this.layer;let r=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForSublayers())),"sublayers-watcher");let n=e.toArray();!l&&this.sublayerIds&&this.sublayerIds.length&&(n=this.sublayerIds.map((e=>s.findSublayerById(e))).filter(Boolean));for(const i of n){const e=i.watch("renderer, opacity, title, visible, legendEnabled",(()=>this._constructLegendElementsForSublayers()));if(this._handles.add(e,"sublayers-watcher"),!this.respectLayerVisibility||i.visible&&i.legendEnabled&&this._isSublayerInScale(i)){const e=i&&null!=i.opacity?i.opacity:null,s=null!=e?e*t:t;if(i.renderer&&!i.sublayers&&i.originIdOf("renderer")>2){await i.load();r=[...await this._getRendererLegendElements(i.renderer,{title:i.title,opacity:s,sublayer:i}),...r]}else{const e=await this._generateSymbolTableElementForSublayer(i,s,l);e&&r.unshift(e)}}}return r.filter((e=>!!e&&(!("infos"in e)||e.infos.length>0)))}async _generateSymbolTableElementForSublayer(e,t,l){if(!l){l=new Map;const t=this.layer,s=e.source;let r=null;if(!(!s||"map-layer"===s.type&&s.mapLayerId===e.id&&(!s.gdbVersion||s.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>2||e.originIdOf("labelingInfo")>2||e.originIdOf("labelsVisible")>2){const e=new L({layer:this.layer});r=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const n=r||`${t.uid}-default`;(await this._getLegendLayers(n,r)).forEach((e=>l.set(e.layerId,e)))}const s=l.get(e.id);if(!s&&e.sublayers){const s=await this._generateLegendElementsForSublayers(e.sublayers,t,l);return{type:"symbol-table",title:e.title,infos:s}}return this._generateSymbolTableElementForLegendLayer(s,e,t)}_generateSymbolTableElementForLegendLayer(e,t,l){var s;if(!e||!e.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const r=null==t?void 0:t.renderer;let n=(null==t?void 0:t.title)||e.layerName;if(r&&(!t||(null==t?void 0:t.originIdOf("renderer"))>2)){const e=(null==t?void 0:t.title)||this._getRendererTitle(r,t);e&&(n&&"string"!=typeof e&&"title"in e&&(e.title=n),n=e)}const i={type:"symbol-table",title:n,legendType:e.legendType?e.legendType:null,infos:[]},a=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return(null==(s=e.legendGroups)?void 0:s.length)>0?e.legendGroups.forEach((t=>{var s;const r={type:"symbol-table",title:t.heading,legendType:e.legendType?e.legendType:null,infos:this._generateSymbolTableElementInfosForLegendLayer(a.filter((e=>e.groupId===t.id)),e.layerId,l)};(null==(s=r.infos)?void 0:s.length)>0&&i.infos.push(r)})):i.infos=this._generateSymbolTableElementInfosForLegendLayer(a,e.layerId,l),i.infos.length>0?i:null}_generateSymbolTableElementInfosForLegendLayer(e,t,s){return e.map((e=>{let r=e.url;if(e.imageData&&e.imageData.length>0)r=`data:image/png;base64,${e.imageData}`;else{if(0===r.indexOf("http"))return null;r=l(`${this.layer.url}/${t}/images/${r}`)}return{label:e.label,src:r,opacity:null==s?this.opacity:s,width:e.width,height:e.height}})).filter((e=>!!e))}_isSublayerInScale(e){const t=e.minScale||0,l=e.maxScale||0;return!(t>0&&t<this.scale||l>this.scale)}_isLegendLayerInScale(e,t){const l=t||this.layer;let s=null,r=null,n=!0;return!l.minScale&&0!==l.minScale||!l.maxScale&&0!==l.maxScale?(0===e.minScale&&l.tileInfo&&(s=l.tileInfo.lods[0].scale),0===e.maxScale&&l.tileInfo&&(r=l.tileInfo.lods[l.tileInfo.lods.length-1].scale)):(s=Math.min(l.minScale,e.minScale)||l.minScale||e.minScale,r=Math.max(l.maxScale,e.maxScale)),(s>0&&s<this.scale||r>this.scale)&&(n=!1),n}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&this.layer.version<10.1||0===e.length)return e;const l=t.renderer,s=e.some((e=>e.values));let r=null,n=null;return s&&e.some(((e,t)=>(e.values||(r=t,n=e,n.label||(n.label="others")),null!=n))),l?"unique-value"===l.type?n&&(e.splice(r,1),e.push(n)):"class-breaks"===l.type&&(n&&e.splice(r,1),e.reverse(),n&&e.push(n)):n&&(e.splice(r,1),e.push(n)),e}async _getRendererLegendElements(e,t={}){return ve(e,this.view)?pe(e)?this._constructPointCloudRendererLegendElements(e,t):_e(e)?this._constructDotDensityRendererLegendElements(e):this._constructRendererLegendElements(e,t):(K.warn(`Renderer of type '${e.type}' not supported!`),[])}_getPointCloudRendererTitle(e){return e.legendOptions&&e.legendOptions.title||e.field}_constructPointCloudRendererLegendElements(e,t={}){const l=t.title,s=[];let r=null,n=null;if(ge(e))r={type:"symbol-table",title:l||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach((e=>{r.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(ne,e.color)})}));else if(be(e)){const t=e.stops;let s=null;if(t.length&&(1===t.length&&(s=t[0].color),!s)){const e=t[0].value,l=t[t.length-1].value;if(null!=e&&null!=l){s=D(e+(l-e)/2,t)}}r={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(ne,s||ne.color)}]};const i=M(e.stops);n={type:"color-ramp",title:l||this._getPointCloudRendererTitle(e),infos:i,preview:T(i.map((e=>e.color)))}}else Se(e)&&(r={type:"symbol-table",title:l||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos.forEach((e=>{r.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(ne,e.color)})})));r&&r.infos.length&&s.push(r),n&&n.infos.length&&s.push(n);const i=s.reduce(((e,t)=>e.concat(t.infos)),[]).filter((e=>!!e.symbol)).map((t=>this._getSymbolPreview(t,this.opacity,{symbolConfig:{applyColorModulation:!!e.colorModulation}})));return d(i).then((()=>s))}_getElementInfoForDotDensity(e,t){const{backgroundColor:l,outline:s,dotSize:r}=e,n=this.effectList,i=null==n?void 0:n.effects.map((e=>e.toJSON())),a=w(i),o=r+"-"+t+"-"+l+"-"+(s&&JSON.stringify(s.toJSON()))+"-"+a,u=this._dotDensityUrlCache,c=u.has(o)?u.get(o):z(e,t);u.set(o,c);const d={shape:{type:"image",x:0,y:0,width:c.width,height:c.height,src:c.src},fill:null,stroke:null,offset:[0,0]},y=V([[d]],[c.width,c.height],{effectView:this.effectList});return{opacity:1,src:c.src,preview:y,width:c.width,height:c.height}}_constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),l=e.legendOptions&&e.legendOptions.unit,s={type:"symbol-table",title:{value:t&&Math.round(t),unit:l||""},infos:[]};return e.attributes.forEach((t=>{const l=this._getElementInfoForDotDensity(e,t.color);l.label=t.label||t.valueExpressionTitle||t.field,s.infos.push(l)})),Promise.resolve([s])}async _constructRendererLegendElements(e,t={}){const{title:l,sublayer:s}=t,r=s||this.layer;let n=await this._loadRenderer(e);this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const i=await this._getVisualVariableLegendElements(n,r)||[],a={type:"symbol-table",title:l||this._getRendererTitle(n,r),infos:[]};let o=null,c=!1;const y=new Set;if(je(n)){let e=l;const t=Oe(n)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",s=i.findIndex((e=>"color-ramp"===e.type)),r=-1!==s?i.splice(s,1)[0]:null,a=i.findIndex((e=>"size-ramp"===e.type)),o=-1!==a?i.splice(a,1)[0]:null,u=[];r&&(e=r.title,u.push(r)),o&&(e=o.title,u.push(o)),u.length>0&&i.push({type:t,title:e,infos:u})}else if(me(n)){const e=U(n);i.push({type:"heatmap-ramp",title:l,infos:e,preview:T(e.map((e=>e.color)),{effectList:this.effectList})})}else if(he(n)){const e=n&&n.authoringInfo;if(e&&"relationship"===e.type){const{focus:t,numClasses:l,field1:s,field2:o}=e;if(l&&s&&o){const e=[s,o];let u=B(t)||0;for(const t of e){const{field:e,normalizationField:l,label:s}=t,n=s||{field:this._getFieldAlias(e,r),normField:l&&this._getFieldAlias(l,r)},i=De.clone();i.angle=u,a.infos.push({label:n,symbol:i}),y.add(i),u+=90}const c=k({focus:t,numClasses:l,infos:n.uniqueValueInfos});i.unshift(c)}}else{const e=n.field;n.uniqueValueInfos.forEach((t=>{t.symbol&&a.infos.push({label:t.label||this._getDomainName(e,t.value,r)||t.value,value:t.value,symbol:t.symbol})}))}n.defaultSymbol&&(a.infos.push({label:n.defaultLabel||"others",symbol:n.defaultSymbol}),c=!0)}else if(ye(n)){o=this._isUnclassedRenderer(n);(!o||!this._hasSizeRamp)&&(n.classBreakInfos.forEach((e=>{e.symbol&&a.infos.unshift({label:e.label||(o?null:e.minValue+" - "+e.maxValue),value:[e.minValue,e.maxValue],symbol:e.symbol})})),o&&(a.title=null),this._updateInfosforClassedSizeRenderer(n,a.infos)),n.defaultSymbol&&!o&&(a.infos.push({label:n.defaultLabel||"others",symbol:n.defaultSymbol}),c=!0)}else if(ue(n))if(Te(this.layer)||ze(this.layer)){const e=this._constructTileImageryStretchRendererElements(n);xe(e)?i.push(e):a.infos=e}else{const e=this.layer;let t,l;n.statistics&&n.statistics.length&&(t=null!=n.statistics[0].min?n.statistics[0].min:n.statistics[0][0],l=null!=n.statistics[0].max?n.statistics[0].max:n.statistics[0][1]);let s=[];const r=u(e.renderingRule?await e.generateRasterInfo(e.renderingRule):e.serviceRasterInfo),o=r.keyProperties.BandProperties,c=re[e.rasterInfo.pixelType.toLowerCase()];1===r.bandCount||e.bandIds&&1===e.bandIds.length?(t=null!=t?t:r.statistics?r.statistics[e.bandIds[0]].min:c[0],l=null!=l?l:r.statistics?r.statistics[e.bandIds[0]].max:c[1],t||l?i.push(this._getStretchLegendElements(n,{min:t,max:l})):this._getServerSideLegend()):r.bandCount>=3?o&&o.length>=r.bandCount?e.bandIds&&3===e.bandIds.length?(s=e.bandIds.map((e=>o[e].BandName)),a.infos=this._createSymbolTableElementMultiBand(s)):"lerc"===e.format?(s=[0,1,2].map((e=>o[e].BandName)),a.infos=this._createSymbolTableElementMultiBand(s)):this._getServerSideLegend():"lerc"===e.format?(s=["band1","band2","band3"],a.infos=this._createSymbolTableElementMultiBand(s)):this._getServerSideLegend():this._getServerSideLegend()}else if(oe(n))n.colormapInfos.forEach((e=>{a.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(ie,e.color)})}));else if(de(n)){let e=n.symbol;switch(t.geometryType){case"point":e="pointSymbol"in r&&r.pointSymbol;break;case"polyline":e="lineSymbol"in r&&r.lineSymbol;break;case"polygon":e="polygonSymbol"in r&&r.polygonSymbol}n.symbol&&!this._hasSizeRamp&&a.infos.push({label:n.label,symbol:e})}else if(ae(n)){n.outputUnit&&(this.title="("+n.toJSON().outputUnit+")"),a.title=n.attributeField;const e=n.getClassBreakInfos();null!=e&&e.length?e.forEach((e=>{a.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})})):a.infos.push({label:n.attributeField,symbol:n.getDefaultSymbol()})}else ce(n)&&i.push(this._getStretchLegendElements(n,{min:0,max:255}));const h=n.defaultSymbol;!h||c||de(n)||o&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||i.push({type:"symbol-table",infos:[{label:n.defaultLabel||"others",symbol:h}]}),a.infos.length&&i.unshift(a);const m=null==t.opacity?this.opacity:t.opacity,p=this._isTallSymbol("visualVariables"in n&&n.visualVariables),f=Ve(this.layer)||Te(this.layer),g=i.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!(null==e||!e.symbol))).map((e=>this._getSymbolPreview(e,m,{isDefault:e.symbol===h,applyScaleDrivenSize:!y.has(e.symbol),symbolConfig:{isTall:p,isSquareFill:f},effectList:y.has(e.symbol)?null:this.effectList})));return n=null,await d(g),i}_getServerSideLegend(){setTimeout((()=>this.buildLegendElementsForTools()),0)}_getAllInfos(e){const t=null==e?void 0:e.infos;return t?t.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]):[e]}_constructTileImageryStretchRendererElements(e){var t,l;const s=this.layer,r=s.rasterInfo,n=r.bandCount||e.statistics.length;let i,a,o=[];const u=r.keyProperties&&r.keyProperties.BandProperties,c=null!=e&&null!=(t=e.statistics)&&t.length?e.statistics:null==r?void 0:r.statistics;if(c)i=void 0!==c[0].min?c[0].min:c[0][0],a=c[0].max||c[0][1];else{const e=re[s.rasterInfo.pixelType.toLowerCase()];i=e[0],a=e[1]}if(s.hasStandardTime()&&(i=s.getStandardTimeValue(i),a=s.getStandardTimeValue(a)),1===r.bandCount||1===(null==(l=s.bandIds)?void 0:l.length))return this._getStretchLegendElements(e,{min:i,max:a});function d(e){var t;const l=(null!=s&&null!=(t=s.bandIds)&&t.length?s.bandIds:Array.from(Array(Math.min(r.bandCount,3)).keys())).map((t=>e&&e[t]&&e[t].BandName||"band"+(t+1)));return l.length<3?l.push(l[1]):l.length>3&&l.splice(3),l}return o=u&&u.length>=n?d(u):d(),this._createSymbolTableElementMultiBand(o)}_getStretchLegendElements(e,t){const l=e.colorRamp,s=P(l,t);return{type:"stretch-ramp",title:"",infos:s,preview:T(s.map((e=>e.color)))}}_createSymbolTableElementMultiBand(e){const t=[],l=["red","green","blue"];return e.forEach(((e,s)=>{t.push({label:{colorName:l[s],bandName:e},src:J[s],opacity:1})})),t}_updateInfosforClassedSizeRenderer(e,t){const l=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,s=e.classBreakInfos.some((e=>j(e.symbol)));if(l&&s){const l=q,s=W,r=e.classBreakInfos.length,n=(l-s)/(r>1?r-1:r);t.forEach(((e,t)=>{e.size=l-n*t}))}}_isTallSymbol(e){let t=!1,l=!1;if(e)for(let s=0;s<e.length&&(!t||!l);s++){const r=e[s];"size"===r.type&&("height"===r.axis&&(t=!0),"width-and-depth"===r.axis&&(l=!0))}return t&&l}async _getSymbolPreview(e,t,l){let s=null!=l&&l.isDefault||null!=e.size||!this._hasSizeRamp?e.size:h(22);if(this._scaleDrivenSizeVariable&&null!=l&&l.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");s=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}return x(e.symbol,{size:s,opacity:t,scale:!1,symbolConfig:null==l?void 0:l.symbolConfig,effectView:null==l?void 0:l.effectList}).then((t=>(e.preview=t,e))).catch((()=>(e.preview=null,e)))}async _loadRenderer(e){var t,l;const s=[],r=this.layer;e=e.clone(),this._hasClusterSizeVariable=!1;const n="visualVariables"in e&&(null==(t=e.visualVariables)?void 0:t.some((e=>"size"===e.type&&"outline"!==e.target&&!le.test(e.valueExpression))));if(e&&"visualVariables"in e&&!n&&"featureReduction"in r&&"cluster"===(null==(l=r.featureReduction)?void 0:l.type)){const t=this.layerView._effectiveRenderer,l=u(O(t,this.view));if(l){const t=r.featureReduction;if("clusterMinSize"in t&&"clusterMaxSize"in t){const{clusterMinSize:e,clusterMaxSize:s}=t;l.legendOptions=new F({showLegend:e!==s})}const s=e.visualVariables||[];e.visualVariables=s.concat([l]),this._hasClusterSizeVariable=!0}}const i=await this._getMedianColor(e);if(ye(e)||he(e)){const t=(e.classBreakInfos||e.uniqueValueInfos).map((e=>this._fetchSymbol(e.symbol,i).then((t=>{e.symbol=t})).catch((()=>{e.symbol=null}))));Array.prototype.push.apply(s,t)}return s.push(this._fetchSymbol(e.symbol||e.defaultSymbol,e.defaultSymbol?null:i).then((t=>{this._applySymbolToRenderer(e,t,de(e))})).catch((()=>{this._applySymbolToRenderer(e,null,de(e))}))),d(s).then((()=>e))}_applySymbolToRenderer(e,t,l){l?e.symbol=t:e.defaultSymbol=t}async _getMedianColor(e){if(!("visualVariables"in e)||!e.visualVariables)return null;const t=e.visualVariables.find((e=>"color"===e.type));if(!t)return null;let l=null,s=null;if(t.stops){if(1===t.stops.length)return t.stops[0].color;l=t.stops[0].value,s=t.stops[t.stops.length-1].value}const r=l+(s-l)/2,{getColor:n}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");return n(t,r)}_fetchSymbol(e,t){if(!e)return Promise.reject();if("web-style"===e.type){const l=e.portal,s=l&&l.url,r=l&&l.user&&l.user.username,n=e.name+"-"+e.styleName+"-"+e.styleUrl+"-"+s+"-"+r,i=this._webStyleSymbolCache;return i.has(n)||("2d"===this.view.type?i.set(n,e.fetchCIMSymbol()):i.set(n,e.fetchSymbol())),i.get(n).then((e=>this._getAppliedCloneSymbol(e,t))).catch((()=>(K.warn("Fetching web-style failed!"),Promise.reject())))}return Promise.resolve(this._getAppliedCloneSymbol(e,t))}_getAppliedCloneSymbol(e,l){if(!e||!l)return e;const s=e.clone(),r=l&&l.toRgba();return s.type.indexOf("3d")>-1?this._applyColorTo3dSymbol(s,r):"cim"===s.type?R(s,l):s.color&&(s.color=new t(r||s.color)),s}_applyColorTo3dSymbol(e,l){l&&e.symbolLayers.forEach((e=>{e&&(e.material||(e.material={}),e.material.color=new t(l))}))}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||!e.visualVariables||"vector-field"===e.type)return null;const l=e.visualVariables,s=[],r=[],n=[];for(const c of l)"color"===c.type?s.push(c):"size"===c.type?r.push(c):"opacity"===c.type&&n.push(c);const i=[...s,...r,...n];let a,o;if(0===s.length&&ye(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];a=t&&t.symbol}if(0===s.length&&de(e)&&(a=e.symbol),a)if(a.type.indexOf("3d")>-1){const e=a.symbolLayers.getItemAt(0);"water"===e.type?c(e.color)&&(o=e.color):c(e.material)&&c(e.material.color)&&(o=e.material.color)}else a.url||(o=a.color);const u=this.effectList;return(await Promise.all(i.map((async l=>{if(!l.legendOptions||!1!==l.legendOptions.showLegend){const s=this._getRampTitle(l,t);let r=null;const n="getField"in t&&t.getField&&t.getField(l.field),i=n&&E(n);if("color"===l.type){const e=await A(l,null,i);r={type:"color-ramp",title:s,infos:e,preview:T(e.map((e=>e.color)),{effectList:u})},this._hasColorRamp||(this._hasColorRamp=!(null==r.infos||!r.infos.length))}else if("size"===l.type&&"outline"!==l.target)le.test(l.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=l):(r={type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(l):s,infos:await N(e,l,await this._getMedianColor(e),this.scale,this.view.type,i)},this._hasSizeRamp||(this._hasSizeRamp=!(null==r.infos||!r.infos.length)));else if("opacity"===l.type){const e=await A(l,o,i);r={type:"opacity-ramp",title:s,infos:e,preview:T(e.map((e=>e.color)),{effectList:u})},this._hasOpacityRamp||(this._hasOpacityRamp=!(null==r.infos||!r.infos.length))}return r&&r.infos?r:null}})))).filter((e=>!!e))}_getDomainName(e,t,l){if(e&&"function"!=typeof e){const s="getField"in l&&l.getField&&l.getField(e),r=s&&"getFieldDomain"in l&&l.getFieldDomain?l.getFieldDomain(s.name):null;return r&&"coded-value"===r.type?r.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,l=e.field;if("featureReduction"in t&&t.featureReduction&&"cluster"===t.featureReduction.type){const e=t.featureReduction,s="popupTemplate"in e&&e.popupTemplate,r=s&&s.fieldInfos;if(r)for(const t of r)if(t.fieldName===l)return"cluster_count"===l?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let l=e.field,s=e.normalizationField,r=!1,n=!1,i=!1,a=null;l="function"==typeof l?null:l,s="function"==typeof s?null:s;const o=e.legendOptions&&e.legendOptions.title;if(null!=o)a=o;else if(e.valueExpressionTitle)a=e.valueExpressionTitle;else{if("renderer"in t&&t.renderer&&"authoringInfo"in t.renderer&&t.renderer.authoringInfo&&t.renderer.authoringInfo.visualVariables){const e=t.renderer.authoringInfo.visualVariables;for(let t=0;t<e.length;t++){const l=e[t];if("color"===l.type){if("ratio"===l.style){r=!0;break}if("percent"===l.style){n=!0;break}if("percent-of-total"===l.style){i=!0;break}}}}a={field:l&&this._getFieldAlias(l,t),normField:s&&this._getFieldAlias(s,t),ratio:r,ratioPercent:n,ratioPercentTotal:i}}return a}_getRendererTitle(e,t){const l=e;if(l.legendOptions&&l.legendOptions.title)return l.legendOptions.title;if(l.valueExpressionTitle)return l.valueExpressionTitle;let s=l.field,r=null,n=null;ye(l)&&(r=l.normalizationField,n="percent-of-total"===l.normalizationType),s="function"==typeof s?null:s,r="function"==typeof r?null:r;let i=null;return(s||r)&&(i={field:s&&this._getFieldAlias(s,t),normField:r&&this._getFieldAlias(r,t),normByPct:n}),i}_getFieldAlias(e,t){const l="popupTemplate"in t&&t.popupTemplate,s=l&&l.fieldInfos;let r=null;s&&s.some((t=>e===t.fieldName&&(r=t,!0)));let n=null;"getField"in t&&t.getField?n=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(n=t.fieldsIndex.get(e));const i=r||n;let a=null;return i&&(a=r&&r.label||n&&n.alias||"name"in i&&i.name||"fieldName"in i&&i.fieldName),a}_isUnclassedRenderer(e){const t=e.visualVariables;let l=!1;return ye(e)&&e.classBreakInfos&&1===e.classBreakInfos.length&&t&&(l=e.field?t.some((t=>!(!t||e.field!==t.field||(e.normalizationField||t.normalizationField)&&e.normalizationField!==t.normalizationField))):!!t.length),l}};e([S()],Pe.prototype,"children",void 0),e([S({readOnly:!0})],Pe.prototype,"effectList",null),e([S()],Pe.prototype,"layerView",void 0),e([S()],Pe.prototype,"layer",void 0),e([S()],Pe.prototype,"legendElements",void 0),e([S({readOnly:!0})],Pe.prototype,"opacity",null),e([S()],Pe.prototype,"parent",void 0),e([S({readOnly:!0,dependsOn:[]})],Pe.prototype,"ready",null),e([S()],Pe.prototype,"hideLayersNotInCurrentView",void 0),e([S()],Pe.prototype,"keepCacheOnDestroy",void 0),e([S()],Pe.prototype,"respectLayerVisibility",void 0),e([S({readOnly:!0})],Pe.prototype,"scale",null),e([S()],Pe.prototype,"sublayerIds",void 0),e([S({readOnly:!0})],Pe.prototype,"isScaleDriven",null),e([S()],Pe.prototype,"title",void 0),e([S({readOnly:!0,dependsOn:["ready"],value:0})],Pe.prototype,"version",null),e([S()],Pe.prototype,"view",void 0),Pe=e([_("esri.widgets.Legend.support.ActiveLayerInfo")],Pe);const Ae=Pe;export{Ae as default};