@arcgis/core 4.34.0-next.42 → 4.34.0-next.44
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.
- package/Basemap.js +1 -1
- package/Ground.js +1 -1
- package/PopupTemplate.js +1 -1
- package/WebDocument2D.js +1 -1
- package/WebScene.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/07eea90733834313e9fa.js +1 -0
- package/assets/esri/core/workers/chunks/08840c4d3df711065571.js +1 -0
- package/assets/esri/core/workers/chunks/0d73afce787ee1e76b21.js +1 -0
- package/assets/esri/core/workers/chunks/0ebf666564d323d82259.js +1 -0
- package/assets/esri/core/workers/chunks/1a3a4c2c642899be37a0.js +1 -0
- package/assets/esri/core/workers/chunks/20ffac42ff5095af00fe.js +1 -0
- package/assets/esri/core/workers/chunks/{d465e1b3a8a53d9c0a12.js → 24e76fa530fc0c495fb5.js} +1 -1
- package/assets/esri/core/workers/chunks/{9247d768c3eccc0828a9.js → 28d71e1b866113650c75.js} +1 -1
- package/assets/esri/core/workers/chunks/{31e6eb2685872baf538a.js → 2aac5d560e4c5defe882.js} +1 -1
- package/assets/esri/core/workers/chunks/{85bfd380d4f522ff8e83.js → 2ae50b02cdf126a8b562.js} +1 -1
- package/assets/esri/core/workers/chunks/349da65a8793f7873366.js +22 -0
- package/assets/esri/core/workers/chunks/4622a3e64d3c4aafa56b.js +1 -0
- package/assets/esri/core/workers/chunks/{eea3e0bd17479a767160.js → 48514235c32917e43a3f.js} +55 -54
- package/assets/esri/core/workers/chunks/5ae6e2b3557fe8730072.js +1 -0
- package/assets/esri/core/workers/chunks/5f28470304b57e24d94c.js +1 -0
- package/assets/esri/core/workers/chunks/655b8d24ffe5405f8ba1.js +1 -0
- package/assets/esri/core/workers/chunks/6cd828cfe41e0cab2068.js +1 -0
- package/assets/esri/core/workers/chunks/{ad106f5f6d6848f40de3.js → 71b222089f5e9dcee474.js} +1 -1
- package/assets/esri/core/workers/chunks/7b560ac0be93c6aa9940.js +1 -0
- package/assets/esri/core/workers/chunks/{962c0ef63de1635fb4aa.js → 7e99fc78bd0f40a8ba81.js} +1 -1
- package/assets/esri/core/workers/chunks/863e87ac982d7727b435.js +1 -0
- package/assets/esri/core/workers/chunks/8867368ab9b005460f19.js +353 -0
- package/assets/esri/core/workers/chunks/892623d938583cd0f006.js +1 -0
- package/assets/esri/core/workers/chunks/{d5d2d4df407cf078bb81.js → 97fc21355efc7b289f3b.js} +1 -1
- package/assets/esri/core/workers/chunks/99daf4b144838fa9ca67.js +1 -0
- package/assets/esri/core/workers/chunks/9d9a7333a968065b53a1.js +1 -0
- package/assets/esri/core/workers/chunks/{cca36750c86352c6d1f9.js → a638f1688ac9525a52a7.js} +1 -1
- package/assets/esri/core/workers/chunks/ab3c018c406dcd81ef9e.js +1 -0
- package/assets/esri/core/workers/chunks/af98c7546be409303213.js +1 -0
- package/assets/esri/core/workers/chunks/b01a90ce699058307bc2.js +1 -0
- package/assets/esri/core/workers/chunks/{9e7af4c3c0f8cf0f5c5b.js → b4251e10621fb3ad03a3.js} +1 -1
- package/assets/esri/core/workers/chunks/b79aa5ba0424641f878b.js +1 -0
- package/assets/esri/core/workers/chunks/bb56defb6dfb9b2c1f27.js +1 -0
- package/assets/esri/core/workers/chunks/c6da9ba188b627ab3b79.js +1 -0
- package/assets/esri/core/workers/chunks/{9c60599131860f635483.js → cd6398a2951922e13b86.js} +1 -1
- package/assets/esri/core/workers/chunks/ceb63ca9ad473c3f1820.js +1 -0
- package/assets/esri/core/workers/chunks/d392fbbcfac2a1b54bd6.js +1 -0
- package/assets/esri/core/workers/chunks/d547b27ac750953a998f.js +1 -0
- package/assets/esri/core/workers/chunks/{7d082bfcd13ad6e8c89d.js → d552b22219ec795aff89.js} +1 -1
- package/assets/esri/core/workers/chunks/dbc9bb3011f16ce33f71.js +1 -0
- package/assets/esri/core/workers/chunks/{7f523fa4d4ade4316625.js → e19cd07df8ce87e18832.js} +1 -1
- package/assets/esri/core/workers/chunks/{c8d57588267e2fc4406c.js → e3f5afdf133c58b3d161.js} +1 -1
- package/assets/esri/core/workers/chunks/e505a101621de39de280.js +1 -0
- package/assets/esri/core/workers/chunks/e5aeb34d918dee539694.js +1 -0
- package/assets/esri/core/workers/chunks/e7806a57d29bca385f1d.js +1 -0
- package/assets/esri/core/workers/chunks/{712c740cf58c2e282efc.js → e962e6b47cb7e5a71c24.js} +1 -1
- package/assets/esri/core/workers/chunks/eafc4da265469e9e5e0b.js +1 -0
- package/assets/esri/core/workers/chunks/{88308a0dcc479688e67c.js → f1adf8ebc2c1b93857bf.js} +1 -1
- package/assets/esri/core/workers/chunks/f1b02c4bd5fde235212b.js +1 -0
- package/assets/esri/core/workers/chunks/f65b2d3a91a0c726fee4.js +1 -0
- package/assets/esri/core/workers/chunks/f667096ea325f690c4a6.js +1 -0
- package/assets/esri/core/workers/chunks/fe55833c80cf59df9c2b.js +1 -0
- package/assets/esri/libs/i3s/i3s.wasm +0 -0
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_en.json +1 -1
- package/chunks/ComponentShader.glsl.js +6 -5
- package/chunks/i3s.js +1 -1
- package/config.js +1 -1
- package/core/floatRGBA.js +1 -1
- package/graphic/graphicOrigins.d.ts +2 -0
- package/interfaces.d.ts +281 -124
- package/kernel.js +1 -1
- package/layers/CSVLayer.js +1 -1
- package/layers/GeoJSONLayer.js +1 -1
- package/layers/GraphicsLayer.js +1 -1
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/IntegratedMeshLayer.js +1 -1
- package/layers/Layer.js +1 -1
- package/layers/MapImageLayer.js +1 -1
- package/layers/MediaLayer.js +1 -1
- package/layers/OrientedImageryLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/TileLayer.js +1 -1
- package/layers/VectorTileLayer.js +1 -1
- package/layers/WCSLayer.js +1 -1
- package/layers/WMSLayer.js +1 -1
- package/layers/WebTileLayer.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/TemporalSceneLayer.js +1 -1
- package/layers/support/BuildingFilter.js +1 -1
- package/layers/support/LayerContingentValuesCache.js +1 -1
- package/layers/support/MapImage.js +1 -1
- package/layers/support/rasterDatasets/multipartParser.js +1 -1
- package/networks/Network.js +1 -1
- package/package.json +1 -1
- package/portal/Portal.js +1 -1
- package/portal/PortalItem.js +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/renderers/DotDensityRenderer.js +1 -1
- package/renderers/FlowRenderer.js +1 -1
- package/renderers/VectorFieldRenderer.js +1 -1
- package/renderers/support/ColormapInfo.js +1 -1
- package/rest/featureService/FeatureService.js +1 -1
- package/rest/knowledgeGraph/wasmInterface/knowledgeWasmAccess.js +1 -1
- package/rest/support/AlgorithmicColorRamp.js +1 -1
- package/rest/support/AttributeBinsFeatureSet.js +1 -1
- package/rest/support/DirectionsFeature.js +1 -1
- package/rest/support/FindImagesParameters.js +1 -1
- package/rest/support/ImageAreaParameters.js +1 -1
- package/rest/support/ImageBoundaryParameters.js +1 -1
- package/rest/support/ImageDistanceParameters.js +1 -1
- package/rest/support/ImageGPSInfoParameters.js +1 -1
- package/rest/support/ImageHeightParameters.js +1 -1
- package/rest/support/ImageHistogramParameters.js +1 -1
- package/rest/support/ImageIdentifyParameters.js +1 -1
- package/rest/support/ImagePixelLocationParameters.js +1 -1
- package/rest/support/ImagePointParameters.js +1 -1
- package/rest/support/ImageToMapMultirayParameters.js +1 -1
- package/rest/support/ImageToMapParameters.js +1 -1
- package/rest/support/ImageUrlParameters.js +1 -1
- package/rest/support/MapToImageParameters.js +1 -1
- package/rest/support/MeasureFromImageParameters.js +1 -1
- package/rest/support/MultipartColorRamp.js +1 -1
- package/support/revision.js +1 -1
- package/support/zipUtils.js +1 -1
- package/symbols/cim/animationUtils.js +1 -1
- package/symbols/support/gfxUtils.js +1 -1
- package/symbols/support/symbolLayerUtils.js +1 -1
- package/versionManagement/VersionManagementService.js +1 -1
- package/versionManagement/VersioningState.js +1 -1
- package/views/2d/engine/webgl/GlyphMosaic.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/projection.js +1 -1
- package/views/2d/input/handlers/MouseWheelZoom.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/3d/analysis/AreaMeasurementAnalysisView3D.js +1 -1
- package/views/3d/analysis/DimensionAnalysisView3D.js +1 -1
- package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
- package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSightAnalysisView3D.js +1 -1
- package/views/3d/analysis/SliceAnalysisView3D.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/layers/i3s/I3SUtil.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/support/GaussianSplatSortWorker.js +1 -1
- package/views/3d/support/GaussianSplatWorkerHandle.js +1 -1
- package/views/3d/support/flow/StreamlineResources3D.js +5 -0
- package/views/3d/support/flow/StreamlineResources3DOverlay.js +5 -0
- package/views/3d/support/flow/StreamlineResources3DShape.js +5 -0
- package/views/3d/support/flow/geometryUtils.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentData.glsl.js +21 -14
- package/views/3d/webgl-engine/collections/Component/UniformComponentParameters.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +5 -5
- package/views/3d/webgl-engine/core/shaderLibrary/util/RgbaFloatEncoding.glsl.js +7 -0
- package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js +7 -6
- package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
- package/views/SelectionManager.js +1 -1
- package/views/View.js +1 -1
- package/views/View2D.js +1 -1
- package/views/draw/Draw.js +1 -1
- package/webscene/spec-certification/compare.js +1 -1
- package/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/FeatureForm/GroupInput.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/ValuePicker/ValuePickerCombobox.js +1 -1
- package/widgets/Widget.js +1 -1
- package/widgets/smartMapping/ClassedColorSlider/ClassedColorSliderViewModel.js +1 -1
- package/widgets/smartMapping/ClassedSizeSlider/ClassedSizeSliderViewModel.js +1 -1
- package/widgets/smartMapping/ColorSizeSlider/ColorSizeSliderViewModel.js +1 -1
- package/widgets/smartMapping/ColorSlider/ColorSliderViewModel.js +1 -1
- package/widgets/smartMapping/HeatmapSlider/HeatmapSliderViewModel.js +1 -1
- package/widgets/smartMapping/OpacitySlider/OpacitySliderViewModel.js +1 -1
- package/widgets/smartMapping/SizeSlider/SizeSliderViewModel.js +1 -1
- package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js +1 -1
- package/assets/esri/core/workers/chunks/00ae094cc21bc42faa54.js +0 -1
- package/assets/esri/core/workers/chunks/016d421114118307d4dd.js +0 -1
- package/assets/esri/core/workers/chunks/1cd15aa69f85ecfa32b0.js +0 -1
- package/assets/esri/core/workers/chunks/21a9f9c0cc1cde2fee90.js +0 -1
- package/assets/esri/core/workers/chunks/2ae0bda04fd5386b462f.js +0 -1
- package/assets/esri/core/workers/chunks/3358c1b04490706681cc.js +0 -1
- package/assets/esri/core/workers/chunks/364fb103cb139f26b455.js +0 -1
- package/assets/esri/core/workers/chunks/4ae15645e68e7f6dd6b7.js +0 -1
- package/assets/esri/core/workers/chunks/5156410dd84ea1232a6c.js +0 -1
- package/assets/esri/core/workers/chunks/560bb06cf1bf30df4af3.js +0 -1
- package/assets/esri/core/workers/chunks/5f11fff5bc16fdec42db.js +0 -1
- package/assets/esri/core/workers/chunks/647cff1eaaf1b622f439.js +0 -1
- package/assets/esri/core/workers/chunks/6b5b609b357924fa35be.js +0 -1
- package/assets/esri/core/workers/chunks/6b73926feb5c5d957062.js +0 -1
- package/assets/esri/core/workers/chunks/6c167daf115cd6abb3e5.js +0 -1
- package/assets/esri/core/workers/chunks/719b89341b26c3568c2f.js +0 -1
- package/assets/esri/core/workers/chunks/791b3130b34b52160c1f.js +0 -1
- package/assets/esri/core/workers/chunks/79b389baf972d329c38d.js +0 -1
- package/assets/esri/core/workers/chunks/7a5808c6e67c43274d86.js +0 -1
- package/assets/esri/core/workers/chunks/7ef7f3925495b9ade88c.js +0 -1
- package/assets/esri/core/workers/chunks/82955562805ad5514ed8.js +0 -346
- package/assets/esri/core/workers/chunks/90a9b618058dc41294de.js +0 -1
- package/assets/esri/core/workers/chunks/95f0c15d83d1f38e01d0.js +0 -1
- package/assets/esri/core/workers/chunks/98ac849cccc4d5316021.js +0 -1
- package/assets/esri/core/workers/chunks/a13a36207f265f720255.js +0 -1
- package/assets/esri/core/workers/chunks/a36be186ad10200c420c.js +0 -1
- package/assets/esri/core/workers/chunks/ad1e5c24c1eae5ab8e45.js +0 -1
- package/assets/esri/core/workers/chunks/b481807b31e59cce9931.js +0 -1
- package/assets/esri/core/workers/chunks/bc27cdd7c415ab166536.js +0 -1
- package/assets/esri/core/workers/chunks/c474800508e3ad5ce9d7.js +0 -1
- package/assets/esri/core/workers/chunks/c52314b987c63cd630f7.js +0 -1
- package/assets/esri/core/workers/chunks/d1635a7ab0c204852237.js +0 -1
- package/assets/esri/core/workers/chunks/da228aed337f492456cc.js +0 -1
- package/assets/esri/core/workers/chunks/e08b2e9213d35f85916f.js +0 -1
- package/assets/esri/core/workers/chunks/ec9ed7c9d64f88fcb806.js +0 -1
- package/assets/esri/core/workers/chunks/fb84fa28978a1820a725.js +0 -1
- package/views/3d/support/flow/StreamlinesResources3D.js +0 -5
package/widgets/FeatureTable.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{watch as i,on as l,sync as o,initial as n}from"../core/reactiveUtils.js";import{renderingSanitizer as s}from"../core/sanitizerUtils.js";import{formatFileSize as a}from"../core/unitFormatUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{isLayerFromCatalog as d}from"../layers/catalog/catalogUtils.js";import{isKnowledgeGraphLayer as h,isMapImageLayer as p,isSubtypeGroupLayer as m}from"../layers/support/layerUtils.js";import u from"../tables/AttributeTableTemplate.js";import g from"./Widget.js";import{isSupportedImage as w,getCalciteIconForAttachment as b}from"./Attachments/support/attachmentUtils.js";import{loadPromptComponents as v,Prompt as y}from"./Editor/components/Prompt.js";import f from"./FeatureTable/ColumnMenuVisibleElements.js";import _ from"./FeatureTable/FeatureTableViewModel.js";import M from"./FeatureTable/VisibleElements.js";import{isGroupColumn as C}from"./FeatureTable/support/columnUtils.js";import{loadFieldColumnComponents as A,isIFeatureTableSupportedLayer as S,isIFeatureTableSupportedLayerWithAttachments as T,getRelationshipIdsToShow as E}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as V}from"./support/componentsUtils.js";import{globalCss as I}from"./support/globalCss.js";import{getIconForLayer as R}from"./support/iconUtils.js";import{storeNode as x,discardNode as k}from"./support/widgetUtils.js";import{messageBundle as D}from"./support/decorators/messageBundle.js";import{vmEvent as P}from"./support/decorators/vmEvent.js";import{tsx as O}from"./support/jsxFactory.js";import{substitute as F}from"../intl/substitute.js";var j;const z="esri-feature-table",L=`${z}__attachments-view`,U={base:z,content:`${z}__content`,menuPopover:`${z}__menu-popover`,layerDropdownMenu:`${z}__layer-switcher-menu`,tableContainer:`${z}__table-container`,tableContainerWithAttachments:`${z}__table-container--attachments`,tableNavigation:`${z}__table-navigation`,attachmentsView:L,attachmentsViewContent:`${L}__content`,attachmentsViewDropArea:`${L}__drop-area`,attachmentsViewIcon:`${L}__icon`,attachmentsViewInformation:`${L}__information`,attachmentsViewList:`${L}__list`,attachmentsViewListFileSize:`${L}__list__filesize`,attachmentsViewListItemDelete:`${L}__list-item--delete`,attachmentsViewListThumbnail:`${L}__list__thumbnail`,expanded:`${z}__expanded`,collapsed:`${z}__collapsed`},$={chevronRight:"chevron-right",clearSelection:"clear-selection",downloadTo:"download-to",exclamationMarkTriangle:"exclamation-mark-triangle",exportToCSV:"file-csv",folderOpen:"folder-open",delete:"trash",launch:"launch",layers:"layers",moveUp:"move-up",plus:"plus",refresh:"refresh",replaceImage:"replace-image",save:"save",showAll:"selection-x",showColumn:"show-column",showSelected:"selection-filter",upload:"upload",zoomToSelection:"zoom-to-object"};let B=j=class extends g{constructor(e,t){super(e,t),this._attachmentsInput=null,this._columnVisibilityActions=new Map,this.attachmentsList=null,this.description=null,this.disabled=!1,this.menuConfig=null,this.navigationScale="m",this.title=null,this.viewModel=new _,this.visibleElements=new M,this._showDeletePrompt=this._showDeletePrompt.bind(this),this._onDeleteSelectionClick=this._onDeleteSelectionClick.bind(this)}initialize(){this.addHandles([i(()=>[this.isQueryingOrSyncing,this.editingEnabled],()=>this.scheduleRender()),i(()=>[this._effectiveVisibleElements,this._effectiveVisibleElements.columnDescriptions,this._effectiveVisibleElements.columnMenus,this._effectiveVisibleElements.columnMenuItems,this.columns.length],()=>{this.columns.forEach(e=>e.visibleElements=this._effectiveVisibleElements),this.refreshCellContent()},o),i(()=>this._effectiveVisibleElements.selectionColumn,e=>{this.grid&&(this.grid.selectionColumnEnabled=e)},n),l(()=>this.viewModel,"show-related-table",e=>this._onShowRelatedTable(e)),i(()=>this.editingEnabled,()=>{const{attachmentsViewOptions:e}=this;this.clearPrompt(),e&&(e.form?.reset(),e.candidates=null)})])}loadDependencies(){return Promise.all([V({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),alert:()=>import("@esri/calcite-components/dist/components/calcite-alert"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),pagination:()=>import("@esri/calcite-components/dist/components/calcite-pagination"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")}),v(),A()])}destroy(){this.drainRelatedTables(),this.clearPrompt()}get _effectiveDescription(){const{description:e}=this;return null!=e?s.sanitize("function"==typeof e?e():e):void 0}get _effectiveLayers(){const{layer:e,layers:t}=this,i=t?.length?t.filter(S):[],l=i.length?i:[...this._viewLayers];return e&&!l.includes(e)&&l.push(e),l}get _effectiveTitle(){const{layer:e,messages:t,state:i,highlightIds:l,title:o,size:n}=this;if(o)return s.sanitize("function"==typeof o?o():o);if(!e)return t.noLayer;switch(i){case"disabled":return t.errorLayer;case"ready":case"loading":return t.loading;case"error":return t.errorData}return F(t.header,{title:s.sanitize(e.title),count:n,selected:l.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _filteredTables(){const e=this.relatedTables.toArray(),t=1===e.length;return this.allRelatedTablesVisible?e:t?[e[0]]:this._shouldShowAttachmentsView?e.slice(-1):e.slice(-2)}get _hasAttachmentsViewError(){return null!=this.attachmentsViewOptions.error}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showExportSelectionToCSVAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnsVisibilityAction)}get _shouldShowGrid(){return this.allRelatedTablesVisible||1===this.relatedTables.length&&!this._shouldShowAttachmentsView}get _shouldShowMenu(){const{header:e,menu:t}=this._effectiveVisibleElements;return!(!e||!t||!this._hasDefaultMenuItems&&!this._hasCustomMenuItems)}get _shouldShowAttachmentsView(){return!(null==this.attachmentsViewOptions.objectId&&!this.relatedTables.some(e=>null!=e.attachmentsViewOptions.objectId))}get _showClearSelectionAction(){return!(!this.highlightIds.length||!this._effectiveVisibleElements.menuItems?.clearSelection||this.relatedTables.length||this._shouldShowAttachmentsView)}get _showColumnsVisibilityAction(){const{header:e,menu:t,menuItems:i}=this._effectiveVisibleElements;return!(!(e&&t&&i?.toggleColumns)||this.showRelatedTableCallback||this.allRelatedTablesVisible||this._shouldShowAttachmentsView)}get _showDeleteSelectionAction(){return!(!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete)||this.relatedTables.length||this._shouldShowAttachmentsView)}get _showExportSelectionToCSVAction(){return!(!(this._effectiveVisibleElements.menuItems.exportSelectionToCSV&&this.layer&&this.highlightIds.length)||this.relatedTables.length)}get _showLayerDropdown(){return!(!this._effectiveLayers.length||!this._effectiveVisibleElements.layerDropdown)}get _shouldShowNavigationBar(){const e=!!this.relatedTable||this._shouldShowAttachmentsView;return!this.tableParent&&e}get _showRefreshDataAction(){return!!this._effectiveVisibleElements.menuItems?.refreshData}get _showSelectedRecordsShowSelectedAction(){const e=this.objectIds.length,t=this.highlightIds.length;return!(!t||!this._effectiveVisibleElements.menuItems?.selectedRecordsShowSelectedToggle||e&&t===e||this.relatedTables.length||this._shouldShowAttachmentsView)}get _showSelectedRecordsShowAllAction(){return!(!this._effectiveVisibleElements.menuItems?.selectedRecordsShowAllToggle||!this.objectIds.length||this.relatedTables.length)}get _showZoomToSelectionAction(){return!(!this.view||!this.highlightIds.length||this.effectiveTable.layer?.isTable||!this._effectiveVisibleElements.menuItems?.zoomToSelection)}get _viewLayers(){const e=this.view?.map;if(!e)return[];const t=new Set,i=e=>{!S(e)||m(e)||t.has(e)||"sublayer"===e.type&&!e.capabilities?.operations?.supportsQuery||(e.load(),t.add(e))},l=e=>{d(e)||"catalog-footprint"===e.type||(h(e)?(e.load(),e.layers?.forEach(i),e.tables?.forEach(i)):p(e)?(e.loadAll(),e.allSublayers?.forEach(i),e.subtables?.forEach(i)):m(e)?(e.loadAll(),e.sublayers?.forEach(i)):i(e))};return e.allLayers.forEach(l),e.allTables.forEach(l),[...t.values()]}get grid(){return this.viewModel.grid}get actionColumn(){return this.viewModel.actionColumn}get actionColumnConfig(){return this.viewModel.actionColumnConfig}set actionColumnConfig(e){this.viewModel.actionColumnConfig=e}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get allColumns(){return this.viewModel.allColumns}get allRelatedTablesVisible(){return this.viewModel.allRelatedTablesVisible}get allVisibleColumns(){return this.viewModel.allVisibleColumns}get attachmentsColumns(){return this.viewModel.attachmentsColumns}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get attachmentsViewOptions(){return this.viewModel.attachmentsViewOptions}set attachmentsViewOptions(e){this.viewModel.attachmentsViewOptions=e}get attributeTableTemplate(){return this.viewModel.attributeTableTemplate}set attributeTableTemplate(e){this.viewModel.attributeTableTemplate=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get clearPrompt(){return this.viewModel.clearPrompt}set clearPrompt(e){this.viewModel.clearPrompt=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get definitionExpression(){return this.viewModel.definitionExpression}set definitionExpression(e){this.viewModel.definitionExpression=e}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get effectiveSize(){return this.viewModel.effectiveSize}get effectiveTable(){return this.relatedTable||this}get fieldColumns(){return this.viewModel.fieldColumns}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get filterBySelectionEnabled(){return this.viewModel.filterBySelectionEnabled}set filterBySelectionEnabled(e){this.viewModel.filterBySelectionEnabled=e}get groupColumns(){return this.viewModel.groupColumns}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get icon(){return"table"}set icon(e){this._overrideIfSome("icon",e)}get initialSize(){return this.viewModel.initialSize}set initialSize(e){this.viewModel.initialSize=e}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing}get isSyncingAttachments(){return this.viewModel.isSyncingAttachments}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get layers(){return this.viewModel.layers}set layers(e){this.viewModel.layers=e}get layerView(){return this.viewModel.layerView}get maxSize(){return this.viewModel.maxSize}set maxSize(e){this.viewModel.maxSize=e}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesUnits(){return this.viewModel.messagesUnits}set messagesUnits(e){this.viewModel.messagesUnits=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=e}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get multipleSortPriority(){return this.viewModel.multipleSortPriority}set multipleSortPriority(e){this.viewModel.multipleSortPriority=e}get noDataMessage(){return this.viewModel.noDataMessage}set noDataMessage(e){this.viewModel.noDataMessage=e}get objectIds(){return this.viewModel.objectIds}set objectIds(e){this.viewModel.objectIds=e}get outFields(){return this.viewModel.outFields}set outFields(e){this.viewModel.outFields=e}get pageCount(){return this.viewModel.pageCount}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get prompt(){return this.viewModel.prompt}set prompt(e){this.viewModel.prompt=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.viewModel.relatedTable}get relatedTables(){return this.viewModel.relatedTables}set relatedTables(e){this.viewModel.relatedTables=e}get relationship(){return this.viewModel.relationship}get relationshipColumnConfigs(){return this.viewModel.relationshipColumnConfigs}set relationshipColumnConfigs(e){this.viewModel.relationshipColumnConfigs=e}get relationshipColumns(){return this.viewModel.relationshipColumns}get relationshipConfig(){return this.viewModel.relationshipConfig}set relationshipConfig(e){this.viewModel.relationshipConfig=e}get relationshipInfos(){return this.viewModel.relationshipInfos}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}get returnMEnabled(){return this.viewModel.returnMEnabled}set returnMEnabled(e){this.viewModel.returnMEnabled=e}get returnZEnabled(){return this.viewModel.returnZEnabled}set returnZEnabled(e){this.viewModel.returnZEnabled=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get selectionSource(){return this.viewModel.selectionSource}set selectionSource(e){this.viewModel.selectionSource=e}get showAllRelatedTables(){return this.viewModel.showAllRelatedTables}set showAllRelatedTables(e){this.viewModel.showAllRelatedTables=e}get showPrompt(){return this.viewModel.showPrompt}set showPrompt(e){this.viewModel.showPrompt=e}get showRelatedTableCallback(){return this.viewModel.showRelatedTableCallback}set showRelatedTableCallback(e){this.viewModel.showRelatedTableCallback=e}get size(){return this.viewModel.size}get state(){return this.viewModel.state}get supportsAddAttachments(){return this.viewModel.supportsAddAttachments}get supportsAttachments(){return this.viewModel.supportsAttachments}get supportsDeleteAttachments(){return this.viewModel.supportsDeleteAttachments}get supportsResizeAttachments(){return this.viewModel.supportsResizeAttachments}get supportsUpdateAttachments(){return this.viewModel.supportsUpdateAttachments}get syncTemplateOnChangesEnabled(){return this.viewModel.syncTemplateOnChangesEnabled}set syncTemplateOnChangesEnabled(e){this.viewModel.syncTemplateOnChangesEnabled=e}get tableController(){return this.viewModel.tableController}set tableController(e){this.viewModel.tableController=e}get tableParent(){return this.viewModel.tableParent}set tableParent(e){this.viewModel.tableParent=e}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get tableTemplateOverride(){return this.viewModel.tableTemplateOverride}set tableTemplateOverride(e){this.viewModel.tableTemplateOverride=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visibleColumns(){return this.viewModel.visibleColumns}get visibleElementsOverride(){const{attachmentsViewOptions:e,relatedTable:t,tableController:i,visibleElements:l}=this,{columnDescriptions:o,columnMenus:n,tooltips:s}=l,a=null!=e.objectId;if(t)return new M({columnDescriptions:o,columnMenus:n,tooltips:s,close:l.close,header:l.header,layerDropdown:l.layerDropdown,layerDropdownIcons:l.layerDropdownIcons,menu:l.menu,menuItems:l.menuItems,progress:l.progress,selectionColumn:!1,columnMenuItems:new f({sortAscending:!1,sortDescending:!1})});if(i){const e=i.relatedTable===this,t=i.allRelatedTablesVisible,r=e&&l.selectionColumn&&!t&&!a,c=e&&!t&&!a;return new M({columnDescriptions:o,columnMenus:n,tooltips:s,selectionColumn:r,close:!1,header:!1,layerDropdown:!1,menu:!1,progress:!1,columnMenuItems:new f({sortAscending:c,sortDescending:c})})}return a?new M({columnDescriptions:o,columnMenus:n,tooltips:s,close:l.close,header:l.header,layerDropdown:l.layerDropdown,layerDropdownIcons:l.layerDropdownIcons,menu:l.menu,menuItems:l.menuItems,progress:l.progress,selectionColumn:!1,columnMenuItems:new f({sortAscending:!1,sortDescending:!1})}):null}clearSelectionFilter(){this.viewModel.clearSelectionFilter()}async deleteAttachments(e,t,i){null!=e&&t?.length&&(i?this._showDeleteAttachmentPrompt(e,t):await this.viewModel.deleteAttachments(e,t))}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}async downloadAttachmentById(e,t){return this.viewModel.downloadAttachmentById(e,t)}drainRelatedTables(){this.viewModel.drainRelatedTables()}exportSelectionToCSV(e){return this.viewModel.exportSelectionToCSV(e)}filterBySelection(){this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}goToPage(e){this.viewModel.goToPage(e)}hideColumn(e){this.grid?.hideColumn(e)}nextPage(){this.viewModel.nextPage()}previousPage(){this.viewModel.previousPage()}async refresh(){await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}async saveAttachmentsViewForm(){await this.viewModel.saveAttachmentsViewForm()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollLeft(){this.viewModel.scrollLeft()}scrollToBottom(){this.viewModel.scrollToBottom()}scrollToIndex(e){this.viewModel.scrollToIndex(e)}scrollToRow(e){this.viewModel.scrollToRow(e)}scrollToTop(){this.viewModel.scrollToTop()}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}zoomToSelection(){this.effectiveTable.viewModel.zoomToSelection()}render(){const{_effectiveVisibleElements:e,isQueryingOrSyncing:t,menuConfig:i,state:l}=this;return O("div",{bind:this,class:this.classes(U.base,I.widget)},O("calcite-panel",{bind:this,class:U.content,closable:e.close,description:this._effectiveDescription,disabled:this.disabled||"disabled"===l&&!this._effectiveLayers?.length,heading:e.header?this._effectiveTitle:void 0,loading:"loading"===l,menuOpen:!!i?.open,overlayPositioning:"fixed",onCalcitePanelClose:e=>{e.currentTarget.closed=!1,this.emit("close")}},e.progress?O("calcite-progress",{type:t?"indeterminate":"determinate"}):null,this._showLayerDropdown?this._renderLayerDropdown():null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderNavigationBar(),this._renderTables(),this._renderError()),this._renderColumnVisibilityPopover(),this._renderPrompt())}_renderTables(){const{grid:e,relatedTables:t}=this,i=this.classes(U.tableContainer);if(t.length){const l=this.classes(U.base,this.allRelatedTablesVisible?U.expanded:U.collapsed,this._shouldShowAttachmentsView?U.tableContainerWithAttachments:void 0);return O("div",{class:i},O("calcite-panel",{overlayPositioning:"fixed"},O("div",null,[this._shouldShowGrid?O("div",{class:l},e?.render(),this._renderPagination()):void 0,...this._filteredTables.map(e=>{const i=t.indexOf(e);return O("div",{class:l,key:`related-${i}`},e.render())}),,])))}return null!=this.attachmentsViewOptions.objectId?O("div",{class:i},O("calcite-panel",{overlayPositioning:"fixed"},O("div",null,[O("div",{class:this.classes(U.base,U.collapsed)},e?.render(),this._renderPagination()),this._renderAttachmentsView()]))):[O("div",{class:i},e?.render()),this._renderPagination()]}_renderPagination(){if(this.paginationEnabled)return O("calcite-pagination",{pageSize:1,startItem:this.pageIndex+1,totalItems:this.pageCount,onCalcitePaginationChange:e=>this.goToPage(e.currentTarget.startItem-1)})}_renderError(){const{messages:e}=this;return O("calcite-alert",{autoClose:!0,autoCloseDuration:"fast",icon:$.exclamationMarkTriangle,kind:"danger",label:e.errorOccured,open:this._hasAttachmentsViewError,slot:"alerts",onCalciteAlertClose:()=>{this.attachmentsViewOptions.error=null}},O("span",{slot:"message"},e.errorOccured))}_renderPrompt(){return this.prompt?O(y,{...this.prompt,headingLevel:2}):void 0}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=F(e.deleteSelectionCount,{count:this.highlightIds.length});this.showPrompt({title:i,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this.clearPrompt()}}})}_showDeleteAttachmentPrompt(e,t){const{messages:i,messagesCommon:l}=this,o=F(i.deleteAttachmentCount,{count:t.length});this.showPrompt({title:o,message:i.deleteAttachmentConfirmation,context:"danger",actions:{primary:{label:l.delete,action:async()=>{try{await this.deleteAttachments(e,t,!1)}finally{this.clearPrompt()}}},secondary:{label:l.cancel,action:()=>this.clearPrompt()}}})}async _onDeleteSelectionClick(){try{await this.viewModel.deleteSelection()}finally{this.clearPrompt()}}_renderHeaderMenuAction(e){const{disabled:t,hidden:i,icon:l,text:o,clickFunction:n}=e;if(!i)return O("calcite-action",{disabled:t??this.menuConfig?.disabled,icon:l??void 0,key:o,onclick:()=>n(),slot:"header-menu-actions",text:o,textEnabled:!0,title:o})}_renderHeaderMenuActions(){return this._shouldShowMenu?[this._renderDefaultHeaderMenuActions(),this._renderCustomHeaderMenuActions()]:[]}_renderDefaultHeaderMenuActions(){if(!this._hasDefaultMenuItems)return[];const{messages:e}=this;return[this._showRefreshDataAction&&{icon:$.refresh,text:e.refreshData,clickFunction:()=>this.refresh()},this._showDeleteSelectionAction&&{icon:$.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)},this._showClearSelectionAction&&{icon:$.clearSelection,text:e.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()},this._showZoomToSelectionAction&&{icon:$.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()},this._showSelectedRecordsShowSelectedAction&&{icon:$.showSelected,text:e.showSelected,clickFunction:()=>{const{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}},this._showSelectedRecordsShowAllAction&&{icon:$.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()},this._showExportSelectionToCSVAction&&{icon:$.exportToCSV,text:e.exportSelectionCSV,clickFunction:()=>this.exportSelectionToCSV()}].filter(t).map(e=>e&&this._renderHeaderMenuAction(e))}_renderCustomHeaderMenuActions(){return this.menuConfig?.items?.map(({disabled:e,hidden:t,icon:i,label:l,clickFunction:o})=>this._renderHeaderMenuAction({hidden:"function"==typeof t?t():t,icon:i,text:l,disabled:e,clickFunction:e=>o(e)}))??[]}_renderColumnVisibilityAction(){if(!this._showColumnsVisibilityAction)return[];const{_columnVisibilityActions:e,effectiveTable:t,id:i}=this,l=this.messages.toggleColumns;return O("calcite-action",{afterCreate:t=>e.set(i,t),afterRemoved:()=>e.delete(i),appearance:"transparent",bind:this,disabled:t.menuConfig?.disabled,icon:$.showColumn,id:`${i}__toggle-columns-action`,slot:"header-actions-end",text:l},this._effectiveVisibleElements.tooltips?O("calcite-tooltip",{closeOnClick:!0,overlayPositioning:"fixed",placement:"bottom-end",slot:"tooltip"},l):null)}_renderColumnVisibilityPopover(){if(!this._showColumnsVisibilityAction||this.effectiveTable.menuConfig?.disabled)return;const{effectiveTable:e}=this,t=this.messages.toggleColumns;return O("calcite-popover",{autoClose:!0,class:U.menuPopover,label:t,overlayPositioning:"fixed",placement:"top-end",pointerDisabled:!0,referenceElement:this._columnVisibilityActions.get(this.id)},O("calcite-list",{displayMode:"nested",filterEnabled:!0,filterPlaceholder:t,label:t,selectionMode:"multiple"},e.columns.toArray().map(t=>{const i=C(t)?t.columns?.map(t=>this._renderColumnListItem({column:t,table:e,ignoreSelect:!0})):void 0;return this._renderColumnListItem({column:t,table:e,items:i})})))}_renderColumnListItem(e){const{column:t,table:i,items:l,ignoreSelect:o}=e,{effectiveLabel:n,fieldName:s,hidden:a}=t;return O("calcite-list-item",{expanded:!(!l?.length||a)||void 0,key:`toggle-columns__item-${s}`,label:n,selected:!a,value:s,onCalciteListItemSelect:e=>{o&&e.stopPropagation(),i.toggleColumnVisibility(e.currentTarget.value)}},l)}_renderLayerDropdown(){const e=this.messages.selectALayer;return O("div",{class:U.layerDropdownMenu,key:`${this.id}-layerDropdown`,slot:"header-actions-start"},O("calcite-dropdown",{bind:this,maxItems:5,overlayPositioning:"fixed",placement:"bottom-start"},O("calcite-action",{icon:$.layers,slot:"trigger",text:e,title:e}),O("calcite-dropdown-group",{selectionMode:"single"},this._effectiveLayers.map((e,t)=>this._renderLayerDropdownItem(e,t))??null)))}_renderLayerDropdownItem(e,t){const i=this.visibleElements.layerDropdownIcons;return O("calcite-dropdown-item",{iconStart:i?R(e):void 0,key:`dropdown-item-${t}`,label:e.title??"",selected:e===this.layer,value:e.id,onCalciteDropdownItemSelect:()=>{this.layer=e}},e.title)}_onRelatedNavigationItemClick(e){this.viewModel.drainRelatedTablesAboveIndex(e)}_collapseRelatedTable(e){this.viewModel.collapseRelatedTable(this.effectiveTable,e)}_onShowRelatedTable(e){this.showRelatedTableCallback||(this._collapseRelatedTable(e),this._createRelatedTable(e))}async _createRelatedTable(e){const{editingEnabled:t,effectiveTable:i,paginationEnabled:l,pageSize:o,view:n,viewModel:s}=this,{layer:a,objectId:r,relatedLayer:c,relationshipId:d}=e;await a.load();const h=this.attachmentsEnabled&&T(a),p=new j({layer:a,attachmentsEnabled:h,editingEnabled:t,paginationEnabled:l,pageSize:o,relatedRecordsEnabled:!0,relationshipConfig:{objectId:r,relatedLayer:c,relationshipId:d},relationshipColumnConfigs:E(a,d),tableController:this,tableParent:i,view:n,showRelatedTableCallback:e=>s.emit("show-related-table",e)});this.relatedTables.add(p),this.scheduleRender()}_renderAttachmentsView(){const{attachmentInfos:e,mode:t,objectId:i}=this.attachmentsViewOptions;return"file"!==t&&e.length&&null!=i?this._renderAttachmentsViewList():this._renderAttachmentsViewFilePane()}_renderAttachmentsViewFilePane(){const{attachmentsViewOptions:e,isSyncingAttachments:t,supportsAddAttachments:i,messages:l,messagesUnits:o}=this,{attachmentId:n,attachmentInfos:s,candidates:r,objectId:c}=e,d=s.find(e=>e.id===n),h=s.length,p=r?.length,m=d?O("calcite-label",{alignment:"center",key:"replace-file-node",scale:"l"},l.replaceFile):void 0,u=p?void 0:O("calcite-label",{alignment:"center",key:"message-node",scale:"m"},i?null==c?l.noFeature:l.dragAndDropToUpload:l.editingRestricted),g=Array.from(r??[]).pop(),w=g?O("calcite-label",{key:"filename-node"},g.name):void 0,b=i&&null!=c,v=b&&p,y=O("input",{afterCreate:x,afterRemoved:k,afterUpdate:x,bind:this,"data-node-ref":"_attachmentsInput",files:r,hidden:!0,name:"attachment",onchange:e=>this._onAttachmentsViewCandidateChange(e),type:"file"}),f=b?O("calcite-button",{appearance:"outline-fill",bind:this,disabled:t,iconStart:$.folderOpen,key:"select-node",loading:!1,onclick:()=>{this._attachmentsInput&&(this._attachmentsInput.value="",this._attachmentsInput.click())},width:"full"},l.selectFile):void 0,_=v?O("calcite-button",{appearance:"outline-fill",bind:this,disabled:t,iconStart:$.save,key:"save-node",loading:t,onclick:()=>{this.saveAttachmentsViewForm()},width:"full"},d?l.updateAttachment:l.addAttachment):void 0,M=h||p?O("calcite-button",{appearance:"transparent",bind:this,disabled:t,key:"cancel-node",onclick:()=>{this._attachmentsInput&&(this._attachmentsInput.value=""),e.reset(),e.attachmentInfos?.length&&(e.mode="list")},width:"full"},this.messagesCommon.cancel):void 0;return[O("div",{class:U.attachmentsView,key:"attachments-view"},O("div",{class:U.attachmentsViewContent,key:"attachments-view-content"},O("div",{bind:this,class:U.attachmentsViewDropArea,ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop},O("calcite-icon",{class:U.attachmentsViewIcon,icon:$.upload,scale:"l"}),m,u,O("form",{afterCreate:t=>e.form=t,afterRemoved:()=>e.form=null,bind:this,key:"attachments-form"},O("fieldset",null,w,y,f,_,M)))),null!=c&&null!=d?O("div",{class:U.attachmentsViewInformation,key:"information"},this._renderAttachmentsViewThumbnail(d,200),O("label",{key:"file-label"},l.fileName),O("span",{key:"file-span"},d.name),O("label",{key:"size-label"},l.size),O("span",{key:"size-span"},a(o,d.size??0))):void 0)]}_renderAttachmentsViewList(){const{attachmentsViewOptions:e,isSyncingAttachments:t,messages:i,messagesUnits:l,supportsDeleteAttachments:o,supportsUpdateAttachments:n}=this,{attachmentInfos:s,objectId:r}=e;return O("calcite-list",{afterCreate:x,afterRemoved:k,afterUpdate:x,bind:this,class:U.attachmentsViewList,"data-node-ref":"attachmentsList",key:`attachments-list-${r}`,label:i?.attachments,loading:t,ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop,selectionMode:"multiple",onCalciteListChange:()=>this.scheduleRender()},...s?.map(t=>{const{id:s,name:c,size:d,url:h}=t,p=a(l,d??0);return O("calcite-list-item",{afterRemoved:()=>this.scheduleRender(),key:`attachment-${s}`,label:c,value:s},this._renderAttachmentsViewListThumbnail(t),O("span",{class:U.attachmentsViewListFileSize,slot:"actions-end",title:p},p),O("calcite-action",{appearance:"transparent",icon:$.downloadTo,key:`download-attachment-${s}`,label:`${c}`,onclick:e=>{e.preventDefault(),this.downloadAttachmentById(r??-1,s)},slot:"actions-end",text:i.downloadAttachment,title:i.downloadAttachment}),n&&null!=r?O("calcite-action",{appearance:"transparent",disabled:!n,icon:$.replaceImage,key:`replace-attachment-${s}`,label:`${c}`,onclick:()=>{e.mode="file",e.attachmentId=s},slot:"actions-end",text:i.updateAttachment,title:i.updateAttachment}):void 0,O("calcite-action",{appearance:"transparent",icon:$.launch,key:`launch-attachment-${s}`,label:`${c}`,onclick:()=>{h&&window.open(h,"_blank")},slot:"actions-end",text:i.viewAttachment,title:i.viewAttachment}),o&&null!=r?O("calcite-action",{appearance:"transparent",class:U.attachmentsViewListItemDelete,disabled:!o,icon:$.delete,key:`delete-attachment-${s}`,label:`${c}`,onclick:()=>{this.deleteAttachments(r,[s],!0)},slot:"actions-end",text:i.deleteAttachment,title:i.deleteAttachment}):void 0)}))}_renderAttachmentsViewListThumbnail(e){return O("div",{class:U.attachmentsViewListThumbnail,slot:"content-start"},O("a",{href:e.url??"",rel:"noreferrer",target:"_blank"},this._renderAttachmentsViewThumbnail(e)))}_renderAttachmentsViewThumbnail(e,t=64){const{contentType:i,name:l,size:o,url:n}=e,s=`${n}${n?.includes("?")?"&":"?"}w=${t}&s=${o}`;return this.supportsResizeAttachments&&w(i)?O("img",{alt:l,key:`thumbnail-image-${l}`,src:s,title:l}):O("calcite-icon",{icon:b(i),key:`thumbnail-icon-${l}`,scale:"l",textLabel:l,title:l})}_onAttachmentsViewCandidateChange({target:e}){this.attachmentsViewOptions.candidates=e?.files}_onAttachmentsViewDrop(e){e.preventDefault(),(this.supportsAddAttachments||this.supportsUpdateAttachments)&&this.attachmentsViewOptions.set({mode:"file",candidates:e.dataTransfer?.files})}_renderNavigationBar(){const{effectiveTable:e,messages:t,messagesCommon:i,navigationScale:l,relatedTable:o,relatedTables:n}=this;if(!this._shouldShowNavigationBar)return;const{attachmentsList:s,attachmentsViewOptions:a,layer:r,supportsAddAttachments:c,supportsDeleteAttachments:d}=e;if(!r)return;const{attachmentInfos:h,objectId:p}=a,m=null!=p,u=h.length,g=s?.selectedItems?.length??0,w=`${r.objectIdField}: ${p}`,b=F(t.selectedCount,{count:g}),v=F(t.attachmentsCount,{count:u}),y=m?O("calcite-action",{bind:this,icon:$.chevronRight,iconFlipRtl:!0,key:"navigation-feature",onclick:()=>e.scrollToRow(p),scale:l,text:w,textEnabled:!0,title:w}):void 0,f=m?O("calcite-action",{icon:$.chevronRight,iconFlipRtl:!0,key:"navigation-attachments-label",label:v,onclick:()=>{u>0&&(a.mode="list")},scale:l,text:v,textEnabled:!0,title:v}):void 0,_=m?O("calcite-chip",{closable:!0,closed:0===g,key:"navigation-chip",kind:"inverse",label:b,scale:l,selected:!0,title:b,value:"selected",onCalciteChipClose:()=>s?.selectedItems?.forEach(e=>e.selected=!1)},b):void 0,M=o?O("calcite-label",{layout:"inline",scale:l},t.showAllTables,O("calcite-switch",{checked:this.allRelatedTablesVisible,scale:l,onCalciteSwitchChange:e=>this.showAllRelatedTables=!!e.currentTarget.checked})):void 0,C=m&&"list"===a.mode&&null!=p&&g&&d?O("calcite-action",{icon:$.delete,iconFlipRtl:!0,key:"attachments-trash-all",onclick:()=>{e.deleteAttachments(p,s?.selectedItems?.map(e=>e.value)??[],!0)},scale:l,text:i.delete,textEnabled:!0,title:F(t.deleteAttachmentCount,{count:g})}):void 0,A=m&&"list"===a.mode&&c?O("calcite-action",{bind:this,icon:$.plus,iconFlipRtl:!0,key:"attachments-add",onclick:()=>{a.attachmentId=null,a.mode="file"},scale:l,text:t.addAttachment,textEnabled:!0,title:t.addAttachment}):void 0;return O("div",{class:U.tableNavigation,key:"table-nav"},O("calcite-action",{icon:$.moveUp,iconFlipRtl:!0,key:"go-back",onclick:()=>{o&&this.drainRelatedTables(),e.attachmentsViewOptions.objectId=null},scale:l,text:this.layer?.title??"",textEnabled:!1,title:o?t.exitRelatedRecords:t.exitAttachments}),n.toArray().map((e,t)=>this._renderRelatedTableNavigationAction(e,t)),y,f,O("div",null,_,M,C,A))}_renderRelatedTableNavigationAction(e,t){const i=this._getLabelForRelatedTableNavigationAction(e);return O("calcite-action",{icon:$.chevronRight,iconFlipRtl:!0,key:t,onclick:()=>this._onRelatedNavigationItemClick(t),scale:this.navigationScale,text:i,textEnabled:!0,title:e.layer?.title||""})}_getLabelForRelatedTableNavigationAction(e){const t=e.layer?.title;if(!t)return"";const{relatedTables:i}=this;if(i.length<=1)return t;return i.indexOf(e)!==i.length-1&&t.length>20?`${t.slice(0,20)}...`:t}};e([r()],B.prototype,"_attachmentsInput",void 0),e([r()],B.prototype,"_columnVisibilityActions",void 0),e([r()],B.prototype,"_effectiveDescription",null),e([r()],B.prototype,"_effectiveLayers",null),e([r()],B.prototype,"_effectiveTitle",null),e([r()],B.prototype,"_effectiveVisibleElements",null),e([r()],B.prototype,"_filteredTables",null),e([r()],B.prototype,"_hasAttachmentsViewError",null),e([r()],B.prototype,"_hasCustomMenuItems",null),e([r()],B.prototype,"_hasDefaultMenuItems",null),e([r()],B.prototype,"_shouldShowGrid",null),e([r()],B.prototype,"_shouldShowMenu",null),e([r()],B.prototype,"_shouldShowAttachmentsView",null),e([r()],B.prototype,"_showClearSelectionAction",null),e([r()],B.prototype,"_showColumnsVisibilityAction",null),e([r()],B.prototype,"_showDeleteSelectionAction",null),e([r()],B.prototype,"_showExportSelectionToCSVAction",null),e([r()],B.prototype,"_showLayerDropdown",null),e([r()],B.prototype,"_shouldShowNavigationBar",null),e([r()],B.prototype,"_showRefreshDataAction",null),e([r()],B.prototype,"_showSelectedRecordsShowSelectedAction",null),e([r()],B.prototype,"_showSelectedRecordsShowAllAction",null),e([r()],B.prototype,"_showZoomToSelectionAction",null),e([r()],B.prototype,"_viewLayers",null),e([r()],B.prototype,"attachmentsList",void 0),e([r({readOnly:!0})],B.prototype,"grid",null),e([r()],B.prototype,"actionColumn",null),e([r()],B.prototype,"actionColumnConfig",null),e([r({readOnly:!0})],B.prototype,"activeFilters",null),e([r({readOnly:!0})],B.prototype,"activeSortOrders",null),e([r()],B.prototype,"allColumns",null),e([r({readOnly:!0})],B.prototype,"allRelatedTablesVisible",null),e([r()],B.prototype,"allVisibleColumns",null),e([r()],B.prototype,"attachmentsColumns",null),e([r()],B.prototype,"attachmentsEnabled",null),e([r()],B.prototype,"attachmentsViewOptions",null),e([r({type:u})],B.prototype,"attributeTableTemplate",null),e([r()],B.prototype,"autoRefreshEnabled",null),e([r()],B.prototype,"clearPrompt",null),e([r()],B.prototype,"columnPerformanceModeEnabled",null),e([r()],B.prototype,"columnReorderingEnabled",null),e([r({readOnly:!0})],B.prototype,"columns",null),e([r()],B.prototype,"definitionExpression",null),e([r()],B.prototype,"description",void 0),e([r()],B.prototype,"disabled",void 0),e([r()],B.prototype,"editingEnabled",null),e([r()],B.prototype,"effectiveSize",null),e([r()],B.prototype,"effectiveTable",null),e([r()],B.prototype,"fieldColumns",null),e([r()],B.prototype,"filterGeometry",null),e([r()],B.prototype,"filterBySelectionEnabled",null),e([r()],B.prototype,"groupColumns",null),e([r()],B.prototype,"hiddenFields",null),e([r()],B.prototype,"highlightEnabled",null),e([r()],B.prototype,"highlightIds",null),e([r()],B.prototype,"icon",null),e([r()],B.prototype,"initialSize",null),e([r()],B.prototype,"isQueryingOrSyncing",null),e([r()],B.prototype,"isSyncingAttachments",null),e([r()],B.prototype,"label",null),e([r()],B.prototype,"layer",null),e([r()],B.prototype,"layers",null),e([r()],B.prototype,"layerView",null),e([r()],B.prototype,"maxSize",null),e([r(),D("esri/widgets/FeatureTable/t9n/FeatureTable")],B.prototype,"messages",null),e([r(),D("esri/t9n/common")],B.prototype,"messagesCommon",null),e([r(),D("esri/core/t9n/Units")],B.prototype,"messagesUnits",null),e([r(),D("esri/widgets/support/t9n/uriUtils")],B.prototype,"messagesURIUtils",null),e([r()],B.prototype,"menuConfig",void 0),e([r()],B.prototype,"multipleSelectionEnabled",null),e([r()],B.prototype,"multiSortEnabled",null),e([r()],B.prototype,"multipleSortPriority",null),e([r()],B.prototype,"navigationScale",void 0),e([r()],B.prototype,"noDataMessage",null),e([r()],B.prototype,"objectIds",null),e([r()],B.prototype,"outFields",null),e([r()],B.prototype,"pageCount",null),e([r()],B.prototype,"pageIndex",null),e([r()],B.prototype,"pageSize",null),e([r()],B.prototype,"paginationEnabled",null),e([r()],B.prototype,"prompt",null),e([r()],B.prototype,"relatedRecordsEnabled",null),e([r()],B.prototype,"relatedTable",null),e([r()],B.prototype,"relatedTables",null),e([r()],B.prototype,"relationship",null),e([r()],B.prototype,"relationshipColumnConfigs",null),e([r()],B.prototype,"relationshipColumns",null),e([r()],B.prototype,"relationshipConfig",null),e([r()],B.prototype,"relationshipInfos",null),e([r()],B.prototype,"returnGeometryEnabled",null),e([r()],B.prototype,"returnMEnabled",null),e([r()],B.prototype,"returnZEnabled",null),e([r()],B.prototype,"rowHighlightIds",null),e([r()],B.prototype,"selectionSource",null),e([r()],B.prototype,"showAllRelatedTables",null),e([r()],B.prototype,"showPrompt",null),e([r()],B.prototype,"showRelatedTableCallback",null),e([r()],B.prototype,"size",null),e([r({readOnly:!0})],B.prototype,"state",null),e([r()],B.prototype,"supportsAddAttachments",null),e([r()],B.prototype,"supportsAttachments",null),e([r()],B.prototype,"supportsDeleteAttachments",null),e([r()],B.prototype,"supportsResizeAttachments",null),e([r()],B.prototype,"supportsUpdateAttachments",null),e([r()],B.prototype,"syncTemplateOnChangesEnabled",null),e([r({constructOnly:!0})],B.prototype,"tableController",null),e([r({constructOnly:!0})],B.prototype,"tableParent",null),e([r()],B.prototype,"tableTemplate",null),e([r()],B.prototype,"tableTemplateOverride",null),e([r()],B.prototype,"title",void 0),e([r()],B.prototype,"timeExtent",null),e([r()],B.prototype,"timeZone",null),e([r()],B.prototype,"view",null),e([r({type:_}),P(["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder","show-related-table"])],B.prototype,"viewModel",void 0),e([r()],B.prototype,"visibleColumns",null),e([r({type:M,nonNullable:!0})],B.prototype,"visibleElements",void 0),e([r({type:M})],B.prototype,"visibleElementsOverride",null),B=j=e([c("esri.widgets.FeatureTable")],B);const N=B;export{N as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{watch as i,on as l,sync as o,initial as n}from"../core/reactiveUtils.js";import{renderingSanitizer as s}from"../core/sanitizerUtils.js";import{formatFileSize as a}from"../core/unitFormatUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{isLayerFromCatalog as d}from"../layers/catalog/catalogUtils.js";import{isKnowledgeGraphLayer as h,isMapImageLayer as p,isSubtypeGroupLayer as m}from"../layers/support/layerUtils.js";import u from"../tables/AttributeTableTemplate.js";import g from"./Widget.js";import{isSupportedImage as w,getCalciteIconForAttachment as b}from"./Attachments/support/attachmentUtils.js";import{loadPromptComponents as v,Prompt as y}from"./Editor/components/Prompt.js";import f from"./FeatureTable/ColumnMenuVisibleElements.js";import _ from"./FeatureTable/FeatureTableViewModel.js";import M from"./FeatureTable/VisibleElements.js";import{isGroupColumn as C}from"./FeatureTable/support/columnUtils.js";import{loadFieldColumnComponents as A,isIFeatureTableSupportedLayer as S,isIFeatureTableSupportedLayerWithAttachments as T,getRelationshipIdsToShow as E}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as V}from"./support/componentsUtils.js";import{globalCss as I}from"./support/globalCss.js";import{getIconForLayer as R}from"./support/iconUtils.js";import{storeNode as x,discardNode as k}from"./support/widgetUtils.js";import{messageBundle as D}from"./support/decorators/messageBundle.js";import{vmEvent as P}from"./support/decorators/vmEvent.js";import{tsx as O}from"./support/jsxFactory.js";import{substitute as F}from"../intl/substitute.js";var j;const z="esri-feature-table",L=`${z}__attachments-view`,U={base:z,content:`${z}__content`,menuPopover:`${z}__menu-popover`,layerDropdownMenu:`${z}__layer-switcher-menu`,tableContainer:`${z}__table-container`,tableContainerWithAttachments:`${z}__table-container--attachments`,tableNavigation:`${z}__table-navigation`,attachmentsView:L,attachmentsViewContent:`${L}__content`,attachmentsViewDropArea:`${L}__drop-area`,attachmentsViewIcon:`${L}__icon`,attachmentsViewInformation:`${L}__information`,attachmentsViewList:`${L}__list`,attachmentsViewListFileSize:`${L}__list__filesize`,attachmentsViewListItemDelete:`${L}__list-item--delete`,attachmentsViewListThumbnail:`${L}__list__thumbnail`,expanded:`${z}__expanded`,collapsed:`${z}__collapsed`},$={chevronRight:"chevron-right",clearSelection:"clear-selection",downloadTo:"download-to",exclamationMarkTriangle:"exclamation-mark-triangle",exportToCSV:"file-csv",folderOpen:"folder-open",delete:"trash",launch:"launch",layers:"layers",moveUp:"move-up",plus:"plus",refresh:"refresh",replaceImage:"replace-image",save:"save",showAll:"selection-x",showColumn:"show-column",showSelected:"selection-filter",upload:"upload",zoomToSelection:"zoom-to-object"};let B=j=class extends g{constructor(e,t){super(e,t),this._attachmentsInput=null,this._columnVisibilityActions=new Map,this.attachmentsList=null,this.description=null,this.disabled=!1,this.menuConfig=null,this.navigationScale="m",this.title=null,this.viewModel=new _,this.visibleElements=new M,this._showDeletePrompt=this._showDeletePrompt.bind(this),this._onDeleteSelectionClick=this._onDeleteSelectionClick.bind(this)}initialize(){this.addHandles([i(()=>[this.isQueryingOrSyncing,this.editingEnabled],()=>this.scheduleRender()),i(()=>[this._effectiveVisibleElements,this._effectiveVisibleElements.columnDescriptions,this._effectiveVisibleElements.columnMenus,this._effectiveVisibleElements.columnMenuItems,this.columns.length],()=>{this.columns.forEach(e=>e.visibleElements=this._effectiveVisibleElements),this.refreshCellContent()},o),i(()=>this._effectiveVisibleElements.selectionColumn,e=>{this.grid&&(this.grid.selectionColumnEnabled=e)},n),l(()=>this.viewModel,"show-related-table",e=>this._onShowRelatedTable(e)),i(()=>this.editingEnabled,()=>{const{attachmentsViewOptions:e}=this;this.clearPrompt(),e&&(e.form?.reset(),e.candidates=null)})])}loadDependencies(){return Promise.all([V({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),alert:()=>import("@esri/calcite-components/dist/components/calcite-alert"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),pagination:()=>import("@esri/calcite-components/dist/components/calcite-pagination"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")}),v(),A()])}destroy(){this.drainRelatedTables(),this.clearPrompt()}get _effectiveDescription(){const{description:e}=this;return null!=e?s.sanitize("function"==typeof e?e():e):void 0}get _effectiveLayers(){const{layer:e,layers:t}=this,i=t?.length?t.filter(S):[],l=i.length?i:[...this._viewLayers];return e&&!l.includes(e)&&l.push(e),l}get _effectiveTitle(){const{layer:e,messages:t,state:i,highlightIds:l,title:o,size:n}=this;if(o)return s.sanitize("function"==typeof o?o():o);if(!e)return t.noLayer;switch(i){case"disabled":return t.errorLayer;case"ready":case"loading":return t.loading;case"error":return t.errorData}return F(t.header,{title:s.sanitize(e.title),count:n,selected:l.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _filteredTables(){const e=this.relatedTables.toArray(),t=1===e.length;return this.allRelatedTablesVisible?e:t?[e[0]]:this._shouldShowAttachmentsView?e.slice(-1):e.slice(-2)}get _hasAttachmentsViewError(){return null!=this.attachmentsViewOptions.error}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showExportSelectionToCSVAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnsVisibilityAction)}get _shouldShowGrid(){return this.allRelatedTablesVisible||1===this.relatedTables.length&&!this._shouldShowAttachmentsView}get _shouldShowMenu(){const{header:e,menu:t}=this._effectiveVisibleElements;return!(!e||!t||!this._hasDefaultMenuItems&&!this._hasCustomMenuItems)}get _shouldShowAttachmentsView(){return!(null==this.attachmentsViewOptions.objectId&&!this.relatedTables.some(e=>null!=e.attachmentsViewOptions.objectId))}get _showClearSelectionAction(){return!(!this.highlightIds.length||!this._effectiveVisibleElements.menuItems?.clearSelection||this.relatedTables.length||this._shouldShowAttachmentsView)}get _showColumnsVisibilityAction(){const{header:e,menu:t,menuItems:i}=this._effectiveVisibleElements;return!(!(e&&t&&i?.toggleColumns)||this.showRelatedTableCallback||this.allRelatedTablesVisible||this._shouldShowAttachmentsView)}get _showDeleteSelectionAction(){return!(!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete)||this.relatedTables.length||this._shouldShowAttachmentsView)}get _showExportSelectionToCSVAction(){return!(!(this._effectiveVisibleElements.menuItems.exportSelectionToCSV&&this.layer&&this.highlightIds.length)||this.relatedTables.length)}get _showLayerDropdown(){return!(!this._effectiveLayers.length||!this._effectiveVisibleElements.layerDropdown)}get _shouldShowNavigationBar(){const e=!!this.relatedTable||this._shouldShowAttachmentsView;return!this.tableParent&&e}get _showRefreshDataAction(){return!!this._effectiveVisibleElements.menuItems?.refreshData}get _showSelectedRecordsShowSelectedAction(){const e=this.objectIds.length,t=this.highlightIds.length;return!(!t||!this._effectiveVisibleElements.menuItems?.selectedRecordsShowSelectedToggle||e&&t===e||this.relatedTables.length||this._shouldShowAttachmentsView)}get _showSelectedRecordsShowAllAction(){return!(!this._effectiveVisibleElements.menuItems?.selectedRecordsShowAllToggle||!this.objectIds.length||this.relatedTables.length)}get _showZoomToSelectionAction(){return!(!this.view||!this.highlightIds.length||this.effectiveTable.layer?.isTable||!this._effectiveVisibleElements.menuItems?.zoomToSelection)}get _viewLayers(){const e=this.view?.map;if(!e)return[];const t=new Set,i=e=>{!S(e)||m(e)||t.has(e)||"sublayer"===e.type&&!e.capabilities?.operations?.supportsQuery||(e.load(),t.add(e))},l=e=>{d(e)||"catalog-footprint"===e.type||(h(e)?(e.load(),e.layers?.forEach(i),e.tables?.forEach(i)):p(e)?(e.loadAll(),e.allSublayers?.forEach(i),e.subtables?.forEach(i)):m(e)?(e.loadAll(),e.sublayers?.forEach(i)):i(e))};return e.allLayers.forEach(l),e.allTables.forEach(l),[...t.values()]}get grid(){return this.viewModel.grid}get actionColumn(){return this.viewModel.actionColumn}get actionColumnConfig(){return this.viewModel.actionColumnConfig}set actionColumnConfig(e){this.viewModel.actionColumnConfig=e}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get allColumns(){return this.viewModel.allColumns}get allRelatedTablesVisible(){return this.viewModel.allRelatedTablesVisible}get allVisibleColumns(){return this.viewModel.allVisibleColumns}get attachmentsColumns(){return this.viewModel.attachmentsColumns}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get attachmentsViewOptions(){return this.viewModel.attachmentsViewOptions}set attachmentsViewOptions(e){this.viewModel.attachmentsViewOptions=e}get attributeTableTemplate(){return this.viewModel.attributeTableTemplate}set attributeTableTemplate(e){this.viewModel.attributeTableTemplate=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get clearPrompt(){return this.viewModel.clearPrompt}set clearPrompt(e){this.viewModel.clearPrompt=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get definitionExpression(){return this.viewModel.definitionExpression}set definitionExpression(e){this.viewModel.definitionExpression=e}set container(e){super.container=e}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get effectiveSize(){return this.viewModel.effectiveSize}get effectiveTable(){return this.relatedTable||this}get fieldColumns(){return this.viewModel.fieldColumns}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get filterBySelectionEnabled(){return this.viewModel.filterBySelectionEnabled}set filterBySelectionEnabled(e){this.viewModel.filterBySelectionEnabled=e}get groupColumns(){return this.viewModel.groupColumns}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get icon(){return"table"}set icon(e){this._overrideIfSome("icon",e)}get initialSize(){return this.viewModel.initialSize}set initialSize(e){this.viewModel.initialSize=e}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing}get isSyncingAttachments(){return this.viewModel.isSyncingAttachments}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get layers(){return this.viewModel.layers}set layers(e){this.viewModel.layers=e}get layerView(){return this.viewModel.layerView}get maxSize(){return this.viewModel.maxSize}set maxSize(e){this.viewModel.maxSize=e}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesUnits(){return this.viewModel.messagesUnits}set messagesUnits(e){this.viewModel.messagesUnits=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=e}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get multipleSortPriority(){return this.viewModel.multipleSortPriority}set multipleSortPriority(e){this.viewModel.multipleSortPriority=e}get noDataMessage(){return this.viewModel.noDataMessage}set noDataMessage(e){this.viewModel.noDataMessage=e}get objectIds(){return this.viewModel.objectIds}set objectIds(e){this.viewModel.objectIds=e}get outFields(){return this.viewModel.outFields}set outFields(e){this.viewModel.outFields=e}get pageCount(){return this.viewModel.pageCount}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get prompt(){return this.viewModel.prompt}set prompt(e){this.viewModel.prompt=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.viewModel.relatedTable}get relatedTables(){return this.viewModel.relatedTables}set relatedTables(e){this.viewModel.relatedTables=e}get relationship(){return this.viewModel.relationship}get relationshipColumnConfigs(){return this.viewModel.relationshipColumnConfigs}set relationshipColumnConfigs(e){this.viewModel.relationshipColumnConfigs=e}get relationshipColumns(){return this.viewModel.relationshipColumns}get relationshipConfig(){return this.viewModel.relationshipConfig}set relationshipConfig(e){this.viewModel.relationshipConfig=e}get relationshipInfos(){return this.viewModel.relationshipInfos}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}get returnMEnabled(){return this.viewModel.returnMEnabled}set returnMEnabled(e){this.viewModel.returnMEnabled=e}get returnZEnabled(){return this.viewModel.returnZEnabled}set returnZEnabled(e){this.viewModel.returnZEnabled=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get selectionSource(){return this.viewModel.selectionSource}set selectionSource(e){this.viewModel.selectionSource=e}get showAllRelatedTables(){return this.viewModel.showAllRelatedTables}set showAllRelatedTables(e){this.viewModel.showAllRelatedTables=e}get showPrompt(){return this.viewModel.showPrompt}set showPrompt(e){this.viewModel.showPrompt=e}get showRelatedTableCallback(){return this.viewModel.showRelatedTableCallback}set showRelatedTableCallback(e){this.viewModel.showRelatedTableCallback=e}get size(){return this.viewModel.size}get state(){return this.viewModel.state}get supportsAddAttachments(){return this.viewModel.supportsAddAttachments}get supportsAttachments(){return this.viewModel.supportsAttachments}get supportsDeleteAttachments(){return this.viewModel.supportsDeleteAttachments}get supportsResizeAttachments(){return this.viewModel.supportsResizeAttachments}get supportsUpdateAttachments(){return this.viewModel.supportsUpdateAttachments}get syncTemplateOnChangesEnabled(){return this.viewModel.syncTemplateOnChangesEnabled}set syncTemplateOnChangesEnabled(e){this.viewModel.syncTemplateOnChangesEnabled=e}get tableController(){return this.viewModel.tableController}set tableController(e){this.viewModel.tableController=e}get tableParent(){return this.viewModel.tableParent}set tableParent(e){this.viewModel.tableParent=e}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get tableTemplateOverride(){return this.viewModel.tableTemplateOverride}set tableTemplateOverride(e){this.viewModel.tableTemplateOverride=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visibleColumns(){return this.viewModel.visibleColumns}get visibleElementsOverride(){const{attachmentsViewOptions:e,relatedTable:t,tableController:i,visibleElements:l}=this,{columnDescriptions:o,columnMenus:n,tooltips:s}=l,a=null!=e.objectId;if(t)return new M({columnDescriptions:o,columnMenus:n,tooltips:s,close:l.close,header:l.header,layerDropdown:l.layerDropdown,layerDropdownIcons:l.layerDropdownIcons,menu:l.menu,menuItems:l.menuItems,progress:l.progress,selectionColumn:!1,columnMenuItems:new f({sortAscending:!1,sortDescending:!1})});if(i){const e=i.relatedTable===this,t=i.allRelatedTablesVisible,r=e&&l.selectionColumn&&!t&&!a,c=e&&!t&&!a;return new M({columnDescriptions:o,columnMenus:n,tooltips:s,selectionColumn:r,close:!1,header:!1,layerDropdown:!1,menu:!1,progress:!1,columnMenuItems:new f({sortAscending:c,sortDescending:c})})}return a?new M({columnDescriptions:o,columnMenus:n,tooltips:s,close:l.close,header:l.header,layerDropdown:l.layerDropdown,layerDropdownIcons:l.layerDropdownIcons,menu:l.menu,menuItems:l.menuItems,progress:l.progress,selectionColumn:!1,columnMenuItems:new f({sortAscending:!1,sortDescending:!1})}):null}clearSelectionFilter(){this.viewModel.clearSelectionFilter()}async deleteAttachments(e,t,i){null!=e&&t?.length&&(i?this._showDeleteAttachmentPrompt(e,t):await this.viewModel.deleteAttachments(e,t))}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}async downloadAttachmentById(e,t){return this.viewModel.downloadAttachmentById(e,t)}drainRelatedTables(){this.viewModel.drainRelatedTables()}exportSelectionToCSV(e){return this.viewModel.exportSelectionToCSV(e)}filterBySelection(){this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}goToPage(e){this.viewModel.goToPage(e)}hideColumn(e){this.grid?.hideColumn(e)}nextPage(){this.viewModel.nextPage()}previousPage(){this.viewModel.previousPage()}async refresh(){await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}async saveAttachmentsViewForm(){await this.viewModel.saveAttachmentsViewForm()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollLeft(){this.viewModel.scrollLeft()}scrollToBottom(){this.viewModel.scrollToBottom()}scrollToIndex(e){this.viewModel.scrollToIndex(e)}scrollToRow(e){this.viewModel.scrollToRow(e)}scrollToTop(){this.viewModel.scrollToTop()}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}zoomToSelection(){this.effectiveTable.viewModel.zoomToSelection()}render(){const{_effectiveVisibleElements:e,isQueryingOrSyncing:t,menuConfig:i,state:l}=this;return O("div",{bind:this,class:this.classes(U.base,I.widget)},O("calcite-panel",{bind:this,class:U.content,closable:e.close,description:this._effectiveDescription,disabled:this.disabled||"disabled"===l&&!this._effectiveLayers?.length,heading:e.header?this._effectiveTitle:void 0,loading:"loading"===l,menuOpen:!!i?.open,overlayPositioning:"fixed",onCalcitePanelClose:e=>{e.currentTarget.closed=!1,this.emit("close")}},e.progress?O("calcite-progress",{type:t?"indeterminate":"determinate"}):null,this._showLayerDropdown?this._renderLayerDropdown():null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderNavigationBar(),this._renderTables(),this._renderError()),this._renderColumnVisibilityPopover(),this._renderPrompt())}_renderTables(){const{grid:e,relatedTables:t}=this,i=this.classes(U.tableContainer);if(t.length){const l=this.classes(U.base,this.allRelatedTablesVisible?U.expanded:U.collapsed,this._shouldShowAttachmentsView?U.tableContainerWithAttachments:void 0);return O("div",{class:i},O("calcite-panel",{overlayPositioning:"fixed"},O("div",null,[this._shouldShowGrid?O("div",{class:l},e?.render(),this._renderPagination()):void 0,...this._filteredTables.map(e=>{const i=t.indexOf(e);return O("div",{class:l,key:`related-${i}`},e.render())}),,])))}return null!=this.attachmentsViewOptions.objectId?O("div",{class:i},O("calcite-panel",{overlayPositioning:"fixed"},O("div",null,[O("div",{class:this.classes(U.base,U.collapsed)},e?.render(),this._renderPagination()),this._renderAttachmentsView()]))):[O("div",{class:i},e?.render()),this._renderPagination()]}_renderPagination(){if(this.paginationEnabled)return O("calcite-pagination",{pageSize:1,startItem:this.pageIndex+1,totalItems:this.pageCount,onCalcitePaginationChange:e=>this.goToPage(e.currentTarget.startItem-1)})}_renderError(){const{messages:e}=this;return O("calcite-alert",{autoClose:!0,autoCloseDuration:"fast",icon:$.exclamationMarkTriangle,kind:"danger",label:e.errorOccured,open:this._hasAttachmentsViewError,slot:"alerts",onCalciteAlertClose:()=>{this.attachmentsViewOptions.error=null}},O("span",{slot:"message"},e.errorOccured))}_renderPrompt(){return this.prompt?O(y,{...this.prompt,headingLevel:2}):void 0}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=F(e.deleteSelectionCount,{count:this.highlightIds.length});this.showPrompt({title:i,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this.clearPrompt()}}})}_showDeleteAttachmentPrompt(e,t){const{messages:i,messagesCommon:l}=this,o=F(i.deleteAttachmentCount,{count:t.length});this.showPrompt({title:o,message:i.deleteAttachmentConfirmation,context:"danger",actions:{primary:{label:l.delete,action:async()=>{try{await this.deleteAttachments(e,t,!1)}finally{this.clearPrompt()}}},secondary:{label:l.cancel,action:()=>this.clearPrompt()}}})}async _onDeleteSelectionClick(){try{await this.viewModel.deleteSelection()}finally{this.clearPrompt()}}_renderHeaderMenuAction(e){const{disabled:t,hidden:i,icon:l,text:o,clickFunction:n}=e;if(!i)return O("calcite-action",{disabled:t??this.menuConfig?.disabled,icon:l??void 0,key:o,onclick:()=>n(),slot:"header-menu-actions",text:o,textEnabled:!0,title:o})}_renderHeaderMenuActions(){return this._shouldShowMenu?[this._renderDefaultHeaderMenuActions(),this._renderCustomHeaderMenuActions()]:[]}_renderDefaultHeaderMenuActions(){if(!this._hasDefaultMenuItems)return[];const{messages:e}=this;return[this._showRefreshDataAction&&{icon:$.refresh,text:e.refreshData,clickFunction:()=>this.refresh()},this._showDeleteSelectionAction&&{icon:$.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)},this._showClearSelectionAction&&{icon:$.clearSelection,text:e.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()},this._showZoomToSelectionAction&&{icon:$.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()},this._showSelectedRecordsShowSelectedAction&&{icon:$.showSelected,text:e.showSelected,clickFunction:()=>{const{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}},this._showSelectedRecordsShowAllAction&&{icon:$.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()},this._showExportSelectionToCSVAction&&{icon:$.exportToCSV,text:e.exportSelectionCSV,clickFunction:()=>this.exportSelectionToCSV()}].filter(t).map(e=>e&&this._renderHeaderMenuAction(e))}_renderCustomHeaderMenuActions(){return this.menuConfig?.items?.map(({disabled:e,hidden:t,icon:i,label:l,clickFunction:o})=>this._renderHeaderMenuAction({hidden:"function"==typeof t?t():t,icon:i,text:l,disabled:e,clickFunction:e=>o(e)}))??[]}_renderColumnVisibilityAction(){if(!this._showColumnsVisibilityAction)return[];const{_columnVisibilityActions:e,effectiveTable:t,id:i}=this,l=this.messages.toggleColumns;return O("calcite-action",{afterCreate:t=>e.set(i,t),afterRemoved:()=>e.delete(i),appearance:"transparent",bind:this,disabled:t.menuConfig?.disabled,icon:$.showColumn,id:`${i}__toggle-columns-action`,slot:"header-actions-end",text:l},this._effectiveVisibleElements.tooltips?O("calcite-tooltip",{closeOnClick:!0,overlayPositioning:"fixed",placement:"bottom-end",slot:"tooltip"},l):null)}_renderColumnVisibilityPopover(){if(!this._showColumnsVisibilityAction||this.effectiveTable.menuConfig?.disabled)return;const{effectiveTable:e}=this,t=this.messages.toggleColumns;return O("calcite-popover",{autoClose:!0,class:U.menuPopover,label:t,overlayPositioning:"fixed",placement:"top-end",pointerDisabled:!0,referenceElement:this._columnVisibilityActions.get(this.id)},O("calcite-list",{displayMode:"nested",filterEnabled:!0,filterPlaceholder:t,label:t,selectionMode:"multiple"},e.columns.toArray().map(t=>{const i=C(t)?t.columns?.map(t=>this._renderColumnListItem({column:t,table:e,ignoreSelect:!0})):void 0;return this._renderColumnListItem({column:t,table:e,items:i})})))}_renderColumnListItem(e){const{column:t,table:i,items:l,ignoreSelect:o}=e,{effectiveLabel:n,fieldName:s,hidden:a}=t;return O("calcite-list-item",{expanded:!(!l?.length||a)||void 0,key:`toggle-columns__item-${s}`,label:n,selected:!a,value:s,onCalciteListItemSelect:e=>{o&&e.stopPropagation(),i.toggleColumnVisibility(e.currentTarget.value)}},l)}_renderLayerDropdown(){const e=this.messages.selectALayer;return O("div",{class:U.layerDropdownMenu,key:`${this.id}-layerDropdown`,slot:"header-actions-start"},O("calcite-dropdown",{bind:this,maxItems:5,overlayPositioning:"fixed",placement:"bottom-start"},O("calcite-action",{icon:$.layers,slot:"trigger",text:e,title:e}),O("calcite-dropdown-group",{selectionMode:"single"},this._effectiveLayers.map((e,t)=>this._renderLayerDropdownItem(e,t))??null)))}_renderLayerDropdownItem(e,t){const i=this.visibleElements.layerDropdownIcons;return O("calcite-dropdown-item",{iconStart:i?R(e):void 0,key:`dropdown-item-${t}`,label:e.title??"",selected:e===this.layer,value:e.id,onCalciteDropdownItemSelect:()=>{this.layer=e}},e.title)}_onRelatedNavigationItemClick(e){this.viewModel.drainRelatedTablesAboveIndex(e)}_collapseRelatedTable(e){this.viewModel.collapseRelatedTable(this.effectiveTable,e)}_onShowRelatedTable(e){this.showRelatedTableCallback||(this._collapseRelatedTable(e),this._createRelatedTable(e))}async _createRelatedTable(e){const{editingEnabled:t,effectiveTable:i,paginationEnabled:l,pageSize:o,view:n,viewModel:s}=this,{layer:a,objectId:r,relatedLayer:c,relationshipId:d}=e;await a.load();const h=this.attachmentsEnabled&&T(a),p=new j({layer:a,attachmentsEnabled:h,editingEnabled:t,paginationEnabled:l,pageSize:o,relatedRecordsEnabled:!0,relationshipConfig:{objectId:r,relatedLayer:c,relationshipId:d},relationshipColumnConfigs:E(a,d),tableController:this,tableParent:i,view:n,showRelatedTableCallback:e=>s.emit("show-related-table",e)});this.relatedTables.add(p),this.scheduleRender()}_renderAttachmentsView(){const{attachmentInfos:e,mode:t,objectId:i}=this.attachmentsViewOptions;return"file"!==t&&e.length&&null!=i?this._renderAttachmentsViewList():this._renderAttachmentsViewFilePane()}_renderAttachmentsViewFilePane(){const{attachmentsViewOptions:e,isSyncingAttachments:t,supportsAddAttachments:i,messages:l,messagesUnits:o}=this,{attachmentId:n,attachmentInfos:s,candidates:r,objectId:c}=e,d=s.find(e=>e.id===n),h=s.length,p=r?.length,m=d?O("calcite-label",{alignment:"center",key:"replace-file-node",scale:"l"},l.replaceFile):void 0,u=p?void 0:O("calcite-label",{alignment:"center",key:"message-node",scale:"m"},i?null==c?l.noFeature:l.dragAndDropToUpload:l.editingRestricted),g=Array.from(r??[]).pop(),w=g?O("calcite-label",{key:"filename-node"},g.name):void 0,b=i&&null!=c,v=b&&p,y=O("input",{afterCreate:x,afterRemoved:k,afterUpdate:x,bind:this,"data-node-ref":"_attachmentsInput",files:r,hidden:!0,name:"attachment",onchange:e=>this._onAttachmentsViewCandidateChange(e),type:"file"}),f=b?O("calcite-button",{appearance:"outline-fill",bind:this,disabled:t,iconStart:$.folderOpen,key:"select-node",loading:!1,onclick:()=>{this._attachmentsInput&&(this._attachmentsInput.value="",this._attachmentsInput.click())},width:"full"},l.selectFile):void 0,_=v?O("calcite-button",{appearance:"outline-fill",bind:this,disabled:t,iconStart:$.save,key:"save-node",loading:t,onclick:()=>{this.saveAttachmentsViewForm()},width:"full"},d?l.updateAttachment:l.addAttachment):void 0,M=h||p?O("calcite-button",{appearance:"transparent",bind:this,disabled:t,key:"cancel-node",onclick:()=>{this._attachmentsInput&&(this._attachmentsInput.value=""),e.reset(),e.attachmentInfos?.length&&(e.mode="list")},width:"full"},this.messagesCommon.cancel):void 0;return[O("div",{class:U.attachmentsView,key:"attachments-view"},O("div",{class:U.attachmentsViewContent,key:"attachments-view-content"},O("div",{bind:this,class:U.attachmentsViewDropArea,ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop},O("calcite-icon",{class:U.attachmentsViewIcon,icon:$.upload,scale:"l"}),m,u,O("form",{afterCreate:t=>e.form=t,afterRemoved:()=>e.form=null,bind:this,key:"attachments-form"},O("fieldset",null,w,y,f,_,M)))),null!=c&&null!=d?O("div",{class:U.attachmentsViewInformation,key:"information"},this._renderAttachmentsViewThumbnail(d,200),O("label",{key:"file-label"},l.fileName),O("span",{key:"file-span"},d.name),O("label",{key:"size-label"},l.size),O("span",{key:"size-span"},a(o,d.size??0))):void 0)]}_renderAttachmentsViewList(){const{attachmentsViewOptions:e,isSyncingAttachments:t,messages:i,messagesUnits:l,supportsDeleteAttachments:o,supportsUpdateAttachments:n}=this,{attachmentInfos:s,objectId:r}=e;return O("calcite-list",{afterCreate:x,afterRemoved:k,afterUpdate:x,bind:this,class:U.attachmentsViewList,"data-node-ref":"attachmentsList",key:`attachments-list-${r}`,label:i?.attachments,loading:t,ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop,selectionMode:"multiple",onCalciteListChange:()=>this.scheduleRender()},...s?.map(t=>{const{id:s,name:c,size:d,url:h}=t,p=a(l,d??0);return O("calcite-list-item",{afterRemoved:()=>this.scheduleRender(),key:`attachment-${s}`,label:c,value:s},this._renderAttachmentsViewListThumbnail(t),O("span",{class:U.attachmentsViewListFileSize,slot:"actions-end",title:p},p),O("calcite-action",{appearance:"transparent",icon:$.downloadTo,key:`download-attachment-${s}`,label:`${c}`,onclick:e=>{e.preventDefault(),this.downloadAttachmentById(r??-1,s)},slot:"actions-end",text:i.downloadAttachment,title:i.downloadAttachment}),n&&null!=r?O("calcite-action",{appearance:"transparent",disabled:!n,icon:$.replaceImage,key:`replace-attachment-${s}`,label:`${c}`,onclick:()=>{e.mode="file",e.attachmentId=s},slot:"actions-end",text:i.updateAttachment,title:i.updateAttachment}):void 0,O("calcite-action",{appearance:"transparent",icon:$.launch,key:`launch-attachment-${s}`,label:`${c}`,onclick:()=>{h&&window.open(h,"_blank")},slot:"actions-end",text:i.viewAttachment,title:i.viewAttachment}),o&&null!=r?O("calcite-action",{appearance:"transparent",class:U.attachmentsViewListItemDelete,disabled:!o,icon:$.delete,key:`delete-attachment-${s}`,label:`${c}`,onclick:()=>{this.deleteAttachments(r,[s],!0)},slot:"actions-end",text:i.deleteAttachment,title:i.deleteAttachment}):void 0)}))}_renderAttachmentsViewListThumbnail(e){return O("div",{class:U.attachmentsViewListThumbnail,slot:"content-start"},O("a",{href:e.url??"",rel:"noreferrer",target:"_blank"},this._renderAttachmentsViewThumbnail(e)))}_renderAttachmentsViewThumbnail(e,t=64){const{contentType:i,name:l,size:o,url:n}=e,s=`${n}${n?.includes("?")?"&":"?"}w=${t}&s=${o}`;return this.supportsResizeAttachments&&w(i)?O("img",{alt:l,key:`thumbnail-image-${l}`,src:s,title:l}):O("calcite-icon",{icon:b(i),key:`thumbnail-icon-${l}`,scale:"l",textLabel:l,title:l})}_onAttachmentsViewCandidateChange({target:e}){this.attachmentsViewOptions.candidates=e?.files}_onAttachmentsViewDrop(e){e.preventDefault(),(this.supportsAddAttachments||this.supportsUpdateAttachments)&&this.attachmentsViewOptions.set({mode:"file",candidates:e.dataTransfer?.files})}_renderNavigationBar(){const{effectiveTable:e,messages:t,messagesCommon:i,navigationScale:l,relatedTable:o,relatedTables:n}=this;if(!this._shouldShowNavigationBar)return;const{attachmentsList:s,attachmentsViewOptions:a,layer:r,supportsAddAttachments:c,supportsDeleteAttachments:d}=e;if(!r)return;const{attachmentInfos:h,objectId:p}=a,m=null!=p,u=h.length,g=s?.selectedItems?.length??0,w=`${r.objectIdField}: ${p}`,b=F(t.selectedCount,{count:g}),v=F(t.attachmentsCount,{count:u}),y=m?O("calcite-action",{bind:this,icon:$.chevronRight,iconFlipRtl:!0,key:"navigation-feature",onclick:()=>e.scrollToRow(p),scale:l,text:w,textEnabled:!0,title:w}):void 0,f=m?O("calcite-action",{icon:$.chevronRight,iconFlipRtl:!0,key:"navigation-attachments-label",label:v,onclick:()=>{u>0&&(a.mode="list")},scale:l,text:v,textEnabled:!0,title:v}):void 0,_=m?O("calcite-chip",{closable:!0,closed:0===g,key:"navigation-chip",kind:"inverse",label:b,scale:l,selected:!0,title:b,value:"selected",onCalciteChipClose:()=>s?.selectedItems?.forEach(e=>e.selected=!1)},b):void 0,M=o?O("calcite-label",{layout:"inline",scale:l},t.showAllTables,O("calcite-switch",{checked:this.allRelatedTablesVisible,scale:l,onCalciteSwitchChange:e=>this.showAllRelatedTables=!!e.currentTarget.checked})):void 0,C=m&&"list"===a.mode&&null!=p&&g&&d?O("calcite-action",{icon:$.delete,iconFlipRtl:!0,key:"attachments-trash-all",onclick:()=>{e.deleteAttachments(p,s?.selectedItems?.map(e=>e.value)??[],!0)},scale:l,text:i.delete,textEnabled:!0,title:F(t.deleteAttachmentCount,{count:g})}):void 0,A=m&&"list"===a.mode&&c?O("calcite-action",{bind:this,icon:$.plus,iconFlipRtl:!0,key:"attachments-add",onclick:()=>{a.attachmentId=null,a.mode="file"},scale:l,text:t.addAttachment,textEnabled:!0,title:t.addAttachment}):void 0;return O("div",{class:U.tableNavigation,key:"table-nav"},O("calcite-action",{icon:$.moveUp,iconFlipRtl:!0,key:"go-back",onclick:()=>{o&&this.drainRelatedTables(),e.attachmentsViewOptions.objectId=null},scale:l,text:this.layer?.title??"",textEnabled:!1,title:o?t.exitRelatedRecords:t.exitAttachments}),n.toArray().map((e,t)=>this._renderRelatedTableNavigationAction(e,t)),y,f,O("div",null,_,M,C,A))}_renderRelatedTableNavigationAction(e,t){const i=this._getLabelForRelatedTableNavigationAction(e);return O("calcite-action",{icon:$.chevronRight,iconFlipRtl:!0,key:t,onclick:()=>this._onRelatedNavigationItemClick(t),scale:this.navigationScale,text:i,textEnabled:!0,title:e.layer?.title||""})}_getLabelForRelatedTableNavigationAction(e){const t=e.layer?.title;if(!t)return"";const{relatedTables:i}=this;if(i.length<=1)return t;return i.indexOf(e)!==i.length-1&&t.length>20?`${t.slice(0,20)}...`:t}};e([r()],B.prototype,"_attachmentsInput",void 0),e([r()],B.prototype,"_columnVisibilityActions",void 0),e([r()],B.prototype,"_effectiveDescription",null),e([r()],B.prototype,"_effectiveLayers",null),e([r()],B.prototype,"_effectiveTitle",null),e([r()],B.prototype,"_effectiveVisibleElements",null),e([r()],B.prototype,"_filteredTables",null),e([r()],B.prototype,"_hasAttachmentsViewError",null),e([r()],B.prototype,"_hasCustomMenuItems",null),e([r()],B.prototype,"_hasDefaultMenuItems",null),e([r()],B.prototype,"_shouldShowGrid",null),e([r()],B.prototype,"_shouldShowMenu",null),e([r()],B.prototype,"_shouldShowAttachmentsView",null),e([r()],B.prototype,"_showClearSelectionAction",null),e([r()],B.prototype,"_showColumnsVisibilityAction",null),e([r()],B.prototype,"_showDeleteSelectionAction",null),e([r()],B.prototype,"_showExportSelectionToCSVAction",null),e([r()],B.prototype,"_showLayerDropdown",null),e([r()],B.prototype,"_shouldShowNavigationBar",null),e([r()],B.prototype,"_showRefreshDataAction",null),e([r()],B.prototype,"_showSelectedRecordsShowSelectedAction",null),e([r()],B.prototype,"_showSelectedRecordsShowAllAction",null),e([r()],B.prototype,"_showZoomToSelectionAction",null),e([r()],B.prototype,"_viewLayers",null),e([r()],B.prototype,"attachmentsList",void 0),e([r({readOnly:!0})],B.prototype,"grid",null),e([r()],B.prototype,"actionColumn",null),e([r()],B.prototype,"actionColumnConfig",null),e([r({readOnly:!0})],B.prototype,"activeFilters",null),e([r({readOnly:!0})],B.prototype,"activeSortOrders",null),e([r()],B.prototype,"allColumns",null),e([r({readOnly:!0})],B.prototype,"allRelatedTablesVisible",null),e([r()],B.prototype,"allVisibleColumns",null),e([r()],B.prototype,"attachmentsColumns",null),e([r()],B.prototype,"attachmentsEnabled",null),e([r()],B.prototype,"attachmentsViewOptions",null),e([r({type:u})],B.prototype,"attributeTableTemplate",null),e([r()],B.prototype,"autoRefreshEnabled",null),e([r()],B.prototype,"clearPrompt",null),e([r()],B.prototype,"columnPerformanceModeEnabled",null),e([r()],B.prototype,"columnReorderingEnabled",null),e([r({readOnly:!0})],B.prototype,"columns",null),e([r()],B.prototype,"definitionExpression",null),e([r()],B.prototype,"description",void 0),e([r()],B.prototype,"disabled",void 0),e([r()],B.prototype,"editingEnabled",null),e([r()],B.prototype,"effectiveSize",null),e([r()],B.prototype,"effectiveTable",null),e([r()],B.prototype,"fieldColumns",null),e([r()],B.prototype,"filterGeometry",null),e([r()],B.prototype,"filterBySelectionEnabled",null),e([r()],B.prototype,"groupColumns",null),e([r()],B.prototype,"hiddenFields",null),e([r()],B.prototype,"highlightEnabled",null),e([r()],B.prototype,"highlightIds",null),e([r()],B.prototype,"icon",null),e([r()],B.prototype,"initialSize",null),e([r()],B.prototype,"isQueryingOrSyncing",null),e([r()],B.prototype,"isSyncingAttachments",null),e([r()],B.prototype,"label",null),e([r()],B.prototype,"layer",null),e([r()],B.prototype,"layers",null),e([r()],B.prototype,"layerView",null),e([r()],B.prototype,"maxSize",null),e([r(),D("esri/widgets/FeatureTable/t9n/FeatureTable")],B.prototype,"messages",null),e([r(),D("esri/t9n/common")],B.prototype,"messagesCommon",null),e([r(),D("esri/core/t9n/Units")],B.prototype,"messagesUnits",null),e([r(),D("esri/widgets/support/t9n/uriUtils")],B.prototype,"messagesURIUtils",null),e([r()],B.prototype,"menuConfig",void 0),e([r()],B.prototype,"multipleSelectionEnabled",null),e([r()],B.prototype,"multiSortEnabled",null),e([r()],B.prototype,"multipleSortPriority",null),e([r()],B.prototype,"navigationScale",void 0),e([r()],B.prototype,"noDataMessage",null),e([r()],B.prototype,"objectIds",null),e([r()],B.prototype,"outFields",null),e([r()],B.prototype,"pageCount",null),e([r()],B.prototype,"pageIndex",null),e([r()],B.prototype,"pageSize",null),e([r()],B.prototype,"paginationEnabled",null),e([r()],B.prototype,"prompt",null),e([r()],B.prototype,"relatedRecordsEnabled",null),e([r()],B.prototype,"relatedTable",null),e([r()],B.prototype,"relatedTables",null),e([r()],B.prototype,"relationship",null),e([r()],B.prototype,"relationshipColumnConfigs",null),e([r()],B.prototype,"relationshipColumns",null),e([r()],B.prototype,"relationshipConfig",null),e([r()],B.prototype,"relationshipInfos",null),e([r()],B.prototype,"returnGeometryEnabled",null),e([r()],B.prototype,"returnMEnabled",null),e([r()],B.prototype,"returnZEnabled",null),e([r()],B.prototype,"rowHighlightIds",null),e([r()],B.prototype,"selectionSource",null),e([r()],B.prototype,"showAllRelatedTables",null),e([r()],B.prototype,"showPrompt",null),e([r()],B.prototype,"showRelatedTableCallback",null),e([r()],B.prototype,"size",null),e([r({readOnly:!0})],B.prototype,"state",null),e([r()],B.prototype,"supportsAddAttachments",null),e([r()],B.prototype,"supportsAttachments",null),e([r()],B.prototype,"supportsDeleteAttachments",null),e([r()],B.prototype,"supportsResizeAttachments",null),e([r()],B.prototype,"supportsUpdateAttachments",null),e([r()],B.prototype,"syncTemplateOnChangesEnabled",null),e([r({constructOnly:!0})],B.prototype,"tableController",null),e([r({constructOnly:!0})],B.prototype,"tableParent",null),e([r()],B.prototype,"tableTemplate",null),e([r()],B.prototype,"tableTemplateOverride",null),e([r()],B.prototype,"title",void 0),e([r()],B.prototype,"timeExtent",null),e([r()],B.prototype,"timeZone",null),e([r()],B.prototype,"view",null),e([r({type:_}),P(["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder","show-related-table"])],B.prototype,"viewModel",void 0),e([r()],B.prototype,"visibleColumns",null),e([r({type:M,nonNullable:!0})],B.prototype,"visibleElements",void 0),e([r({type:M})],B.prototype,"visibleElementsOverride",null),B=j=e([c("esri.widgets.FeatureTable")],B);const N=B;export{N 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as u,sync as h}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../geometry/Point.js";import{project as g,initializeProjection as f}from"../../geometry/projectionUtils.js";import m from"../../geometry/SpatialReference.js";import{getPointFromGeometry as y}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as w}from"../../geometry/support/webMercatorUtils.js";import{fallbackObjectIDAttribute as F}from"../../layers/LayerConstants.js";import v from"../../symbols/SimpleFillSymbol.js";import{getDisplayedSymbol as _}from"../../symbols/support/symbolUtils.js";import{system as b}from"../../time/constants.js";import{highlightsSupported as C}from"../../views/support/layerViewUtils.js";import P from"../Feature/FeatureViewModel.js";import{ActionsCollection as M,zoomToClusteredFeatures as E,browseClusteredFeatures as V,zoomToFeature as j}from"../Popup/actions.js";import{triggerAction as L,isClusterFeature as A,getSelectedTarget as I,removeClusteredFeaturesForBrowsing as R,displayClusterExtent as x,browseAggregateFeatures as O}from"../Popup/actionUtils.js";import T from"../support/AnchorElementViewModel.js";import{GoTo as S}from"../support/GoTo.js";const B="location-scale-handle",H=()=>[j.clone()],U=()=>[E.clone(),V.clone()];let G=null;function Z(e,t){return"building-scene"===e||"map-image"===e||"tile"===e||"imagery"===e||"2d"===t&&"imagery-tile"===e}let z=class extends(S(T)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._selectedClusterFeature=null,this.actions=new M,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.initialDisplayMode="feature",this.selectedClusterBoundaryFeature=new t({symbol:new v({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=o(async e=>{const{spatialReference:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if(i&&"mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const e=this.selectedFeature;let i=e.geometry;const r=this._getHighlightLayer(e),o=e.getObjectId();if(!r||!this.view)return;if(o){const e=this.view?.allLayerViews.find(e=>e.layer.uid===r.uid);if(!e||!("queryFeatures"in e))return;const s=e.createQuery();s.outSpatialReference=t,s.objectIds=[o],s.returnGeometry=!0;const{features:a}=await e.queryFeatures(s);i=a[0]?.geometry}if(!i||"mesh"===i.type)return;i=g(i,t),G||(G=await Promise.all([await import("../../geometry/operators/intersectsOperator.js"),await import("../../geometry/operators/proximityOperator.js")]));const[a,n]=G;if(!a.execute(i,s)){const t=n.getNearestCoordinate(i,s).coordinate??s;this.selectedFeature===e&&(this.location=t)}}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=y(this.selectedFeature.geometry)??s})}initialize(){this.addHandles([this.on("view-change",()=>this._autoClose()),l(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),l(()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),l(()=>this.view?.animation?.state,e=>this._animationStateChange(e)),l(()=>this.location,e=>this._locationChange(e)),l(()=>this.selectedFeature,e=>this._selectedFeatureChange(e)),l(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),l(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),l(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on("trigger-action",e=>L({event:e,viewModel:this,view:this.view})),u(()=>!this.waitingForResult,()=>this._waitingForResultChange(),h),l(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),l(()=>this.view?.scale,()=>this._viewScaleChange()),u(()=>!this.visible,()=>this.browseClusterEnabled=!1),l(()=>this.browseClusterEnabled,e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new M;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach(t=>e.add(t)),e}get defaultActions(){const e=this._get("defaultActions")||new M;return e.removeAll(),e.addMany(A(this.selectedFeature)?U():H()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;"list"!==this.initialDisplayMode?o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1):(!o||o&&i===s)&&(this.selectedFeatureIndex=-1)}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=w(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice()).forEach(e=>this._pendingPromises.add(e)),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())):this._set("promises",[])}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??b}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some(e=>e.waitingForContent)}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=I(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount),this}previous(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount),this}disableClusterBrowsing(){R(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?A(t)?(await x(this),await O(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}handleViewClick(e){this._fetchFeaturesAndOpen(e)}_getRoundRobinIndex(e,t){return(e+t)%t}_animationStateChange(e){this.zoomToLocation||(j.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(A(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:s}=this;s&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null==i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach((t,i)=>{t&&(t.graphic??=e[o+i])})}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(!e||!s)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),A(e))return;return e.symbol=await _(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}const r=e.sourceLayer?.type;if("map-image"!==r&&"imagery"!==r&&"imagery-tile"!==r||(e.symbol=await _(e)),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=y(e.geometry)}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s,spatialReference:r,map:o,timeZone:a,location:n}=this;if(A(t[0])||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(),u=[];t.forEach((t,i)=>{if(!t)return;let h=null;if(l.some((e,i)=>(e&&e.graphic===t&&(h=e,l.splice(i,1)),!!h)),h)u[i]=h;else{const l=new P({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:r,graphic:t===e?t:null,location:n,map:o,view:s,timeZone:a});u[i]=l}}),l.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:s}=this;if(!s)return null;await(s?.when());const r=e?.spatialReference;return r&&i?(await f(r,i,null,t),s.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch(()=>{}).then(()=>{this._fetchFeaturesController=null}),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e,{view:s}=this;this.removeHandles(B),this.addHandles([l(()=>this.view?.scale,()=>this._debouncedLocationUpdate(t).catch(e=>{a(e)||r.getLogger(this).error(e)})),u(()=>!this.visible,()=>{this.removeHandles(B)},{once:!0})],B);const{pendingFeatures:o}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:o})}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t??i}_getHighlightLayerView(e,t){return"subtype-sublayer"===t.type&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,i){if(Z(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||F:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);const i=this[t];if(!i)return;const{highlightEnabled:s,view:r,visible:o}=this;if(!r||!s||!o)return;const a=this._getHighlightLayer(i);if(!a)return;const n=this._getHighlightLayerView(r,a);if(!n)return;this._highlightPromises[e]=n;const l=await n;if(!(l&&C(l)&&this._highlightPromises[e]===n&&this[t]&&this.highlightEnabled))return;const u=l.highlight(this._getHighlightTarget(i,a,r.type));this.addHandles(u,e)}async _highlightActiveFeature(){return this._highlightFeature("highlight-active-feature","activeFeature")}async _highlightSelectedFeature(){return this._highlightFeature("highlight-selected-feature","selectedFeature")}_updateFeatures(e){const{features:t}=this,i=e.filter(e=>!t.includes(e));i?.length&&(this.features=t.concat(i))}};e([c()],z.prototype,"_fetchFeaturesController",void 0),e([c({type:M})],z.prototype,"actions",void 0),e([c({readOnly:!0})],z.prototype,"active",null),e([c()],z.prototype,"activeFeature",void 0),e([c({readOnly:!0})],z.prototype,"allActions",null),e([c()],z.prototype,"autoCloseEnabled",void 0),e([c()],z.prototype,"browseClusterEnabled",void 0),e([c()],z.prototype,"content",void 0),e([c({type:M,readOnly:!0})],z.prototype,"defaultActions",null),e([c({type:Boolean})],z.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],z.prototype,"featureCount",null),e([c()],z.prototype,"featurePage",void 0),e([c({value:[]})],z.prototype,"features",null),e([c()],z.prototype,"featuresPerPage",void 0),e([c()],z.prototype,"featureMenuOpen",void 0),e([c()],z.prototype,"featureMenuTitle",void 0),e([c()],z.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],z.prototype,"featureViewModels",void 0),e([c()],z.prototype,"highlightEnabled",void 0),e([c()],z.prototype,"includeDefaultActions",void 0),e([c()],z.prototype,"initialDisplayMode",void 0),e([c({type:d})],z.prototype,"location",null),e([c()],z.prototype,"map",null),e([c({readOnly:!0})],z.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],z.prototype,"promiseCount",null),e([c()],z.prototype,"promises",null),e([c({readOnly:!0})],z.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],z.prototype,"selectedFeature",null),e([c({value:-1})],z.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],z.prototype,"selectedFeatureViewModel",null),e([c({type:m})],z.prototype,"spatialReference",null),e([c({readOnly:!0})],z.prototype,"state",null),e([c()],z.prototype,"timeZone",null),e([c()],z.prototype,"title",void 0),e([c()],z.prototype,"updateLocationEnabled",void 0),e([c()],z.prototype,"view",void 0),e([c()],z.prototype,"visible",void 0),e([c({readOnly:!0})],z.prototype,"waitingForContents",null),e([c({readOnly:!0})],z.prototype,"waitingForResult",null),e([c()],z.prototype,"zoomFactor",void 0),e([c()],z.prototype,"zoomToLocation",void 0),e([c()],z.prototype,"centerAtLocation",null),z=e([p("esri.widgets.Features.FeaturesViewModel")],z);export{z as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as u,sync as h}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../geometry/Point.js";import{project as g,initializeProjection as f}from"../../geometry/projectionUtils.js";import m from"../../geometry/SpatialReference.js";import{getPointFromGeometry as y}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as w}from"../../geometry/support/webMercatorUtils.js";import{fallbackObjectIDAttribute as F}from"../../layers/LayerConstants.js";import v from"../../symbols/SimpleFillSymbol.js";import{getDisplayedSymbol as _}from"../../symbols/support/symbolUtils.js";import{system as b}from"../../time/constants.js";import{highlightsSupported as C}from"../../views/support/layerViewUtils.js";import P from"../Feature/FeatureViewModel.js";import{ActionsCollection as M,zoomToClusteredFeatures as E,browseClusteredFeatures as L,zoomToFeature as V}from"../Popup/actions.js";import{triggerAction as j,isClusterFeature as A,getSelectedTarget as I,removeClusteredFeaturesForBrowsing as R,displayClusterExtent as x,browseAggregateFeatures as O}from"../Popup/actionUtils.js";import T from"../support/AnchorElementViewModel.js";import{GoTo as S}from"../support/GoTo.js";const B="location-scale-handle",H=()=>[V.clone()],U=()=>[E.clone(),L.clone()];let G=null;function Z(e,t){return"building-scene"===e||"map-image"===e||"tile"===e||"imagery"===e||"2d"===t&&"imagery-tile"===e}let z=class extends(S(T)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._selectedClusterFeature=null,this.actions=new M,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.initialDisplayMode="feature",this.selectedClusterBoundaryFeature=new t({symbol:new v({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=o(async e=>{const{spatialReference:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if(i&&"mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const e=this.selectedFeature;let i=e.geometry;const r=this._getHighlightLayer(e),o=e.getObjectId();if(!r||!this.view)return;if(o){const e=this.view?.allLayerViews.find(e=>e.layer.uid===r.uid);if(!e||!("queryFeatures"in e))return;const s=e.createQuery();s.outSpatialReference=t,s.objectIds=[o],s.returnGeometry=!0;const{features:a}=await e.queryFeatures(s);i=a[0]?.geometry}if(!i||"mesh"===i.type)return;i=g(i,t),G||(G=await Promise.all([await import("../../geometry/operators/intersectsOperator.js"),await import("../../geometry/operators/proximityOperator.js")]));const[a,n]=G;if(!a.execute(i,s)){const t=n.getNearestCoordinate(i,s).coordinate??s;this.selectedFeature===e&&(this.location=t)}}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=y(this.selectedFeature.geometry)??s})}initialize(){this.addHandles([this.on("view-change",()=>this._autoClose()),l(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),l(()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),l(()=>this.view?.animation?.state,e=>this._animationStateChange(e)),l(()=>this.location,e=>this._locationChange(e)),l(()=>this.selectedFeature,e=>this._selectedFeatureChange(e)),l(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),l(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),l(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on("trigger-action",e=>j({event:e,viewModel:this,view:this.view})),u(()=>!this.waitingForResult,()=>this._waitingForResultChange(),h),l(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),l(()=>this.view?.scale,()=>this._viewScaleChange()),u(()=>!this.visible,()=>this.browseClusterEnabled=!1),l(()=>this.browseClusterEnabled,e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new M;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach(t=>e.add(t)),e}get defaultActions(){const e=this._get("defaultActions")||new M;return e.removeAll(),e.addMany(A(this.selectedFeature)?U():H()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;"list"!==this.initialDisplayMode?o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1):(!o||o&&i===s)&&(this.selectedFeatureIndex=-1)}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=w(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice()).forEach(e=>this._pendingPromises.add(e)),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())):this._set("promises",[])}get screenLocation(){return super.screenLocation}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??b}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some(e=>e.waitingForContent)}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=I(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount),this}previous(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount),this}disableClusterBrowsing(){R(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?A(t)?(await x(this),await O(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}handleViewClick(e){this._fetchFeaturesAndOpen(e)}_getRoundRobinIndex(e,t){return(e+t)%t}_animationStateChange(e){this.zoomToLocation||(V.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(A(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:s}=this;s&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null==i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach((t,i)=>{t&&(t.graphic??=e[o+i])})}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(!e||!s)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),A(e))return;return e.symbol=await _(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}const r=e.sourceLayer?.type;if("map-image"!==r&&"imagery"!==r&&"imagery-tile"!==r||(e.symbol=await _(e)),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=y(e.geometry)}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s,spatialReference:r,map:o,timeZone:a,location:n}=this;if(A(t[0])||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(),u=[];t.forEach((t,i)=>{if(!t)return;let h=null;if(l.some((e,i)=>(e&&e.graphic===t&&(h=e,l.splice(i,1)),!!h)),h)u[i]=h;else{const l=new P({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:r,graphic:t===e?t:null,location:n,map:o,view:s,timeZone:a});u[i]=l}}),l.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:s}=this;if(!s)return null;await(s?.when());const r=e?.spatialReference;return r&&i?(await f(r,i,null,t),s.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch(()=>{}).then(()=>{this._fetchFeaturesController=null}),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e,{view:s}=this;this.removeHandles(B),this.addHandles([l(()=>this.view?.scale,()=>this._debouncedLocationUpdate(t).catch(e=>{a(e)||r.getLogger(this).error(e)})),u(()=>!this.visible,()=>{this.removeHandles(B)},{once:!0})],B);const{pendingFeatures:o}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:o})}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t??i}_getHighlightLayerView(e,t){return"subtype-sublayer"===t.type&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,i){if(Z(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||F:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);const i=this[t];if(!i)return;const{highlightEnabled:s,view:r,visible:o}=this;if(!r||!s||!o)return;const a=this._getHighlightLayer(i);if(!a)return;const n=this._getHighlightLayerView(r,a);if(!n)return;this._highlightPromises[e]=n;const l=await n;if(!(l&&C(l)&&this._highlightPromises[e]===n&&this[t]&&this.highlightEnabled))return;const u=l.highlight(this._getHighlightTarget(i,a,r.type));this.addHandles(u,e)}async _highlightActiveFeature(){return this._highlightFeature("highlight-active-feature","activeFeature")}async _highlightSelectedFeature(){return this._highlightFeature("highlight-selected-feature","selectedFeature")}_updateFeatures(e){const{features:t}=this,i=e.filter(e=>!t.includes(e));i?.length&&(this.features=t.concat(i))}};e([c()],z.prototype,"_fetchFeaturesController",void 0),e([c({type:M})],z.prototype,"actions",void 0),e([c({readOnly:!0})],z.prototype,"active",null),e([c()],z.prototype,"activeFeature",void 0),e([c({readOnly:!0})],z.prototype,"allActions",null),e([c()],z.prototype,"autoCloseEnabled",void 0),e([c()],z.prototype,"browseClusterEnabled",void 0),e([c()],z.prototype,"content",void 0),e([c({type:M,readOnly:!0})],z.prototype,"defaultActions",null),e([c({type:Boolean})],z.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],z.prototype,"featureCount",null),e([c()],z.prototype,"featurePage",void 0),e([c({value:[]})],z.prototype,"features",null),e([c()],z.prototype,"featuresPerPage",void 0),e([c()],z.prototype,"featureMenuOpen",void 0),e([c()],z.prototype,"featureMenuTitle",void 0),e([c()],z.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],z.prototype,"featureViewModels",void 0),e([c()],z.prototype,"highlightEnabled",void 0),e([c()],z.prototype,"includeDefaultActions",void 0),e([c()],z.prototype,"initialDisplayMode",void 0),e([c({type:d})],z.prototype,"location",null),e([c()],z.prototype,"map",null),e([c({readOnly:!0})],z.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],z.prototype,"promiseCount",null),e([c()],z.prototype,"promises",null),e([c({readOnly:!0})],z.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],z.prototype,"selectedFeature",null),e([c({value:-1})],z.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],z.prototype,"selectedFeatureViewModel",null),e([c({type:m})],z.prototype,"spatialReference",null),e([c({readOnly:!0})],z.prototype,"state",null),e([c()],z.prototype,"timeZone",null),e([c()],z.prototype,"title",void 0),e([c()],z.prototype,"updateLocationEnabled",void 0),e([c()],z.prototype,"view",void 0),e([c()],z.prototype,"visible",void 0),e([c({readOnly:!0})],z.prototype,"waitingForContents",null),e([c({readOnly:!0})],z.prototype,"waitingForResult",null),e([c()],z.prototype,"zoomFactor",void 0),e([c()],z.prototype,"zoomToLocation",void 0),e([c()],z.prototype,"centerAtLocation",null),z=e([p("esri.widgets.Features.FeaturesViewModel")],z);export{z 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../Color.js";import"../../../intl.js";import{addTokenParameter as s}from"../../../kernel.js";import i from"../../../request.js";import l from"../../../core/Accessor.js";import{isSome as r}from"../../../core/arrayUtils.js";import n from"../../../core/Collection.js";import has from"../../../core/has.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{clamp as u}from"../../../core/mathUtils.js";import{debounce as c}from"../../../core/promiseUtils.js";import{on as d,watch as y,initial as h,whenOnce as m}from"../../../core/reactiveUtils.js";import{px2pt as f}from"../../../core/screenUtils.js";import{parseWhereClause as p}from"../../../core/sql.js";import{addQueryParameters as g}from"../../../core/urlUtils.js";import{property as b}from"../../../core/accessorSupport/decorators/property.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{EffectView as _}from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as w}from"../../../layers/effects/jsonUtils.js";import{getEffectiveDisplayFilter as v}from"../../../layers/support/displayFilterUtils.js";import{ExportImageParameters as L}from"../../../layers/support/ExportImageParameters.js";import{collectFields as E,collectArcadeFieldNames as C}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as F}from"../../../layers/support/layerUtils.js";import{getPixelValueRange as I}from"../../../layers/support/rasterFormats/pixelRangeUtils.js";import{fromJSON as R}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as V}from"../../../renderers/support/rendererConversion.js";import D from"../../../renderers/visualVariables/SizeVariable.js";import x from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{updateReferenceSizeSymbol as z}from"../../../smartMapping/renderers/support/referenceSizeUtils.js";import T from"../../../symbols/SimpleFillSymbol.js";import j from"../../../symbols/SimpleMarkerSymbol.js";import{applyCIMSymbolColor as O}from"../../../symbols/support/cimSymbolUtils.js";import{renderSymbol as P}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as M,renderDotDensityPreviewHTML as A,renderPieChartPreviewHTML as k,renderPreviewHTML as U}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as B}from"../../../symbols/support/utils.js";import{getEffectiveClusterSizeVariable as N}from"./clusterUtils.js";import{getColorFromPointCloudStops as q,getRampStopsForPointCloud as $,getStretchRampStops as H,getRampStops as W}from"./colorRampUtils.js";import{getHeatmapRampStops as G}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as J,getRelationshipRampElement as Q}from"./relationshipRampUtils.js";import{getRampStops as Z,realWorldMaxSize as K,realWorldMinSize as X}from"./sizeRampUtils.js";import{specialCharsLessThan as Y,specialCharsGreaterThan as ee,getAuthoringInfoVisualVariableByTheme as te,getSymbolForFlowRenderer as se,getMedianColor as ie,rgbImgSource as le,getDateFormatOptions as re}from"./utils.js";import{formatNumberLabel as ne}from"../../smartMapping/support/utils.js";import{fetchMessageBundle as ae}from"../../../intl/messages.js";import{substitute as oe}from"../../../intl/substitute.js";const ue=16,ce="https://utility.arcgis.com/sharing/tools/legend",de="esri.layers.ImageryLayer",ye="esri.layers.ImageryTileLayer",he="esri.layers.WCSLayer",me=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,fe=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),pe=new j({size:6,outline:{color:[128,128,128,.5],width:.5}}),ge=new T({style:"solid"});function be(e){return"flow"===e.type}function Se(e){return"vector-field"===e.type}function _e(e){return"raster-colormap"===e.type}function we(e){return"raster-stretch"===e.type}function ve(e){return"raster-shaded-relief"===e.type}function Le(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function Ee(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function Fe(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function Ie(e){return Ve(e)||De(e)||xe(e)||Re(e)}function Re(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function Ve(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function De(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function xe(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function ze(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function Te(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function je(e,t){return Le(e)||Ee(e)||Ce(e)||Fe(e)||ze(e)||Te(e)?"2d"===t.type||V(e):we(e)||_e(e)||ve(e)||Ve(e)||De(e)||xe(e)||Se(e)||be(e)}function Oe(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Pe(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function Me(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Ae(e){return"esri.layers.WMSLayer"===e.declaredClass}function ke(e){return"esri.layers.WMTSLayer"===e.declaredClass}function Ue(e){return"esri.layers.MapImageLayer"===e.declaredClass}function Be(e){return"esri.layers.TileLayer"===e.declaredClass}function Ne(e){return e.declaredClass===de}function qe(e){return e.declaredClass===ye}function $e(e){return e.declaredClass===he}function He(e){return"stretch-ramp"===e.type}function We(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type}function Ge(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}function Je(e){return"sublayers"in e}function Qe(e){return e&&"symbol"in e}async function Ze(e,t){const s=await ae("esri/widgets/Legend/t9n/Legend");return"previewTemplateAriaLabel"!==e||t||(e="previewAriaLabel"),oe(s[e],{label:t})}function Ke(e,t){const{field:s,field2:i,field3:l,fieldDelimiter:r,valueExpression:n}=e;if(!s)return null;const a=!(!s&&!n||!i&&!l)?t?.toString().split(r||""):[t],o=s?{[s]:a?.[0]}:null;return o&&(i&&(o[i]=a?.[1]),l&&(o[l]=a?.[2])),o}const Xe=new j({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let Ye={},et=class extends l{constructor(e){super(e),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._hasClusterSizeVariable=!1,this._layerDefinitionExpression=null,this._layerDefinitionExpressionClause=null,this._layerDisplayFilterId=null,this._layerDisplayFilterClause=null,this.children=new n,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this.addHandles([d(()=>this.children,"change",t=>{const{added:s,removed:i}=t;s.forEach(t=>{const s=`activeLayerInfo-ready-watcher-${t.layer.uid}`;this.addHandles(y(()=>t.ready,e,h),s)}),i.forEach(e=>this.removeHandles(e.layer.uid)),e()})]),this.keepCacheOnDestroy||(Ye={})}destroy(){this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(Ye=null),this._layerDefinitionExpressionClause=null}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new _,t.effect=e.effect,t.endTransition(),t.scale=this.scale),t}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,s=this.layer.parent,i=s&&"uid"in s?this._getParentLayerOpacity(s):null;return null!=t?t*e:null!=i?i*e:e}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view?.scale??0}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?!!("displayFilterInfo"in e&&e.displayFilterInfo&&Ce(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(F(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet?.features.length){const t=e.layerDefinition,s=t?.drawingInfo,i=s&&R(s.renderer),l=fe.read(t.geometryType);return i?this._getRendererLegendElements(i,{title:e.name,geometryType:l}):(o.getLogger(this).warn("drawingInfo not available!"),null)}return null});try{const e=[],s=await Promise.allSettled(t);for(const t of s)if("fulfilled"===t.status)for(const s of t.value??[])e.push(s);this.legendElements=e,this.notifyChange("ready")}catch(s){o.getLogger(this).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).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).warn("error while building legend for layer!",t)}}async buildLegendElementsForTools(){const e=this.layer;if(Me(e))await this._constructLegendElementsForVoxelLayer();else if(ke(e))this._constructLegendElementsForWMTSlayer();else if(Ae(e))await this._constructLegendElementsForWMSSublayers();else if(Oe(e))await this._constructLegendElementsForBuildingSceneLayer();else if(Ue(e)||Be(e)||Pe(e))await this._constructLegendElementsForSublayers();else{this.removeHandles("imageryLayers-watcher");let t="default";if(Ne(e)){const s=e;t=(s?.rasterFunction?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}if(qe(e)||"link-chart"===e.type)return;await this._getLegendLayers(`${e.uid}-${t}`).then(async t=>{this.legendElements=[],this.notifyChange("ready");const s=t.map(async t=>{if(Ne(e)){const t=y(()=>[e.rasterFunction,e.bandIds],()=>c(async()=>{Ye.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()})());this.addHandles(t,"imageryLayers-watcher")}const s=this._generateSymbolTableElementForLegendLayer(t);s?.infos.length&&(Ne(e)&&(s.title=e.title),this.legendElements.push(s)),this.notifyChange("ready")});await Promise.allSettled(s)}).catch(e=>{o.getLogger(this).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 m(()=>!t.updating);const i=s?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();if(!i)return!0;i.geometry=this.view.extent;return 0!==(s?"queryFeatureCount"in t&&await t.queryFeatureCount(i):"queryFeatureCount"in e&&await e.queryFeatureCount(i))}_getParentLayerOpacity(e){let t=1;const s=e.parent;return s&&"uid"in s&&(t=this._getParentLayerOpacity(s)),e.opacity*t}_isGroupActive(){return this.children.some(e=>e.ready)}_isRendererScaleDriven(e){if("dot-density"===e.type)return!0;const t="valueExpression"in e?e.valueExpression:null;if(me.test(t))return!0;const s="visualVariables"in e?e.visualVariables:null;return!!s?.some(e=>this._isScaleDrivenSizeVariable(e))||this._hasScaleDrivenSymbols(e)}_hasScaleDrivenSymbols(e){switch(e.type){case"simple":return this._isScaleDrivenSymbol(e.symbol);case"class-breaks":return this._isScaleDrivenSymbol(e.defaultSymbol)||e.classBreakInfos.some(e=>this._isScaleDrivenSymbol(e.symbol));case"unique-value":return this._isScaleDrivenSymbol(e.defaultSymbol)||!!e.uniqueValueInfos?.some(e=>this._isScaleDrivenSymbol(e.symbol))}return!1}_isScaleDrivenSymbol(e){if("cim"===e?.type){const{primitiveOverrides:t,minScale:s,maxScale:i}=e.data,l=t?.some(e=>/\$view\.scale/.test(e.valueExpressionInfo?.expression||""))??!1;return null!=s||null!=i||l}return!1}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,s=t.minSize,i=t.maxSize;return!("object"!=typeof s||!s||!this._isScaleDrivenSizeVariable(s))||(!("object"!=typeof i||!i||!this._isScaleDrivenSizeVariable(i))||me.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&&Ue(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.removeHandles("voxel-style-watcher"),this.removeHandles("voxel-current-variable");const e=this.layer;this.addHandles(y(()=>e.currentVariableId,()=>this._constructLegendElementsForVoxelLayer()),"voxel-current-variable"),this.addHandles(y(()=>e.getVariableStyles(),()=>this._constructLegendElementsForVoxelLayer()),"voxel-style-watcher");const t=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 T({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:i}=t.transferFunction,l=e.toArray().reverse(),r=i.map((e,t)=>`${0===t?Y:ee} ${ne(e)}`).reverse(),n=l.map(e=>({color:e.color,value:null,label:null}));n[0].label=r[0],n[n.length-1].label=r[1],s.push({type:"color-ramp",title:t.label,infos:n,preview:M(l.map(e=>e.color),{ariaLabel:await Ze("previewColorRampAriaLabel")})})}await this._generatePreviewsForLegendElements(s,{opacity:e.opacity}),this.legendElements=s,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this.removeHandles("wmts-activeLayer-watcher");const e=this.layer.activeLayer;this.addHandles(y(()=>{const{layer:e}=this;return e&&"activeLayer"in e&&e.activeLayer},()=>this._constructLegendElementsForWMTSlayer()),"wmts-activeLayer-watcher");const t=e.styleId?e.styles?.find(({id:t})=>t===e.styleId)?.legendUrl:void 0;t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}]),this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this.legendElements=[],this.removeHandles("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this.addHandles(y(()=>{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.layer,i=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForWMSSublayers()),"wms-sublayers-watcher");const l=this.sublayerIds?.map(e=>s.findSublayerById(e))?.filter(r)??[],n=l.length?l:e.toArray();for(const r of n){const e=y(()=>[r.title,r.visible,r.legendEnabled],()=>this._constructLegendElementsForWMSSublayers());if(this.addHandles(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e?.infos.length&&i.unshift(e)}}return i}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 l={type:"symbol-table",title:e.title||e.name||String(e.id??""),infos:[]};t&&(s=g(s,t));let r=null;const n=e.layer?.opacity;try{r=(await i(s,{responseType:"image"})).data,r&&(r.style.opacity=n)}catch{}return l.infos.push({src:s,preview:r,opacity:n}),l}_getLegendLayers(e,t){const s=Ye&&Ye[e];return s?Promise.resolve(s):this._legendRequest(t).then(t=>{const s=t.layers;return Ye[e]=s,s})}_legendRequest(e){const t=this.layer;let s={f:"json",dynamicLayers:e};if(Ne(t)){const e=t.exportImageServiceParameters.rasterFunction;if(e&&(s.renderingRule=JSON.stringify(e.functionDefinition?.toJSON()||e.toJSON())),t.bandIds&&(s.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:i,customParameters:l}=t;s={raster:e,viewId:i,...s,...l}}}let l=t.url.replace(/(\/)+$/,"");if("version"in t&&+t.version>=10.01){const e=l.indexOf("?");e>-1?l=l.slice(0,e)+"/legend"+l.slice(e):l+="/legend"}else{const e=l.toLowerCase().indexOf("/rest/"),t=-1===e?l:l.slice(0,e)+l.slice(e+5);l=ce+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return i(l,{query:s}).then(e=>e.data)}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;this.addHandles(y(()=>e.sublayers,()=>this._constructLegendElementsForBuildingSceneLayer()),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForBuildingSublayers(e,t){let s=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForBuildingSceneLayer()),"sublayers-watcher");const i=e.toArray();for(const l of i){const e=y(()=>["renderer"in l&&l.renderer,l.opacity,l.title,l.visible],()=>this._constructLegendElementsForBuildingSceneLayer());if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||l.visible){const e=null!=l?.opacity?l.opacity:null,i=null!=e?e*t:t;if("building-group"===l.type){const e={type:"symbol-table",title:l.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(l.sublayers,i);e.infos.push(...t),s=[e,...s]}else if(l.renderer){s=[...await this._getRendererLegendElements(l.renderer,{title:l.title,opacity:i,sublayer:l}),...s]}}}return s.filter(e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0))}async _constructLegendElementsForSublayers(){this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;if(Ue(e)||Be(e)||Pe(e)){this.addHandles(y(()=>e.sublayers,()=>this._constructLegendElementsForSublayers),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}}}async _generateLegendElementsForSublayers(e,t,s){const i=this.layer;let l=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForSublayers()),"sublayers-watcher");let n=e.toArray();!s&&this.sublayerIds&&this.sublayerIds.length&&(n=Pe(i)?this.sublayerIds.map(e=>i.findSublayerForSubtypeCode(e)).filter(r):this.sublayerIds.map(e=>i.findSublayerById(e)).filter(r));for(const r of n){const e=y(()=>[r.renderer,r.opacity,r.title,r.visible,r.legendEnabled],()=>this._constructLegendElementsForSublayers());if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled&&this._isSublayerInScale(r)){const e=null!=r?.opacity?r.opacity:null,i=null!=e?e*t:t,n=!Je(r)||r.originIdOf("renderer")>2&&!r.sublayers;if(r.renderer&&n){await r.load();l=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:i,sublayer:r}),...l]}else if(Je(r)){const e=await this._generateSymbolTableElementForSublayer(r,i,s);e&&l.unshift(e)}}}return l.filter(e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0))}async _generateSymbolTableElementForSublayer(e,t,s){if(!s){s=new Map;const t=this.layer,i=e.source;let l=null;if(!(!i||"map-layer"===i.type&&i.mapLayerId===e.id&&(!i.gdbVersion||i.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>2||e.originIdOf("labelingInfo")>2||e.originIdOf("labelsVisible")>2){const e=new L({layer:this.layer});l=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const r=l||`${t.uid}-default`;(await this._getLegendLayers(r,l)).forEach(e=>s.set(e.layerId,e))}const i=s.get(e.id);if((!i||i?.subLayerIds&&i.defaultVisibility)&&e.sublayers){const i=await this._generateLegendElementsForSublayers(e.sublayers,t,s);return{type:"symbol-table",title:e.title,infos:i}}return this._generateSymbolTableElementForLegendLayer(i,e,t)}_generateSymbolTableElementForLegendLayer(e,t,s){if(!e?.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const i=t?.renderer;let l=t?.title||e.layerName;if(i&&(!t||t?.originIdOf("renderer")>2)){const e=t?.title||this._getRendererTitle(i,t);e&&(l&&"string"!=typeof e&&"title"in e&&(e.title=l),l=e)}const r={type:"symbol-table",title:l,legendType:e.legendType||null,infos:[]},n=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return e.legendGroups&&e.legendGroups.length>0?e.legendGroups.forEach(t=>{const i={type:"symbol-table",title:t.heading,legendType:e.legendType||null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter(e=>e.groupId===t.id),e.layerId,s)};i.infos?.length>0&&r.infos.push(i)}):r.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,s),r.infos.length>0?r:null}_generateSymbolTableElementInfosForLegendLayer(e,t,i){return e.map(e=>{let l=e.url;if(e.imageData&&e.imageData.length>0)l=`data:image/png;base64,${e.imageData}`;else{if(0===l.indexOf("http"))return null;l=s(`${this.layer.url}/${t}/images/${l}`)}return{label:e.label,src:l,opacity:i??this.opacity,width:e.width,height:e.height}}).filter(r)}_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 i=null,l=null,r=!0;return!s.minScale&&0!==s.minScale||!s.maxScale&&0!==s.maxScale?(0===e.minScale&&s.tileInfo&&(i=s.tileInfo.lods[0].scale),0===e.maxScale&&s.tileInfo&&(l=s.tileInfo.lods[s.tileInfo.lods.length-1].scale)):(i=Math.min(s.minScale,e.minScale)||s.minScale||e.minScale,l=Math.max(s.maxScale,e.maxScale)),(i>0&&i<this.scale||l>this.scale)&&(r=!1),r}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&+this.layer.version<10.1||0===e.length)return e;const s=t.renderer,i=e.some(e=>e.values);let l=0,r=null;return i&&e.some((e,t)=>(e.values||(l=t,r=e,r.label||(r.label="others")),null!=r)),s?"unique-value"===s.type?r&&(e.splice(l,1),e.push(r)):"class-breaks"===s.type&&(r&&e.splice(l,1),s.legendOptions?.order||e.reverse(),r&&e.push(r)):r&&(e.splice(l,1),e.push(r)),e}async _getRendererLegendElements(e,t={}){if(!je(e,this.view))return o.getLogger(this).warn(`Renderer of type '${e.type}' not supported!`),[];if(Ie(e))return this._constructPointCloudRendererLegendElements(e,t);if(ze(e))return this._constructDotDensityRendererLegendElements(e);const s=await this._loadRenderer(e);return Te(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?.title||e.field)??""}async _constructPointCloudRendererLegendElements(e,t={}){const s=t.title,i=[];let l=null,r=null;if(Ve(e))l={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach(e=>{l.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(pe,e.color)})});else if(De(e)){const t=e.stops;let i=null;if(t?.length&&(1===t.length&&(i=t[0].color),!i)){const e=t[0].value,s=t[t.length-1].value;if(null!=e&&null!=s){i=q(e+(s-e)/2,t)}}l={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(pe,i||pe.color)}]};const n=$(e.stops??[])??[];r={type:"color-ramp",title:s||this._getPointCloudRendererTitle(e),infos:n,preview:M(n.map(e=>e.color),{ariaLabel:await Ze("previewColorRampAriaLabel")})}}else xe(e)&&(l={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos?.forEach(e=>{l.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(pe,e.color)})}));return l?.infos.length&&i.push(l),r?.infos.length&&i.push(r),await this._generatePreviewsForLegendElements(i,{opacity:this.opacity,symbolConfig:{applyColorModulation:!!e.colorModulation}}),i}async _getElementInfoForDotDensity(e,t){const{color:s,label:i,valueExpressionTitle:l}=t,{backgroundColor:r,outline:n,dotSize:a}=e,o=this.effectList,u=o?.effects.map(e=>e.toJSON()),c=w(u),d=await Ze("previewTemplateAriaLabel",i||l),y=a+"-"+s+"-"+r+"-"+(n&&JSON.stringify(n.toJSON()))+"-"+c,h=this._dotDensityUrlCache,m=h.has(y)?h.get(y):A(e,s,{ariaLabel:d});h.set(y,m);const f={shape:{type:"image",x:0,y:0,width:m.width,height:m.height,src:m.src},fill:null,stroke:null,offset:[0,0]},p=P([[f]],[m.width,m.height],{effectView:this.effectList,ariaLabel:d});return{opacity:1,src:m.src,preview:p,width:m.width,height:m.height}}async _constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),s=e.legendOptions?.unit,i={type:"symbol-table",title:{value:t&&Math.round(t),unit:s||""},infos:[]};for(const l of e.attributes){const t=await this._getElementInfoForDotDensity(e,l);t.label=l.label||l.valueExpressionTitle||l.field,i.infos.push(t)}return[i]}async _constructPieChartRendererLegendElements(e){const t=[];let s=null;const i=e.outline;e.attributes.forEach(e=>{const s=new j({color:e.color,outline:i}),l=e.label||e.valueExpressionTitle||e.field;t.push({label:l,symbol:s})});const l=t.length?[...t]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const l=new j({color:e.othersCategory.color,outline:i});s=e.othersCategory.label||"Other",t.push({label:s,symbol:l})}if(e.defaultColor?.a){const s=new j({color:e.defaultColor,outline:i});t.push({label:e.defaultLabel,symbol:s})}const r=await this._getVisualVariableLegendElements(e,this.layer)||[];if(t.length){r.unshift({type:"symbol-table",title:null,infos:t});const n=l.filter(e=>e.label!==s).map(e=>e.symbol.color).filter(Boolean),a=k(n,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,effectList:this.effectList,outline:i,ariaLabel:await Ze("previewPieChartAriaLabel")});r.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:t,preview:a})}return await this._generatePreviewsForLegendElements(r,{opacity:this.layer.opacity,effectView:this.effectList}),r}async _getWhereClause(e,t,s){const i=await p(e,s),l=new Set,{field:r,field2:n,field3:a}=t;E(l,s,[r,n,a]),await C(l,s,t.valueExpression);const o=new Set(Array.from(l,e=>e.toLowerCase())),u=i?.fieldNames.map(e=>e.toLowerCase());return u?.some(e=>!o.has(e))?null:i}async _processDefinitionExpression(e,t){if(!("definitionExpression"in e))return;const s=e.definitionExpression;s&&this.respectLayerDefinitionExpression?this._layerDefinitionExpression!==s&&(this._layerDefinitionExpressionClause=await this._getWhereClause(s,t,e.fieldsIndex)):this._layerDefinitionExpressionClause=null,this._layerDefinitionExpression=s}async _processDisplayFilter(e,t){if(!("displayFilterInfo"in e))return;const s=e.displayFilterInfo?v(e.displayFilterInfo,this.view):null;return s?.where?this._layerDisplayFilterId!==s?.id&&(this._layerDisplayFilterClause=await this._getWhereClause(s.where,t,e.fieldsIndex)):this._layerDisplayFilterClause=null,this._layerDisplayFilterId=s?.id,s}async _constructRendererLegendElements(e,t={}){const{title:s,sublayer:i}=t,l=i||this.layer,r=te(e,"reference-size"),n=te(e,"spike");let a=null;Ce(e)&&(await this._processDefinitionExpression(l,e),a=await this._processDisplayFilter(l,e)),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const o=await this._getVisualVariableLegendElements(e,l)||[],u={type:"symbol-table",title:s||this._getRendererTitle(e,l),infos:[]};let c=null,d=!1;const y=new Set;if(be(e)&&!this._hasSizeRamp){const t=await se(e);u.infos.push({label:null,symbol:t})}else if(We(e)){let t=s;const i=Ge(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",l=o.findIndex(e=>"color-ramp"===e.type),r=-1!==l?o.splice(l,1)[0]:null,n=o.findIndex(e=>"size-ramp"===e.type),a=-1!==n?o.splice(n,1)[0]:null,u=[];r&&(t=r.title,u.push(r)),a&&(t=a.title,u.push(a)),u.length>0&&o.push({type:i,title:t,infos:u})}else if(Fe(e)){const t=G(e);o.push({type:"heatmap-ramp",title:s||this._getRendererTitle(e,l),infos:t,preview:M(t.map(e=>e.color),{effectList:this.effectList,ariaLabel:await Ze("previewColorRampAriaLabel")})})}else if(Ce(e)){const t=e.authoringInfo;if(t&&"relationship"===t.type){const{numClasses:s,field1:i,field2:r}=t,n=t.focus;if(s&&i&&r){const t=[i,r];let a=J(n)||0;for(const e of t){const{field:t,normalizationField:s,label:i}=e,r=i||{field:this._getFieldAlias(t,l),normField:s&&this._getFieldAlias(s,l)},n=Xe.clone();n.angle=a,u.infos.push({label:r,symbol:n}),y.add(n),a+=90}const c=Q({focus:n,numClasses:s,infos:e.uniqueValueInfos??[]});o.unshift(c)}}else if(Ne(this.layer)||qe(this.layer))e.uniqueValueInfos?.forEach(t=>{t.symbol&&this._checkClausesForUVR(e,t.value)&&u.infos.push({label:t.label||t.value,value:t.value,symbol:t.symbol})});else{const{field:t,field2:i,field3:n,fieldDelimiter:o,valueExpression:c,defaultSymbol:y}=e,h=!(!t&&!c||!i&&!n),m=this._layerDisplayFilterClause?a?.title:null,f=[];if(e.uniqueValueGroups?.forEach(s=>{const a={type:"symbol-table",title:m||s.heading,infos:[]};s.classes?.forEach(s=>{const{symbol:u,values:d}=s;if(u){const y=[],m=[];for(const e of d??[]){const{value:s,value2:r,value3:a}=e,u=[],d=[];(t||c)&&(u.push(s),d.push(this._getDomainName(t,s,l))),i&&(u.push(r),d.push(this._getDomainName(i,r,l))),n&&(u.push(a),d.push(this._getDomainName(n,a,l))),y.push(h?u.join(o||""):u[0]),m.push(d.join(" - "))}const f=y.join(", ");let p=s.label;if(!p){const e=m.filter(Boolean);p=e.length?e.join(", "):f}const g=u.clone();"cim"===g.type&&r&&z(g,{innerDotSize:.5*ue,outerRingSize:ue}),y.some(t=>this._checkClausesForUVR(e,t))&&a.infos.push({label:p,value:f,symbol:g})}}),a.infos.length&&f.push(a)}),f.length){const t=f[0];if(1===f.length&&"title"in t&&!t.title){const e=t.infos?.filter(Qe)??[];u.infos.push(...e)}else y&&(f.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:y}]}),d=!0),u.infos.push(...f);s||e.legendOptions?.title||e.valueExpressionTitle||(u.title=null)}}e.defaultSymbol&&!d&&(u.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),d=!0)}else if(Ee(e)){if(!r&&!n){c=this._isUnclassedRenderer(e);if(!c||!this._hasSizeRamp){const t=e.classBreakInfos.filter(({symbol:e})=>e),s="ascending-values"===e.legendOptions?.order;for(const{label:e,minValue:i,maxValue:l,symbol:r}of t){const t={label:e||(c?null:`${i} - ${l}`),value:[i,l],symbol:r};s?u.infos.push(t):u.infos.unshift(t)}c&&(u.title=null),this._updateInfosForClassedSizeRenderer(e,u.infos)}e.defaultSymbol&&!c&&(u.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),d=!0)}}else if(we(e))if(qe(this.layer)||$e(this.layer)){const t=await this._constructTileImageryStretchRendererElements(e);He(t)?o.push(t):u.infos=t}else{const t=this.layer;let s,i;e.customStatistics?.length&&({min:s,max:i}=e.customStatistics[0]);let l=[],r=t.serviceRasterInfo;if(t.rasterFunction)try{r=await t.generateRasterInfo(t.rasterFunction)}catch{}const n=I(r.pixelType);if(1===r.bandCount){const l=t.bandIds?.[0]||0;s=null!=s?s:r.statistics?r.statistics[l].min:n[0],i=null!=i?i:r.statistics?r.statistics[l].max:n[1],s||i?o.push(await this._getStretchLegendElements(e,{min:s,max:i})):this._getServerSideLegend()}else if(t.bandIds&&1===t.bandIds.length)s=null!=s?s:r.statistics?r.statistics[t.bandIds[0]].min:n[0],i=null!=i?i:r.statistics?r.statistics[t.bandIds[0]].max:n[1],s||i?o.push(await this._getStretchLegendElements(e,{min:s,max:i})):this._getServerSideLegend();else if(r.bandCount>=3){const{bandInfos:e}=r,{bandIds:s}=t;e.length>=r.bandCount?3===s?.length?(l=s.map(t=>e[t].name),u.infos=this._createSymbolTableElementMultiBand(l)):"lerc"===t.format?(l=[0,1,2].map(t=>e[t].name),u.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend():"lerc"===t.format?(l=["band1","band2","band3"],u.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend()}else this._getServerSideLegend()}else if(_e(e))e.colormapInfos.forEach(e=>{u.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(ge,e.color)})});else if(Le(e)){let s=e.symbol;switch(t.geometryType){case"point":s="pointSymbol"in l?l.pointSymbol:null;break;case"polyline":s="lineSymbol"in l?l.lineSymbol:null;break;case"polygon":s="polygonSymbol"in l?l.polygonSymbol:null}const i=this._hasClusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&i&&u.infos.push({label:e.label,symbol:s})}else if(Se(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),u.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach(e=>{u.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})}):u.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else ve(e)&&o.push(await this._getStretchLegendElements(e,{min:0,max:255}));const h=e.defaultSymbol;!h||d||Le(e)||c&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||o.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:h}]}),u.infos.length&&o.unshift(u);const m=null==t.opacity?this.opacity:t.opacity,f=this._isTallSymbol("visualVariables"in e?e.visualVariables:null),p=Ne(this.layer)||qe(this.layer);return await this._generatePreviewsForLegendElements(o,{opacity:m,symbolConfig:{isTall:f,isSquareFill:p},effectView:this.effectList},{defaultSymbol:h,arrowMarkerSymbols:y}),e=null,o}_checkClausesForUVR(e,t){const s=Ke(e,t);return!s||(!this._layerDefinitionExpressionClause||this._layerDefinitionExpressionClause.testFeature(s))&&(!this._layerDisplayFilterClause||this._layerDisplayFilterClause.testFeature(s))}_getServerSideLegend(){setTimeout(()=>this.buildLegendElementsForTools(),0)}_getAllInfos(e){const t=e?.infos;return t?t.reduce((e,t)=>e.concat(this._getAllInfos(t)),[]):[e]}async _constructTileImageryStretchRendererElements(e){const t=this.layer,s=t.symbolizer.rasterInfo??t.raster.rasterInfo;let i,l;const r=e?.customStatistics?.length?e.customStatistics:s?.statistics;if(r)({min:i,max:l}=r[0]);else{const e=I(s.pixelType);i=e[0],l=e[1]}if(t.hasStandardTime()&&(i=t.getStandardTimeValue(i),l=t.getStandardTimeValue(l)),1===s.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:i,max:l});const n=(t?.bandIds?.length?t.bandIds:Array.from(Array(Math.min(s.bandCount,3)).keys())).map(e=>s.bandInfos[e].name);return n.length<3?n.push(n[1]):n.length>3&&n.splice(3),this._createSymbolTableElementMultiBand(n)}async _getStretchLegendElements(e,t){const s=e.colorRamp,i=H(s,t);return{type:"stretch-ramp",title:"",infos:i,preview:M(i.map(e=>e.color),{ariaLabel:await Ze("previewColorRampAriaLabel")})}}_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:null}async _getSizeLegendElement(e,t,s,i){return{type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(t):e,infos:await Z(s,t,await ie(s),this.scale,this.view,i,this._hasClusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],s=["red","green","blue"];return e.forEach((e,i)=>{t.push({label:{colorName:s[i],bandName:e},src:le[i],opacity:this.opacity??1})}),t}_updateInfosForClassedSizeRenderer(e,t){const s=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,i=e.classBreakInfos.some(e=>B(e.symbol));if(s&&i){const s=K,i=X,l=e.classBreakInfos.length,r=(s-i)/(l>1?l-1:l);t.forEach((e,t)=>{e.size=s-r*t})}}_isTallSymbol(e){let t=!1,s=!1;if(e)for(let i=0;i<e.length&&(!t||!s);i++){const l=e[i];"size"===l.type&&("height"===l.axis&&(t=!0),"width-and-depth"===l.axis&&(s=!0))}return t&&s}async _generatePreviewsForLegendElements(e,t,s){const i=[];for(const l of e)for(const e of l.infos??[])if("infos"in e&&e.infos&&i.push(this._generatePreviewsForLegendElements([e],t,s)),Qe(e)&&e.symbol&&!e.preview){let r=!0;if("cim"===e.symbol.type){const{minScale:t,maxScale:s}=e.symbol.data;(t&&t<this.scale||s&&s>this.scale)&&(r=!1)}r&&i.push(this._generateSymbolPreviewForInfo(e,{...t,clipBloomEffect:"theme"in l&&"spike"===l.theme,effectView:s?.arrowMarkerSymbols?.has(e.symbol)?null:t.effectView},s?{isDefault:e.symbol===s.defaultSymbol,applyScaleDrivenSize:!s.arrowMarkerSymbols?.has(e.symbol)}:void 0))}await Promise.all(i)}async _generateSymbolPreviewForInfo(e,t,s){try{let i=!s?.isDefault&&null==e.size&&this._hasSizeRamp?f(22):e.size;if(this._scaleDrivenSizeVariable&&s?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");i=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}const l="cim"===e.symbol.type?{style:"legend",cimOptions:{allowScalingUp:!s?.isDefault&&this._hasSizeRamp||!(!this._scaleDrivenSizeVariable||!s?.applyScaleDrivenSize),viewParams:this.isScaleDriven?{viewingMode:"2d"===this.view?.type?"map":this.view?.viewingMode,scale:this.view?.scale}:null}}:{},r=e.label&&"string"!=typeof e.label?null:await Ze("previewTemplateAriaLabel",e.label);e.preview=await U(e.symbol,{size:i,scale:!1,ariaLabel:r,...t,...l})}catch{e.preview=null,o.getLogger(this).warn(`Generating symbol preview failed for symbol type: ${e.symbol?.type}`)}}_getClusterRenderer(e){this._hasClusterSizeVariable=!1;const t="renderer"in this.layer?this.layer.renderer:null,s=e.renderer?.clone()||t?.clone(),i=N(e,this.layerView,this.view);if(i&&null!=s&&"visualVariables"in s){const t=s.visualVariables?.some(e=>"size"===e.type&&"outline"!==e.target&&!me.test(e.valueExpression));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:s}=e;i.legendOptions=new x({showLegend:t!==s})}const t=s.visualVariables||[];s.visualVariables=t.concat([i]),this._hasClusterSizeVariable=!0}}return s}async _loadRenderer(e){const t=[],s=e.clone(),i=await ie(s);if(Ee(s)||Ce(s)){const e=(s.classBreakInfos||s.uniqueValueInfos).map(e=>this._fetchSymbol(e.symbol,i).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:i).then(e=>{this._applySymbolToRenderer(s,e,Le(s))}).catch(()=>{this._applySymbolToRenderer(s,null,Le(s))})),await Promise.allSettled(t),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 i=await e.fetchSymbol({cache:s});return this._getAppliedCloneSymbol(i,t)}catch{throw o.getLogger(this).warn("Fetching web-style failed!"),new Error}}return this._getAppliedCloneSymbol(e,t)}_getAppliedCloneSymbol(e,s){if(!e||!s)return e;const i=e.clone(),l=s&&s.toRgba();return i.type.includes("3d")?this._applyColorTo3dSymbol(i,l):"cim"===i.type?O(i,s):i.color&&(i.color=new t(l||i.color)),i}_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)||"vector-field"===e.type)return null;const s=e.visualVariables??[],i=[],l=[],n=[],a=te(e,"reference-size")??te(e,"spike");let o;if(2===a?.sizeStops?.length&&(Ee(e)||Ce(e))){const[e,t]=a.sizeStops;o=new D({field:a.field??void 0,normalizationField:a.normalizationField,minSize:u(e.size,10,100),maxSize:u(t.size,50,150),minDataValue:e.value,maxDataValue:t.value}),l.push(o)}for(const r of s)"color"===r.type?i.push(r):"size"===r.type?l.push(r):"opacity"===r.type&&n.push(r);const c=[...i,...l,...n];let d,y;if(0===i.length&&Ee(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];d=t&&t.symbol}if(0===i.length&&Le(e)&&(d=e.symbol),d)if(d.type.includes("3d")){const e=d.symbolLayers.at(0);"water"===e.type?null!=e.color&&(y=e.color):null!=e.material?.color&&(y=e.material.color)}else d.url||(y=d.color);const h=this.effectList;return(await Promise.all(c.map(async s=>{if(!s.legendOptions||!1!==s.legendOptions.showLegend){const i=be(e)?s.field:this._getRampTitle(s,t);let l=null;const r=re(t,s,this.view.timeZone);if("color"===s.type){const e=await W(s,null,r)??[];l={type:"color-ramp",title:i,infos:e,preview:M(e.map(e=>e.color),{effectList:h,ariaLabel:await Ze("previewColorRampAriaLabel")})},this._hasColorRamp||(this._hasColorRamp=e.length>0)}else if("size"===s.type&&"outline"!==s.target)me.test(s.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=s):(l=await this._getSizeLegendElement(i,s,e,r),o===s&&"spike"===a?.theme&&(l.theme=a.theme),this._hasSizeRamp||(this._hasSizeRamp=!(null==l.infos||!l.infos.length)));else if("opacity"===s.type){const e=await W(s,y,r)??[];l={type:"opacity-ramp",title:i,infos:e,preview:M(e.map(e=>e.color),{effectList:h,ariaLabel:await Ze("previewColorRampAriaLabel")})},this._hasOpacityRamp||(this._hasOpacityRamp=e.length>0)}return l?.infos?l:null}}))).filter(r)}_getDomainName(e,t,s){if(e&&"function"!=typeof e){const i="getField"in s&&s.getField?.(e),l=i&&"getFieldDomain"in s&&s.getFieldDomain?s.getFieldDomain(i.name,{excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")}):null;return"coded-value"===l?.type?l.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,i="popupTemplate"in e&&e.popupTemplate,l=i&&i.fieldInfos;if(l)for(const t of l)if(t.fieldName===s)return"cluster_count"===s?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let s=e.field,i=e.normalizationField,l=!1,r=!1,n=!1,a=null;s="function"==typeof s?null:s,i="function"==typeof i?null:i;const o=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?.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){l=!0;break}if("percent"===s.style){r=!0;break}if("percent-of-total"===s.style){n=!0;break}}}}a={field:s&&this._getFieldAlias(s,t),normField:i&&this._getFieldAlias(i,t),ratio:l,ratioPercent:r,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const s=e;if(s.legendOptions?.title)return s.legendOptions.title;if(s.valueExpressionTitle)return s.valueExpressionTitle;let i=s.field,l=null,r=null;if(Ee(s)&&(l=s.normalizationField,r="percent-of-total"===s.normalizationType),i="function"==typeof i?null:i,l="function"==typeof l?null:l,Ce(s)){const{field2:e,field3:l,fieldDelimiter:r}=s;let n=i&&this._getFieldAlias(i,t);return e&&(n=`<${n}>${r}<${this._getFieldAlias(e,t)}>`,l&&(n=`${n}${r}<${this._getFieldAlias(l,t)}>`)),n}let n=null;return(i||l)&&(n={field:i&&this._getFieldAlias(i,t),normField:l&&this._getFieldAlias(l,t),normByPct:r}),n}_getFieldAlias(e,t){const s="popupTemplate"in t?t.popupTemplate:null,i=s?.fieldInfos;let l=i?.find(t=>e===t.fieldName),r=null;"getField"in t&&t.getField?r=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(r=t.fieldsIndex.get(e));let n=null;const a="featureReduction"in t&&t.featureReduction;a&&(l??="popupTemplate"in a?a.popupTemplate?.fieldInfos?.find(t=>e?.toLowerCase()===t.fieldName?.toLowerCase()):void 0,"fields"in a&&a.fields&&(n=a.fields.find(t=>t.name?.toLowerCase()===e?.toLowerCase())));const o=l||r||n;let u=null;return o&&(u=l?.label||r?.alias||n?.alias||"name"in o&&o.name||"fieldName"in o&&o.fieldName||null),u}_isUnclassedRenderer(e){const t=e.visualVariables;let s=!1;return Ee(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([b()],et.prototype,"children",void 0),e([b({readOnly:!0})],et.prototype,"effectList",null),e([b()],et.prototype,"layerView",void 0),e([b()],et.prototype,"layer",void 0),e([b()],et.prototype,"legendElements",void 0),e([b({readOnly:!0})],et.prototype,"opacity",null),e([b()],et.prototype,"parent",void 0),e([b({readOnly:!0,dependsOn:[]})],et.prototype,"ready",null),e([b()],et.prototype,"hideLayersNotInCurrentView",void 0),e([b()],et.prototype,"keepCacheOnDestroy",void 0),e([b()],et.prototype,"respectLayerDefinitionExpression",void 0),e([b()],et.prototype,"respectLayerVisibility",void 0),e([b({readOnly:!0})],et.prototype,"scale",null),e([b()],et.prototype,"sublayerIds",void 0),e([b({readOnly:!0})],et.prototype,"isScaleDriven",null),e([b()],et.prototype,"title",void 0),e([b({readOnly:!0,dependsOn:["ready"],value:0})],et.prototype,"version",null),e([b()],et.prototype,"view",void 0),et=e([S("esri.widgets.Legend.support.ActiveLayerInfo")],et);export{et as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../Color.js";import"../../../intl.js";import{addTokenParameter as s}from"../../../kernel.js";import i from"../../../request.js";import l from"../../../core/Accessor.js";import{isSome as r}from"../../../core/arrayUtils.js";import n from"../../../core/Collection.js";import has from"../../../core/has.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{clamp as u}from"../../../core/mathUtils.js";import{debounce as c}from"../../../core/promiseUtils.js";import{on as d,watch as y,initial as h,whenOnce as m}from"../../../core/reactiveUtils.js";import{px2pt as f}from"../../../core/screenUtils.js";import{parseWhereClause as p}from"../../../core/sql.js";import{addQueryParameters as g}from"../../../core/urlUtils.js";import{property as b}from"../../../core/accessorSupport/decorators/property.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{EffectView as _}from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as w}from"../../../layers/effects/jsonUtils.js";import{getEffectiveDisplayFilter as v}from"../../../layers/support/displayFilterUtils.js";import{ExportImageParameters as L}from"../../../layers/support/ExportImageParameters.js";import{collectFields as E,collectArcadeFieldNames as C}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as F}from"../../../layers/support/layerUtils.js";import{getPixelValueRange as I}from"../../../layers/support/rasterFormats/pixelRangeUtils.js";import{fromJSON as R}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as V}from"../../../renderers/support/rendererConversion.js";import D from"../../../renderers/visualVariables/SizeVariable.js";import x from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{updateReferenceSizeSymbol as z}from"../../../smartMapping/renderers/support/referenceSizeUtils.js";import T from"../../../symbols/SimpleFillSymbol.js";import j from"../../../symbols/SimpleMarkerSymbol.js";import{applyCIMSymbolColor as O}from"../../../symbols/support/cimSymbolUtils.js";import{renderSymbol as P}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as M,renderDotDensityPreviewHTML as A,renderPieChartPreviewHTML as k,renderPreviewHTML as U}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as B}from"../../../symbols/support/utils.js";import{getEffectiveClusterSizeVariable as N}from"./clusterUtils.js";import{getColorFromPointCloudStops as q,getRampStopsForPointCloud as $,getStretchRampStops as H,getRampStops as W}from"./colorRampUtils.js";import{getHeatmapRampStops as G}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as J,getRelationshipRampElement as Q}from"./relationshipRampUtils.js";import{getRampStops as Z,realWorldMaxSize as K,realWorldMinSize as X}from"./sizeRampUtils.js";import{specialCharsLessThan as Y,specialCharsGreaterThan as ee,getAuthoringInfoVisualVariableByTheme as te,getSymbolForFlowRenderer as se,getMedianColor as ie,rgbImgSource as le,getDateFormatOptions as re}from"./utils.js";import{formatNumberLabel as ne}from"../../smartMapping/support/utils.js";import{fetchMessageBundle as ae}from"../../../intl/messages.js";import{substitute as oe}from"../../../intl/substitute.js";const ue=16,ce="https://utility.arcgis.com/sharing/tools/legend",de="esri.layers.ImageryLayer",ye="esri.layers.ImageryTileLayer",he="esri.layers.WCSLayer",me=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,fe=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),pe=new j({size:6,outline:{color:[128,128,128,.5],width:.5}}),ge=new T({style:"solid"});function be(e){return"flow"===e.type}function Se(e){return"vector-field"===e.type}function _e(e){return"raster-colormap"===e.type}function we(e){return"raster-stretch"===e.type}function ve(e){return"raster-shaded-relief"===e.type}function Le(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function Ee(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function Fe(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function Ie(e){return Ve(e)||De(e)||xe(e)||Re(e)}function Re(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function Ve(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function De(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function xe(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function ze(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function Te(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function je(e,t){return Le(e)||Ee(e)||Ce(e)||Fe(e)||ze(e)||Te(e)?"2d"===t.type||V(e):we(e)||_e(e)||ve(e)||Ve(e)||De(e)||xe(e)||Se(e)||be(e)}function Oe(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Pe(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function Me(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Ae(e){return"esri.layers.WMSLayer"===e.declaredClass}function ke(e){return"esri.layers.WMTSLayer"===e.declaredClass}function Ue(e){return"esri.layers.MapImageLayer"===e.declaredClass}function Be(e){return"esri.layers.TileLayer"===e.declaredClass}function Ne(e){return e.declaredClass===de}function qe(e){return e.declaredClass===ye}function $e(e){return e.declaredClass===he}function He(e){return"stretch-ramp"===e.type}function We(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type}function Ge(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}function Je(e){return"sublayers"in e}function Qe(e){return e&&"symbol"in e}async function Ze(e,t){const s=await ae("esri/widgets/Legend/t9n/Legend");return"previewTemplateAriaLabel"!==e||t||(e="previewAriaLabel"),oe(s[e],{label:t})}function Ke(e,t){const{field:s,field2:i,field3:l,fieldDelimiter:r,valueExpression:n}=e;if(!s)return null;const a=!(!s&&!n||!i&&!l)?t?.toString().split(r||""):[t],o=s?{[s]:a?.[0]}:null;return o&&(i&&(o[i]=a?.[1]),l&&(o[l]=a?.[2])),o}const Xe=new j({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let Ye={},et=class extends l{constructor(e){super(e),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._hasClusterSizeVariable=!1,this._layerDefinitionExpression=null,this._layerDefinitionExpressionClause=null,this._layerDisplayFilterId=null,this._layerDisplayFilterClause=null,this.children=new n,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this.addHandles([d(()=>this.children,"change",t=>{const{added:s,removed:i}=t;s.forEach(t=>{const s=`activeLayerInfo-ready-watcher-${t.layer.uid}`;this.addHandles(y(()=>t.ready,e,h),s)}),i.forEach(e=>this.removeHandles(e.layer.uid)),e()})]),this.keepCacheOnDestroy||(Ye={})}destroy(){this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(Ye=null),this._layerDefinitionExpressionClause=null}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new _,t.effect=e.effect,t.endTransition(),t.scale=this.scale),t}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,s=this.layer.parent,i=s&&"uid"in s?this._getParentLayerOpacity(s):null;return null!=t?t*e:null!=i?i*e:e}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view?.scale??0}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?!!("displayFilterInfo"in e&&e.displayFilterInfo&&Ce(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(F(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet?.features.length){const t=e.layerDefinition,s=t?.drawingInfo,i=s&&R(s.renderer),l=fe.read(t.geometryType);return i?this._getRendererLegendElements(i,{title:e.name,geometryType:l}):(o.getLogger(this).warn("drawingInfo not available!"),null)}return null});try{const e=[],s=await Promise.allSettled(t);for(const t of s)if("fulfilled"===t.status)for(const s of t.value??[])e.push(s);this.legendElements=e,this.notifyChange("ready")}catch(s){o.getLogger(this).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).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).warn("error while building legend for layer!",t)}}async buildLegendElementsForTools(){const e=this.layer;if(Me(e))await this._constructLegendElementsForVoxelLayer();else if(ke(e))this._constructLegendElementsForWMTSlayer();else if(Ae(e))await this._constructLegendElementsForWMSSublayers();else if(Oe(e))await this._constructLegendElementsForBuildingSceneLayer();else if(Ue(e)||Be(e)||Pe(e))await this._constructLegendElementsForSublayers();else{this.removeHandles("imageryLayers-watcher");let t="default";if(Ne(e)){const s=e;t=(s?.rasterFunction?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}if(qe(e)||"link-chart"===e.type)return;await this._getLegendLayers(`${e.uid}-${t}`).then(async t=>{this.legendElements=[],this.notifyChange("ready");const s=t.map(async t=>{if(Ne(e)){const t=y(()=>[e.rasterFunction,e.bandIds],()=>c(async()=>{Ye.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()})());this.addHandles(t,"imageryLayers-watcher")}const s=this._generateSymbolTableElementForLegendLayer(t);s?.infos.length&&(Ne(e)&&(s.title=e.title),this.legendElements.push(s)),this.notifyChange("ready")});await Promise.allSettled(s)}).catch(e=>{o.getLogger(this).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 m(()=>!t.updating);const i=s?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();if(!i)return!0;i.geometry=this.view.extent;return 0!==(s?"queryFeatureCount"in t&&await t.queryFeatureCount(i):"queryFeatureCount"in e&&await e.queryFeatureCount(i))}_getParentLayerOpacity(e){let t=1;const s=e.parent;return s&&"uid"in s&&(t=this._getParentLayerOpacity(s)),e.opacity*t}_isGroupActive(){return this.children.some(e=>e.ready)}_isRendererScaleDriven(e){if("dot-density"===e.type)return!0;const t="valueExpression"in e?e.valueExpression:null;if(me.test(t))return!0;const s="visualVariables"in e?e.visualVariables:null;return!!s?.some(e=>this._isScaleDrivenSizeVariable(e))||this._hasScaleDrivenSymbols(e)}_hasScaleDrivenSymbols(e){switch(e.type){case"simple":return this._isScaleDrivenSymbol(e.symbol);case"class-breaks":return this._isScaleDrivenSymbol(e.defaultSymbol)||e.classBreakInfos.some(e=>this._isScaleDrivenSymbol(e.symbol));case"unique-value":return this._isScaleDrivenSymbol(e.defaultSymbol)||!!e.uniqueValueInfos?.some(e=>this._isScaleDrivenSymbol(e.symbol))}return!1}_isScaleDrivenSymbol(e){if("cim"===e?.type){const{primitiveOverrides:t,minScale:s,maxScale:i}=e.data,l=t?.some(e=>(e.valueExpressionInfo?.expression||"").includes("$view.scale"))??!1;return null!=s||null!=i||l}return!1}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,s=t.minSize,i=t.maxSize;return!("object"!=typeof s||!s||!this._isScaleDrivenSizeVariable(s))||(!("object"!=typeof i||!i||!this._isScaleDrivenSizeVariable(i))||me.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&&Ue(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.removeHandles("voxel-style-watcher"),this.removeHandles("voxel-current-variable");const e=this.layer;this.addHandles(y(()=>e.currentVariableId,()=>this._constructLegendElementsForVoxelLayer()),"voxel-current-variable"),this.addHandles(y(()=>e.getVariableStyles(),()=>this._constructLegendElementsForVoxelLayer()),"voxel-style-watcher");const t=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 T({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:i}=t.transferFunction,l=e.toArray().reverse(),r=i.map((e,t)=>`${0===t?Y:ee} ${ne(e)}`).reverse(),n=l.map(e=>({color:e.color,value:null,label:null}));n[0].label=r[0],n[n.length-1].label=r[1],s.push({type:"color-ramp",title:t.label,infos:n,preview:M(l.map(e=>e.color),{ariaLabel:await Ze("previewColorRampAriaLabel")})})}await this._generatePreviewsForLegendElements(s,{opacity:e.opacity}),this.legendElements=s,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this.removeHandles("wmts-activeLayer-watcher");const e=this.layer.activeLayer;this.addHandles(y(()=>{const{layer:e}=this;return e&&"activeLayer"in e&&e.activeLayer},()=>this._constructLegendElementsForWMTSlayer()),"wmts-activeLayer-watcher");const t=e.styleId?e.styles?.find(({id:t})=>t===e.styleId)?.legendUrl:void 0;t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}]),this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this.legendElements=[],this.removeHandles("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this.addHandles(y(()=>{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.layer,i=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForWMSSublayers()),"wms-sublayers-watcher");const l=this.sublayerIds?.map(e=>s.findSublayerById(e))?.filter(r)??[],n=l.length?l:e.toArray();for(const r of n){const e=y(()=>[r.title,r.visible,r.legendEnabled],()=>this._constructLegendElementsForWMSSublayers());if(this.addHandles(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e?.infos.length&&i.unshift(e)}}return i}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 l={type:"symbol-table",title:e.title||e.name||String(e.id??""),infos:[]};t&&(s=g(s,t));let r=null;const n=e.layer?.opacity;try{r=(await i(s,{responseType:"image"})).data,r&&(r.style.opacity=n)}catch{}return l.infos.push({src:s,preview:r,opacity:n}),l}_getLegendLayers(e,t){const s=Ye&&Ye[e];return s?Promise.resolve(s):this._legendRequest(t).then(t=>{const s=t.layers;return Ye[e]=s,s})}_legendRequest(e){const t=this.layer;let s={f:"json",dynamicLayers:e};if(Ne(t)){const e=t.exportImageServiceParameters.rasterFunction;if(e&&(s.renderingRule=JSON.stringify(e.functionDefinition?.toJSON()||e.toJSON())),t.bandIds&&(s.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:i,customParameters:l}=t;s={raster:e,viewId:i,...s,...l}}}let l=t.url.replace(/(\/)+$/,"");if("version"in t&&+t.version>=10.01){const e=l.indexOf("?");e>-1?l=l.slice(0,e)+"/legend"+l.slice(e):l+="/legend"}else{const e=l.toLowerCase().indexOf("/rest/"),t=-1===e?l:l.slice(0,e)+l.slice(e+5);l=ce+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return i(l,{query:s}).then(e=>e.data)}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;this.addHandles(y(()=>e.sublayers,()=>this._constructLegendElementsForBuildingSceneLayer()),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForBuildingSublayers(e,t){let s=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForBuildingSceneLayer()),"sublayers-watcher");const i=e.toArray();for(const l of i){const e=y(()=>["renderer"in l&&l.renderer,l.opacity,l.title,l.visible],()=>this._constructLegendElementsForBuildingSceneLayer());if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||l.visible){const e=null!=l?.opacity?l.opacity:null,i=null!=e?e*t:t;if("building-group"===l.type){const e={type:"symbol-table",title:l.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(l.sublayers,i);e.infos.push(...t),s=[e,...s]}else if(l.renderer){s=[...await this._getRendererLegendElements(l.renderer,{title:l.title,opacity:i,sublayer:l}),...s]}}}return s.filter(e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0))}async _constructLegendElementsForSublayers(){this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;if(Ue(e)||Be(e)||Pe(e)){this.addHandles(y(()=>e.sublayers,()=>this._constructLegendElementsForSublayers),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}}}async _generateLegendElementsForSublayers(e,t,s){const i=this.layer;let l=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForSublayers()),"sublayers-watcher");let n=e.toArray();!s&&this.sublayerIds&&this.sublayerIds.length&&(n=Pe(i)?this.sublayerIds.map(e=>i.findSublayerForSubtypeCode(e)).filter(r):this.sublayerIds.map(e=>i.findSublayerById(e)).filter(r));for(const r of n){const e=y(()=>[r.renderer,r.opacity,r.title,r.visible,r.legendEnabled],()=>this._constructLegendElementsForSublayers());if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled&&this._isSublayerInScale(r)){const e=null!=r?.opacity?r.opacity:null,i=null!=e?e*t:t,n=!Je(r)||r.originIdOf("renderer")>2&&!r.sublayers;if(r.renderer&&n){await r.load();l=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:i,sublayer:r}),...l]}else if(Je(r)){const e=await this._generateSymbolTableElementForSublayer(r,i,s);e&&l.unshift(e)}}}return l.filter(e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0))}async _generateSymbolTableElementForSublayer(e,t,s){if(!s){s=new Map;const t=this.layer,i=e.source;let l=null;if(!(!i||"map-layer"===i.type&&i.mapLayerId===e.id&&(!i.gdbVersion||i.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>2||e.originIdOf("labelingInfo")>2||e.originIdOf("labelsVisible")>2){const e=new L({layer:this.layer});l=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const r=l||`${t.uid}-default`;(await this._getLegendLayers(r,l)).forEach(e=>s.set(e.layerId,e))}const i=s.get(e.id);if((!i||i?.subLayerIds&&i.defaultVisibility)&&e.sublayers){const i=await this._generateLegendElementsForSublayers(e.sublayers,t,s);return{type:"symbol-table",title:e.title,infos:i}}return this._generateSymbolTableElementForLegendLayer(i,e,t)}_generateSymbolTableElementForLegendLayer(e,t,s){if(!e?.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const i=t?.renderer;let l=t?.title||e.layerName;if(i&&(!t||t?.originIdOf("renderer")>2)){const e=t?.title||this._getRendererTitle(i,t);e&&(l&&"string"!=typeof e&&"title"in e&&(e.title=l),l=e)}const r={type:"symbol-table",title:l,legendType:e.legendType||null,infos:[]},n=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return e.legendGroups&&e.legendGroups.length>0?e.legendGroups.forEach(t=>{const i={type:"symbol-table",title:t.heading,legendType:e.legendType||null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter(e=>e.groupId===t.id),e.layerId,s)};i.infos?.length>0&&r.infos.push(i)}):r.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,s),r.infos.length>0?r:null}_generateSymbolTableElementInfosForLegendLayer(e,t,i){return e.map(e=>{let l=e.url;if(e.imageData&&e.imageData.length>0)l=`data:image/png;base64,${e.imageData}`;else{if(0===l.indexOf("http"))return null;l=s(`${this.layer.url}/${t}/images/${l}`)}return{label:e.label,src:l,opacity:i??this.opacity,width:e.width,height:e.height}}).filter(r)}_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 i=null,l=null,r=!0;return!s.minScale&&0!==s.minScale||!s.maxScale&&0!==s.maxScale?(0===e.minScale&&s.tileInfo&&(i=s.tileInfo.lods[0].scale),0===e.maxScale&&s.tileInfo&&(l=s.tileInfo.lods[s.tileInfo.lods.length-1].scale)):(i=Math.min(s.minScale,e.minScale)||s.minScale||e.minScale,l=Math.max(s.maxScale,e.maxScale)),(i>0&&i<this.scale||l>this.scale)&&(r=!1),r}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&+this.layer.version<10.1||0===e.length)return e;const s=t.renderer,i=e.some(e=>e.values);let l=0,r=null;return i&&e.some((e,t)=>(e.values||(l=t,r=e,r.label||(r.label="others")),null!=r)),s?"unique-value"===s.type?r&&(e.splice(l,1),e.push(r)):"class-breaks"===s.type&&(r&&e.splice(l,1),s.legendOptions?.order||e.reverse(),r&&e.push(r)):r&&(e.splice(l,1),e.push(r)),e}async _getRendererLegendElements(e,t={}){if(!je(e,this.view))return o.getLogger(this).warn(`Renderer of type '${e.type}' not supported!`),[];if(Ie(e))return this._constructPointCloudRendererLegendElements(e,t);if(ze(e))return this._constructDotDensityRendererLegendElements(e);const s=await this._loadRenderer(e);return Te(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?.title||e.field)??""}async _constructPointCloudRendererLegendElements(e,t={}){const s=t.title,i=[];let l=null,r=null;if(Ve(e))l={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach(e=>{l.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(pe,e.color)})});else if(De(e)){const t=e.stops;let i=null;if(t?.length&&(1===t.length&&(i=t[0].color),!i)){const e=t[0].value,s=t[t.length-1].value;if(null!=e&&null!=s){i=q(e+(s-e)/2,t)}}l={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(pe,i||pe.color)}]};const n=$(e.stops??[])??[];r={type:"color-ramp",title:s||this._getPointCloudRendererTitle(e),infos:n,preview:M(n.map(e=>e.color),{ariaLabel:await Ze("previewColorRampAriaLabel")})}}else xe(e)&&(l={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos?.forEach(e=>{l.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(pe,e.color)})}));return l?.infos.length&&i.push(l),r?.infos.length&&i.push(r),await this._generatePreviewsForLegendElements(i,{opacity:this.opacity,symbolConfig:{applyColorModulation:!!e.colorModulation}}),i}async _getElementInfoForDotDensity(e,t){const{color:s,label:i,valueExpressionTitle:l}=t,{backgroundColor:r,outline:n,dotSize:a}=e,o=this.effectList,u=o?.effects.map(e=>e.toJSON()),c=w(u),d=await Ze("previewTemplateAriaLabel",i||l),y=a+"-"+s+"-"+r+"-"+(n&&JSON.stringify(n.toJSON()))+"-"+c,h=this._dotDensityUrlCache,m=h.has(y)?h.get(y):A(e,s,{ariaLabel:d});h.set(y,m);const f={shape:{type:"image",x:0,y:0,width:m.width,height:m.height,src:m.src},fill:null,stroke:null,offset:[0,0]},p=P([[f]],[m.width,m.height],{effectView:this.effectList,ariaLabel:d});return{opacity:1,src:m.src,preview:p,width:m.width,height:m.height}}async _constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),s=e.legendOptions?.unit,i={type:"symbol-table",title:{value:t&&Math.round(t),unit:s||""},infos:[]};for(const l of e.attributes){const t=await this._getElementInfoForDotDensity(e,l);t.label=l.label||l.valueExpressionTitle||l.field,i.infos.push(t)}return[i]}async _constructPieChartRendererLegendElements(e){const t=[];let s=null;const i=e.outline;e.attributes.forEach(e=>{const s=new j({color:e.color,outline:i}),l=e.label||e.valueExpressionTitle||e.field;t.push({label:l,symbol:s})});const l=t.length?[...t]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const l=new j({color:e.othersCategory.color,outline:i});s=e.othersCategory.label||"Other",t.push({label:s,symbol:l})}if(e.defaultColor?.a){const s=new j({color:e.defaultColor,outline:i});t.push({label:e.defaultLabel,symbol:s})}const r=await this._getVisualVariableLegendElements(e,this.layer)||[];if(t.length){r.unshift({type:"symbol-table",title:null,infos:t});const n=l.filter(e=>e.label!==s).map(e=>e.symbol.color).filter(Boolean),a=k(n,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,effectList:this.effectList,outline:i,ariaLabel:await Ze("previewPieChartAriaLabel")});r.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:t,preview:a})}return await this._generatePreviewsForLegendElements(r,{opacity:this.layer.opacity,effectView:this.effectList}),r}async _getWhereClause(e,t,s){const i=await p(e,s),l=new Set,{field:r,field2:n,field3:a}=t;E(l,s,[r,n,a]),await C(l,s,t.valueExpression);const o=new Set(Array.from(l,e=>e.toLowerCase())),u=i?.fieldNames.map(e=>e.toLowerCase());return u?.some(e=>!o.has(e))?null:i}async _processDefinitionExpression(e,t){if(!("definitionExpression"in e))return;const s=e.definitionExpression;s&&this.respectLayerDefinitionExpression?this._layerDefinitionExpression!==s&&(this._layerDefinitionExpressionClause=await this._getWhereClause(s,t,e.fieldsIndex)):this._layerDefinitionExpressionClause=null,this._layerDefinitionExpression=s}async _processDisplayFilter(e,t){if(!("displayFilterInfo"in e))return;const s=e.displayFilterInfo?v(e.displayFilterInfo,this.view):null;return s?.where?this._layerDisplayFilterId!==s?.id&&(this._layerDisplayFilterClause=await this._getWhereClause(s.where,t,e.fieldsIndex)):this._layerDisplayFilterClause=null,this._layerDisplayFilterId=s?.id,s}async _constructRendererLegendElements(e,t={}){const{title:s,sublayer:i}=t,l=i||this.layer,r=te(e,"reference-size"),n=te(e,"spike");let a=null;Ce(e)&&(await this._processDefinitionExpression(l,e),a=await this._processDisplayFilter(l,e)),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const o=await this._getVisualVariableLegendElements(e,l)||[],u={type:"symbol-table",title:s||this._getRendererTitle(e,l),infos:[]};let c=null,d=!1;const y=new Set;if(be(e)&&!this._hasSizeRamp){const t=await se(e);u.infos.push({label:null,symbol:t})}else if(We(e)){let t=s;const i=Ge(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",l=o.findIndex(e=>"color-ramp"===e.type),r=-1!==l?o.splice(l,1)[0]:null,n=o.findIndex(e=>"size-ramp"===e.type),a=-1!==n?o.splice(n,1)[0]:null,u=[];r&&(t=r.title,u.push(r)),a&&(t=a.title,u.push(a)),u.length>0&&o.push({type:i,title:t,infos:u})}else if(Fe(e)){const t=G(e);o.push({type:"heatmap-ramp",title:s||this._getRendererTitle(e,l),infos:t,preview:M(t.map(e=>e.color),{effectList:this.effectList,ariaLabel:await Ze("previewColorRampAriaLabel")})})}else if(Ce(e)){const t=e.authoringInfo;if(t&&"relationship"===t.type){const{numClasses:s,field1:i,field2:r}=t,n=t.focus;if(s&&i&&r){const t=[i,r];let a=J(n)||0;for(const e of t){const{field:t,normalizationField:s,label:i}=e,r=i||{field:this._getFieldAlias(t,l),normField:s&&this._getFieldAlias(s,l)},n=Xe.clone();n.angle=a,u.infos.push({label:r,symbol:n}),y.add(n),a+=90}const c=Q({focus:n,numClasses:s,infos:e.uniqueValueInfos??[]});o.unshift(c)}}else if(Ne(this.layer)||qe(this.layer))e.uniqueValueInfos?.forEach(t=>{t.symbol&&this._checkClausesForUVR(e,t.value)&&u.infos.push({label:t.label||t.value,value:t.value,symbol:t.symbol})});else{const{field:t,field2:i,field3:n,fieldDelimiter:o,valueExpression:c,defaultSymbol:y}=e,h=!(!t&&!c||!i&&!n),m=this._layerDisplayFilterClause?a?.title:null,f=[];if(e.uniqueValueGroups?.forEach(s=>{const a={type:"symbol-table",title:m||s.heading,infos:[]};s.classes?.forEach(s=>{const{symbol:u,values:d}=s;if(u){const y=[],m=[];for(const e of d??[]){const{value:s,value2:r,value3:a}=e,u=[],d=[];(t||c)&&(u.push(s),d.push(this._getDomainName(t,s,l))),i&&(u.push(r),d.push(this._getDomainName(i,r,l))),n&&(u.push(a),d.push(this._getDomainName(n,a,l))),y.push(h?u.join(o||""):u[0]),m.push(d.join(" - "))}const f=y.join(", ");let p=s.label;if(!p){const e=m.filter(Boolean);p=e.length?e.join(", "):f}const g=u.clone();"cim"===g.type&&r&&z(g,{innerDotSize:.5*ue,outerRingSize:ue}),y.some(t=>this._checkClausesForUVR(e,t))&&a.infos.push({label:p,value:f,symbol:g})}}),a.infos.length&&f.push(a)}),f.length){const t=f[0];if(1===f.length&&"title"in t&&!t.title){const e=t.infos?.filter(Qe)??[];u.infos.push(...e)}else y&&(f.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:y}]}),d=!0),u.infos.push(...f);s||e.legendOptions?.title||e.valueExpressionTitle||(u.title=null)}}e.defaultSymbol&&!d&&(u.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),d=!0)}else if(Ee(e)){if(!r&&!n){c=this._isUnclassedRenderer(e);if(!c||!this._hasSizeRamp){const t=e.classBreakInfos.filter(({symbol:e})=>e),s="ascending-values"===e.legendOptions?.order;for(const{label:e,minValue:i,maxValue:l,symbol:r}of t){const t={label:e||(c?null:`${i} - ${l}`),value:[i,l],symbol:r};s?u.infos.push(t):u.infos.unshift(t)}c&&(u.title=null),this._updateInfosForClassedSizeRenderer(e,u.infos)}e.defaultSymbol&&!c&&(u.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),d=!0)}}else if(we(e))if(qe(this.layer)||$e(this.layer)){const t=await this._constructTileImageryStretchRendererElements(e);He(t)?o.push(t):u.infos=t}else{const t=this.layer;let s,i;e.customStatistics?.length&&({min:s,max:i}=e.customStatistics[0]);let l=[],r=t.serviceRasterInfo;if(t.rasterFunction)try{r=await t.generateRasterInfo(t.rasterFunction)}catch{}const n=I(r.pixelType);if(1===r.bandCount){const l=t.bandIds?.[0]||0;s=null!=s?s:r.statistics?r.statistics[l].min:n[0],i=null!=i?i:r.statistics?r.statistics[l].max:n[1],s||i?o.push(await this._getStretchLegendElements(e,{min:s,max:i})):this._getServerSideLegend()}else if(t.bandIds&&1===t.bandIds.length)s=null!=s?s:r.statistics?r.statistics[t.bandIds[0]].min:n[0],i=null!=i?i:r.statistics?r.statistics[t.bandIds[0]].max:n[1],s||i?o.push(await this._getStretchLegendElements(e,{min:s,max:i})):this._getServerSideLegend();else if(r.bandCount>=3){const{bandInfos:e}=r,{bandIds:s}=t;e.length>=r.bandCount?3===s?.length?(l=s.map(t=>e[t].name),u.infos=this._createSymbolTableElementMultiBand(l)):"lerc"===t.format?(l=[0,1,2].map(t=>e[t].name),u.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend():"lerc"===t.format?(l=["band1","band2","band3"],u.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend()}else this._getServerSideLegend()}else if(_e(e))e.colormapInfos.forEach(e=>{u.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(ge,e.color)})});else if(Le(e)){let s=e.symbol;switch(t.geometryType){case"point":s="pointSymbol"in l?l.pointSymbol:null;break;case"polyline":s="lineSymbol"in l?l.lineSymbol:null;break;case"polygon":s="polygonSymbol"in l?l.polygonSymbol:null}const i=this._hasClusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&i&&u.infos.push({label:e.label,symbol:s})}else if(Se(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),u.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach(e=>{u.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})}):u.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else ve(e)&&o.push(await this._getStretchLegendElements(e,{min:0,max:255}));const h=e.defaultSymbol;!h||d||Le(e)||c&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||o.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:h}]}),u.infos.length&&o.unshift(u);const m=null==t.opacity?this.opacity:t.opacity,f=this._isTallSymbol("visualVariables"in e?e.visualVariables:null),p=Ne(this.layer)||qe(this.layer);return await this._generatePreviewsForLegendElements(o,{opacity:m,symbolConfig:{isTall:f,isSquareFill:p},effectView:this.effectList},{defaultSymbol:h,arrowMarkerSymbols:y}),e=null,o}_checkClausesForUVR(e,t){const s=Ke(e,t);return!s||(!this._layerDefinitionExpressionClause||this._layerDefinitionExpressionClause.testFeature(s))&&(!this._layerDisplayFilterClause||this._layerDisplayFilterClause.testFeature(s))}_getServerSideLegend(){setTimeout(()=>this.buildLegendElementsForTools(),0)}_getAllInfos(e){const t=e?.infos;return t?t.reduce((e,t)=>e.concat(this._getAllInfos(t)),[]):[e]}async _constructTileImageryStretchRendererElements(e){const t=this.layer,s=t.symbolizer.rasterInfo??t.raster.rasterInfo;let i,l;const r=e?.customStatistics?.length?e.customStatistics:s?.statistics;if(r)({min:i,max:l}=r[0]);else{const e=I(s.pixelType);i=e[0],l=e[1]}if(t.hasStandardTime()&&(i=t.getStandardTimeValue(i),l=t.getStandardTimeValue(l)),1===s.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:i,max:l});const n=(t?.bandIds?.length?t.bandIds:Array.from(Array(Math.min(s.bandCount,3)).keys())).map(e=>s.bandInfos[e].name);return n.length<3?n.push(n[1]):n.length>3&&n.splice(3),this._createSymbolTableElementMultiBand(n)}async _getStretchLegendElements(e,t){const s=e.colorRamp,i=H(s,t);return{type:"stretch-ramp",title:"",infos:i,preview:M(i.map(e=>e.color),{ariaLabel:await Ze("previewColorRampAriaLabel")})}}_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:null}async _getSizeLegendElement(e,t,s,i){return{type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(t):e,infos:await Z(s,t,await ie(s),this.scale,this.view,i,this._hasClusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],s=["red","green","blue"];return e.forEach((e,i)=>{t.push({label:{colorName:s[i],bandName:e},src:le[i],opacity:this.opacity??1})}),t}_updateInfosForClassedSizeRenderer(e,t){const s=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,i=e.classBreakInfos.some(e=>B(e.symbol));if(s&&i){const s=K,i=X,l=e.classBreakInfos.length,r=(s-i)/(l>1?l-1:l);t.forEach((e,t)=>{e.size=s-r*t})}}_isTallSymbol(e){let t=!1,s=!1;if(e)for(let i=0;i<e.length&&(!t||!s);i++){const l=e[i];"size"===l.type&&("height"===l.axis&&(t=!0),"width-and-depth"===l.axis&&(s=!0))}return t&&s}async _generatePreviewsForLegendElements(e,t,s){const i=[];for(const l of e)for(const e of l.infos??[])if("infos"in e&&e.infos&&i.push(this._generatePreviewsForLegendElements([e],t,s)),Qe(e)&&e.symbol&&!e.preview){let r=!0;if("cim"===e.symbol.type){const{minScale:t,maxScale:s}=e.symbol.data;(t&&t<this.scale||s&&s>this.scale)&&(r=!1)}r&&i.push(this._generateSymbolPreviewForInfo(e,{...t,clipBloomEffect:"theme"in l&&"spike"===l.theme,effectView:s?.arrowMarkerSymbols?.has(e.symbol)?null:t.effectView},s?{isDefault:e.symbol===s.defaultSymbol,applyScaleDrivenSize:!s.arrowMarkerSymbols?.has(e.symbol)}:void 0))}await Promise.all(i)}async _generateSymbolPreviewForInfo(e,t,s){try{let i=!s?.isDefault&&null==e.size&&this._hasSizeRamp?f(22):e.size;if(this._scaleDrivenSizeVariable&&s?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");i=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}const l="cim"===e.symbol.type?{style:"legend",cimOptions:{allowScalingUp:!s?.isDefault&&this._hasSizeRamp||!(!this._scaleDrivenSizeVariable||!s?.applyScaleDrivenSize),viewParams:this.isScaleDriven?{viewingMode:"2d"===this.view?.type?"map":this.view?.viewingMode,scale:this.view?.scale}:null}}:{},r=e.label&&"string"!=typeof e.label?null:await Ze("previewTemplateAriaLabel",e.label);e.preview=await U(e.symbol,{size:i,scale:!1,ariaLabel:r,...t,...l})}catch{e.preview=null,o.getLogger(this).warn(`Generating symbol preview failed for symbol type: ${e.symbol?.type}`)}}_getClusterRenderer(e){this._hasClusterSizeVariable=!1;const t="renderer"in this.layer?this.layer.renderer:null,s=e.renderer?.clone()||t?.clone(),i=N(e,this.layerView,this.view);if(i&&null!=s&&"visualVariables"in s){const t=s.visualVariables?.some(e=>"size"===e.type&&"outline"!==e.target&&!me.test(e.valueExpression));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:s}=e;i.legendOptions=new x({showLegend:t!==s})}const t=s.visualVariables||[];s.visualVariables=t.concat([i]),this._hasClusterSizeVariable=!0}}return s}async _loadRenderer(e){const t=[],s=e.clone(),i=await ie(s);if(Ee(s)||Ce(s)){const e=(s.classBreakInfos||s.uniqueValueInfos).map(e=>this._fetchSymbol(e.symbol,i).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:i).then(e=>{this._applySymbolToRenderer(s,e,Le(s))}).catch(()=>{this._applySymbolToRenderer(s,null,Le(s))})),await Promise.allSettled(t),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 i=await e.fetchSymbol({cache:s});return this._getAppliedCloneSymbol(i,t)}catch{throw o.getLogger(this).warn("Fetching web-style failed!"),new Error}}return this._getAppliedCloneSymbol(e,t)}_getAppliedCloneSymbol(e,s){if(!e||!s)return e;const i=e.clone(),l=s&&s.toRgba();return i.type.includes("3d")?this._applyColorTo3dSymbol(i,l):"cim"===i.type?O(i,s):i.color&&(i.color=new t(l||i.color)),i}_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)||"vector-field"===e.type)return null;const s=e.visualVariables??[],i=[],l=[],n=[],a=te(e,"reference-size")??te(e,"spike");let o;if(2===a?.sizeStops?.length&&(Ee(e)||Ce(e))){const[e,t]=a.sizeStops;o=new D({field:a.field??void 0,normalizationField:a.normalizationField,minSize:u(e.size,10,100),maxSize:u(t.size,50,150),minDataValue:e.value,maxDataValue:t.value}),l.push(o)}for(const r of s)"color"===r.type?i.push(r):"size"===r.type?l.push(r):"opacity"===r.type&&n.push(r);const c=[...i,...l,...n];let d,y;if(0===i.length&&Ee(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];d=t&&t.symbol}if(0===i.length&&Le(e)&&(d=e.symbol),d)if(d.type.includes("3d")){const e=d.symbolLayers.at(0);"water"===e.type?null!=e.color&&(y=e.color):null!=e.material?.color&&(y=e.material.color)}else d.url||(y=d.color);const h=this.effectList;return(await Promise.all(c.map(async s=>{if(!s.legendOptions||!1!==s.legendOptions.showLegend){const i=be(e)?s.field:this._getRampTitle(s,t);let l=null;const r=re(t,s,this.view.timeZone);if("color"===s.type){const e=await W(s,null,r)??[];l={type:"color-ramp",title:i,infos:e,preview:M(e.map(e=>e.color),{effectList:h,ariaLabel:await Ze("previewColorRampAriaLabel")})},this._hasColorRamp||(this._hasColorRamp=e.length>0)}else if("size"===s.type&&"outline"!==s.target)me.test(s.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=s):(l=await this._getSizeLegendElement(i,s,e,r),o===s&&"spike"===a?.theme&&(l.theme=a.theme),this._hasSizeRamp||(this._hasSizeRamp=!(null==l.infos||!l.infos.length)));else if("opacity"===s.type){const e=await W(s,y,r)??[];l={type:"opacity-ramp",title:i,infos:e,preview:M(e.map(e=>e.color),{effectList:h,ariaLabel:await Ze("previewColorRampAriaLabel")})},this._hasOpacityRamp||(this._hasOpacityRamp=e.length>0)}return l?.infos?l:null}}))).filter(r)}_getDomainName(e,t,s){if(e&&"function"!=typeof e){const i="getField"in s&&s.getField?.(e),l=i&&"getFieldDomain"in s&&s.getFieldDomain?s.getFieldDomain(i.name,{excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")}):null;return"coded-value"===l?.type?l.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,i="popupTemplate"in e&&e.popupTemplate,l=i&&i.fieldInfos;if(l)for(const t of l)if(t.fieldName===s)return"cluster_count"===s?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let s=e.field,i=e.normalizationField,l=!1,r=!1,n=!1,a=null;s="function"==typeof s?null:s,i="function"==typeof i?null:i;const o=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?.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){l=!0;break}if("percent"===s.style){r=!0;break}if("percent-of-total"===s.style){n=!0;break}}}}a={field:s&&this._getFieldAlias(s,t),normField:i&&this._getFieldAlias(i,t),ratio:l,ratioPercent:r,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const s=e;if(s.legendOptions?.title)return s.legendOptions.title;if(s.valueExpressionTitle)return s.valueExpressionTitle;let i=s.field,l=null,r=null;if(Ee(s)&&(l=s.normalizationField,r="percent-of-total"===s.normalizationType),i="function"==typeof i?null:i,l="function"==typeof l?null:l,Ce(s)){const{field2:e,field3:l,fieldDelimiter:r}=s;let n=i&&this._getFieldAlias(i,t);return e&&(n=`<${n}>${r}<${this._getFieldAlias(e,t)}>`,l&&(n=`${n}${r}<${this._getFieldAlias(l,t)}>`)),n}let n=null;return(i||l)&&(n={field:i&&this._getFieldAlias(i,t),normField:l&&this._getFieldAlias(l,t),normByPct:r}),n}_getFieldAlias(e,t){const s="popupTemplate"in t?t.popupTemplate:null,i=s?.fieldInfos;let l=i?.find(t=>e===t.fieldName),r=null;"getField"in t&&t.getField?r=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(r=t.fieldsIndex.get(e));let n=null;const a="featureReduction"in t&&t.featureReduction;a&&(l??="popupTemplate"in a?a.popupTemplate?.fieldInfos?.find(t=>e?.toLowerCase()===t.fieldName?.toLowerCase()):void 0,"fields"in a&&a.fields&&(n=a.fields.find(t=>t.name?.toLowerCase()===e?.toLowerCase())));const o=l||r||n;let u=null;return o&&(u=l?.label||r?.alias||n?.alias||"name"in o&&o.name||"fieldName"in o&&o.fieldName||null),u}_isUnclassedRenderer(e){const t=e.visualVariables;let s=!1;return Ee(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([b()],et.prototype,"children",void 0),e([b({readOnly:!0})],et.prototype,"effectList",null),e([b()],et.prototype,"layerView",void 0),e([b()],et.prototype,"layer",void 0),e([b()],et.prototype,"legendElements",void 0),e([b({readOnly:!0})],et.prototype,"opacity",null),e([b()],et.prototype,"parent",void 0),e([b({readOnly:!0,dependsOn:[]})],et.prototype,"ready",null),e([b()],et.prototype,"hideLayersNotInCurrentView",void 0),e([b()],et.prototype,"keepCacheOnDestroy",void 0),e([b()],et.prototype,"respectLayerDefinitionExpression",void 0),e([b()],et.prototype,"respectLayerVisibility",void 0),e([b({readOnly:!0})],et.prototype,"scale",null),e([b()],et.prototype,"sublayerIds",void 0),e([b({readOnly:!0})],et.prototype,"isScaleDriven",null),e([b()],et.prototype,"title",void 0),e([b({readOnly:!0,dependsOn:["ready"],value:0})],et.prototype,"version",null),e([b()],et.prototype,"view",void 0),et=e([S("esri.widgets.Legend.support.ActiveLayerInfo")],et);export{et 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{loadCalciteComponents as s}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{tsx as
|
|
5
|
+
import{__decorate as e}from"tslib";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{loadCalciteComponents as s}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{tsx as l}from"../support/jsxFactory.js";import r from"./ValuePickerBaseComponent.js";const i="esri-value-picker__combobox";let a=class extends r{constructor(e,t){super(e,t),this.items=null,this.placeholder=null,this.type="combobox"}loadDependencies(){return s({combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item")})}get canNext(){return!(!this.items||!this.viewModel)&&this.items.findIndex(({value:e})=>e===this.viewModel.values?.[0])!==this.items.length-1}get canPlay(){return null!=this.viewModel&&!!this.items?.length}get canPrevious(){const{items:e,viewModel:t}=this;return!(!e||!t)&&0!==e.findIndex(({value:e})=>e===t.values?.[0])}get label(){return super.label}set label(e){super.label=e}render(){const{viewModel:e}=this;if(null==e)return l("div",null);const t=e.values?.[0];return l("div",{class:i},l("calcite-combobox",{disabled:e.disabled,label:this.label,maxItems:10,overlayPositioning:"fixed",placeholder:this.placeholder??void 0,selectionMode:"single",onCalciteComboboxChange:t=>{Array.isArray(t.currentTarget.value)||(null!=e.values?e.values[0]!==t.currentTarget.value&&(e.values=[t.currentTarget.value]):e.values=[t.currentTarget.value])}},this.items?.map(({value:e,label:o},s)=>l("calcite-combobox-item",{key:s,selected:e===t,textLabel:o,value:e}))))}animate(e){this._step(1,e)}next(){this._step(1)}previous(){this._step(-1)}_step(e,t=!1){const{viewModel:o,items:s}=this;if(!s?.length||!o)return;if(!o.values)return void(o.values=[s[0].value]);const l=s.findIndex(({value:e})=>e===o.values[0]);if(-1===l)return void(o.values=[s[0].value]);const r=l+e;r<0||r>=s.length?o.loop||t?o.values=[s[1===e?0:s.length-1].value]:"playing"===o.state&&o.pause():o.values=[s[r].value]}};e([t()],a.prototype,"canNext",null),e([t()],a.prototype,"canPlay",null),e([t()],a.prototype,"canPrevious",null),e([t()],a.prototype,"items",void 0),e([t()],a.prototype,"placeholder",void 0),e([t()],a.prototype,"type",void 0),a=e([o("esri.widgets.ValuePicker.ValuePickerCombobox")],a);const n=a;export{n as default};
|