@arcgis/core 4.34.0-next.43 → 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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/08840c4d3df711065571.js +1 -0
- package/assets/esri/core/workers/chunks/{b85dbefdb09bc6c99e0d.js → 2aac5d560e4c5defe882.js} +1 -1
- package/assets/esri/core/workers/chunks/{68a69d3fcad6febf55f6.js → 349da65a8793f7873366.js} +6 -6
- package/assets/esri/core/workers/chunks/4622a3e64d3c4aafa56b.js +1 -0
- package/assets/esri/core/workers/chunks/{9aa84b86262fa8334bc4.js → 48514235c32917e43a3f.js} +44 -44
- package/assets/esri/core/workers/chunks/7b560ac0be93c6aa9940.js +1 -0
- package/assets/esri/core/workers/chunks/863e87ac982d7727b435.js +1 -0
- package/assets/esri/core/workers/chunks/{d5d2d4df407cf078bb81.js → 97fc21355efc7b289f3b.js} +1 -1
- package/assets/esri/core/workers/chunks/9d9a7333a968065b53a1.js +1 -0
- package/assets/esri/core/workers/chunks/{615915e7c48f0a3d0060.js → d547b27ac750953a998f.js} +1 -1
- package/assets/esri/core/workers/chunks/dbc9bb3011f16ce33f71.js +1 -0
- package/assets/esri/core/workers/chunks/eafc4da265469e9e5e0b.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/i3s.js +1 -1
- package/config.js +1 -1
- package/kernel.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/TemporalSceneLayer.js +1 -1
- package/layers/support/rasterDatasets/multipartParser.js +1 -1
- package/package.json +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/rest/knowledgeGraph/wasmInterface/knowledgeWasmAccess.js +1 -1
- package/rest/support/AlgorithmicColorRamp.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/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/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.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/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +5 -5
- 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/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
- package/views/SelectionManager.js +1 -1
- package/webscene/spec-certification/compare.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.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/016d421114118307d4dd.js +0 -1
- package/assets/esri/core/workers/chunks/345ed9ac44e47355803e.js +0 -1
- package/assets/esri/core/workers/chunks/6b73926feb5c5d957062.js +0 -1
- package/assets/esri/core/workers/chunks/98ac849cccc4d5316021.js +0 -1
- package/assets/esri/core/workers/chunks/c47227a626edc1e1ecf1.js +0 -1
- package/assets/esri/core/workers/chunks/c474800508e3ad5ce9d7.js +0 -1
- package/assets/esri/core/workers/chunks/fb84fa28978a1820a725.js +0 -1
- package/views/3d/support/flow/StreamlinesResources3D.js +0 -5
|
@@ -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 t from"../../../core/Accessor.js";import r from"../../../core/Collection.js";import o from"../../../core/Logger.js";import{removeMaybe as i,abortMaybe as s}from"../../../core/maybe.js";import{ignoreAbortErrors as a,debounce as l,whenOrTimeout as n}from"../../../core/promiseUtils.js";import{watch as c,on as h,whenOnce as p}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as g}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as m,isSubtypeSublayer as u}from"../../../layers/support/layerUtils.js";import{isSelectableLayer as f}from"../../../views/support/selectionUtils.js";import{goTo as v}from"../goToUtils.js";import _ from"./GroupLayerItem.js";import I from"./LayerItem.js";import{computeEffectiveCount as b,getNestedLayerItems as C,isLayerItem as S,isGroupLayerItem as L,getNestedFeatureItems as w}from"./selectionListUtils.js";const M=100;let H=class extends t{constructor(e){super(e),this._allLayerItems=null,this._groupItemCache=new Map,this._hoverHighlightHandle=null,this._layerEditAbortControllers=new Map,this._layerEditHandles=new r,this._layerItemCache=new Map,this._onChangeAbortController=null,this._updatingHandles=new d,this.filterText=void 0,this.layer=null,this.maxVisibleFeatureCountPerLayer=500,this.selectionManager=null,this._onSelectionChangeController=async()=>{this._cancelOnSelectionChange();const e=new AbortController;this._onChangeAbortController=e,await this._updatingHandles.addPromise(a(this._generateListItems(e))),this._onChangeAbortController===e&&(this._onChangeAbortController=null);const t=this.layer&&this.effectiveSelectionManager?.getSelection(this.layer);t?.length||(this.layer=null)},this._cancelOnSelectionChange=()=>this._onChangeAbortController?.abort(),this._onSelectionChangeDebounced=l(this._onSelectionChangeController,M),this._cancelOnLayerEdit=e=>this._layerEditAbortControllers.get(e)?.abort()}initialize(){this.addHandles([c(()=>[this.view,this.effectiveSelectionManager,...this._sources],()=>{this._onSelectionChange(),this._refreshLayerEditHandles()}),h(()=>this.effectiveSelectionManager?.sources,"change",()=>{this._onSelectionChange(),this._refreshLayerEditHandles()}),h(()=>this.effectiveSelectionManager,"selection-change",()=>this._onSelectionChange())])}destroy(){this._cancelOnSelectionChange(),this.removeTemporaryHighlight(),this._updatingHandles.destroy(),this._layerEditHandles.drain(i),this._layerEditAbortControllers.forEach(s)}get _sources(){return this.effectiveSelectionManager?.sources.toArray()??[]}get activeLayerItem(){const{layer:e}=this;return e&&this.layerItems.find(t=>t.layer===e)}get allLayerItems(){return this._allLayerItems??[]}get effectiveCount(){return b(this.allLayerItems)}get effectiveSelectionManager(){return this.selectionManager??this.view?.selectionManager}get isUpdating(){return!(!this._onChangeAbortController&&!this._updatingHandles.updating)}get layerItems(){return C(this.allLayerItems)}get layerViewMap(){const e=new Map,{view:t}=this;if(!t)return e;for(const r of t.allLayerViews)if(e.set(r.layer.id,r),m(r.layer))for(const t of r.layer.sublayers)e.set(t.id,r);return e}get maxVisibleFeatureCountExceeded(){return this.allLayerItems.some(e=>e.maxVisibleFeatureCountExceeded)}get state(){const{view:e}=this;return e?e.ready?this.effectiveSelectionManager?"ready":"error":"loading":"disabled"}get viewLayersAndTables(){const{view:e}=this;return e?.map?[...e.map.layers.toArray().reverse(),...e.map.tables.toArray().reverse()]:[]}get visibleFeatureCount(){return this.activeLayerItem?.visibleTotal??this.visibleFeatureItems.length}get visibleFeatureItems(){return this.layerItems.flatMap(e=>e.featureItems.filter(e=>e.visible))}get visibleLayerCount(){const{effectiveSelectionManager:e}=this;return e&&0!==e.count?1===e.count||this.activeLayerItem?1:this.layerItems.filter(e=>e.visible).length:0}addTemporaryHighlight({graphic:e,layerView:t}){this.removeTemporaryHighlight(),t&&e&&(this._hoverHighlightHandle=t.highlight(e,{name:"temporary"}))}clear(){this.effectiveSelectionManager?.clear()}deselectFeatureItem(e){const t=e.graphic.getObjectId();null!=t&&this.effectiveSelectionManager?.removeFromSelection(e.layer,[t])}deselectGroupItem(e){e.items.forEach(e=>{S(e)?this.deselectLayerItem(e):this.deselectGroupItem(e)})}deselectLayerItem(e){this.effectiveSelectionManager?.setSelection(e.layer,[])}deselectItem(e){L(e)?this.deselectGroupItem(e):S(e)?this.deselectLayerItem(e):this.deselectFeatureItem(e)}goToItem(e){S(e)||L(e)?this._goTo(w([e]).map(e=>e.graphic)):this._goTo(e.graphic)}layersToItems(e){const{controller:t,groupLayerItem:r,layers:o,promises:i}=e,{_groupItemCache:s,_layerItemCache:a,effectiveSelectionManager:l,viewLayersAndTables:n}=this,c=o??n;if(!l||0===l.count)return[];const h=[];for(const p of c)switch(p.type){case"subtype-group":case"group":{const e=s.get(p),r=e??new _({layer:p,viewModel:this});e||s.set(p,r),i.push(r.sync({controller:t,promises:i})),h.push(r)}break;default:if(f(p)||u(p)){const e=p,o=l.getSelection(e);if(!o?.length)continue;const s=a.get(e),n=s??new I({groupLayerItem:r,layer:e,viewModel:this});s||a.set(e,n),i.push(n.sync({controller:t,promises:i})),h.push(n)}}return h}removeFromSelection(e){this.effectiveSelectionManager?.removeFromSelection(e.layer,e.objectIds)}removeTemporaryHighlight(){this._hoverHighlightHandle=i(this._hoverHighlightHandle)}selectSingleFeatureItem(e){const t=e.objectId;if(null!=t&&this.effectiveSelectionManager)for(const{layer:r}of this.effectiveSelectionManager.selections)this.setSelection({layer:r,objectIds:r===e.layer?[t]:[]})}selectSingleGroupItem(e){if(this.effectiveSelectionManager)for(const{layer:t,selection:r}of this.effectiveSelectionManager.selections)this.setSelection({layer:t,objectIds:t.parent===e.layer?r:[]})}selectSingleItem(e){L(e)?this.selectSingleGroupItem(e):S(e)?this.selectSingleLayerItem(e):this.selectSingleFeatureItem(e)}selectSingleLayerItem(e){if(this.effectiveSelectionManager)for(const{layer:t,selection:r}of this.effectiveSelectionManager.selections)this.setSelection({layer:t,objectIds:t===e.layer?r:[]})}setSelection(e){this.effectiveSelectionManager?.setSelection(e.layer,e.objectIds)}async _goTo(e){const{view:t}=this;if(t)try{await v(t,e)}catch(r){"AbortError"!==r.name&&o.getLogger(this).warn("Failed to go to feature(s)",r)}}async _generateListItems(e){try{this.removeTemporaryHighlight();const t=[],r=this.layersToItems({controller:e,promises:t});t.length>0&&await Promise.all(t),this._onChangeAbortController===e&&(this._allLayerItems=r)}catch(t){o.getLogger(this).warn("Failed updating selection",t)}}_onSelectionChange(){a(this._onSelectionChangeDebounced())}_refreshLayerEditHandles(){const{effectiveSelectionManager:e}=this;if(this._layerEditHandles.drain(i),!e?.sources.length)return;const t=new Set(e.sources.map(e=>u(e)?e.parent:e));for(const r of t)f(r)&&"on"in r&&this._layerEditHandles.push(r.on("edits",e=>this._onLayerEdit(e,r)))}async _onLayerEdit(e,t){try{if(this.removeTemporaryHighlight(),this._cancelOnLayerEdit(t),!e.updatedFeatures.some(e=>null!=e.objectId&&!e.error))return;const r=new AbortController;this._layerEditAbortControllers.set(t,r);const o="subtype-group"===t.type?this.allLayerItems.find(e=>e.layer===t):this.layerItems.find(e=>e.layer===t);if(o?.layerView){const e=o.layerView;if(await this._onLayerViewUpdate(e),r.signal.aborted)return;o.reset(),this._onSelectionChange()}this._layerEditAbortControllers.get(t)===r&&this._layerEditAbortControllers.delete(t)}catch(r){o.getLogger(this).warn("Failed updating selected features",r)}}async _onLayerViewUpdate(e){await n(p(()=>e.updating),2e3),await p(()=>!e.updating)}};e([y()],H.prototype,"_allLayerItems",void 0),e([y()],H.prototype,"_groupItemCache",void 0),e([y()],H.prototype,"_hoverHighlightHandle",void 0),e([y()],H.prototype,"_layerEditAbortControllers",void 0),e([y()],H.prototype,"_layerEditHandles",void 0),e([y()],H.prototype,"_layerItemCache",void 0),e([y()],H.prototype,"_onChangeAbortController",void 0),e([y()],H.prototype,"_sources",null),e([y()],H.prototype,"_updatingHandles",void 0),e([y()],H.prototype,"activeLayerItem",null),e([y()],H.prototype,"allLayerItems",null),e([y()],H.prototype,"effectiveCount",null),e([y()],H.prototype,"effectiveSelectionManager",null),e([y()],H.prototype,"filterText",void 0),e([y()],H.prototype,"isUpdating",null),e([y()],H.prototype,"layer",void 0),e([y()],H.prototype,"layerItems",null),e([y()],H.prototype,"layerViewMap",null),e([y()],H.prototype,"maxVisibleFeatureCountExceeded",null),e([y()],H.prototype,"maxVisibleFeatureCountPerLayer",void 0),e([y()],H.prototype,"selectionManager",void 0),e([y()],H.prototype,"state",null),e([y()],H.prototype,"view",void 0),e([y()],H.prototype,"viewLayersAndTables",null),e([y()],H.prototype,"visibleFeatureCount",null),e([y()],H.prototype,"visibleFeatureItems",null),e([y()],H.prototype,"visibleLayerCount",null),H=e([g("esri.widgets.support.SelectionList.SelectionListViewModel")],H);const j=H;export{j as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import r from"../../../core/Collection.js";import o from"../../../core/Logger.js";import{removeMaybe as i,abortMaybe as s}from"../../../core/maybe.js";import{ignoreAbortErrors as a,debounce as l,whenOrTimeout as n}from"../../../core/promiseUtils.js";import{watch as c,on as h,whenOnce as p}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as g}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as m,isSubtypeSublayer as u}from"../../../layers/support/layerUtils.js";import{isSelectableLayer as f}from"../../../views/support/selectionUtils.js";import{goTo as v}from"../goToUtils.js";import _ from"./GroupLayerItem.js";import I from"./LayerItem.js";import{computeEffectiveCount as b,getNestedLayerItems as C,isLayerItem as S,isGroupLayerItem as L,getNestedFeatureItems as w}from"./selectionListUtils.js";const M=100;let H=class extends t{constructor(e){super(e),this._allLayerItems=null,this._groupItemCache=new Map,this._hoverHighlightHandle=null,this._layerEditAbortControllers=new Map,this._layerEditHandles=new r,this._layerItemCache=new Map,this._onChangeAbortController=null,this._updatingHandles=new d,this.filterText=void 0,this.layer=null,this.maxVisibleFeatureCountPerLayer=500,this.selectionManager=null,this._onSelectionChangeController=async()=>{this._cancelOnSelectionChange();const e=new AbortController;this._onChangeAbortController=e,await this._updatingHandles.addPromise(a(this._generateListItems(e))),this._onChangeAbortController===e&&(this._onChangeAbortController=null);const t=this.layer&&this.effectiveSelectionManager?.getSelection(this.layer);t?.length||(this.layer=null)},this._cancelOnSelectionChange=()=>this._onChangeAbortController?.abort(),this._onSelectionChangeDebounced=l(this._onSelectionChangeController,M),this._cancelOnLayerEdit=e=>this._layerEditAbortControllers.get(e)?.abort()}initialize(){this.addHandles([c(()=>[this.view,this.effectiveSelectionManager,...this._sources],()=>{this._onSelectionChange(),this._refreshLayerEditHandles()}),h(()=>this.effectiveSelectionManager?.sources,"change",()=>{this._onSelectionChange(),this._refreshLayerEditHandles()}),h(()=>this.effectiveSelectionManager,"selection-change",()=>this._onSelectionChange())])}destroy(){this._cancelOnSelectionChange(),this.removeTemporaryHighlight(),this._updatingHandles.destroy(),this._layerEditHandles.drain(i),this._layerEditAbortControllers.forEach(s)}get _sources(){return this.effectiveSelectionManager?.sources.toArray()??[]}get activeLayerItem(){const{layer:e}=this;return e&&this.layerItems.find(t=>t.layer===e)}get allLayerItems(){return this._allLayerItems??[]}get effectiveCount(){return b(this.allLayerItems)}get effectiveSelectionManager(){return this.selectionManager??this.view?.selectionManager}get isUpdating(){return!(!this._onChangeAbortController&&!this._updatingHandles.updating)}get layerItems(){return C(this.allLayerItems)}get layerViewMap(){const e=new Map,{view:t}=this;if(!t)return e;for(const r of t.allLayerViews)if(e.set(r.layer.id,r),m(r.layer))for(const t of r.layer.sublayers)e.set(t.id,r);return e}get maxVisibleFeatureCountExceeded(){return this.allLayerItems.some(e=>e.maxVisibleFeatureCountExceeded)}get state(){const{view:e}=this;return e?e.ready?this.effectiveSelectionManager?"ready":"error":"loading":"disabled"}get viewLayersAndTables(){const{view:e}=this;return e?.map?[...e.map.layers.toArray().reverse(),...e.map.tables.toArray().reverse()]:[]}get visibleFeatureCount(){return this.activeLayerItem?.visibleTotal??this.visibleFeatureItems.length}get visibleFeatureItems(){return this.layerItems.flatMap(e=>e.featureItems.filter(e=>e.visible))}get visibleLayerCount(){const{effectiveSelectionManager:e}=this;return e&&0!==e.count?1===e.count||this.activeLayerItem?1:this.layerItems.filter(e=>e.visible).length:0}addTemporaryHighlight({graphic:e,layerView:t}){this.removeTemporaryHighlight(),t&&e&&(this._hoverHighlightHandle=t.highlight(e,{name:"temporary"}))}clear(){this.effectiveSelectionManager?.clear()}deselectFeatureItem(e){const t=e.graphic.getObjectId();null!=t&&this.effectiveSelectionManager?.removeFromSelection(e.layer,[t])}deselectGroupItem(e){e.items.forEach(e=>{S(e)?this.deselectLayerItem(e):this.deselectGroupItem(e)})}deselectLayerItem(e){this.effectiveSelectionManager?.setSelection(e.layer,[])}deselectItem(e){L(e)?this.deselectGroupItem(e):S(e)?this.deselectLayerItem(e):this.deselectFeatureItem(e)}goToItem(e){S(e)||L(e)?this._goTo(w([e]).map(e=>e.graphic)):this._goTo(e.graphic)}layersToItems(e){const{controller:t,groupLayerItem:r,layers:o,promises:i}=e,{_groupItemCache:s,_layerItemCache:a,effectiveSelectionManager:l,viewLayersAndTables:n}=this,c=o??n;if(!l||0===l.count)return[];const h=[];for(const p of c)switch(p.type){case"subtype-group":case"group":{const e=s.get(p),r=e??new _({layer:p,viewModel:this});e||s.set(p,r),i.push(r.sync({controller:t,promises:i})),h.push(r)}break;default:if(f(p)||u(p)){const e=p,o=l.getSelection(e);if(!o?.length)continue;const s=a.get(e),n=s??new I({groupLayerItem:r,layer:e,viewModel:this});s||a.set(e,n),i.push(n.sync({controller:t,promises:i})),h.push(n)}}return h}removeFromSelection(e){this.effectiveSelectionManager?.removeFromSelection(e.layer,e.objectIds)}removeTemporaryHighlight(){this._hoverHighlightHandle=i(this._hoverHighlightHandle)}selectSingleFeatureItem(e){const t=e.objectId;if(null!=t&&this.effectiveSelectionManager)for(const{layer:r}of this.effectiveSelectionManager.selections)this.setSelection({layer:r,objectIds:r===e.layer?[t]:[]})}selectSingleGroupItem(e){if(this.effectiveSelectionManager)for(const{layer:t,selection:r}of this.effectiveSelectionManager.selections)this.setSelection({layer:t,objectIds:t.parent===e.layer?r:[]})}selectSingleItem(e){L(e)?this.selectSingleGroupItem(e):S(e)?this.selectSingleLayerItem(e):this.selectSingleFeatureItem(e)}selectSingleLayerItem(e){if(this.effectiveSelectionManager)for(const{layer:t,selection:r}of this.effectiveSelectionManager.selections)this.setSelection({layer:t,objectIds:t===e.layer?r:[]})}setSelection(e){this.effectiveSelectionManager?.setSelection(e.layer,e.objectIds)}async _goTo(e){const{view:t}=this;if(t)try{await v(t,e)}catch(r){"AbortError"!==r.name&&o.getLogger(this).warn("Failed to go to feature(s)",r)}}async _generateListItems(e){try{this.removeTemporaryHighlight();const t=[],r=this.layersToItems({controller:e,promises:t});t.length>0&&await Promise.all(t),this._onChangeAbortController===e&&(this._allLayerItems=r)}catch(t){o.getLogger(this).warn("Failed updating selection",t)}}_onSelectionChange(){a(this._onSelectionChangeDebounced())}_refreshLayerEditHandles(){const{effectiveSelectionManager:e}=this;if(this._layerEditHandles.drain(i),!e?.sources.length)return;const t=new Set(e.sources.map(e=>u(e)?e.parent:e));for(const r of t)f(r)&&"on"in r&&this._layerEditHandles.push(r.on("edits",e=>{this._onLayerEdit(e,r)}))}async _onLayerEdit(e,t){try{if(this.removeTemporaryHighlight(),this._cancelOnLayerEdit(t),!e.updatedFeatures.some(e=>null!=e.objectId&&!e.error))return;const r=new AbortController;this._layerEditAbortControllers.set(t,r);const o="subtype-group"===t.type?this.allLayerItems.find(e=>e.layer===t):this.layerItems.find(e=>e.layer===t);if(o?.layerView){const e=o.layerView;if(await this._onLayerViewUpdate(e),r.signal.aborted)return;o.reset(),this._onSelectionChange()}this._layerEditAbortControllers.get(t)===r&&this._layerEditAbortControllers.delete(t)}catch(r){o.getLogger(this).warn("Failed updating selected features",r)}}async _onLayerViewUpdate(e){await n(p(()=>e.updating),2e3),await p(()=>!e.updating)}};e([y()],H.prototype,"_allLayerItems",void 0),e([y()],H.prototype,"_groupItemCache",void 0),e([y()],H.prototype,"_hoverHighlightHandle",void 0),e([y()],H.prototype,"_layerEditAbortControllers",void 0),e([y()],H.prototype,"_layerEditHandles",void 0),e([y()],H.prototype,"_layerItemCache",void 0),e([y()],H.prototype,"_onChangeAbortController",void 0),e([y()],H.prototype,"_sources",null),e([y()],H.prototype,"_updatingHandles",void 0),e([y()],H.prototype,"activeLayerItem",null),e([y()],H.prototype,"allLayerItems",null),e([y()],H.prototype,"effectiveCount",null),e([y()],H.prototype,"effectiveSelectionManager",null),e([y()],H.prototype,"filterText",void 0),e([y()],H.prototype,"isUpdating",null),e([y()],H.prototype,"layer",void 0),e([y()],H.prototype,"layerItems",null),e([y()],H.prototype,"layerViewMap",null),e([y()],H.prototype,"maxVisibleFeatureCountExceeded",null),e([y()],H.prototype,"maxVisibleFeatureCountPerLayer",void 0),e([y()],H.prototype,"selectionManager",void 0),e([y()],H.prototype,"state",null),e([y()],H.prototype,"view",void 0),e([y()],H.prototype,"viewLayersAndTables",null),e([y()],H.prototype,"visibleFeatureCount",null),e([y()],H.prototype,"visibleFeatureItems",null),e([y()],H.prototype,"visibleLayerCount",null),H=e([g("esri.widgets.support.SelectionList.SelectionListViewModel")],H);const j=H;export{j as default};
|
package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.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 t}from"tslib";import e from"../../../Graphic.js";import o from"../../../core/Accessor.js";import{ClonableMixin as r}from"../../../core/Clonable.js";import s from"../../../core/Collection.js";import{IdentifiableMixin as i}from"../../../core/Identifiable.js";import{getOrCreateMapValue as a}from"../../../core/MapUtils.js";import{ignoreAbortErrors as n,debounce as c}from"../../../core/promiseUtils.js";import l from"../../../core/ReactiveMap.js";import{watch as u,initial as y}from"../../../core/reactiveUtils.js";import{sqlIn as d}from"../../../core/sql.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{queryAllJSON as m}from"../../../layers/support/featureQueryAll.js";import{isSubtypeSublayer as g,isSubtypeGroupLayer as _}from"../../../layers/support/layerUtils.js";import w from"../../../rest/networks/support/NetworkElement.js";import b from"../../../rest/support/FeatureSet.js";import A from"../../../rest/support/Query.js";import{featureUtilityNetworkFields as F}from"../../Feature/FeatureUtilityNetworkAssociations/resources.js";import{findUtilityNetwork as f}from"../../Feature/support/featureUtils.js";import{getFeatureTitle as C}from"./utils/getFeatureTitle.js";const I=100;let v=class extends(r(i(o))){constructor(t){super(t),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.networkSourceIdsInUse=new Set,this.source="popup",this.description=null,this.graphic=null,this.layer=null,this.map=null,this.featureCount=0,this.associationTypes=null,this.showAllEnabled=!1,this.title=null,this.attachmentsFeatureCount=0,this.structureFeatureCount=0,this.contentFeatureCount=0,this.containerFeatureCount=0,this.connectivityFeatureCount=0,this._queryOpenAssociationType=async()=>{this.activeAssociationType&&await this._queryDebounced(this.activeAssociationType)},this._cancelQuery=()=>{const{_queryAbortController:t}=this;t&&t.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:t}=this;t&&t.abort(),this._queryFeatureCountAbortController=null},this._queryController=async t=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await n(this._query(t)),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const t=new AbortController;this._queryFeatureCountAbortController=t,await n(this._queryFeatureCount()),this._queryFeatureCountAbortController===t&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryDebounced=c(this._queryController,I),this._queryFeatureCountDebounced=c(this._queryFeatureCountController,I)}initialize(){this.addHandles([u(()=>[this.graphic,this.layer,this.map,this.associationTypes,this.objectId,this.globalId,this.canQuery],()=>this.refresh(),y),u(()=>this.activeAssociationType,t=>this._queryDebounced(t),y)])}destroy(){this._cancelQuery(),this._cancelQueryFeatureCount(),this._destroyAssociatedFeatureViewModels()}get supportsCacheHint(){return!!this.layer?.capabilities?.query?.supportsCacheHint}get canLoad(){return!!this.map&&!!this.associationTypes&&"string"==typeof this.globalId}get canQuery(){const t=this.layer?.capabilities?.query;return!!this.associationTypes&&"string"==typeof this.globalId&&!!t?.supportsPagination}set displayCount(t){const e=0,o=3;this._set("displayCount",Math.max(t??o,e))}get displayCount(){return this._get("displayCount")}get objectId(){return(this.objectIdField&&this.graphic?.attributes?.[this.objectIdField])??null}get objectIdField(){return this.layer?.objectIdField||null}get globalId(){return(this.globalIdField&&this.graphic?.attributes?.[this.globalIdField])??null}get globalIdField(){const{layer:t}=this;return t?.globalIdField}get activeAssociationType(){return this._get("activeAssociationType")}set activeAssociationType(t){t&&!this.associationTypes.includes(t)||this._set("activeAssociationType",t)}get state(){const{_queryAbortController:t,_queryFeatureCountAbortController:e,_queryPageAbortController:o,canQuery:r,_loaded:s,canLoad:i,source:a}=this;return e||i&&!s?"loading":t||o?"querying":!r||"popup"===a&&0===this.featureCount?"disabled":"ready"}get utilityNetwork(){const{layer:t,map:e}=this;if(!t?.loaded||!e)return null;const o=g(t)?t.parent:t;return f(e,o)}get attachmentsAssociations(){return this._get("attachmentsAssociations")||new s}get structureAssociations(){return this._get("structureAssociations")||new s}get contentAssociations(){return this._get("contentAssociations")||new s}get containerAssociations(){return this._get("containerAssociations")||new s}get connectivityAssociations(){return this._get("connectivityAssociations")||new s}get associationFeatures(){return this._get("associationFeatures")||new l}get associationViewModels(){return this._get("associationViewModels")||new Map}async refresh(){await this._queryFeatureCountDebounced(),await this._queryOpenAssociationType()}getFeatureCountForAssociationType(t){switch(t){case"attachment":return this.attachmentsFeatureCount;case"structure":return this.structureFeatureCount;case"content":return this.contentFeatureCount;case"container":return this.containerFeatureCount;case"connectivity":return this.connectivityFeatureCount}}_destroyAssociatedFeatureViewModels(){this.associationViewModels.forEach(t=>t.destroyAll())}async _loadUtiltyNetworks(){const t=this.map;if(!t)return;await Promise.allSettled(t.utilityNetworks?.map(async t=>{await t.load()})??[]);const e=this.utilityNetwork;if(e){const o=t=>{if("layerId"in t&&e.isUtilityLayer(t)){const o=null!=t.layerId?e.getSourceIdByLayerId(t.layerId):null;null!=o&&this.networkSourceIdsInUse.add(o)}};this._set("networkSourceIdsInUse",new Set),t.allLayers.forEach(o),t.allTables.forEach(o)}}async _findLayersBySourceId(t){const{utilityNetwork:e,map:o}=this,r=t=>{const o=t;if(!t.url)return!1;if(o.layerId===s){return t.url.replace(/\/\d+$/,"")===e?.featureServiceUrl}return!1};await(e?.load());const s=e.getLayerIdBySourceId(t),i=o.allLayers.filter(r),a=o.allTables.filter(r),n=i.concat(a).toArray();return await Promise.allSettled(n.map(t=>t.load())),n}_clearAssociations(){this.attachmentsAssociations.removeAll(),this.structureAssociations.removeAll(),this.contentAssociations.removeAll(),this.containerAssociations.removeAll(),this.connectivityAssociations.removeAll()}_clearFeatures(){this.associationFeatures.forEach(t=>t.removeAll()),this.associationFeatures.clear()}_getAssociationsByType(t){switch(t){case"attachment":return this.attachmentsAssociations;case"structure":return this.structureAssociations;case"connectivity":return this.connectivityAssociations;case"container":return this.containerAssociations;case"content":return this.contentAssociations}}async _queryLayer(t,e,o,r,s){const i=this._getFeatureQueryWhereClause(t,e,o,r),a=new A({where:i,outFields:["*"],cacheHint:this.supportsCacheHint}),n=b.fromJSON(await m(t,a,s));return n.features.forEach(e=>{e.layer=e.sourceLayer=_(t)?t.findSublayerForFeature(e):t}),n.features}async _createAssociationFeatureObjects(t,e,o,r,s,i){if(0===t.length)return[];const a=new Map;for(const[c,l]of e){const t=await this._findLayersBySourceId(c);for(const e of t){(await this._queryLayer(e,l,r,s,i)).forEach(t=>{if("popup"===this.source?t.sourceLayer&&t.getEffectivePopupTemplate():!!t.sourceLayer){const o=a.get(t.attributes[e.globalIdField])??[];o.push(t),a.set(t.attributes[e.globalIdField],o)}})}}const n=[];return await Promise.all(t.toArray().map(async t=>{const{fromNetworkElement:e,toNetworkElement:r}=t,s=e.globalId===o?r:e,i=a.get(s.globalId)??[];await Promise.all(i.map(async e=>{const o=this.utilityNetwork?.getTerminalById(s?.terminalId)?.name,r=e.sourceLayer&&"getFeatureTitle"in e.sourceLayer?await e.sourceLayer.getFeatureTitle(e):C(e);n.push({title:r,feature:e,association:t,terminalName:o})}))})),n}_parseFeatureObjects(t,e){const o=new Map;t.forEach(t=>{const e=t?.feature,r=e.sourceLayer;a(o,r,()=>new s).add(t)});for(const[r,s]of o)this._sortFeatureObjectsByTitle(s),e.set(r,s)}_sortFeatureObjectsByTitle(t){t.sort(this._compareByFeatureTitle)}_compareByFeatureTitle(t,e){return t.title.localeCompare(e.title,void 0,{numeric:!0})}async _queryAssociations(t){const{layer:e,globalId:o,associationTypes:r,utilityNetwork:s,canQuery:i}=this;if(await Promise.allSettled([e?.load(),s?.load()]),this._clearAssociations(),!(i&&e&&r&&s&&o))return;const a=g(e)?e.parent:e,n=new w({globalId:o,networkSourceId:s.getSourceIdByLayerId(a.layerId)}),c=new Set;r.forEach(t=>{switch(t.type){case"attachment":case"structure":c.add("attachment");break;case"container":case"content":c.add("containment");break;case"connectivity":c.add("connectivity"),c.add("junction-junction-connectivity"),c.add("junction-edge-from-connectivity"),c.add("junction-edge-midspan-connectivity"),c.add("junction-edge-to-connectivity")}});const l=await(s?.queryAssociations({elements:[n],types:Array.from(c)},{signal:t?.signal})),u=new Map,y=new Map;r.forEach(t=>{y.set(t.type,t),u.set(t.type,[])}),l.forEach(t=>{const{toNetworkElement:e,fromNetworkElement:r}=t;switch(t.associationType){case"connectivity":case"junction-junction-connectivity":case"junction-edge-from-connectivity":case"junction-edge-midspan-connectivity":case"junction-edge-to-connectivity":if(r?.globalId===o){if(this._shouldDiscardNetworkElement(e,"connectivity",y))break;u.get("connectivity")?.push(e.globalId)}else{if(this._shouldDiscardNetworkElement(r,"connectivity",y))break;u.get("connectivity")?.push(r.globalId)}this.connectivityAssociations.add(t);break;case"containment":if(r?.globalId===o){if(this._shouldDiscardNetworkElement(e,"content",y))break;u.get("content")?.push(e.globalId),this.contentAssociations.add(t)}else{if(this._shouldDiscardNetworkElement(r,"container",y))break;u.get("container")?.push(r.globalId),this.containerAssociations.add(t)}break;case"attachment":if(r?.globalId===o){if(this._shouldDiscardNetworkElement(e,"attachment",y))break;u.get("attachment")?.push(e.globalId),this.attachmentsAssociations.add(t)}else{if(this._shouldDiscardNetworkElement(r,"structure",y))break;u.get("structure")?.push(r.globalId),this.structureAssociations.add(t)}}});const d=r.map(async e=>{const{associatedNetworkSourceId:o,associatedAssetGroup:r,associatedAssetType:s}=e,i=u.get(e.type),a=null!=r?await this._countAssociatedFeatures(o,i,r,s,t):i.length;switch(e.type){case"attachment":this._set("attachmentsFeatureCount",a);break;case"structure":this._set("structureFeatureCount",a);break;case"content":this._set("contentFeatureCount",a);break;case"container":this._set("containerFeatureCount",a);break;case"connectivity":this._set("connectivityFeatureCount",a)}});await Promise.allSettled(d)}async _countAssociatedFeatureCount(t,e,o,r,s){const i=this._getFeatureQueryWhereClause(t,e,o,r);return t.queryFeatureCount({where:i,outFields:["*"],returnGeometry:!1},{signal:s?.signal})}async _countAssociatedFeatures(t,e,o,r,s){if(0===e.length)return 0;const i=(await this._findLayersBySourceId(t)).map(async t=>this._countAssociatedFeatureCount(t,e,o,r,s));return(await Promise.all(i)).reduce((t,e)=>t+e,0)}async _queryAssociatedFeatures(t,e){const{layer:o,globalId:r,associationTypes:s,utilityNetwork:i,canQuery:a,associationFeatures:n}=this;if(await Promise.allSettled([o?.load(),i?.load()]),!(a&&o&&s&&i))return;const c=this._getAssociationsByType(t.type),{associatedAssetGroup:l,associatedAssetType:u}=t,y=new Map;c.forEach(t=>{const{fromNetworkElement:e,toNetworkElement:o}=t,{networkSourceId:s,elementGlobalId:i}=e.globalId===r?{networkSourceId:o.networkSourceId,elementGlobalId:o.globalId}:{networkSourceId:e.networkSourceId,elementGlobalId:e.globalId},a=y.get(s)||[];a.push(i),y.set(s,a)});const d=await this._createAssociationFeatureObjects(c,y,r,l,u,e);this._parseFeatureObjects(d,n)}async _queryFeatureCount(){await this._loadUtiltyNetworks();const{_queryFeatureCountAbortController:t,canQuery:e}=this;e?(await this._queryAssociations(t),this._set("featureCount",this.attachmentsFeatureCount+this.structureFeatureCount+this.contentFeatureCount+this.containerFeatureCount+this.connectivityFeatureCount)):this._set("featureCount",0)}async _query(t){if(!t)return;await this._loadUtiltyNetworks();const{_queryAbortController:e}=this;this._destroyAssociatedFeatureViewModels(),this._clearFeatures(),0!==this.featureCount&&(this.destroyed||await this._queryAssociatedFeatures(t,{signal:e?.signal}))}_shouldDiscardNetworkElement(t,e,o){if(!t)return!1;const{networkSourceIdsInUse:r}=this,{networkSourceId:s}=t,i=o.get(e)?.associatedNetworkSourceId,a=r.has(s);return null!=i&&i!==s||!a}_getFeatureQueryWhereClause(t,e,o,r){const s=t.globalIdField,i=t.fieldsIndex.get(F.assetGroup),a=t.fieldsIndex.get(F.assetType),n=null!=o,c=null!=r;return[s?d(s,e):null,n?`(${i?.name} = ${o})`:null,n&&c?`(${a?.name} = ${r})`:null].filter(Boolean).join(" AND ")}};t([h()],v.prototype,"_loaded",void 0),t([h()],v.prototype,"_queryAbortController",void 0),t([h()],v.prototype,"_queryPageAbortController",void 0),t([h()],v.prototype,"_queryFeatureCountAbortController",void 0),t([h({readOnly:!0})],v.prototype,"supportsCacheHint",null),t([h({readOnly:!0})],v.prototype,"canLoad",null),t([h({readOnly:!0})],v.prototype,"canQuery",null),t([h()],v.prototype,"networkSourceIdsInUse",void 0),t([h({constructOnly:!0})],v.prototype,"source",void 0),t([h()],v.prototype,"description",void 0),t([h({value:3})],v.prototype,"displayCount",null),t([h({type:e})],v.prototype,"graphic",void 0),t([h()],v.prototype,"layer",void 0),t([h()],v.prototype,"map",void 0),t([h({readOnly:!0})],v.prototype,"objectId",null),t([h({readOnly:!0})],v.prototype,"objectIdField",null),t([h({readOnly:!0})],v.prototype,"globalId",null),t([h({readOnly:!0})],v.prototype,"globalIdField",null),t([h()],v.prototype,"featureCount",void 0),t([h()],v.prototype,"associationTypes",void 0),t([h()],v.prototype,"activeAssociationType",null),t([h()],v.prototype,"showAllEnabled",void 0),t([h()],v.prototype,"state",null),t([h()],v.prototype,"title",void 0),t([h({readOnly:!0})],v.prototype,"utilityNetwork",null),t([h({readOnly:!0})],v.prototype,"attachmentsFeatureCount",void 0),t([h({readOnly:!0})],v.prototype,"structureFeatureCount",void 0),t([h({readOnly:!0})],v.prototype,"attachmentsAssociations",null),t([h({readOnly:!0})],v.prototype,"structureAssociations",null),t([h({readOnly:!0})],v.prototype,"contentFeatureCount",void 0),t([h({readOnly:!0})],v.prototype,"containerFeatureCount",void 0),t([h({readOnly:!0})],v.prototype,"contentAssociations",null),t([h({readOnly:!0})],v.prototype,"containerAssociations",null),t([h({readOnly:!0})],v.prototype,"connectivityFeatureCount",void 0),t([h({readOnly:!0})],v.prototype,"connectivityAssociations",null),t([h({readOnly:!0})],v.prototype,"associationFeatures",null),t([h({readOnly:!0})],v.prototype,"associationViewModels",null),v=t([p("esri.widgets.support.UtilityNetworkAssociations.FeatureUtilityNetworkAssociationsViewModel")],v);export{v as default};
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../../Graphic.js";import o from"../../../core/Accessor.js";import{ClonableMixin as r}from"../../../core/Clonable.js";import s from"../../../core/Collection.js";import{IdentifiableMixin as i}from"../../../core/Identifiable.js";import{getOrCreateMapValue as a}from"../../../core/MapUtils.js";import{ignoreAbortErrors as n,debounce as c}from"../../../core/promiseUtils.js";import l from"../../../core/ReactiveMap.js";import{watch as u,initial as y}from"../../../core/reactiveUtils.js";import{sqlIn as d}from"../../../core/sql.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{queryAllJSON as m}from"../../../layers/support/featureQueryAll.js";import{isSubtypeSublayer as g,isSubtypeGroupLayer as _}from"../../../layers/support/layerUtils.js";import w from"../../../rest/networks/support/NetworkElement.js";import b from"../../../rest/support/FeatureSet.js";import A from"../../../rest/support/Query.js";import{featureUtilityNetworkFields as F}from"../../Feature/FeatureUtilityNetworkAssociations/resources.js";import{findUtilityNetwork as f}from"../../Feature/support/featureUtils.js";import{getFeatureTitle as C}from"./utils/getFeatureTitle.js";const I=100;let v=class extends(r(i(o))){constructor(t){super(t),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.networkSourceIdsInUse=new Set,this.source="popup",this.description=null,this.graphic=null,this.layer=null,this.map=null,this.featureCount=0,this.associationTypes=null,this.showAllEnabled=!1,this.title=null,this.attachmentsFeatureCount=0,this.structureFeatureCount=0,this.contentFeatureCount=0,this.containerFeatureCount=0,this.connectivityFeatureCount=0,this._queryOpenAssociationType=async()=>{this.activeAssociationType&&await this._queryDebounced(this.activeAssociationType)},this._cancelQuery=()=>{const{_queryAbortController:t}=this;t&&t.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:t}=this;t&&t.abort(),this._queryFeatureCountAbortController=null},this._queryController=async t=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await n(this._query(t)),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const t=new AbortController;this._queryFeatureCountAbortController=t,await n(this._queryFeatureCount()),this._queryFeatureCountAbortController===t&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryDebounced=c(this._queryController,I),this._queryFeatureCountDebounced=c(this._queryFeatureCountController,I)}initialize(){this.addHandles([u(()=>[this.graphic,this.layer,this.map,this.associationTypes,this.objectId,this.globalId,this.canQuery],()=>{this.refresh()},y),u(()=>this.activeAssociationType,t=>{this._queryDebounced(t)},y)])}destroy(){this._cancelQuery(),this._cancelQueryFeatureCount(),this._destroyAssociatedFeatureViewModels()}get supportsCacheHint(){return!!this.layer?.capabilities?.query?.supportsCacheHint}get canLoad(){return!!this.map&&!!this.associationTypes&&"string"==typeof this.globalId}get canQuery(){const t=this.layer?.capabilities?.query;return!!this.associationTypes&&"string"==typeof this.globalId&&!!t?.supportsPagination}set displayCount(t){const e=0,o=3;this._set("displayCount",Math.max(t??o,e))}get displayCount(){return this._get("displayCount")}get objectId(){return(this.objectIdField&&this.graphic?.attributes?.[this.objectIdField])??null}get objectIdField(){return this.layer?.objectIdField||null}get globalId(){return(this.globalIdField&&this.graphic?.attributes?.[this.globalIdField])??null}get globalIdField(){const{layer:t}=this;return t?.globalIdField}get activeAssociationType(){return this._get("activeAssociationType")}set activeAssociationType(t){t&&!this.associationTypes.includes(t)||this._set("activeAssociationType",t)}get state(){const{_queryAbortController:t,_queryFeatureCountAbortController:e,_queryPageAbortController:o,canQuery:r,_loaded:s,canLoad:i,source:a}=this;return e||i&&!s?"loading":t||o?"querying":!r||"popup"===a&&0===this.featureCount?"disabled":"ready"}get utilityNetwork(){const{layer:t,map:e}=this;if(!t?.loaded||!e)return null;const o=g(t)?t.parent:t;return f(e,o)}get attachmentsAssociations(){return this._get("attachmentsAssociations")||new s}get structureAssociations(){return this._get("structureAssociations")||new s}get contentAssociations(){return this._get("contentAssociations")||new s}get containerAssociations(){return this._get("containerAssociations")||new s}get connectivityAssociations(){return this._get("connectivityAssociations")||new s}get associationFeatures(){return this._get("associationFeatures")||new l}get associationViewModels(){return this._get("associationViewModels")||new Map}async refresh(){await this._queryFeatureCountDebounced(),await this._queryOpenAssociationType()}getFeatureCountForAssociationType(t){switch(t){case"attachment":return this.attachmentsFeatureCount;case"structure":return this.structureFeatureCount;case"content":return this.contentFeatureCount;case"container":return this.containerFeatureCount;case"connectivity":return this.connectivityFeatureCount}}_destroyAssociatedFeatureViewModels(){this.associationViewModels.forEach(t=>t.destroyAll())}async _loadUtiltyNetworks(){const t=this.map;if(!t)return;await Promise.allSettled(t.utilityNetworks?.map(async t=>{await t.load()})??[]);const e=this.utilityNetwork;if(e){const o=t=>{if("layerId"in t&&e.isUtilityLayer(t)){const o=null!=t.layerId?e.getSourceIdByLayerId(t.layerId):null;null!=o&&this.networkSourceIdsInUse.add(o)}};this._set("networkSourceIdsInUse",new Set),t.allLayers.forEach(o),t.allTables.forEach(o)}}async _findLayersBySourceId(t){const{utilityNetwork:e,map:o}=this,r=t=>{const o=t;if(!t.url)return!1;if(o.layerId===s){return t.url.replace(/\/\d+$/,"")===e?.featureServiceUrl}return!1};await(e?.load());const s=e.getLayerIdBySourceId(t),i=o.allLayers.filter(r),a=o.allTables.filter(r),n=i.concat(a).toArray();return await Promise.allSettled(n.map(t=>t.load())),n}_clearAssociations(){this.attachmentsAssociations.removeAll(),this.structureAssociations.removeAll(),this.contentAssociations.removeAll(),this.containerAssociations.removeAll(),this.connectivityAssociations.removeAll()}_clearFeatures(){this.associationFeatures.forEach(t=>t.removeAll()),this.associationFeatures.clear()}_getAssociationsByType(t){switch(t){case"attachment":return this.attachmentsAssociations;case"structure":return this.structureAssociations;case"connectivity":return this.connectivityAssociations;case"container":return this.containerAssociations;case"content":return this.contentAssociations}}async _queryLayer(t,e,o,r,s){const i=this._getFeatureQueryWhereClause(t,e,o,r),a=new A({where:i,outFields:["*"],cacheHint:this.supportsCacheHint}),n=b.fromJSON(await m(t,a,s));return n.features.forEach(e=>{e.layer=e.sourceLayer=_(t)?t.findSublayerForFeature(e):t}),n.features}async _createAssociationFeatureObjects(t,e,o,r,s,i){if(0===t.length)return[];const a=new Map;for(const[c,l]of e){const t=await this._findLayersBySourceId(c);for(const e of t){(await this._queryLayer(e,l,r,s,i)).forEach(t=>{if("popup"===this.source?t.sourceLayer&&t.getEffectivePopupTemplate():!!t.sourceLayer){const o=a.get(t.attributes[e.globalIdField])??[];o.push(t),a.set(t.attributes[e.globalIdField],o)}})}}const n=[];return await Promise.all(t.toArray().map(async t=>{const{fromNetworkElement:e,toNetworkElement:r}=t,s=e.globalId===o?r:e,i=a.get(s.globalId)??[];await Promise.all(i.map(async e=>{const o=this.utilityNetwork?.getTerminalById(s?.terminalId)?.name,r=e.sourceLayer&&"getFeatureTitle"in e.sourceLayer?await e.sourceLayer.getFeatureTitle(e):C(e);n.push({title:r,feature:e,association:t,terminalName:o})}))})),n}_parseFeatureObjects(t,e){const o=new Map;t.forEach(t=>{const e=t?.feature,r=e.sourceLayer;a(o,r,()=>new s).add(t)});for(const[r,s]of o)this._sortFeatureObjectsByTitle(s),e.set(r,s)}_sortFeatureObjectsByTitle(t){t.sort(this._compareByFeatureTitle)}_compareByFeatureTitle(t,e){return t.title.localeCompare(e.title,void 0,{numeric:!0})}async _queryAssociations(t){const{layer:e,globalId:o,associationTypes:r,utilityNetwork:s,canQuery:i}=this;if(await Promise.allSettled([e?.load(),s?.load()]),this._clearAssociations(),!(i&&e&&r&&s&&o))return;const a=g(e)?e.parent:e,n=new w({globalId:o,networkSourceId:s.getSourceIdByLayerId(a.layerId)}),c=new Set;r.forEach(t=>{switch(t.type){case"attachment":case"structure":c.add("attachment");break;case"container":case"content":c.add("containment");break;case"connectivity":c.add("connectivity"),c.add("junction-junction-connectivity"),c.add("junction-edge-from-connectivity"),c.add("junction-edge-midspan-connectivity"),c.add("junction-edge-to-connectivity")}});const l=await(s?.queryAssociations({elements:[n],types:Array.from(c)},{signal:t?.signal})),u=new Map,y=new Map;r.forEach(t=>{y.set(t.type,t),u.set(t.type,[])}),l.forEach(t=>{const{toNetworkElement:e,fromNetworkElement:r}=t;switch(t.associationType){case"connectivity":case"junction-junction-connectivity":case"junction-edge-from-connectivity":case"junction-edge-midspan-connectivity":case"junction-edge-to-connectivity":if(r?.globalId===o){if(this._shouldDiscardNetworkElement(e,"connectivity",y))break;u.get("connectivity")?.push(e.globalId)}else{if(this._shouldDiscardNetworkElement(r,"connectivity",y))break;u.get("connectivity")?.push(r.globalId)}this.connectivityAssociations.add(t);break;case"containment":if(r?.globalId===o){if(this._shouldDiscardNetworkElement(e,"content",y))break;u.get("content")?.push(e.globalId),this.contentAssociations.add(t)}else{if(this._shouldDiscardNetworkElement(r,"container",y))break;u.get("container")?.push(r.globalId),this.containerAssociations.add(t)}break;case"attachment":if(r?.globalId===o){if(this._shouldDiscardNetworkElement(e,"attachment",y))break;u.get("attachment")?.push(e.globalId),this.attachmentsAssociations.add(t)}else{if(this._shouldDiscardNetworkElement(r,"structure",y))break;u.get("structure")?.push(r.globalId),this.structureAssociations.add(t)}}});const d=r.map(async e=>{const{associatedNetworkSourceId:o,associatedAssetGroup:r,associatedAssetType:s}=e,i=u.get(e.type),a=null!=r?await this._countAssociatedFeatures(o,i,r,s,t):i.length;switch(e.type){case"attachment":this._set("attachmentsFeatureCount",a);break;case"structure":this._set("structureFeatureCount",a);break;case"content":this._set("contentFeatureCount",a);break;case"container":this._set("containerFeatureCount",a);break;case"connectivity":this._set("connectivityFeatureCount",a)}});await Promise.allSettled(d)}async _countAssociatedFeatureCount(t,e,o,r,s){const i=this._getFeatureQueryWhereClause(t,e,o,r);return t.queryFeatureCount({where:i,outFields:["*"],returnGeometry:!1},{signal:s?.signal})}async _countAssociatedFeatures(t,e,o,r,s){if(0===e.length)return 0;const i=(await this._findLayersBySourceId(t)).map(async t=>this._countAssociatedFeatureCount(t,e,o,r,s));return(await Promise.all(i)).reduce((t,e)=>t+e,0)}async _queryAssociatedFeatures(t,e){const{layer:o,globalId:r,associationTypes:s,utilityNetwork:i,canQuery:a,associationFeatures:n}=this;if(await Promise.allSettled([o?.load(),i?.load()]),!(a&&o&&s&&i))return;const c=this._getAssociationsByType(t.type),{associatedAssetGroup:l,associatedAssetType:u}=t,y=new Map;c.forEach(t=>{const{fromNetworkElement:e,toNetworkElement:o}=t,{networkSourceId:s,elementGlobalId:i}=e.globalId===r?{networkSourceId:o.networkSourceId,elementGlobalId:o.globalId}:{networkSourceId:e.networkSourceId,elementGlobalId:e.globalId},a=y.get(s)||[];a.push(i),y.set(s,a)});const d=await this._createAssociationFeatureObjects(c,y,r,l,u,e);this._parseFeatureObjects(d,n)}async _queryFeatureCount(){await this._loadUtiltyNetworks();const{_queryFeatureCountAbortController:t,canQuery:e}=this;e?(await this._queryAssociations(t),this._set("featureCount",this.attachmentsFeatureCount+this.structureFeatureCount+this.contentFeatureCount+this.containerFeatureCount+this.connectivityFeatureCount)):this._set("featureCount",0)}async _query(t){if(!t)return;await this._loadUtiltyNetworks();const{_queryAbortController:e}=this;this._destroyAssociatedFeatureViewModels(),this._clearFeatures(),0!==this.featureCount&&(this.destroyed||await this._queryAssociatedFeatures(t,{signal:e?.signal}))}_shouldDiscardNetworkElement(t,e,o){if(!t)return!1;const{networkSourceIdsInUse:r}=this,{networkSourceId:s}=t,i=o.get(e)?.associatedNetworkSourceId,a=r.has(s);return null!=i&&i!==s||!a}_getFeatureQueryWhereClause(t,e,o,r){const s=t.globalIdField,i=t.fieldsIndex.get(F.assetGroup),a=t.fieldsIndex.get(F.assetType),n=null!=o,c=null!=r;return[s?d(s,e):null,n?`(${i?.name} = ${o})`:null,n&&c?`(${a?.name} = ${r})`:null].filter(Boolean).join(" AND ")}};t([h()],v.prototype,"_loaded",void 0),t([h()],v.prototype,"_queryAbortController",void 0),t([h()],v.prototype,"_queryPageAbortController",void 0),t([h()],v.prototype,"_queryFeatureCountAbortController",void 0),t([h({readOnly:!0})],v.prototype,"supportsCacheHint",null),t([h({readOnly:!0})],v.prototype,"canLoad",null),t([h({readOnly:!0})],v.prototype,"canQuery",null),t([h()],v.prototype,"networkSourceIdsInUse",void 0),t([h({constructOnly:!0})],v.prototype,"source",void 0),t([h()],v.prototype,"description",void 0),t([h({value:3})],v.prototype,"displayCount",null),t([h({type:e})],v.prototype,"graphic",void 0),t([h()],v.prototype,"layer",void 0),t([h()],v.prototype,"map",void 0),t([h({readOnly:!0})],v.prototype,"objectId",null),t([h({readOnly:!0})],v.prototype,"objectIdField",null),t([h({readOnly:!0})],v.prototype,"globalId",null),t([h({readOnly:!0})],v.prototype,"globalIdField",null),t([h()],v.prototype,"featureCount",void 0),t([h()],v.prototype,"associationTypes",void 0),t([h()],v.prototype,"activeAssociationType",null),t([h()],v.prototype,"showAllEnabled",void 0),t([h()],v.prototype,"state",null),t([h()],v.prototype,"title",void 0),t([h({readOnly:!0})],v.prototype,"utilityNetwork",null),t([h({readOnly:!0})],v.prototype,"attachmentsFeatureCount",void 0),t([h({readOnly:!0})],v.prototype,"structureFeatureCount",void 0),t([h({readOnly:!0})],v.prototype,"attachmentsAssociations",null),t([h({readOnly:!0})],v.prototype,"structureAssociations",null),t([h({readOnly:!0})],v.prototype,"contentFeatureCount",void 0),t([h({readOnly:!0})],v.prototype,"containerFeatureCount",void 0),t([h({readOnly:!0})],v.prototype,"contentAssociations",null),t([h({readOnly:!0})],v.prototype,"containerAssociations",null),t([h({readOnly:!0})],v.prototype,"connectivityFeatureCount",void 0),t([h({readOnly:!0})],v.prototype,"connectivityAssociations",null),t([h({readOnly:!0})],v.prototype,"associationFeatures",null),t([h({readOnly:!0})],v.prototype,"associationViewModels",null),v=t([p("esri.widgets.support.UtilityNetworkAssociations.FeatureUtilityNetworkAssociationsViewModel")],v);export{v 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"../../../intl.js";import t from"../../../core/ReactiveMap.js";import{watch as o}from"../../../core/reactiveUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import s from"../../Widget.js";import{loadCalciteComponents as n}from"../componentsUtils.js";import"../widgetUtils.js";import{messageBundle as a}from"../decorators/messageBundle.js";import{tsx as c}from"../jsxFactory.js";import l from"./FeatureUtilityNetworkAssociationsViewModel.js";import{substitute as u}from"../../../intl/substitute.js";const d="esri-utility-network-association-list",p={featureObserver:`${d}__feature-observer`,filterContainer:`${d}__filter-container`,limitNoticeContainer:`${d}__limit-notice-container`,loadingContainer:`${d}__loading-container`};let m=class extends s{constructor(e,o){super(e,o),this._isFeatureCountNoticeOpen=!0,this._observer=new IntersectionObserver(([e])=>{e?.isIntersecting&&this._increaseFeaturePage()},{root:window.document}),this._observerNode=null,this.featuresPerPage=50,this.filterText="",this.headingLevel=5,this.maxFeatureCount=1e3,this.messagesFeature=null,this.messagesCommon=null,this.selectedLayer=null,this.tooltipReferenceMap=new t,this.viewModel=new l}initialize(){this.setUpObserver()}loadDependencies(){return n({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this.tooltipReferenceMap.clear()}get associatedFeatureCount(){const e=this.viewModel.associationViewModels,t=this.selectedLayer?e.get(this.selectedLayer):null;return t?t.length:0}set currentFeaturePage(e){const{featuresPerPage:t,associatedFeatureCount:o}=this,i=Math.ceil(o/t)||1,r=Math.max(Math.min(e,i),1);this._set("currentFeaturePage",r)}get currentFeaturePage(){return this._get("currentFeaturePage")??1}get endIndex(){const{currentFeaturePage:e,featuresPerPage:t,maxFeatureCount:o}=this;return Math.min(e*t,o)}renderConnectivityIcon(e,t){const{tooltipReferenceMap:o}=this;let i;switch(e){case"junction-edge-from-connectivity":i="connection-end-left";break;case"junction-edge-to-connectivity":i="connection-end-right";break;case"junction-edge-midspan-connectivity":i="connection-middle";break;default:i="connection-to-connection"}return c("calcite-icon",{afterCreate:e=>o.set(t,e),afterRemoved:()=>o.delete(t),icon:i,scale:"s",slot:"content-start"})}renderFeatureCountWarning(){const{associatedFeatureCount:e,maxFeatureCount:t,messagesFeature:o}=this;return e>t?c("calcite-notice",{class:this._isFeatureCountNoticeOpen?p.limitNoticeContainer:void 0,closable:!0,icon:"information",kind:"info",open:!0,scale:"s",width:"full",onCalciteNoticeBeforeOpen:()=>this._isFeatureCountNoticeOpen=!0,onCalciteNoticeClose:()=>this._isFeatureCountNoticeOpen=!1},c("div",{slot:"title"},o.associationsLimitNoticeTitle),c("div",{slot:"message"},u(o.associationsLimitNoticeMessage,{number:t}))):null}renderFeatureObserver(){return c("div",{afterCreate:this._onObserverCreate,bind:this,class:p.featureObserver,key:"feature-observer"})}renderFilter(){return c("div",{class:p.filterContainer,key:"filter"},c("calcite-input",{icon:"search",placeholder:this.messagesFeature.associationFilterPlaceholder,type:"search",onCalciteInputInput:e=>{this.filterText=e.currentTarget.value.trim().toLowerCase(),this.currentFeaturePage=1}}))}renderLoading(){return c("div",{class:p.loadingContainer,key:"loading-container"},this.renderLoadingIcon())}renderLoadingIcon(){return c("calcite-loader",{inline:!0,label:this.messagesCommon.loading})}getConnectivityTooltip(e){const{messagesFeature:t}=this;switch(e){case"connectivity":case"junction-junction-connectivity":return t.associationsJunctionJunction;case"junction-edge-from-connectivity":return t.associationsJunctionEdgeFrom;case"junction-edge-midspan-connectivity":return t.associationsJunctionEdgeMidspan;case"junction-edge-to-connectivity":return t.associationsJunctionEdgeTo;default:return""}}setUpObserver(){this.addHandles(o(()=>this._observerNode,()=>this._onObserverChange()))}_increaseFeaturePage(){this.currentFeaturePage++}async _onObserverChange(){this._observerNode&&this._observer.unobserve(this._observerNode);const{state:e,showAllEnabled:t}=this.viewModel;this._observerNode&&"ready"===e&&t&&this._observer.observe(this._observerNode)}_onObserverCreate(e){this._observerNode=e}};e([i()],m.prototype,"_observer",void 0),e([i()],m.prototype,"_observerNode",void 0),e([i()],m.prototype,"associatedFeatureCount",null),e([i()],m.prototype,"currentFeaturePage",null),e([i()],m.prototype,"endIndex",null),e([i()],m.prototype,"featuresPerPage",void 0),e([i()],m.prototype,"filterText",void 0),e([i()],m.prototype,"headingLevel",void 0),e([i()],m.prototype,"maxFeatureCount",void 0),e([i(),a("esri/widgets/Feature/t9n/Feature")],m.prototype,"messagesFeature",void 0),e([i(),a("esri/t9n/common")],m.prototype,"messagesCommon",void 0),e([i()],m.prototype,"selectedLayer",void 0),e([i()],m.prototype,"tooltipReferenceMap",void 0),e([i({type:l})],m.prototype,"viewModel",void 0),m=e([r("esri.widgets.support.UtilityNetworkAssociations.UtilityNetworkAssociationList")],m);export{m as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import"../../../intl.js";import t from"../../../core/ReactiveMap.js";import{watch as o}from"../../../core/reactiveUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import s from"../../Widget.js";import{loadCalciteComponents as n}from"../componentsUtils.js";import"../widgetUtils.js";import{messageBundle as a}from"../decorators/messageBundle.js";import{tsx as c}from"../jsxFactory.js";import l from"./FeatureUtilityNetworkAssociationsViewModel.js";import{substitute as u}from"../../../intl/substitute.js";const d="esri-utility-network-association-list",p={featureObserver:`${d}__feature-observer`,filterContainer:`${d}__filter-container`,limitNoticeContainer:`${d}__limit-notice-container`,loadingContainer:`${d}__loading-container`};let m=class extends s{constructor(e,o){super(e,o),this._isFeatureCountNoticeOpen=!0,this._observer=new IntersectionObserver(([e])=>{e?.isIntersecting&&this._increaseFeaturePage()},{root:window.document}),this._observerNode=null,this.featuresPerPage=50,this.filterText="",this.headingLevel=5,this.maxFeatureCount=1e3,this.messagesFeature=null,this.messagesCommon=null,this.selectedLayer=null,this.tooltipReferenceMap=new t,this.viewModel=new l}initialize(){this.setUpObserver()}loadDependencies(){return n({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this.tooltipReferenceMap.clear()}get associatedFeatureCount(){const e=this.viewModel.associationViewModels,t=this.selectedLayer?e.get(this.selectedLayer):null;return t?t.length:0}set currentFeaturePage(e){const{featuresPerPage:t,associatedFeatureCount:o}=this,i=Math.ceil(o/t)||1,r=Math.max(Math.min(e,i),1);this._set("currentFeaturePage",r)}get currentFeaturePage(){return this._get("currentFeaturePage")??1}get endIndex(){const{currentFeaturePage:e,featuresPerPage:t,maxFeatureCount:o}=this;return Math.min(e*t,o)}renderConnectivityIcon(e,t){const{tooltipReferenceMap:o}=this;let i;switch(e){case"junction-edge-from-connectivity":i="connection-end-left";break;case"junction-edge-to-connectivity":i="connection-end-right";break;case"junction-edge-midspan-connectivity":i="connection-middle";break;default:i="connection-to-connection"}return c("calcite-icon",{afterCreate:e=>o.set(t,e),afterRemoved:()=>o.delete(t),icon:i,scale:"s",slot:"content-start"})}renderFeatureCountWarning(){const{associatedFeatureCount:e,maxFeatureCount:t,messagesFeature:o}=this;return e>t?c("calcite-notice",{class:this._isFeatureCountNoticeOpen?p.limitNoticeContainer:void 0,closable:!0,icon:"information",kind:"info",open:!0,scale:"s",width:"full",onCalciteNoticeBeforeOpen:()=>this._isFeatureCountNoticeOpen=!0,onCalciteNoticeClose:()=>this._isFeatureCountNoticeOpen=!1},c("div",{slot:"title"},o.associationsLimitNoticeTitle),c("div",{slot:"message"},u(o.associationsLimitNoticeMessage,{number:t}))):null}renderFeatureObserver(){return c("div",{afterCreate:this._onObserverCreate,bind:this,class:p.featureObserver,key:"feature-observer"})}renderFilter(){return c("div",{class:p.filterContainer,key:"filter"},c("calcite-input",{icon:"search",placeholder:this.messagesFeature.associationFilterPlaceholder,type:"search",onCalciteInputInput:e=>{this.filterText=e.currentTarget.value.trim().toLowerCase(),this.currentFeaturePage=1}}))}renderLoading(){return c("div",{class:p.loadingContainer,key:"loading-container"},this.renderLoadingIcon())}renderLoadingIcon(){return c("calcite-loader",{inline:!0,label:this.messagesCommon.loading})}getConnectivityTooltip(e){const{messagesFeature:t}=this;switch(e){case"connectivity":case"junction-junction-connectivity":return t.associationsJunctionJunction;case"junction-edge-from-connectivity":return t.associationsJunctionEdgeFrom;case"junction-edge-midspan-connectivity":return t.associationsJunctionEdgeMidspan;case"junction-edge-to-connectivity":return t.associationsJunctionEdgeTo;default:return""}}setUpObserver(){this.addHandles(o(()=>this._observerNode,()=>{this._onObserverChange()}))}_increaseFeaturePage(){this.currentFeaturePage++}async _onObserverChange(){this._observerNode&&this._observer.unobserve(this._observerNode);const{state:e,showAllEnabled:t}=this.viewModel;this._observerNode&&"ready"===e&&t&&this._observer.observe(this._observerNode)}_onObserverCreate(e){this._observerNode=e}};e([i()],m.prototype,"_observer",void 0),e([i()],m.prototype,"_observerNode",void 0),e([i()],m.prototype,"associatedFeatureCount",null),e([i()],m.prototype,"currentFeaturePage",null),e([i()],m.prototype,"endIndex",null),e([i()],m.prototype,"featuresPerPage",void 0),e([i()],m.prototype,"filterText",void 0),e([i()],m.prototype,"headingLevel",void 0),e([i()],m.prototype,"maxFeatureCount",void 0),e([i(),a("esri/widgets/Feature/t9n/Feature")],m.prototype,"messagesFeature",void 0),e([i(),a("esri/t9n/common")],m.prototype,"messagesCommon",void 0),e([i()],m.prototype,"selectedLayer",void 0),e([i()],m.prototype,"tooltipReferenceMap",void 0),e([i({type:l})],m.prototype,"viewModel",void 0),m=e([r("esri.widgets.support.UtilityNetworkAssociations.UtilityNetworkAssociationList")],m);export{m as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[5404],{95404:(e,r,t)=>{t.d(r,{computeObjectLayerResourceSize:()=>u}),t(78888);var i=t(49186),o=t(66344),n=t(51850),s=t(70328),l=t(8887);let c=new o.q(50);async function u(e,r=null){if(!e.isPrimitive){const r=e.resource?.href;if(!r)throw new i.A("symbol:invalid-resource","The symbol does not have a valid resource");const o=c.get(r);if(void 0!==o)return o;const{fetch:l}=await Promise.all([t.e(3030),t.e(7937),t.e(7005),t.e(998),t.e(4304)]).then(t.bind(t,64304)),u=await l(r,{disableTextures:!0,spherical:!0}),a=(0,s.Ej)(u.referenceBoundingBox,(0,n.vt)());return c.put(r,a),a}if(!e.resource?.primitive)throw new i.A("symbol:invalid-resource","The symbol does not have a valid resource");const o=(0,s.vt)((0,l.Fq)(e.resource.primitive));if(null!=r)for(let e=0;e<o.length;e++)o[e]*=r;return(0,s.Ej)(o,(0,n.vt)())}}}]);
|