@arcgis/core 4.26.0-next.20230113 → 4.26.0-next.20230115

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 (47) hide show
  1. package/WebMap.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/05679a6529421d546fe0.js +1 -0
  5. package/assets/esri/core/workers/chunks/2e5b61ee21fa6287cc65.js +1 -0
  6. package/assets/esri/core/workers/chunks/2e7e8b035673d90deefd.js +1 -0
  7. package/assets/esri/core/workers/chunks/4e13f84441f0b149f32e.js +1 -0
  8. package/assets/esri/core/workers/chunks/5605de870cfc1498a393.js +1 -0
  9. package/assets/esri/core/workers/chunks/5ad3a3d15831b759e758.js +1 -0
  10. package/assets/esri/core/workers/chunks/633a86e8e8ad2ab866f4.js +1 -0
  11. package/assets/esri/core/workers/chunks/86491e6269e25b1766ed.js +1 -0
  12. package/assets/esri/core/workers/chunks/c3fda4056c5eeaef1339.js +1 -0
  13. package/assets/esri/core/workers/chunks/{399c453397a1f10408bf.js → c7b23f664a2707b96daf.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{dd2e9206133d6888f33d.js → dc6bad8c0a09393834a1.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{bc3564689bd42cba97f9.js → f34c607e73757f6024eb.js} +1 -1
  16. package/core/accessorSupport/decorators/persistable.js +1 -1
  17. package/core/accessorSupport/write.js +1 -1
  18. package/layers/mixins/ArcGISImageService.js +1 -1
  19. package/layers/mixins/ImageryTileMixin.js +1 -1
  20. package/layers/mixins/SceneService.js +1 -1
  21. package/layers/support/PixelBlock.js +1 -1
  22. package/layers/support/imageryRendererUtils.js +1 -1
  23. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  24. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  25. package/layers/support/rasterDatasets/multidimensionalUtils.js +1 -1
  26. package/layers/support/rasterFormats/Lerc.js +1 -1
  27. package/layers/support/rasterFormats/RasterCodec.js +1 -1
  28. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  29. package/layers/support/rasterFormats/pixelRangeUtils.js +5 -0
  30. package/layers/support/rasterFunctions/ConvolutionFunction.js +1 -1
  31. package/layers/support/rasterFunctions/stretchUtils.js +1 -1
  32. package/package.json +1 -1
  33. package/renderers/support/rasterRendererHelper.js +1 -1
  34. package/support/revision.js +1 -1
  35. package/views/2d/engine/Stage.js +1 -1
  36. package/views/MapView.js +1 -1
  37. package/widgets/FeatureTable/FieldColumn.js +1 -1
  38. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  39. package/assets/esri/core/workers/chunks/1363e647f3b0bca07e09.js +0 -1
  40. package/assets/esri/core/workers/chunks/2541edeae4b1a53b8723.js +0 -1
  41. package/assets/esri/core/workers/chunks/3b689bb038ebc301c3b2.js +0 -1
  42. package/assets/esri/core/workers/chunks/6216cd8134703fd9d9b4.js +0 -1
  43. package/assets/esri/core/workers/chunks/64f137358100a1c818f0.js +0 -1
  44. package/assets/esri/core/workers/chunks/6fba07833345b2d8d373.js +0 -1
  45. package/assets/esri/core/workers/chunks/78fd609f334a29ef39dc.js +0 -1
  46. package/assets/esri/core/workers/chunks/798cd875d64182741364.js +0 -1
  47. package/assets/esri/core/workers/chunks/8bd26c71e78698c16778.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";import{on as t}from"../../../core/events.js";import has from"../../../core/has.js";import{unwrap as r,removeMaybe as s}from"../../../core/maybe.js";import{watch as i,initial as n}from"../../../core/reactiveUtils.js";import{addFrameTask as a}from"../../../core/scheduling.js";import{c as o}from"../../../chunks/mat3f32.js";import h from"../../../symbols/cim/CIMResourceManager.js";import{Container as d}from"./Container.js";import{BufferPool as l}from"./webgl/BufferPool.js";import{WGLDrawPhase as p}from"./webgl/enums.js";import c from"./webgl/Painter.js";import{Profiler as u}from"./webgl/Profiler.js";import{Timeline as m}from"../support/Timeline.js";import{resampleHermite as f}from"../../support/screenshotUtils.js";import{createContextOrErrorHTML as g}from"../../webgl/context-util.js";import{TargetType as _,DepthStencilTargetType as b,PixelFormat as w,PixelType as R}from"../../webgl/enums.js";import{FramebufferObject as y}from"../../webgl/FramebufferObject.js";import{RenderingContext as x}from"../../webgl/RenderingContext.js";import{createEmptyImageData as O}from"../../../core/imageUtils.js";const P=2e3;class T extends d{constructor(s,i){super(),this._trash=new Set,this._renderRemainingTime=0,this._lastFrameRenderTime=0,this.renderRequested=!1,this.stage=this,this._stationary=!0;const{canvas:n=document.createElement("canvas"),alpha:o=!0,stencil:d=!0,contextOptions:p={}}=i;this._canvas=n;const f=g("2d",n,{alpha:o,antialias:!1,depth:!0,stencil:d});this.context=new x(r(f)??null,p),this.resourceManager=new h,this.painter=new c(this.context,this,this.resourceManager),has("esri-2d-profiler")&&(this._debugOutput=document.createElement("div"),this._debugOutput.setAttribute("style","margin: 24px 64px; position: absolute; color: red;"),s.appendChild(this._debugOutput)),this._renderParameters={drawPhase:0,state:this.state,pixelRatio:window.devicePixelRatio,stationary:!1,globalOpacity:1,blendMode:null,deltaTime:-1,time:0,inFadeTransition:!1,effects:null,context:this.context,painter:this.painter,timeline:i.timeline||new m,renderingOptions:i.renderingOptions,requestRender:()=>this.requestRender(),allowDelayedRender:!1,requireFBO:!1,profiler:new u(this.context,this._debugOutput),dataUploadCounter:0},this._taskHandle=a({render:e=>this.renderFrame(e)}),this._taskHandle.pause(),this._lostWebGLContextHandle=t(n,"webglcontextlost",(()=>{this.emit("webgl-error",{error:new e("webgl-context-lost")})})),this._bufferPool=new l,n.setAttribute("style","width: 100%; height:100%; display:block;"),s.appendChild(n)}destroy(){this.removeAllChildren(),this._emptyTrash(),this._taskHandle=s(this._taskHandle),this._lostWebGLContextHandle=s(this._lostWebGLContextHandle),this._canvas.parentNode?.removeChild(this._canvas),this._debugOutput?.parentNode?.removeChild(this._debugOutput),this._bufferPool.destroy(),this.highlightOptions=null,this.resourceManager.destroy(),this.painter.dispose(),this.context.dispose(),this._canvas=null}get background(){return this._background}set background(e){this._background=e,this.requestRender()}get bufferPool(){return this._bufferPool}get highlightOptions(){return this._highlightOptions}set highlightOptions(e){this._highlightOptionsHandle=s(this._highlightOptionsHandle),this._highlightOptions=e,e&&(this._highlightOptionsHandle=i((()=>this._highlightOptions?.version),(()=>{this.painter.setHighlightOptions(e),this.requestRender()}),n))}get renderingOptions(){return this._renderingOptions}set renderingOptions(e){this._renderingOptions=e,this.requestRender()}get state(){return this._state}set state(e){this._state=e,this.requestRender()}get stationary(){return this._stationary}set stationary(e){this._stationary!==e&&(this._stationary=e,this.requestRender())}trashDisplayObject(e){this._trash.add(e),this.requestRender()}untrashDisplayObject(e){return this._trash.delete(e)}requestRender(){this._renderRemainingTime=P,this.renderRequested||(this.renderRequested=!0,this.emit("will-render"),this._taskHandle.resume())}renderFrame(e){const t=this._lastFrameRenderTime?e.time-this._lastFrameRenderTime:0;this._renderRemainingTime-=t,this._renderRemainingTime<=0&&this._taskHandle.pause(),this._lastFrameRenderTime=e.time,this.renderRequested=!1,this._renderParameters.state=this._state,this._renderParameters.stationary=this.stationary,this._renderParameters.pixelRatio=window.devicePixelRatio,this._renderParameters.globalOpacity=1,this._renderParameters.time=e.time,this._renderParameters.deltaTime=e.deltaTime,this._renderParameters.effects=null,this.processRender(this._renderParameters),this._emptyTrash(),this.emit("post-render")}_createTransforms(){return{dvs:o()}}renderChildren(e){for(const t of this.children)t.beforeRender(e);this._renderChildren(this.children,e);for(const t of this.children)t.afterRender(e)}_renderChildren(e,t){const r=this.context;this.painter.textureUploadManager.upload(),r.resetInfo(),t.profiler.recordStart("drawLayers"),t.dataUploadCounter=0,t.drawPhase=p.MAP,this.painter.beforeRenderLayers(r,this.background);for(const s of e)s.processRender(t);this.painter.prepareDisplay(t,this.background,this.state.padding),this.painter.renderLayers(r),t.drawPhase=p.HIGHLIGHT,this.painter.beforeRenderLayers(r);for(const s of e)s.processRender(t);this.painter.renderLayers(r);if(this._isLabelDrawPhaseRequired(e)){t.drawPhase=p.LABEL,this.painter.beforeRenderLayers(r);for(const r of e)r.processRender(t);this.painter.renderLayers(r)}if(has("esri-tiles-debug")){t.drawPhase=p.DEBUG,this.painter.beforeRenderLayers(r);for(const r of e)r.processRender(t);this.painter.renderLayers(r)}t.profiler.recordEnd("drawLayers"),r.logInfo()}doRender(e){const t=this.context,{state:r,pixelRatio:s}=e;this._resizeCanvas(e),t.setViewport(0,0,s*r.size[0],s*r.size[1]),t.setDepthWriteEnabled(!0),t.setStencilWriteMask(255),super.doRender(e)}async takeScreenshot(e){const{framebufferWidth:t,framebufferHeight:r}={framebufferWidth:Math.round(this.state.size[0]*e.resolutionScale),framebufferHeight:Math.round(this.state.size[1]*e.resolutionScale)},s=1,i=this.context,n=this._state.clone();if(null!=e.rotation){const t=n.viewpoint;n.viewpoint.rotation=e.rotation,n.viewpoint=t}const a={...this._renderParameters,drawPhase:null,globalOpacity:1,stationary:!0,state:n,pixelRatio:s,time:performance.now(),deltaTime:0,blendMode:null,effects:null,inFadeTransition:!1},o=new y(i,{colorTarget:_.TEXTURE,depthStencilTarget:b.DEPTH_STENCIL_RENDER_BUFFER,width:t,height:r}),h=i.getBoundFramebufferObject(),d=i.getViewport();i.bindFramebuffer(o),i.setViewport(0,0,t,r),this._renderChildren(e.children,a);const l=this._readbackScreenshot(o,{...e.cropArea,y:r-(e.cropArea.y+e.cropArea.height)});i.bindFramebuffer(h),i.setViewport(d.x,d.y,d.width,d.height),this.requestRender();const p=await l;let c;return 1===e.outputScale?c=p:(c=new ImageData(Math.round(p.width*e.outputScale),Math.round(p.height*e.outputScale)),f(p,c,!0)),c}async _readbackScreenshot(e,t){const r=O(t.width,t.height,document.createElement("canvas"));return await e.readPixelsAsync(t.x,t.y,t.width,t.height,w.RGBA,R.UNSIGNED_BYTE,new Uint8Array(r.data.buffer)),r}_resizeCanvas(e){const t=this._canvas,r=t.style,{state:{size:s},pixelRatio:i}=e,n=s[0],a=s[1],o=Math.round(n*i),h=Math.round(a*i);t.width===o&&t.height===h||(t.width=o,t.height=h),r.width=n+"px",r.height=a+"px"}_emptyTrash(){for(;this._trash.size>0;){const e=Array.from(this._trash);this._trash.clear();for(const t of e)t.processDetach()}}_isLabelDrawPhaseRequired(e){let t=!1;for(const r of e){if(!(r instanceof d)){t=t||!1;break}if(r.hasLabels)return!0;t=t||this._isLabelDrawPhaseRequired(r.children)}return t}}export{P as EXTRA_RENDER_TIME,T as Stage};
5
+ import e from"../../../core/Error.js";import{on as t}from"../../../core/events.js";import has from"../../../core/has.js";import{unwrap as r,removeMaybe as s}from"../../../core/maybe.js";import{watch as i,initial as n}from"../../../core/reactiveUtils.js";import{addFrameTask as a}from"../../../core/scheduling.js";import{c as o}from"../../../chunks/mat3f32.js";import h from"../../../symbols/cim/CIMResourceManager.js";import{Container as d}from"./Container.js";import{BufferPool as l}from"./webgl/BufferPool.js";import{WGLDrawPhase as p}from"./webgl/enums.js";import c from"./webgl/Painter.js";import{Profiler as u}from"./webgl/Profiler.js";import{Timeline as m}from"../support/Timeline.js";import{resampleHermite as f}from"../../support/screenshotUtils.js";import{createContextOrErrorHTML as g}from"../../webgl/context-util.js";import{TargetType as _,DepthStencilTargetType as b,PixelFormat as w,PixelType as R}from"../../webgl/enums.js";import{FramebufferObject as y}from"../../webgl/FramebufferObject.js";import{RenderingContext as x}from"../../webgl/RenderingContext.js";import{createEmptyImageData as O}from"../../../core/imageUtils.js";const P=2e3;class T extends d{constructor(s,i){super(),this._trash=new Set,this._renderRemainingTime=0,this._lastFrameRenderTime=0,this.renderRequested=!1,this.stage=this,this._stationary=!0;const{canvas:n=document.createElement("canvas"),alpha:o=!0,stencil:d=!0,contextOptions:p={}}=i;this._canvas=n;const f=g("2d",n,{alpha:o,antialias:!1,depth:!0,stencil:d});this.context=new x(r(f)??null,p),this.resourceManager=new h,this.painter=new c(this.context,this,this.resourceManager),has("esri-2d-profiler")&&(this._debugOutput=document.createElement("div"),this._debugOutput.setAttribute("style","margin: 24px 64px; position: absolute; color: red;"),s.appendChild(this._debugOutput)),this._renderParameters={drawPhase:0,state:this.state,pixelRatio:window.devicePixelRatio,stationary:!1,globalOpacity:1,blendMode:null,deltaTime:-1,time:0,inFadeTransition:!1,effects:null,context:this.context,painter:this.painter,timeline:i.timeline||new m,renderingOptions:i.renderingOptions,requestRender:()=>this.requestRender(),allowDelayedRender:!1,requireFBO:!1,profiler:new u(this.context,this._debugOutput),dataUploadCounter:0},this._taskHandle=a({render:e=>this.renderFrame(e)}),this._taskHandle.pause(),this._lostWebGLContextHandle=t(n,"webglcontextlost",(()=>{this.emit("webgl-error",{error:new e("webgl-context-lost")})})),this._bufferPool=new l,n.setAttribute("style","width: 100%; height:100%; display:block;"),s.appendChild(n)}destroy(){this.removeAllChildren(),this._emptyTrash(),this._taskHandle=s(this._taskHandle),this._lostWebGLContextHandle=s(this._lostWebGLContextHandle),this._canvas.parentNode?.removeChild(this._canvas),this._debugOutput?.parentNode?.removeChild(this._debugOutput),this._bufferPool.destroy(),this.highlightOptions=null,this.resourceManager.destroy(),this.painter.dispose(),this.context.dispose(),this._canvas=null}get background(){return this._background}set background(e){this._background=e,this.requestRender()}get bufferPool(){return this._bufferPool}get highlightOptions(){return this._highlightOptions}set highlightOptions(e){this._highlightOptionsHandle=s(this._highlightOptionsHandle),this._highlightOptions=e,e&&(this._highlightOptionsHandle=i((()=>this._highlightOptions?.version),(()=>{this.painter.setHighlightOptions(e),this.requestRender()}),n))}get renderingOptions(){return this._renderingOptions}set renderingOptions(e){this._renderingOptions=e,this.requestRender()}get state(){return this._state}set state(e){this._state=e,this.requestRender()}get stationary(){return this._stationary}set stationary(e){this._stationary!==e&&(this._stationary=e,this.requestRender())}trashDisplayObject(e){this._trash.add(e),this.requestRender()}untrashDisplayObject(e){return this._trash.delete(e)}requestRender(){this._renderRemainingTime=P,this.renderRequested||(this.renderRequested=!0,this.emit("will-render"),this._taskHandle.resume())}renderFrame(e){const t=this._lastFrameRenderTime?e.time-this._lastFrameRenderTime:0;this._renderRemainingTime-=t,this._renderRemainingTime<=0&&this._taskHandle.pause(),this._lastFrameRenderTime=e.time,this.renderRequested=!1,this._renderParameters.state=this._state,this._renderParameters.stationary=this.stationary,this._renderParameters.pixelRatio=window.devicePixelRatio,this._renderParameters.globalOpacity=1,this._renderParameters.time=e.time,this._renderParameters.deltaTime=e.deltaTime,this._renderParameters.effects=null,this.processRender(this._renderParameters),this._emptyTrash(),this.emit("post-render")}_createTransforms(){return{dvs:o()}}renderChildren(e){for(const t of this.children)t.beforeRender(e);this._renderChildren(this.children,e);for(const t of this.children)t.afterRender(e)}_renderChildren(e,t){const r=this.context;this.painter.textureUploadManager.upload(),r.resetInfo(),t.profiler.recordStart("drawLayers"),t.dataUploadCounter=0,t.drawPhase=p.MAP,this.painter.beforeRenderLayers(r,this.background);for(const s of e)s.processRender(t);this.painter.prepareDisplay(t,this.background,this.state.padding),this.painter.renderLayers(r),t.drawPhase=p.HIGHLIGHT,this.painter.beforeRenderLayers(r);for(const s of e)s.processRender(t);this.painter.renderLayers(r);if(this._isLabelDrawPhaseRequired(e)){t.drawPhase=p.LABEL,this.painter.beforeRenderLayers(r);for(const r of e)r.processRender(t);this.painter.renderLayers(r)}if(has("esri-tiles-debug")){t.drawPhase=p.DEBUG,this.painter.beforeRenderLayers(r);for(const r of e)r.processRender(t);this.painter.renderLayers(r)}t.profiler.recordEnd("drawLayers"),r.logInfo()}doRender(e){const t=this.context,{state:r,pixelRatio:s}=e;this._resizeCanvas(e),t.setViewport(0,0,s*r.size[0],s*r.size[1]),t.setDepthWriteEnabled(!0),t.setStencilWriteMask(255),super.doRender(e)}async takeScreenshot(e){const{framebufferWidth:t,framebufferHeight:r}={framebufferWidth:Math.round(this.state.size[0]*e.resolutionScale),framebufferHeight:Math.round(this.state.size[1]*e.resolutionScale)},s=e.resolutionScale,i=this.context,n=this._state.clone();if(null!=e.rotation){const t=n.viewpoint;n.viewpoint.rotation=e.rotation,n.viewpoint=t}const a={...this._renderParameters,drawPhase:null,globalOpacity:1,stationary:!0,state:n,pixelRatio:s,time:performance.now(),deltaTime:0,blendMode:null,effects:null,inFadeTransition:!1},o=new y(i,{colorTarget:_.TEXTURE,depthStencilTarget:b.DEPTH_STENCIL_RENDER_BUFFER,width:t,height:r}),h=i.getBoundFramebufferObject(),d=i.getViewport();i.bindFramebuffer(o),i.setViewport(0,0,t,r),this._renderChildren(e.children,a);const l=this._readbackScreenshot(o,{...e.cropArea,y:r-(e.cropArea.y+e.cropArea.height)});i.bindFramebuffer(h),i.setViewport(d.x,d.y,d.width,d.height),this.requestRender();const p=await l;let c;return 1===e.outputScale?c=p:(c=new ImageData(Math.round(p.width*e.outputScale),Math.round(p.height*e.outputScale)),f(p,c,!0)),c}async _readbackScreenshot(e,t){const r=O(t.width,t.height,document.createElement("canvas"));return await e.readPixelsAsync(t.x,t.y,t.width,t.height,w.RGBA,R.UNSIGNED_BYTE,new Uint8Array(r.data.buffer)),r}_resizeCanvas(e){const t=this._canvas,r=t.style,{state:{size:s},pixelRatio:i}=e,n=s[0],a=s[1],o=Math.round(n*i),h=Math.round(a*i);t.width===o&&t.height===h||(t.width=o,t.height=h),r.width=n+"px",r.height=a+"px"}_emptyTrash(){for(;this._trash.size>0;){const e=Array.from(this._trash);this._trash.clear();for(const t of e)t.processDetach()}}_isLabelDrawPhaseRequired(e){let t=!1;for(const r of e){if(!(r instanceof d)){t=t||!1;break}if(r.hasLabels)return!0;t=t||this._isLabelDrawPhaseRequired(r.children)}return t}}export{P as EXTRA_RENDER_TIME,T as Stage};
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.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import i from"../Viewpoint.js";import s from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import n from"../core/Error.js";import has from"../core/has.js";import{isIterable as a}from"../core/iteratorUtils.js";import o from"../core/Logger.js";import{isSome as l,unwrap as p,isNone as h}from"../core/maybe.js";import{throwIfAborted as c}from"../core/promiseUtils.js";import{watch as d,whenOnce as u,sync as g,syncAndInitial as m}from"../core/reactiveUtils.js";import{createScreenPoint as y}from"../core/screenUtils.js";import w from"../core/Warning.js";import{initialize as f}from"../core/workers/workers.js";import{property as _}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{subclass as v}from"../core/accessorSupport/decorators/subclass.js";import V from"../geometry/Extent.js";import S from"../geometry/Point.js";import{load as T,canProjectWithoutEngine as j,project as b,isLoaded as M}from"../geometry/projection.js";import{equals as R}from"../geometry/support/spatialReferenceUtils.js";import x from"../layers/support/TileInfo.js";import{BreakpointsOwner as L}from"./BreakpointsOwner.js";import{DOMContainer as O}from"./DOMContainer.js";import{PopupView as k}from"./PopupView.js";import C from"./View.js";import z from"./ViewAnimation.js";import P from"./2d/AnimationManager.js";import E from"./2d/FrameTask.js";import{layerView2DImporter as G}from"./2d/layerViewModuleImportUtils.js";import N from"./2d/MapViewConstraints.js";import q from"./2d/PaddedViewState.js";import"./2d/tiling/PagedTileQueue.js";import D from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{centerAt as U,setExtent as A,rotateTo as F,scaleTo as I,copy as W,create as $,extentToScale as B,resize as H,angleBetween as J}from"./2d/viewpointUtils.js";import Q from"./2d/input/MapViewInputManager.js";import Z from"./2d/layers/features/support/TileStore.js";import K from"./2d/support/HighlightOptions.js";import{Timeline as Y}from"./2d/support/Timeline.js";import X from"./support/createScreenshotPlan.js";import{encode as ee,encodeData as te,getMaximumResolutionScale as ie,getFormatAndQuality as se}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as re,createScreenPointFromSupportedEvent as ne}from"./support/screenUtils.js";import{check as ae}from"./support/WebGLRequirements.js";import oe from"./ui/2d/DefaultUI2D.js";import le from"../webmap/background/ColorBackground.js";let pe,he,ce,de,ue,ge;async function me(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:s,MagnifierView2D:r,Stage:n}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);he=e,ce=t,de=i,ue=s,ge=r,pe=n}const ye=160;function we(e){return e&&"esri.Viewpoint"===e.declaredClass}let fe=class extends(L(O(k(C)))){constructor(e){super(e),this._magnifierView=null,this._stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.fullOpacity=1,this.graphicsView=null,this.labelManager=null,this.mapViewNavigation=null,this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.rendering=!1,this.supersampleScreenshotsEnabled=!1,this.supportsGround=!1,this._stationaryTimer=null,this._gotoTask=null,this.frameTask=new E(this),this._pePromise=null,this.floors=new s,this.highlightOptions=new K,this.inputManager=new Q({view:this}),this.map=null,this.resizeAlign="center",this.spatialReferenceLocked=!1,this.timeline=new Y,this.type="2d",this.ui=new oe,this._pixelFormat={flipY:!0,premultipliedAlpha:!0},this.constraints=new N,this.padding={top:0,right:0,bottom:0,left:0},this.handles.add([d((()=>this.viewpoint),(()=>{this._lastStationaryEventTimestamp=performance.now(),this._flipStationary(ye)}),g),this.on("resize",(e=>this._resizeHandler(e))),d((()=>this.animationManager?.animation),(e=>{this.animation=e}))]),f()}destroy(){this._set("preconditionsReady",!1),this._gotoTask=this.frameTask=null,this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new Z(this.featuresTilingScheme)}get initialExtentRequired(){const{scale:e,constraints:t,center:i,viewpoint:s,extent:r}=this;let n=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!r&&(t?.effectiveLODs||(n=-1),(!i||0===e&&-1===n)&&(!s||!l(s.targetGeometry)||"extent"!==s.targetGeometry.type&&!s.scale)))}get resourceManager(){return this._stage.resourceManager}get textureManager(){return this._stage.painter.textureManager}get _defaultsFromMapSettings(){return{required:{tileInfo:!0,heightModelInfo:!1,extent:!1},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get _projectionEngineLoaded(){return!!M()||(this._pePromise||(this._pePromise=T().finally((()=>{this._pePromise=null}))),!1)}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=this.spatialReference,i=p(e.targetGeometry);return!!j(i.spatialReference,t)||this._projectionEngineLoaded}set animation(e){const t=this._get("animation");if(e===t)return;if(t&&t.stop(),!e||e.isFulfilled())return void this._set("animation",null);this._set("animation",e),this.frameTask.animationInProgress=!0;const i=()=>{e===this._get("animation")&&(this._set("animation",null),this.frameTask?.requestFrame()),this.frameTask&&(this.frameTask.animationInProgress=!1)};e.when(i,i)}get background(){return Te(this.map)?this.map.initialViewProperties.background:null}set background(e){this._override("background",e)}get center(){if(!this.ready)return this._get("center");const{center:e,spatialReference:t}=this.state.paddedViewState;return new S({x:e[0],y:e[1],spatialReference:t})}set center(e){if(null==e)return;if(!this.ready)return this._set("center",e),void this.notifyChange("initialExtentRequired");let t;try{t=this._project(e,this.spatialReference)}catch(s){return void o.getLogger(this.declaredClass).error(new n("mapview:invalid-center","could not project the value in the view's spatial reference",{input:e,error:s}))}const i=this.viewpoint;U(i,i,t),this.viewpoint=i}set constraints(e){const t=this._get("constraints");t&&(this.handles.remove("map-view-constraints"),t.destroy()),this._set("constraints",e),e&&(e.view=this,this.ready&&(this.state.viewpoint=e.fit(this.state.paddedViewState.viewpoint)),this.handles.add(d((()=>e.version),(()=>{this.ready&&this.state&&(this.state.viewpoint=e.fit(this.state.paddedViewState.viewpoint))}),g),"map-view-constraints"))}get extent(){return this.ready?this.state.paddedViewState.extent.clone():this._get("extent")}set extent(e){if(null==e)return;if(!e.width||!e.height)return void o.getLogger(this.declaredClass).error(new n("mapview:invalid-extent","invalid extent size"));if(!this.ready)return this._set("extent",e),this._set("center",null),this._set("viewpoint",null),this._set("scale",0),this._set("zoom",-1),void this.notifyChange("initialExtentRequired");let t;try{t=this._project(e,this.spatialReference)}catch(s){return void o.getLogger(this.declaredClass).error(new n("mapview:invalid-extent","could not project the value in the view's spatial reference",{error:s}))}const i=this.viewpoint;A(i,i,t,this.size,{constraints:this.constraints}),this.viewpoint=i}get padding(){return this.ready?this.state.padding:this._get("padding")}set padding(e){this.ready?(this.state.padding=e,this._set("padding",this.state.padding)):this._set("padding",e)}get resolution(){return this.state?this.state.resolution:0}get rotation(){return this.ready?this.state.rotation:this._get("rotation")}set rotation(e){if(isNaN(e))return;if(!this.ready)return void this._set("rotation",e);const t=this.viewpoint;F(t,t,e),this.viewpoint=t}get scale(){return this.ready?this.state.scale:this._get("scale")}set scale(e){if(!e||isNaN(e))return;if(!this.ready){this._set("scale",e),this._set("zoom",-1);const t=this._get("extent");return t&&(this._set("extent",null),this._set("center",t.center)),void this.notifyChange("initialExtentRequired")}const t=this.viewpoint;I(t,t,e),this.viewpoint=t}get stationary(){return!(this.animation||this.navigating||this.resizing||this._stationaryTimer)}get updating(){const e=!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some((e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)));if(has("esri-2d-log-updating")){const t=this.allLayerViews.reduce(((e,t)=>({...e,[t.layer.id]:!t.destroyed&&!("layerViews"in t)&&t.updating})),{});console.log(`Updating MapView: ${e}\n-> Null LayerViewManager: ${!this.layerViewManager}\n-> Null LabelManager: ${!this.labelManager}\n-> Null GraphicsView: ${!this.graphicsView}\n-> layerViewManager.updating: ${this.layerViewManager?.updating}\n-> labelManager.updating: ${this.labelManager?.updating}\n-> graphicsView.updating: ${this.graphicsView?.updating}\n-> allLayerViews: ${JSON.stringify(t)}\n`)}return e}get viewpoint(){if(!this.ready)return this._get("viewpoint");const e=this.state.paddedViewState;return e&&e.viewpoint.clone()}set viewpoint(e){if(null==e)return;if(!this.ready)return this._set("viewpoint",e),this._set("extent",null),this._set("center",null),this._set("zoom",-1),this._set("scale",0),void this.notifyChange("initialExtentRequired");let t,s;try{t=this._project(e,this.spatialReference),!e.scale||isNaN(e.scale)?s=new n("mapview:invalid-viewpoint",`invalid scale value of ${e.scale}`):h(e.targetGeometry)&&(s=new n("mapview:invalid-viewpoint","geometry not defined"))}catch(a){s=new n("mapview:invalid-viewpoint","could not project the value in the view's spatial reference",{error:a})}if(s)return void o.getLogger(this.declaredClass).error(s);this._scaleBeforeChangingSpatialReference=null;const r=new i({targetGeometry:new S,scale:0,rotation:0});W(r,t),this.constraints.constrain(r,this.state.paddedViewState.viewpoint),this.state.viewpoint=r,this.frameTask.requestFrame(),this._set("viewpoint",r)}get zoom(){return this.ready?this.constraints.scaleToZoom(this.scale):this._get("zoom")}set zoom(e){if(null==e)return;if(!this.ready){this._set("zoom",e),this._set("scale",0);const t=this._get("extent");return t&&(this._set("extent",null),this._set("center",t.center)),void this.notifyChange("initialExtentRequired")}if(!this.constraints.effectiveLODs)return void this._set("zoom",-1);const t=this.viewpoint;I(t,t,this.constraints.zoomToScale(e)),this.viewpoint=t,this._set("zoom",this.constraints.scaleToZoom(this.scale))}get navigating(){return!(!this.mapViewNavigation||!this.mapViewNavigation.interacting)}goTo(e,t){if(e)return this.animation&&(this.animation=null),this._createAnimation(),u((()=>this.ready),t).then((()=>{const i={animate:!0,...t},s=$(e,this);return this.animation?.update(s),this._gotoTask={},i.animate?this._gotoAnimated(s,i):this._gotoImmediate(s,i)}));o.getLogger(this.declaredClass).error("#goTo()","target cannot be null or undefined")}async hitTest(e,t){const i=re(e)?ne(this,e):e;if(!this.ready||isNaN(i.x)||isNaN(i.y))return{screenPoint:i,results:[]};let s=new Set,r=!1,n=null,a=null;t?.include?Se(t.include,Ve(this,(e=>s.add(e)),(e=>{n||(n=new Set),n.add(e)}),(e=>s.add(e)),(()=>r=!0))):(r=!0,s=new Set(this.allLayerViews)),t?.exclude&&Se(t.exclude,Ve(this,(e=>s.delete(e)),(e=>{a||(a=new Set),a.add(e)})));const o=this.allLayerViews.filter((e=>!e.suspended&&s.has(e))).reverse(),p=this.toMap(i);let h=[...r?this.graphicsView.hitTest(p).map((e=>({type:"graphic",graphic:e,layer:null,mapPoint:p}))):[],...await Promise.all(o.map((e=>e.hitTest(p,i))).toArray())].filter(l).flat().filter(l);return n&&(h=h.filter((e=>!("graphic"in e)||!e.graphic||n?.has(ve(e.graphic))))),a&&(h=h.filter((e=>!("graphic"in e)||!e.graphic||a?.has(ve(e.graphic))))),{screenPoint:i,results:h}}async takeScreenshot(e){const t=this._createScreenshotPlan(e),i=await this._stage.takeScreenshot(t);return ee(i,{format:t.format,quality:t.quality,rotation:0,disableDecorations:!1},this._pixelFormat)}async _takeScreenshot(e){const t=this._createScreenshotPlan(e),i=await this._stage.takeScreenshot(t);return te(i,this._pixelFormat)}_createScreenshotPlan(e){e=e??{};const t=this.supersampleScreenshotsEnabled?Math.min(4,ie(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:s,quality:r}=se(e.format,e.quality);return X(e,t,this.size,this.padding,s,r,i,e.rotation)}get test(){return{takeScreenshot:e=>this._takeScreenshot(e)}}toMap(e){if(!this.ready)return null;const t=re(e)?ne(this,e):e,i=[0,0],[s,r]=this.state.toMap(i,[t.x,t.y]),n=this.spatialReference;return new S({x:s,y:r,spatialReference:n})}toScreen(e){if(!this.ready)return null;const t=this._project(e,this.spatialReference),i=[t.x,t.y];return this.state.toScreen(i,i),y(i[0],i[1])}on(e,t,i,s){const r=this.inputManager&&this.viewEvents.on(e,t,i,s);return r||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()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map?.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||null}hasLayerViewModule(e){return G.hasLayerViewModule(e)}importLayerView(e){return G.importLayerView(e)}pixelSizeAt(){return this.ready?this.state.resolution:(o.getLogger(this.declaredClass).error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}popupHitTest(e){return this.hitTest(e).then((t=>({...t,mapPoint:this.toMap(e)})))}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}validate(){let e=ae(this.type);return has("safari")&&has("safari")<9&&(e=new n("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:has("safari")})),l(e)?(o.getLogger(this.declaredClass).warn("#validate()",e.message),Promise.reject(e)):me()}_createAnimation(){return this.animation&&!this.animation.done||(this.animation=new z),this.animation}_cancellableGoTo(e,t,i){const s=()=>e===this._gotoTask,r=i.then((()=>{s()&&(this.animation=null)})).catch((e=>{throw s()&&(this.animation=null,t.done||(t.stop(),this.frameTask.animationInProgress=!1)),e})),n=new Promise((e=>e(r)));return t.when().catch((()=>{s()&&n.cancel&&n.cancel()})),n}_gotoImmediate(e,t){const i=this._gotoTask,s=this.animation,r=e.then((e=>{if(c(t),i!==this._gotoTask)throw new n("view:goto-interrupted","Goto was interrupted");this.viewpoint=s.target=e,s.finish()}));return this._cancellableGoTo(i,s,r)}_flipStationary(e){return null!==this._stationaryTimer||(this._stationaryTimer=setTimeout((()=>{this._stationaryTimer=null;const e=performance.now()-this._lastStationaryEventTimestamp;e<ye&&(this._stationaryTimer=this._flipStationary(e))}),e)),this._stationaryTimer}_getDefaultViewpoint(){const{constraints:e,initialExtent:t,map:s,padding:r,size:n}=this;if(!e)return null;const a=s&&"initialViewProperties"in s?s.initialViewProperties:void 0,o={zoom:this._get("zoom"),scale:this._get("scale"),center:this._get("center"),extent:this._get("extent"),rotation:this._get("rotation"),viewpoint:this._get("viewpoint"),spatialReference:this._userSpatialReference};e.effectiveLODs?-1!==o.zoom&&(o.scale=e.zoomToScale(o.zoom)):o.zoom=-1;let h=null,c=null,d=0;const u=o.viewpoint&&o.viewpoint.rotation,g=o.viewpoint&&o.viewpoint.targetGeometry;l(g)&&("extent"===g.type?h=g:"point"===g.type&&(c=g,d=o.viewpoint.scale));const m=o.extent||h||p(a?.viewpoint?.targetGeometry)?.extent||t,y=o.center||c||m?.center,w=o.scale||d||a?.viewpoint?.scale||m&&B(m,[n[0]-r.left-r.right,n[1]-r.top-r.bottom]),f=o.rotation||u||a?.viewpoint?.rotation||0;return y&&w?new i({targetGeometry:y,scale:w,rotation:f}):null}_gotoAnimated(e,t){const i=this._gotoTask,s=this.animation,r=e.then((e=>{if(c(t),i!==this._gotoTask)throw new n("view:goto-interrupted","Goto was interrupted");return s.update(e),this.animationManager.animate(s,this.viewpoint,t),s.when().then((()=>{}),(()=>{}))}));return this._cancellableGoTo(i,s,r)}_project(e,t){const i=e&&e.targetGeometry||e;if(!t)return e;if(!i)return null;if(t.imageCoordinateSystem||i.spatialReference?.imageCoordinateSystem)return e;if(R(t,i.spatialReference))return e;const s=b(i,t);if(!s)throw new n("mapview:projection-not-possible","projecting input geometry to target spatial reference returned a null value",{geometry:i,spatialReference:t});return we(e)?(e.targetGeometry=s,e):s}_resizeHandler(e){if(!this.ready)return;const t=this.state;let i=this.state.paddedViewState.viewpoint;const s=this.state.paddedViewState.size.concat();t.size=[e.width,e.height],H(i,i,s,this.state.paddedViewState.size,this.resizeAlign),i=this.constraints.constrain(i,void 0),this.state.viewpoint=i}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint(),t=e.targetGeometry;try{this._project(e,this.spatialReference)}catch(l){o.getLogger(this.declaredClass).warn(new w("mapview:startup-projection-error","projection of initial viewpoint to the view's spatial reference, defaulting to the initial viewpoint.",{center:t.toJSON(),spatialReference:this.spatialReference,error:l})),e.targetGeometry=this.defaultsFromMap.extent?.center||new S({x:0,y:0,spatialReference:this.spatialReference})}this.constraints?.fit(e),this._set("state",new q({padding:this._get("padding"),size:this.size,viewpoint:e})),this.graphics.owner=this;const i=new pe(this.surface,{canvas:this.renderCanvas,supersampleScreenshots:this.supersampleScreenshotsEnabled,contextOptions:{disabledExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions},renderingOptions:this.renderingOptions,timeline:this.timeline});this._stage=i,this._magnifierView=new ge,this._magnifierView.magnifier=this.magnifier;const s=new de({view:this});this._set("labelManager",s);const r=new P({view:this});this._set("animationManager",r);const n=new ue({view:this,animationManager:r});this._set("mapViewNavigation",n),this._setupSpatialReferenceDependentProperties(),this.handles.add([this.rootLayerViews.on("change",(()=>this._updateStageChildren())),i.on("post-render",(()=>this._set("rendering",i.renderRequested))),i.on("will-render",(()=>this._set("rendering",i.renderRequested))),i.on("webgl-error",(e=>this.fatalError=e.error)),d((()=>this.stationary),(e=>i.stationary=e),m),d((()=>this.background),(e=>{i.background=e,this._magnifierView.background=e}),m),d((()=>this.magnifier),(e=>this._magnifierView.magnifier=e),m),d((()=>this.renderingOptions),(e=>i.renderingOptions=e),m),d((()=>this.highlightOptions),(e=>i.highlightOptions=e),m),d((()=>this.state.id),(()=>i.state=this.state),m)],"map-view"),this._updateStageChildren();const a=this._resolveWhenReady;this._resolveWhenReady=[],a.forEach((e=>e(this))),this.timeline.end("MapView Startup"),this.frameTask&&this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.handles.remove("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._stage.destroy(),this._stage=null,this._set("graphicsView",null),this._magnifierView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask&&this.frameTask.stop(),this._stationaryTimer&&(clearTimeout(this._stationaryTimer),this._stationaryTimer=null),this._set("ready",!1);const{center:[e,t],spatialReference:i,rotation:s,scale:r}=this.state.paddedViewState,n=new S({x:e,y:t,spatialReference:i});this._set("viewpoint",null),this._set("extent",null),this._set("center",n),this._set("zoom",-1),this._set("rotation",s),this._set("scale",r),this._set("spatialReference",i),this._set("state",null),this.animation=null}_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)}_setupSpatialReferenceDependentProperties(){const e=new D(x.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new he({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new ce(e)});this.frameTask.graphicsView=t,this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),this.frameTask.graphicsView=null,e.destroy(),this._set("featuresTilingScheme",null)}_spatialReferenceChanged(e){if(!this.ready)return;this.frameTask.stop();for(const i of this.allLayerViews)i.processDetach();this._destroySpatialReferenceDependentProperties();const t=this.state.paddedViewState.clone();if(h(this._scaleBeforeChangingSpatialReference))this._scaleBeforeChangingSpatialReference=t.scale;else{const e=t.viewpoint.clone();e.scale=this._scaleBeforeChangingSpatialReference,t.viewpoint=e}const s=t.clone(),[r,n]=t.center;let a=null;try{a=this._project(new S({x:r,y:n,spatialReference:t.spatialReference}),e)}catch(p){M()||o.getLogger(this.declaredClass).warn(new w("mapview:spatial-reference-change","could not project the view's center to the new spatial reference",{center:a?.toJSON(),spatialReference:e,error:p}))}a||(a=new S({x:0,y:0,spatialReference:e}));const l=U(new i({targetGeometry:new S,scale:0,rotation:0}),t.viewpoint,a);s.viewpoint=l;try{const i=20,r=[t.size[0]/2,t.size[1]/2],n=[r[0]+i,r[1]],a=t.toMap([0,0],n),{x:o,y:p}=this._project(new S({x:a[0],y:a[1],spatialReference:t.spatialReference}),e);a[0]=o,a[1]=p,s.toScreen(a,a);const h=J(r,a,n),c=Math.hypot(a[0]-r[0],a[1]-r[1])/i;!Number.isFinite(c)||Math.abs(c)>4?(l.rotation=0,l.targetGeometry=new S({x:0,y:0,spatialReference:e})):(l.scale*=c,l.scale>has("mapview-srswitch-adjust-rotation-scale-threshold")?l.rotation=0:l.rotation+=Number.isFinite(h)?h:0)}catch{}this._get("constraints").constrain(l,void 0),this._get("state").viewpoint=l,this._stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const i of this.allLayerViews)i.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}};fe.type="2d",e([_({readOnly:!0})],fe.prototype,"animationManager",void 0),e([_({constructOnly:!0})],fe.prototype,"deactivatedWebGLExtensions",void 0),e([_({constructOnly:!0})],fe.prototype,"debugWebGLExtensions",void 0),e([_({readOnly:!0})],fe.prototype,"featuresTilingScheme",void 0),e([_({readOnly:!0})],fe.prototype,"fullOpacity",void 0),e([_({readOnly:!0})],fe.prototype,"graphicsTileStore",null),e([_()],fe.prototype,"graphicsView",void 0),e([_({readOnly:!0})],fe.prototype,"state",void 0),e([_()],fe.prototype,"initialExtentRequired",null),e([_()],fe.prototype,"labelManager",void 0),e([_({readOnly:!0})],fe.prototype,"resourceManager",null),e([_({readOnly:!0})],fe.prototype,"textureManager",null),e([_({readOnly:!0})],fe.prototype,"mapViewNavigation",void 0),e([_({constructOnly:!0})],fe.prototype,"renderCanvas",void 0),e([_()],fe.prototype,"renderingOptions",void 0),e([_({readOnly:!0})],fe.prototype,"rendering",void 0),e([_({constructOnly:!0})],fe.prototype,"supersampleScreenshotsEnabled",void 0),e([_({readOnly:!0})],fe.prototype,"supportsGround",void 0),e([_()],fe.prototype,"_stationaryTimer",void 0),e([_()],fe.prototype,"_defaultsFromMapSettings",null),e([_()],fe.prototype,"_pePromise",void 0),e([_({readOnly:!0})],fe.prototype,"typeSpecificPreconditionsReady",null),e([_()],fe.prototype,"animation",null),e([_({type:le})],fe.prototype,"background",null),e([_({value:null,type:S,dependsOn:["state.id","ready"]})],fe.prototype,"center",null),e([_({type:N})],fe.prototype,"constraints",null),e([_({value:null,type:V,dependsOn:["state.id","ready"]})],fe.prototype,"extent",null),e([_()],fe.prototype,"floors",void 0),e([_({type:K})],fe.prototype,"highlightOptions",void 0),e([_({readOnly:!0})],fe.prototype,"inputManager",void 0),e([_()],fe.prototype,"map",void 0),e([_({value:{top:0,right:0,bottom:0,left:0},cast:e=>({top:0,right:0,bottom:0,left:0,...e})})],fe.prototype,"padding",null),e([_()],fe.prototype,"resizeAlign",void 0),e([_({readOnly:!0,dependsOn:["state.id"]})],fe.prototype,"resolution",null),e([_({value:0,type:Number,dependsOn:["state.id","ready"]})],fe.prototype,"rotation",null),e([_({value:0,type:Number,dependsOn:["state.id","ready"]})],fe.prototype,"scale",null),e([_({constructOnly:!0})],fe.prototype,"spatialReferenceLocked",void 0),e([_()],fe.prototype,"stationary",null),e([_({type:Y,readOnly:!0})],fe.prototype,"timeline",void 0),e([_({readOnly:!0})],fe.prototype,"type",void 0),e([_({readOnly:!0})],fe.prototype,"updating",null),e([_({value:null,type:i,dependsOn:["state.id","ready"]})],fe.prototype,"viewpoint",null),e([_({value:-1,dependsOn:["state.id","ready"]})],fe.prototype,"zoom",null),e([_({readOnly:!0})],fe.prototype,"navigating",null),e([_({type:oe})],fe.prototype,"ui",void 0),fe=e([v("esri.views.MapView")],fe);const _e=fe;function ve(e){const t=e.getObjectId();return t?`${e.layer?.uid??e.sourceLayer?.uid??"MapView"}/${t}`:`"MapView/${e.uid}`}function Ve(e,i,s,r,n){return a=>{if(a instanceof t){if(a.layer===e)n?.();else{const t=e.allLayerViews.find((e=>e.layer===a.layer));t&&r?.(t)}s(ve(a))}else{const t=e.allLayerViews.find((e=>e.layer===a));t&&i(t)}}}function Se(e,t){if(e)if(a(e))for(const i of e)if(a(i))for(const e of i)t(e);else t(i);else t(e)}function Te(e){return"esri.WebMap"===e?.declaredClass}export{_e as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import i from"../Viewpoint.js";import s from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import n from"../core/Error.js";import has from"../core/has.js";import{isIterable as a}from"../core/iteratorUtils.js";import o from"../core/Logger.js";import{isSome as l,unwrap as p,isNone as h}from"../core/maybe.js";import{throwIfAborted as c}from"../core/promiseUtils.js";import{watch as d,whenOnce as u,sync as g,syncAndInitial as m}from"../core/reactiveUtils.js";import{createScreenPoint as y}from"../core/screenUtils.js";import w from"../core/Warning.js";import{initialize as f}from"../core/workers/workers.js";import{property as _}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{subclass as v}from"../core/accessorSupport/decorators/subclass.js";import V from"../geometry/Extent.js";import S from"../geometry/Point.js";import{load as T,canProjectWithoutEngine as j,project as b,isLoaded as M}from"../geometry/projection.js";import{equals as R}from"../geometry/support/spatialReferenceUtils.js";import x from"../layers/support/TileInfo.js";import{BreakpointsOwner as L}from"./BreakpointsOwner.js";import{DOMContainer as O}from"./DOMContainer.js";import{PopupView as k}from"./PopupView.js";import C from"./View.js";import z from"./ViewAnimation.js";import P from"./2d/AnimationManager.js";import E from"./2d/FrameTask.js";import{layerView2DImporter as G}from"./2d/layerViewModuleImportUtils.js";import N from"./2d/MapViewConstraints.js";import q from"./2d/PaddedViewState.js";import"./2d/tiling/PagedTileQueue.js";import D from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{centerAt as U,setExtent as A,rotateTo as F,scaleTo as I,copy as W,create as $,extentToScale as B,resize as H,angleBetween as J}from"./2d/viewpointUtils.js";import Q from"./2d/input/MapViewInputManager.js";import Z from"./2d/layers/features/support/TileStore.js";import K from"./2d/support/HighlightOptions.js";import{Timeline as Y}from"./2d/support/Timeline.js";import X from"./support/createScreenshotPlan.js";import{encode as ee,encodeData as te,getMaximumResolutionScale as ie,getFormatAndQuality as se}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as re,createScreenPointFromSupportedEvent as ne}from"./support/screenUtils.js";import{check as ae}from"./support/WebGLRequirements.js";import oe from"./ui/2d/DefaultUI2D.js";import le from"../webmap/background/ColorBackground.js";let pe,he,ce,de,ue,ge;async function me(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:s,MagnifierView2D:r,Stage:n}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);he=e,ce=t,de=i,ue=s,ge=r,pe=n}const ye=160;function we(e){return e&&"esri.Viewpoint"===e.declaredClass}let fe=class extends(L(O(k(C)))){constructor(e){super(e),this._magnifierView=null,this._stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.fullOpacity=1,this.graphicsView=null,this.labelManager=null,this.mapViewNavigation=null,this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.rendering=!1,this.supersampleScreenshotsEnabled=!0,this.supportsGround=!1,this._stationaryTimer=null,this._gotoTask=null,this.frameTask=new E(this),this._pePromise=null,this.floors=new s,this.highlightOptions=new K,this.inputManager=new Q({view:this}),this.map=null,this.resizeAlign="center",this.spatialReferenceLocked=!1,this.timeline=new Y,this.type="2d",this.ui=new oe,this._pixelFormat={flipY:!0,premultipliedAlpha:!0},this.constraints=new N,this.padding={top:0,right:0,bottom:0,left:0},this.handles.add([d((()=>this.viewpoint),(()=>{this._lastStationaryEventTimestamp=performance.now(),this._flipStationary(ye)}),g),this.on("resize",(e=>this._resizeHandler(e))),d((()=>this.animationManager?.animation),(e=>{this.animation=e}))]),f()}destroy(){this._set("preconditionsReady",!1),this._gotoTask=this.frameTask=null,this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new Z(this.featuresTilingScheme)}get initialExtentRequired(){const{scale:e,constraints:t,center:i,viewpoint:s,extent:r}=this;let n=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!r&&(t?.effectiveLODs||(n=-1),(!i||0===e&&-1===n)&&(!s||!l(s.targetGeometry)||"extent"!==s.targetGeometry.type&&!s.scale)))}get resourceManager(){return this._stage.resourceManager}get textureManager(){return this._stage.painter.textureManager}get _defaultsFromMapSettings(){return{required:{tileInfo:!0,heightModelInfo:!1,extent:!1},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get _projectionEngineLoaded(){return!!M()||(this._pePromise||(this._pePromise=T().finally((()=>{this._pePromise=null}))),!1)}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=this.spatialReference,i=p(e.targetGeometry);return!!j(i.spatialReference,t)||this._projectionEngineLoaded}set animation(e){const t=this._get("animation");if(e===t)return;if(t&&t.stop(),!e||e.isFulfilled())return void this._set("animation",null);this._set("animation",e),this.frameTask.animationInProgress=!0;const i=()=>{e===this._get("animation")&&(this._set("animation",null),this.frameTask?.requestFrame()),this.frameTask&&(this.frameTask.animationInProgress=!1)};e.when(i,i)}get background(){return Te(this.map)?this.map.initialViewProperties.background:null}set background(e){this._override("background",e)}get center(){if(!this.ready)return this._get("center");const{center:e,spatialReference:t}=this.state.paddedViewState;return new S({x:e[0],y:e[1],spatialReference:t})}set center(e){if(null==e)return;if(!this.ready)return this._set("center",e),void this.notifyChange("initialExtentRequired");let t;try{t=this._project(e,this.spatialReference)}catch(s){return void o.getLogger(this.declaredClass).error(new n("mapview:invalid-center","could not project the value in the view's spatial reference",{input:e,error:s}))}const i=this.viewpoint;U(i,i,t),this.viewpoint=i}set constraints(e){const t=this._get("constraints");t&&(this.handles.remove("map-view-constraints"),t.destroy()),this._set("constraints",e),e&&(e.view=this,this.ready&&(this.state.viewpoint=e.fit(this.state.paddedViewState.viewpoint)),this.handles.add(d((()=>e.version),(()=>{this.ready&&this.state&&(this.state.viewpoint=e.fit(this.state.paddedViewState.viewpoint))}),g),"map-view-constraints"))}get extent(){return this.ready?this.state.paddedViewState.extent.clone():this._get("extent")}set extent(e){if(null==e)return;if(!e.width||!e.height)return void o.getLogger(this.declaredClass).error(new n("mapview:invalid-extent","invalid extent size"));if(!this.ready)return this._set("extent",e),this._set("center",null),this._set("viewpoint",null),this._set("scale",0),this._set("zoom",-1),void this.notifyChange("initialExtentRequired");let t;try{t=this._project(e,this.spatialReference)}catch(s){return void o.getLogger(this.declaredClass).error(new n("mapview:invalid-extent","could not project the value in the view's spatial reference",{error:s}))}const i=this.viewpoint;A(i,i,t,this.size,{constraints:this.constraints}),this.viewpoint=i}get padding(){return this.ready?this.state.padding:this._get("padding")}set padding(e){this.ready?(this.state.padding=e,this._set("padding",this.state.padding)):this._set("padding",e)}get resolution(){return this.state?this.state.resolution:0}get rotation(){return this.ready?this.state.rotation:this._get("rotation")}set rotation(e){if(isNaN(e))return;if(!this.ready)return void this._set("rotation",e);const t=this.viewpoint;F(t,t,e),this.viewpoint=t}get scale(){return this.ready?this.state.scale:this._get("scale")}set scale(e){if(!e||isNaN(e))return;if(!this.ready){this._set("scale",e),this._set("zoom",-1);const t=this._get("extent");return t&&(this._set("extent",null),this._set("center",t.center)),void this.notifyChange("initialExtentRequired")}const t=this.viewpoint;I(t,t,e),this.viewpoint=t}get stationary(){return!(this.animation||this.navigating||this.resizing||this._stationaryTimer)}get updating(){const e=!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some((e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)));if(has("esri-2d-log-updating")){const t=this.allLayerViews.reduce(((e,t)=>({...e,[t.layer.id]:!t.destroyed&&!("layerViews"in t)&&t.updating})),{});console.log(`Updating MapView: ${e}\n-> Null LayerViewManager: ${!this.layerViewManager}\n-> Null LabelManager: ${!this.labelManager}\n-> Null GraphicsView: ${!this.graphicsView}\n-> layerViewManager.updating: ${this.layerViewManager?.updating}\n-> labelManager.updating: ${this.labelManager?.updating}\n-> graphicsView.updating: ${this.graphicsView?.updating}\n-> allLayerViews: ${JSON.stringify(t)}\n`)}return e}get viewpoint(){if(!this.ready)return this._get("viewpoint");const e=this.state.paddedViewState;return e&&e.viewpoint.clone()}set viewpoint(e){if(null==e)return;if(!this.ready)return this._set("viewpoint",e),this._set("extent",null),this._set("center",null),this._set("zoom",-1),this._set("scale",0),void this.notifyChange("initialExtentRequired");let t,s;try{t=this._project(e,this.spatialReference),!e.scale||isNaN(e.scale)?s=new n("mapview:invalid-viewpoint",`invalid scale value of ${e.scale}`):h(e.targetGeometry)&&(s=new n("mapview:invalid-viewpoint","geometry not defined"))}catch(a){s=new n("mapview:invalid-viewpoint","could not project the value in the view's spatial reference",{error:a})}if(s)return void o.getLogger(this.declaredClass).error(s);this._scaleBeforeChangingSpatialReference=null;const r=new i({targetGeometry:new S,scale:0,rotation:0});W(r,t),this.constraints.constrain(r,this.state.paddedViewState.viewpoint),this.state.viewpoint=r,this.frameTask.requestFrame(),this._set("viewpoint",r)}get zoom(){return this.ready?this.constraints.scaleToZoom(this.scale):this._get("zoom")}set zoom(e){if(null==e)return;if(!this.ready){this._set("zoom",e),this._set("scale",0);const t=this._get("extent");return t&&(this._set("extent",null),this._set("center",t.center)),void this.notifyChange("initialExtentRequired")}if(!this.constraints.effectiveLODs)return void this._set("zoom",-1);const t=this.viewpoint;I(t,t,this.constraints.zoomToScale(e)),this.viewpoint=t,this._set("zoom",this.constraints.scaleToZoom(this.scale))}get navigating(){return!(!this.mapViewNavigation||!this.mapViewNavigation.interacting)}goTo(e,t){if(e)return this.animation&&(this.animation=null),this._createAnimation(),u((()=>this.ready),t).then((()=>{const i={animate:!0,...t},s=$(e,this);return this.animation?.update(s),this._gotoTask={},i.animate?this._gotoAnimated(s,i):this._gotoImmediate(s,i)}));o.getLogger(this.declaredClass).error("#goTo()","target cannot be null or undefined")}async hitTest(e,t){const i=re(e)?ne(this,e):e;if(!this.ready||isNaN(i.x)||isNaN(i.y))return{screenPoint:i,results:[]};let s=new Set,r=!1,n=null,a=null;t?.include?Se(t.include,Ve(this,(e=>s.add(e)),(e=>{n||(n=new Set),n.add(e)}),(e=>s.add(e)),(()=>r=!0))):(r=!0,s=new Set(this.allLayerViews)),t?.exclude&&Se(t.exclude,Ve(this,(e=>s.delete(e)),(e=>{a||(a=new Set),a.add(e)})));const o=this.allLayerViews.filter((e=>!e.suspended&&s.has(e))).reverse(),p=this.toMap(i);let h=[...r?this.graphicsView.hitTest(p).map((e=>({type:"graphic",graphic:e,layer:null,mapPoint:p}))):[],...await Promise.all(o.map((e=>e.hitTest(p,i))).toArray())].filter(l).flat().filter(l);return n&&(h=h.filter((e=>!("graphic"in e)||!e.graphic||n?.has(ve(e.graphic))))),a&&(h=h.filter((e=>!("graphic"in e)||!e.graphic||a?.has(ve(e.graphic))))),{screenPoint:i,results:h}}async takeScreenshot(e){const t=this._createScreenshotPlan(e),i=await this._stage.takeScreenshot(t);return ee(i,{format:t.format,quality:t.quality,rotation:0,disableDecorations:!1},this._pixelFormat)}async _takeScreenshot(e){const t=this._createScreenshotPlan(e),i=await this._stage.takeScreenshot(t);return te(i,this._pixelFormat)}_createScreenshotPlan(e){e=e??{};const t=this.supersampleScreenshotsEnabled?Math.min(4,ie(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:s,quality:r}=se(e.format,e.quality);return X(e,t,this.size,this.padding,s,r,i,e.rotation)}get test(){return{takeScreenshot:e=>this._takeScreenshot(e)}}toMap(e){if(!this.ready)return null;const t=re(e)?ne(this,e):e,i=[0,0],[s,r]=this.state.toMap(i,[t.x,t.y]),n=this.spatialReference;return new S({x:s,y:r,spatialReference:n})}toScreen(e){if(!this.ready)return null;const t=this._project(e,this.spatialReference),i=[t.x,t.y];return this.state.toScreen(i,i),y(i[0],i[1])}on(e,t,i,s){const r=this.inputManager&&this.viewEvents.on(e,t,i,s);return r||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()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map?.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||null}hasLayerViewModule(e){return G.hasLayerViewModule(e)}importLayerView(e){return G.importLayerView(e)}pixelSizeAt(){return this.ready?this.state.resolution:(o.getLogger(this.declaredClass).error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}popupHitTest(e){return this.hitTest(e).then((t=>({...t,mapPoint:this.toMap(e)})))}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}validate(){let e=ae(this.type);return has("safari")&&has("safari")<9&&(e=new n("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:has("safari")})),l(e)?(o.getLogger(this.declaredClass).warn("#validate()",e.message),Promise.reject(e)):me()}_createAnimation(){return this.animation&&!this.animation.done||(this.animation=new z),this.animation}_cancellableGoTo(e,t,i){const s=()=>e===this._gotoTask,r=i.then((()=>{s()&&(this.animation=null)})).catch((e=>{throw s()&&(this.animation=null,t.done||(t.stop(),this.frameTask.animationInProgress=!1)),e})),n=new Promise((e=>e(r)));return t.when().catch((()=>{s()&&n.cancel&&n.cancel()})),n}_gotoImmediate(e,t){const i=this._gotoTask,s=this.animation,r=e.then((e=>{if(c(t),i!==this._gotoTask)throw new n("view:goto-interrupted","Goto was interrupted");this.viewpoint=s.target=e,s.finish()}));return this._cancellableGoTo(i,s,r)}_flipStationary(e){return null!==this._stationaryTimer||(this._stationaryTimer=setTimeout((()=>{this._stationaryTimer=null;const e=performance.now()-this._lastStationaryEventTimestamp;e<ye&&(this._stationaryTimer=this._flipStationary(e))}),e)),this._stationaryTimer}_getDefaultViewpoint(){const{constraints:e,initialExtent:t,map:s,padding:r,size:n}=this;if(!e)return null;const a=s&&"initialViewProperties"in s?s.initialViewProperties:void 0,o={zoom:this._get("zoom"),scale:this._get("scale"),center:this._get("center"),extent:this._get("extent"),rotation:this._get("rotation"),viewpoint:this._get("viewpoint"),spatialReference:this._userSpatialReference};e.effectiveLODs?-1!==o.zoom&&(o.scale=e.zoomToScale(o.zoom)):o.zoom=-1;let h=null,c=null,d=0;const u=o.viewpoint&&o.viewpoint.rotation,g=o.viewpoint&&o.viewpoint.targetGeometry;l(g)&&("extent"===g.type?h=g:"point"===g.type&&(c=g,d=o.viewpoint.scale));const m=o.extent||h||p(a?.viewpoint?.targetGeometry)?.extent||t,y=o.center||c||m?.center,w=o.scale||d||a?.viewpoint?.scale||m&&B(m,[n[0]-r.left-r.right,n[1]-r.top-r.bottom]),f=o.rotation||u||a?.viewpoint?.rotation||0;return y&&w?new i({targetGeometry:y,scale:w,rotation:f}):null}_gotoAnimated(e,t){const i=this._gotoTask,s=this.animation,r=e.then((e=>{if(c(t),i!==this._gotoTask)throw new n("view:goto-interrupted","Goto was interrupted");return s.update(e),this.animationManager.animate(s,this.viewpoint,t),s.when().then((()=>{}),(()=>{}))}));return this._cancellableGoTo(i,s,r)}_project(e,t){const i=e&&e.targetGeometry||e;if(!t)return e;if(!i)return null;if(t.imageCoordinateSystem||i.spatialReference?.imageCoordinateSystem)return e;if(R(t,i.spatialReference))return e;const s=b(i,t);if(!s)throw new n("mapview:projection-not-possible","projecting input geometry to target spatial reference returned a null value",{geometry:i,spatialReference:t});return we(e)?(e.targetGeometry=s,e):s}_resizeHandler(e){if(!this.ready)return;const t=this.state;let i=this.state.paddedViewState.viewpoint;const s=this.state.paddedViewState.size.concat();t.size=[e.width,e.height],H(i,i,s,this.state.paddedViewState.size,this.resizeAlign),i=this.constraints.constrain(i,void 0),this.state.viewpoint=i}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint(),t=e.targetGeometry;try{this._project(e,this.spatialReference)}catch(l){o.getLogger(this.declaredClass).warn(new w("mapview:startup-projection-error","projection of initial viewpoint to the view's spatial reference, defaulting to the initial viewpoint.",{center:t.toJSON(),spatialReference:this.spatialReference,error:l})),e.targetGeometry=this.defaultsFromMap.extent?.center||new S({x:0,y:0,spatialReference:this.spatialReference})}this.constraints?.fit(e),this._set("state",new q({padding:this._get("padding"),size:this.size,viewpoint:e})),this.graphics.owner=this;const i=new pe(this.surface,{canvas:this.renderCanvas,supersampleScreenshots:this.supersampleScreenshotsEnabled,contextOptions:{disabledExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions},renderingOptions:this.renderingOptions,timeline:this.timeline});this._stage=i,this._magnifierView=new ge,this._magnifierView.magnifier=this.magnifier;const s=new de({view:this});this._set("labelManager",s);const r=new P({view:this});this._set("animationManager",r);const n=new ue({view:this,animationManager:r});this._set("mapViewNavigation",n),this._setupSpatialReferenceDependentProperties(),this.handles.add([this.rootLayerViews.on("change",(()=>this._updateStageChildren())),i.on("post-render",(()=>this._set("rendering",i.renderRequested))),i.on("will-render",(()=>this._set("rendering",i.renderRequested))),i.on("webgl-error",(e=>this.fatalError=e.error)),d((()=>this.stationary),(e=>i.stationary=e),m),d((()=>this.background),(e=>{i.background=e,this._magnifierView.background=e}),m),d((()=>this.magnifier),(e=>this._magnifierView.magnifier=e),m),d((()=>this.renderingOptions),(e=>i.renderingOptions=e),m),d((()=>this.highlightOptions),(e=>i.highlightOptions=e),m),d((()=>this.state.id),(()=>i.state=this.state),m)],"map-view"),this._updateStageChildren();const a=this._resolveWhenReady;this._resolveWhenReady=[],a.forEach((e=>e(this))),this.timeline.end("MapView Startup"),this.frameTask&&this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.handles.remove("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._stage.destroy(),this._stage=null,this._set("graphicsView",null),this._magnifierView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask&&this.frameTask.stop(),this._stationaryTimer&&(clearTimeout(this._stationaryTimer),this._stationaryTimer=null),this._set("ready",!1);const{center:[e,t],spatialReference:i,rotation:s,scale:r}=this.state.paddedViewState,n=new S({x:e,y:t,spatialReference:i});this._set("viewpoint",null),this._set("extent",null),this._set("center",n),this._set("zoom",-1),this._set("rotation",s),this._set("scale",r),this._set("spatialReference",i),this._set("state",null),this.animation=null}_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)}_setupSpatialReferenceDependentProperties(){const e=new D(x.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new he({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new ce(e)});this.frameTask.graphicsView=t,this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),this.frameTask.graphicsView=null,e.destroy(),this._set("featuresTilingScheme",null)}_spatialReferenceChanged(e){if(!this.ready)return;this.frameTask.stop();for(const i of this.allLayerViews)i.processDetach();this._destroySpatialReferenceDependentProperties();const t=this.state.paddedViewState.clone();if(h(this._scaleBeforeChangingSpatialReference))this._scaleBeforeChangingSpatialReference=t.scale;else{const e=t.viewpoint.clone();e.scale=this._scaleBeforeChangingSpatialReference,t.viewpoint=e}const s=t.clone(),[r,n]=t.center;let a=null;try{a=this._project(new S({x:r,y:n,spatialReference:t.spatialReference}),e)}catch(p){M()||o.getLogger(this.declaredClass).warn(new w("mapview:spatial-reference-change","could not project the view's center to the new spatial reference",{center:a?.toJSON(),spatialReference:e,error:p}))}a||(a=new S({x:0,y:0,spatialReference:e}));const l=U(new i({targetGeometry:new S,scale:0,rotation:0}),t.viewpoint,a);s.viewpoint=l;try{const i=20,r=[t.size[0]/2,t.size[1]/2],n=[r[0]+i,r[1]],a=t.toMap([0,0],n),{x:o,y:p}=this._project(new S({x:a[0],y:a[1],spatialReference:t.spatialReference}),e);a[0]=o,a[1]=p,s.toScreen(a,a);const h=J(r,a,n),c=Math.hypot(a[0]-r[0],a[1]-r[1])/i;!Number.isFinite(c)||Math.abs(c)>4?(l.rotation=0,l.targetGeometry=new S({x:0,y:0,spatialReference:e})):(l.scale*=c,l.scale>has("mapview-srswitch-adjust-rotation-scale-threshold")?l.rotation=0:l.rotation+=Number.isFinite(h)?h:0)}catch{}this._get("constraints").constrain(l,void 0),this._get("state").viewpoint=l,this._stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const i of this.allLayerViews)i.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}};fe.type="2d",e([_({readOnly:!0})],fe.prototype,"animationManager",void 0),e([_({constructOnly:!0})],fe.prototype,"deactivatedWebGLExtensions",void 0),e([_({constructOnly:!0})],fe.prototype,"debugWebGLExtensions",void 0),e([_({readOnly:!0})],fe.prototype,"featuresTilingScheme",void 0),e([_({readOnly:!0})],fe.prototype,"fullOpacity",void 0),e([_({readOnly:!0})],fe.prototype,"graphicsTileStore",null),e([_()],fe.prototype,"graphicsView",void 0),e([_({readOnly:!0})],fe.prototype,"state",void 0),e([_()],fe.prototype,"initialExtentRequired",null),e([_()],fe.prototype,"labelManager",void 0),e([_({readOnly:!0})],fe.prototype,"resourceManager",null),e([_({readOnly:!0})],fe.prototype,"textureManager",null),e([_({readOnly:!0})],fe.prototype,"mapViewNavigation",void 0),e([_({constructOnly:!0})],fe.prototype,"renderCanvas",void 0),e([_()],fe.prototype,"renderingOptions",void 0),e([_({readOnly:!0})],fe.prototype,"rendering",void 0),e([_({constructOnly:!0})],fe.prototype,"supersampleScreenshotsEnabled",void 0),e([_({readOnly:!0})],fe.prototype,"supportsGround",void 0),e([_()],fe.prototype,"_stationaryTimer",void 0),e([_()],fe.prototype,"_defaultsFromMapSettings",null),e([_()],fe.prototype,"_pePromise",void 0),e([_({readOnly:!0})],fe.prototype,"typeSpecificPreconditionsReady",null),e([_()],fe.prototype,"animation",null),e([_({type:le})],fe.prototype,"background",null),e([_({value:null,type:S,dependsOn:["state.id","ready"]})],fe.prototype,"center",null),e([_({type:N})],fe.prototype,"constraints",null),e([_({value:null,type:V,dependsOn:["state.id","ready"]})],fe.prototype,"extent",null),e([_()],fe.prototype,"floors",void 0),e([_({type:K})],fe.prototype,"highlightOptions",void 0),e([_({readOnly:!0})],fe.prototype,"inputManager",void 0),e([_()],fe.prototype,"map",void 0),e([_({value:{top:0,right:0,bottom:0,left:0},cast:e=>({top:0,right:0,bottom:0,left:0,...e})})],fe.prototype,"padding",null),e([_()],fe.prototype,"resizeAlign",void 0),e([_({readOnly:!0,dependsOn:["state.id"]})],fe.prototype,"resolution",null),e([_({value:0,type:Number,dependsOn:["state.id","ready"]})],fe.prototype,"rotation",null),e([_({value:0,type:Number,dependsOn:["state.id","ready"]})],fe.prototype,"scale",null),e([_({constructOnly:!0})],fe.prototype,"spatialReferenceLocked",void 0),e([_()],fe.prototype,"stationary",null),e([_({type:Y,readOnly:!0})],fe.prototype,"timeline",void 0),e([_({readOnly:!0})],fe.prototype,"type",void 0),e([_({readOnly:!0})],fe.prototype,"updating",null),e([_({value:null,type:i,dependsOn:["state.id","ready"]})],fe.prototype,"viewpoint",null),e([_({value:-1,dependsOn:["state.id","ready"]})],fe.prototype,"zoom",null),e([_({readOnly:!0})],fe.prototype,"navigating",null),e([_({type:oe})],fe.prototype,"ui",void 0),fe=e([v("esri.views.MapView")],fe);const _e=fe;function ve(e){const t=e.getObjectId();return t?`${e.layer?.uid??e.sourceLayer?.uid??"MapView"}/${t}`:`"MapView/${e.uid}`}function Ve(e,i,s,r,n){return a=>{if(a instanceof t){if(a.layer===e)n?.();else{const t=e.allLayerViews.find((e=>e.layer===a.layer));t&&r?.(t)}s(ve(a))}else{const t=e.allLayerViews.find((e=>e.layer===a));t&&i(t)}}}function Se(e,t){if(e)if(a(e))for(const i of e)if(a(i))for(const e of i)t(e);else t(i);else t(e)}function Te(e){return"esri.WebMap"===e?.declaredClass}export{_e as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t}from"../../core/maybe.js";import{watch as n}from"../../core/reactiveUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as l,convertDateFormatToIntlOptions as a}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as r,formatNumber as s}from"../../intl/number.js";import u from"../../layers/support/CodedValueDomain.js";import{isNumericField as d,isStringField as p}from"../../layers/support/fieldUtils.js";import c from"../FeatureForm/InputField.js";import m from"./Grid/EditorColumn.js";import h from"../support/DatePicker.js";import f from"../support/TimePicker.js";import{renderingSanitizer as g}from"../support/widgetUtils.js";const y={cancelEdit:"Escape"},v="esri-field-column",b={headerContent:`${v}__header-content`,headerLabel:`${v}__header-label`,input:`${v}__cell-input`,inputContainer:`${v}__cell__input-container`,dateInputContainer:`${v}__cell__date-input-container`,dateInputWrapper:`${v}__cell__date-input-wrapper`,button:`${v}__button`,saveIcon:"esri-icon-save",trashIcon:"esri-icon-trash",locked:"esri-icon-locked"},_=a("short-date-short-time"),F=a("short-date"),C={useGrouping:!0,maximumFractionDigits:20};let E=class extends m{constructor(e){super(e),this._inputField=null,this.cellValueFormatFunction=({rowData:e,value:t})=>{if(this.formatFunction){const{config:e,field:n}=this;return this.formatFunction({config:e,field:n,value:g.sanitize(t)})}if(null===t)return"&nbsp;";const{config:n,field:i}=this,{item:{feature:o}}=e,a=this._getDomainForFeature(o);if(a)return this._getComputedDomain(t,a);if("date"===i.type){const e=this._getDateFormatOptions(),n="feature"===this.layer?.type&&this.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null;return t?l(t,{...e,...n}):null}if(d(i)){const e=n?.format?r(n.format):C;return s(parseFloat(t),e)}return g.sanitize(t)},this.cellValueValidatorFunction=({oldValue:e,value:n})=>!(this._inputField&&!this._inputField.valid)&&(!(this.required&&(!t(n)||""===n))&&e!==n),this.config=null,this.editingEnabled=!1,this.expressionInfos=null,this.field=null,this.formatFunction=null,this.headerRenderFunction=e=>{const{root:t}=e,{editable:n,editingEnabled:i,headerMenuEnabled:o,sortable:l}=this;if(this.removeCellContent(t),t.classList.add(b.headerContent),i&&!n&&t.appendChild(this.createLockedElement()),l)this.headerSorterRenderFunction(e);else{const e=document.createElement("div");e.classList.add(b.headerLabel),e.textContent=this.label,t.appendChild(e)}o&&this.headerMenuRenderFunction(e)},this.inputRenderFunction=({root:e,column:t,rowData:n})=>{if(this.activeEditInfo?.updating)return;if(!this.editable)return;const i=this.getCellValue(t,n),o=this.createInputElement({root:e,column:t,rowData:n,value:i});if(this._set("activeEditInfo",{column:t,input:o,root:e,rowData:n,updating:!0,oldValue:i}),"date"===this.field.type)return void this._renderDateEditors(i,e,o);const l=this.createInputContainer();l.appendChild(o),this.removeCellContent(e),e.appendChild(l),o.focus(),o instanceof HTMLInputElement&&o.select(),this.grid?.notifyResize()},this.layer=null,this.parseInputValueFunction=({input:e})=>{const t=this._inputField,n=e.value,{required:i,type:o}=t;return i||""!==n?"number"===o||"date"===o?parseFloat(n):"text"===o?n.trim():n:null},this.template=null,this.updateRowItemFunction=({rowData:e,column:t,value:n})=>{e.item.feature.attributes[t.path]=n}}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get description(){return this.template?.description??this.config?.description??this.field?.description??null}get editable(){const{config:e,editingEnabled:t,field:n,template:i}=this;return t?!1!==i?.editable&&(!1!==e?.editable&&n?.editable):i?i.editable:!!e&&(!0===e.editable&&n?.editable)}get header(){return this.template?.label||this.config?.label||this.alias||this.path||null}get hidden(){const{config:e}=this;return!1===e?.visible||this._get("hidden")||!1}set hidden(e){this._set("hidden",e)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,config:t,template:n}=this,i=e?.length,o=n?.input&&"maxLength"in n.input?n.input.maxLength:t?.maxLength;return!isNaN(o)&&o>=-1&&(-1===i||o<=i)?o:i}get minLength(){const{config:e,template:t,maxLength:n}=this,i=t?.input&&"minLength"in t.input?t.input.minLength:e?.minLength||null;return n&&i<=n?i:null}get name(){return this.field?.name}get nullable(){return this.field?.nullable??!1}get path(){return this.field?.name}get required(){const{config:e,field:t,template:n}=this,i=t?.nullable,o=e?.required,l=n?.required;return this.editable&&(!i||!0===o||!0===l)}get sortable(){return this.template?!1!==this.template?.sortable:!1!==this.config?.sortable}createInputElement({rowData:e,value:t}){const{item:n}=e;if(!n||!n.feature)return null;this._inputField=this._setUpInputField(n.feature,t);const{field:i,maxLength:o,minLength:l,required:a}=this,{domain:r}=this._inputField;let s=null;"coded-value"===r?.type?(s=this._createSelectElement(t,r.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),this._inputField),s.onchange=()=>{s.onblur=null,p()}):(s=document.createElement("input"),s.type=d(i)?"number":"text",o>-1&&(s.maxLength=o),l>0&&(s.minLength=l)),s.classList.add(b.input),s.value=t,s.required=a;let u=!1;s.onkeydown=e=>{u=e.key===y.cancelEdit},s.onblur=()=>{s.onblur=null,p()};const p=()=>{u?this.cancel():this.submit(),this._inputField=null};return s}createInputContainer(){const e=document.createElement("div");return e.classList.add(b.inputContainer),e}createLockedElement(){const e=document.createElement("div");return e.classList.add(b.locked),e}getCellValue({path:e},{item:t}){return t?.feature?.attributes?.[e]??null}_renderDateEditors(e,t,i){const{config:o,messagesCommon:l,template:a}=this,r=e?new Date(e):new Date(Date.now()),s=new h({dateInputEnabled:!0,value:r}),u=new f({value:r});i.value=r.getTime().toString();let d=!e;const p=()=>{d=!0;const e=this._getCombinedDateTime(s.value,u.value);i.value=e.getTime().toString()},c=()=>{d?this.submit():this.cancel()},m=()=>{i.value=null,this.submit()};n((()=>[s.value,u.value]),(()=>p()));const g=document.createElement("div"),y=document.createElement("div");s.container=g,u.container=y;const v=document.createElement("button");v.classList.add(b.button,b.saveIcon),v.onclick=()=>c(),v.title=l?.save;const _=document.createElement("button");_.classList.add(b.button,b.trashIcon),_.onclick=()=>m(),_.title=l?.clear;const F=document.createElement("div");F.classList.add(b.dateInputWrapper),F.appendChild(g),(a&&a.input&&"datetime-picker"===a.input.type&&!1!==a.input.includeTime||o&&!1!==o.includeTime)&&F.appendChild(y);const C=document.createElement("div");C.classList.add(b.dateInputContainer),C.appendChild(F),C.appendChild(v),C.appendChild(_),s.when((()=>this.grid?.notifyResize())),u.when((()=>this.grid?.notifyResize())),this.removeCellContent(t),t.appendChild(C),this.grid?.notifyResize()}_createSelectElement(e,t,n){let i=!1;const o=t.map((t=>{t.value===e&&(i=!0);const n=document.createElement("option");return n.text=t.name,n.value=t.value,n}));if(null!=e&&""!==e&&!i){const t=document.createElement("option");t.text=e,t.value=e,o.unshift(t)}if(!n.required&&null==n.value){const e=document.createElement("option");e.value="",o.unshift(e)}const l=document.createElement("select");return o.forEach((e=>l.add(e))),l.value=e,l}_setUpInputField(e,t){const{config:n,field:i,layer:o}=this,l=new c({config:n,feature:e,initialFeature:e.clone(),field:i,layer:o,group:null,messages:null});return l.set("value",t),l}_isDomainCompatible(e){const{field:t}=this;if(e&&"coded-value"===e.type){const n=typeof e.codedValues[0].code;if("string"===n&&p(t)||"number"===n&&d(t))return!0}return!(!e||"range"!==e.type||!d(t))}_getDomainForFeature(e){const{config:t,layer:n,name:i,template:o}=this;if("wfs"===n.type||"geojson"===n.type||"csv"===n.type)return null;if(o?.domain&&this._isDomainCompatible(o.domain))return o.domain;const{typeIdField:l}=n,a=l===i,r=this.field.domain;if(a&&!r)return new u({name:"__internal-type-based-coded-value-domain__",codedValues:n.types.map((({id:e,name:t})=>({code:e,name:t})))});const s=l&&n.getFieldDomain(i,{feature:e})||r,d=t?.domain;return this._isDomainCompatible(d)?d:s}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const n=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return n&&n.length?n[0].name:e}return null}_getCombinedDateTime(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}_getDateFormatOptions(){const{config:e,template:t}=this,n=t?.format?.dateFormat||e?.format?.dateFormat;return n?a(n):t&&t.input&&"includeTime"in t.input==!1||!1===e?.includeTime?F:_}};e([i({readOnly:!0})],E.prototype,"alias",null),e([i()],E.prototype,"cellValueFormatFunction",void 0),e([i()],E.prototype,"cellValueValidatorFunction",void 0),e([i()],E.prototype,"config",void 0),e([i({readOnly:!0})],E.prototype,"defaultValue",null),e([i({readOnly:!0})],E.prototype,"description",null),e([i({readOnly:!0})],E.prototype,"editable",null),e([i()],E.prototype,"editingEnabled",void 0),e([i()],E.prototype,"expressionInfos",void 0),e([i()],E.prototype,"field",void 0),e([i()],E.prototype,"formatFunction",void 0),e([i({readOnly:!0})],E.prototype,"header",null),e([i()],E.prototype,"hidden",null),e([i()],E.prototype,"headerRenderFunction",void 0),e([i()],E.prototype,"inputRenderFunction",void 0),e([i()],E.prototype,"layer",void 0),e([i({readOnly:!0})],E.prototype,"loadingMessage",null),e([i()],E.prototype,"maxLength",null),e([i()],E.prototype,"minLength",null),e([i({readOnly:!0})],E.prototype,"name",null),e([i({readOnly:!0})],E.prototype,"nullable",null),e([i()],E.prototype,"parseInputValueFunction",void 0),e([i({readOnly:!0})],E.prototype,"path",null),e([i({readOnly:!0})],E.prototype,"required",null),e([i()],E.prototype,"sortable",null),e([i()],E.prototype,"template",void 0),e([i()],E.prototype,"updateRowItemFunction",void 0),E=e([o("esri.widgets.FeatureTable.FieldColumn")],E);const L=E;export{L as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t}from"../../core/maybe.js";import{watch as n}from"../../core/reactiveUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as a,convertDateFormatToIntlOptions as r}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as l,formatNumber as s}from"../../intl/number.js";import u from"../../layers/support/CodedValueDomain.js";import{isNumericField as d,isStringField as p}from"../../layers/support/fieldUtils.js";import c from"../FeatureForm/InputField.js";import m from"./Grid/EditorColumn.js";import h from"../support/DatePicker.js";import f from"../support/TimePicker.js";import{renderingSanitizer as g}from"../support/widgetUtils.js";const y={cancelEdit:"Escape"},v="esri-field-column",b={headerContent:`${v}__header-content`,headerLabel:`${v}__header-label`,input:`${v}__cell-input`,inputContainer:`${v}__cell__input-container`,dateInputContainer:`${v}__cell__date-input-container`,dateInputWrapper:`${v}__cell__date-input-wrapper`,button:`${v}__button`,saveIcon:"esri-icon-save",trashIcon:"esri-icon-trash",locked:"esri-icon-locked"},_=r("short-date-short-time"),F=r("short-date"),C={useGrouping:!0,maximumFractionDigits:20};let E=class extends m{constructor(e){super(e),this._inputField=null,this.cellValueFormatFunction=({rowData:e,value:t})=>{if(this.formatFunction){const{config:e,field:n}=this;return this.formatFunction({config:e,field:n,value:g.sanitize(t)})}if(null===t)return"&nbsp;";const{config:n,field:i}=this,{item:{feature:o}}=e,r=this._getDomainForFeature(o);if(r)return this._getComputedDomain(t,r);if("date"===i.type){const e=this._getDateFormatOptions(),n="feature"===this.layer?.type&&this.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null;return t?a(t,{...e,...n}):null}if(d(i)){const e=n?.format?l(n.format):C;return s(parseFloat(t),e)}return g.sanitize(t)},this.cellValueValidatorFunction=({oldValue:e,value:n})=>!(this._inputField&&!this._inputField.valid)&&(!(this.required&&(!t(n)||""===n))&&e!==n),this.config=null,this.editingEnabled=!1,this.expressionInfos=null,this.field=null,this.formatFunction=null,this.headerRenderFunction=e=>{const{root:t}=e,{editable:n,editingEnabled:i,headerMenuEnabled:o,sortable:a}=this;if(this.removeCellContent(t),t.classList.add(b.headerContent),i&&!n&&t.appendChild(this.createLockedElement()),a)this.headerSorterRenderFunction(e);else{const e=document.createElement("div");e.classList.add(b.headerLabel),e.textContent=this.label,t.appendChild(e)}o&&this.headerMenuRenderFunction(e)},this.inputRenderFunction=({root:e,column:t,rowData:n})=>{if(this.activeEditInfo?.updating)return;if(!this.editable)return;const i=this.getCellValue(t,n),o=this.createInputElement({root:e,column:t,rowData:n,value:i});if(this._set("activeEditInfo",{column:t,input:o,root:e,rowData:n,updating:!0,oldValue:i}),"date"===this.field.type)return void this._renderDateEditors(i,e,o);const a=this.createInputContainer();a.appendChild(o),this.removeCellContent(e),e.appendChild(a),o.focus(),o instanceof HTMLInputElement&&o.select(),this.grid?.notifyResize()},this.layer=null,this.parseInputValueFunction=({input:e})=>{const t=this._inputField,n=e.value,{required:i,type:o}=t;return i||""!==n?"number"===o||"date"===o?parseFloat(n):"text"===o?n.trim():n:null},this.store=null,this.template=null,this.updateRowItemFunction=({rowData:e,column:t,value:n})=>{e.item.feature.attributes[t.path]=n},this.updateStoreItemFunction=async({rowData:e,column:t,value:n})=>{if(!e||!this.store)return;const i=e.item.objectId,o=this.store.getObjectIdIndex(i)??e.index;await this.store.updateItem({index:o,name:t.path,value:n})}}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get description(){return this.template?.description??this.config?.description??this.field?.description??null}get editable(){const{config:e,editingEnabled:t,field:n,template:i}=this;return t?!1!==i?.editable&&(!1!==e?.editable&&n?.editable):i?i.editable:!!e&&(!0===e.editable&&n?.editable)}get header(){return this.template?.label||this.config?.label||this.alias||this.path||null}get hidden(){const{config:e}=this;return!1===e?.visible||this._get("hidden")||!1}set hidden(e){this._set("hidden",e)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,config:t,template:n}=this,i=e?.length,o=n?.input&&"maxLength"in n.input?n.input.maxLength:t?.maxLength;return!isNaN(o)&&o>=-1&&(-1===i||o<=i)?o:i}get minLength(){const{config:e,template:t,maxLength:n}=this,i=t?.input&&"minLength"in t.input?t.input.minLength:e?.minLength||null;return n&&i<=n?i:null}get name(){return this.field?.name}get nullable(){return this.field?.nullable??!1}get path(){return this.field?.name}get required(){const{config:e,field:t,template:n}=this,i=t?.nullable,o=e?.required,a=n?.required;return this.editable&&(!i||!0===o||!0===a)}get sortable(){return this.template?!1!==this.template?.sortable:!1!==this.config?.sortable}createInputElement({rowData:e,value:t}){const{item:n}=e;if(!n||!n.feature)return null;this._inputField=this._setUpInputField(n.feature,t);const{field:i,maxLength:o,minLength:a,required:r}=this,{domain:l}=this._inputField;let s=null;"coded-value"===l?.type?(s=this._createSelectElement(t,l.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),this._inputField),s.onchange=()=>{s.onblur=null,p()}):(s=document.createElement("input"),s.type=d(i)?"number":"text",o>-1&&(s.maxLength=o),a>0&&(s.minLength=a)),s.classList.add(b.input),s.value=t,s.required=r;let u=!1;s.onkeydown=e=>{u=e.key===y.cancelEdit},s.onblur=()=>{s.onblur=null,p()};const p=()=>{u?this.cancel():this.submit(),this._inputField=null};return s}createInputContainer(){const e=document.createElement("div");return e.classList.add(b.inputContainer),e}createLockedElement(){const e=document.createElement("div");return e.classList.add(b.locked),e}getCellValue({path:e},{item:t}){return t?.feature?.attributes?.[e]??null}_renderDateEditors(e,t,i){const{config:o,messagesCommon:a,template:r}=this,l=e?new Date(e):new Date(Date.now()),s=new h({dateInputEnabled:!0,value:l}),u=new f({value:l});i.value=l.getTime().toString();let d=!e;const p=()=>{d=!0;const e=this._getCombinedDateTime(s.value,u.value);i.value=e.getTime().toString()},c=()=>{d?this.submit():this.cancel()},m=()=>{i.value=null,this.submit()};n((()=>[s.value,u.value]),(()=>p()));const g=document.createElement("div"),y=document.createElement("div");s.container=g,u.container=y;const v=document.createElement("button");v.classList.add(b.button,b.saveIcon),v.onclick=()=>c(),v.title=a?.save;const _=document.createElement("button");_.classList.add(b.button,b.trashIcon),_.onclick=()=>m(),_.title=a?.clear;const F=document.createElement("div");F.classList.add(b.dateInputWrapper),F.appendChild(g),(r&&r.input&&"datetime-picker"===r.input.type&&!1!==r.input.includeTime||o&&!1!==o.includeTime)&&F.appendChild(y);const C=document.createElement("div");C.classList.add(b.dateInputContainer),C.appendChild(F),C.appendChild(v),C.appendChild(_),s.when((()=>this.grid?.notifyResize())),u.when((()=>this.grid?.notifyResize())),this.removeCellContent(t),t.appendChild(C),this.grid?.notifyResize()}_createSelectElement(e,t,n){let i=!1;const o=t.map((t=>{t.value===e&&(i=!0);const n=document.createElement("option");return n.text=t.name,n.value=t.value,n}));if(null!=e&&""!==e&&!i){const t=document.createElement("option");t.text=e,t.value=e,o.unshift(t)}if(!n.required&&null==n.value){const e=document.createElement("option");e.value="",o.unshift(e)}const a=document.createElement("select");return o.forEach((e=>a.add(e))),a.value=e,a}_setUpInputField(e,t){const{config:n,field:i,layer:o}=this,a=new c({config:n,feature:e,initialFeature:e.clone(),field:i,layer:o,group:null,messages:null});return a.set("value",t),a}_isDomainCompatible(e){const{field:t}=this;if(e&&"coded-value"===e.type){const n=typeof e.codedValues[0].code;if("string"===n&&p(t)||"number"===n&&d(t))return!0}return!(!e||"range"!==e.type||!d(t))}_getDomainForFeature(e){const{config:t,layer:n,name:i,template:o}=this;if("wfs"===n.type||"geojson"===n.type||"csv"===n.type)return null;if(o?.domain&&this._isDomainCompatible(o.domain))return o.domain;const{typeIdField:a}=n,r=a===i,l=this.field.domain;if(r&&!l)return new u({name:"__internal-type-based-coded-value-domain__",codedValues:n.types.map((({id:e,name:t})=>({code:e,name:t})))});const s=a&&n.getFieldDomain(i,{feature:e})||l,d=t?.domain;return this._isDomainCompatible(d)?d:s}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const n=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return n&&n.length?n[0].name:e}return null}_getCombinedDateTime(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}_getDateFormatOptions(){const{config:e,template:t}=this,n=t?.format?.dateFormat||e?.format?.dateFormat;return n?r(n):t&&t.input&&"includeTime"in t.input==!1||!1===e?.includeTime?F:_}};e([i({readOnly:!0})],E.prototype,"alias",null),e([i()],E.prototype,"cellValueFormatFunction",void 0),e([i()],E.prototype,"cellValueValidatorFunction",void 0),e([i()],E.prototype,"config",void 0),e([i({readOnly:!0})],E.prototype,"defaultValue",null),e([i({readOnly:!0})],E.prototype,"description",null),e([i({readOnly:!0})],E.prototype,"editable",null),e([i()],E.prototype,"editingEnabled",void 0),e([i()],E.prototype,"expressionInfos",void 0),e([i()],E.prototype,"field",void 0),e([i()],E.prototype,"formatFunction",void 0),e([i({readOnly:!0})],E.prototype,"header",null),e([i()],E.prototype,"hidden",null),e([i()],E.prototype,"headerRenderFunction",void 0),e([i()],E.prototype,"inputRenderFunction",void 0),e([i()],E.prototype,"layer",void 0),e([i({readOnly:!0})],E.prototype,"loadingMessage",null),e([i()],E.prototype,"maxLength",null),e([i()],E.prototype,"minLength",null),e([i({readOnly:!0})],E.prototype,"name",null),e([i({readOnly:!0})],E.prototype,"nullable",null),e([i()],E.prototype,"parseInputValueFunction",void 0),e([i({readOnly:!0})],E.prototype,"path",null),e([i({readOnly:!0})],E.prototype,"required",null),e([i()],E.prototype,"sortable",null),e([i()],E.prototype,"store",void 0),e([i()],E.prototype,"template",void 0),e([i()],E.prototype,"updateRowItemFunction",void 0),e([i()],E.prototype,"updateStoreItemFunction",void 0),E=e([o("esri.widgets.FeatureTable.FieldColumn")],E);const I=E;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.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import{addTokenParameter as s}from"../../../kernel.js";import l 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 h}from"../../../core/promiseUtils.js";import{on as y,watch as m,whenOnce as f,initial as p}from"../../../core/reactiveUtils.js";import{px2pt as g}from"../../../core/screenUtils.js";import{addQueryParameters as b}from"../../../core/urlUtils.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{OriginId as L}from"../../../core/accessorSupport/PropertyOrigin.js";import{EffectView as v}from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as w}from"../../../layers/effects/jsonUtils.js";import{ExportImageParameters as E}from"../../../layers/support/ExportImageParameters.js";import{isDateField as C}from"../../../layers/support/fieldUtils.js";import{fromJSON as I}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as R}from"../../../renderers/support/rendererConversion.js";import F from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{applyCIMSymbolColor as V}from"../../../symbols/support/cimSymbolUtils.js";import{SymbolSizeDefaults as T}from"../../../symbols/support/previewUtils.js";import{renderSymbol as z}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as x,renderDotDensityPreviewHTML as j,renderPieChartPreviewHTML as D,renderPreviewHTML as O}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as P}from"../../../symbols/support/utils.js";import{getClusterSizeVariable as M}from"./clusterUtils.js";import{getColorFromPointCloudStops as A,getRampStopsForPointCloud as B,getStrectchRampStops as U,getRampStops as k}from"./colorRampUtils.js";import{getHeatmapRampStops as N}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as q,getRelationshipRampElement as $}from"./relationshipRampUtils.js";import{getRampStops as W,REAL_WORLD_MAX_SIZE as G,REAL_WORLD_MIN_SIZE as J}from"./sizeRampUtils.js";import{SPECIAL_CHARS_LESS_THAN as Q,SPECIAL_CHARS_GREATER_THAN as H,getSymbolForFlowRenderer as X,getMedianColor as K,RGB_IMG_SOURCE as Y}from"./utils.js";import{formatNumberLabel as Z}from"../../smartMapping/support/utils.js";import ee from"../../../symbols/SimpleMarkerSymbol.js";import te from"../../../symbols/SimpleFillSymbol.js";const se="https://utility.arcgis.com/sharing/tools/legend",le="esri.layers.ImageryLayer",re="esri.layers.ImageryTileLayer",ie="esri.layers.WCSLayer",ne=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,ae=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),oe={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]},ue=new ee({size:6,outline:{color:[128,128,128,.5],width:.5}}),ce=new te({style:"solid"});function de(e){return"flow"===e.type}function he(e){return"vector-field"===e.type}function ye(e){return"raster-colormap"===e.type}function me(e){return"raster-stretch"===e.type}function fe(e){return"raster-shaded-relief"===e.type}function pe(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function ge(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function be(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function Se(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function _e(e){return ve(e)||we(e)||Ee(e)||Le(e)}function Le(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function ve(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function we(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function Ee(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function Ie(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function Re(e,t){return pe(e)||ge(e)||be(e)||Se(e)||Ce(e)||Ie(e)?"2d"===t.type||R(e):me(e)||ye(e)||fe(e)||ve(e)||we(e)||Ee(e)||he(e)||de(e)}function Fe(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Ve(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function Te(e){return"esri.layers.VoxelLayer"===e.declaredClass}function ze(e){return"esri.layers.WMSLayer"===e.declaredClass}function xe(e){return"esri.layers.WMTSLayer"===e.declaredClass}function je(e){return"esri.layers.MapImageLayer"===e.declaredClass}function De(e){return"esri.layers.TileLayer"===e.declaredClass}function Oe(e){return"esri.layers.FeatureLayer"===e.declaredClass}function Pe(e){return e.declaredClass===le}function Me(e){return e.declaredClass===re}function Ae(e){return e.declaredClass===ie}function Be(e){return"stretch-ramp"===e.type}function Ue(e){return"univariate-color-size"===("authoringInfo"in e&&e?.authoringInfo)?.type}function ke(e){const t="authoringInfo"in e&&e?.authoringInfo;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}const Ne=new ee({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let qe={},$e=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([y((()=>this.children),"change",(t=>{const{added:s,removed:l}=t,r=this._handles;s.forEach((t=>{const s=`activeLayerInfo-ready-watcher-${t.layer.uid}`;r.add(m((()=>t.ready),e,p),s)})),l.forEach((e=>r.remove(e.layer.uid))),e()}))]),this.keepCacheOnDestroy||(qe={})}destroy(){this._handles.destroy(),this._handles=null,this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(qe=null)}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new v,t.effect=e.effect,t.endTransitions(),t.scale=this.scale),t}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,s=this.layer.parent,l=s&&"uid"in s?this._getParentLayerOpacity(s):null;return null!=t?t*e:null!=l?l*e:e}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){if("cluster"===e.featureReduction.type)return!0;if("binning"===e.featureReduction.type&&"renderer"in e.featureReduction&&e.featureReduction.renderer)return this._isRendererScaleDriven(e.featureReduction.renderer)}return"renderer"in e&&e.renderer?this._isRendererScaleDriven(e.renderer):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(Oe(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet&&e.featureSet.features.length){const t=e.layerDefinition,s=t&&t.drawingInfo,l=s&&I(s.renderer),r=ae.read(t.geometryType);return l?this._getRendererLegendElements(l,{title:e.name,geometryType:r}):(o.getLogger(this.declaredClass).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(s){o.getLogger(this.declaredClass).warn("error while building legend for layer!",s)}}async buildLegendElementsForRenderer(e){try{const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getRendererLegendElements(e):[],this.notifyChange("ready")}catch(t){o.getLogger(this.declaredClass).warn("error while building legend for layer!",t)}}async buildLegendElementsForFeatureReduction(e){try{const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getLegendElementsForFeatureReduction(e):[],this.notifyChange("ready")}catch(t){o.getLogger(this.declaredClass).warn("error while building legend for layer!",t)}}async buildLegendElementsForTools(){const e=this.layer;if(Te(e))this._constructLegendElementsForVoxellayer();else if(xe(e))this._constructLegendElementsForWMTSlayer();else if(ze(e))await this._constructLegendElementsForWMSSublayers();else if(Fe(e))await this._constructLegendElementsForBuildingSceneLayer();else if(je(e)||De(e)||Ve(e))await this._constructLegendElementsForSublayers();else{this._handles.remove("imageryLayers-watcher");let t="default";if(Pe(e)){t=(e?.renderingRule?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}await this._getLegendLayers(`${e.uid}-${t}`).then((async t=>{this.legendElements=[],this.notifyChange("ready");const s=t.map((async t=>{if(Pe(e)||Me(e)){const t=m((()=>["renderingRule"in e&&e.renderingRule,e.bandIds]),(()=>h((async()=>{qe.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()}))()));this._handles.add(t,"imageryLayers-watcher")}const s=this._generateSymbolTableElementForLegendLayer(t);s&&s.infos.length&&(Pe(e)&&(s.title=e.title),this.legendElements.push(s)),this.notifyChange("ready")}));await d(s)})).catch((e=>{o.getLogger(this.declaredClass).warn("Request to server for legend has failed!",e)}))}}async _isLayerInCurrentView(){const e=this.layer,t=this.layerView,s=t&&"createQuery"in t&&"queryFeatureCount"in t;if(!s&&!(t&&"createQuery"in e&&"queryFeatureCount"in e))return!0;await f((()=>!t.updating));const l=s?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();l.geometry=this.view.extent;return 0!==(s?"queryFeatureCount"in t&&await t.queryFeatureCount(l):"queryFeatureCount"in e&&await e.queryFeatureCount(l))}_getParentLayerOpacity(e){let t=1;const s=e.parent;return s&&"uid"in s&&(t=this._getParentLayerOpacity(s)),e.opacity*t}_isGroupActive(){const e=this.children;return!!e.length&&e.some((e=>e.ready))}_isRendererScaleDriven(e){if("dot-density"===e.type)return!0;const t="valueExpression"in e&&e.valueExpression;if(ne.test(t))return!0;const s="visualVariables"in e&&e.visualVariables;return!!s&&s.some((e=>this._isScaleDrivenSizeVariable(e)))}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,s=t.minSize,l=t.maxSize;return"object"==typeof s&&s?this._isScaleDrivenSizeVariable(s):"object"==typeof l&&l?this._isScaleDrivenSizeVariable(l):!!t.expression||ne.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&&je(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const s of t.sourceJSON.layers)if(s.id===e.source.mapLayerId&&(s.minScale>0||s.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxellayer(){this.legendElements=[],this._handles.remove("voxel-style-watcher"),this._handles.remove("voxel-current-variable");const e=this.layer;this._handles.add(m((()=>e.currentVariableId),(()=>this._constructLegendElementsForVoxellayer())),"voxel-current-variable"),this._handles.add(m((()=>e.getVariableStyles()),(()=>this._constructLegendElementsForVoxellayer())),"voxel-style-watcher");const t=u(e.getVariableStyle(null)),s=[];if(t)if(t.uniqueValues?.length){const e=[];t.uniqueValues.forEach((t=>{t.enabled&&e.push({label:t.label||`${t.value}`,value:t.value,symbol:new te({color:t.color,outline:null})})})),e.length&&s.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:l}=t.transferFunction,r=e.toArray().reverse(),i=l.map(((e,t)=>`${0===t?Q:H} ${Z(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],s.push({type:"color-ramp",title:t.label,infos:n,preview:x(r.map((e=>e.color)))})}const l=e.opacity,r=s.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!!e?.symbol)).map((e=>this._getSymbolPreview(e,l)));await d(r),this.legendElements=s,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this._handles.remove("wmts-activeLayer-watcher");const e=this.layer.activeLayer;if(this._handles.add(m((()=>{const{layer:e}=this;return e&&"activeLayer"in e&&e.activeLayer}),(()=>this._constructLegendElementsForWMTSlayer())),"wmts-activeLayer-watcher"),e.styleId&&e.styles){let t=null;e.styles.some((s=>e.styleId===s.id&&(t=s.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(m((()=>{const{layer:e}=this;return e&&"sublayers"in e&&e.sublayers}),(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher"),this.legendElements=await this._generateLegendElementsForWMSSublayers(e.sublayers,t),this.notifyChange("ready")}async _generateLegendElementsForWMSSublayers(e,t){const s=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher");const l=e.toArray();for(const r of l){const e=m((()=>[r.title,r.visible,r.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&&s.unshift(e)}}return s}async _generateSymbolTableElementForWMSSublayer(e,t){if(!e.legendUrl&&e.sublayers){const s=(await this._generateLegendElementsForWMSSublayers(e.sublayers,t)).filter((e=>e));return{type:"symbol-table",title:e.title,infos:s}}return this._generateSymbolTableElementForLegendUrl(e,t)}async _generateSymbolTableElementForLegendUrl(e,t){let s=e.legendUrl;if(!s)return;const r={type:"symbol-table",title:e.title||e.name||e.id&&e.id+"",infos:[]};t&&(s=b(s,t));let i=null;const n=e.layer?.opacity;try{i=(await l(s,{responseType:"image"})).data,i&&(i.style.opacity=n)}catch{}return r.infos.push({src:s,preview:i,opacity:n}),r}_getLegendLayers(e,t){const s=qe&&qe[e];return s?Promise.resolve(s):this._legendRequest(t).then((t=>{const s=t.layers;return qe[e]=s,s}))}_legendRequest(e){const t=this.layer;let s={f:"json",dynamicLayers:e};if(Pe(t)){const e=t.exportImageServiceParameters.renderingRule;if(e&&(s.renderingRule=JSON.stringify(e.rasterFunctionDefinition||e.toJSON())),t.bandIds&&(s.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:l,customParameters:r}=t;s={raster:e,viewId:l,...s,...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=se+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return l(r,{query:s}).then((e=>e.data))}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this._handles.remove("sublayers-watcher");const e=this.layer;this._handles.add(m((()=>e.sublayers),(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this.declaredClass).warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForBuildingSublayers(e,t){let s=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");const l=e.toArray();for(const r of l){const e=m((()=>["renderer"in r&&r.renderer,r.opacity,r.title,r.visible]),(()=>this._constructLegendElementsForBuildingSceneLayer()));if(this._handles.add(e,"sublayers-watcher"),!this.respectLayerVisibility||r.visible){const e=r&&null!=r.opacity?r.opacity:null,l=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,l);e.infos.push(...t),s=[e,...s]}else if(r.renderer){s=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:l,sublayer:r}),...s]}}}return s.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(m((()=>e.sublayers),(()=>this._constructLegendElementsForSublayers)),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this.declaredClass).warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForSublayers(e,t,s){const l=this.layer;let r=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForSublayers())),"sublayers-watcher");let i=e.toArray();!s&&this.sublayerIds&&this.sublayerIds.length&&(i=this.sublayerIds.map((e=>l.findSublayerById(e))).filter(Boolean));for(const n of i){const e=m((()=>[n.renderer,n.opacity,n.title,n.visible,n.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,i=null!=e?e*t:t,a=!!Ve(l)||n.originIdOf("renderer")>L.SERVICE;if(n.renderer&&!n.sublayers&&a){await n.load();r=[...await this._getRendererLegendElements(n.renderer,{title:n.title,opacity:i,sublayer:n}),...r]}else{const e=await this._generateSymbolTableElementForSublayer(n,i,s);e&&r.unshift(e)}}}return r.filter((e=>!!e&&(!("infos"in e)||e.infos.length>0)))}async _generateSymbolTableElementForSublayer(e,t,s){if(!s){s=new Map;const t=this.layer,l=e.source;let r=null;if(!(!l||"map-layer"===l.type&&l.mapLayerId===e.id&&(!l.gdbVersion||l.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>L.SERVICE||e.originIdOf("labelingInfo")>L.SERVICE||e.originIdOf("labelsVisible")>L.SERVICE){const e=new E({layer:this.layer});r=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const i=r||`${t.uid}-default`;(await this._getLegendLayers(i,r)).forEach((e=>s.set(e.layerId,e)))}const l=s.get(e.id);if((!l||l?.subLayerIds&&l.defaultVisibility)&&e.sublayers){const l=await this._generateLegendElementsForSublayers(e.sublayers,t,s);return{type:"symbol-table",title:e.title,infos:l}}return this._generateSymbolTableElementForLegendLayer(l,e,t)}_generateSymbolTableElementForLegendLayer(e,t,s){if(!e||!e.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const l=t?.renderer;let r=t?.title||e.layerName;if(l&&(!t||t?.originIdOf("renderer")>L.SERVICE)){const e=t?.title||this._getRendererTitle(l,t);e&&(r&&"string"!=typeof e&&"title"in e&&(e.title=r),r=e)}const i={type:"symbol-table",title:r,legendType:e.legendType?e.legendType:null,infos:[]},n=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return e.legendGroups?.length>0?e.legendGroups.forEach((t=>{const l={type:"symbol-table",title:t.heading,legendType:e.legendType?e.legendType:null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter((e=>e.groupId===t.id)),e.layerId,s)};l.infos?.length>0&&i.infos.push(l)})):i.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,s),i.infos.length>0?i:null}_generateSymbolTableElementInfosForLegendLayer(e,t,l){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=s(`${this.layer.url}/${t}/images/${r}`)}return{label:e.label,src:r,opacity:l??this.opacity,width:e.width,height:e.height}})).filter((e=>!!e))}_isSublayerInScale(e){const t=e.minScale||0,s=e.maxScale||0;return!(t>0&&t<this.scale||s>this.scale)}_isLegendLayerInScale(e,t){const s=t||this.layer;let l=null,r=null,i=!0;return!s.minScale&&0!==s.minScale||!s.maxScale&&0!==s.maxScale?(0===e.minScale&&s.tileInfo&&(l=s.tileInfo.lods[0].scale),0===e.maxScale&&s.tileInfo&&(r=s.tileInfo.lods[s.tileInfo.lods.length-1].scale)):(l=Math.min(s.minScale,e.minScale)||s.minScale||e.minScale,r=Math.max(s.maxScale,e.maxScale)),(l>0&&l<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 s=t.renderer,l=e.some((e=>e.values));let r=null,i=null;return l&&e.some(((e,t)=>(e.values||(r=t,i=e,i.label||(i.label="others")),null!=i))),s?"unique-value"===s.type?i&&(e.splice(r,1),e.push(i)):"class-breaks"===s.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={}){if(!Re(e,this.view))return o.getLogger(this.declaredClass).warn(`Renderer of type '${e.type}' not supported!`),[];if(_e(e))return this._constructPointCloudRendererLegendElements(e,t);if(Ce(e))return this._constructDotDensityRendererLegendElements(e);const s=await this._loadRenderer(e);return Ie(s)?this._constructPieChartRendererLegendElements(s):this._constructRendererLegendElements(s,t)}async _getLegendElementsForFeatureReduction(e){let t=null;return"binning"===e.type?t=e.renderer:"cluster"===e.type&&(t=this._getClusterRenderer(e)),t?this._getRendererLegendElements(t):[]}_getPointCloudRendererTitle(e){return e.legendOptions&&e.legendOptions.title||e.field}_constructPointCloudRendererLegendElements(e,t={}){const s=t.title,l=[];let r=null,i=null;if(ve(e))r={type:"symbol-table",title:s||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(ue,e.color)})}));else if(we(e)){const t=e.stops;let l=null;if(t.length&&(1===t.length&&(l=t[0].color),!l)){const e=t[0].value,s=t[t.length-1].value;if(null!=e&&null!=s){l=A(e+(s-e)/2,t)}}r={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(ue,l||ue.color)}]};const n=B(e.stops);i={type:"color-ramp",title:s||this._getPointCloudRendererTitle(e),infos:n,preview:x(n.map((e=>e.color)))}}else Ee(e)&&(r={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos.forEach((e=>{r.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(ue,e.color)})})));r&&r.infos.length&&l.push(r),i&&i.infos.length&&l.push(i);const n=l.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((()=>l))}_getElementInfoForDotDensity(e,t){const{backgroundColor:s,outline:l,dotSize:r}=e,i=this.effectList?.effects.map((e=>e.toJSON())),n=w(i),a=r+"-"+t+"-"+s+"-"+(l&&JSON.stringify(l.toJSON()))+"-"+n,o=this._dotDensityUrlCache,u=o.has(a)?o.get(a):j(e,t);o.set(a,u);const c={shape:{type:"image",x:0,y:0,width:u.width,height:u.height,src:u.src},fill:null,stroke:null,offset:[0,0]},d=z([[c]],[u.width,u.height],{effectView:this.effectList});return{opacity:1,src:u.src,preview:d,width:u.width,height:u.height}}_constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),s=e.legendOptions&&e.legendOptions.unit,l={type:"symbol-table",title:{value:t&&Math.round(t),unit:s||""},infos:[]};return e.attributes.forEach((t=>{const s=this._getElementInfoForDotDensity(e,t.color);s.label=t.label||t.valueExpressionTitle||t.field,l.infos.push(s)})),Promise.resolve([l])}async _constructPieChartRendererLegendElements(e){const t=this.layer.opacity,s=[],l="Others",r=e.outline;e.attributes.forEach((e=>{const t=new ee({color:e.color,outline:r}),l=e.label||e.valueExpressionTitle||e.field;s.push({label:l,symbol:t})}));const i=s.length?[...s]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const t=new ee({color:e.othersCategory.color,outline:r});s.push({label:e.othersCategory.label||l,symbol:t})}if(e.defaultColor?.a){const t=new ee({color:e.defaultColor,outline:r});s.push({label:e.defaultLabel,symbol:t})}const n=await this._getVisualVariableLegendElements(e,this.layer)||[];if(s.length){n.unshift({type:"symbol-table",title:null,infos:s});const t=i.filter((e=>e.label!==l)).map((e=>e.symbol.color)).filter(Boolean),a=D(t,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,effectList:this.effectList,outline:r});n.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:s,preview:a})}const a=n.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!!e?.symbol&&!e?.preview)).map((e=>this._getSymbolPreview(e,t,{effectList:this.effectList})));return await d(a),n}async _constructRendererLegendElements(e,t={}){const{title:s,sublayer:l}=t,r=l||this.layer;this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const i=await this._getVisualVariableLegendElements(e,r)||[],n={type:"symbol-table",title:s||this._getRendererTitle(e,r),infos:[]};let a=null,o=!1;const c=new Set;if(de(e)&&!this._hasSizeRamp){const t=await X(e);n.infos.push({label:null,symbol:t})}else if(Ue(e)){let t=s;const l=ke(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",r=i.findIndex((e=>"color-ramp"===e.type)),n=-1!==r?i.splice(r,1)[0]:null,a=i.findIndex((e=>"size-ramp"===e.type)),o=-1!==a?i.splice(a,1)[0]:null,u=[];n&&(t=n.title,u.push(n)),o&&(t=o.title,u.push(o)),u.length>0&&i.push({type:l,title:t,infos:u})}else if(Se(e)){const t=N(e);i.push({type:"heatmap-ramp",title:s||this._getRendererTitle(e,r),infos:t,preview:x(t.map((e=>e.color)),{effectList:this.effectList})})}else if(be(e)){const t=e&&e.authoringInfo;if(t&&"relationship"===t.type){const{focus:s,numClasses:l,field1:a,field2:o}=t;if(l&&a&&o){const t=[a,o];let u=q(s)||0;for(const e of t){const{field:t,normalizationField:s,label:l}=e,i=l||{field:this._getFieldAlias(t,r),normField:s&&this._getFieldAlias(s,r)},a=Ne.clone();a.angle=u,n.infos.push({label:i,symbol:a}),c.add(a),u+=90}const d=$({focus:s,numClasses:l,infos:e.uniqueValueInfos});i.unshift(d)}}else if(Pe(this.layer)||Me(this.layer))e.uniqueValueInfos.forEach((e=>{e.symbol&&n.infos.push({label:e.label||e.value,value:e.value,symbol:e.symbol})}));else{const{field:t,field2:s,field3:l,fieldDelimiter:i,valueExpression:a}=e,o=!(!t&&!a||!s&&!l),u=[];if(e.uniqueValueGroups.forEach((e=>{const n={type:"symbol-table",title:e.heading,infos:[]};e.classes.forEach((e=>{const{symbol:u,values:c}=e;if(u){const d=[],h=[];for(const e of c){const{value:n,value2:u,value3:c}=e,y=[],m=[];(t||a)&&(y.push(n),m.push(this._getDomainName(t,n,r))),s&&(y.push(u),m.push(this._getDomainName(s,u,r))),l&&(y.push(c),m.push(this._getDomainName(l,c,r))),d.push(o?y.join(i||""):y[0]),h.push(m.join(" - "))}const y=d.join(", ");let m=e.label;if(!m){const e=h.filter(Boolean);m=e.length?e.join(", "):y}n.infos.push({label:m,value:y,symbol:u})}})),n.infos.length&&u.push(n)})),u.length){const e=u[0];1===u.length&&"title"in e&&!e.title?n.infos.push(...e.infos):n.infos.push(...u)}}e.defaultSymbol&&(n.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),o=!0)}else if(ge(e)){a=this._isUnclassedRenderer(e);(!a||!this._hasSizeRamp)&&(e.classBreakInfos.forEach((e=>{e.symbol&&n.infos.unshift({label:e.label||(a?null:e.minValue+" - "+e.maxValue),value:[e.minValue,e.maxValue],symbol:e.symbol})})),a&&(n.title=null),this._updateInfosforClassedSizeRenderer(e,n.infos)),e.defaultSymbol&&!a&&(n.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),o=!0)}else if(me(e))if(Me(this.layer)||Ae(this.layer)){const t=this._constructTileImageryStretchRendererElements(e);Be(t)?i.push(t):n.infos=t}else{const t=this.layer;let s,l;e.statistics&&e.statistics.length&&(s=null!=e.statistics[0].min?e.statistics[0].min:e.statistics[0][0],l=null!=e.statistics[0].max?e.statistics[0].max:e.statistics[0][1]);let r=[];const a=u(t.renderingRule?await t.generateRasterInfo(t.renderingRule):t.serviceRasterInfo),o=a.keyProperties.BandProperties,c=oe[a.pixelType.toLowerCase()];if(1===a.bandCount){const r=t.bandIds?.[0]||0;s=null!=s?s:a.statistics?a.statistics[r].min:c[0],l=null!=l?l:a.statistics?a.statistics[r].max:c[1],s||l?i.push(this._getStretchLegendElements(e,{min:s,max:l})):this._getServerSideLegend()}else t.bandIds&&1===t.bandIds.length?(s=null!=s?s:a.statistics?a.statistics[t.bandIds[0]].min:c[0],l=null!=l?l:a.statistics?a.statistics[t.bandIds[0]].max:c[1],s||l?i.push(this._getStretchLegendElements(e,{min:s,max:l})):this._getServerSideLegend()):a.bandCount>=3?o&&o.length>=a.bandCount?t.bandIds&&3===t.bandIds.length?(r=t.bandIds.map((e=>o[e].BandName)),n.infos=this._createSymbolTableElementMultiBand(r)):"lerc"===t.format?(r=[0,1,2].map((e=>o[e].BandName)),n.infos=this._createSymbolTableElementMultiBand(r)):this._getServerSideLegend():"lerc"===t.format?(r=["band1","band2","band3"],n.infos=this._createSymbolTableElementMultiBand(r)):this._getServerSideLegend():this._getServerSideLegend()}else if(ye(e))e.colormapInfos.forEach((e=>{n.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(ce,e.color)})}));else if(pe(e)){let s=e.symbol;switch(t.geometryType){case"point":s="pointSymbol"in r&&r.pointSymbol;break;case"polyline":s="lineSymbol"in r&&r.lineSymbol;break;case"polygon":s="polygonSymbol"in r&&r.polygonSymbol}const l=this._hasClusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&l&&n.infos.push({label:e.label,symbol:s})}else if(he(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),n.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach((e=>{n.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})})):n.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else fe(e)&&i.push(this._getStretchLegendElements(e,{min:0,max:255}));const h=e.defaultSymbol;!h||o||pe(e)||a&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||i.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:h}]}),n.infos.length&&i.unshift(n);const y=null==t.opacity?this.opacity:t.opacity,m=this._isTallSymbol("visualVariables"in e&&e.visualVariables),f=Pe(this.layer)||Me(this.layer),p=i.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!!e?.symbol)).map((e=>this._getSymbolPreview(e,y,{isDefault:e.symbol===h,applyScaleDrivenSize:!c.has(e.symbol),symbolConfig:{isTall:m,isSquareFill:f},effectList:c.has(e.symbol)?null:this.effectList})));return e=null,await d(p),i}_getServerSideLegend(){setTimeout((()=>this.buildLegendElementsForTools()),0)}_getAllInfos(e){const t=e?.infos;return t?t.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]):[e]}_constructTileImageryStretchRendererElements(e){const t=this.layer,{rasterInfo:s}=t.raster,l=s.bandCount||e.statistics.length;let r,i,n=[];const a=s.keyProperties&&s.keyProperties.BandProperties,o=e?.statistics?.length?e.statistics:s?.statistics;if(o)r=void 0!==o[0].min?o[0].min:o[0][0],i=o[0].max||o[0][1];else{const e=oe[s.pixelType.toLowerCase()];r=e[0],i=e[1]}if(t.hasStandardTime()&&(r=t.getStandardTimeValue(r),i=t.getStandardTimeValue(i)),1===s.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:r,max:i});function u(e){const l=(t?.bandIds?.length?t.bandIds:Array.from(Array(Math.min(s.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 n=a&&a.length>=l?u(a):u(),this._createSymbolTableElementMultiBand(n)}_getStretchLegendElements(e,t){const s=e.colorRamp,l=U(s,t);return{type:"stretch-ramp",title:"",infos:l,preview:x(l.map((e=>e.color)))}}_getClusterSymbol(){const e=this.layer,t="featureReduction"in e&&e.featureReduction,s=t&&"symbol"in t&&t.renderer;return s&&!0!==s?.authoringInfo?.isAutoGenerated?null:t&&"symbol"in t&&t.symbol}async _getSizeLegendElement(e,t,s,l){return{type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(t):e,infos:await W(s,t,await K(s),this.scale,this.view.type,l,this._hasClusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],s=["red","green","blue"];return e.forEach(((e,l)=>{t.push({label:{colorName:s[l],bandName:e},src:Y[l],opacity:this.opacity??1})})),t}_updateInfosforClassedSizeRenderer(e,t){const s=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,l=e.classBreakInfos.some((e=>P(e.symbol)));if(s&&l){const s=G,l=J,r=e.classBreakInfos.length,i=(s-l)/(r>1?r-1:r);t.forEach(((e,t)=>{e.size=s-i*t}))}}_isTallSymbol(e){let t=!1,s=!1;if(e)for(let l=0;l<e.length&&(!t||!s);l++){const r=e[l];"size"===r.type&&("height"===r.axis&&(t=!0),"width-and-depth"===r.axis&&(s=!0))}return t&&s}async _getSymbolPreview(e,t,s){let l=!s?.isDefault&&null==e.size&&this._hasSizeRamp?g(T.size):e.size;if(this._scaleDrivenSizeVariable&&s?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");l=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}return O(e.symbol,{size:l,opacity:t,scale:!1,symbolConfig:s?.symbolConfig,effectView:s?.effectList}).then((t=>(e.preview=t,e))).catch((()=>(e.preview=null,e)))}_getClusterRenderer(e){this._hasClusterSizeVariable=!1;const t="renderer"in this.layer&&this.layer.renderer,s=e.renderer?.clone()||t?.clone(),l=u(M(this.layerView._effectiveRenderer,this.view));if(l&&"visualVariables"in s){const t=s.visualVariables?.some((e=>"size"===e.type&&"outline"!==e.target&&!ne.test(e.valueExpression)));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:s}=e;l.legendOptions=new F({showLegend:t!==s})}const t=s.visualVariables||[];s.visualVariables=t.concat([l]),this._hasClusterSizeVariable=!0}}return s}async _loadRenderer(e){const t=[],s=e.clone(),l=await K(s);if(ge(s)||be(s)){const e=(s.classBreakInfos||s.uniqueValueInfos).map((e=>this._fetchSymbol(e.symbol,l).then((t=>{e.symbol=t})).catch((()=>{e.symbol=null}))));Array.prototype.push.apply(t,e)}return t.push(this._fetchSymbol(s.symbol||s.defaultSymbol,s.defaultSymbol?null:l).then((e=>{this._applySymbolToRenderer(s,e,pe(s))})).catch((()=>{this._applySymbolToRenderer(s,null,pe(s))}))),d(t).then((()=>s))}_applySymbolToRenderer(e,t,s){s?e.symbol=t:e.defaultSymbol=t}async _fetchSymbol(e,t){if(!e)throw new Error;if("web-style"===e.type){const s=this._webStyleSymbolCache;try{const l=await("2d"===this.view.type?e.fetchCIMSymbol({cache:s}):e.fetchSymbol({cache:s}));return this._getAppliedCloneSymbol(l,t)}catch{throw o.getLogger(this.declaredClass).warn("Fetching web-style failed!"),new Error}}return this._getAppliedCloneSymbol(e,t)}_getAppliedCloneSymbol(e,s){if(!e||!s)return e;const l=e.clone(),r=s&&s.toRgba();return l.type.includes("3d")?this._applyColorTo3dSymbol(l,r):"cim"===l.type?V(l,s):l.color&&(l.color=new t(r||l.color)),l}_applyColorTo3dSymbol(e,s){s&&e.symbolLayers.forEach((e=>{e&&(e.material||(e.material={}),e.material.color=new t(s))}))}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||!e.visualVariables||"vector-field"===e.type)return null;const s=e.visualVariables,l=[],r=[],i=[];for(const c of s)"color"===c.type?l.push(c):"size"===c.type?r.push(c):"opacity"===c.type&&i.push(c);const n=[...l,...r,...i];let a,o;if(0===l.length&&ge(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];a=t&&t.symbol}if(0===l.length&&pe(e)&&(a=e.symbol),a)if(a.type.includes("3d")){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 s=>{if(!s.legendOptions||!1!==s.legendOptions.showLegend){const l=de(e)?s.field:this._getRampTitle(s,t);let r=null;const i="getField"in t&&t.getField&&t.getField(s.field),n=i&&C(i);if("color"===s.type){const e=await k(s,null,n);r={type:"color-ramp",title:l,infos:e,preview:x(e.map((e=>e.color)),{effectList:u})},this._hasColorRamp||(this._hasColorRamp=!(null==r.infos||!r.infos.length))}else if("size"===s.type&&"outline"!==s.target)ne.test(s.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=s):(r=await this._getSizeLegendElement(l,s,e,n),this._hasSizeRamp||(this._hasSizeRamp=!(null==r.infos||!r.infos.length)));else if("opacity"===s.type){const e=await k(s,o,n);r={type:"opacity-ramp",title:l,infos:e,preview:x(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,s){if(e&&"function"!=typeof e){const l="getField"in s&&s.getField&&s.getField(e),r=l&&"getFieldDomain"in s&&s.getFieldDomain?s.getFieldDomain(l.name):null;return r&&"coded-value"===r.type?r.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,s=e.field;if("featureReduction"in t&&t.featureReduction&&"cluster"===t.featureReduction.type){const e=t.featureReduction,l="popupTemplate"in e&&e.popupTemplate,r=l&&l.fieldInfos;if(r)for(const t of r)if(t.fieldName===s)return"cluster_count"===s?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let s=e.field,l=e.normalizationField,r=!1,i=!1,n=!1,a=null;s="function"==typeof s?null:s,l="function"==typeof l?null:l;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 s=e[t];if("color"===s.type){if("ratio"===s.style){r=!0;break}if("percent"===s.style){i=!0;break}if("percent-of-total"===s.style){n=!0;break}}}}a={field:s&&this._getFieldAlias(s,t),normField:l&&this._getFieldAlias(l,t),ratio:r,ratioPercent:i,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const s=e;if(s.legendOptions&&s.legendOptions.title)return s.legendOptions.title;if(s.valueExpressionTitle)return s.valueExpressionTitle;let l=s.field,r=null,i=null;if(ge(s)&&(r=s.normalizationField,i="percent-of-total"===s.normalizationType),l="function"==typeof l?null:l,r="function"==typeof r?null:r,be(s)){const{field2:e,field3:r,fieldDelimiter:i}=s;let n=l&&this._getFieldAlias(l,t);return e&&(n=`<${n}>${i}<${this._getFieldAlias(e,t)}>`,r&&(n=`${n}${i}<${this._getFieldAlias(r,t)}>`)),n}let n=null;return(l||r)&&(n={field:l&&this._getFieldAlias(l,t),normField:r&&this._getFieldAlias(r,t),normByPct:i}),n}_getFieldAlias(e,t){const s="popupTemplate"in t&&t.popupTemplate,l=s&&s.fieldInfos;let r=null;l&&l.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));let n=null;const a="featureReduction"in t&&t.featureReduction;a&&(!r&&"popupTemplate"in a&&a.popupTemplate&&a.popupTemplate.fieldInfos&&a.popupTemplate.fieldInfos.some((t=>e?.toLowerCase()===t.fieldName?.toLowerCase()&&(r=t,!0))),"fields"in a&&a.fields&&(n=a.fields.find((t=>t.name?.toLowerCase()===e?.toLowerCase()))));const o=r||i||n;let u=null;return o&&(u=r?.label||i?.alias||n?.alias||"name"in o&&o.name||"fieldName"in o&&o.fieldName),u}_isUnclassedRenderer(e){const t=e.visualVariables;let s=!1;return ge(e)&&e.classBreakInfos&&1===e.classBreakInfos.length&&t&&(s=e.field?t.some((t=>!(!t||e.field!==t.field||(e.normalizationField||t.normalizationField)&&e.normalizationField!==t.normalizationField))):!!t.length),s}};e([S()],$e.prototype,"children",void 0),e([S({readOnly:!0})],$e.prototype,"effectList",null),e([S()],$e.prototype,"layerView",void 0),e([S()],$e.prototype,"layer",void 0),e([S()],$e.prototype,"legendElements",void 0),e([S({readOnly:!0})],$e.prototype,"opacity",null),e([S()],$e.prototype,"parent",void 0),e([S({readOnly:!0,dependsOn:[]})],$e.prototype,"ready",null),e([S()],$e.prototype,"hideLayersNotInCurrentView",void 0),e([S()],$e.prototype,"keepCacheOnDestroy",void 0),e([S()],$e.prototype,"respectLayerVisibility",void 0),e([S({readOnly:!0})],$e.prototype,"scale",null),e([S()],$e.prototype,"sublayerIds",void 0),e([S({readOnly:!0})],$e.prototype,"isScaleDriven",null),e([S()],$e.prototype,"title",void 0),e([S({readOnly:!0,dependsOn:["ready"],value:0})],$e.prototype,"version",null),e([S()],$e.prototype,"view",void 0),$e=e([_("esri.widgets.Legend.support.ActiveLayerInfo")],$e);const We=$e;export{We as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import{addTokenParameter as s}from"../../../kernel.js";import l 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 h}from"../../../core/promiseUtils.js";import{on as y,watch as m,whenOnce as f,initial as p}from"../../../core/reactiveUtils.js";import{px2pt as g}from"../../../core/screenUtils.js";import{addQueryParameters as b}from"../../../core/urlUtils.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{OriginId as L}from"../../../core/accessorSupport/PropertyOrigin.js";import{EffectView as v}from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as w}from"../../../layers/effects/jsonUtils.js";import{ExportImageParameters as E}from"../../../layers/support/ExportImageParameters.js";import{isDateField as C}from"../../../layers/support/fieldUtils.js";import{getPixelValueRange as I}from"../../../layers/support/rasterFormats/pixelRangeUtils.js";import{fromJSON as R}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as F}from"../../../renderers/support/rendererConversion.js";import V from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{applyCIMSymbolColor as T}from"../../../symbols/support/cimSymbolUtils.js";import{SymbolSizeDefaults as z}from"../../../symbols/support/previewUtils.js";import{renderSymbol as x}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as j,renderDotDensityPreviewHTML as D,renderPieChartPreviewHTML as O,renderPreviewHTML as P}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as M}from"../../../symbols/support/utils.js";import{getClusterSizeVariable as A}from"./clusterUtils.js";import{getColorFromPointCloudStops as B,getRampStopsForPointCloud as k,getStrectchRampStops as U,getRampStops as N}from"./colorRampUtils.js";import{getHeatmapRampStops as q}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as $,getRelationshipRampElement as W}from"./relationshipRampUtils.js";import{getRampStops as G,REAL_WORLD_MAX_SIZE as J,REAL_WORLD_MIN_SIZE as Q}from"./sizeRampUtils.js";import{SPECIAL_CHARS_LESS_THAN as H,SPECIAL_CHARS_GREATER_THAN as K,getSymbolForFlowRenderer as X,getMedianColor as Y,RGB_IMG_SOURCE as Z}from"./utils.js";import{formatNumberLabel as ee}from"../../smartMapping/support/utils.js";import te from"../../../symbols/SimpleMarkerSymbol.js";import se from"../../../symbols/SimpleFillSymbol.js";const le="https://utility.arcgis.com/sharing/tools/legend",re="esri.layers.ImageryLayer",ie="esri.layers.ImageryTileLayer",ne="esri.layers.WCSLayer",ae=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,oe=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),ue=new te({size:6,outline:{color:[128,128,128,.5],width:.5}}),ce=new se({style:"solid"});function de(e){return"flow"===e.type}function he(e){return"vector-field"===e.type}function ye(e){return"raster-colormap"===e.type}function me(e){return"raster-stretch"===e.type}function fe(e){return"raster-shaded-relief"===e.type}function pe(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function ge(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function be(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function Se(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function _e(e){return ve(e)||we(e)||Ee(e)||Le(e)}function Le(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function ve(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function we(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function Ee(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function Ie(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function Re(e,t){return pe(e)||ge(e)||be(e)||Se(e)||Ce(e)||Ie(e)?"2d"===t.type||F(e):me(e)||ye(e)||fe(e)||ve(e)||we(e)||Ee(e)||he(e)||de(e)}function Fe(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Ve(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function Te(e){return"esri.layers.VoxelLayer"===e.declaredClass}function ze(e){return"esri.layers.WMSLayer"===e.declaredClass}function xe(e){return"esri.layers.WMTSLayer"===e.declaredClass}function je(e){return"esri.layers.MapImageLayer"===e.declaredClass}function De(e){return"esri.layers.TileLayer"===e.declaredClass}function Oe(e){return"esri.layers.FeatureLayer"===e.declaredClass}function Pe(e){return e.declaredClass===re}function Me(e){return e.declaredClass===ie}function Ae(e){return e.declaredClass===ne}function Be(e){return"stretch-ramp"===e.type}function ke(e){return"univariate-color-size"===("authoringInfo"in e&&e?.authoringInfo)?.type}function Ue(e){const t="authoringInfo"in e&&e?.authoringInfo;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}const Ne=new te({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let qe={},$e=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([y((()=>this.children),"change",(t=>{const{added:s,removed:l}=t,r=this._handles;s.forEach((t=>{const s=`activeLayerInfo-ready-watcher-${t.layer.uid}`;r.add(m((()=>t.ready),e,p),s)})),l.forEach((e=>r.remove(e.layer.uid))),e()}))]),this.keepCacheOnDestroy||(qe={})}destroy(){this._handles.destroy(),this._handles=null,this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(qe=null)}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new v,t.effect=e.effect,t.endTransitions(),t.scale=this.scale),t}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,s=this.layer.parent,l=s&&"uid"in s?this._getParentLayerOpacity(s):null;return null!=t?t*e:null!=l?l*e:e}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){if("cluster"===e.featureReduction.type)return!0;if("binning"===e.featureReduction.type&&"renderer"in e.featureReduction&&e.featureReduction.renderer)return this._isRendererScaleDriven(e.featureReduction.renderer)}return"renderer"in e&&e.renderer?this._isRendererScaleDriven(e.renderer):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(Oe(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet&&e.featureSet.features.length){const t=e.layerDefinition,s=t&&t.drawingInfo,l=s&&R(s.renderer),r=oe.read(t.geometryType);return l?this._getRendererLegendElements(l,{title:e.name,geometryType:r}):(o.getLogger(this.declaredClass).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(s){o.getLogger(this.declaredClass).warn("error while building legend for layer!",s)}}async buildLegendElementsForRenderer(e){try{const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getRendererLegendElements(e):[],this.notifyChange("ready")}catch(t){o.getLogger(this.declaredClass).warn("error while building legend for layer!",t)}}async buildLegendElementsForFeatureReduction(e){try{const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getLegendElementsForFeatureReduction(e):[],this.notifyChange("ready")}catch(t){o.getLogger(this.declaredClass).warn("error while building legend for layer!",t)}}async buildLegendElementsForTools(){const e=this.layer;if(Te(e))this._constructLegendElementsForVoxellayer();else if(xe(e))this._constructLegendElementsForWMTSlayer();else if(ze(e))await this._constructLegendElementsForWMSSublayers();else if(Fe(e))await this._constructLegendElementsForBuildingSceneLayer();else if(je(e)||De(e)||Ve(e))await this._constructLegendElementsForSublayers();else{this._handles.remove("imageryLayers-watcher");let t="default";if(Pe(e)){t=(e?.renderingRule?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}await this._getLegendLayers(`${e.uid}-${t}`).then((async t=>{this.legendElements=[],this.notifyChange("ready");const s=t.map((async t=>{if(Pe(e)||Me(e)){const t=m((()=>["renderingRule"in e&&e.renderingRule,e.bandIds]),(()=>h((async()=>{qe.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()}))()));this._handles.add(t,"imageryLayers-watcher")}const s=this._generateSymbolTableElementForLegendLayer(t);s&&s.infos.length&&(Pe(e)&&(s.title=e.title),this.legendElements.push(s)),this.notifyChange("ready")}));await d(s)})).catch((e=>{o.getLogger(this.declaredClass).warn("Request to server for legend has failed!",e)}))}}async _isLayerInCurrentView(){const e=this.layer,t=this.layerView,s=t&&"createQuery"in t&&"queryFeatureCount"in t;if(!s&&!(t&&"createQuery"in e&&"queryFeatureCount"in e))return!0;await f((()=>!t.updating));const l=s?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();l.geometry=this.view.extent;return 0!==(s?"queryFeatureCount"in t&&await t.queryFeatureCount(l):"queryFeatureCount"in e&&await e.queryFeatureCount(l))}_getParentLayerOpacity(e){let t=1;const s=e.parent;return s&&"uid"in s&&(t=this._getParentLayerOpacity(s)),e.opacity*t}_isGroupActive(){const e=this.children;return!!e.length&&e.some((e=>e.ready))}_isRendererScaleDriven(e){if("dot-density"===e.type)return!0;const t="valueExpression"in e&&e.valueExpression;if(ae.test(t))return!0;const s="visualVariables"in e&&e.visualVariables;return!!s&&s.some((e=>this._isScaleDrivenSizeVariable(e)))}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,s=t.minSize,l=t.maxSize;return"object"==typeof s&&s?this._isScaleDrivenSizeVariable(s):"object"==typeof l&&l?this._isScaleDrivenSizeVariable(l):!!t.expression||ae.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&&je(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const s of t.sourceJSON.layers)if(s.id===e.source.mapLayerId&&(s.minScale>0||s.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxellayer(){this.legendElements=[],this._handles.remove("voxel-style-watcher"),this._handles.remove("voxel-current-variable");const e=this.layer;this._handles.add(m((()=>e.currentVariableId),(()=>this._constructLegendElementsForVoxellayer())),"voxel-current-variable"),this._handles.add(m((()=>e.getVariableStyles()),(()=>this._constructLegendElementsForVoxellayer())),"voxel-style-watcher");const t=u(e.getVariableStyle(null)),s=[];if(t)if(t.uniqueValues?.length){const e=[];t.uniqueValues.forEach((t=>{t.enabled&&e.push({label:t.label||`${t.value}`,value:t.value,symbol:new se({color:t.color,outline:null})})})),e.length&&s.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:l}=t.transferFunction,r=e.toArray().reverse(),i=l.map(((e,t)=>`${0===t?H:K} ${ee(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],s.push({type:"color-ramp",title:t.label,infos:n,preview:j(r.map((e=>e.color)))})}const l=e.opacity,r=s.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!!e?.symbol)).map((e=>this._getSymbolPreview(e,l)));await d(r),this.legendElements=s,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this._handles.remove("wmts-activeLayer-watcher");const e=this.layer.activeLayer;if(this._handles.add(m((()=>{const{layer:e}=this;return e&&"activeLayer"in e&&e.activeLayer}),(()=>this._constructLegendElementsForWMTSlayer())),"wmts-activeLayer-watcher"),e.styleId&&e.styles){let t=null;e.styles.some((s=>e.styleId===s.id&&(t=s.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(m((()=>{const{layer:e}=this;return e&&"sublayers"in e&&e.sublayers}),(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher"),this.legendElements=await this._generateLegendElementsForWMSSublayers(e.sublayers,t),this.notifyChange("ready")}async _generateLegendElementsForWMSSublayers(e,t){const s=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher");const l=e.toArray();for(const r of l){const e=m((()=>[r.title,r.visible,r.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&&s.unshift(e)}}return s}async _generateSymbolTableElementForWMSSublayer(e,t){if(!e.legendUrl&&e.sublayers){const s=(await this._generateLegendElementsForWMSSublayers(e.sublayers,t)).filter((e=>e));return{type:"symbol-table",title:e.title,infos:s}}return this._generateSymbolTableElementForLegendUrl(e,t)}async _generateSymbolTableElementForLegendUrl(e,t){let s=e.legendUrl;if(!s)return;const r={type:"symbol-table",title:e.title||e.name||e.id&&e.id+"",infos:[]};t&&(s=b(s,t));let i=null;const n=e.layer?.opacity;try{i=(await l(s,{responseType:"image"})).data,i&&(i.style.opacity=n)}catch{}return r.infos.push({src:s,preview:i,opacity:n}),r}_getLegendLayers(e,t){const s=qe&&qe[e];return s?Promise.resolve(s):this._legendRequest(t).then((t=>{const s=t.layers;return qe[e]=s,s}))}_legendRequest(e){const t=this.layer;let s={f:"json",dynamicLayers:e};if(Pe(t)){const e=t.exportImageServiceParameters.renderingRule;if(e&&(s.renderingRule=JSON.stringify(e.rasterFunctionDefinition||e.toJSON())),t.bandIds&&(s.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:l,customParameters:r}=t;s={raster:e,viewId:l,...s,...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=le+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return l(r,{query:s}).then((e=>e.data))}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this._handles.remove("sublayers-watcher");const e=this.layer;this._handles.add(m((()=>e.sublayers),(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this.declaredClass).warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForBuildingSublayers(e,t){let s=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");const l=e.toArray();for(const r of l){const e=m((()=>["renderer"in r&&r.renderer,r.opacity,r.title,r.visible]),(()=>this._constructLegendElementsForBuildingSceneLayer()));if(this._handles.add(e,"sublayers-watcher"),!this.respectLayerVisibility||r.visible){const e=r&&null!=r.opacity?r.opacity:null,l=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,l);e.infos.push(...t),s=[e,...s]}else if(r.renderer){s=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:l,sublayer:r}),...s]}}}return s.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(m((()=>e.sublayers),(()=>this._constructLegendElementsForSublayers)),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this.declaredClass).warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForSublayers(e,t,s){const l=this.layer;let r=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForSublayers())),"sublayers-watcher");let i=e.toArray();!s&&this.sublayerIds&&this.sublayerIds.length&&(i=this.sublayerIds.map((e=>l.findSublayerById(e))).filter(Boolean));for(const n of i){const e=m((()=>[n.renderer,n.opacity,n.title,n.visible,n.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,i=null!=e?e*t:t,a=!!Ve(l)||n.originIdOf("renderer")>L.SERVICE;if(n.renderer&&!n.sublayers&&a){await n.load();r=[...await this._getRendererLegendElements(n.renderer,{title:n.title,opacity:i,sublayer:n}),...r]}else{const e=await this._generateSymbolTableElementForSublayer(n,i,s);e&&r.unshift(e)}}}return r.filter((e=>!!e&&(!("infos"in e)||e.infos.length>0)))}async _generateSymbolTableElementForSublayer(e,t,s){if(!s){s=new Map;const t=this.layer,l=e.source;let r=null;if(!(!l||"map-layer"===l.type&&l.mapLayerId===e.id&&(!l.gdbVersion||l.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>L.SERVICE||e.originIdOf("labelingInfo")>L.SERVICE||e.originIdOf("labelsVisible")>L.SERVICE){const e=new E({layer:this.layer});r=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const i=r||`${t.uid}-default`;(await this._getLegendLayers(i,r)).forEach((e=>s.set(e.layerId,e)))}const l=s.get(e.id);if((!l||l?.subLayerIds&&l.defaultVisibility)&&e.sublayers){const l=await this._generateLegendElementsForSublayers(e.sublayers,t,s);return{type:"symbol-table",title:e.title,infos:l}}return this._generateSymbolTableElementForLegendLayer(l,e,t)}_generateSymbolTableElementForLegendLayer(e,t,s){if(!e||!e.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const l=t?.renderer;let r=t?.title||e.layerName;if(l&&(!t||t?.originIdOf("renderer")>L.SERVICE)){const e=t?.title||this._getRendererTitle(l,t);e&&(r&&"string"!=typeof e&&"title"in e&&(e.title=r),r=e)}const i={type:"symbol-table",title:r,legendType:e.legendType?e.legendType:null,infos:[]},n=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return e.legendGroups?.length>0?e.legendGroups.forEach((t=>{const l={type:"symbol-table",title:t.heading,legendType:e.legendType?e.legendType:null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter((e=>e.groupId===t.id)),e.layerId,s)};l.infos?.length>0&&i.infos.push(l)})):i.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,s),i.infos.length>0?i:null}_generateSymbolTableElementInfosForLegendLayer(e,t,l){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=s(`${this.layer.url}/${t}/images/${r}`)}return{label:e.label,src:r,opacity:l??this.opacity,width:e.width,height:e.height}})).filter((e=>!!e))}_isSublayerInScale(e){const t=e.minScale||0,s=e.maxScale||0;return!(t>0&&t<this.scale||s>this.scale)}_isLegendLayerInScale(e,t){const s=t||this.layer;let l=null,r=null,i=!0;return!s.minScale&&0!==s.minScale||!s.maxScale&&0!==s.maxScale?(0===e.minScale&&s.tileInfo&&(l=s.tileInfo.lods[0].scale),0===e.maxScale&&s.tileInfo&&(r=s.tileInfo.lods[s.tileInfo.lods.length-1].scale)):(l=Math.min(s.minScale,e.minScale)||s.minScale||e.minScale,r=Math.max(s.maxScale,e.maxScale)),(l>0&&l<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 s=t.renderer,l=e.some((e=>e.values));let r=null,i=null;return l&&e.some(((e,t)=>(e.values||(r=t,i=e,i.label||(i.label="others")),null!=i))),s?"unique-value"===s.type?i&&(e.splice(r,1),e.push(i)):"class-breaks"===s.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={}){if(!Re(e,this.view))return o.getLogger(this.declaredClass).warn(`Renderer of type '${e.type}' not supported!`),[];if(_e(e))return this._constructPointCloudRendererLegendElements(e,t);if(Ce(e))return this._constructDotDensityRendererLegendElements(e);const s=await this._loadRenderer(e);return Ie(s)?this._constructPieChartRendererLegendElements(s):this._constructRendererLegendElements(s,t)}async _getLegendElementsForFeatureReduction(e){let t=null;return"binning"===e.type?t=e.renderer:"cluster"===e.type&&(t=this._getClusterRenderer(e)),t?this._getRendererLegendElements(t):[]}_getPointCloudRendererTitle(e){return e.legendOptions&&e.legendOptions.title||e.field}_constructPointCloudRendererLegendElements(e,t={}){const s=t.title,l=[];let r=null,i=null;if(ve(e))r={type:"symbol-table",title:s||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(ue,e.color)})}));else if(we(e)){const t=e.stops;let l=null;if(t.length&&(1===t.length&&(l=t[0].color),!l)){const e=t[0].value,s=t[t.length-1].value;if(null!=e&&null!=s){l=B(e+(s-e)/2,t)}}r={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(ue,l||ue.color)}]};const n=k(e.stops);i={type:"color-ramp",title:s||this._getPointCloudRendererTitle(e),infos:n,preview:j(n.map((e=>e.color)))}}else Ee(e)&&(r={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos.forEach((e=>{r.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(ue,e.color)})})));r&&r.infos.length&&l.push(r),i&&i.infos.length&&l.push(i);const n=l.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((()=>l))}_getElementInfoForDotDensity(e,t){const{backgroundColor:s,outline:l,dotSize:r}=e,i=this.effectList?.effects.map((e=>e.toJSON())),n=w(i),a=r+"-"+t+"-"+s+"-"+(l&&JSON.stringify(l.toJSON()))+"-"+n,o=this._dotDensityUrlCache,u=o.has(a)?o.get(a):D(e,t);o.set(a,u);const c={shape:{type:"image",x:0,y:0,width:u.width,height:u.height,src:u.src},fill:null,stroke:null,offset:[0,0]},d=x([[c]],[u.width,u.height],{effectView:this.effectList});return{opacity:1,src:u.src,preview:d,width:u.width,height:u.height}}_constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),s=e.legendOptions&&e.legendOptions.unit,l={type:"symbol-table",title:{value:t&&Math.round(t),unit:s||""},infos:[]};return e.attributes.forEach((t=>{const s=this._getElementInfoForDotDensity(e,t.color);s.label=t.label||t.valueExpressionTitle||t.field,l.infos.push(s)})),Promise.resolve([l])}async _constructPieChartRendererLegendElements(e){const t=this.layer.opacity,s=[],l="Others",r=e.outline;e.attributes.forEach((e=>{const t=new te({color:e.color,outline:r}),l=e.label||e.valueExpressionTitle||e.field;s.push({label:l,symbol:t})}));const i=s.length?[...s]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const t=new te({color:e.othersCategory.color,outline:r});s.push({label:e.othersCategory.label||l,symbol:t})}if(e.defaultColor?.a){const t=new te({color:e.defaultColor,outline:r});s.push({label:e.defaultLabel,symbol:t})}const n=await this._getVisualVariableLegendElements(e,this.layer)||[];if(s.length){n.unshift({type:"symbol-table",title:null,infos:s});const t=i.filter((e=>e.label!==l)).map((e=>e.symbol.color)).filter(Boolean),a=O(t,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,effectList:this.effectList,outline:r});n.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:s,preview:a})}const a=n.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!!e?.symbol&&!e?.preview)).map((e=>this._getSymbolPreview(e,t,{effectList:this.effectList})));return await d(a),n}async _constructRendererLegendElements(e,t={}){const{title:s,sublayer:l}=t,r=l||this.layer;this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const i=await this._getVisualVariableLegendElements(e,r)||[],n={type:"symbol-table",title:s||this._getRendererTitle(e,r),infos:[]};let a=null,o=!1;const c=new Set;if(de(e)&&!this._hasSizeRamp){const t=await X(e);n.infos.push({label:null,symbol:t})}else if(ke(e)){let t=s;const l=Ue(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",r=i.findIndex((e=>"color-ramp"===e.type)),n=-1!==r?i.splice(r,1)[0]:null,a=i.findIndex((e=>"size-ramp"===e.type)),o=-1!==a?i.splice(a,1)[0]:null,u=[];n&&(t=n.title,u.push(n)),o&&(t=o.title,u.push(o)),u.length>0&&i.push({type:l,title:t,infos:u})}else if(Se(e)){const t=q(e);i.push({type:"heatmap-ramp",title:s||this._getRendererTitle(e,r),infos:t,preview:j(t.map((e=>e.color)),{effectList:this.effectList})})}else if(be(e)){const t=e&&e.authoringInfo;if(t&&"relationship"===t.type){const{focus:s,numClasses:l,field1:a,field2:o}=t;if(l&&a&&o){const t=[a,o];let u=$(s)||0;for(const e of t){const{field:t,normalizationField:s,label:l}=e,i=l||{field:this._getFieldAlias(t,r),normField:s&&this._getFieldAlias(s,r)},a=Ne.clone();a.angle=u,n.infos.push({label:i,symbol:a}),c.add(a),u+=90}const d=W({focus:s,numClasses:l,infos:e.uniqueValueInfos});i.unshift(d)}}else if(Pe(this.layer)||Me(this.layer))e.uniqueValueInfos.forEach((e=>{e.symbol&&n.infos.push({label:e.label||e.value,value:e.value,symbol:e.symbol})}));else{const{field:t,field2:s,field3:l,fieldDelimiter:i,valueExpression:a}=e,o=!(!t&&!a||!s&&!l),u=[];if(e.uniqueValueGroups.forEach((e=>{const n={type:"symbol-table",title:e.heading,infos:[]};e.classes.forEach((e=>{const{symbol:u,values:c}=e;if(u){const d=[],h=[];for(const e of c){const{value:n,value2:u,value3:c}=e,y=[],m=[];(t||a)&&(y.push(n),m.push(this._getDomainName(t,n,r))),s&&(y.push(u),m.push(this._getDomainName(s,u,r))),l&&(y.push(c),m.push(this._getDomainName(l,c,r))),d.push(o?y.join(i||""):y[0]),h.push(m.join(" - "))}const y=d.join(", ");let m=e.label;if(!m){const e=h.filter(Boolean);m=e.length?e.join(", "):y}n.infos.push({label:m,value:y,symbol:u})}})),n.infos.length&&u.push(n)})),u.length){const e=u[0];1===u.length&&"title"in e&&!e.title?n.infos.push(...e.infos):n.infos.push(...u)}}e.defaultSymbol&&(n.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),o=!0)}else if(ge(e)){a=this._isUnclassedRenderer(e);(!a||!this._hasSizeRamp)&&(e.classBreakInfos.forEach((e=>{e.symbol&&n.infos.unshift({label:e.label||(a?null:e.minValue+" - "+e.maxValue),value:[e.minValue,e.maxValue],symbol:e.symbol})})),a&&(n.title=null),this._updateInfosforClassedSizeRenderer(e,n.infos)),e.defaultSymbol&&!a&&(n.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),o=!0)}else if(me(e))if(Me(this.layer)||Ae(this.layer)){const t=this._constructTileImageryStretchRendererElements(e);Be(t)?i.push(t):n.infos=t}else{const t=this.layer;let s,l;e.statistics&&e.statistics.length&&(s=null!=e.statistics[0].min?e.statistics[0].min:e.statistics[0][0],l=null!=e.statistics[0].max?e.statistics[0].max:e.statistics[0][1]);let r=[];const a=u(t.renderingRule?await t.generateRasterInfo(t.renderingRule):t.serviceRasterInfo),o=a.keyProperties.BandProperties,c=I(a.pixelType);if(1===a.bandCount){const r=t.bandIds?.[0]||0;s=null!=s?s:a.statistics?a.statistics[r].min:c[0],l=null!=l?l:a.statistics?a.statistics[r].max:c[1],s||l?i.push(this._getStretchLegendElements(e,{min:s,max:l})):this._getServerSideLegend()}else t.bandIds&&1===t.bandIds.length?(s=null!=s?s:a.statistics?a.statistics[t.bandIds[0]].min:c[0],l=null!=l?l:a.statistics?a.statistics[t.bandIds[0]].max:c[1],s||l?i.push(this._getStretchLegendElements(e,{min:s,max:l})):this._getServerSideLegend()):a.bandCount>=3?o&&o.length>=a.bandCount?t.bandIds&&3===t.bandIds.length?(r=t.bandIds.map((e=>o[e].BandName)),n.infos=this._createSymbolTableElementMultiBand(r)):"lerc"===t.format?(r=[0,1,2].map((e=>o[e].BandName)),n.infos=this._createSymbolTableElementMultiBand(r)):this._getServerSideLegend():"lerc"===t.format?(r=["band1","band2","band3"],n.infos=this._createSymbolTableElementMultiBand(r)):this._getServerSideLegend():this._getServerSideLegend()}else if(ye(e))e.colormapInfos.forEach((e=>{n.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(ce,e.color)})}));else if(pe(e)){let s=e.symbol;switch(t.geometryType){case"point":s="pointSymbol"in r&&r.pointSymbol;break;case"polyline":s="lineSymbol"in r&&r.lineSymbol;break;case"polygon":s="polygonSymbol"in r&&r.polygonSymbol}const l=this._hasClusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&l&&n.infos.push({label:e.label,symbol:s})}else if(he(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),n.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach((e=>{n.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})})):n.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else fe(e)&&i.push(this._getStretchLegendElements(e,{min:0,max:255}));const h=e.defaultSymbol;!h||o||pe(e)||a&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||i.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:h}]}),n.infos.length&&i.unshift(n);const y=null==t.opacity?this.opacity:t.opacity,m=this._isTallSymbol("visualVariables"in e&&e.visualVariables),f=Pe(this.layer)||Me(this.layer),p=i.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!!e?.symbol)).map((e=>this._getSymbolPreview(e,y,{isDefault:e.symbol===h,applyScaleDrivenSize:!c.has(e.symbol),symbolConfig:{isTall:m,isSquareFill:f},effectList:c.has(e.symbol)?null:this.effectList})));return e=null,await d(p),i}_getServerSideLegend(){setTimeout((()=>this.buildLegendElementsForTools()),0)}_getAllInfos(e){const t=e?.infos;return t?t.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]):[e]}_constructTileImageryStretchRendererElements(e){const t=this.layer,{rasterInfo:s}=t.raster,l=s.bandCount||e.statistics.length;let r,i,n=[];const a=s.keyProperties&&s.keyProperties.BandProperties,o=e?.statistics?.length?e.statistics:s?.statistics;if(o)r=void 0!==o[0].min?o[0].min:o[0][0],i=o[0].max||o[0][1];else{const e=I(s.pixelType);r=e[0],i=e[1]}if(t.hasStandardTime()&&(r=t.getStandardTimeValue(r),i=t.getStandardTimeValue(i)),1===s.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:r,max:i});function u(e){const l=(t?.bandIds?.length?t.bandIds:Array.from(Array(Math.min(s.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 n=a&&a.length>=l?u(a):u(),this._createSymbolTableElementMultiBand(n)}_getStretchLegendElements(e,t){const s=e.colorRamp,l=U(s,t);return{type:"stretch-ramp",title:"",infos:l,preview:j(l.map((e=>e.color)))}}_getClusterSymbol(){const e=this.layer,t="featureReduction"in e&&e.featureReduction,s=t&&"symbol"in t&&t.renderer;return s&&!0!==s?.authoringInfo?.isAutoGenerated?null:t&&"symbol"in t&&t.symbol}async _getSizeLegendElement(e,t,s,l){return{type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(t):e,infos:await G(s,t,await Y(s),this.scale,this.view.type,l,this._hasClusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],s=["red","green","blue"];return e.forEach(((e,l)=>{t.push({label:{colorName:s[l],bandName:e},src:Z[l],opacity:this.opacity??1})})),t}_updateInfosforClassedSizeRenderer(e,t){const s=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,l=e.classBreakInfos.some((e=>M(e.symbol)));if(s&&l){const s=J,l=Q,r=e.classBreakInfos.length,i=(s-l)/(r>1?r-1:r);t.forEach(((e,t)=>{e.size=s-i*t}))}}_isTallSymbol(e){let t=!1,s=!1;if(e)for(let l=0;l<e.length&&(!t||!s);l++){const r=e[l];"size"===r.type&&("height"===r.axis&&(t=!0),"width-and-depth"===r.axis&&(s=!0))}return t&&s}async _getSymbolPreview(e,t,s){let l=!s?.isDefault&&null==e.size&&this._hasSizeRamp?g(z.size):e.size;if(this._scaleDrivenSizeVariable&&s?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");l=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}return P(e.symbol,{size:l,opacity:t,scale:!1,symbolConfig:s?.symbolConfig,effectView:s?.effectList}).then((t=>(e.preview=t,e))).catch((()=>(e.preview=null,e)))}_getClusterRenderer(e){this._hasClusterSizeVariable=!1;const t="renderer"in this.layer&&this.layer.renderer,s=e.renderer?.clone()||t?.clone(),l=u(A(this.layerView._effectiveRenderer,this.view));if(l&&"visualVariables"in s){const t=s.visualVariables?.some((e=>"size"===e.type&&"outline"!==e.target&&!ae.test(e.valueExpression)));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:s}=e;l.legendOptions=new V({showLegend:t!==s})}const t=s.visualVariables||[];s.visualVariables=t.concat([l]),this._hasClusterSizeVariable=!0}}return s}async _loadRenderer(e){const t=[],s=e.clone(),l=await Y(s);if(ge(s)||be(s)){const e=(s.classBreakInfos||s.uniqueValueInfos).map((e=>this._fetchSymbol(e.symbol,l).then((t=>{e.symbol=t})).catch((()=>{e.symbol=null}))));Array.prototype.push.apply(t,e)}return t.push(this._fetchSymbol(s.symbol||s.defaultSymbol,s.defaultSymbol?null:l).then((e=>{this._applySymbolToRenderer(s,e,pe(s))})).catch((()=>{this._applySymbolToRenderer(s,null,pe(s))}))),d(t).then((()=>s))}_applySymbolToRenderer(e,t,s){s?e.symbol=t:e.defaultSymbol=t}async _fetchSymbol(e,t){if(!e)throw new Error;if("web-style"===e.type){const s=this._webStyleSymbolCache;try{const l=await("2d"===this.view.type?e.fetchCIMSymbol({cache:s}):e.fetchSymbol({cache:s}));return this._getAppliedCloneSymbol(l,t)}catch{throw o.getLogger(this.declaredClass).warn("Fetching web-style failed!"),new Error}}return this._getAppliedCloneSymbol(e,t)}_getAppliedCloneSymbol(e,s){if(!e||!s)return e;const l=e.clone(),r=s&&s.toRgba();return l.type.includes("3d")?this._applyColorTo3dSymbol(l,r):"cim"===l.type?T(l,s):l.color&&(l.color=new t(r||l.color)),l}_applyColorTo3dSymbol(e,s){s&&e.symbolLayers.forEach((e=>{e&&(e.material||(e.material={}),e.material.color=new t(s))}))}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||!e.visualVariables||"vector-field"===e.type)return null;const s=e.visualVariables,l=[],r=[],i=[];for(const c of s)"color"===c.type?l.push(c):"size"===c.type?r.push(c):"opacity"===c.type&&i.push(c);const n=[...l,...r,...i];let a,o;if(0===l.length&&ge(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];a=t&&t.symbol}if(0===l.length&&pe(e)&&(a=e.symbol),a)if(a.type.includes("3d")){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 s=>{if(!s.legendOptions||!1!==s.legendOptions.showLegend){const l=de(e)?s.field:this._getRampTitle(s,t);let r=null;const i="getField"in t&&t.getField&&t.getField(s.field),n=i&&C(i);if("color"===s.type){const e=await N(s,null,n);r={type:"color-ramp",title:l,infos:e,preview:j(e.map((e=>e.color)),{effectList:u})},this._hasColorRamp||(this._hasColorRamp=!(null==r.infos||!r.infos.length))}else if("size"===s.type&&"outline"!==s.target)ae.test(s.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=s):(r=await this._getSizeLegendElement(l,s,e,n),this._hasSizeRamp||(this._hasSizeRamp=!(null==r.infos||!r.infos.length)));else if("opacity"===s.type){const e=await N(s,o,n);r={type:"opacity-ramp",title:l,infos:e,preview:j(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,s){if(e&&"function"!=typeof e){const l="getField"in s&&s.getField&&s.getField(e),r=l&&"getFieldDomain"in s&&s.getFieldDomain?s.getFieldDomain(l.name):null;return r&&"coded-value"===r.type?r.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,s=e.field;if("featureReduction"in t&&t.featureReduction&&"cluster"===t.featureReduction.type){const e=t.featureReduction,l="popupTemplate"in e&&e.popupTemplate,r=l&&l.fieldInfos;if(r)for(const t of r)if(t.fieldName===s)return"cluster_count"===s?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let s=e.field,l=e.normalizationField,r=!1,i=!1,n=!1,a=null;s="function"==typeof s?null:s,l="function"==typeof l?null:l;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 s=e[t];if("color"===s.type){if("ratio"===s.style){r=!0;break}if("percent"===s.style){i=!0;break}if("percent-of-total"===s.style){n=!0;break}}}}a={field:s&&this._getFieldAlias(s,t),normField:l&&this._getFieldAlias(l,t),ratio:r,ratioPercent:i,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const s=e;if(s.legendOptions&&s.legendOptions.title)return s.legendOptions.title;if(s.valueExpressionTitle)return s.valueExpressionTitle;let l=s.field,r=null,i=null;if(ge(s)&&(r=s.normalizationField,i="percent-of-total"===s.normalizationType),l="function"==typeof l?null:l,r="function"==typeof r?null:r,be(s)){const{field2:e,field3:r,fieldDelimiter:i}=s;let n=l&&this._getFieldAlias(l,t);return e&&(n=`<${n}>${i}<${this._getFieldAlias(e,t)}>`,r&&(n=`${n}${i}<${this._getFieldAlias(r,t)}>`)),n}let n=null;return(l||r)&&(n={field:l&&this._getFieldAlias(l,t),normField:r&&this._getFieldAlias(r,t),normByPct:i}),n}_getFieldAlias(e,t){const s="popupTemplate"in t&&t.popupTemplate,l=s&&s.fieldInfos;let r=null;l&&l.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));let n=null;const a="featureReduction"in t&&t.featureReduction;a&&(!r&&"popupTemplate"in a&&a.popupTemplate&&a.popupTemplate.fieldInfos&&a.popupTemplate.fieldInfos.some((t=>e?.toLowerCase()===t.fieldName?.toLowerCase()&&(r=t,!0))),"fields"in a&&a.fields&&(n=a.fields.find((t=>t.name?.toLowerCase()===e?.toLowerCase()))));const o=r||i||n;let u=null;return o&&(u=r?.label||i?.alias||n?.alias||"name"in o&&o.name||"fieldName"in o&&o.fieldName),u}_isUnclassedRenderer(e){const t=e.visualVariables;let s=!1;return ge(e)&&e.classBreakInfos&&1===e.classBreakInfos.length&&t&&(s=e.field?t.some((t=>!(!t||e.field!==t.field||(e.normalizationField||t.normalizationField)&&e.normalizationField!==t.normalizationField))):!!t.length),s}};e([S()],$e.prototype,"children",void 0),e([S({readOnly:!0})],$e.prototype,"effectList",null),e([S()],$e.prototype,"layerView",void 0),e([S()],$e.prototype,"layer",void 0),e([S()],$e.prototype,"legendElements",void 0),e([S({readOnly:!0})],$e.prototype,"opacity",null),e([S()],$e.prototype,"parent",void 0),e([S({readOnly:!0,dependsOn:[]})],$e.prototype,"ready",null),e([S()],$e.prototype,"hideLayersNotInCurrentView",void 0),e([S()],$e.prototype,"keepCacheOnDestroy",void 0),e([S()],$e.prototype,"respectLayerVisibility",void 0),e([S({readOnly:!0})],$e.prototype,"scale",null),e([S()],$e.prototype,"sublayerIds",void 0),e([S({readOnly:!0})],$e.prototype,"isScaleDriven",null),e([S()],$e.prototype,"title",void 0),e([S({readOnly:!0,dependsOn:["ready"],value:0})],$e.prototype,"version",null),e([S()],$e.prototype,"view",void 0),$e=e([_("esri.widgets.Legend.support.ActiveLayerInfo")],$e);const We=$e;export{We as default};
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[7476],{28659:(e,t,r)=>{r.d(t,{B:()=>f});var i=r(81153),s=r(17452),o=r(41123),n=r(7628),a=r(31263),l=r(5600);function p(e){return d[function(e){return e instanceof Blob?e.type:function(e){const t=(0,s.Ml)(e);return y[t]||c}(e.url)}(e)]||u}const d={},c="text/plain",u=d[c],y={png:"image/png",jpeg:"image/jpeg",jpg:"image/jpg",bmp:"image/bmp",gif:"image/gif",json:"application/json",txt:"text/plain",xml:"application/xml",svg:"image/svg+xml",zip:"application/zip",pbf:"application/vnd.mapbox-vector-tile",gz:"application/gzip","bin.gz":"application/octet-stream"};for(const e in y)d[y[e]]=e;var h=r(25929);function f(e){const t=e?.origins??[void 0];return(r,o)=>{const d=function(e,t,r){if("resource"===e?.type)return function(e,t,r){const o=(0,n.Oe)(t,r);return{type:String,read:(e,t,r)=>{const i=(0,h.r)(e,t,r);return o.type===String?i:"function"==typeof o.type?new o.type({url:i}):void 0},write:{writer(t,n,l,d){if(!d||!d.resources)return"string"==typeof t?void(n[l]=(0,h.t)(t,d)):void(n[l]=t.write({},d));const c=function(e){return null==e?null:"string"==typeof e?e:e.url}(t),u=(0,h.t)(c,{...d,verifyItemRelativeUrls:d&&d.verifyItemRelativeUrls?{writtenUrls:d.verifyItemRelativeUrls.writtenUrls,rootPath:void 0}:void 0},h.M.NO),y=o.type!==String&&(!(0,i.l)(this)||d&&d.origin&&this.originIdOf(r)>(0,a.M9)(d.origin)),f={object:this,propertyName:r,value:t,targetUrl:u,dest:n,targetPropertyName:l,context:d,params:e};d&&d.portalItem&&u&&!(0,s.YP)(u)?y?function(e){const{context:t,targetUrl:r,params:i,value:o,dest:n,targetPropertyName:a}=e;if(!t.portalItem)return;const l=t.portalItem.resourceFromPath(r),d=b(o,r,t),c=p(d),u=(0,s.Ml)(l.path),y=i?.compress??!1;c===u?(t.resources&&m({...e,resource:l,content:d,compress:y,updates:t.resources.toUpdate}),n[a]=r):g(e)}(f):function({context:e,targetUrl:t,dest:r,targetPropertyName:i}){e.portalItem&&e.resources&&(e.resources.toKeep.push({resource:e.portalItem.resourceFromPath(t),compress:!1}),r[i]=t)}(f):d&&d.portalItem&&(null==u||null!=(0,h.i)(u)||(0,s.jc)(u)||y)?g(f):n[l]=u}}}}(e,t,r);switch(e?.type??"other"){case"other":return{read:!0,write:!0};case"url":{const{read:e,write:t}=h.a;return{read:e,write:t}}}}(e,r,o);for(const e of t){const t=(0,l.CJ)(r,e,o);for(const e in d)t[e]=d[e]}}}function g(e){const{targetUrl:t,params:i,value:n,context:a,dest:l,targetPropertyName:d}=e;if(!a.portalItem)return;const c=(0,h.p)(t),u=c?.filename??(0,o.D)(),y=i?.prefix??c?.prefix,f=b(n,t,a),g=(0,s.v_)(y,u),v=`${g}.${p(f)}`,w=a.portalItem.resourceFromPath(v);(0,s.jc)(t)&&a.resources&&a.resources.pendingOperations.push(async function(e){const t=(await Promise.resolve().then(r.bind(r,3172))).default,{data:i}=await t(e,{responseType:"blob"});return i}(t).then((e=>{w.path=`${g}.${p(e)}`,l[d]=w.itemRelativeUrl})).catch((()=>{})));const I=i?.compress??!1;a.resources&&m({...e,resource:w,content:f,compress:I,updates:a.resources.toAdd}),l[d]=w.itemRelativeUrl}function m({object:e,propertyName:t,updates:r,resource:i,content:s,compress:o}){r.push({resource:i,content:s,compress:o,finish:r=>{!function(e,t,r){"string"==typeof e[t]?e[t]=r.url:e[t].url=r.url}(e,t,r)}})}function b(e,t,r){return"string"==typeof e?{url:t}:new Blob([JSON.stringify(e.toJSON(r))],{type:"application/json"})}},57476:(e,t,r)=>{r.r(t),r.d(t,{default:()=>he});var i=r(43697),s=r(38171),o=r(51773),n=(r(16050),r(12501),r(28756),r(92271),r(72529),r(5499),r(84382),r(81571),r(91423),r(32400)),a=r(3172),l=r(46791),p=r(20102),d=r(92604),c=r(70586),u=r(16453),y=r(95330),h=r(17445),f=r(17452),g=r(5600),m=(r(75215),r(67676),r(1153)),b=r(71715),v=r(52011),w=r(31263),I=r(87085),_=r(54295),C=r(17287),L=r(66361),S=r(38009),F=r(16859),j=r(72965),x=r(32271),O=r(15506),P=r(21506),R=r(61960),E=r(85857),T=r(14147),N=r(53518),A=r(99514),Z=r(35671),D=r(51161),U=r(54306),q=r(30707),Q=r(56765),k=r(96674);let G=class extends k.wq{constructor(){super(...arguments),this.name=null,this.field=null,this.currentRangeExtent=null,this.fullRangeExtent=null,this.type="rangeInfo"}};(0,i._)([(0,g.Cb)({type:String,json:{read:!0,write:!0}})],G.prototype,"name",void 0),(0,i._)([(0,g.Cb)({type:String,json:{read:!0,write:!0}})],G.prototype,"field",void 0),(0,i._)([(0,g.Cb)({type:[Number],json:{read:!0,write:!0}})],G.prototype,"currentRangeExtent",void 0),(0,i._)([(0,g.Cb)({type:[Number],json:{read:!0,write:!0}})],G.prototype,"fullRangeExtent",void 0),(0,i._)([(0,g.Cb)({type:["rangeInfo"],readOnly:!0,json:{read:!1,write:!0}})],G.prototype,"type",void 0),G=(0,i._)([(0,v.j)("esri.layers.support.RangeInfo")],G);var V,J=r(61247),W=r(22974),M=r(28659),z=r(20941),$=(r(80442),r(38913)),K=r(44547);let B=V=class extends((0,k.eC)(l.Z.ofType($.Z))){constructor(e){super(e)}clone(){return new V(this.items.map((e=>e.clone())))}write(e,t){return this.toJSON(t)}toJSON(e){const t=e?.layer?.spatialReference;return t?this.toArray().map((r=>{if(!t.equals(r.spatialReference)){if(!(0,K.Up)(r.spatialReference,t))return e&&e.messages&&e.messages.push(new z.Z("scenefilter:unsupported","Scene filters with incompatible spatial references are not supported",{modification:this,spatialReference:e.layer.spatialReference,context:e})),null;const i=new $.Z;(0,K.Wt)(r,i,t),r=i}const i=r.toJSON(e);return delete i.spatialReference,i})).filter((e=>null!=e)):(e?.messages&&e.messages.push(new z.Z("scenefilter:unsupported","Writing Scene filters without context layer is not supported",{modification:this,spatialReference:e.layer.spatialReference,context:e})),this.toArray().map((t=>t.toJSON(e))))}static fromJSON(e,t){const r=new V;return e.forEach((e=>r.add($.Z.fromJSON(e,t)))),r}};B=V=(0,i._)([(0,v.j)("esri.layers.support.PolygonCollection")],B);const Y=B;var H,X=r(25929);let ee=H=class extends k.wq{constructor(e){super(e),this.spatialRelationship="disjoint",this.geometries=new Y,this._geometriesSource=null,this._handles=new J.Z}initialize(){this._handles.add((0,h.on)((()=>this.geometries),"after-changes",(()=>this.geometries=this.geometries),h.Z_))}destroy(){this._handles.destroy()}readGeometries(e,t,r){this._geometriesSource={url:(0,X.f)(e,r),context:r}}async loadGeometries(e,t){if((0,c.Wi)(this._geometriesSource))return;const{url:r,context:i}=this._geometriesSource,s=await(0,a.default)(r,{responseType:"json",signal:(0,c.U2)(t,"signal")}),o=e.toJSON(),n=s.data.map((e=>({...e,spatialReference:o})));this.geometries=Y.fromJSON(n,i),this._geometriesSource=null}clone(){return new H({geometries:(0,W.d9)(this.geometries),spatialRelationship:this.spatialRelationship})}};(0,i._)([(0,g.Cb)({type:["disjoint","contains"],nonNullable:!0,json:{write:!0}})],ee.prototype,"spatialRelationship",void 0),(0,i._)([(0,g.Cb)({type:Y,nonNullable:!0,json:{write:!0}}),(0,M.B)({origins:["web-scene","portal-item"],type:"resource",prefix:"geometries"})],ee.prototype,"geometries",void 0),(0,i._)([(0,b.r)(["web-scene","portal-item"],"geometries")],ee.prototype,"readGeometries",null),ee=H=(0,i._)([(0,v.j)("esri.layers.support.SceneFilter")],ee);const te=ee;var re=r(40555),ie=r(14165),se=r(72245),oe=r(32163),ne=r(77397),ae=r(19833),le=r(65242);const pe=["3DObject","Point"],de=(0,N.v)();let ce=class extends((0,L.o1)((0,x.Vt)((0,C.Y)((0,S.q)((0,F.I)((0,j.M)((0,u.R)((0,_.V)(I.Z))))))))){constructor(...e){super(...e),this.featureReduction=null,this.rangeInfos=null,this.operationalLayerType="ArcGISSceneServiceLayer",this.type="scene",this.fields=null,this.floorInfo=null,this.outFields=null,this.nodePages=null,this.materialDefinitions=null,this.textureSetDefinitions=null,this.geometryDefinitions=null,this.serviceUpdateTimeStamp=null,this.excludeObjectIds=new l.Z,this.definitionExpression=null,this.filter=null,this.path=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.priority=null,this.semantic=null,this.cachedDrawingInfo={color:!1},this.popupEnabled=!0,this.popupTemplate=null,this.objectIdField=null,this.globalIdField=null,this._fieldUsageInfo={},this.screenSizePerspectiveEnabled=!0}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){const r=this.getFeatureType(t?.feature)?.domains?.[e];return r&&"inherited"!==r.type?r:this.getField(e)?.domain??null}getFeatureType(e){return null!=e&&(0,c.pC)(this.associatedLayer)?this.associatedLayer.getFeatureType(e):null}get types(){return(0,c.pC)(this.associatedLayer)?this.associatedLayer.types??[]:[]}get typeIdField(){return(0,c.pC)(this.associatedLayer)?this.associatedLayer.typeIdField:null}get formTemplate(){return(0,c.pC)(this.associatedLayer)?this.associatedLayer.formTemplate:null}get fieldsIndex(){return new A.Z(this.fields)}readNodePages(e,t,r){return"Point"===t.layerType&&(e=t.pointNodePages),null==e||"object"!=typeof e?null:D.U4.fromJSON(e,r)}set elevationInfo(e){this._set("elevationInfo",e),this.loaded&&this._validateElevationInfo()}get geometryType(){return ye[this.profile]||"mesh"}set renderer(e){(0,Z.YN)(e,this.fieldsIndex),this._set("renderer",e)}readCachedDrawingInfo(e){return null!=e&&"object"==typeof e||(e={}),null==e.color&&(e.color=!1),e}get capabilities(){const e=(0,c.pC)(this.associatedLayer)&&this.associatedLayer.capabilities?this.associatedLayer.capabilities:O.C,{query:t,editing:{supportsGlobalId:r,supportsRollbackOnFailure:i,supportsUploadWithItemId:s,supportsGeometryUpdate:o,supportsReturnServiceEditsInSourceSpatialReference:n},data:{supportsZ:a,supportsM:l,isVersioned:p,supportsAttachment:d},operations:{supportsEditing:u,supportsAdd:y,supportsUpdate:h,supportsDelete:f,supportsQuery:g,supportsQueryAttachments:m}}=e,b=e.operations.supportsChangeTracking,v=(0,c.pC)(this.associatedLayer)&&(0,c.pC)(this.associatedLayer.infoFor3D)&&(0,se.Rx)();return{query:t,editing:{supportsGlobalId:r,supportsReturnServiceEditsInSourceSpatialReference:n,supportsRollbackOnFailure:i,supportsGeometryUpdate:v&&o,supportsUploadWithItemId:s},data:{supportsAttachment:d,supportsZ:a,supportsM:l,isVersioned:p},operations:{supportsQuery:g,supportsQueryAttachments:m,supportsEditing:u&&b,supportsAdd:v&&y&&b,supportsDelete:v&&f&&b,supportsUpdate:h&&b}}}get editingEnabled(){return this._isOverridden("editingEnabled")?this._get("editingEnabled"):this.userHasEditingPrivileges}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}get infoFor3D(){return(0,c.pC)(this.associatedLayer)?this.associatedLayer.infoFor3D:null}get defaultPopupTemplate(){return(0,c.pC)(this.associatedLayer)||this.attributeStorageInfo?this.createPopupTemplate():null}readObjectIdField(e,t){return!e&&t.fields&&t.fields.some((t=>("esriFieldTypeOID"===t.type&&(e=t.name),!!e))),e||void 0}readGlobalIdField(e,t){return!e&&t.fields&&t.fields.some((t=>("esriFieldTypeGlobalID"===t.type&&(e=t.name),!!e))),e||void 0}get displayField(){return(0,c.pC)(this.associatedLayer)?this.associatedLayer.displayField:null}readProfile(e,t){const r=t.store.profile;return null!=r&&ue[r]?ue[r]:(d.Z.getLogger(this.declaredClass).error("Unknown or missing profile",{profile:r,layer:this}),"mesh-pyramids")}load(e){const t=(0,c.pC)(e)?e.signal:null,r=this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(y.r9).then((()=>this._fetchService(t))).then((()=>Promise.all([this._fetchIndexAndUpdateExtent(this.nodePages,t),this._setAssociatedFeatureLayer(t),(0,c.pC)(this.filter)?this.filter.loadGeometries(this.spatialReference):null]))).then((()=>this._validateElevationInfo())).then((()=>this._applyAssociatedLayerOverrides())).then((()=>this._populateFieldUsageInfo())).then((()=>(0,re.y)(this,{origin:"service"},t))).then((()=>(0,Z.YN)(this.renderer,this.fieldsIndex))).then((()=>this.finishLoadEditablePortalLayer(e)));return this.addResolvingPromise(r),Promise.resolve(this)}async beforeSave(){(0,c.pC)(this.filter)&&await this.load()}createQuery(){const e=new ie.Z;return"mesh"!==this.geometryType&&(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||"1=1",e.sqlFormat="standard",e}queryExtent(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryExtent(e||this.createQuery(),t)))}queryFeatureCount(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryFeatureCount(e||this.createQuery(),t)))}queryFeatures(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryFeatures(e||this.createQuery(),t))).then((e=>{if(e?.features)for(const t of e.features)t.layer=this,t.sourceLayer=this;return e}))}async queryCachedAttributes(e,t){const r=(0,Z.Lk)(this.fieldsIndex,await(0,ae.e)(this,(0,ae.V)(this)));return(0,ne.xe)(this.parsedUrl.path,this.attributeStorageInfo??[],e,t,r)}async queryCachedFeature(e,t){const r=await this.queryCachedAttributes(e,[t]);if(!r||0===r.length)throw new p.Z("scenelayer:feature-not-in-cached-data","Feature not found in cached data");const i=new s.Z;return i.attributes=r[0],i.layer=this,i.sourceLayer=this,i}queryObjectIds(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryObjectIds(e||this.createQuery(),t)))}queryAttachments(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryAttachments(e,t)))}getFieldUsageInfo(e){const t={supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1};return this.loaded?this._fieldUsageInfo[e]||t:(d.Z.getLogger(this.declaredClass).error("#getFieldUsageInfo()","Unavailable until layer is loaded"),t)}createPopupTemplate(e){return(0,oe.eZ)(this,e)}_getAssociatedLayerForQuery(){const e=this.associatedLayer;return(0,c.pC)(e)&&e.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),(0,c.Wi)(this.associatedLayer))throw new p.Z("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});try{await this.associatedLayer.load()}catch(e){throw new p.Z("scenelayer:query-not-available","SceneLayer associated feature layer could not be loaded",{layer:this,error:e})}return this.associatedLayer}hasCachedStatistics(e){return null!=this.statisticsInfo&&this.statisticsInfo.some((t=>t.name===e))}async queryCachedStatistics(e,t){if(await this.load(t),!this.statisticsInfo)throw new p.Z("scenelayer:no-cached-statistics","Cached statistics are not available for this layer");const r=this.fieldsIndex.get(e);if(!r)throw new p.Z("scenelayer:field-unexisting",`Field '${e}' does not exist on the layer`);for(const e of this.statisticsInfo)if(e.name===r.name){const r=(0,f.v_)(this.parsedUrl.path,e.href);return(0,a.default)(r,{query:{f:"json",token:this.apiKey},responseType:"json",signal:t?t.signal:null}).then((e=>e.data))}throw new p.Z("scenelayer:no-cached-statistics","Cached statistics for this attribute are not available")}async saveAs(e,t){return this._debouncedSaveOperations(x.xp.SAVE_AS,{...t,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"},e)}async save(){const e={getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"};return this._debouncedSaveOperations(x.xp.SAVE,e)}async applyEdits(e,t){const i=await r.e(7541).then(r.bind(r,87269));if(await this.load(),(0,c.Wi)(this.associatedLayer))throw new p.Z(`${this.type}-layer:not-editable`,"Service is not editable");return await this.associatedLayer.load(),i.applyEdits(this,this.associatedLayer.source,e,t)}on(e,t){return super.on(e,t)}validateLayer(e){if(e.layerType&&!pe.includes(e.layerType))throw new p.Z("scenelayer:layer-type-not-supported","SceneLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor))throw new p.Z("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});if(this.version.major>2)throw new p.Z("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});!function(e,t){let r=!1,i=!1;if(null==e)r=!0,i=!0;else{const s=t&&t.isGeographic;switch(e){case"east-north-up":case"earth-centered":r=!0,i=s;break;case"vertex-reference-frame":r=!0,i=!s;break;default:r=!1}}if(!r)throw new p.Z("scenelayer:unsupported-normal-reference-frame","Normal reference frame is invalid.");if(!i)throw new p.Z("scenelayer:incompatible-normal-reference-frame","Normal reference frame is incompatible with layer spatial reference.")}(this.normalReferenceFrame,this.spatialReference)}_getTypeKeywords(){const e=[];if("points"===this.profile)e.push("Point");else{if("mesh-pyramids"!==this.profile)throw new p.Z("scenelayer:unknown-profile","SceneLayer:save() encountered an unknown SceneLayer profile: "+this.profile);e.push("3DObject")}return e}_populateFieldUsageInfo(){if(this._fieldUsageInfo={},this.fields)for(const e of this.fields){const t=!(!this.attributeStorageInfo||!this.attributeStorageInfo.some((t=>t.name===e.name))),r=!!((0,c.pC)(this.associatedLayer)&&this.associatedLayer.fields&&this.associatedLayer.fields.some((t=>t&&e.name===t.name))),i={supportsLabelingInfo:t,supportsRenderer:t,supportsPopupTemplate:t||r,supportsLayerQuery:r};this._fieldUsageInfo[e.name]=i}}_applyAssociatedLayerOverrides(){this._applyAssociatedLayerFieldsOverrides(),this._applyAssociatedLayerPopupOverrides()}_applyAssociatedLayerFieldsOverrides(){if((0,c.Wi)(this.associatedLayer)||!this.associatedLayer.fields)return;let e=null;for(const t of this.associatedLayer.fields){const r=this.getField(t.name);r?(!r.domain&&t.domain&&(r.domain=t.domain.clone()),r.editable=t.editable,r.nullable=t.nullable,r.length=t.length):(e||(e=this.fields?this.fields.slice():[]),e.push(t.clone()))}e&&this._set("fields",e)}_applyAssociatedLayerPopupOverrides(){if((0,c.Wi)(this.associatedLayer))return;const e=["popupTemplate","popupEnabled"],t=(0,m.vw)(this);for(let r=0;r<e.length;r++){const i=e[r],s=this.originIdOf(i),o=this.associatedLayer.originIdOf(i);s<o&&(o===w.s3.SERVICE||o===w.s3.PORTAL_ITEM)&&t.setAtOrigin(i,this.associatedLayer[i],o)}}async _setAssociatedFeatureLayer(e){if(!["mesh-pyramids","points"].includes(this.profile))return;const t=new T.W(this.parsedUrl,this.portalItem,this.apiKey,e);try{this.associatedLayer=await t.fetch()}catch(e){(0,y.D_)(e)||this._logWarningOnPopupEnabled()}}async _logWarningOnPopupEnabled(){await(0,h.N1)((()=>this.popupEnabled&&null!=this.popupTemplate));const e=`this SceneLayer: ${this.title}`;null==this.attributeStorageInfo?d.Z.getLogger(this.declaredClass).warn(`Associated FeatureLayer could not be loaded and no binary attributes found. Popups will not work on ${e}`):d.Z.getLogger(this.declaredClass).info(`Associated FeatureLayer could not be loaded. Falling back to binary attributes for Popups on ${e}`)}_validateElevationInfo(){const e=this.elevationInfo;e&&("mesh-pyramids"===this.profile&&"relative-to-scene"===e.mode&&d.Z.getLogger(this.declaredClass).warn(".elevationInfo=","Mesh scene layers don't support relative-to-scene elevation mode"),e.featureExpressionInfo&&"0"!==e.featureExpressionInfo.expression&&d.Z.getLogger(this.declaredClass).warn(".elevationInfo=","Scene layers do not support featureExpressionInfo"))}};(0,i._)([(0,g.Cb)({types:{key:"type",base:R.B,typeMap:{selection:E.Z}},json:{origins:{"web-scene":{name:"layerDefinition.featureReduction",write:!0},"portal-item":{name:"layerDefinition.featureReduction",write:!0}}}})],ce.prototype,"featureReduction",void 0),(0,i._)([(0,g.Cb)({type:[G],json:{read:!1,origins:{"web-scene":{name:"layerDefinition.rangeInfos",write:!0},"portal-item":{name:"layerDefinition.rangeInfos",write:!0}}}})],ce.prototype,"rangeInfos",void 0),(0,i._)([(0,g.Cb)({json:{read:!1}})],ce.prototype,"associatedLayer",void 0),(0,i._)([(0,g.Cb)({type:["show","hide"]})],ce.prototype,"listMode",void 0),(0,i._)([(0,g.Cb)({type:["ArcGISSceneServiceLayer"]})],ce.prototype,"operationalLayerType",void 0),(0,i._)([(0,g.Cb)({json:{read:!1},readOnly:!0})],ce.prototype,"type",void 0),(0,i._)([(0,g.Cb)({...de.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"fields",void 0),(0,i._)([(0,g.Cb)()],ce.prototype,"types",null),(0,i._)([(0,g.Cb)()],ce.prototype,"typeIdField",null),(0,i._)([(0,g.Cb)()],ce.prototype,"formTemplate",null),(0,i._)([(0,g.Cb)({readOnly:!0})],ce.prototype,"fieldsIndex",null),(0,i._)([(0,g.Cb)({type:Q.Z,json:{read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo"}}})],ce.prototype,"floorInfo",void 0),(0,i._)([(0,g.Cb)(de.outFields)],ce.prototype,"outFields",void 0),(0,i._)([(0,g.Cb)({type:D.U4,readOnly:!0,json:{read:!1}})],ce.prototype,"nodePages",void 0),(0,i._)([(0,b.r)("service","nodePages",["nodePages","pointNodePages"])],ce.prototype,"readNodePages",null),(0,i._)([(0,g.Cb)({type:[D.QI],readOnly:!0})],ce.prototype,"materialDefinitions",void 0),(0,i._)([(0,g.Cb)({type:[D.Yh],readOnly:!0})],ce.prototype,"textureSetDefinitions",void 0),(0,i._)([(0,g.Cb)({type:[D.H3],readOnly:!0})],ce.prototype,"geometryDefinitions",void 0),(0,i._)([(0,g.Cb)({readOnly:!0})],ce.prototype,"serviceUpdateTimeStamp",void 0),(0,i._)([(0,g.Cb)({readOnly:!0})],ce.prototype,"attributeStorageInfo",void 0),(0,i._)([(0,g.Cb)({readOnly:!0})],ce.prototype,"statisticsInfo",void 0),(0,i._)([(0,g.Cb)({type:l.Z.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.excludeObjectIds",write:{enabled:!0}}})],ce.prototype,"excludeObjectIds",void 0),(0,i._)([(0,g.Cb)({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],ce.prototype,"definitionExpression",void 0),(0,i._)([(0,g.Cb)({type:te,json:{name:"layerDefinition.polygonFilter",write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],ce.prototype,"filter",void 0),(0,i._)([(0,g.Cb)({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],ce.prototype,"path",void 0),(0,i._)([(0,g.Cb)(P.PV)],ce.prototype,"elevationInfo",null),(0,i._)([(0,g.Cb)({type:String})],ce.prototype,"geometryType",null),(0,i._)([(0,g.Cb)(P.iR)],ce.prototype,"labelsVisible",void 0),(0,i._)([(0,g.Cb)({type:[U.Z],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:{reader:q.r},write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:q.r},write:!0}})],ce.prototype,"labelingInfo",void 0),(0,i._)([(0,g.Cb)(P.rn)],ce.prototype,"legendEnabled",void 0),(0,i._)([(0,g.Cb)({type:Number,json:{origins:{"web-document":{default:1,write:{enabled:!0,target:{opacity:{type:Number},"layerDefinition.drawingInfo.transparency":{type:Number}}},read:{source:["opacity","layerDefinition.drawingInfo.transparency"],reader(e,t){if("number"==typeof e&&e>=0&&e<=1)return e;const r=t.layerDefinition?.drawingInfo?.transparency;return void 0!==r?(0,le.b)(r):void 0}}},"portal-item":{write:!0},service:{read:!1}}}})],ce.prototype,"opacity",void 0),(0,i._)([(0,g.Cb)({type:["Low","High"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"priority",void 0),(0,i._)([(0,g.Cb)({type:["Labels"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"semantic",void 0),(0,i._)([(0,g.Cb)({types:n.o,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],ce.prototype,"renderer",null),(0,i._)([(0,g.Cb)({json:{read:!1}})],ce.prototype,"cachedDrawingInfo",void 0),(0,i._)([(0,b.r)("service","cachedDrawingInfo")],ce.prototype,"readCachedDrawingInfo",null),(0,i._)([(0,g.Cb)({readOnly:!0,json:{read:!1}})],ce.prototype,"capabilities",null),(0,i._)([(0,g.Cb)({type:Boolean,json:{read:!1}})],ce.prototype,"editingEnabled",null),(0,i._)([(0,g.Cb)({readOnly:!0,json:{write:!1,read:!1}})],ce.prototype,"infoFor3D",null),(0,i._)([(0,g.Cb)(P.C_)],ce.prototype,"popupEnabled",void 0),(0,i._)([(0,g.Cb)({type:o.Z,json:{name:"popupInfo",write:!0}})],ce.prototype,"popupTemplate",void 0),(0,i._)([(0,g.Cb)({readOnly:!0,json:{read:!1}})],ce.prototype,"defaultPopupTemplate",null),(0,i._)([(0,g.Cb)({type:String,json:{read:!1}})],ce.prototype,"objectIdField",void 0),(0,i._)([(0,b.r)("service","objectIdField",["objectIdField","fields"])],ce.prototype,"readObjectIdField",null),(0,i._)([(0,g.Cb)({type:String,json:{read:!1}})],ce.prototype,"globalIdField",void 0),(0,i._)([(0,b.r)("service","globalIdField",["globalIdField","fields"])],ce.prototype,"readGlobalIdField",null),(0,i._)([(0,g.Cb)({readOnly:!0,type:String,json:{read:!1}})],ce.prototype,"displayField",null),(0,i._)([(0,g.Cb)({type:String,json:{read:!1}})],ce.prototype,"profile",void 0),(0,i._)([(0,b.r)("service","profile",["store.profile"])],ce.prototype,"readProfile",null),(0,i._)([(0,g.Cb)({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],ce.prototype,"normalReferenceFrame",void 0),(0,i._)([(0,g.Cb)(P.YI)],ce.prototype,"screenSizePerspectiveEnabled",void 0),ce=(0,i._)([(0,v.j)("esri.layers.SceneLayer")],ce);const ue={"mesh-pyramids":"mesh-pyramids",meshpyramids:"mesh-pyramids","features-meshes":"mesh-pyramids",points:"points","features-points":"points",lines:"lines","features-lines":"lines",polygons:"polygons","features-polygons":"polygons"},ye={"mesh-pyramids":"mesh",points:"point",lines:"polyline",polygons:"polygon"},he=ce}}]);