@arcgis/core 4.30.0-next.20240213 → 4.30.0-next.20240215
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/TimeExtent.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/08ba549f9c4afc42a21c.js +1 -0
- package/assets/esri/core/workers/chunks/114afcee6a66415cd123.js +1 -0
- package/assets/esri/core/workers/chunks/1320562881294ce93806.js +1 -0
- package/assets/esri/core/workers/chunks/13451fa3e4b02ca2beb0.js +1 -0
- package/assets/esri/core/workers/chunks/{a384f29cb3256401962a.js → 1629a8c2085dce59cd1b.js} +1 -1
- package/assets/esri/core/workers/chunks/18512caeeb03b9759ab1.js +1 -0
- package/assets/esri/core/workers/chunks/{cc1c958aad790a44048b.js → 1ca28af7c516d8283bb0.js} +1 -1
- package/assets/esri/core/workers/chunks/1f8a0fb32b96e50f5909.js +1 -0
- package/assets/esri/core/workers/chunks/{abab3abb8ea7610d9fb8.js → 21e7a88478f5d15e0e71.js} +1 -1
- package/assets/esri/core/workers/chunks/24452a26b0c5322c7d2b.js +1 -0
- package/assets/esri/core/workers/chunks/25b88787ead0cc44cda4.js +1 -0
- package/assets/esri/core/workers/chunks/2649166d1a462c7f8338.js +1 -0
- package/assets/esri/core/workers/chunks/2c96771a365f8f70e996.js +1 -0
- package/assets/esri/core/workers/chunks/352e7f8d694f3f217a2d.js +1 -0
- package/assets/esri/core/workers/chunks/392214a3a1d712eda155.js +1 -0
- package/assets/esri/core/workers/chunks/397f15b5bce6838db084.js +1 -0
- package/assets/esri/core/workers/chunks/3bf281e979408b9363ed.js +1 -0
- package/assets/esri/core/workers/chunks/4edc667148d023b5b5af.js +1 -0
- package/assets/esri/core/workers/chunks/51e4f771bfe352967c97.js +1 -0
- package/assets/esri/core/workers/chunks/55cd747e06bb59d1a328.js +1 -0
- package/assets/esri/core/workers/chunks/5638d95e600ff271c5b1.js +1 -0
- package/assets/esri/core/workers/chunks/563d172caa15ea1b510d.js +1108 -0
- package/assets/esri/core/workers/chunks/58f088b08e12c5435dbc.js +1 -0
- package/assets/esri/core/workers/chunks/5aef1e898618f8dda2c9.js +1 -0
- package/assets/esri/core/workers/chunks/608be8ebf772aefc36a5.js +1 -0
- package/assets/esri/core/workers/chunks/64df2521b2814d2fb918.js +1 -0
- package/assets/esri/core/workers/chunks/65070fb591f6ef8313c3.js +1 -0
- package/assets/esri/core/workers/chunks/656ec8a14df0e4b68433.js +1 -0
- package/assets/esri/core/workers/chunks/6601fe99d587b9dff3c7.js +1 -0
- package/assets/esri/core/workers/chunks/{274e623323e24250ca46.js → 6ac424af4f2825fabceb.js} +1 -1
- package/assets/esri/core/workers/chunks/{eb2d6f1ee63b40ae0736.js → 774b655498289b1b36bb.js} +1 -1
- package/assets/esri/core/workers/chunks/781bb63af571568358e3.js +1 -0
- package/assets/esri/core/workers/chunks/9e54d2cbe42f5552aaca.js +1 -0
- package/assets/esri/core/workers/chunks/{f03d62ab7806b68d0b62.js → 9fbf61675e2a5374f754.js} +1 -1
- package/assets/esri/core/workers/chunks/a5253543eae1708d11b9.js +1 -0
- package/assets/esri/core/workers/chunks/aa9b46bcb75c96731de3.js +1 -0
- package/assets/esri/core/workers/chunks/cfb8b6b5e9c21d582cf4.js +1 -0
- package/assets/esri/core/workers/chunks/d1b2372084c1e8c60f79.js +1 -0
- package/assets/esri/core/workers/chunks/{1c6914ded7db720f7bf7.js → daf6eab5dd198ca9a67b.js} +1 -1
- package/assets/esri/core/workers/chunks/e03edeaf3af46495449e.js +1 -0
- package/assets/esri/core/workers/chunks/e685214698fbc84276dd.js +1 -0
- package/assets/esri/core/workers/chunks/ebb294c82207f3ff9f04.js +1 -0
- package/assets/esri/core/workers/chunks/ec20e23aec9370df8a55.js +1 -0
- package/assets/esri/core/workers/chunks/{e4da908079417cc2f495.js → ee0c77889059815a31b2.js} +1 -1
- package/assets/esri/core/workers/chunks/f68b7bb88c444a7cbbd2.js +1 -0
- package/assets/esri/core/workers/chunks/f90bbebd2dc07a77ce09.js +1 -0
- package/assets/esri/core/workers/chunks/fa388680ff976a6b30f6.js +1 -0
- package/chunks/vec32.js +1 -1
- package/interfaces.d.ts +135 -68
- package/layers/WFSLayer.js +1 -1
- package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
- package/layers/graphics/applyEditsUtils.js +1 -1
- package/layers/graphics/editingSupport.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/save/featureLayerUtils.js +1 -1
- package/layers/support/arcgisLayers.js +1 -1
- package/layers/support/fetchService.js +1 -1
- package/layers/support/fromPortalItem.js +1 -1
- package/networks/Network.js +1 -1
- package/package.json +1 -1
- package/portal/Portal.js +1 -1
- package/portal/PortalGroup.js +1 -1
- package/portal/PortalUser.js +1 -1
- package/portal/support/geometryServiceUtils.js +1 -1
- package/portal/support/layersLoader.js +1 -1
- package/portal/support/loadUtils.js +1 -1
- package/portal/support/portalLayers.js +1 -1
- package/renderers/visualVariables/SizeVariable.js +1 -1
- package/rest/knowledgeGraph/wasmInterface/wasmToUpdateResponseFactories.js +1 -1
- package/rest/networks/support/Association.js +1 -1
- package/rest/places.js +1 -1
- package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
- package/rest/support/ImageSampleParameters.js +1 -1
- package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/SceneLayerAdapter.js +1 -1
- package/support/elevationInfoUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/symbols/cim/defaultCIMValues.js +1 -1
- package/symbols/cim/utils.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
- package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
- package/views/2d/engine/webgl/collisions/CollisionEngine.js +1 -1
- package/views/2d/engine/webgl/definitions.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
- package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
- package/views/2d/layers/features/schema/processor/VisualVariablesSchema.js +1 -1
- package/views/2d/layers/features/sources/strategies/SnapshotLoadStrategy.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/DisplayIdGenerator.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
- package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/webgl/RenderNode.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeNormalTexture.glsl.js +9 -7
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceConstants.js +5 -0
- package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +8 -8
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
- package/views/3d/webgl-engine/lib/ObjectAndLayerIdRenderHelper.js +1 -1
- package/views/draw/DrawGraphicTool.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/drawSurfaces.js +1 -1
- package/views/interactive/snapping/SnappingManager.js +1 -1
- package/views/interactive/snapping/SnappingOptions.js +1 -1
- package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
- package/views/layers/ImageryTileLayerView.js +1 -1
- package/webdoc/support/webdocLoadUtils.js +1 -1
- package/webdoc/support/webdocSaveUtils.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/components/FooterActions.js +1 -1
- package/widgets/Editor/support/EditorItem.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/Search/support/locatorUtils.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/00b9e92f8df245a83921.js +0 -1
- package/assets/esri/core/workers/chunks/02a6c43ec17e7223fac5.js +0 -1
- package/assets/esri/core/workers/chunks/02ee044597c89c86b934.js +0 -1
- package/assets/esri/core/workers/chunks/05ebb9cec0e1826b283f.js +0 -1
- package/assets/esri/core/workers/chunks/143ccb14c9e915dd1412.js +0 -1
- package/assets/esri/core/workers/chunks/24649b410b757599a549.js +0 -1
- package/assets/esri/core/workers/chunks/24d19abc680b341d13bb.js +0 -1
- package/assets/esri/core/workers/chunks/2519b207894132d5ea91.js +0 -1
- package/assets/esri/core/workers/chunks/30f9b2a3417cbcfeecca.js +0 -1
- package/assets/esri/core/workers/chunks/42ab9c282bb267c3db03.js +0 -1
- package/assets/esri/core/workers/chunks/478815fc19b452d8317d.js +0 -1
- package/assets/esri/core/workers/chunks/49afeac45250b15b5f36.js +0 -1
- package/assets/esri/core/workers/chunks/50bb67f2eeace5d50673.js +0 -1
- package/assets/esri/core/workers/chunks/50cdc59426ba859027e2.js +0 -1
- package/assets/esri/core/workers/chunks/5401ec9c9fd62dcac6ec.js +0 -1
- package/assets/esri/core/workers/chunks/554d86df71821d671d2c.js +0 -1
- package/assets/esri/core/workers/chunks/58c5861d060c808813a1.js +0 -1
- package/assets/esri/core/workers/chunks/5dbb3ef6fdd25ac632ad.js +0 -1
- package/assets/esri/core/workers/chunks/61c4bb58ef9f2d99c75e.js +0 -1
- package/assets/esri/core/workers/chunks/6e50220f8e2d392e2855.js +0 -1
- package/assets/esri/core/workers/chunks/6fd8047741a0df006ddd.js +0 -1
- package/assets/esri/core/workers/chunks/7709248f59520aee6f51.js +0 -1
- package/assets/esri/core/workers/chunks/8852a64918caf80fc414.js +0 -1
- package/assets/esri/core/workers/chunks/8d119dc0a92ad3612daa.js +0 -1
- package/assets/esri/core/workers/chunks/94dfb80ab23dda92918b.js +0 -1
- package/assets/esri/core/workers/chunks/9ebbc75ba5c623a322aa.js +0 -1
- package/assets/esri/core/workers/chunks/a5babc10f47c24651d15.js +0 -1
- package/assets/esri/core/workers/chunks/a74c59cf5d1c4e63a4e1.js +0 -1
- package/assets/esri/core/workers/chunks/ada5d6fd70bd3e403442.js +0 -1
- package/assets/esri/core/workers/chunks/b95d69d84d60ac9828b9.js +0 -1
- package/assets/esri/core/workers/chunks/be562536212360943388.js +0 -1
- package/assets/esri/core/workers/chunks/ce823fc2d0e0095f398c.js +0 -1
- package/assets/esri/core/workers/chunks/d06d36815c2121484a13.js +0 -1
- package/assets/esri/core/workers/chunks/d5f06a7b0ea7951c8dd0.js +0 -1
- package/assets/esri/core/workers/chunks/ddc71fe66c7a49082920.js +0 -1
- package/assets/esri/core/workers/chunks/de6d54df7ae32694fd70.js +0 -1
- package/assets/esri/core/workers/chunks/f13c4b9692dad5802a32.js +0 -1106
- package/assets/esri/core/workers/chunks/f1e8f7d1a98b9e207b1b.js +0 -1
- package/assets/esri/core/workers/chunks/f9e9675f1c2287231653.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as h,sync as u}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{initializeProjection as p,project as g}from"../../geometry/projection.js";import{getPointFromGeometry as f}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as m}from"../../geometry/support/webMercatorUtils.js";import y from"../../layers/Layer.js";import{fallbackObjectIDAttribute as w}from"../../layers/LayerConstants.js";import{getDisplayedSymbol as F}from"../../symbols/support/symbolUtils.js";import{highlightsSupported as v}from"../../views/support/layerViewUtils.js";import _ from"../Feature/FeatureViewModel.js";import{ActionsCollection as b,zoomToFeature as C,zoomToClusteredFeatures as P,browseClusteredFeatures as E}from"../Popup/actions.js";import{triggerAction as j,isClusterFeature as M,removeClusteredFeaturesForBrowsing as A,displayClusterExtent as L,browseAggregateFeatures as V,getSelectedTarget as I}from"../Popup/actionUtils.js";import S from"../support/AnchorElementViewModel.js";import{GoToMixin as O}from"../support/GoTo.js";import x from"../../symbols/SimpleFillSymbol.js";import T from"../../geometry/Point.js";const H=()=>[C.clone()],B=()=>[P.clone(),E.clone()];let R=null,U=class extends(O(S)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightSelectedFeaturePromise=null,this._highlightActiveFeaturePromise=null,this._selectedClusterFeature=null,this._locationScaleHandle=null,this.actions=new b,this.activeFeature=null,this.autoCloseEnabled=!1,this.autoOpenEnabled=!0,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.selectedClusterBoundaryFeature=new t({symbol:new x({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=o((async e=>{const{view:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if("mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const{pendingFeatures:e}=await this._fetchFeaturesWithController({mapPoint:s}),i=(await Promise.all(e)).flat().filter(Boolean);if(!i.length)return;if(i.length!==this.features.length){const e=this._getHighlightLayer(this.selectedFeature),t="imagery"===e?.type?void 0:e&&"objectIdField"in e?e.objectIdField||w:null;if(t){const s=this.selectedFeature.getObjectId(),r=i.findIndex((i=>{const r=this._getHighlightLayer(i);return r?.uid===e?.uid&&i.attributes[t]===s}));this.features=i,this.selectedFeatureIndex=r}}const r=i[this.selectedFeatureIndex]?.geometry,o=("mesh"!==r?.type?r:null)??this.selectedFeature.geometry,a=g(o,t.spatialReference);R||(R=await import("../../geometry/geometryEngineAsync.js")),a&&!await R.intersects(a,s)&&(this.location=(await R.nearestCoordinate(a,s)).coordinate??s)}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=f(this.selectedFeature.geometry)??s}))}initialize(){this.addHandles([this.on("view-change",(()=>this._autoClose())),l((()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view]),(()=>this._highlightSelectedFeature())),l((()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view]),(()=>this._highlightActiveFeature())),l((()=>this.view?.animation?.state),(e=>this._animationStateChange(e))),l((()=>this.location),(e=>this._locationChange(e))),l((()=>this.selectedFeature),(e=>this._selectedFeatureChange(e))),l((()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage]),(()=>this._selectedFeatureIndexChange())),l((()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels]),(()=>this._setGraphicOnFeatureViewModels())),l((()=>this.featureViewModels),(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>j({event:e,viewModel:this,view:this.view}))),h((()=>!this.waitingForResult),(()=>this._waitingForResultChange()),u),l((()=>[this.features,this.view?.map,this.view?.spatialReference,this.view?.timeZone]),(()=>this._updateFeatureVMs())),l((()=>this.view?.scale),(()=>this._viewScaleChange())),h((()=>!this.visible),(()=>this.browseClusterEnabled=!1)),l((()=>this.browseClusterEnabled),(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this._locationScaleHandle?.remove(),this._locationScaleHandle=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new b;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,h=n?.overwriteActions?l:l?.concat(a)??a;return h?.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){const e=this._get("defaultActions")||new b;return e.removeAll(),e.addMany(M(this.selectedFeature)?B():H()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1)}set location(e){let t=e;const i=this.view?.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=m(e)),this._set("location",t)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice(0)).forEach((e=>this._pendingPromises.add(e))),e.reduce(((e,t)=>e.finally((()=>t.then((e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)})).finally((()=>this._pendingPromises.delete(t))).catch((()=>{}))))),Promise.resolve())):this._set("promises",[])}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;e=isNaN(e)||e<-1||!t?-1:(e+t)%t,this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get state(){return this.view?.ready?"ready":"disabled"}get waitingForContents(){return this.featureViewModels.some((e=>e.waitingForContent))}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=I(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex++,this}previous(){return this.selectedFeatureIndex--,this}disableClusterBrowsing(){A(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?M(t)?(await L(this),await V(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}handleViewClick(e){this.autoOpenEnabled&&this._fetchFeaturesAndOpen(e)}_animationStateChange(e){this.zoomToLocation||(C.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(M(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i}=this;i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>1?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>1?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null===i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach(((t,i)=>{t&&(t.graphic??=e[o+i])}))}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(e&&s){if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),M(e))return;return e.symbol=await F(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}if(!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=f(e.geometry)}}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s}=this;if(M(e)||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const r=i.slice(0),o=[];t.forEach(((t,i)=>{if(!t)return;let a=null;if(r.some(((e,i)=>(e&&e.graphic===t&&(a=e,r.splice(i,1)),!!a))),a)o[i]=a;else{const r=new _({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:s?.spatialReference,graphic:t===e?t:null,location:this.location,map:s?.map,view:s});o[i]=r}})),r.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",o)}async _getScreenPoint(e,t){const{view:i}=this;await(i?.when());const s=e?.spatialReference,r=i?.spatialReference;return s&&r?(await p(s,r,null,t),i.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch((()=>{})).then((()=>{this._fetchFeaturesController=null})),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e,{view:s}=this;this._locationScaleHandle?.remove(),this._locationScaleHandle=l((()=>this.view?.scale),(()=>this._debouncedLocationUpdate(t).catch((e=>{a(e)||r.getLogger(this).error(e)}))));const{pendingFeatures:o}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:o})}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t}_getHighlightTarget(e,t){const i=e.getObjectId();if(null!=i)return i;const s="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||w:null,r=e.attributes;return r&&s&&r[s]||e}_mapIncludesLayer(e){return!!this.view?.map?.allLayers?.includes(e)}async _highlightActiveFeature(){const e="highlight-active-feature";this.removeHandles(e);const{highlightEnabled:t,view:i,activeFeature:s,visible:r}=this;if(!(s&&i&&t&&r))return;const o=this._getHighlightLayer(s);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(i,o);this._highlightActiveFeaturePromise=a;const n=await a;if(!(n&&v(n)&&this._highlightActiveFeaturePromise===a&&this.activeFeature&&this.highlightEnabled))return;const l=n.highlight(this._getHighlightTarget(s,o));this.addHandles(l,e)}async _highlightSelectedFeature(){const e="highlight-selected-feature";this.removeHandles(e);const{selectedFeature:t,highlightEnabled:i,view:s,visible:r}=this;if(!(t&&s&&i&&r))return;const o=this._getHighlightLayer(t);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(s,o);this._highlightSelectedFeaturePromise=a;const n=await a;if(!(n&&v(n)&&this._highlightSelectedFeaturePromise===a&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const l=n.highlight(this._getHighlightTarget(t,o));this.addHandles(l,e)}_updateFeatures(e){const{features:t}=this,i=e.filter((e=>!t.includes(e)));i?.length&&(this.features=t.concat(i))}};e([c()],U.prototype,"_fetchFeaturesController",void 0),e([c({type:b})],U.prototype,"actions",void 0),e([c({readOnly:!0})],U.prototype,"active",null),e([c()],U.prototype,"activeFeature",void 0),e([c({readOnly:!0})],U.prototype,"allActions",null),e([c()],U.prototype,"autoCloseEnabled",void 0),e([c()],U.prototype,"autoOpenEnabled",void 0),e([c()],U.prototype,"browseClusterEnabled",void 0),e([c()],U.prototype,"content",void 0),e([c({type:b,readOnly:!0})],U.prototype,"defaultActions",null),e([c({type:Boolean})],U.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],U.prototype,"featureCount",null),e([c()],U.prototype,"featurePage",void 0),e([c({value:[]})],U.prototype,"features",null),e([c()],U.prototype,"featuresPerPage",void 0),e([c()],U.prototype,"featureMenuOpen",void 0),e([c()],U.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],U.prototype,"featureViewModels",void 0),e([c()],U.prototype,"highlightEnabled",void 0),e([c()],U.prototype,"includeDefaultActions",void 0),e([c({type:T})],U.prototype,"location",null),e([c({readOnly:!0})],U.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],U.prototype,"promiseCount",null),e([c()],U.prototype,"promises",null),e([c({readOnly:!0})],U.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],U.prototype,"selectedFeature",null),e([c({value:-1})],U.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],U.prototype,"selectedFeatureViewModel",null),e([c({readOnly:!0})],U.prototype,"state",null),e([c()],U.prototype,"title",void 0),e([c()],U.prototype,"updateLocationEnabled",void 0),e([c()],U.prototype,"view",void 0),e([c()],U.prototype,"visible",void 0),e([c({readOnly:!0})],U.prototype,"waitingForContents",null),e([c({readOnly:!0})],U.prototype,"waitingForResult",null),e([c()],U.prototype,"zoomFactor",void 0),e([c()],U.prototype,"zoomToLocation",void 0),e([c()],U.prototype,"centerAtLocation",null),U=e([d("esri.widgets.Features.FeaturesViewModel")],U);const G=U;export{G as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as h,sync as u}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{initializeProjection as p,project as g}from"../../geometry/projection.js";import{getPointFromGeometry as f}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as m}from"../../geometry/support/webMercatorUtils.js";import y from"../../layers/Layer.js";import{fallbackObjectIDAttribute as w}from"../../layers/LayerConstants.js";import{getDisplayedSymbol as F}from"../../symbols/support/symbolUtils.js";import{highlightsSupported as v}from"../../views/support/layerViewUtils.js";import _ from"../Feature/FeatureViewModel.js";import{ActionsCollection as b,zoomToFeature as C,zoomToClusteredFeatures as P,browseClusteredFeatures as E}from"../Popup/actions.js";import{triggerAction as j,isClusterFeature as M,removeClusteredFeaturesForBrowsing as A,displayClusterExtent as L,browseAggregateFeatures as V,getSelectedTarget as I}from"../Popup/actionUtils.js";import S from"../support/AnchorElementViewModel.js";import{GoToMixin as O}from"../support/GoTo.js";import x from"../../symbols/SimpleFillSymbol.js";import T from"../../geometry/Point.js";const H=()=>[C.clone()],B=()=>[P.clone(),E.clone()];let R=null;function U(e,t){return"building-scene"===e||"2d"===t&&("map-image"===e||"tile"===e||"imagery"===e||"imagery-tile"===e)}let G=class extends(O(S)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightSelectedFeaturePromise=null,this._highlightActiveFeaturePromise=null,this._selectedClusterFeature=null,this._locationScaleHandle=null,this.actions=new b,this.activeFeature=null,this.autoCloseEnabled=!1,this.autoOpenEnabled=!0,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.selectedClusterBoundaryFeature=new t({symbol:new x({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=o((async e=>{const{view:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if("mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const{pendingFeatures:e}=await this._fetchFeaturesWithController({mapPoint:s}),i=(await Promise.all(e)).flat().filter(Boolean);if(!i.length)return;if(i.length!==this.features.length){const e=this._getHighlightLayer(this.selectedFeature),t="imagery"===e?.type?void 0:e&&"objectIdField"in e?e.objectIdField||w:null;if(t){const s=this.selectedFeature.getObjectId(),r=i.findIndex((i=>{const r=this._getHighlightLayer(i);return r?.uid===e?.uid&&i.attributes[t]===s}));this.features=i,this.selectedFeatureIndex=r}}const r=i[this.selectedFeatureIndex]?.geometry,o=("mesh"!==r?.type?r:null)??this.selectedFeature.geometry,a=g(o,t.spatialReference);R||(R=await import("../../geometry/geometryEngineAsync.js")),a&&!await R.intersects(a,s)&&(this.location=(await R.nearestCoordinate(a,s)).coordinate??s)}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=f(this.selectedFeature.geometry)??s}))}initialize(){this.addHandles([this.on("view-change",(()=>this._autoClose())),l((()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view]),(()=>this._highlightSelectedFeature())),l((()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view]),(()=>this._highlightActiveFeature())),l((()=>this.view?.animation?.state),(e=>this._animationStateChange(e))),l((()=>this.location),(e=>this._locationChange(e))),l((()=>this.selectedFeature),(e=>this._selectedFeatureChange(e))),l((()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage]),(()=>this._selectedFeatureIndexChange())),l((()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels]),(()=>this._setGraphicOnFeatureViewModels())),l((()=>this.featureViewModels),(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>j({event:e,viewModel:this,view:this.view}))),h((()=>!this.waitingForResult),(()=>this._waitingForResultChange()),u),l((()=>[this.features,this.view?.map,this.view?.spatialReference,this.view?.timeZone]),(()=>this._updateFeatureVMs())),l((()=>this.view?.scale),(()=>this._viewScaleChange())),h((()=>!this.visible),(()=>this.browseClusterEnabled=!1)),l((()=>this.browseClusterEnabled),(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this._locationScaleHandle?.remove(),this._locationScaleHandle=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new b;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,h=n?.overwriteActions?l:l?.concat(a)??a;return h?.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){const e=this._get("defaultActions")||new b;return e.removeAll(),e.addMany(M(this.selectedFeature)?B():H()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1)}set location(e){let t=e;const i=this.view?.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=m(e)),this._set("location",t)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice(0)).forEach((e=>this._pendingPromises.add(e))),e.reduce(((e,t)=>e.finally((()=>t.then((e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)})).finally((()=>this._pendingPromises.delete(t))).catch((()=>{}))))),Promise.resolve())):this._set("promises",[])}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;e=isNaN(e)||e<-1||!t?-1:(e+t)%t,this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get state(){return this.view?.ready?"ready":"disabled"}get waitingForContents(){return this.featureViewModels.some((e=>e.waitingForContent))}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=I(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex++,this}previous(){return this.selectedFeatureIndex--,this}disableClusterBrowsing(){A(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?M(t)?(await L(this),await V(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}handleViewClick(e){this.autoOpenEnabled&&this._fetchFeaturesAndOpen(e)}_animationStateChange(e){this.zoomToLocation||(C.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(M(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i}=this;i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>1?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>1?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null===i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach(((t,i)=>{t&&(t.graphic??=e[o+i])}))}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(e&&s){if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),M(e))return;return e.symbol=await F(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}if(e.symbol=await F(e),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=f(e.geometry)}}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s}=this;if(M(e)||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const r=i.slice(0),o=[];t.forEach(((t,i)=>{if(!t)return;let a=null;if(r.some(((e,i)=>(e&&e.graphic===t&&(a=e,r.splice(i,1)),!!a))),a)o[i]=a;else{const r=new _({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:s?.spatialReference,graphic:t===e?t:null,location:this.location,map:s?.map,view:s});o[i]=r}})),r.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",o)}async _getScreenPoint(e,t){const{view:i}=this;await(i?.when());const s=e?.spatialReference,r=i?.spatialReference;return s&&r?(await p(s,r,null,t),i.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch((()=>{})).then((()=>{this._fetchFeaturesController=null})),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e,{view:s}=this;this._locationScaleHandle?.remove(),this._locationScaleHandle=l((()=>this.view?.scale),(()=>this._debouncedLocationUpdate(t).catch((e=>{a(e)||r.getLogger(this).error(e)}))));const{pendingFeatures:o}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:o})}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t}_getHighlightTarget(e,t,i){if(U(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||w:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.view?.map?.allLayers?.includes(e)}async _highlightActiveFeature(){const e="highlight-active-feature";this.removeHandles(e);const{highlightEnabled:t,view:i,activeFeature:s,visible:r}=this;if(!(s&&i&&t&&r))return;const o=this._getHighlightLayer(s);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(i,o);this._highlightActiveFeaturePromise=a;const n=await a;if(!(n&&v(n)&&this._highlightActiveFeaturePromise===a&&this.activeFeature&&this.highlightEnabled))return;const l=n.highlight(this._getHighlightTarget(s,o,i.type));this.addHandles(l,e)}async _highlightSelectedFeature(){const e="highlight-selected-feature";this.removeHandles(e);const{selectedFeature:t,highlightEnabled:i,view:s,visible:r}=this;if(!(t&&s&&i&&r))return;const o=this._getHighlightLayer(t);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(s,o);this._highlightSelectedFeaturePromise=a;const n=await a;if(!(n&&v(n)&&this._highlightSelectedFeaturePromise===a&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const l=n.highlight(this._getHighlightTarget(t,o,s.type));this.addHandles(l,e)}_updateFeatures(e){const{features:t}=this,i=e.filter((e=>!t.includes(e)));i?.length&&(this.features=t.concat(i))}};e([c()],G.prototype,"_fetchFeaturesController",void 0),e([c({type:b})],G.prototype,"actions",void 0),e([c({readOnly:!0})],G.prototype,"active",null),e([c()],G.prototype,"activeFeature",void 0),e([c({readOnly:!0})],G.prototype,"allActions",null),e([c()],G.prototype,"autoCloseEnabled",void 0),e([c()],G.prototype,"autoOpenEnabled",void 0),e([c()],G.prototype,"browseClusterEnabled",void 0),e([c()],G.prototype,"content",void 0),e([c({type:b,readOnly:!0})],G.prototype,"defaultActions",null),e([c({type:Boolean})],G.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],G.prototype,"featureCount",null),e([c()],G.prototype,"featurePage",void 0),e([c({value:[]})],G.prototype,"features",null),e([c()],G.prototype,"featuresPerPage",void 0),e([c()],G.prototype,"featureMenuOpen",void 0),e([c()],G.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],G.prototype,"featureViewModels",void 0),e([c()],G.prototype,"highlightEnabled",void 0),e([c()],G.prototype,"includeDefaultActions",void 0),e([c({type:T})],G.prototype,"location",null),e([c({readOnly:!0})],G.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],G.prototype,"promiseCount",null),e([c()],G.prototype,"promises",null),e([c({readOnly:!0})],G.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],G.prototype,"selectedFeature",null),e([c({value:-1})],G.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],G.prototype,"selectedFeatureViewModel",null),e([c({readOnly:!0})],G.prototype,"state",null),e([c()],G.prototype,"title",void 0),e([c()],G.prototype,"updateLocationEnabled",void 0),e([c()],G.prototype,"view",void 0),e([c()],G.prototype,"visible",void 0),e([c({readOnly:!0})],G.prototype,"waitingForContents",null),e([c({readOnly:!0})],G.prototype,"waitingForResult",null),e([c()],G.prototype,"zoomFactor",void 0),e([c()],G.prototype,"zoomToLocation",void 0),e([c()],G.prototype,"centerAtLocation",null),G=e([d("esri.widgets.Features.FeaturesViewModel")],G);const z=G;export{z as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import"../../../intl.js";import{addTokenParameter as s}from"../../../kernel.js";import l from"../../../request.js";import"../../../symbols.js";import i from"../../../core/Accessor.js";import{isSome as r}from"../../../core/arrayUtils.js";import n from"../../../core/Collection.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{debounce as u}from"../../../core/promiseUtils.js";import{on as c,watch as d,whenOnce as y,initial as h}from"../../../core/reactiveUtils.js";import{px2pt as m}from"../../../core/screenUtils.js";import{addQueryParameters as f}from"../../../core/urlUtils.js";import{property as p}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as g}from"../../../core/accessorSupport/decorators/subclass.js";import{OriginId as b}from"../../../core/accessorSupport/PropertyOrigin.js";import{EffectView as S}from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as _}from"../../../layers/effects/jsonUtils.js";import{ExportImageParameters as v}from"../../../layers/support/ExportImageParameters.js";import{isFeatureLayer as w}from"../../../layers/support/layerUtils.js";import{getPixelValueRange as L}from"../../../layers/support/rasterFormats/pixelRangeUtils.js";import{fromJSON as E}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as C}from"../../../renderers/support/rendererConversion.js";import I from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{applyCIMSymbolColor as R}from"../../../symbols/support/cimSymbolUtils.js";import{SymbolSizeDefaults as F}from"../../../symbols/support/previewUtils.js";import{renderSymbol as V}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as T,renderDotDensityPreviewHTML as z,renderPieChartPreviewHTML as x,renderPreviewHTML as D}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as j}from"../../../symbols/support/utils.js";import{getEffectiveClusterSizeVariable as O}from"./clusterUtils.js";import{getColorFromPointCloudStops as P,getRampStopsForPointCloud as A,getStretchRampStops as M,getRampStops as U}from"./colorRampUtils.js";import{getHeatmapRampStops as k}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as B,getRelationshipRampElement as N}from"./relationshipRampUtils.js";import{getRampStops as q,realWorldMaxSize as H,realWorldMinSize as $}from"./sizeRampUtils.js";import{specialCharsLessThan as W,specialCharsGreaterThan as G,getSymbolForFlowRenderer as J,isRasterBandStatistics as Q,getMedianColor as Z,rgbImgSource as K,getDateFormatOptions as X}from"./utils.js";import{formatNumberLabel as Y}from"../../smartMapping/support/utils.js";import ee from"../../../symbols/SimpleMarkerSymbol.js";import te from"../../../symbols/SimpleFillSymbol.js";import{fetchMessageBundle as se}from"../../../intl/messages.js";import{substitute as le}from"../../../intl/substitute.js";const ie="https://utility.arcgis.com/sharing/tools/legend",re="esri.layers.ImageryLayer",ne="esri.layers.ImageryTileLayer",ae="esri.layers.WCSLayer",oe=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,ue=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),ce=new ee({size:6,outline:{color:[128,128,128,.5],width:.5}}),de=new te({style:"solid"});function ye(e){return"flow"===e.type}function he(e){return"vector-field"===e.type}function me(e){return"raster-colormap"===e.type}function fe(e){return"raster-stretch"===e.type}function pe(e){return"raster-shaded-relief"===e.type}function ge(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function be(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function Se(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function _e(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function ve(e){return Le(e)||Ee(e)||Ce(e)||we(e)}function we(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function Le(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function Ee(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function Ie(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function Re(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function Fe(e,t){return ge(e)||be(e)||Se(e)||_e(e)||Ie(e)||Re(e)?"2d"===t.type||C(e):fe(e)||me(e)||pe(e)||Le(e)||Ee(e)||Ce(e)||he(e)||ye(e)}function Ve(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Te(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function ze(e){return"esri.layers.VoxelLayer"===e.declaredClass}function xe(e){return"esri.layers.WMSLayer"===e.declaredClass}function De(e){return"esri.layers.WMTSLayer"===e.declaredClass}function je(e){return"esri.layers.MapImageLayer"===e.declaredClass}function Oe(e){return"esri.layers.TileLayer"===e.declaredClass}function Pe(e){return e.declaredClass===re}function Ae(e){return e.declaredClass===ne}function Me(e){return e.declaredClass===ae}function Ue(e){return"stretch-ramp"===e.type}function ke(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type}function Be(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}function Ne(e){return"sublayers"in e}async function qe(e,t){const s=await se("esri/widgets/Legend/t9n/Legend");return"previewTemplateAriaLabel"!==e||t||(e="previewAriaLabel"),le(s[e],{label:t})}const He=new ee({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let $e={},We=class extends i{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.children=new n,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this.addHandles([c((()=>this.children),"change",(t=>{const{added:s,removed:l}=t;s.forEach((t=>{const s=`activeLayerInfo-ready-watcher-${t.layer.uid}`;this.addHandles(d((()=>t.ready),e,h),s)})),l.forEach((e=>this.removeHandles(e.layer.uid))),e()}))]),this.keepCacheOnDestroy||($e={})}destroy(){this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||($e=null)}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new S,t.effect=e.effect,t.endTransitions(),t.scale=this.scale),t}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,s=this.layer.parent,l=s&&"uid"in s?this._getParentLayerOpacity(s):null;return null!=t?t*e:null!=l?l*e:e}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view?.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?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(w(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet?.features.length){const t=e.layerDefinition,s=t?.drawingInfo,l=s&&E(s.renderer),i=ue.read(t.geometryType);return l?this._getRendererLegendElements(l,{title:e.name,geometryType:i}):(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(ze(e))this._constructLegendElementsForVoxelLayer();else if(De(e))this._constructLegendElementsForWMTSlayer();else if(xe(e))await this._constructLegendElementsForWMSSublayers();else if(Ve(e))await this._constructLegendElementsForBuildingSceneLayer();else if(je(e)||Oe(e)||Te(e))await this._constructLegendElementsForSublayers();else{this.removeHandles("imageryLayers-watcher");let t="default";if(Pe(e)){const s=e;t=(s?.rasterFunction?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}if(Ae(e))return;await this._getLegendLayers(`${e.uid}-${t}`).then((async t=>{this.legendElements=[],this.notifyChange("ready");const s=t.map((async t=>{if(Pe(e)){const t=d((()=>["renderingRule"in e&&e.rasterFunction,e.bandIds]),(()=>u((async()=>{$e.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()}))()));this.addHandles(t,"imageryLayers-watcher")}const s=this._generateSymbolTableElementForLegendLayer(t);s&&s.infos.length&&(Pe(e)&&(s.title=e.title),this.legendElements.push(s)),this.notifyChange("ready")}));await 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 y((()=>!t.updating));const l=s?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();if(!l)return!0;l.geometry=this.view.extent;return 0!==(s?"queryFeatureCount"in t&&await t.queryFeatureCount(l):"queryFeatureCount"in e&&await e.queryFeatureCount(l))}_getParentLayerOpacity(e){let t=1;const s=e.parent;return s&&"uid"in s&&(t=this._getParentLayerOpacity(s)),e.opacity*t}_isGroupActive(){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(oe.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:l}=e.data,i=t?.some((e=>/\$view\.scale/.test(e.valueExpressionInfo?.expression||"")))??!1;return null!=s||null!=l||i}return!1}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,s=t.minSize,l=t.maxSize;return!("object"!=typeof s||!s||!this._isScaleDrivenSizeVariable(s))||(!("object"!=typeof l||!l||!this._isScaleDrivenSizeVariable(l))||(!!t.expression||oe.test(t.valueExpression)))}_isLayerScaleDriven(e){if("minScale"in e&&e.minScale>0||"maxScale"in e&&e.maxScale>0)return!0;if("sublayers"in e&&e.sublayers)return e.sublayers.some((e=>this._isLayerScaleDriven(e)));const t=e.parent;if(!1===e.loaded&&t&&je(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const s of t.sourceJSON.layers??[])if(s.id===e.source.mapLayerId&&(s.minScale>0||s.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxelLayer(){this.legendElements=[],this.removeHandles("voxel-style-watcher"),this.removeHandles("voxel-current-variable");const e=this.layer;this.addHandles(d((()=>e.currentVariableId),(()=>this._constructLegendElementsForVoxelLayer())),"voxel-current-variable"),this.addHandles(d((()=>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 te({color:t.color,outline:null})})})),e.length&&s.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:l}=t.transferFunction,i=e.toArray().reverse(),r=l.map(((e,t)=>`${0===t?W:G} ${Y(e)}`)).reverse(),n=i.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:T(i.map((e=>e.color)),{ariaLabel:await qe("previewColorRampAriaLabel")})})}const l=e.opacity,i=s.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol)).map((e=>this._getSymbolPreview(e,l)));await Promise.allSettled(i),this.legendElements=s,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this.removeHandles("wmts-activeLayer-watcher");const e=this.layer.activeLayer;this.addHandles(d((()=>{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(d((()=>{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,l=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher");const i=this.sublayerIds?.map((e=>s.findSublayerById(e)))?.filter(r)??[],n=i.length?i:e.toArray();for(const r of n){const e=d((()=>[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&&l.unshift(e)}}return l}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 i={type:"symbol-table",title:e.title||e.name||String(e.id??""),infos:[]};t&&(s=f(s,t));let r=null;const n=e.layer?.opacity;try{r=(await l(s,{responseType:"image"})).data,r&&(r.style.opacity=n)}catch{}return i.infos.push({src:s,preview:r,opacity:n}),i}_getLegendLayers(e,t){const s=$e&&$e[e];return s?Promise.resolve(s):this._legendRequest(t).then((t=>{const s=t.layers;return $e[e]=s,s}))}_legendRequest(e){const t=this.layer;let s={f:"json",dynamicLayers:e};if(Pe(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:l,customParameters:i}=t;s={raster:e,viewId:l,...s,...i}}}let i=t.url.replace(/(\/)+$/,"");if("version"in t&&+t.version>=10.01){const e=i.indexOf("?");e>-1?i=i.substring(0,e)+"/legend"+i.substring(e):i+="/legend"}else{const e=i.toLowerCase().indexOf("/rest/"),t=i.substring(0,e)+i.substring(e+5,i.length);i=ie+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return l(i,{query:s}).then((e=>e.data))}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;this.addHandles(d((()=>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 l=e.toArray();for(const i of l){const e=d((()=>["renderer"in i&&i.renderer,i.opacity,i.title,i.visible]),(()=>this._constructLegendElementsForBuildingSceneLayer()));if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||i.visible){const e=null!=i?.opacity?i.opacity:null,l=null!=e?e*t:t;if("building-group"===i.type){const e={type:"symbol-table",title:i.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(i.sublayers,l);e.infos.push(...t),s=[e,...s]}else if(i.renderer){s=[...await this._getRendererLegendElements(i.renderer,{title:i.title,opacity:l,sublayer:i}),...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(je(e)||Oe(e)||Te(e)){this.addHandles(d((()=>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 l=this.layer;let i=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForSublayers())),"sublayers-watcher");let n=e.toArray();!s&&this.sublayerIds&&this.sublayerIds.length&&(n=Te(l)?this.sublayerIds.map((e=>l.findSublayerForSubtypeCode(e))).filter(r):this.sublayerIds.map((e=>l.findSublayerById(e))).filter(r));for(const r of n){const e=d((()=>[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,l=null!=e?e*t:t,n=!Ne(r)||r.originIdOf("renderer")>b.SERVICE&&!r.sublayers;if(r.renderer&&n){await r.load();i=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:l,sublayer:r}),...i]}else if(Ne(r)){const e=await this._generateSymbolTableElementForSublayer(r,l,s);e&&i.unshift(e)}}}return i.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,l=e.source;let i=null;if(!(!l||"map-layer"===l.type&&l.mapLayerId===e.id&&(!l.gdbVersion||l.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>b.SERVICE||e.originIdOf("labelingInfo")>b.SERVICE||e.originIdOf("labelsVisible")>b.SERVICE){const e=new v({layer:this.layer});i=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const r=i||`${t.uid}-default`;(await this._getLegendLayers(r,i)).forEach((e=>s.set(e.layerId,e)))}const l=s.get(e.id);if((!l||l?.subLayerIds&&l.defaultVisibility)&&e.sublayers){const l=await this._generateLegendElementsForSublayers(e.sublayers,t,s);return{type:"symbol-table",title:e.title,infos:l}}return this._generateSymbolTableElementForLegendLayer(l,e,t)}_generateSymbolTableElementForLegendLayer(e,t,s){if(!e?.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const l=t?.renderer;let i=t?.title||e.layerName;if(l&&(!t||t?.originIdOf("renderer")>b.SERVICE)){const e=t?.title||this._getRendererTitle(l,t);e&&(i&&"string"!=typeof e&&"title"in e&&(e.title=i),i=e)}const r={type:"symbol-table",title:i,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 l={type:"symbol-table",title:t.heading,legendType:e.legendType||null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter((e=>e.groupId===t.id)),e.layerId,s)};l.infos?.length>0&&r.infos.push(l)})):r.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,s),r.infos.length>0?r:null}_generateSymbolTableElementInfosForLegendLayer(e,t,l){return e.map((e=>{let i=e.url;if(e.imageData&&e.imageData.length>0)i=`data:image/png;base64,${e.imageData}`;else{if(0===i.indexOf("http"))return null;i=s(`${this.layer.url}/${t}/images/${i}`)}return{label:e.label,src:i,opacity:l??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 l=null,i=null,r=!0;return!s.minScale&&0!==s.minScale||!s.maxScale&&0!==s.maxScale?(0===e.minScale&&s.tileInfo&&(l=s.tileInfo.lods[0].scale),0===e.maxScale&&s.tileInfo&&(i=s.tileInfo.lods[s.tileInfo.lods.length-1].scale)):(l=Math.min(s.minScale,e.minScale)||s.minScale||e.minScale,i=Math.max(s.maxScale,e.maxScale)),(l>0&&l<this.scale||i>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,l=e.some((e=>e.values));let i=0,r=null;return l&&e.some(((e,t)=>(e.values||(i=t,r=e,r.label||(r.label="others")),null!=r))),s?"unique-value"===s.type?r&&(e.splice(i,1),e.push(r)):"class-breaks"===s.type&&(r&&e.splice(i,1),e.reverse(),r&&e.push(r)):r&&(e.splice(i,1),e.push(r)),e}async _getRendererLegendElements(e,t={}){if(!Fe(e,this.view))return o.getLogger(this).warn(`Renderer of type '${e.type}' not supported!`),[];if(ve(e))return this._constructPointCloudRendererLegendElements(e,t);if(Ie(e))return this._constructDotDensityRendererLegendElements(e);const s=await this._loadRenderer(e);return Re(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,l=[];let i=null,r=null;if(Le(e))i={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach((e=>{i.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(ce,e.color)})}));else if(Ee(e)){const t=e.stops;let l=null;if(t?.length&&(1===t.length&&(l=t[0].color),!l)){const e=t[0].value,s=t[t.length-1].value;if(null!=e&&null!=s){l=P(e+(s-e)/2,t)}}i={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(ce,l||ce.color)}]};const n=A(e.stops??[])??[];r={type:"color-ramp",title:s||this._getPointCloudRendererTitle(e),infos:n,preview:T(n.map((e=>e.color)),{ariaLabel:await qe("previewColorRampAriaLabel")})}}else Ce(e)&&(i={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos?.forEach((e=>{i.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(ce,e.color)})})));i&&i.infos.length&&l.push(i),r&&r.infos.length&&l.push(r);const n=l.reduce(((e,t)=>[...e,...t.infos??[]]),[]).filter((e=>!!e.symbol)).map((t=>this._getSymbolPreview(t,this.opacity,{symbolConfig:{applyColorModulation:!!e.colorModulation}})));return await Promise.allSettled(n),l}async _getElementInfoForDotDensity(e,t){const{color:s,label:l,valueExpressionTitle:i}=t,{backgroundColor:r,outline:n,dotSize:a}=e,o=this.effectList,u=o?.effects.map((e=>e.toJSON())),c=_(u),d=await qe("previewTemplateAriaLabel",l||i),y=a+"-"+s+"-"+r+"-"+(n&&JSON.stringify(n.toJSON()))+"-"+c,h=this._dotDensityUrlCache,m=h.has(y)?h.get(y):z(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=V([[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,l={type:"symbol-table",title:{value:t&&Math.round(t),unit:s||""},infos:[]};for(const i of e.attributes){const t=await this._getElementInfoForDotDensity(e,i);t.label=i.label||i.valueExpressionTitle||i.field,l.infos.push(t)}return[l]}async _constructPieChartRendererLegendElements(e){const t=this.layer.opacity,s=[];let l=null;const i=e.outline;e.attributes.forEach((e=>{const t=new ee({color:e.color,outline:i}),l=e.label||e.valueExpressionTitle||e.field;s.push({label:l,symbol:t})}));const r=s.length?[...s]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const t=new ee({color:e.othersCategory.color,outline:i});l=e.othersCategory.label||"Other",s.push({label:l,symbol:t})}if(e.defaultColor?.a){const t=new ee({color:e.defaultColor,outline:i});s.push({label:e.defaultLabel,symbol:t})}const n=await this._getVisualVariableLegendElements(e,this.layer)||[];if(s.length){n.unshift({type:"symbol-table",title:null,infos:s});const t=r.filter((e=>e.label!==l)).map((e=>e.symbol.color)).filter(Boolean),a=x(t,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,effectList:this.effectList,outline:i,ariaLabel:await qe("previewPieChartAriaLabel")});n.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:s,preview:a})}const a=n.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol&&!e?.preview)).map((e=>this._getSymbolPreview(e,t,{effectList:this.effectList})));return await Promise.allSettled(a),n}async _constructRendererLegendElements(e,t={}){const{title:s,sublayer:l}=t,i=l||this.layer;this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const r=await this._getVisualVariableLegendElements(e,i)||[],n={type:"symbol-table",title:s||this._getRendererTitle(e,i),infos:[]};let a=null,o=!1;const u=new Set;if(ye(e)&&!this._hasSizeRamp){const t=await J(e);n.infos.push({label:null,symbol:t})}else if(ke(e)){let t=s;const l=Be(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",i=r.findIndex((e=>"color-ramp"===e.type)),n=-1!==i?r.splice(i,1)[0]:null,a=r.findIndex((e=>"size-ramp"===e.type)),o=-1!==a?r.splice(a,1)[0]:null,u=[];n&&(t=n.title,u.push(n)),o&&(t=o.title,u.push(o)),u.length>0&&r.push({type:l,title:t,infos:u})}else if(_e(e)){const t=k(e);r.push({type:"heatmap-ramp",title:s||this._getRendererTitle(e,i),infos:t,preview:T(t.map((e=>e.color)),{effectList:this.effectList,ariaLabel:await qe("previewColorRampAriaLabel")})})}else if(Se(e)){const t=e&&e.authoringInfo;if(t&&"relationship"===t.type){const{numClasses:s,field1:l,field2:a}=t,o=t.focus;if(s&&l&&a){const t=[l,a];let c=B(o)||0;for(const e of t){const{field:t,normalizationField:s,label:l}=e,r=l||{field:this._getFieldAlias(t,i),normField:s&&this._getFieldAlias(s,i)},a=He.clone();a.angle=c,n.infos.push({label:r,symbol:a}),u.add(a),c+=90}const d=N({focus:o,numClasses:s,infos:e.uniqueValueInfos??[]});r.unshift(d)}}else if(Pe(this.layer)||Ae(this.layer))e.uniqueValueInfos?.forEach((e=>{e.symbol&&n.infos.push({label:e.label||e.value,value:e.value,symbol:e.symbol})}));else{const{field:t,field2:l,field3:r,fieldDelimiter:a,valueExpression:u,defaultSymbol:c}=e,d=!(!t&&!u||!l&&!r),y=[];if(e.uniqueValueGroups?.forEach((e=>{const s={type:"symbol-table",title:e.heading,infos:[]};e.classes?.forEach((e=>{const{symbol:n,values:o}=e;if(n){const c=[],y=[];for(const e of o??[]){const{value:s,value2:n,value3:o}=e,h=[],m=[];(t||u)&&(h.push(s),m.push(this._getDomainName(t,s,i))),l&&(h.push(n),m.push(this._getDomainName(l,n,i))),r&&(h.push(o),m.push(this._getDomainName(r,o,i))),c.push(d?h.join(a||""):h[0]),y.push(m.join(" - "))}const h=c.join(", ");let m=e.label;if(!m){const e=y.filter(Boolean);m=e.length?e.join(", "):h}s.infos.push({label:m,value:h,symbol:n})}})),s.infos.length&&y.push(s)})),y.length){const t=y[0];1===y.length&&"title"in t&&!t.title?n.infos.push(...t.infos??[]):(c&&(y.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:c}]}),o=!0),n.infos.push(...y)),s||e.legendOptions?.title||e.valueExpressionTitle||(n.title=null)}}e.defaultSymbol&&!o&&(n.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),o=!0)}else if(be(e)){a=this._isUnclassedRenderer(e);(!a||!this._hasSizeRamp)&&(e.classBreakInfos.forEach((e=>{e.symbol&&n.infos.unshift({label:e.label||(a?null:e.minValue+" - "+e.maxValue),value:[e.minValue,e.maxValue],symbol:e.symbol})})),a&&(n.title=null),this._updateInfosForClassedSizeRenderer(e,n.infos)),e.defaultSymbol&&!a&&(n.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),o=!0)}else if(fe(e))if(Ae(this.layer)||Me(this.layer)){const t=await this._constructTileImageryStretchRendererElements(e);Ue(t)?r.push(t):n.infos=t}else{const t=this.layer;let s,l;if(e.statistics?.length){const t=e.statistics[0];Q(t)?(s=t.min,l=t.max):[s,l]=t}let i=[],a=t.serviceRasterInfo;if(t.rasterFunction)try{a=await t.generateRasterInfo(t.rasterFunction)}catch{}const o=L(a.pixelType);if(1===a.bandCount){const i=t.bandIds?.[0]||0;s=null!=s?s:a.statistics?a.statistics[i].min:o[0],l=null!=l?l:a.statistics?a.statistics[i].max:o[1],s||l?r.push(await this._getStretchLegendElements(e,{min:s,max:l})):this._getServerSideLegend()}else if(t.bandIds&&1===t.bandIds.length)s=null!=s?s:a.statistics?a.statistics[t.bandIds[0]].min:o[0],l=null!=l?l:a.statistics?a.statistics[t.bandIds[0]].max:o[1],s||l?r.push(await this._getStretchLegendElements(e,{min:s,max:l})):this._getServerSideLegend();else if(a.bandCount>=3){const{bandInfos:e}=a,{bandIds:s}=t;e.length>=a.bandCount?3===s?.length?(i=s.map((t=>e[t].name)),n.infos=this._createSymbolTableElementMultiBand(i)):"lerc"===t.format?(i=[0,1,2].map((t=>e[t].name)),n.infos=this._createSymbolTableElementMultiBand(i)):this._getServerSideLegend():"lerc"===t.format?(i=["band1","band2","band3"],n.infos=this._createSymbolTableElementMultiBand(i)):this._getServerSideLegend()}else this._getServerSideLegend()}else if(me(e))e.colormapInfos.forEach((e=>{n.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(de,e.color)})}));else if(ge(e)){let s=e.symbol;switch(t.geometryType){case"point":s="pointSymbol"in i?i.pointSymbol:null;break;case"polyline":s="lineSymbol"in i?i.lineSymbol:null;break;case"polygon":s="polygonSymbol"in i?i.polygonSymbol:null}const l=this._hasClusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&l&&n.infos.push({label:e.label,symbol:s})}else if(he(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),n.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach((e=>{n.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})})):n.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else pe(e)&&r.push(await this._getStretchLegendElements(e,{min:0,max:255}));const c=e.defaultSymbol;!c||o||ge(e)||a&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||r.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:c}]}),n.infos.length&&r.unshift(n);const d=null==t.opacity?this.opacity:t.opacity,y=this._isTallSymbol("visualVariables"in e?e.visualVariables:null),h=Pe(this.layer)||Ae(this.layer),m=r.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol)).filter((e=>{if("cim"===e.symbol.type){const{minScale:t,maxScale:s}=e.symbol.data;if(t&&t<this.scale||s&&s>this.scale)return!1}return!0})).map((e=>this._getSymbolPreview(e,d,{isDefault:e.symbol===c,applyScaleDrivenSize:!u.has(e.symbol),symbolConfig:{isTall:y,isSquareFill:h},effectList:u.has(e.symbol)?null:this.effectList})));return e=null,await Promise.allSettled(m),r}_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 l,i;const r=e?.statistics?.length?e.statistics:s?.statistics;if(r){const e=r[0];Q(e)?(l=e.min,i=e.max):[l,i]=e}else{const e=L(s.pixelType);l=e[0],i=e[1]}if(t.hasStandardTime()&&(l=t.getStandardTimeValue(l),i=t.getStandardTimeValue(i)),1===s.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:l,max:i});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,l=M(s,t);return{type:"stretch-ramp",title:"",infos:l,preview:T(l.map((e=>e.color)),{ariaLabel:await qe("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,l){return{type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(t):e,infos:await q(s,t,await Z(s),this.scale,this.view,l,this._hasClusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],s=["red","green","blue"];return e.forEach(((e,l)=>{t.push({label:{colorName:s[l],bandName:e},src:K[l],opacity:this.opacity??1})})),t}_updateInfosForClassedSizeRenderer(e,t){const s=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,l=e.classBreakInfos.some((e=>j(e.symbol)));if(s&&l){const s=H,l=$,i=e.classBreakInfos.length,r=(s-l)/(i>1?i-1:i);t.forEach(((e,t)=>{e.size=s-r*t}))}}_isTallSymbol(e){let t=!1,s=!1;if(e)for(let l=0;l<e.length&&(!t||!s);l++){const i=e[l];"size"===i.type&&("height"===i.axis&&(t=!0),"width-and-depth"===i.axis&&(s=!0))}return t&&s}async _getSymbolPreview(e,t,s){let l=!s?.isDefault&&null==e.size&&this._hasSizeRamp?m(F.size):e.size;if(this._scaleDrivenSizeVariable&&s?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");l=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}const i=!s?.isDefault&&this._hasSizeRamp||!(!this._scaleDrivenSizeVariable||!s?.applyScaleDrivenSize);return D(e.symbol,{size:l,opacity:t,scale:!1,symbolConfig:s?.symbolConfig,effectView:s?.effectList,style:"legend",cimOptions:{allowScalingUp:i,viewParams:this.isScaleDriven?{viewingMode:"2d"===this.view?.type?"map":this.view?.viewingMode,scale:this.view?.scale}:null},ariaLabel:e.label&&"string"!=typeof e.label?null:await qe("previewTemplateAriaLabel",e.label)}).then((t=>(e.preview=t,e))).catch((()=>(e.preview=null,e)))}_getClusterRenderer(e){this._hasClusterSizeVariable=!1;const t="renderer"in this.layer?this.layer.renderer:null,s=e.renderer?.clone()||t?.clone(),l=O(e,this.layerView,this.view);if(l&&null!=s&&"visualVariables"in s){const t=s.visualVariables?.some((e=>"size"===e.type&&"outline"!==e.target&&!oe.test(e.valueExpression)));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:s}=e;l.legendOptions=new I({showLegend:t!==s})}const t=s.visualVariables||[];s.visualVariables=t.concat([l]),this._hasClusterSizeVariable=!0}}return s}async _loadRenderer(e){const t=[],s=e.clone(),l=await Z(s);if(be(s)||Se(s)){const e=(s.classBreakInfos||s.uniqueValueInfos).map((e=>this._fetchSymbol(e.symbol,l).then((t=>{e.symbol=t})).catch((()=>{e.symbol=null}))));Array.prototype.push.apply(t,e)}return t.push(this._fetchSymbol(s.symbol||s.defaultSymbol,s.defaultSymbol?null:l).then((e=>{this._applySymbolToRenderer(s,e,ge(s))})).catch((()=>{this._applySymbolToRenderer(s,null,ge(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 l=await("2d"===this.view.type?e.fetchCIMSymbol({cache:s}):e.fetchSymbol({cache:s}));return this._getAppliedCloneSymbol(l,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 l=e.clone(),i=s&&s.toRgba();return l.type.includes("3d")?this._applyColorTo3dSymbol(l,i):"cim"===l.type?R(l,s):l.color&&(l.color=new t(i||l.color)),l}_applyColorTo3dSymbol(e,s){s&&e.symbolLayers.forEach((e=>{e&&(e.material||(e.material={}),e.material.color=new t(s))}))}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||!e.visualVariables||"vector-field"===e.type)return null;const s=e.visualVariables,l=[],i=[],n=[];for(const r of s)"color"===r.type?l.push(r):"size"===r.type?i.push(r):"opacity"===r.type&&n.push(r);const a=[...l,...i,...n];let o,u;if(0===l.length&&be(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];o=t&&t.symbol}if(0===l.length&&ge(e)&&(o=e.symbol),o)if(o.type.includes("3d")){const e=o.symbolLayers.at(0);"water"===e.type?null!=e.color&&(u=e.color):null!=e.material?.color&&(u=e.material.color)}else o.url||(u=o.color);const c=this.effectList;return(await Promise.all(a.map((async s=>{if(!s.legendOptions||!1!==s.legendOptions.showLegend){const l=ye(e)?s.field:this._getRampTitle(s,t);let i=null;const r=X(t,s,this.view.timeZone);if("color"===s.type){const e=await U(s,null,r)??[];i={type:"color-ramp",title:l,infos:e,preview:T(e.map((e=>e.color)),{effectList:c,ariaLabel:await qe("previewColorRampAriaLabel")})},this._hasColorRamp||(this._hasColorRamp=e.length>0)}else if("size"===s.type&&"outline"!==s.target)oe.test(s.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=s):(i=await this._getSizeLegendElement(l,s,e,r),this._hasSizeRamp||(this._hasSizeRamp=!(null==i.infos||!i.infos.length)));else if("opacity"===s.type){const e=await U(s,u,r)??[];i={type:"opacity-ramp",title:l,infos:e,preview:T(e.map((e=>e.color)),{effectList:c,ariaLabel:await qe("previewColorRampAriaLabel")})},this._hasOpacityRamp||(this._hasOpacityRamp=e.length>0)}return i&&i.infos?i:null}})))).filter(r)}_getDomainName(e,t,s){if(e&&"function"!=typeof e){const l="getField"in s&&s.getField?.(e),i=l&&"getFieldDomain"in s&&s.getFieldDomain?s.getFieldDomain(l.name):null;return"coded-value"===i?.type?i.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,s=e.field;if("featureReduction"in t&&t.featureReduction&&"cluster"===t.featureReduction.type){const e=t.featureReduction,l="popupTemplate"in e&&e.popupTemplate,i=l&&l.fieldInfos;if(i)for(const t of i)if(t.fieldName===s)return"cluster_count"===s?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let s=e.field,l=e.normalizationField,i=!1,r=!1,n=!1,a=null;s="function"==typeof s?null:s,l="function"==typeof l?null:l;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){i=!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:l&&this._getFieldAlias(l,t),ratio:i,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 l=s.field,i=null,r=null;if(be(s)&&(i=s.normalizationField,r="percent-of-total"===s.normalizationType),l="function"==typeof l?null:l,i="function"==typeof i?null:i,Se(s)){const{field2:e,field3:i,fieldDelimiter:r}=s;let n=l&&this._getFieldAlias(l,t);return e&&(n=`<${n}>${r}<${this._getFieldAlias(e,t)}>`,i&&(n=`${n}${r}<${this._getFieldAlias(i,t)}>`)),n}let n=null;return(l||i)&&(n={field:l&&this._getFieldAlias(l,t),normField:i&&this._getFieldAlias(i,t),normByPct:r}),n}_getFieldAlias(e,t){const s="popupTemplate"in t?t.popupTemplate:null,l=s?.fieldInfos;let i=l?.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&&(i??="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=i||r||n;let u=null;return o&&(u=i?.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 be(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([p()],We.prototype,"children",void 0),e([p({readOnly:!0})],We.prototype,"effectList",null),e([p()],We.prototype,"layerView",void 0),e([p()],We.prototype,"layer",void 0),e([p()],We.prototype,"legendElements",void 0),e([p({readOnly:!0})],We.prototype,"opacity",null),e([p()],We.prototype,"parent",void 0),e([p({readOnly:!0,dependsOn:[]})],We.prototype,"ready",null),e([p()],We.prototype,"hideLayersNotInCurrentView",void 0),e([p()],We.prototype,"keepCacheOnDestroy",void 0),e([p()],We.prototype,"respectLayerVisibility",void 0),e([p({readOnly:!0})],We.prototype,"scale",null),e([p()],We.prototype,"sublayerIds",void 0),e([p({readOnly:!0})],We.prototype,"isScaleDriven",null),e([p()],We.prototype,"title",void 0),e([p({readOnly:!0,dependsOn:["ready"],value:0})],We.prototype,"version",null),e([p()],We.prototype,"view",void 0),We=e([g("esri.widgets.Legend.support.ActiveLayerInfo")],We);const Ge=We;export{Ge as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import"../../../intl.js";import{addTokenParameter as s}from"../../../kernel.js";import l from"../../../request.js";import"../../../symbols.js";import i from"../../../core/Accessor.js";import{isSome as r}from"../../../core/arrayUtils.js";import n from"../../../core/Collection.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{debounce as u}from"../../../core/promiseUtils.js";import{on as c,watch as d,whenOnce as y,initial as h}from"../../../core/reactiveUtils.js";import{px2pt as m}from"../../../core/screenUtils.js";import{addQueryParameters as f}from"../../../core/urlUtils.js";import{property as p}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as g}from"../../../core/accessorSupport/decorators/subclass.js";import{OriginId as b}from"../../../core/accessorSupport/PropertyOrigin.js";import{EffectView as S}from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as _}from"../../../layers/effects/jsonUtils.js";import{ExportImageParameters as v}from"../../../layers/support/ExportImageParameters.js";import{isFeatureLayer as w}from"../../../layers/support/layerUtils.js";import{getPixelValueRange as L}from"../../../layers/support/rasterFormats/pixelRangeUtils.js";import{fromJSON as E}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as C}from"../../../renderers/support/rendererConversion.js";import I from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{applyCIMSymbolColor as R}from"../../../symbols/support/cimSymbolUtils.js";import{SymbolSizeDefaults as F}from"../../../symbols/support/previewUtils.js";import{renderSymbol as V}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as T,renderDotDensityPreviewHTML as z,renderPieChartPreviewHTML as x,renderPreviewHTML as D}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as j}from"../../../symbols/support/utils.js";import{getEffectiveClusterSizeVariable as O}from"./clusterUtils.js";import{getColorFromPointCloudStops as P,getRampStopsForPointCloud as A,getStretchRampStops as M,getRampStops as U}from"./colorRampUtils.js";import{getHeatmapRampStops as k}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as B,getRelationshipRampElement as N}from"./relationshipRampUtils.js";import{getRampStops as q,realWorldMaxSize as H,realWorldMinSize as $}from"./sizeRampUtils.js";import{specialCharsLessThan as W,specialCharsGreaterThan as G,getSymbolForFlowRenderer as J,isRasterBandStatistics as Q,getMedianColor as Z,rgbImgSource as K,getDateFormatOptions as X}from"./utils.js";import{formatNumberLabel as Y}from"../../smartMapping/support/utils.js";import ee from"../../../symbols/SimpleMarkerSymbol.js";import te from"../../../symbols/SimpleFillSymbol.js";import{fetchMessageBundle as se}from"../../../intl/messages.js";import{substitute as le}from"../../../intl/substitute.js";const ie="https://utility.arcgis.com/sharing/tools/legend",re="esri.layers.ImageryLayer",ne="esri.layers.ImageryTileLayer",ae="esri.layers.WCSLayer",oe=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,ue=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),ce=new ee({size:6,outline:{color:[128,128,128,.5],width:.5}}),de=new te({style:"solid"});function ye(e){return"flow"===e.type}function he(e){return"vector-field"===e.type}function me(e){return"raster-colormap"===e.type}function fe(e){return"raster-stretch"===e.type}function pe(e){return"raster-shaded-relief"===e.type}function ge(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function be(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function Se(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function _e(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function ve(e){return Le(e)||Ee(e)||Ce(e)||we(e)}function we(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function Le(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function Ee(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function Ie(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function Re(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function Fe(e,t){return ge(e)||be(e)||Se(e)||_e(e)||Ie(e)||Re(e)?"2d"===t.type||C(e):fe(e)||me(e)||pe(e)||Le(e)||Ee(e)||Ce(e)||he(e)||ye(e)}function Ve(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Te(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function ze(e){return"esri.layers.VoxelLayer"===e.declaredClass}function xe(e){return"esri.layers.WMSLayer"===e.declaredClass}function De(e){return"esri.layers.WMTSLayer"===e.declaredClass}function je(e){return"esri.layers.MapImageLayer"===e.declaredClass}function Oe(e){return"esri.layers.TileLayer"===e.declaredClass}function Pe(e){return e.declaredClass===re}function Ae(e){return e.declaredClass===ne}function Me(e){return e.declaredClass===ae}function Ue(e){return"stretch-ramp"===e.type}function ke(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type}function Be(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}function Ne(e){return"sublayers"in e}async function qe(e,t){const s=await se("esri/widgets/Legend/t9n/Legend");return"previewTemplateAriaLabel"!==e||t||(e="previewAriaLabel"),le(s[e],{label:t})}const He=new ee({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let $e={},We=class extends i{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.children=new n,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this.addHandles([c((()=>this.children),"change",(t=>{const{added:s,removed:l}=t;s.forEach((t=>{const s=`activeLayerInfo-ready-watcher-${t.layer.uid}`;this.addHandles(d((()=>t.ready),e,h),s)})),l.forEach((e=>this.removeHandles(e.layer.uid))),e()}))]),this.keepCacheOnDestroy||($e={})}destroy(){this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||($e=null)}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new S,t.effect=e.effect,t.endTransitions(),t.scale=this.scale),t}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,s=this.layer.parent,l=s&&"uid"in s?this._getParentLayerOpacity(s):null;return null!=t?t*e:null!=l?l*e:e}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view?.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?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(w(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet?.features.length){const t=e.layerDefinition,s=t?.drawingInfo,l=s&&E(s.renderer),i=ue.read(t.geometryType);return l?this._getRendererLegendElements(l,{title:e.name,geometryType:i}):(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(ze(e))this._constructLegendElementsForVoxelLayer();else if(De(e))this._constructLegendElementsForWMTSlayer();else if(xe(e))await this._constructLegendElementsForWMSSublayers();else if(Ve(e))await this._constructLegendElementsForBuildingSceneLayer();else if(je(e)||Oe(e)||Te(e))await this._constructLegendElementsForSublayers();else{this.removeHandles("imageryLayers-watcher");let t="default";if(Pe(e)){const s=e;t=(s?.rasterFunction?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}if(Ae(e))return;await this._getLegendLayers(`${e.uid}-${t}`).then((async t=>{this.legendElements=[],this.notifyChange("ready");const s=t.map((async t=>{if(Pe(e)){const t=d((()=>["renderingRule"in e&&e.rasterFunction,e.bandIds]),(()=>u((async()=>{$e.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()}))()));this.addHandles(t,"imageryLayers-watcher")}const s=this._generateSymbolTableElementForLegendLayer(t);s&&s.infos.length&&(Pe(e)&&(s.title=e.title),this.legendElements.push(s)),this.notifyChange("ready")}));await 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 y((()=>!t.updating));const l=s?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();if(!l)return!0;l.geometry=this.view.extent;return 0!==(s?"queryFeatureCount"in t&&await t.queryFeatureCount(l):"queryFeatureCount"in e&&await e.queryFeatureCount(l))}_getParentLayerOpacity(e){let t=1;const s=e.parent;return s&&"uid"in s&&(t=this._getParentLayerOpacity(s)),e.opacity*t}_isGroupActive(){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(oe.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:l}=e.data,i=t?.some((e=>/\$view\.scale/.test(e.valueExpressionInfo?.expression||"")))??!1;return null!=s||null!=l||i}return!1}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,s=t.minSize,l=t.maxSize;return!("object"!=typeof s||!s||!this._isScaleDrivenSizeVariable(s))||(!("object"!=typeof l||!l||!this._isScaleDrivenSizeVariable(l))||oe.test(t.valueExpression))}_isLayerScaleDriven(e){if("minScale"in e&&e.minScale>0||"maxScale"in e&&e.maxScale>0)return!0;if("sublayers"in e&&e.sublayers)return e.sublayers.some((e=>this._isLayerScaleDriven(e)));const t=e.parent;if(!1===e.loaded&&t&&je(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const s of t.sourceJSON.layers??[])if(s.id===e.source.mapLayerId&&(s.minScale>0||s.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxelLayer(){this.legendElements=[],this.removeHandles("voxel-style-watcher"),this.removeHandles("voxel-current-variable");const e=this.layer;this.addHandles(d((()=>e.currentVariableId),(()=>this._constructLegendElementsForVoxelLayer())),"voxel-current-variable"),this.addHandles(d((()=>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 te({color:t.color,outline:null})})})),e.length&&s.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:l}=t.transferFunction,i=e.toArray().reverse(),r=l.map(((e,t)=>`${0===t?W:G} ${Y(e)}`)).reverse(),n=i.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:T(i.map((e=>e.color)),{ariaLabel:await qe("previewColorRampAriaLabel")})})}const l=e.opacity,i=s.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol)).map((e=>this._getSymbolPreview(e,l)));await Promise.allSettled(i),this.legendElements=s,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this.removeHandles("wmts-activeLayer-watcher");const e=this.layer.activeLayer;this.addHandles(d((()=>{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(d((()=>{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,l=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher");const i=this.sublayerIds?.map((e=>s.findSublayerById(e)))?.filter(r)??[],n=i.length?i:e.toArray();for(const r of n){const e=d((()=>[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&&l.unshift(e)}}return l}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 i={type:"symbol-table",title:e.title||e.name||String(e.id??""),infos:[]};t&&(s=f(s,t));let r=null;const n=e.layer?.opacity;try{r=(await l(s,{responseType:"image"})).data,r&&(r.style.opacity=n)}catch{}return i.infos.push({src:s,preview:r,opacity:n}),i}_getLegendLayers(e,t){const s=$e&&$e[e];return s?Promise.resolve(s):this._legendRequest(t).then((t=>{const s=t.layers;return $e[e]=s,s}))}_legendRequest(e){const t=this.layer;let s={f:"json",dynamicLayers:e};if(Pe(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:l,customParameters:i}=t;s={raster:e,viewId:l,...s,...i}}}let i=t.url.replace(/(\/)+$/,"");if("version"in t&&+t.version>=10.01){const e=i.indexOf("?");e>-1?i=i.substring(0,e)+"/legend"+i.substring(e):i+="/legend"}else{const e=i.toLowerCase().indexOf("/rest/"),t=i.substring(0,e)+i.substring(e+5,i.length);i=ie+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return l(i,{query:s}).then((e=>e.data))}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;this.addHandles(d((()=>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 l=e.toArray();for(const i of l){const e=d((()=>["renderer"in i&&i.renderer,i.opacity,i.title,i.visible]),(()=>this._constructLegendElementsForBuildingSceneLayer()));if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||i.visible){const e=null!=i?.opacity?i.opacity:null,l=null!=e?e*t:t;if("building-group"===i.type){const e={type:"symbol-table",title:i.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(i.sublayers,l);e.infos.push(...t),s=[e,...s]}else if(i.renderer){s=[...await this._getRendererLegendElements(i.renderer,{title:i.title,opacity:l,sublayer:i}),...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(je(e)||Oe(e)||Te(e)){this.addHandles(d((()=>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 l=this.layer;let i=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForSublayers())),"sublayers-watcher");let n=e.toArray();!s&&this.sublayerIds&&this.sublayerIds.length&&(n=Te(l)?this.sublayerIds.map((e=>l.findSublayerForSubtypeCode(e))).filter(r):this.sublayerIds.map((e=>l.findSublayerById(e))).filter(r));for(const r of n){const e=d((()=>[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,l=null!=e?e*t:t,n=!Ne(r)||r.originIdOf("renderer")>b.SERVICE&&!r.sublayers;if(r.renderer&&n){await r.load();i=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:l,sublayer:r}),...i]}else if(Ne(r)){const e=await this._generateSymbolTableElementForSublayer(r,l,s);e&&i.unshift(e)}}}return i.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,l=e.source;let i=null;if(!(!l||"map-layer"===l.type&&l.mapLayerId===e.id&&(!l.gdbVersion||l.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>b.SERVICE||e.originIdOf("labelingInfo")>b.SERVICE||e.originIdOf("labelsVisible")>b.SERVICE){const e=new v({layer:this.layer});i=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const r=i||`${t.uid}-default`;(await this._getLegendLayers(r,i)).forEach((e=>s.set(e.layerId,e)))}const l=s.get(e.id);if((!l||l?.subLayerIds&&l.defaultVisibility)&&e.sublayers){const l=await this._generateLegendElementsForSublayers(e.sublayers,t,s);return{type:"symbol-table",title:e.title,infos:l}}return this._generateSymbolTableElementForLegendLayer(l,e,t)}_generateSymbolTableElementForLegendLayer(e,t,s){if(!e?.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const l=t?.renderer;let i=t?.title||e.layerName;if(l&&(!t||t?.originIdOf("renderer")>b.SERVICE)){const e=t?.title||this._getRendererTitle(l,t);e&&(i&&"string"!=typeof e&&"title"in e&&(e.title=i),i=e)}const r={type:"symbol-table",title:i,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 l={type:"symbol-table",title:t.heading,legendType:e.legendType||null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter((e=>e.groupId===t.id)),e.layerId,s)};l.infos?.length>0&&r.infos.push(l)})):r.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,s),r.infos.length>0?r:null}_generateSymbolTableElementInfosForLegendLayer(e,t,l){return e.map((e=>{let i=e.url;if(e.imageData&&e.imageData.length>0)i=`data:image/png;base64,${e.imageData}`;else{if(0===i.indexOf("http"))return null;i=s(`${this.layer.url}/${t}/images/${i}`)}return{label:e.label,src:i,opacity:l??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 l=null,i=null,r=!0;return!s.minScale&&0!==s.minScale||!s.maxScale&&0!==s.maxScale?(0===e.minScale&&s.tileInfo&&(l=s.tileInfo.lods[0].scale),0===e.maxScale&&s.tileInfo&&(i=s.tileInfo.lods[s.tileInfo.lods.length-1].scale)):(l=Math.min(s.minScale,e.minScale)||s.minScale||e.minScale,i=Math.max(s.maxScale,e.maxScale)),(l>0&&l<this.scale||i>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,l=e.some((e=>e.values));let i=0,r=null;return l&&e.some(((e,t)=>(e.values||(i=t,r=e,r.label||(r.label="others")),null!=r))),s?"unique-value"===s.type?r&&(e.splice(i,1),e.push(r)):"class-breaks"===s.type&&(r&&e.splice(i,1),e.reverse(),r&&e.push(r)):r&&(e.splice(i,1),e.push(r)),e}async _getRendererLegendElements(e,t={}){if(!Fe(e,this.view))return o.getLogger(this).warn(`Renderer of type '${e.type}' not supported!`),[];if(ve(e))return this._constructPointCloudRendererLegendElements(e,t);if(Ie(e))return this._constructDotDensityRendererLegendElements(e);const s=await this._loadRenderer(e);return Re(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,l=[];let i=null,r=null;if(Le(e))i={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach((e=>{i.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(ce,e.color)})}));else if(Ee(e)){const t=e.stops;let l=null;if(t?.length&&(1===t.length&&(l=t[0].color),!l)){const e=t[0].value,s=t[t.length-1].value;if(null!=e&&null!=s){l=P(e+(s-e)/2,t)}}i={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(ce,l||ce.color)}]};const n=A(e.stops??[])??[];r={type:"color-ramp",title:s||this._getPointCloudRendererTitle(e),infos:n,preview:T(n.map((e=>e.color)),{ariaLabel:await qe("previewColorRampAriaLabel")})}}else Ce(e)&&(i={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos?.forEach((e=>{i.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(ce,e.color)})})));i&&i.infos.length&&l.push(i),r&&r.infos.length&&l.push(r);const n=l.reduce(((e,t)=>[...e,...t.infos??[]]),[]).filter((e=>!!e.symbol)).map((t=>this._getSymbolPreview(t,this.opacity,{symbolConfig:{applyColorModulation:!!e.colorModulation}})));return await Promise.allSettled(n),l}async _getElementInfoForDotDensity(e,t){const{color:s,label:l,valueExpressionTitle:i}=t,{backgroundColor:r,outline:n,dotSize:a}=e,o=this.effectList,u=o?.effects.map((e=>e.toJSON())),c=_(u),d=await qe("previewTemplateAriaLabel",l||i),y=a+"-"+s+"-"+r+"-"+(n&&JSON.stringify(n.toJSON()))+"-"+c,h=this._dotDensityUrlCache,m=h.has(y)?h.get(y):z(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=V([[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,l={type:"symbol-table",title:{value:t&&Math.round(t),unit:s||""},infos:[]};for(const i of e.attributes){const t=await this._getElementInfoForDotDensity(e,i);t.label=i.label||i.valueExpressionTitle||i.field,l.infos.push(t)}return[l]}async _constructPieChartRendererLegendElements(e){const t=this.layer.opacity,s=[];let l=null;const i=e.outline;e.attributes.forEach((e=>{const t=new ee({color:e.color,outline:i}),l=e.label||e.valueExpressionTitle||e.field;s.push({label:l,symbol:t})}));const r=s.length?[...s]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const t=new ee({color:e.othersCategory.color,outline:i});l=e.othersCategory.label||"Other",s.push({label:l,symbol:t})}if(e.defaultColor?.a){const t=new ee({color:e.defaultColor,outline:i});s.push({label:e.defaultLabel,symbol:t})}const n=await this._getVisualVariableLegendElements(e,this.layer)||[];if(s.length){n.unshift({type:"symbol-table",title:null,infos:s});const t=r.filter((e=>e.label!==l)).map((e=>e.symbol.color)).filter(Boolean),a=x(t,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,effectList:this.effectList,outline:i,ariaLabel:await qe("previewPieChartAriaLabel")});n.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:s,preview:a})}const a=n.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol&&!e?.preview)).map((e=>this._getSymbolPreview(e,t,{effectList:this.effectList})));return await Promise.allSettled(a),n}async _constructRendererLegendElements(e,t={}){const{title:s,sublayer:l}=t,i=l||this.layer;this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const r=await this._getVisualVariableLegendElements(e,i)||[],n={type:"symbol-table",title:s||this._getRendererTitle(e,i),infos:[]};let a=null,o=!1;const u=new Set;if(ye(e)&&!this._hasSizeRamp){const t=await J(e);n.infos.push({label:null,symbol:t})}else if(ke(e)){let t=s;const l=Be(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",i=r.findIndex((e=>"color-ramp"===e.type)),n=-1!==i?r.splice(i,1)[0]:null,a=r.findIndex((e=>"size-ramp"===e.type)),o=-1!==a?r.splice(a,1)[0]:null,u=[];n&&(t=n.title,u.push(n)),o&&(t=o.title,u.push(o)),u.length>0&&r.push({type:l,title:t,infos:u})}else if(_e(e)){const t=k(e);r.push({type:"heatmap-ramp",title:s||this._getRendererTitle(e,i),infos:t,preview:T(t.map((e=>e.color)),{effectList:this.effectList,ariaLabel:await qe("previewColorRampAriaLabel")})})}else if(Se(e)){const t=e&&e.authoringInfo;if(t&&"relationship"===t.type){const{numClasses:s,field1:l,field2:a}=t,o=t.focus;if(s&&l&&a){const t=[l,a];let c=B(o)||0;for(const e of t){const{field:t,normalizationField:s,label:l}=e,r=l||{field:this._getFieldAlias(t,i),normField:s&&this._getFieldAlias(s,i)},a=He.clone();a.angle=c,n.infos.push({label:r,symbol:a}),u.add(a),c+=90}const d=N({focus:o,numClasses:s,infos:e.uniqueValueInfos??[]});r.unshift(d)}}else if(Pe(this.layer)||Ae(this.layer))e.uniqueValueInfos?.forEach((e=>{e.symbol&&n.infos.push({label:e.label||e.value,value:e.value,symbol:e.symbol})}));else{const{field:t,field2:l,field3:r,fieldDelimiter:a,valueExpression:u,defaultSymbol:c}=e,d=!(!t&&!u||!l&&!r),y=[];if(e.uniqueValueGroups?.forEach((e=>{const s={type:"symbol-table",title:e.heading,infos:[]};e.classes?.forEach((e=>{const{symbol:n,values:o}=e;if(n){const c=[],y=[];for(const e of o??[]){const{value:s,value2:n,value3:o}=e,h=[],m=[];(t||u)&&(h.push(s),m.push(this._getDomainName(t,s,i))),l&&(h.push(n),m.push(this._getDomainName(l,n,i))),r&&(h.push(o),m.push(this._getDomainName(r,o,i))),c.push(d?h.join(a||""):h[0]),y.push(m.join(" - "))}const h=c.join(", ");let m=e.label;if(!m){const e=y.filter(Boolean);m=e.length?e.join(", "):h}s.infos.push({label:m,value:h,symbol:n})}})),s.infos.length&&y.push(s)})),y.length){const t=y[0];1===y.length&&"title"in t&&!t.title?n.infos.push(...t.infos??[]):(c&&(y.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:c}]}),o=!0),n.infos.push(...y)),s||e.legendOptions?.title||e.valueExpressionTitle||(n.title=null)}}e.defaultSymbol&&!o&&(n.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),o=!0)}else if(be(e)){a=this._isUnclassedRenderer(e);(!a||!this._hasSizeRamp)&&(e.classBreakInfos.forEach((e=>{e.symbol&&n.infos.unshift({label:e.label||(a?null:e.minValue+" - "+e.maxValue),value:[e.minValue,e.maxValue],symbol:e.symbol})})),a&&(n.title=null),this._updateInfosForClassedSizeRenderer(e,n.infos)),e.defaultSymbol&&!a&&(n.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),o=!0)}else if(fe(e))if(Ae(this.layer)||Me(this.layer)){const t=await this._constructTileImageryStretchRendererElements(e);Ue(t)?r.push(t):n.infos=t}else{const t=this.layer;let s,l;if(e.statistics?.length){const t=e.statistics[0];Q(t)?(s=t.min,l=t.max):[s,l]=t}let i=[],a=t.serviceRasterInfo;if(t.rasterFunction)try{a=await t.generateRasterInfo(t.rasterFunction)}catch{}const o=L(a.pixelType);if(1===a.bandCount){const i=t.bandIds?.[0]||0;s=null!=s?s:a.statistics?a.statistics[i].min:o[0],l=null!=l?l:a.statistics?a.statistics[i].max:o[1],s||l?r.push(await this._getStretchLegendElements(e,{min:s,max:l})):this._getServerSideLegend()}else if(t.bandIds&&1===t.bandIds.length)s=null!=s?s:a.statistics?a.statistics[t.bandIds[0]].min:o[0],l=null!=l?l:a.statistics?a.statistics[t.bandIds[0]].max:o[1],s||l?r.push(await this._getStretchLegendElements(e,{min:s,max:l})):this._getServerSideLegend();else if(a.bandCount>=3){const{bandInfos:e}=a,{bandIds:s}=t;e.length>=a.bandCount?3===s?.length?(i=s.map((t=>e[t].name)),n.infos=this._createSymbolTableElementMultiBand(i)):"lerc"===t.format?(i=[0,1,2].map((t=>e[t].name)),n.infos=this._createSymbolTableElementMultiBand(i)):this._getServerSideLegend():"lerc"===t.format?(i=["band1","band2","band3"],n.infos=this._createSymbolTableElementMultiBand(i)):this._getServerSideLegend()}else this._getServerSideLegend()}else if(me(e))e.colormapInfos.forEach((e=>{n.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(de,e.color)})}));else if(ge(e)){let s=e.symbol;switch(t.geometryType){case"point":s="pointSymbol"in i?i.pointSymbol:null;break;case"polyline":s="lineSymbol"in i?i.lineSymbol:null;break;case"polygon":s="polygonSymbol"in i?i.polygonSymbol:null}const l=this._hasClusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&l&&n.infos.push({label:e.label,symbol:s})}else if(he(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),n.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach((e=>{n.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})})):n.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else pe(e)&&r.push(await this._getStretchLegendElements(e,{min:0,max:255}));const c=e.defaultSymbol;!c||o||ge(e)||a&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||r.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:c}]}),n.infos.length&&r.unshift(n);const d=null==t.opacity?this.opacity:t.opacity,y=this._isTallSymbol("visualVariables"in e?e.visualVariables:null),h=Pe(this.layer)||Ae(this.layer),m=r.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol)).filter((e=>{if("cim"===e.symbol.type){const{minScale:t,maxScale:s}=e.symbol.data;if(t&&t<this.scale||s&&s>this.scale)return!1}return!0})).map((e=>this._getSymbolPreview(e,d,{isDefault:e.symbol===c,applyScaleDrivenSize:!u.has(e.symbol),symbolConfig:{isTall:y,isSquareFill:h},effectList:u.has(e.symbol)?null:this.effectList})));return e=null,await Promise.allSettled(m),r}_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 l,i;const r=e?.statistics?.length?e.statistics:s?.statistics;if(r){const e=r[0];Q(e)?(l=e.min,i=e.max):[l,i]=e}else{const e=L(s.pixelType);l=e[0],i=e[1]}if(t.hasStandardTime()&&(l=t.getStandardTimeValue(l),i=t.getStandardTimeValue(i)),1===s.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:l,max:i});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,l=M(s,t);return{type:"stretch-ramp",title:"",infos:l,preview:T(l.map((e=>e.color)),{ariaLabel:await qe("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,l){return{type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(t):e,infos:await q(s,t,await Z(s),this.scale,this.view,l,this._hasClusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],s=["red","green","blue"];return e.forEach(((e,l)=>{t.push({label:{colorName:s[l],bandName:e},src:K[l],opacity:this.opacity??1})})),t}_updateInfosForClassedSizeRenderer(e,t){const s=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,l=e.classBreakInfos.some((e=>j(e.symbol)));if(s&&l){const s=H,l=$,i=e.classBreakInfos.length,r=(s-l)/(i>1?i-1:i);t.forEach(((e,t)=>{e.size=s-r*t}))}}_isTallSymbol(e){let t=!1,s=!1;if(e)for(let l=0;l<e.length&&(!t||!s);l++){const i=e[l];"size"===i.type&&("height"===i.axis&&(t=!0),"width-and-depth"===i.axis&&(s=!0))}return t&&s}async _getSymbolPreview(e,t,s){let l=!s?.isDefault&&null==e.size&&this._hasSizeRamp?m(F.size):e.size;if(this._scaleDrivenSizeVariable&&s?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");l=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}const i=!s?.isDefault&&this._hasSizeRamp||!(!this._scaleDrivenSizeVariable||!s?.applyScaleDrivenSize);return D(e.symbol,{size:l,opacity:t,scale:!1,symbolConfig:s?.symbolConfig,effectView:s?.effectList,style:"legend",cimOptions:{allowScalingUp:i,viewParams:this.isScaleDriven?{viewingMode:"2d"===this.view?.type?"map":this.view?.viewingMode,scale:this.view?.scale}:null},ariaLabel:e.label&&"string"!=typeof e.label?null:await qe("previewTemplateAriaLabel",e.label)}).then((t=>(e.preview=t,e))).catch((()=>(e.preview=null,e)))}_getClusterRenderer(e){this._hasClusterSizeVariable=!1;const t="renderer"in this.layer?this.layer.renderer:null,s=e.renderer?.clone()||t?.clone(),l=O(e,this.layerView,this.view);if(l&&null!=s&&"visualVariables"in s){const t=s.visualVariables?.some((e=>"size"===e.type&&"outline"!==e.target&&!oe.test(e.valueExpression)));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:s}=e;l.legendOptions=new I({showLegend:t!==s})}const t=s.visualVariables||[];s.visualVariables=t.concat([l]),this._hasClusterSizeVariable=!0}}return s}async _loadRenderer(e){const t=[],s=e.clone(),l=await Z(s);if(be(s)||Se(s)){const e=(s.classBreakInfos||s.uniqueValueInfos).map((e=>this._fetchSymbol(e.symbol,l).then((t=>{e.symbol=t})).catch((()=>{e.symbol=null}))));Array.prototype.push.apply(t,e)}return t.push(this._fetchSymbol(s.symbol||s.defaultSymbol,s.defaultSymbol?null:l).then((e=>{this._applySymbolToRenderer(s,e,ge(s))})).catch((()=>{this._applySymbolToRenderer(s,null,ge(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 l=await("2d"===this.view.type?e.fetchCIMSymbol({cache:s}):e.fetchSymbol({cache:s}));return this._getAppliedCloneSymbol(l,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 l=e.clone(),i=s&&s.toRgba();return l.type.includes("3d")?this._applyColorTo3dSymbol(l,i):"cim"===l.type?R(l,s):l.color&&(l.color=new t(i||l.color)),l}_applyColorTo3dSymbol(e,s){s&&e.symbolLayers.forEach((e=>{e&&(e.material||(e.material={}),e.material.color=new t(s))}))}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||!e.visualVariables||"vector-field"===e.type)return null;const s=e.visualVariables,l=[],i=[],n=[];for(const r of s)"color"===r.type?l.push(r):"size"===r.type?i.push(r):"opacity"===r.type&&n.push(r);const a=[...l,...i,...n];let o,u;if(0===l.length&&be(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];o=t&&t.symbol}if(0===l.length&&ge(e)&&(o=e.symbol),o)if(o.type.includes("3d")){const e=o.symbolLayers.at(0);"water"===e.type?null!=e.color&&(u=e.color):null!=e.material?.color&&(u=e.material.color)}else o.url||(u=o.color);const c=this.effectList;return(await Promise.all(a.map((async s=>{if(!s.legendOptions||!1!==s.legendOptions.showLegend){const l=ye(e)?s.field:this._getRampTitle(s,t);let i=null;const r=X(t,s,this.view.timeZone);if("color"===s.type){const e=await U(s,null,r)??[];i={type:"color-ramp",title:l,infos:e,preview:T(e.map((e=>e.color)),{effectList:c,ariaLabel:await qe("previewColorRampAriaLabel")})},this._hasColorRamp||(this._hasColorRamp=e.length>0)}else if("size"===s.type&&"outline"!==s.target)oe.test(s.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=s):(i=await this._getSizeLegendElement(l,s,e,r),this._hasSizeRamp||(this._hasSizeRamp=!(null==i.infos||!i.infos.length)));else if("opacity"===s.type){const e=await U(s,u,r)??[];i={type:"opacity-ramp",title:l,infos:e,preview:T(e.map((e=>e.color)),{effectList:c,ariaLabel:await qe("previewColorRampAriaLabel")})},this._hasOpacityRamp||(this._hasOpacityRamp=e.length>0)}return i&&i.infos?i:null}})))).filter(r)}_getDomainName(e,t,s){if(e&&"function"!=typeof e){const l="getField"in s&&s.getField?.(e),i=l&&"getFieldDomain"in s&&s.getFieldDomain?s.getFieldDomain(l.name):null;return"coded-value"===i?.type?i.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,s=e.field;if("featureReduction"in t&&t.featureReduction&&"cluster"===t.featureReduction.type){const e=t.featureReduction,l="popupTemplate"in e&&e.popupTemplate,i=l&&l.fieldInfos;if(i)for(const t of i)if(t.fieldName===s)return"cluster_count"===s?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let s=e.field,l=e.normalizationField,i=!1,r=!1,n=!1,a=null;s="function"==typeof s?null:s,l="function"==typeof l?null:l;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){i=!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:l&&this._getFieldAlias(l,t),ratio:i,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 l=s.field,i=null,r=null;if(be(s)&&(i=s.normalizationField,r="percent-of-total"===s.normalizationType),l="function"==typeof l?null:l,i="function"==typeof i?null:i,Se(s)){const{field2:e,field3:i,fieldDelimiter:r}=s;let n=l&&this._getFieldAlias(l,t);return e&&(n=`<${n}>${r}<${this._getFieldAlias(e,t)}>`,i&&(n=`${n}${r}<${this._getFieldAlias(i,t)}>`)),n}let n=null;return(l||i)&&(n={field:l&&this._getFieldAlias(l,t),normField:i&&this._getFieldAlias(i,t),normByPct:r}),n}_getFieldAlias(e,t){const s="popupTemplate"in t?t.popupTemplate:null,l=s?.fieldInfos;let i=l?.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&&(i??="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=i||r||n;let u=null;return o&&(u=i?.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 be(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([p()],We.prototype,"children",void 0),e([p({readOnly:!0})],We.prototype,"effectList",null),e([p()],We.prototype,"layerView",void 0),e([p()],We.prototype,"layer",void 0),e([p()],We.prototype,"legendElements",void 0),e([p({readOnly:!0})],We.prototype,"opacity",null),e([p()],We.prototype,"parent",void 0),e([p({readOnly:!0,dependsOn:[]})],We.prototype,"ready",null),e([p()],We.prototype,"hideLayersNotInCurrentView",void 0),e([p()],We.prototype,"keepCacheOnDestroy",void 0),e([p()],We.prototype,"respectLayerVisibility",void 0),e([p({readOnly:!0})],We.prototype,"scale",null),e([p()],We.prototype,"sublayerIds",void 0),e([p({readOnly:!0})],We.prototype,"isScaleDriven",null),e([p()],We.prototype,"title",void 0),e([p({readOnly:!0,dependsOn:["ready"],value:0})],We.prototype,"version",null),e([p()],We.prototype,"view",void 0),We=e([g("esri.widgets.Legend.support.ActiveLayerInfo")],We);const Ge=We;export{Ge 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../request.js";import{isSome as
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import{id as e}from"../../kernel.js";import r from"../../request.js";import{isSome as o}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import i from"../../core/Error.js";import{clone as a}from"../../core/lang.js";import l from"../../core/Loadable.js";import{isAbortError as n}from"../../core/promiseUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as u,convertDateFormatToIntlOptions as c}from"../../intl/date.js";import{getLanguage as f}from"../../intl/locale.js";import d from"../../portal/Portal.js";import y from"../../portal/PortalQueryParams.js";import{execute as h}from"../../rest/geoprocessor/execute.js";import"../../rest/geoprocessor/GPOptions.js";import"../../config.js";import"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtilsCommon.js";import"../../geometry/support/spatialReferenceUtils.js";import"../../geometry/SpatialReference.js";import"../../geometry/support/Ellipsoid.js";import"../../geometry.js";import"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import"../../geometry/Point.js";import"../../core/urlUtils.js";import"../../layers/support/Field.js";import"../../layers/support/MapImage.js";import"../../rest/support/DataFile.js";import"../../rest/support/FeatureSet.js";import"../../rest/support/LinearUnit.js";import"../../rest/support/ParameterValue.js";import"../../rest/support/RasterData.js";import"../../rest/support/JobInfo.js";import{execute as v}from"../../rest/print.js";import{fromJSON as T}from"../../rest/support/fileFormat.js";import{fromJSON as w}from"../../rest/support/layoutTemplate.js";import g from"../../rest/support/PrintParameters.js";import j from"../../rest/support/PrintTemplate.js";import P from"./CustomTemplate.js";const S=s.ofType(P);function x(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find((t=>e in t))){const{customTextElements:e}=t.layoutOptions;let r=u(Date.now(),c("short-date"));"ar"===f()&&(r=""+r),e.push({date:r})}}let L=class extends l{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this.allowedFormats="all",this.allowedLayouts="all",this.defaultTemplates=new S,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.portal=d.getDefault(),this.printServiceUrl=null,this.printTimeout=12e4,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null}destroy(){this.view=null}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=a(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach((e=>{const r=t[e];if(r){const t=this.templateCustomTextElements?.[e];r.forEach((e=>{const[r]=Object.entries(e)[0];t?.forEach((t=>{const[o,s]=Object.entries(t)[0];r===o&&(e[r]=s)}))}))}})),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async getLayoutTemplateInfo(t,r){const{id:o}=t;"public"!==t.access&&e&&await e.getCredential(this._printServiceLayoutsUrl);const s={Layout_Item_ID:JSON.stringify({id:o})},{results:i}=await h(this._printServiceLayoutsUrl,s,null,r),a=i[0].value[0],l=a.layoutOptions.mapSurroundInfos.find((({type:t})=>"CIMMarkerNorthArrow"===t));return l&&(this.templateToNorthArrowInfo[o]=l),a}async print(t){const{view:e,extraParameters:r,updateDelay:o}=this;if(!e)throw new i("print:view-required","view is not set");x(t);const s=new g({view:e,template:t,extraParameters:r,updateDelay:o});try{return await v(this.effectivePrintServiceUrl,s,{timeout:this.printTimeout})}catch(a){throw new i("print:export-error","An error occurred while exporting the web map.",{error:a})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:r,customTextElements:o,dpi:s,forceFeatureAttributes:i,format:a,height:l,includeTables:n,layout:p,layoutItem:m,legendEnabled:u,northArrowEnabled:c,scale:f,scaleEnabled:d,title:y,width:h}){const v=new j({attributionVisible:t,forceFeatureAttributes:i,format:a,includeTables:n,layout:p,layoutItem:m,layoutOptions:{authorText:e||"",copyrightText:r||"",customTextElements:o,titleText:y||""},outScale:f??0,scalePreserved:d});h&&(v.exportOptions.width=h),l&&(v.exportOptions.height=l),s&&(v.exportOptions.dpi=s),!u&&v.layoutOptions&&(v.layoutOptions.legendLayers=[]);const T=this.templateToNorthArrowInfo[m?.id??p];if(T){!(T.visible===c)&&v.layoutOptions&&(v.layoutOptions.elementOverrides={[T.name]:{visible:c}})}return v}async _loadResources(t){let e=[];if(!this.printServiceUrl){if(this.destroyed)return;try{await this.portal.load(t)}catch(a){throw new i("print:could-not-load-portal","Cannot load print resource information from portal",{error:a,url:this.effectivePrintServiceUrl})}const r=this.portal.helperServices?.printTask;r&&(this._set("effectivePrintServiceUrl",r.url),e=r.templates?.map((t=>P.fromJSON(t)))??[])}this.defaultTemplates.addMany(e);const r=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!r?.includes("gpserver"))throw new i("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl});const[o,s]=await Promise.all([this._getPrintServiceLayouts(t),this._getPrintServiceTemplates(t)]);if(this._processPrintServiceLayouts(o),this._processPrintServiceTemplates(s),!this.printServiceUrl){const e=await this._getPortalCustomTemplates(t);this.defaultTemplates.addMany(e)}}async _getPortalCustomTemplates(t){const{layoutGroupQuery:e}=this.portal;if(!e)return[];const r=new y({query:e,disableExtraQuery:!0}),o=await this.portal.queryGroups(r,t);if(!o.total)return[];const s=o.results[0],i=new y({num:100,query:"type:Layout"}),a=(await s.queryItems(i,t)).results;return a.length?a.map((t=>new P({label:t.title,layoutItem:t}))):[]}_processPrintServiceTemplates(t){this._set("templatesInfo",t)}async _getPrintServiceLayouts(t){let e=[];const r=async e=>{this._printServiceLayoutsUrl=this.effectivePrintServiceUrl.replace(/(\/GPServer\/).+/i,`$1${encodeURI(e)}`);return(await h(this._printServiceLayoutsUrl,null,null,t)).results[0].value};try{e=await r("Get Layout Templates Info Task")}catch{}if(!e||e.length<1)try{e=await r("Get Layout Templates Info")}catch{}return e}_processPrintServiceLayouts(t){const e={},r={};t.forEach((({layoutTemplate:t,layoutOptions:{customTextElements:o,mapSurroundInfos:s}})=>{const i=w(t);e[i]=o,s&&(r[i]=s.find((({type:t})=>"CIMMarkerNorthArrow"===t)))})),this._serviceTemplateCustomTextElements=Object.freeze(e),this.templateToNorthArrowInfo=r}async _getPrintServiceTemplates(t){let e;try{({data:e}=await r(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw n(l)?l:new i("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:o}=e,s=o.find((({name:t})=>"Format"===t)),a=o.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(s),layout:this._getLayout(a)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>this.allowedFormats.includes(T(t)))),r=(e.length?e:t.choiceList).map(T).filter(o),s=T(t.defaultValue),i=r.includes(s)?s:r[0];return{choiceList:r,defaultValue:i}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),r="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(w(t)))),s=(r.length?r:e).map(w).filter(o),i=w(t.defaultValue),a=s.includes(i)?i:s.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??s.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??s[0];return{choiceList:s,defaultValue:a}}};t([p()],L.prototype,"_serviceTemplateCustomTextElements",void 0),t([p()],L.prototype,"allowedFormats",void 0),t([p()],L.prototype,"allowedLayouts",void 0),t([p({type:S})],L.prototype,"defaultTemplates",void 0),t([p()],L.prototype,"error",void 0),t([p()],L.prototype,"extraParameters",void 0),t([p()],L.prototype,"includeDefaultTemplates",void 0),t([p({readOnly:!0})],L.prototype,"effectivePrintServiceUrl",null),t([p()],L.prototype,"effectiveTemplateCustomTextElements",null),t([p({type:d})],L.prototype,"portal",void 0),t([p()],L.prototype,"printServiceUrl",void 0),t([p()],L.prototype,"printTimeout",void 0),t([p({readOnly:!0})],L.prototype,"state",null),t([p({readOnly:!0})],L.prototype,"templatesInfo",void 0),t([p()],L.prototype,"updateDelay",void 0),t([p()],L.prototype,"view",void 0),t([p()],L.prototype,"templateCustomTextElements",void 0),t([p()],L.prototype,"templateToNorthArrowInfo",void 0),L=t([m("esri.widgets.Print.PrintViewModel")],L);const _=L;export{_ as default};
|
package/widgets/Print.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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../chunks/tslib.es6.js";import e from"../core/Collection.js";import{clone as a}from"../core/lang.js";import i from"../core/Logger.js";import{watch as o}from"../core/reactiveUtils.js";import{addProxy as n,hasSameOrigin as s}from"../core/urlUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{getToken as p}from"../rest/utils.js";import{toJSON as d}from"../rest/support/fileFormat.js";import c from"./Widget.js";import u from"./Print/FileLink.js";import h from"./Print/PrintViewModel.js";import m from"./Print/TemplateOptions.js";import{loadCalciteComponents as b}from"./support/componentsUtils.js";import{globalCss as _}from"./support/globalCss.js";import{Heading as v}from"./support/Heading.js";import{legacyIcon as y}from"./support/legacyIcon.js";import{isActivationKey as f}from"./support/widgetUtils.js";import{messageBundle as g}from"./support/decorators/messageBundle.js";import{tsx as O}from"./support/jsxFactory.js";const w=e.ofType(u),T="MAP_ONLY";var x;!function(t){t.layout="layoutTab",t.mapOnly="mapOnlyTab"}(x||(x={}));const C="esri-print",I=`${C}__advanced-options-button`,L={base:C,widgetIcon:y.printer,headerTitle:`${C}__header-title`,inputText:`${C}__input-text`,layoutTabList:`${C}__layout-tab-list`,layoutTab:`${C}__layout-tab`,layoutSection:`${C}__layout-section`,mapOnlySection:`${C}__map-only-section`,scaleInput:`${C}__scale-input`,loader:`${C}__loader`,advancedOptionsButton:I,advancedOptionsButtonContainer:`${I}-container`,advancedOptionsButtonTitle:`${I}-title`,advancedOptionsButtonIconOpened:`${I}-icon--opened`,advancedOptionsButtonIconClosed:`${I}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${I}-icon--closed-rtl`,refreshButton:`${C}__refresh-button`,swapButton:`${C}__swap-button`,printButton:`${C}__export-button`,formSectionContainer:`${C}__form-section-container`,advancedOptionsSection:`${C}__advanced-options-section`,advancedOptionsContainer:`${C}__advanced-options-container`,authorInfoContainer:`${C}__author-info-container`,copyrightInfoContainer:`${C}__copyright-info-container`,exportedFilesContainer:`${C}__export-panel-container`,exportedFilesTitle:`${C}__export-title`,exportedFile:`${C}__exported-file`,exportedFileLink:`${C}__exported-file-link`,exportedFileLinkTitle:`${C}__exported-file-link-title`,heightContainer:`${C}__height-container`,legendInfoContainer:`${C}__legend-info-container`,printWidgetContainer:`${C}__container`,panelContainer:`${C}__panel-container`,scaleInfoContainer:`${C}__scale-info-container`,scaleInputContainer:`${C}__scale-input-container`,sizeContainer:`${C}__size-container`,widthContainer:`${C}__width-container`,panelError:`${C}__panel--error`,exportedFileError:`${C}__exported-file--error`};function M(t){const e=8.3333,a=11.4583;return{width:Math.round(t*e),height:Math.round(t*a)}}function S(t){return!isNaN(t)&&t>0}function k(t){return t?.toUpperCase()===T}let $=class extends c{constructor(t,e){super(t,e),this._activeTabFocusRequested=!1,this._advancedOptionsVisibleForLayout=!1,this._advancedOptionsVisibleForMapOnly=!1,this._awaitingServerResponse=!1,this._exportedFileNameMap={},this._layoutTabSelected=!0,this._pendingExportScroll=!1,this._rootNode=null,this.exportedLinks=new w,this.headingLevel=3,this.iconClass=L.widgetIcon,this.icon=null,this.templateOptions=new m,this.viewModel=new h,this._onInput=t=>{this._layoutTabSelected?this.templateOptions.title=t.target.value:this.templateOptions.fileName=t.target.value},this._removeLink=t=>{const e=t.currentTarget["data-item"];e&&"error"===e.state&&this.exportedLinks.remove(e)},this._handleLinkClick=t=>{const e=t.currentTarget,{href:a}=e,i=p(this.viewModel.effectivePrintServiceUrl);if(!i)return;if(!t.isTrusted)return void t.stopPropagation();t.preventDefault();const o=new URL(a);o.searchParams.set("token",i),e.href=o.href,e.click(),e.href=a},this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([o((()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format.defaultValue]),(([t,e])=>{if(e&&!t)return void(this.templateOptions.format=e);if(!t||!e||!this.viewModel.templatesInfo)return;if(this.viewModel.templatesInfo.format.choiceList.includes(t))return;const a=this.viewModel.templatesInfo.format.choiceList.find((e=>e.toUpperCase().includes(`(${t.toUpperCase()})`)));this.templateOptions.format=a??e})),o((()=>[this.templateOptions.layout,this.viewModel.templatesInfo?.layout.defaultValue]),(([t,e])=>{if(e&&!t)return void(this.templateOptions.layout=e);if(!t||!e||!this.viewModel.templatesInfo)return;if(this._layoutTabSelected=!k(t),!this._layoutTabSelected)return;this.viewModel.templatesInfo.layout.choiceList.includes(t)||(this.templateOptions.layout=e);const i=this.viewModel.effectiveTemplateCustomTextElements[this.templateOptions.layout];this.templateOptions.customTextElements=i?a(i):null})),o((()=>this.templateOptions.dpi),(t=>{t<=0&&(this.templateOptions.dpi=1)})),o((()=>this.viewModel.view?.scale),(t=>{!t||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=t)}))]);const{height:t,width:e}=this.templateOptions;this.templateOptions.width=e||800,this.templateOptions.height=t||1100;const i=setTimeout((()=>{this._awaitingServerResponse=!0,this.scheduleRender()}),500);this.viewModel.load().then((()=>clearTimeout(i)))}loadDependencies(){return b({combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js")})}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(t){this.viewModel.allowedFormats=t}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(t){this.viewModel.allowedLayouts=t}get error(){return this.viewModel.error}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(t){this.viewModel.extraParameters=t}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(t){this.viewModel.includeDefaultTemplates=t}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get portal(){return this.viewModel.portal}set portal(t){this.viewModel.portal=t}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(t){this.viewModel.printServiceUrl=t}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(t){this.viewModel.templateCustomTextElements=t}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}render(){const{includeDefaultTemplates:t,messages:e,templateOptions:a,viewModel:i,view:o}=this,{attributionEnabled:n,author:s,copyright:l,dpi:r,format:p,height:c,layout:u,layoutItem:h,legendEnabled:m,northArrowEnabled:b,scaleEnabled:f,scale:g,width:w}=a,T="ready"!==i.state,C=this._renderTitleOrFileNameSection(),I=O("div",{class:L.formSectionContainer},O("calcite-label",null,e.fileFormatTitle,O("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",onCalciteComboboxChange:({target:t})=>{this.templateOptions.format=t.selectedItems[0].value}},i.templatesInfo?.format?.choiceList.sort().map(((t,e)=>O("calcite-combobox-item",{key:`file-format-${e}`,selected:t===this.templateOptions.format,textLabel:d(t),value:t})))))),M=i.defaultTemplates.length&&t?i.defaultTemplates.toArray().filter((({label:t})=>!k(t))).sort(((t,e)=>(t.label??"")>(e.label??"")?1:-1)).map(((t,a)=>O("calcite-combobox-item",{"data-item-id":t.layoutItem?.id,key:`organization-template-${a}`,textLabel:t.label??e.untitled,title:t.description??"",value:t.layout}))):null,S=!i.templatesInfo?.layout?.choiceList.length||t&&i.defaultTemplates.length?null:i.templatesInfo.layout.choiceList.map((t=>({label:e[t]??t.replaceAll("_"," "),value:t}))).sort(((t,e)=>t.label>e.label?1:0)).map((({label:t,value:e},a)=>O("calcite-combobox-item",{key:`service-template-${a}`,selected:e===this.templateOptions.layout,textLabel:t,value:e}))),$=O("div",{class:L.formSectionContainer},O("calcite-label",null,e.template,O("calcite-combobox",{clearDisabled:!0,label:e.selectTemplate,maxItems:6,placeholder:e.selectTemplate,selectionMode:"single",onCalciteComboboxChange:({target:t})=>{const e=t.selectedItems[0],a=e.getAttribute("data-item-id");if(a){const t=this.viewModel.defaultTemplates.find((({layoutItem:t})=>a===t?.id));this._applyTemplate(t)}else this._applyTemplate(e.value)}},M,S))),F=O("div",{class:L.formSectionContainer},O("label",null,e.dpi,O("input",{bind:this,class:this.classes(L.inputText,_.input),"data-input-name":"dpi",min:"1",onchange:this._handleDPIChange,tabIndex:0,type:"number",value:`${r}`}))),E=O("div",{class:this.classes(L.scaleInfoContainer,L.formSectionContainer)},O("label",null,O("input",{bind:this,checked:f,"data-option-name":"scaleEnabled",onchange:this._toggleInputValue,tabIndex:0,type:"checkbox"}),e.scale),O("div",{class:L.scaleInputContainer},O("input",{"aria-label":e.scaleLabel,"aria-valuenow":`${g}`,bind:this,class:this.classes(L.inputText,_.input,L.scaleInput),"data-input-name":"scale",disabled:!f,onchange:this._updateInputValue,role:"spinbutton",tabIndex:0,type:"number",value:`${g}`}),O("button",{"aria-label":e.reset,bind:this,class:this.classes(_.widgetButton,L.refreshButton,y.refresh),onclick:this._resetToCurrentScale,tabIndex:0,type:"button"}))),A=this._advancedOptionsVisibleForLayout?O("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:L.advancedOptionsContainer},E,O("div",{class:this.classes(L.authorInfoContainer,L.formSectionContainer)},O("label",null,e.author,O("input",{bind:this,class:this.classes(L.inputText,_.input),"data-input-name":"author",onchange:this._updateInputValue,tabIndex:0,type:"text",value:s??""}))),O("div",{class:this.classes(L.copyrightInfoContainer,L.formSectionContainer)},O("label",null,e.copyright,O("input",{bind:this,class:this.classes(L.inputText,_.input),"data-input-name":"copyright",onchange:this._updateInputValue,tabIndex:0,type:"text",value:l??""}))),F,O("div",{class:this.classes(L.legendInfoContainer,L.formSectionContainer)},O("label",null,O("input",{bind:this,checked:m,"data-option-name":"legendEnabled",onchange:this._toggleInputValue,tabIndex:0,type:"checkbox"}),e.legend)),this.viewModel.templateToNorthArrowInfo[h?.id??u]?O("div",{class:this.classes(L.legendInfoContainer,L.formSectionContainer),key:"north-arrow"},O("label",null,O("input",{bind:this,checked:b,"data-option-name":"northArrowEnabled",onchange:this._toggleInputValue,tabIndex:0,type:"checkbox"}),e.northArrow)):null,this._renderCustomTextElementSection()):null,V=this._advancedOptionsVisibleForMapOnly?O("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:L.advancedOptionsContainer},E,F,O("div",{class:L.formSectionContainer},O("label",null,O("input",{bind:this,checked:n,"data-option-name":"attributionEnabled",onchange:this._toggleInputValue,tabIndex:0,type:"checkbox"}),e.attribution)),this._renderCustomTextElementSection()):null,j=this._layoutTabSelected?O("section",{"aria-labelledby":`${this.id}__layoutTab`,class:L.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},O("div",{class:L.panelContainer},C,$,this._layoutTabSelected?I:null),O("div",{class:this.classes(L.panelContainer,L.advancedOptionsSection)},O("button",{"aria-expanded":this._advancedOptionsVisibleForLayout?"true":"false","aria-label":e.advancedOptions,bind:this,class:L.advancedOptionsButton,onclick:this._showAdvancedOptions,type:"button"},O("div",{class:L.advancedOptionsButtonContainer},O("span",{"aria-hidden":"true",class:this.classes(y.rightTriangleArrow,L.advancedOptionsButtonIconClosed)}),O("span",{"aria-hidden":"true",class:this.classes(y.leftTriangleArrow,L.advancedOptionsButtonIconClosed_RTL)}),O("span",{"aria-hidden":"true",class:this.classes(y.downArrow,L.advancedOptionsButtonIconOpened)}),O("span",{class:L.advancedOptionsButtonTitle},e.advancedOptions))),A)):O("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:L.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},O("div",{class:L.panelContainer},C,this._layoutTabSelected?null:I,O("div",{class:this.classes(L.sizeContainer,L.formSectionContainer)},O("div",{class:L.widthContainer},O("label",null,e.width,O("input",{bind:this,class:this.classes(L.inputText,_.input),"data-input-name":"width",onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${w}`}))),O("div",{class:L.heightContainer},O("label",null,e.height,O("input",{bind:this,class:this.classes(L.inputText,_.input),"data-input-name":"height",onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${c}`}))),O("button",{"aria-label":e.swap,bind:this,class:this.classes(_.widgetButton,L.swapButton,y.swap),onclick:this._switchInput,tabIndex:0,type:"button"})),O("div",{class:this.classes(L.panelContainer,L.advancedOptionsSection)},O("button",{"aria-expanded":this._advancedOptionsVisibleForMapOnly?"true":"false","aria-label":e.advancedOptions,bind:this,class:L.advancedOptionsButton,onclick:this._showAdvancedOptions,type:"button"},O("div",{class:L.advancedOptionsButtonContainer},O("span",{"aria-hidden":"true",class:this.classes(y.rightTriangleArrow,L.advancedOptionsButtonIconClosed)}),O("span",{"aria-hidden":"true",class:this.classes(y.leftTriangleArrow,L.advancedOptionsButtonIconClosed_RTL)}),O("span",{"aria-hidden":"true",class:this.classes(y.downArrow,L.advancedOptionsButtonIconOpened)}),O("span",{class:L.advancedOptionsButtonTitle},e.advancedOptions))),V))),P=this.exportedLinks.toArray(),B=this._renderExportedLink(P),N={[_.buttonDisabled]:T||!u&&!p},D=!o||"2d"!==o.type,U=O("div",{class:L.panelError},D?e.sceneViewError:e.serviceError),R=O("div",null,O("ul",{bind:this,class:L.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},O("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._layoutTabSelected}`,class:L.layoutTab,"data-tab-id":x.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),O("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${!this._layoutTabSelected}`,class:L.layoutTab,"data-tab-id":x.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab)),j,O("button",{"aria-label":e.exportDescription,bind:this,class:this.classes(L.printButton,_.button,N),disabled:T,onclick:this._handlePrintMap,tabIndex:0,type:"button"},e.export),O("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:L.exportedFilesContainer},O(v,{class:L.exportedFilesTitle,level:this.headingLevel},e.exportText),P.length>0?null:O("div",null,O("div",null,e.exportHint)),B)),H=O("div",{class:L.printWidgetContainer},O("header",{class:L.headerTitle},e.export),this.error||D||!o?U:R),z="initializing"===i.state?this._renderLoader():H;return O("div",{bind:this,class:this.classes(L.base,_.widget,_.panel)},z)}_renderCustomTextElementSection(){const{customTextElements:t}=this.templateOptions;return t?O("div",{class:L.formSectionContainer,key:"custom-text-elements"},t.map((t=>{const[e,a]=Object.entries(t)[0];return"date"===e?null:O("label",{key:e},e,O("input",{bind:this,class:this.classes(L.inputText,_.input),"data-input-custom":!0,"data-input-name":e,onchange:this._updateInputValue,type:"text",value:a}))}))):null}async _applyTemplate(t){if(!t)return;if("string"==typeof t)return this.templateOptions.layout=t,void(this.templateOptions.layoutItem=null);if(!t.layoutTemplateInfo&&t.layoutItem)try{t.layoutTemplateInfo=await this.viewModel.getLayoutTemplateInfo(t.layoutItem);const{hasLegend:e,mapSurroundInfos:a}=t.layoutTemplateInfo.layoutOptions,i=a.some((({type:t,visible:e})=>"CIMMarkerNorthArrow"===t&&e));t.layoutOptions={legend:e,northArrow:i}}catch(l){i.getLogger(this).error(`Failed to load layout info for ${t.label}`,l)}const{format:e,layoutItem:a}=t,o=t.layout??this.templateOptions.layout,n=t.layoutOptions?.legend??this.templateOptions.legendEnabled,s=t.layoutOptions?.northArrow??this.templateOptions.northArrowEnabled;this.templateOptions.set({format:e,layout:o,layoutItem:a,legendEnabled:n,northArrowEnabled:s})}_renderTitleOrFileNameSection(){const{title:t,fileName:e,titlePlaceHolder:a,fileNamePlaceHolder:i}=this.messages,o=this._layoutTabSelected?t:e,n=this._layoutTabSelected?a:i,s=this._layoutTabSelected?this.templateOptions.title:this.templateOptions.fileName;return O("div",{class:L.formSectionContainer},O("calcite-label",null,o,O("calcite-input",{placeholder:n,value:s??"",onCalciteInputInput:this._onInput})))}_focusOnTabChange(t){if(!this._activeTabFocusRequested)return;const e=t.getAttribute("data-tab-id");("layoutTab"===e&&this._layoutTabSelected||"mapOnlyTab"===e&&!this._layoutTabSelected)&&(t.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const t={[L.loader]:this._awaitingServerResponse};return O("div",{class:this.classes(t),key:"loader"})}_createFileLink(t,e){const a=e||this.messages.untitled,i=t.format.toLowerCase(),o=i.includes("png")?"png":i,n=a+o;return void 0!==this._exportedFileNameMap[n]?this._exportedFileNameMap[n]++:this._exportedFileNameMap[n]=0,new u({name:a,extension:o,count:this._exportedFileNameMap[n]})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(t,e,a){t.find((t=>{const[a]=Object.entries(t)[0];return a===e}))[e]=a}_updateInputValue(t){const e=t.target,a=e.getAttribute("data-input-name"),i=!!e["data-input-custom"],{templateOptions:o}=this;if(i)return void this._updateCustomTextElementValue(o.customTextElements,a,e.value);let n;if("number"===e.type){if(!S(e.valueAsNumber)){const t=o[a];return void(e.value=`${t}`)}n=e.valueAsNumber}else n=e.value;o[a]=n}_handleDPIChange(t){this._updateInputValue(t);const e=t.currentTarget.valueAsNumber,{height:a,width:i}=M(e),{templateOptions:o}=this;o.height=a,o.width=i}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:t}=this,e=this.viewModel.toPrintTemplate(t),a=this._layoutTabSelected?e.layoutOptions?.titleText:t.fileName,i=this._createFileLink(e,a);this.exportedLinks.add(i),this.emit("submit",{link:i}),this.viewModel.print(e).then((t=>{i.set({url:t&&t.url,state:"ready"})})).catch((t=>{i.set({error:t,state:"error"})})).then((()=>{this.emit("complete",{link:i}),this.scheduleRender()}))}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_showAdvancedOptions(){this._layoutTabSelected?this._advancedOptionsVisibleForLayout=!this._advancedOptionsVisibleForLayout:this._advancedOptionsVisibleForMapOnly=!this._advancedOptionsVisibleForMapOnly}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const t=this._rootNode;if(!t)return;const{clientHeight:e,scrollHeight:a}=t,i=a-e;i>0&&(t.scrollTop=i)}_toggleInputValue(t){const e=t.target,a=e.getAttribute("data-option-name");this.templateOptions[a]=e.checked,"scaleEnabled"===a&&(this.templateOptions[a]||this._resetToCurrentScale())}_renderExportedLink(t){const e=this.messages;return t.map((t=>{const{error:a,url:i,state:o}=t,l=t.formattedName??"",r="error"===o,p="pending"===o,d="ready"===o,c={[_.anchorDisabled]:p||r};let u=i||null;u&&(u=n(u));const h=s(i,location.href),m={[y.loadingIndicator]:p,[_.rotating]:p,[y.download]:h&&d,[y.launchLinkExternal]:!h&&d,[y.error]:r,[L.exportedFileError]:r},b={[L.exportedFileError]:r};let v;v=p?e.pending:d?e.ready:e.errorMessage;const f=r?"print-task:cim-symbol-unsupported"===a?.name?e.exportWebMapCIMError:e.exportWebMapError:"";return O("div",{"aria-label":v,class:L.exportedFile,"data-item":t,key:l,onclick:this._removeLink,title:f},O("a",{"aria-label":`${l}. ${e.linkReady}`,class:this.classes(L.exportedFileLink,_.anchor,c),download:l,href:u??"",onclick:this._handleLinkClick,rel:"noreferrer",tabIndex:0,target:"_blank"},O("span",{class:this.classes(m)}),O("span",{class:this.classes(L.exportedFileLinkTitle,b)},l)))}))}_toggleLayoutPanel(t){const e=t.target;this._toggleTab(e.getAttribute("data-tab-id"))}_toggleTab(t,e=!0){this._layoutTabSelected=t===x.layout,this.templateOptions.layout=this._layoutTabSelected?this.viewModel.templatesInfo?.layout?.defaultValue??"letter-ansi-a-landscape":T,this.templateOptions.layoutItem=null,e&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(t){const{key:e}=t,a=t.target.getAttribute("data-tab-id");if(f(e))return this._toggleTab(a),t.preventDefault(),void t.stopPropagation();"ArrowLeft"!==e&&"ArrowRight"!==e||(this._toggleTab(a===x.layout?x.mapOnly:x.layout),t.preventDefault(),t.stopPropagation())}};t([l()],$.prototype,"allowedFormats",null),t([l()],$.prototype,"allowedLayouts",null),t([l()],$.prototype,"error",null),t([l({type:w})],$.prototype,"exportedLinks",void 0),t([l()],$.prototype,"extraParameters",null),t([l()],$.prototype,"headingLevel",void 0),t([l()],$.prototype,"iconClass",void 0),t([l()],$.prototype,"icon",void 0),t([l()],$.prototype,"includeDefaultTemplates",null),t([l()],$.prototype,"label",null),t([l(),g("esri/widgets/Print/t9n/Print")],$.prototype,"messages",void 0),t([l()],$.prototype,"portal",null),t([l()],$.prototype,"printServiceUrl",null),t([l()],$.prototype,"templateCustomTextElements",null),t([l({type:m})],$.prototype,"templateOptions",void 0),t([l()],$.prototype,"view",null),t([l({type:h})],$.prototype,"viewModel",void 0),$=t([r("esri.widgets.Print")],$);const F=$;export{F as default};
|
|
5
|
+
import{_ as t}from"../chunks/tslib.es6.js";import e from"../core/Collection.js";import{clone as a}from"../core/lang.js";import i from"../core/Logger.js";import{watch as n}from"../core/reactiveUtils.js";import{addProxy as o,hasSameOrigin as s}from"../core/urlUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{getToken as p}from"../rest/utils.js";import{toJSON as d}from"../rest/support/fileFormat.js";import c from"./Widget.js";import u from"./Print/FileLink.js";import h from"./Print/PrintViewModel.js";import m from"./Print/TemplateOptions.js";import{loadCalciteComponents as b}from"./support/componentsUtils.js";import{globalCss as _}from"./support/globalCss.js";import{Heading as v}from"./support/Heading.js";import{legacyIcon as y}from"./support/legacyIcon.js";import{isActivationKey as f}from"./support/widgetUtils.js";import{messageBundle as g}from"./support/decorators/messageBundle.js";import{tsx as w}from"./support/jsxFactory.js";const O=e.ofType(u),T="MAP_ONLY";var x;!function(t){t.layout="layoutTab",t.mapOnly="mapOnlyTab"}(x||(x={}));const C="esri-print",I=`${C}__advanced-options-button`,S={base:C,widgetIcon:y.printer,headerTitle:`${C}__header-title`,inputText:`${C}__input-text`,layoutTabList:`${C}__layout-tab-list`,layoutTab:`${C}__layout-tab`,layoutSection:`${C}__layout-section`,mapOnlySection:`${C}__map-only-section`,scaleInput:`${C}__scale-input`,loader:`${C}__loader`,advancedOptionsButton:I,advancedOptionsButtonContainer:`${I}-container`,advancedOptionsButtonTitle:`${I}-title`,advancedOptionsButtonIconOpened:`${I}-icon--opened`,advancedOptionsButtonIconClosed:`${I}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${I}-icon--closed-rtl`,refreshButton:`${C}__refresh-button`,swapButton:`${C}__swap-button`,printButton:`${C}__export-button`,formSectionContainer:`${C}__form-section-container`,advancedOptionsSection:`${C}__advanced-options-section`,advancedOptionsContainer:`${C}__advanced-options-container`,authorInfoContainer:`${C}__author-info-container`,copyrightInfoContainer:`${C}__copyright-info-container`,exportedFilesContainer:`${C}__export-panel-container`,exportedFilesTitle:`${C}__export-title`,exportedFile:`${C}__exported-file`,exportedFileLink:`${C}__exported-file-link`,exportedFileLinkTitle:`${C}__exported-file-link-title`,heightContainer:`${C}__height-container`,legendInfoContainer:`${C}__legend-info-container`,printWidgetContainer:`${C}__container`,panelContainer:`${C}__panel-container`,scaleInfoContainer:`${C}__scale-info-container`,scaleInputContainer:`${C}__scale-input-container`,sizeContainer:`${C}__size-container`,widthContainer:`${C}__width-container`,panelError:`${C}__panel--error`,exportedFileError:`${C}__exported-file--error`};function L(t){const e=8.3333,a=11.4583;return{width:Math.round(t*e),height:Math.round(t*a)}}function M(t){return!isNaN(t)&&t>0}function k(t){return t?.toUpperCase()===T}let $=class extends c{constructor(t,e){super(t,e),this._activeTabFocusRequested=!1,this._advancedOptionsVisibleForLayout=!1,this._advancedOptionsVisibleForMapOnly=!1,this._awaitingServerResponse=!1,this._exportedFileNameMap={},this._layoutTabSelected=!0,this._pendingExportScroll=!1,this._rootNode=null,this.exportedLinks=new O,this.headingLevel=3,this.iconClass=S.widgetIcon,this.icon=null,this.templateOptions=new m,this.viewModel=new h,this._onInput=t=>{this._layoutTabSelected?this.templateOptions.title=t.target.value:this.templateOptions.fileName=t.target.value},this._removeLink=t=>{const e=t.currentTarget["data-item"];e&&"error"===e.state&&this.exportedLinks.remove(e)},this._handleLinkClick=t=>{const e=t.currentTarget,{href:a}=e,i=p(this.viewModel.effectivePrintServiceUrl);if(!i)return;if(!t.isTrusted)return void t.stopPropagation();t.preventDefault();const n=new URL(a);n.searchParams.set("token",i),e.href=n.href,e.click(),e.href=a},this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([n((()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format.defaultValue]),(([t,e])=>{if(e&&!t)return void(this.templateOptions.format=e);if(!t||!e||!this.viewModel.templatesInfo)return;if(this.viewModel.templatesInfo.format.choiceList.includes(t))return;const a=this.viewModel.templatesInfo.format.choiceList.find((e=>e.toUpperCase().includes(`(${t.toUpperCase()})`)));this.templateOptions.format=a??e})),n((()=>[this.templateOptions.layout,this.viewModel.templatesInfo?.layout.defaultValue]),(([t,e])=>{if(e&&!t)return void(this.templateOptions.layout=e);if(!t||!e||!this.viewModel.templatesInfo)return;if(this._layoutTabSelected=!k(t),!this._layoutTabSelected)return;this.viewModel.templatesInfo.layout.choiceList.includes(t)||(this.templateOptions.layout=e);const i=this.viewModel.effectiveTemplateCustomTextElements[this.templateOptions.layout];this.templateOptions.customTextElements=i?a(i):null})),n((()=>this.templateOptions.dpi),(t=>{t<=0&&(this.templateOptions.dpi=1)})),n((()=>this.viewModel.view?.scale),(t=>{!t||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=t)}))]);const{height:t,width:e}=this.templateOptions;this.templateOptions.width=e||800,this.templateOptions.height=t||1100;const i=setTimeout((()=>{this._awaitingServerResponse=!0,this.scheduleRender()}),500);this.viewModel.load().then((()=>{clearTimeout(i),this._awaitingServerResponse=!1}))}loadDependencies(){return b({combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js")})}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(t){this.viewModel.allowedFormats=t}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(t){this.viewModel.allowedLayouts=t}get error(){return this.viewModel.error}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(t){this.viewModel.extraParameters=t}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(t){this.viewModel.includeDefaultTemplates=t}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get portal(){return this.viewModel.portal}set portal(t){this.viewModel.portal=t}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(t){this.viewModel.printServiceUrl=t}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(t){this.viewModel.templateCustomTextElements=t}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}render(){const{includeDefaultTemplates:t,messages:e,templateOptions:a,viewModel:i,view:n}=this,{attributionEnabled:o,author:s,copyright:l,dpi:r,format:p,height:c,layout:u,layoutItem:h,legendEnabled:m,northArrowEnabled:b,scaleEnabled:f,scale:g,width:O}=a,T="ready"!==i.state||this._awaitingServerResponse,C=this._renderTitleOrFileNameSection(),I=w("div",{class:S.formSectionContainer},w("calcite-label",null,e.fileFormatTitle,w("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",onCalciteComboboxChange:({target:t})=>{this.templateOptions.format=t.selectedItems[0].value}},i.templatesInfo?.format?.choiceList.sort().map(((t,e)=>w("calcite-combobox-item",{key:`file-format-${e}`,selected:t===this.templateOptions.format,textLabel:d(t),value:t})))))),L=i.defaultTemplates.length&&t?i.defaultTemplates.toArray().filter((({label:t})=>!k(t))).sort(((t,e)=>(t.label??"")>(e.label??"")?1:-1)).map(((t,a)=>w("calcite-combobox-item",{"data-item-id":t.layoutItem?.id,key:`organization-template-${a}`,textLabel:t.label??e.untitled,title:t.description??"",value:t.layout}))):null,M=!i.templatesInfo?.layout?.choiceList.length||t&&i.defaultTemplates.length?null:i.templatesInfo.layout.choiceList.map((t=>({label:e[t]??t.replaceAll("_"," "),value:t}))).sort(((t,e)=>t.label>e.label?1:0)).map((({label:t,value:e},a)=>w("calcite-combobox-item",{key:`service-template-${a}`,selected:e===this.templateOptions.layout,textLabel:t,value:e}))),$=w("div",{class:S.formSectionContainer},w("calcite-label",null,e.template,w("calcite-combobox",{clearDisabled:!0,label:e.selectTemplate,maxItems:6,placeholder:e.selectTemplate,selectionMode:"single",onCalciteComboboxChange:({target:t})=>{const e=t.selectedItems[0],a=e.getAttribute("data-item-id");if(a){const t=this.viewModel.defaultTemplates.find((({layoutItem:t})=>a===t?.id));this._applyTemplate(t)}else this._applyTemplate(e.value)}},L,M))),F=w("div",{class:S.formSectionContainer},w("label",null,e.dpi,w("input",{bind:this,class:this.classes(S.inputText,_.input),"data-input-name":"dpi",min:"1",onchange:this._handleDPIChange,tabIndex:0,type:"number",value:`${r}`}))),E=w("div",{class:this.classes(S.scaleInfoContainer,S.formSectionContainer)},w("label",null,w("input",{bind:this,checked:f,"data-option-name":"scaleEnabled",onchange:this._toggleInputValue,tabIndex:0,type:"checkbox"}),e.scale),w("div",{class:S.scaleInputContainer},w("input",{"aria-label":e.scaleLabel,"aria-valuenow":`${g}`,bind:this,class:this.classes(S.inputText,_.input,S.scaleInput),"data-input-name":"scale",disabled:!f,onchange:this._updateInputValue,role:"spinbutton",tabIndex:0,type:"number",value:`${g}`}),w("button",{"aria-label":e.reset,bind:this,class:this.classes(_.widgetButton,S.refreshButton,y.refresh),onclick:this._resetToCurrentScale,tabIndex:0,type:"button"}))),A=this._advancedOptionsVisibleForLayout?w("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:S.advancedOptionsContainer},E,w("div",{class:this.classes(S.authorInfoContainer,S.formSectionContainer)},w("label",null,e.author,w("input",{bind:this,class:this.classes(S.inputText,_.input),"data-input-name":"author",onchange:this._updateInputValue,tabIndex:0,type:"text",value:s??""}))),w("div",{class:this.classes(S.copyrightInfoContainer,S.formSectionContainer)},w("label",null,e.copyright,w("input",{bind:this,class:this.classes(S.inputText,_.input),"data-input-name":"copyright",onchange:this._updateInputValue,tabIndex:0,type:"text",value:l??""}))),F,w("div",{class:this.classes(S.legendInfoContainer,S.formSectionContainer)},w("label",null,w("input",{bind:this,checked:m,"data-option-name":"legendEnabled",onchange:this._toggleInputValue,tabIndex:0,type:"checkbox"}),e.legend)),this.viewModel.templateToNorthArrowInfo[h?.id??u]?w("div",{class:this.classes(S.legendInfoContainer,S.formSectionContainer),key:"north-arrow"},w("label",null,w("input",{bind:this,checked:b,"data-option-name":"northArrowEnabled",onchange:this._toggleInputValue,tabIndex:0,type:"checkbox"}),e.northArrow)):null,this._renderCustomTextElementSection()):null,V=this._advancedOptionsVisibleForMapOnly?w("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:S.advancedOptionsContainer},E,F,w("div",{class:S.formSectionContainer},w("label",null,w("input",{bind:this,checked:o,"data-option-name":"attributionEnabled",onchange:this._toggleInputValue,tabIndex:0,type:"checkbox"}),e.attribution)),this._renderCustomTextElementSection()):null,j=this._layoutTabSelected?w("section",{"aria-labelledby":`${this.id}__layoutTab`,class:S.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},w("div",{class:S.panelContainer},C,$,this._layoutTabSelected?I:null),w("div",{class:this.classes(S.panelContainer,S.advancedOptionsSection)},w("button",{"aria-expanded":this._advancedOptionsVisibleForLayout?"true":"false","aria-label":e.advancedOptions,bind:this,class:S.advancedOptionsButton,onclick:this._showAdvancedOptions,type:"button"},w("div",{class:S.advancedOptionsButtonContainer},w("span",{"aria-hidden":"true",class:this.classes(y.rightTriangleArrow,S.advancedOptionsButtonIconClosed)}),w("span",{"aria-hidden":"true",class:this.classes(y.leftTriangleArrow,S.advancedOptionsButtonIconClosed_RTL)}),w("span",{"aria-hidden":"true",class:this.classes(y.downArrow,S.advancedOptionsButtonIconOpened)}),w("span",{class:S.advancedOptionsButtonTitle},e.advancedOptions))),A)):w("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:S.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},w("div",{class:S.panelContainer},C,this._layoutTabSelected?null:I,w("div",{class:this.classes(S.sizeContainer,S.formSectionContainer)},w("div",{class:S.widthContainer},w("label",null,e.width,w("input",{bind:this,class:this.classes(S.inputText,_.input),"data-input-name":"width",onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${O}`}))),w("div",{class:S.heightContainer},w("label",null,e.height,w("input",{bind:this,class:this.classes(S.inputText,_.input),"data-input-name":"height",onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${c}`}))),w("button",{"aria-label":e.swap,bind:this,class:this.classes(_.widgetButton,S.swapButton,y.swap),onclick:this._switchInput,tabIndex:0,type:"button"})),w("div",{class:this.classes(S.panelContainer,S.advancedOptionsSection)},w("button",{"aria-expanded":this._advancedOptionsVisibleForMapOnly?"true":"false","aria-label":e.advancedOptions,bind:this,class:S.advancedOptionsButton,onclick:this._showAdvancedOptions,type:"button"},w("div",{class:S.advancedOptionsButtonContainer},w("span",{"aria-hidden":"true",class:this.classes(y.rightTriangleArrow,S.advancedOptionsButtonIconClosed)}),w("span",{"aria-hidden":"true",class:this.classes(y.leftTriangleArrow,S.advancedOptionsButtonIconClosed_RTL)}),w("span",{"aria-hidden":"true",class:this.classes(y.downArrow,S.advancedOptionsButtonIconOpened)}),w("span",{class:S.advancedOptionsButtonTitle},e.advancedOptions))),V))),P=this.exportedLinks.toArray(),B=this._renderExportedLink(P),N={[_.buttonDisabled]:T||!u&&!p},D=!n||"2d"!==n.type,R=w("div",{class:S.panelError},D?e.sceneViewError:e.serviceError),U=w("div",null,w("ul",{bind:this,class:S.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},w("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._layoutTabSelected}`,class:S.layoutTab,"data-tab-id":x.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),w("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${!this._layoutTabSelected}`,class:S.layoutTab,"data-tab-id":x.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab)),j,w("button",{"aria-label":e.exportDescription,bind:this,class:this.classes(S.printButton,_.button,N),disabled:T,onclick:this._handlePrintMap,tabIndex:0,type:"button"},e.export),w("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:S.exportedFilesContainer},w(v,{class:S.exportedFilesTitle,level:this.headingLevel},e.exportText),P.length>0?null:w("div",null,w("div",null,e.exportHint)),B)),H=w("div",{class:S.printWidgetContainer},w("header",{class:S.headerTitle},e.export),this.error||D||!n?R:U),z="initializing"===i.state?this._renderLoader():H;return w("div",{bind:this,class:this.classes(S.base,_.widget,_.panel)},z)}_renderCustomTextElementSection(){const{customTextElements:t}=this.templateOptions;return t?w("div",{class:S.formSectionContainer,key:"custom-text-elements"},t.map((t=>{const[e,a]=Object.entries(t)[0];return"date"===e?null:w("label",{key:e},e,w("input",{bind:this,class:this.classes(S.inputText,_.input),"data-input-custom":!0,"data-input-name":e,onchange:this._updateInputValue,type:"text",value:a}))}))):null}async _applyTemplate(t){if(!t)return;if("string"==typeof t)return this.templateOptions.layout=t,void(this.templateOptions.layoutItem=null);if(!t.layoutTemplateInfo&&t.layoutItem)try{this._awaitingServerResponse=!0,t.layoutTemplateInfo=await this.viewModel.getLayoutTemplateInfo(t.layoutItem);const{hasLegend:e,mapSurroundInfos:a}=t.layoutTemplateInfo.layoutOptions,i=a.some((({type:t,visible:e})=>"CIMMarkerNorthArrow"===t&&e));t.layoutOptions={legend:e,northArrow:i}}catch(l){i.getLogger(this).error(`Failed to load layout info for ${t.label}`,l)}finally{this._awaitingServerResponse=!1}const{format:e,layoutItem:a}=t,n=t.layout??this.templateOptions.layout,o=t.layoutOptions?.legend??this.templateOptions.legendEnabled,s=t.layoutOptions?.northArrow??this.templateOptions.northArrowEnabled;this.templateOptions.set({format:e,layout:n,layoutItem:a,legendEnabled:o,northArrowEnabled:s})}_renderTitleOrFileNameSection(){const{title:t,fileName:e,titlePlaceHolder:a,fileNamePlaceHolder:i}=this.messages,n=this._layoutTabSelected?t:e,o=this._layoutTabSelected?a:i,s=this._layoutTabSelected?this.templateOptions.title:this.templateOptions.fileName;return w("div",{class:S.formSectionContainer},w("calcite-label",null,n,w("calcite-input",{placeholder:o,value:s??"",onCalciteInputInput:this._onInput})))}_focusOnTabChange(t){if(!this._activeTabFocusRequested)return;const e=t.getAttribute("data-tab-id");("layoutTab"===e&&this._layoutTabSelected||"mapOnlyTab"===e&&!this._layoutTabSelected)&&(t.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const t={[S.loader]:this._awaitingServerResponse};return w("div",{class:this.classes(t),key:"loader"})}_createFileLink(t,e){const a=e||this.messages.untitled,i=t.format.toLowerCase(),n=i.includes("png")?"png":i,o=a+n;return void 0!==this._exportedFileNameMap[o]?this._exportedFileNameMap[o]++:this._exportedFileNameMap[o]=0,new u({name:a,extension:n,count:this._exportedFileNameMap[o]})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(t,e,a){t.find((t=>{const[a]=Object.entries(t)[0];return a===e}))[e]=a}_updateInputValue(t){const e=t.target,a=e.getAttribute("data-input-name"),i=!!e["data-input-custom"],{templateOptions:n}=this;if(i)return void this._updateCustomTextElementValue(n.customTextElements,a,e.value);let o;if("number"===e.type){if(!M(e.valueAsNumber)){const t=n[a];return void(e.value=`${t}`)}o=e.valueAsNumber}else o=e.value;n[a]=o}_handleDPIChange(t){this._updateInputValue(t);const e=t.currentTarget.valueAsNumber,{height:a,width:i}=L(e),{templateOptions:n}=this;n.height=a,n.width=i}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:t}=this,e=this.viewModel.toPrintTemplate(t),a=this._layoutTabSelected?e.layoutOptions?.titleText:t.fileName,i=this._createFileLink(e,a);this.exportedLinks.add(i),this.emit("submit",{link:i}),this.viewModel.print(e).then((t=>{i.set({url:t&&t.url,state:"ready"})})).catch((t=>{i.set({error:t,state:"error"})})).then((()=>{this.emit("complete",{link:i}),this.scheduleRender()}))}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_showAdvancedOptions(){this._layoutTabSelected?this._advancedOptionsVisibleForLayout=!this._advancedOptionsVisibleForLayout:this._advancedOptionsVisibleForMapOnly=!this._advancedOptionsVisibleForMapOnly}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const t=this._rootNode;if(!t)return;const{clientHeight:e,scrollHeight:a}=t,i=a-e;i>0&&(t.scrollTop=i)}_toggleInputValue(t){const e=t.target,a=e.getAttribute("data-option-name");this.templateOptions[a]=e.checked,"scaleEnabled"===a&&(this.templateOptions[a]||this._resetToCurrentScale())}_renderExportedLink(t){const e=this.messages;return t.map((t=>{const{error:a,url:i,state:n}=t,l=t.formattedName??"",r="error"===n,p="pending"===n,d="ready"===n,c={[_.anchorDisabled]:p||r};let u=i||null;u&&(u=o(u));const h=s(i,location.href),m={[y.loadingIndicator]:p,[_.rotating]:p,[y.download]:h&&d,[y.launchLinkExternal]:!h&&d,[y.error]:r,[S.exportedFileError]:r},b={[S.exportedFileError]:r};let v;v=p?e.pending:d?e.ready:e.errorMessage;const f=r?"print-task:cim-symbol-unsupported"===a?.name?e.exportWebMapCIMError:e.exportWebMapError:"";return w("div",{"aria-label":v,class:S.exportedFile,"data-item":t,key:l,onclick:this._removeLink,title:f},w("a",{"aria-label":`${l}. ${e.linkReady}`,class:this.classes(S.exportedFileLink,_.anchor,c),download:l,href:u??"",onclick:this._handleLinkClick,rel:"noreferrer",tabIndex:0,target:"_blank"},w("span",{class:this.classes(m)}),w("span",{class:this.classes(S.exportedFileLinkTitle,b)},l)))}))}_toggleLayoutPanel(t){const e=t.target;this._toggleTab(e.getAttribute("data-tab-id"))}_toggleTab(t,e=!0){this._layoutTabSelected=t===x.layout,this.templateOptions.layout=this._layoutTabSelected?this.viewModel.templatesInfo?.layout?.defaultValue??"letter-ansi-a-landscape":T,this.templateOptions.layoutItem=null,e&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(t){const{key:e}=t,a=t.target.getAttribute("data-tab-id");if(f(e))return this._toggleTab(a),t.preventDefault(),void t.stopPropagation();"ArrowLeft"!==e&&"ArrowRight"!==e||(this._toggleTab(a===x.layout?x.mapOnly:x.layout),t.preventDefault(),t.stopPropagation())}};t([l()],$.prototype,"allowedFormats",null),t([l()],$.prototype,"allowedLayouts",null),t([l()],$.prototype,"error",null),t([l({type:O})],$.prototype,"exportedLinks",void 0),t([l()],$.prototype,"extraParameters",null),t([l()],$.prototype,"headingLevel",void 0),t([l()],$.prototype,"iconClass",void 0),t([l()],$.prototype,"icon",void 0),t([l()],$.prototype,"includeDefaultTemplates",null),t([l()],$.prototype,"label",null),t([l(),g("esri/widgets/Print/t9n/Print")],$.prototype,"messages",void 0),t([l()],$.prototype,"portal",null),t([l()],$.prototype,"printServiceUrl",null),t([l()],$.prototype,"templateCustomTextElements",null),t([l({type:m})],$.prototype,"templateOptions",void 0),t([l()],$.prototype,"view",null),t([l({type:h})],$.prototype,"viewModel",void 0),$=t([r("esri.widgets.Print")],$);const F=$;export{F 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import t from"../../../geometry/Polygon.js";import{createExtentFromGeometry as o,scaleExtent as r}from"../../../geometry/support/geometryUtils.js";import{addressToLocations as n}from"../../../rest/locator/addressToLocations.js";import{locationToAddress as s}from"../../../rest/locator/locationToAddress.js";import{suggestLocations as i}from"../../../rest/locator/suggestLocations.js";import c from"../../../rest/support/AddressToLocationsParameters.js";import a from"../../../rest/support/LocationToAddressParameters.js";import u from"../../../rest/support/SuggestLocationsParameters.js";const l="Single Line Input",d=3e5;function m(e,t){return e.location?S(e,t):h(e,t)}function f(e,t){if(t.localSearchDisabled)return null;const o=e?.scale;return"number"==typeof o&&o<=d?e?.extent?.center:null}async function p(e,t){const{source:o,spatialReference:r,view:n,suggestTerm:s,maxSuggestions:c,sourceIndex:a}=e,l=new u,{apiKey:d,url:m}=o,p=w(o,n),g=t?.signal;if(!m)return null;d&&(l.apiKey=d),o.categories&&(l.categories=o.categories),r&&(l.outSpatialReference=r);const y=f(n,o);y&&(l.location=y);if(!s.trim())return null;const{prefix:x="",suffix:v=""}=o,S=`${x}${s}${v}`;return l.text=S,p&&(l.searchExtent=p),l.maxSuggestions=c,o.countryCode&&(l.countryCode=o.countryCode),i(m,l,{signal:g}).then((e=>I(e,a)))}function g(e){return!!e&&/(?:geocode\-api\.arcgis\.com\/arcgis\/rest\/services\/world\/geocodeserver).*/i.test(e)}function y(e){return!!e&&/(?:\/servers\/[\da-z\.-]+\/rest\/services\/world\/geocodeserver).*/i.test(e)}function x(e){return!!e&&/(?:arcgis\.com\/arcgis\/rest\/services\/world\/geocodeserver).*/i.test(e)}const v="https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer";async function S(e,t){const{source:o,spatialReference:r,location:n,sourceIndex:i,view:c}=e,{apiKey:u,url:l,zoomScale:d,defaultZoomScale:m}=o;if(null==l)return[];const f=c?.scale,p=t?.signal,g=new a
|
|
5
|
+
import e from"../../../Graphic.js";import t from"../../../geometry/Polygon.js";import{createExtentFromGeometry as o,scaleExtent as r}from"../../../geometry/support/geometryUtils.js";import{addressToLocations as n}from"../../../rest/locator/addressToLocations.js";import{locationToAddress as s}from"../../../rest/locator/locationToAddress.js";import{suggestLocations as i}from"../../../rest/locator/suggestLocations.js";import c from"../../../rest/support/AddressToLocationsParameters.js";import a from"../../../rest/support/LocationToAddressParameters.js";import u from"../../../rest/support/SuggestLocationsParameters.js";const l="Single Line Input",d=3e5;function m(e,t){return e.location?S(e,t):h(e,t)}function f(e,t){if(t.localSearchDisabled)return null;const o=e?.scale;return"number"==typeof o&&o<=d?e?.extent?.center:null}async function p(e,t){const{source:o,spatialReference:r,view:n,suggestTerm:s,maxSuggestions:c,sourceIndex:a}=e,l=new u,{apiKey:d,url:m}=o,p=w(o,n),g=t?.signal;if(!m)return null;d&&(l.apiKey=d),o.categories&&(l.categories=o.categories),r&&(l.outSpatialReference=r);const y=f(n,o);y&&(l.location=y);if(!s.trim())return null;const{prefix:x="",suffix:v=""}=o,S=`${x}${s}${v}`;return l.text=S,p&&(l.searchExtent=p),l.maxSuggestions=c,o.countryCode&&(l.countryCode=o.countryCode),i(m,l,{signal:g}).then((e=>I(e,a)))}function g(e){return!!e&&/(?:geocode\-api\.arcgis\.com\/arcgis\/rest\/services\/world\/geocodeserver).*/i.test(e)}function y(e){return!!e&&/(?:\/servers\/[\da-z\.-]+\/rest\/services\/world\/geocodeserver).*/i.test(e)}function x(e){return!!e&&/(?:arcgis\.com\/arcgis\/rest\/services\/world\/geocodeserver).*/i.test(e)}const v="https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer";async function S(e,t){const{source:o,spatialReference:r,location:n,sourceIndex:i,view:c}=e,{apiKey:u,url:l,zoomScale:d,defaultZoomScale:m}=o;if(null==l)return[];const f=c?.scale,p=t?.signal,g=new a({location:n});u&&(g.apiKey=u),r&&(g.outSpatialReference=r);try{return K([await s(l,g,{signal:p})],{sourceIndex:i,scale:f,view:c,zoomScale:d,defaultZoomScale:m})}catch(y){return[]}}function w(e,t){const{filter:r,withinViewEnabled:n}=e,s=t?.scale,i=t?.extent,c=r?.geometry;return(c?o(c,t??void 0,s):void 0)||(n&&i?i:void 0)}async function h(e,t){const{source:o,suggestResult:r,spatialReference:s,view:i,maxResults:a,sourceIndex:u}=e,d=o?.zoomScale,m=o?.defaultZoomScale,p=r.text?.trim();if(!p)return null;const g=!r.key&&o.prefix?o.prefix:"",y=!r.key&&o.suffix?o.suffix:"",x=`${g}${r.text}${y}`,v=new c,{apiKey:S,url:h}=o,j=i?.scale,I=w(o,i),$=t?.signal;if(S&&(v.apiKey=S),!h)return null;o.categories&&(v.categories=o.categories),o.locationType&&(v.locationType=o.locationType),s&&(v.outSpatialReference=s);const L=f(i,o);L&&(v.location=L),v.maxLocations=a,I&&(v.searchExtent=I),o.countryCode&&(v.countryCode=o.countryCode);const{key:R}=r,T=`${R}`;return R&&(v.magicKey=T),v.address={},v.address[o.singleLineFieldName||l]=x,o.outFields&&(v.outFields=o.outFields),n(h,v,{signal:$}).then((e=>K(e,{key:T,scale:j,sourceIndex:u,view:i,zoomScale:d,defaultZoomScale:m})))}function j(e,t){return{text:e.text,key:e.magicKey,sourceIndex:t}}function I(e,t){return e.map((e=>j(e,t)))}function $(n,s){const{key:i,scale:c,sourceIndex:a,view:u,zoomScale:l,defaultZoomScale:d}=s,{attributes:m,extent:f,location:p,address:g}=n,y=new e({geometry:p,attributes:m}),x=f||p,v=x?o(x,u??void 0,c??void 0):void 0,S=v?"number"==typeof l?r(v,u??void 0,l):"number"==typeof d&&"point"===x?.type?r(v,u??void 0,d):v:null,w=p?`${p.x},${p.y}`:"",h=g||w,j=y.clone();return null!=S&&(j.geometry=t.fromExtent(S)),{extent:S,feature:y,target:j,key:i,name:h,sourceIndex:a}}function K(e,t){return e.filter(Boolean).map((e=>$(e,t)))}export{f as getLocation,m as getResults,p as getSuggestions,x as isArcGISWorldGeocoder,g as isMeteredArcGISWorldGeocoder,y as isProxiedArcGISWorldGeocoder,v as meteredArcGISLocatorUrl};
|