@arcgis/core 6.0.0-next.20 → 6.0.0-next.22
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/arcgisGlobal.d.ts +1 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0049b66ccbfb168caa76.js +1 -0
- package/assets/esri/core/workers/chunks/092e311cb7aea92a6a26.js +1 -0
- package/assets/esri/core/workers/chunks/0df9a906f7823c23d426.js +1 -0
- package/assets/esri/core/workers/chunks/17c6d66b47aa690df0d4.js +1 -0
- package/assets/esri/core/workers/chunks/{3704b4e7efc3abc1a7b1.js → 242a77066ac5cdb5b7d7.js} +1 -1
- package/assets/esri/core/workers/chunks/2ad69cc496235702bbf2.js +1 -0
- package/assets/esri/core/workers/chunks/2f91fd61019d2a37476d.js +1 -0
- package/assets/esri/core/workers/chunks/3cd04d23b73beaf79650.js +1 -0
- package/assets/esri/core/workers/chunks/434a8ba841a59e0deab9.js +1 -0
- package/assets/esri/core/workers/chunks/{60f92eb03c6e17ab4747.js → 435b90168f79c5587a07.js} +1 -1
- package/assets/esri/core/workers/chunks/{f00458654c7c34c369ef.js → 45ba4aa87a4732198596.js} +1 -1
- package/assets/esri/core/workers/chunks/504184828048310a052c.js +1 -0
- package/assets/esri/core/workers/chunks/{eca44e53bcee9b08d70a.js → 5046214dd32029cb733d.js} +1 -1
- package/assets/esri/core/workers/chunks/53ff68d4f9e365fc15cd.js +1 -0
- package/assets/esri/core/workers/chunks/542e5640ea1b80ef801a.js +1 -0
- package/assets/esri/core/workers/chunks/58865772bed48141a56a.js +1 -0
- package/assets/esri/core/workers/chunks/5a9b7eb26f936f03d02e.js +1 -0
- package/assets/esri/core/workers/chunks/5d76f4d97beee494bbbf.js +1 -0
- package/assets/esri/core/workers/chunks/5f07f52bb8b7721f08d3.js +1 -0
- package/assets/esri/core/workers/chunks/67f54efc817b241f8746.js +1 -0
- package/assets/esri/core/workers/chunks/6d41444b46677aa762a7.js +1 -0
- package/assets/esri/core/workers/chunks/6dfe96b056bec30068df.js +1 -0
- package/assets/esri/core/workers/chunks/7159d9c36869cd82599e.js +29 -0
- package/assets/esri/core/workers/chunks/792d2b62356a1d953c88.js +1 -0
- package/assets/esri/core/workers/chunks/{00d66e3fba5ab4d2aa3c.js → 84940d8e14caf5a27e04.js} +1 -1
- package/assets/esri/core/workers/chunks/{9401cc22373566e1171e.js → 8a7b02037151767542f1.js} +1 -1
- package/assets/esri/core/workers/chunks/95b82cbbe355266c65d7.js +1 -0
- package/assets/esri/core/workers/chunks/a64446a3328a7323e307.js +1 -0
- package/assets/esri/core/workers/chunks/a65951f1d5702cfd996e.js +1 -0
- package/assets/esri/core/workers/chunks/{7bbfe9ff352afc566367.js → a679207c3458cc0b1fec.js} +1 -1
- package/assets/esri/core/workers/chunks/a6f969851d4278865cc5.js +1 -0
- package/assets/esri/core/workers/chunks/aa4f3751f0d830113bed.js +1 -0
- package/assets/esri/core/workers/chunks/b0ca81a07cff25df19d2.js +1 -0
- package/assets/esri/core/workers/chunks/b1d989b72203113a06fe.js +1 -0
- package/assets/esri/core/workers/chunks/{9fab290090ef2ccae810.js → b3273f847405799e3362.js} +1 -1
- package/assets/esri/core/workers/chunks/b4c3ec081874b49ff89b.js +1 -0
- package/assets/esri/core/workers/chunks/b6d71a4ab788a09714f3.js +1 -0
- package/assets/esri/core/workers/chunks/{597db9c90f19092d8d66.js → baed828b7846c0863289.js} +14 -14
- package/assets/esri/core/workers/chunks/{28b74bc77f7c13080074.js → be97a629e2ae4d13ceb3.js} +1 -1
- package/assets/esri/core/workers/chunks/c0d7ae314ebfad1e3791.js +1 -0
- package/assets/esri/core/workers/chunks/c82daefb193aae895bc0.js +1 -0
- package/assets/esri/core/workers/chunks/d8a7eba588d374b2f961.js +1 -0
- package/assets/esri/core/workers/chunks/db9921fbda556f142c4a.js +1 -0
- package/assets/esri/core/workers/chunks/ee08ae5b73439a1ff666.js +1 -0
- package/assets/esri/core/workers/chunks/{a34b3d2e11a777e1ff3f.js → f28b63c1179366dac8a2.js} +1 -1
- package/assets/esri/core/workers/chunks/{557671c897ca5563be6c.js → f6bd7b52745b82ba73dc.js} +1 -1
- package/assets/esri/core/workers/chunks/fcaf9450642fcef83286.js +1 -0
- package/assets/esri/core/workers/chunks/feb41abc03d677df6f73.js +1 -0
- package/assets/esri/core/workers/chunks/ffcb99693182a621a93e.js +1 -0
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +4 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/CloudsComposition.glsl.js +2 -2
- package/chunks/DefaultMaterial.glsl.js +1 -1
- package/chunks/RealisticTree.glsl.js +1 -1
- package/chunks/RibbonLine.glsl.js +113 -121
- package/config.d.ts +47 -38
- package/config.js +1 -1
- package/core/accessorSupport/trackingUtils.js +1 -1
- package/core/accessorSupport/watch.js +1 -1
- package/core/workers/Connection.d.ts +58 -89
- package/core/workers/workerFactory.js +1 -1
- package/core/workers.d.ts +61 -53
- package/geometry/support/MeshComponent.d.ts +1 -1
- package/geometry/support/vcsData.js +1 -1
- package/kernel.js +1 -1
- package/layers/FeatureLayer.d.ts +39 -19
- package/layers/FeatureLayer.js +1 -1
- package/layers/GeospatialPDFLayer.js +1 -1
- package/layers/MapImageLayer.d.ts +10 -3
- package/layers/MapNotesLayer.d.ts +2 -2
- package/layers/SubtypeGroupLayer.d.ts +64 -1
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/graphics/sources/support/QueryTask.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.d.ts +16 -16
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/mixins/ArcGISMapService.js +1 -1
- package/layers/ogc/ogcFeatureUtils.js +1 -1
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/support/LabelClass.d.ts +20 -2
- package/layers/support/Sublayer.d.ts +61 -17
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/TimeInformation.js +2 -0
- package/layers/support/commonProperties.js +1 -1
- package/libs/basisu/textureMetadata.js +2 -0
- package/package.json +4 -4
- package/rest/layerSources/DynamicDataLayer.d.ts +4 -2
- package/rest/layerSources/DynamicDataLayer.js +1 -1
- package/rest/layerSources/DynamicMapLayer.d.ts +1 -1
- package/rest/layerSources/DynamicWorkspaceLayer.d.ts +49 -0
- package/rest/layerSources/DynamicWorkspaceLayer.js +2 -0
- package/rest/layerSources/typeUtils.js +2 -0
- package/rest/print.js +1 -1
- package/rest/query/operations/queryRelatedRecords.js +1 -1
- package/rest/query/operations/queryUtils.js +1 -1
- package/rest/support/Query.js +1 -1
- package/rest/support/RelationshipQuery.js +1 -1
- package/rest/support/timeUtils.js +2 -0
- package/symbols/LineSymbol3D.d.ts +5 -3
- package/symbols/TextSymbol.d.ts +27 -2
- package/time/legacyTimeZoneMap.js +1 -1
- package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
- package/views/2d/analysis/AreaMeasurementAnalysisView2D.js +1 -1
- package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementTool.js +1 -1
- package/views/2d/analysis/DistanceMeasurementAnalysisView2D.js +1 -1
- package/views/2d/analysis/ElevationProfileAnalysisView2D.d.ts +6 -0
- package/views/2d/analysis/ElevationProfileAnalysisView2D.js +1 -1
- package/views/2d/layers/AnnotationFeatureLayerView2D.js +1 -1
- package/views/2d/layers/CSVLayerView2D.js +1 -1
- package/views/2d/layers/CatalogFootprintLayerView2D.js +1 -1
- package/views/2d/layers/DimensionFeatureLayerView2D.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
- package/views/2d/layers/GeoJSONLayerView2D.js +1 -1
- package/views/2d/layers/KnowledgeGraphSublayerView2D.js +1 -1
- package/views/2d/layers/OGCFeatureLayerView2D.js +1 -1
- package/views/2d/layers/OrientedImageryLayerView2D.js +1 -1
- package/views/2d/layers/ParquetLayerView2D.js +1 -1
- package/views/2d/layers/StreamLayerView2D.js +1 -1
- package/views/2d/layers/SubtypeGroupLayerView2D.js +1 -1
- package/views/2d/layers/WFSLayerView2D.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/analysis/Dimension/DimensionVisualization.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
- package/views/3d/analysis/ElevationProfileAnalysisView3D.d.ts +6 -0
- package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightObserverPlugin.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTargetPlugin.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedFieldOfViewManipulation.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedPlacementPointPlugin.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementController.js +1 -1
- package/views/3d/environment/SunLighting.d.ts +17 -1
- package/views/3d/environment/SunLighting.js +1 -1
- package/views/3d/environment/VirtualLighting.d.ts +17 -1
- package/views/3d/environment/VirtualLighting.js +1 -1
- package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
- package/views/3d/interactive/manipulators/ResizeManipulator.js +1 -1
- package/views/3d/interactive/manipulators/RotateManipulator.js +1 -1
- package/views/3d/interactive/manipulators/ShiftManipulator.js +1 -1
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/TiledLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/support/elevationUpdateUtils.js +1 -1
- package/views/3d/terrain/TerrainData.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileAgent.js +1 -1
- package/views/3d/terrain/terrainUtils.js +1 -1
- package/views/3d/terrain/tileUtils.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/SymbolColor.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialExternalColor.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/output/getEmissions.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterColor.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +6 -6
- package/views/3d/webgl-engine/effects/clouds/CloudsComposition.js +1 -1
- package/views/3d/webgl-engine/lib/BasisUtil.js +1 -1
- package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
- package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
- package/views/BasemapView.js +1 -1
- package/views/BreakpointsOwner.d.ts +6 -0
- package/views/GroundView.d.ts +1 -1
- package/views/GroundView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
- package/views/types.d.ts +3 -0
- package/views/ui/UI.js +1 -1
- package/views/webgl/ShaderBuilder.js +1 -1
- package/widgets/Daylight/DaylightViewModel.js +1 -1
- package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +2 -2
- package/widgets/PanoramicViewer/PanoramicVideoViewerViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.d.ts +61 -2
- package/widgets/TimeSlider/TimeSliderViewModel.d.ts +3 -2
- package/widgets/TimeSlider.d.ts +5 -4
- package/assets/esri/core/workers/chunks/0bd5012da287469b17d5.js +0 -1
- package/assets/esri/core/workers/chunks/1e40a26dcce4d1dadc28.js +0 -1
- package/assets/esri/core/workers/chunks/2d13a22f7b2427927fdc.js +0 -1
- package/assets/esri/core/workers/chunks/34e0a8a3a2beea50f4f5.js +0 -1
- package/assets/esri/core/workers/chunks/370aad23df597db80d65.js +0 -1
- package/assets/esri/core/workers/chunks/42fd2a7b22b03dacc6a7.js +0 -1
- package/assets/esri/core/workers/chunks/494bd434fee9032e1d02.js +0 -1
- package/assets/esri/core/workers/chunks/4e350d6c76957f5beb70.js +0 -1
- package/assets/esri/core/workers/chunks/4fe34da1c5d63e66ce98.js +0 -1
- package/assets/esri/core/workers/chunks/501c6e14ab119785252b.js +0 -1
- package/assets/esri/core/workers/chunks/510502a4c9a2ba8d3f7b.js +0 -1
- package/assets/esri/core/workers/chunks/564565246dae080f5e6c.js +0 -1
- package/assets/esri/core/workers/chunks/612104dff305ff062dfa.js +0 -29
- package/assets/esri/core/workers/chunks/6ad309154fe84210d23c.js +0 -1
- package/assets/esri/core/workers/chunks/6c255c029d67423e4dac.js +0 -1
- package/assets/esri/core/workers/chunks/6c9266120d46e8c69dbf.js +0 -1
- package/assets/esri/core/workers/chunks/6c9acd9e4e201dc380e9.js +0 -1
- package/assets/esri/core/workers/chunks/74c866e0b66e61751861.js +0 -1
- package/assets/esri/core/workers/chunks/939942b00ba380e2957e.js +0 -1
- package/assets/esri/core/workers/chunks/95dbbddac6581b9d671f.js +0 -1
- package/assets/esri/core/workers/chunks/9d61740ef8bdcc162be1.js +0 -1
- package/assets/esri/core/workers/chunks/a49fe94933b65b4b64f8.js +0 -1
- package/assets/esri/core/workers/chunks/aa1ac7954e4f0fefe15b.js +0 -1
- package/assets/esri/core/workers/chunks/b48952e1fb4cb7360dd0.js +0 -1
- package/assets/esri/core/workers/chunks/b5df193c93e9c19f9700.js +0 -1
- package/assets/esri/core/workers/chunks/befa32b9e7b3fbdd431e.js +0 -1
- package/assets/esri/core/workers/chunks/c2c1f51a4668055c2838.js +0 -1
- package/assets/esri/core/workers/chunks/d0f5bee9db1ad51ae687.js +0 -1
- package/assets/esri/core/workers/chunks/d678828726371243d5eb.js +0 -1
- package/assets/esri/core/workers/chunks/dd0310184fe4832755a8.js +0 -1
- package/assets/esri/core/workers/chunks/de5ecb567bd69c613e9d.js +0 -1
- package/assets/esri/core/workers/chunks/e1f5d00878f27e1d413e.js +0 -1
- package/assets/esri/core/workers/chunks/e8bf653376a607f00897.js +0 -1
- package/assets/esri/core/workers/chunks/fb70ab267a08e24b710f.js +0 -1
- package/assets/esri/core/workers/chunks/fc44d45598a7476bc606.js +0 -1
package/views/SceneView.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../Camera.js";import n from"../Viewpoint.js";import r from"../core/Collection.js";import{byId as i}from"../core/domUtils.js";import a from"../core/Error.js";import{on as o}from"../core/events.js";import{destroyHandle as s,makeHandle as c}from"../core/handleUtils.js";import has from"../core/has.js";import l from"../core/Logger.js";import{mapCollectionAsync as ee}from"../core/mapCollectionUtils.js";import{destroyMaybe as u,maybeProperty as te}from"../core/maybe.js";import{throwIfDestroyed as ne,throwIfAborted as d,createAbortError as re}from"../core/promiseUtils.js";import ie from"../core/ReactiveSet.js";import{on as f,watch as p,initial as m,sync as h,whenOnce as ae,syncAndInitial as g}from"../core/reactiveUtils.js";import{setFrameDuration as oe,cleanupScheduling as se}from"../core/scheduling.js";import{createScreenPoint as ce,createScreenPointArray as le}from"../core/screenUtils.js";import{cleanupWhereClauseCache as ue}from"../core/sql.js";import{getDefaultVerticalUnitStringForSR as de,getMetersPerUnitForSR as fe}from"../core/units.js";import{property as _,cast as v,subclass as pe}from"../core/accessorSupport/decorators.js";import{ensureType as y,ensureClass as b}from"../core/accessorSupport/ensureType.js";import{overrideDefaultsFrom as me}from"../core/accessorSupport/overrideDefaultsFrom.js";import{runUntracked as he}from"../core/accessorSupport/tracking.js";import{drainNotificationQueue as ge}from"../core/accessorSupport/trackingUtils.js";import{create as _e}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{cleanupPooledRBush as ve}from"../core/libs/rbush/PooledRBush.js";import{initialize as ye}from"../core/workers/workers.js";import x from"../geometry/Extent.js";import be from"../geometry/HeightModelInfo.js";import S from"../geometry/Point.js";import{project as C,canProjectWithoutEngine as xe}from"../geometry/projectionUtils.js";import w from"../geometry/SpatialReference.js";import{cleanupSpatialReferenceEllipsoidUtils as Se}from"../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingRect as Ce}from"../geometry/projection/projectBoundingRect.js";import{projectPointToVector as T}from"../geometry/projection/projectPointToVector.js";import{toExtent as we,create as Te}from"../geometry/support/aaBoundingRect.js";import{renderSRFromViewSR as Ee}from"../geometry/support/coordinateSystem.js";import{getResolutionForScale as De}from"../geometry/support/scaleUtils.js";import{wgs84 as Oe,webMercator as ke}from"../geometry/support/spatialReferenceUtils.js";import{makeDehydratedPoint as Ae}from"../layers/graphics/dehydratedPoint.js";import{isImageryTileLayer as E,isTiledLayer as D,isVoxelLayer as O,isIntegratedMeshLayer as k,isGaussianSplatLayer as je}from"../layers/support/layerUtils.js";import{TilemapCache as Me}from"../layers/support/TilemapCache.js";import{clearDefaultPortalInstance as Ne}from"../portal/portalDefault.js";import{WebSceneTag as Pe}from"../support/tagSymbols.js";import{BreakpointsOwner as Fe}from"./BreakpointsOwner.js";import{DOMContainer as Ie}from"./DOMContainer.js";import{PopupView as Le}from"./PopupView.js";import A from"./View.js";import Re from"./ViewAnimation.js";import{stringFromViewingMode as j,viewingModeFromString as M}from"./ViewingMode.js";import{GroundView3D as ze}from"./3d/GroundView3D.js";import{layerView3DImporter as N}from"./3d/layerViewModuleImportUtils.js";import{importAnalysisViewModule as Be}from"./3d/analysis/analysisViewModuleImportUtils.js";import{cleanupIntersectionUtils as Ve}from"./3d/camera/intersectionUtils.js";import P from"./3d/constraints/Constraints.js";import F from"./3d/environment/Environment.js";import{EnvironmentView as He}from"./3d/environment/EnvironmentView.js";import Ue from"./3d/input/SceneInputManager.js";import{GraphicsDeconflictor as We}from"./3d/layers/graphics/GraphicsDeconflictor.js";import{Labeler as Ge}from"./3d/layers/graphics/Labeler.js";import Ke from"./3d/layers/i3s/I3SLodHandling.js";import{Navigation3D as qe}from"./3d/navigation/Navigation3D.js";import{ScreenSizePerspective as Je}from"./3d/state/ScreenSizePerspective.js";import I from"./3d/state/ViewState.js";import{ViewStateManager as Ye,cleanupViewStateManager as Xe}from"./3d/state/ViewStateManager.js";import{cleanupPointToPointAnimationController as Ze}from"./3d/state/controllers/PointToPointAnimationController.js";import{SceneIntersectionHelper as Qe}from"./3d/state/helpers/SceneIntersectionHelper.js";import{cleanupNavigationUtils as $e}from"./3d/state/utils/navigationUtils.js";import et from"./3d/support/Attribution3D.js";import{CombinedElevationProvider as tt}from"./3d/support/CombinedElevationProvider.js";import{debugFlags as L}from"./3d/support/debugFlags.js";import{getElevationAtPoint as nt}from"./3d/support/ElevationProvider.js";import{GroundAndIMSurface as rt}from"./3d/support/GroundAndIMSurface.js";import{toMap as it,hitTest as at}from"./3d/support/hitTest.js";import{popupHitTest as ot}from"./3d/support/popupHitTest.js";import{getDefaultQualityProfileName as st,getQualityProfileSettings as R}from"./3d/support/QualityProfile.js";import z from"./3d/support/QualitySettings.js";import{RenderCoordsHelper as ct}from"./3d/support/RenderCoordsHelper.js";import{newResourceController as lt}from"./3d/support/ResourceController.js";import ut from"./3d/support/SceneViewPerformanceInfo.js";import{SharedSymbolResources as dt}from"./3d/support/SharedSymbolResources.js";import{ViewSlice as ft}from"./3d/support/ViewSlice.js";import{PointsOfInterest as B}from"./3d/support/pointsOfInterest/PointsOfInterest.js";import V from"./3d/terrain/TerrainSurface.js";import{isSurfaceLayerView as pt,getTiledLayerInfo as mt,checkIfTileInfoSupportedForView as ht}from"./3d/terrain/terrainUtils.js";import{clearTilePerLayerInfo as gt}from"./3d/terrain/TilePerLayerInfo.js";import{cleanupTileRenderer as _t}from"./3d/terrain/TileRenderer.js";import{Stage as vt}from"./3d/webgl-engine/Stage.js";import{olidEnabled as yt}from"./3d/webgl-engine/effects/geometry/olidUtils.js";import{cleanupRenderOccluded as bt}from"./3d/webgl-engine/effects/geometry/RenderOccluded.js";import{defaultTolerance as H}from"./3d/webgl-engine/lib/Intersector.js";import{cleanupShadowmap as xt}from"./3d/webgl-engine/lib/ShadowMap.js";import{terrainId as U}from"./3d/webgl-engine/lib/verticalOffsetUtils.js";import{cleanupEdgeProcessing as St}from"./3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js";import W from"./interactive/options/ViewOptions.js";import Ct from"./support/AnalysisViewManager.js";import{cleanupDrapedUtils as wt}from"./support/drapedUtils.js";import{occludeesSupported as Tt}from"./support/layerViewUtils.js";import{isSupportedScreenPointEvent as G,createScreenPointFromSupportedEvent as K}from"./support/screenUtils.js";import{isSpatialReferenceSupported as Et}from"./support/spatialReferenceSupport.js";import{initializeTextureCompressionWorker as Dt,destroyTextureCompressionWorker as Ot}from"./support/TextureCompressionHelper.js";import kt from"./ui/DefaultUI.js";import At from"./ui/3d/DefaultUI3D.js";import jt from"../webscene/Environment.js";import{clearVNodeCache as Mt}from"../widgets/support/vnodeCache.js";var q;const Nt=Symbol(),J=Symbol();function Pt(e){let t=b(W,e);return t!==e&&e.snapping?.enabled==null&&(t.snapping.enabled=!0),t}let Y=class extends Fe(Le(Ie(A))){static{q=this}get timeZone(){return super.timeZone}set timeZone(e){super.timeZone=e}constructor(e){super(e),this.options=new W({snapping:{enabled:!0}}),this._userClippingArea=null,this._clippingArea=null,this._overrideDefaultEnvironmentOnly=!0,this._resolveWhenReady=[],this._resourceController=lt(this),this.deconflictor=new We({view:this}),this.attribution3D=new et({view:this}),this.labeler=new Ge({view:this,deconflictor:this.deconflictor.labels}),this.sharedSymbolResources=null,this.navigation=new qe({view:this}),this.basemapTerrain=null,this.elevationProvider=new tt({view:this}),this._canvas=null,this.constraints=new P,this._environment=new F,this.environmentView=new He,this.floors=new r,this.fullOpacity=1,this.graphicsView=null,this.analysisViewManager=new Ct({importAnalysisViewModule:e=>Be(e),view:this}),this.groundView=null,this.groundAndIMSurface=null,this.map=null,this._featureTileTreeClients=new ie,this._featureTiles=null,this._featureTreeDebugger=null,this.state=new I({view:this}),this.slice=new ft,this.spatialReference=null,this.preserveDrawingBufferEnabled=!1,this.supersampleScreenshotsEnabled=!0,this.type=`3d`,this.ui=new At,this._numUpdating=0,this._lastUpdateTime=0,this.updatingProgress=.5,this._importControllers=new Map,ye();let t=()=>this._updatingChanged();this.addHandles(s(ee(()=>this.map?.allLayers,async e=>{try{await e.when()}catch{}finally{t()}}))),this.addHandles([f(()=>this.map?.allLayers,`after-changes`,t,{onListenerAdd:t,onListenerRemove:t,sync:!0}),this.allLayerViews.on(`after-changes`,e=>this._updateUpdatingMonitors(e)),p(()=>this.scene,e=>e?.load().catch(()=>{}))]),this.inputManager=new Ue({view:this}),this.stateManager=new Ye({view:this}),this.screenSizePerspective=new Je({view:this})}initialize(){if(has(`enable-feature:esri-compress-textures`)&&has(`wasm-simd`)){let e=Dt(this,this.resourceController);this.addResolvingPromise(e.promise)}this.groundView=new ze({view:this}),this.groundAndIMSurface=new rt({view:this}),this._updateUpdatingMonitors(),this.updatingHandles.add(()=>this.qualitySettings.memoryLimit,e=>{this.resourceController&&(this.resourceController.memoryController.maxMemory=e)},m),this.updatingHandles.add(()=>this.qualitySettings.additionalCacheMemory,e=>{this.resourceController&&(this.resourceController.memoryController.additionalCacheMemory=e)},m),this.updatingHandles.add(()=>this.qualitySettings.frameRate??0,e=>oe(e>0?1e3/Math.ceil(e):0),m),this.addHandles([p(()=>this.spatialReference,()=>this.notifyChange(`clippingArea`),h),p(()=>({plane:this.slice.plane,isDecoration:this.slice.isDecoration}),()=>this._updateSlice(),h)])}destroy(){this.destroyed||(Ot(this),this.updatingHandles.removeAll(),this.basemapTerrain?.clearHandles(),this.elevationProvider.destroy(),this.ui.removeAllHandles(),this.layerViewManager.clearHandles(),this.invalidate(),this.layerViewManager.clear(),this._set(`analysisViewManager`,u(this.analysisViewManager)),this._exitSurface(),this._disposeGraphicsView(),this._disposeFocusAreasView(),this.sharedSymbolResources=u(this.sharedSymbolResources),this._set(`labeler`,u(this.labeler)),this._set(`deconflictor`,u(this.deconflictor)),this._resourceController=u(this._resourceController),this._set(`stateManager`,u(this.stateManager)),this._set(`inputManager`,u(this.inputManager)),this.state.destroy(),this.highlights.destroy(),this.removeHandles(`updatingMonitors`),this._set(`environmentView`,u(this.environmentView)),this._set(`environment`,u(this.environment)),this.groundView=u(this.groundView),this.groundAndIMSurface.destroy(),this.slice.destroy(),this._updatingObjectsWithProgress.length=0,this._updatingObjects.length=0,this.ui?.destroy(),this._set(`ui`,null),this._set(`renderCanvas`,null),this._set(`canvas`,null),this._canvas=null,this.screenSizePerspective.destroy(),this.attribution3D.destroy())}get stage(){return this._stage}get renderSpatialReference(){return this.renderCoordsHelper?.spatialReference}get groundSpatialReference(){return this.groundView?.spatialReference}get analyses(){return super.analyses}set analyses(e){super.analyses=e}get animation(){return this.state?.animation}get overlayManager(){return this.basemapTerrain?.overlayManager}get camera(){return this.stateManager?.camera}set camera(e){this.stateManager&&(this.stateManager.camera=e)}get contentCamera(){return this.stateManager?.contentCamera}set contentCamera(e){this.stateManager&&(this.stateManager.contentCamera=e)}installContentCameraReset(e={sticky:!1}){return this.stateManager.installContentCameraReset(e)}get canvas(){return this._canvas}get center(){return this.stateManager?.center}set center(e){this.stateManager&&(this.stateManager.center=y(S,e))}get clippingArea(){if(this.viewingMode===`global`)return null;let e=this.map,t=this._userClippingArea||te(e,`clippingArea`);return!(this._userClippingArea||te(e,`clippingEnabled`))||t==null?(this._clippingArea=null,null):t instanceof x?this.spatialReference&&(t=X(t,this.spatialReference),t==null)?(l.getLogger(this).error(`#clippingArea`,`setting clippingArea with incompatible SpatialReference`),this._clippingArea):(t=t.clone(),t.intersection(this._groundAndLayersExtent)??(t.xmin=t.xmax,t.ymin=t.ymax),t.zmin=void 0,t.zmax=void 0,t.equals(this._clippingArea)||(this._clippingArea=t),this._clippingArea):(l.getLogger(this).error(`#clippingArea`,`only clippingArea geometries of type Extent are supported`),this._clippingArea)}set clippingArea(e){this.ready&&this.viewingMode===`global`&&e!=null?l.getLogger(this).error(`#clippingArea=`,`Clipping area is only supported in local viewingMode`):this._userClippingArea=e}get renderDataExtent(){if(this.state.viewingMode===1)return null;let e=this.renderSpatialReference,t=this.dataExtent;return t==null||e==null||t.spatialReference.equals(e)?t:X(t,e)}get tileInfo(){return this.basemapTerrain?.tilingScheme?.toTileInfo()}get dataExtent(){let e=this._groundAndLayersExtent,t=this.spatialReference||w.WGS84,n=X(this.clippingArea,t);n!=null&&(e=e==null?n:e.intersection(n));let r=this._get(`dataExtent`);return e!=null&&e.equals(r)?r:e}get _groundAndLayersExtent(){let e=this.spatialReference||w.WGS84,t,n=n=>{let r=X(n,e);r!=null&&(t==null?t=r.clone():t.union(r))},{groundView:r}=this,i=r?.spatialReference,a=r?.fullGroundExtent;i&&a&&n(new x({xmin:a[0],ymin:a[1],zmin:0,xmax:a[2],ymax:a[3],zmax:0,spatialReference:i}));let o=e=>{e.fullExtent==null||e.type===`graphics`&&e.internal||n(e.fullExtent)};if(this.map?.allLayers.forEach(e=>o(e)),t==null)return null;t.hasZ?(t.zmin=Math.min(0,t.zmin??0),t.zmax=Math.max(0,t.zmax??0)):(t.zmin=0,t.zmax=0);let s=this._get(`_groundAndLayersExtent`);return t.equals(s)?s:t}get environment(){return this._environment}set environment(e){if(this._environment===e)return;let{_environment:t}=this;this._environment=null,t?.destroy(),this._environment=e,this.notifyChange(`environment`)}castEnvironment(e){return e?e instanceof F?e:e instanceof jt?this.environment?.cloneWithWebsceneEnvironment(e)??F.fromWebsceneEnvironment(e):y(F,e):new F}get extent(){return this.stateManager?.extent}set extent(e){this.stateManager&&(this.stateManager.extent=e)}get screenCenter(){return this.stateManager?.screenCenter}get frustum(){return this.stateManager?.frustum}get layerviewCollections(){return[this.basemapView?.baseLayerViews,this.basemapView?.groundLayerViews,this.groundView?.layerViews,this.layerViews,this.basemapView?.referenceLayerViews]}get _layerToLayerviewMapping(){return q._layerToLayerview}static{this._layerToLayerview=A._layerToLayerview.concat([[`view.map.ground.layers`,`view.groundView.layerViews`]])}get initialExtentRequired(){return this.stateManager&&!this.stateManager.hasInitialView}get defaultsFromMapSettings(){return{required:{tileInfo:!1,heightModelInfo:!0,extent:!1}}}get interacting(){return this.navigating||(this.toolViewManager?.interacting??!1)}get stationary(){return!this.animation&&!this.resizing&&(this.state?.stationary??!0)}get navigating(){return this.state?.navigating??!1}get scene(){return this.map&&Pe in this.map?this.map:null}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}get featureTiles(){return this._featureTiles}set qualityProfile(e){let t=R(e);t&&this._get(`qualityProfile`)!==e&&(this.qualitySettings=new z(t),this.stage?.renderView.updateQualitySettings(this.qualitySettings),this._set(`qualityProfile`,e))}get qualityProfile(){return this._get(`qualityProfile`)||st()}_updateSlice(){this.stage!=null&&(this.stage.renderer.slice=this.slice)}get typeSpecificPreconditionsReady(){return this.viewingMode?!!this.stateManager?.preinit(this.spatialReference):!1}get resolution(){let{scale:e,spatialReference:t}=this;return t?he(()=>De(e,t)):0}get scale(){return this.stateManager?.scale}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get terrainLevel(){let e=this.basemapTerrain?.tilingScheme,t=this.scale;if(!e||!t)return null;let n=e.levelAtScale(t)+this.qualitySettings.tiledSurface.lodBias,r=e.getMaxLod();return n<=0?null:Math.max(0,Math.min(n,r||1/0))}get heightModelInfo(){let e=this.getDefaultHeightModelInfo();if(!e)return null;let t=de(this.spatialReference);if(t&&e.heightUnit!==t)return new be({heightModel:e.heightModel,heightUnit:t,vertCRS:e.vertCRS,associatedSpatialReference:e.associatedSpatialReference});if(!e.associatedSpatialReference){let t=e.clone();return t.associatedSpatialReference=this.spatialReference,t}return e}get alphaCompositingEnabled(){return this._get(`alphaCompositingEnabled`)}set alphaCompositingEnabled(e){this._stage&&l.getLogger(this).warn(`alphaCompositingEnabled cannot be changed after the view has become ready`),this._set(`alphaCompositingEnabled`,e)}get updating(){if(this.destroying||this.destroyed)return!1;if(!this.initialized)return!0;let e=0,t=this.layerViewManager.updating,n=t?this.layerViewManager.updatingRemaining:0;this.allLayerViews.forEach(r=>{if(!r.isFulfilled())++n;else if(r.updating){if(t=!0,r.suspended||pt(r))return;++n,e+=r.updatingProgress}});let r=.1;for(let t of this._updatingObjects)t?.updating&&(n+=r,e+=.5*r);for(let t of this._updatingObjectsWithProgress)t?.updating&&(++n,e+=t.updatingProgress);let i=!this.stateManager.test.updatingIgnoreRenderState&&this.state.updating;if(t=!!(t||n>0||this.updatingHandles.updating||!this.ready||!this.stationary||i||this._importControllers.size>0||this.inputManager?.updating||this.map?.allLayers?.some(e=>!e.isFulfilled())),t?(this._numUpdating=Math.max(n,this._numUpdating),e+=this._numUpdating-n):this._numUpdating=0,this._numUpdating>0?e/=this._numUpdating:e=+!t,this._get(`updatingProgress`)!==e){let n=performance.now();if(e<1){let t=Math.min((n-this._lastUpdateTime)/2e3,1);e=this.updatingProgress*(1-t)+e*t}this._set(`updatingProgress`,e),this._lastUpdateTime=t&&e<1?n:0}return L.UPDATING&&console.log(`Updating:`,this._updatingObjectsToDebug.filter(e=>e!=null&&e.updating).map(({declaredClass:e})=>e)),t}get _updatingObjects(){return[this.graphicsView,this.basemapView,this._resourceController,this.stage,this.featureTiles,this.pointsOfInterest,this.environmentView,this.overlay,this._featureTreeDebugger,this.toolViewManager,this.analysisViewManager,this.focusAreasView]}get _updatingObjectsWithProgress(){return[this.deconflictor,this.labeler,this.basemapTerrain]}get _updatingObjectsToDebug(){return L.UPDATING?this._updatingObjects.concat(this._updatingObjectsWithProgress).concat(this.allLayerViews.toArray()):[]}get viewingMode(){let e=this._predeterminedViewingMode;if(e!=null)return j(e);let t=this.spatialReference;return t?this.defaultsFromMap?.viewingMode!=null&&t.equals(this.defaultsFromMap.spatialReference)?j(this.defaultsFromMap.viewingMode):Et(t,1)?`global`:`local`:`global`}set viewingMode(e){this.ready?l.getLogger(this).error(`#viewingMode`,`viewingMode cannot be set once view is ready`):this._overrideIfSome(`viewingMode`,e)}get viewpoint(){return this.stateManager?.viewpoint}set viewpoint(e){this.stateManager&&(this.stateManager.viewpoint=e)}get visibleArea(){return this.stateManager?.visibleArea}get zoom(){return this.stateManager.zoom}set zoom(e){this.stateManager&&(this.stateManager.zoom=e)}get resourceController(){return this._resourceController}get quality(){return this._resourceController?.memoryController?.memoryFactor??1}get resolutionScale(){return Math.sqrt(Math.min(1,this.quality/.75))}get performanceInfo(){return new ut(this)}on(e,t,n,r){return this.viewEvents.on(e,t,n,r)||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}toMap(e,t){if(!this.ready)return l.getLogger(this).error(`#toMap()`,`Scene view cannot be used before it is ready`),null;let n=G(e)?K(this,e):e;return it(this,n,t,this._defaultToMapOptions)}toScreen(e){if(!this.ready)return l.getLogger(this).error(`#toScreen()`,`Scene view cannot be used before it is ready`),null;let t=e;return e.z??(t=Ft,t.x=e.x,t.y=e.y,t.z=nt(this.elevationProvider,e)??0,t.spatialReference=e.spatialReference),T(t,Z,this.renderSpatialReference),this.state.camera.projectToScreen(Z,Q),ce(Q[0],Q[1])}pixelSizeAt(e,t){if(!this.ready)return l.getLogger(this).error(`#pixelSizeAt()`,`Scene view cannot be used before it is ready`),null;if(!e)return 0;let n=this.renderSpatialReference;T(e,Z,n);let r=this.state.camera.computeScreenPixelSizeAt(Z);return t&&n!==t?r*fe(n)/fe(t):r}overlayPixelSizeInMapUnits(e){return this.overlayManager?.overlayPixelSizeInMapUnits(e,()=>this.pixelSizeAt(e))??1}hitTest(e,t){if(!this.ready)return l.getLogger(this).error(`#hitTest()`,`Scene view cannot be used before it is ready`),null;let n=G(e)?K(this,e):e;return at(this,n,t,this._defaultHitTestOptions)}async popupHitTest(e){return ot(this,e)}goTo(e,t){return this.updatingHandles.addPromise(this.stateManager.goTo(e,t))}async zoomIn(){if(this.canZoomIn)return this.navigation.zoom(!0)}async zoomOut(){if(this.canZoomOut)return this.navigation.zoom(!1)}async whenAnalysisView(e){if(e.parent==null)throw new a(`view:no-analysisview-for-analysis`,`The analysis does not exist in view.analyses`,{analysis:e});switch(e.parent.type){case`line-of-sight`:case`dimension`:case`viewshed`:return(await this.whenLayerView(e.parent)).whenAnalysisView();default:return this.analysisViewManager.whenAnalysisView(e)}}whenLayerView(e){return super.whenLayerView(e)}async takeScreenshot(e){let t=await this._completeSettings(e);await this.whenReady();let n=(await this.stage.renderView.takeScreenshot(t))[0];return(await import(`./support/screenshotUtils.js`)).encode(n,t,this._pixelFormat())}async _takeScreenshot(e){let t=await this._completeSettings(e);await this.whenReady();let n=(await this.stage.renderView.takeScreenshot(t))[0];return(await import(`./support/screenshotUtils.js`)).encodeData(n,this._pixelFormat())}async _takeScreenshotWithObjectAndLayerId(e){let t=await this._completeSettings(e);t.olidColor=!0,await this.whenReady();let n=await this.stage.renderView.takeScreenshot(t),{encodeData:r}=await import(`./support/screenshotUtils.js`);return[r(n[0],this._pixelFormat()),r(n[1],this._pixelFormat())]}async _completeSettings(e){let{toRenderSettings:t,screenshotSuperSampleSettings:n}=await import(`./support/screenshotUtils.js`),r=t(e,this);return r.pixelRatio/=this.state.pixelRatio,n(r,this.supersampleScreenshotsEnabled,this.padding)}_pixelFormat(){return{flipY:!0,premultipliedAlpha:this.stage?.renderView.getAlpha()??!1}}get test(){}async takeScreenshotWithObjectAndLayerId(e){if(!yt())throw new a(`360vr:objectAndLayerId-rendering-disabled`,`has enable-feature:objectAndLayerId-rendering must be true`);let{encode:t}=await import(`./support/screenshotUtils.js`),n=await this._completeSettings(e);n.olidColor=!0,await this.whenReady();let r=await this.stage.renderView.takeScreenshot(n),i=t(r[0],n,this._pixelFormat()),o=await this._completeSettings(e);return o.format=`png`,[i,t(r[1],o,this._pixelFormat())]}getColorToObjectAndLayerIdMapping(){let e=this.stage.renderView.olidRenderHelper;if(e)return e.getColorToObjectAndLayerIdMapping();throw new a(`360vr:objectAndLayerId-rendering-disabled`,`has enable-feature:objectAndLayerId-rendering must be true`)}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}getAttributionItems(){return super.getAttributionItems().concat(this.attribution3D.attributionItems)}importLayerView(e){return N.importLayerView(e)}hasLayerViewModule(e){return N.hasLayerViewModule(e)}forceDOMReadyCycle(){this.forceReadyCycle()}getWebDocumentSpatialReference(){return this.scene?.initialViewProperties?.spatialReference}getDefaultTimeZone(){return this.scene?.initialViewProperties?.timeZone??null}getSurface(){return this.surface}get _predeterminedViewingMode(){let e=this._isOverridden(`viewingMode`)?this._get(`viewingMode`):this.scene?.initialViewProperties?.viewingMode;return e==null?null:M(e)}getSpatialReferenceSupport(e,t){let n=this._predeterminedViewingMode,r=r=>this._validateSpatialReferenceForViewingMode(e,t,r)?this._makeSpatialReferenceConstraints(e,t,r,n):null,i=n?r(n):[...r(1)??[],...r(2)??[]];return i?.length?{constraints:i}:null}_validateSpatialReferenceForViewingMode(e,t,n){return Et(e,n)?t==null||E(t)?!0:!(D(t)&&mt(t,e,n)==null||O(t)&&n===1):!1}_makeSpatialReferenceConstraints(e,t,n,r){if(t==null)return[{spatialReference:e,viewingMode:n}];let{isWebMercator:i,isWGS84:a,vcsWkid:o,latestVcsWkid:s}=e,c=()=>o==null?i?w.WGS84:w.WebMercator:new w({...i?Oe:ke,vcsWkid:o,latestVcsWkid:s});return E(t)&&(i||a)?!(a&&r!==2)||ht(t.tileInfo,t.fullExtent,e,1)===null?[{spatialReference:e,viewingMode:n},{spatialReference:c(),viewingMode:n}]:[{spatialReference:c(),viewingMode:n}]:!D(t)&&!O(t)&&(i||a)?[{spatialReference:e,viewingMode:n},{spatialReference:c(),viewingMode:n}]:D(t)&&i&&n!==1?[{spatialReference:e,viewingMode:n},{spatialReference:c(),viewingMode:2}]:[{spatialReference:e,viewingMode:n}]}_validateSpatialReference(e){let t=this.getSpatialReferenceSupport(e)!=null,n=this._predeterminedViewingMode;return t||(n==null?e.isGeographic&&l.getLogger(this).warnOnce(`Spatial reference is geographic but not supported.`):l.getLogger(this).warnOnce(`Spatial reference defined on view not supported in ${j(n)} viewing mode.`)),t}whenReady(){return new Promise(e=>{this.ready?e(this):this._resolveWhenReady.push(e)})}trackGraphicState(e){if(!e.graphic)return l.getLogger(this).error(`trackGraphicState`,`GraphicState.graphic must not be null or undefined to start tracking`),null;let t=this.getViewForGraphic(e.graphic),n=null,r=!1,i=t=>{!r&&t!=null&&`processor`in t&&t.processor?.type===`graphics-3d`&&t.processor.graphicsCore&&(n=t.processor.graphicsCore.trackGraphicState(e))};return t==null?this.whenViewForGraphic(e.graphic,{waitForLayer:!0}).then(e=>i(e),()=>{}).catch(()=>{}):i(t),c(()=>{r=!0,n!=null&&(n.remove(),n=null)})}maskOccludee(e){if(!e)return l.getLogger(this).error(`maskOccludee`,`GraphicState.graphic must not be null or undefined to mask an occludee`),null;let t=this.getViewForGraphic(e),n=null,r=!1,i=t=>{!r&&t!=null&&Tt(t)&&(n=t.maskOccludee(e))};return t==null?this.whenViewForGraphic(e,{waitForLayer:!0}).then(e=>i(e),()=>{}).catch(()=>{}):i(t),c(()=>{r=!0,n!=null&&(n.remove(),n=null)})}getViewForGraphic(e){return e.layer===this?this.graphicsView:e.layer?this.allLayerViews.filter(e=>e.type!==`media-3d`).find(t=>t.layer===e.layer):null}graphicChanged(e){this.graphicsView!=null&&this.graphicsView.graphicChanged(e)}async whenViewForGraphic(e,t){return e.layer===this?(await ae(()=>this.graphicsView),this.graphicsView):!e.layer||!this.map?null:!t||!t.waitForLayer||this.map.allLayers.includes(e.layer)?this.whenLayerView(e.layer):new Promise((t,n)=>{let r=this.map.allLayers.on(`change`,i=>{i.added.includes(e.layer)&&(r.remove(),this.whenLayerView(e.layer).then(t,n))})})}enableFeatureTiles(){let e=Symbol();return this._featureTileTreeClients.add(e),c(()=>this._featureTileTreeClients.delete(e))}async _importModule(e,t){let n=new AbortController;this._importControllers.set(e,n),this._updatingChanged();try{let r=await It[e]();if(t&&(ne(this),d(n.signal),await t(n.signal)),this.destroyed)throw re();return d(n.signal),r}catch{return null}finally{this._importControllers.delete(e),this._updatingChanged()}}_abortImport(e){this._importControllers.get(e)?.abort(),this._importControllers.delete(e),this._updatingChanged()}_initBasemapTerrain(){this._set(`basemapTerrain`,new V({view:this})),this.elevationProvider.register(0,this.basemapTerrain)}_exitBasemapTerrain(){let{basemapTerrain:e,elevationProvider:t}=this;e&&(this._set(`basemapTerrain`,null),t.unregister(e),e.destroy())}_initGlobe(){this._initCoordinateSystem(),this.state.createInitialCamera(),this._initBasemapTerrain(),this._set(`pointsOfInterest`,new B({view:this})),this.addHandles([this.updatingHandles.add(()=>L.FEATURE_TILE_TREE_SHOW_TILES,e=>{e&&!this._featureTreeDebugger?this.updatingHandles.addPromise(import(`./3d/layers/support/FeatureTileTree3DDebugger.js`)).then(({FeatureTileTree3DDebugger:e})=>{!this._featureTreeDebugger&&L.FEATURE_TILE_TREE_SHOW_TILES&&(this._featureTreeDebugger=new e({view:this}))}):e||(this._featureTreeDebugger=u(this._featureTreeDebugger))},g),this.updatingHandles.add(()=>({basemapExtent:this.groundView?.groundExtent,basemapSpatialReference:this.groundView?.spatialReference,clippingArea:this.clippingArea,featureTiles:this._featureTiles}),({basemapExtent:e,basemapSpatialReference:t,clippingArea:n,featureTiles:r})=>{if(!r)return;let i=!!e;if(!n&&!i)r.filterExtent=null;else if(!i||!t)r.filterExtent=n;else{let i=e&&t?C(we(e,t),this.spatialReference):null;r.filterExtent=n?n.intersection(i):i}},g),this.updatingHandles.add(()=>this._featureTileTreeClients.size>0,e=>{e?this.updatingHandles.consumePromise(this._ensureFeatureTileTree()):this._featureTiles=u(this._featureTiles)},h)],Nt),this.stateManager.init()}async _ensureFeatureTileTree(){if(this._featureTiles||this._importControllers.has(`FeatureTileTree3D`))return;let e=(await this.updatingHandles.addPromise(this._importModule(`FeatureTileTree3D`)))?.FeatureTileTree3D;e&&(this._featureTiles=new e({renderCoordsHelper:this.renderCoordsHelper,pointsOfInterest:this.pointsOfInterest,viewState:this.state,scheduler:this._resourceController.scheduler,terrain:this.basemapTerrain}),this._updatingChanged())}_exitTerrain(){this.stateManager.exit(),this.removeHandles(J),this.removeHandles(Nt),this._featureTiles=u(this.featureTiles),this._set(`pointsOfInterest`,u(this.pointsOfInterest)),this._exitBasemapTerrain(),this.state.reset(),this._exitCoordinateSystem()}_initCoordinateSystem(){if(this.spatialReference){let e=this.spatialReference,t=this.state.isGlobal,n=Ee(t,e);n!==this.renderSpatialReference&&(this._set(`renderCoordsHelper`,ct.create(this.state.viewingMode,n)),t||this.addHandles(p(()=>this.groundView?.groundExtent,e=>{let t=this.renderCoordsHelper.spatialReference;e!=null&&(e[0]!==0||e[1]!==0||e[2]!==0||e[3]!==0)&&Ce(e,this.groundView.spatialReference,$,t)&&(this.renderCoordsHelper.extent=$)},h),J),this.sceneIntersectionHelper&&this.sceneIntersectionHelper.setTolerance(H/this.renderCoordsHelper.unitInMeters))}else this._set(`renderCoordsHelper`,null)}_exitCoordinateSystem(){this.removeHandles(J),this._set(`renderCoordsHelper`,null)}_updatingChanged(){this.notifyChange(`updating`)}_updateUpdatingMonitors(e=null){(e==null||e.type!==4)&&(this.removeHandles(`updatingMonitors`),this.allLayerViews.forEach(e=>{e.destroyed||(this.addHandles(p(()=>[e.updating,e.updatingProgress],()=>this._updatingChanged(),h),`updatingMonitors`),e.when(()=>this._updatingChanged(),()=>this._updatingChanged()))}),this._updatingChanged())}async _prepareScreenshotOverlay(){this.overlay&&await this.overlay.prepare()}_renderScreenshotOverlay(e,t,n){if(!this.overlay||!this.overlay.hasVisibleItems)return n;let r=e.getContext(`2d`,{willReadFrequently:!0});return r.putImageData(n,0,0),this.overlay.renderCanvas(e,{disableDecorations:t}),r.getImageData(0,0,n.width,n.height)}_initStage(){let e={deactivatedWebGLExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions,alpha:this.alphaCompositingEnabled,preserveDrawingBuffer:this.preserveDrawingBufferEnabled,canvas:this.renderCanvas,screenshot:{prepareOverlay:()=>this._prepareScreenshotOverlay(),renderOverlay:(e,t,n)=>this._renderScreenshotOverlay(e,t,n)}},t=new Qe(this.state.viewingMode,e=>this.stage.layers.forEach(e),this);this._set(`sceneIntersectionHelper`,t);let n=i(this.surface);this._stage=new vt({view:this,options:e,container:n}),this.notifyChange(`stage`),this._updateSlice(),this.addHandles([this.on(`pointer-move`,()=>this.stage?.renderer.resetAnimation()),o(this.stage.renderView.canvas,`webglcontextlost`,e=>{this.fatalError=new a(`webgl-context-lost`,e.statusMessage||`WebGL context lost`)})],`stage`),this.renderCoordsHelper&&this.sceneIntersectionHelper.setTolerance(H/this.renderCoordsHelper.unitInMeters),this._set(`canvas`,this.stage.renderView.canvas)}_exitStage(){this.sceneIntersectionHelper?.destroy(),this._set(`sceneIntersectionHelper`,null),this._stage=u(this.stage),this._set(`stage`,null),this.removeHandles(`stage`),this._set(`canvas`,null)}_initSurface(){this._exitSurface(),this._initStage(),this._initGlobe(),this.sharedSymbolResources=new dt({view:this,resourceController:this._resourceController})}_exitSurface(){this.sharedSymbolResources&&(this.sharedSymbolResources.objectResourceCache.destroy(),this.sharedSymbolResources.destroy(),this.sharedSymbolResources=null,this._exitTerrain(),this._exitStage())}async _ensureGraphicsView(){if(this.graphicsView||this._importControllers.has(`GraphicsView3D`)||this.graphics.length===0)return;this.removeHandles(`GraphicsView3D`);let e=(await this.updatingHandles.addPromise(this._importModule(`GraphicsView3D`,e=>ae(()=>this.groundView?.ready,e))))?.default;e&&this._set(`graphicsView`,new e({view:this,getGraphics:()=>this.graphics})),this._updatingChanged()}_disposeGraphicsView(){this._abortImport(`GraphicsView3D`),this.removeHandles(`GraphicsView3D`),this.graphicsView&&(this.removeHandles(this.graphicsView.processor.layer.id),this.graphicsView.destroy(),this._set(`graphicsView`,null))}_disposeFocusAreasView(){this._abortImport(`FocusAreasView`),this.removeHandles(`FocusAreasView`),this.focusAreasView=u(this.focusAreasView)}async _ensureFocusAreasView(e){if(this.focusAreasView||this._importControllers.has(`FocusAreasView`)||e===0)return;this.removeHandles(`FocusAreasView`);let t=(await this.updatingHandles.addPromise(this._importModule(`FocusAreasView`)))?.FocusAreasView;t&&(this.focusAreasView=new t({view:this})),this._updatingChanged()}_startup(){M(this.viewingMode)===1&&(this._clippingArea=null),this._initSurface(),this._set(`ready`,!0),this.addHandles(f(()=>this.graphics,`after-changes`,()=>this._ensureGraphicsView()),`GraphicsView3D`),this._ensureGraphicsView(),this.addHandles(this.updatingHandles.add(()=>this.map?.focusAreas?.areas.length??0,e=>this._ensureFocusAreasView(e),{initial:!0}),`FocusAreasView`);let e=this.scene?.initialViewProperties??null,t=e?.environment;t&&(this._overrideDefaultEnvironmentOnly?me(this.environment,t):this.environment=this.environment.cloneWithWebsceneEnvironment(t)),this.timeExtent=e?.timeExtent,e?.analyses.applyTo(this),this.labeler.setup(),this.environmentView.connectView(this),this.inputManager.connect();let n=this._resolveWhenReady;this._resolveWhenReady=[],n.forEach(e=>e(this))}_teardown(){this.inputManager.disconnect(),this.environmentView.disconnectView(),this._overrideDefaultEnvironmentOnly=!1,this.labeler.dispose(),this._disposeGraphicsView(),this._disposeFocusAreasView(),this._exitSurface(),this._set(`ready`,!1)}get _defaultToMapOptions(){let e={include:new Set};if(!this.map)return e;this.map.ground&&e.include.add(U);for(let t of this.allLayerViews)(k(t.layer)&&(!has(`enable-feature:im-as-ground`)||t.layer.isUsedAsGroundLayer)||je(t.layer))&&e.include.add(t.uid);return e}get _defaultHitTestOptions(){let e={exclude:new Set};if(!this.map)return e;this.map.ground&&this.map.ground.opacity<1&&e.exclude.add(U);for(let t of this.allLayerViews)(has(`enable-feature:im-as-ground`)?k(t.layer)&&t.layer.isUsedAsGroundLayer:k(t.layer))&&t.fullOpacity<1&&e.exclude.add(t.uid);return e}static{this.type=`3d`}static clearStatics(){Mt(),ge(),ue(),St(),Xe(),Ve(),Se(),wt(),Ne(),_t(),xt(),Ze(),$e(),ve(),se(),bt(),gt(),Ke.cleanupI3SLodHandling(),Me.cleanupTilemapCache(),I.cleanupViewstate(),V.cleanupTerrainSurface()}};e([_({nonNullable:!0}),v(Pt)],Y.prototype,`options`,void 0),e([_()],Y.prototype,`_userClippingArea`,void 0),e([_()],Y.prototype,`_resourceController`,void 0),e([_()],Y.prototype,`stage`,null),e([_({readOnly:!0})],Y.prototype,`deconflictor`,void 0),e([_({readOnly:!0})],Y.prototype,`labeler`,void 0),e([_()],Y.prototype,`navigation`,void 0),e([_({type:Re,readOnly:!0})],Y.prototype,`animation`,null),e([_({readOnly:!0})],Y.prototype,`basemapTerrain`,void 0),e([_({readOnly:!0})],Y.prototype,`overlayManager`,null),e([_({readOnly:!0})],Y.prototype,`elevationProvider`,void 0),e([_()],Y.prototype,`camera`,null),e([_({type:t})],Y.prototype,`contentCamera`,null),e([_({readOnly:!0})],Y.prototype,`canvas`,null),e([_({type:S,useTypeForAutocast:!1})],Y.prototype,`center`,null),e([_({type:x})],Y.prototype,`clippingArea`,null),e([_({type:P,nonNullable:!0})],Y.prototype,`constraints`,void 0),e([_({type:x,readOnly:!0})],Y.prototype,`renderDataExtent`,null),e([_({readOnly:!0})],Y.prototype,`tileInfo`,null),e([_({type:x,readOnly:!0})],Y.prototype,`dataExtent`,null),e([_({type:x,readOnly:!0})],Y.prototype,`_groundAndLayersExtent`,null),e([_({type:F})],Y.prototype,`environment`,null),e([v(`environment`)],Y.prototype,`castEnvironment`,null),e([_({readOnly:!0})],Y.prototype,`environmentView`,void 0),e([_({type:x})],Y.prototype,`extent`,null),e([_({type:r})],Y.prototype,`floors`,void 0),e([_()],Y.prototype,`screenCenter`,null),e([_()],Y.prototype,`frustum`,null),e([_({type:Number,readOnly:!0})],Y.prototype,`fullOpacity`,void 0),e([_({readOnly:!0})],Y.prototype,`graphicsView`,void 0),e([_()],Y.prototype,`analysisViewManager`,void 0),e([_()],Y.prototype,`groundView`,void 0),e([_({readOnly:!0})],Y.prototype,`layerviewCollections`,null),e([_({type:Boolean})],Y.prototype,`initialExtentRequired`,null),e([_()],Y.prototype,`defaultsFromMapSettings`,null),e([_()],Y.prototype,`interacting`,null),e([_()],Y.prototype,`stationary`,null),e([_()],Y.prototype,`navigating`,null),e([_()],Y.prototype,`map`,void 0),e([_()],Y.prototype,`padding`,null),e([_({type:B,readOnly:!0})],Y.prototype,`pointsOfInterest`,void 0),e([_()],Y.prototype,`_featureTiles`,void 0),e([_()],Y.prototype,`featureTiles`,null),e([_()],Y.prototype,`_featureTreeDebugger`,void 0),e([_({constructOnly:!0})],Y.prototype,`deactivatedWebGLExtensions`,void 0),e([_({constructOnly:!0})],Y.prototype,`debugWebGLExtensions`,void 0),e([_({constructOnly:!0})],Y.prototype,`renderCanvas`,void 0),e([_({constructOnly:!0})],Y.prototype,`state`,void 0),e([_()],Y.prototype,`screenSizePerspective`,void 0),e([_({readOnly:!0})],Y.prototype,`inputManager`,void 0),e([_({readOnly:!0})],Y.prototype,`stateManager`,void 0),e([_({type:[`low`,`medium`,`high`]})],Y.prototype,`qualityProfile`,null),e([_({type:z,get(){let e=this._get(`qualitySettings`);if(!e){let t=R(this.qualityProfile);e=new z(t)}return e}})],Y.prototype,`qualitySettings`,void 0),e([_()],Y.prototype,`slice`,void 0),e([_({readOnly:!0})],Y.prototype,`typeSpecificPreconditionsReady`,null),e([_({readOnly:!0})],Y.prototype,`renderCoordsHelper`,void 0),e([_({readOnly:!0})],Y.prototype,`sceneIntersectionHelper`,void 0),e([_({type:Number,readOnly:!0})],Y.prototype,`resolution`,null),e([_({type:Number})],Y.prototype,`scale`,null),e([_({readOnly:!0,type:Number})],Y.prototype,`terrainLevel`,null),e([_()],Y.prototype,`heightModelInfo`,null),e([_({type:w})],Y.prototype,`spatialReference`,void 0),e([_({type:Boolean,value:!1})],Y.prototype,`alphaCompositingEnabled`,null),e([_({constructOnly:!0})],Y.prototype,`preserveDrawingBufferEnabled`,void 0),e([_({type:Boolean})],Y.prototype,`supersampleScreenshotsEnabled`,void 0),e([_({readOnly:!0})],Y.prototype,`type`,void 0),e([_(),v(e=>e instanceof kt?e:b(At,e))],Y.prototype,`ui`,void 0),e([_({type:Boolean,readOnly:!0})],Y.prototype,`updating`,null),e([_()],Y.prototype,`_updatingObjects`,null),e([_()],Y.prototype,`_updatingObjectsWithProgress`,null),e([_()],Y.prototype,`_updatingObjectsToDebug`,null),e([_({type:Number,readOnly:!0})],Y.prototype,`updatingProgress`,void 0),e([_({type:[`global`,`local`]})],Y.prototype,`viewingMode`,null),e([_({type:n})],Y.prototype,`viewpoint`,null),e([_({readOnly:!0})],Y.prototype,`visibleArea`,null),e([_({type:Number})],Y.prototype,`zoom`,null),e([_({readOnly:!0})],Y.prototype,`quality`,null),e([_({readOnly:!0})],Y.prototype,`resolutionScale`,null),e([_()],Y.prototype,`focusAreasView`,void 0),e([_()],Y.prototype,`_defaultToMapOptions`,null),e([_()],Y.prototype,`_defaultHitTestOptions`,null),Y=q=e([pe(`esri.views.SceneView`)],Y);function X(e,t){return e!=null&&xe(e.spatialReference,t)?C(e,t):null}const Z=_e(),Q=le(),$=Te(),Ft=Ae(0,0,0,w.WebMercator),It={GraphicsView3D:()=>import(`./3d/layers/GraphicsView3D.js`),FocusAreasView:()=>import(`./3d/FocusAreasView.js`),FeatureTileTree3D:()=>import(`./3d/layers/support/FeatureTileTree3D.js`)},Lt=Y;export{Lt as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../Camera.js";import n from"../Viewpoint.js";import r from"../core/Collection.js";import{byId as i}from"../core/domUtils.js";import a from"../core/Error.js";import{on as o}from"../core/events.js";import{destroyHandle as s,makeHandle as c}from"../core/handleUtils.js";import has from"../core/has.js";import l from"../core/Logger.js";import{mapCollectionAsync as ee}from"../core/mapCollectionUtils.js";import{destroyMaybe as u,maybeProperty as te}from"../core/maybe.js";import{throwIfDestroyed as ne,throwIfAborted as d,createAbortError as re}from"../core/promiseUtils.js";import ie from"../core/ReactiveSet.js";import{on as f,watch as p,initial as m,sync as h,whenOnce as ae,syncAndInitial as g}from"../core/reactiveUtils.js";import{setFrameDuration as oe,cleanupScheduling as se}from"../core/scheduling.js";import{createScreenPoint as ce,createScreenPointArray as le}from"../core/screenUtils.js";import{cleanupWhereClauseCache as ue}from"../core/sql.js";import{getDefaultVerticalUnitStringForSR as de,getMetersPerUnitForSR as fe}from"../core/units.js";import{property as _,cast as v,subclass as pe}from"../core/accessorSupport/decorators.js";import{ensureType as y,ensureClass as b}from"../core/accessorSupport/ensureType.js";import{overrideDefaultsFrom as me}from"../core/accessorSupport/overrideDefaultsFrom.js";import{runUntracked as he}from"../core/accessorSupport/tracking.js";import{drainNotificationQueue as ge}from"../core/accessorSupport/trackingUtils.js";import{create as _e}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{cleanupPooledRBush as ve}from"../core/libs/rbush/PooledRBush.js";import{initialize as ye}from"../core/workers/workers.js";import x from"../geometry/Extent.js";import be from"../geometry/HeightModelInfo.js";import S from"../geometry/Point.js";import{project as C,canProjectWithoutEngine as xe}from"../geometry/projectionUtils.js";import w from"../geometry/SpatialReference.js";import{cleanupSpatialReferenceEllipsoidUtils as Se}from"../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingRect as Ce}from"../geometry/projection/projectBoundingRect.js";import{projectPointToVector as T}from"../geometry/projection/projectPointToVector.js";import{toExtent as we,create as Te}from"../geometry/support/aaBoundingRect.js";import{renderSRFromViewSR as Ee}from"../geometry/support/coordinateSystem.js";import{getResolutionForScale as De}from"../geometry/support/scaleUtils.js";import{wgs84 as Oe,webMercator as ke}from"../geometry/support/spatialReferenceUtils.js";import{makeDehydratedPoint as Ae}from"../layers/graphics/dehydratedPoint.js";import{isImageryTileLayer as E,isTiledLayer as D,isVoxelLayer as O,isIntegratedMeshLayer as k,isGaussianSplatLayer as je}from"../layers/support/layerUtils.js";import{TilemapCache as Me}from"../layers/support/TilemapCache.js";import{clearDefaultPortalInstance as Ne}from"../portal/portalDefault.js";import{WebSceneTag as Pe}from"../support/tagSymbols.js";import{BreakpointsOwner as Fe}from"./BreakpointsOwner.js";import{DOMContainer as Ie}from"./DOMContainer.js";import{PopupView as Le}from"./PopupView.js";import A from"./View.js";import Re from"./ViewAnimation.js";import{stringFromViewingMode as j,viewingModeFromString as M}from"./ViewingMode.js";import{GroundView3D as ze}from"./3d/GroundView3D.js";import{layerView3DImporter as N}from"./3d/layerViewModuleImportUtils.js";import{importAnalysisViewModule as Be}from"./3d/analysis/analysisViewModuleImportUtils.js";import{cleanupIntersectionUtils as Ve}from"./3d/camera/intersectionUtils.js";import P from"./3d/constraints/Constraints.js";import F from"./3d/environment/Environment.js";import{EnvironmentView as He}from"./3d/environment/EnvironmentView.js";import Ue from"./3d/input/SceneInputManager.js";import{GraphicsDeconflictor as We}from"./3d/layers/graphics/GraphicsDeconflictor.js";import{Labeler as Ge}from"./3d/layers/graphics/Labeler.js";import Ke from"./3d/layers/i3s/I3SLodHandling.js";import{Navigation3D as qe}from"./3d/navigation/Navigation3D.js";import{ScreenSizePerspective as Je}from"./3d/state/ScreenSizePerspective.js";import I from"./3d/state/ViewState.js";import{ViewStateManager as Ye,cleanupViewStateManager as Xe}from"./3d/state/ViewStateManager.js";import{cleanupPointToPointAnimationController as Ze}from"./3d/state/controllers/PointToPointAnimationController.js";import{SceneIntersectionHelper as Qe}from"./3d/state/helpers/SceneIntersectionHelper.js";import{cleanupNavigationUtils as $e}from"./3d/state/utils/navigationUtils.js";import et from"./3d/support/Attribution3D.js";import{CombinedElevationProvider as tt}from"./3d/support/CombinedElevationProvider.js";import{debugFlags as L}from"./3d/support/debugFlags.js";import{getElevationAtPoint as nt}from"./3d/support/ElevationProvider.js";import{GroundAndIMSurface as rt}from"./3d/support/GroundAndIMSurface.js";import{toMap as it,hitTest as at}from"./3d/support/hitTest.js";import{popupHitTest as ot}from"./3d/support/popupHitTest.js";import{getDefaultQualityProfileName as st,getQualityProfileSettings as R}from"./3d/support/QualityProfile.js";import z from"./3d/support/QualitySettings.js";import{RenderCoordsHelper as ct}from"./3d/support/RenderCoordsHelper.js";import{newResourceController as lt}from"./3d/support/ResourceController.js";import ut from"./3d/support/SceneViewPerformanceInfo.js";import{SharedSymbolResources as dt}from"./3d/support/SharedSymbolResources.js";import{ViewSlice as ft}from"./3d/support/ViewSlice.js";import{PointsOfInterest as B}from"./3d/support/pointsOfInterest/PointsOfInterest.js";import V from"./3d/terrain/TerrainSurface.js";import{isSurfaceLayerView as pt,getTiledLayerInfo as mt,checkIfTileInfoSupportedForView as ht}from"./3d/terrain/terrainUtils.js";import{clearTilePerLayerInfo as gt}from"./3d/terrain/TilePerLayerInfo.js";import{cleanupTileRenderer as _t}from"./3d/terrain/TileRenderer.js";import{Stage as vt}from"./3d/webgl-engine/Stage.js";import{olidEnabled as yt}from"./3d/webgl-engine/effects/geometry/olidUtils.js";import{cleanupRenderOccluded as bt}from"./3d/webgl-engine/effects/geometry/RenderOccluded.js";import{defaultTolerance as H}from"./3d/webgl-engine/lib/Intersector.js";import{cleanupShadowmap as xt}from"./3d/webgl-engine/lib/ShadowMap.js";import{terrainId as U}from"./3d/webgl-engine/lib/verticalOffsetUtils.js";import{cleanupEdgeProcessing as St}from"./3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js";import W from"./interactive/options/ViewOptions.js";import Ct from"./support/AnalysisViewManager.js";import{cleanupDrapedUtils as wt}from"./support/drapedUtils.js";import{occludeesSupported as Tt}from"./support/layerViewUtils.js";import{isSupportedScreenPointEvent as G,createScreenPointFromSupportedEvent as K}from"./support/screenUtils.js";import{isSpatialReferenceSupported as Et}from"./support/spatialReferenceSupport.js";import{initializeTextureCompressionWorker as Dt,destroyTextureCompressionWorker as Ot}from"./support/TextureCompressionHelper.js";import kt from"./ui/DefaultUI.js";import At from"./ui/3d/DefaultUI3D.js";import jt from"../webscene/Environment.js";import{clearVNodeCache as Mt}from"../widgets/support/vnodeCache.js";var q;const Nt=Symbol(),J=Symbol();function Pt(e){let t=b(W,e);return t!==e&&e.snapping?.enabled==null&&(t.snapping.enabled=!0),t}let Y=class extends Fe(Le(Ie(A))){static{q=this}get timeZone(){return super.timeZone}set timeZone(e){super.timeZone=e}constructor(e){super(e),this.options=new W({snapping:{enabled:!0}}),this._userClippingArea=null,this._clippingArea=null,this._overrideDefaultEnvironmentOnly=!0,this._resolveWhenReady=[],this._resourceController=lt(this),this.deconflictor=new We({view:this}),this.attribution3D=new et({view:this}),this.labeler=new Ge({view:this,deconflictor:this.deconflictor.labels}),this.sharedSymbolResources=null,this.navigation=new qe({view:this}),this.basemapTerrain=null,this.elevationProvider=new tt({view:this}),this._canvas=null,this.constraints=new P,this._environment=new F,this.environmentView=new He,this.floors=new r,this.fullOpacity=1,this.graphicsView=null,this.analysisViewManager=new Ct({importAnalysisViewModule:e=>Be(e),view:this}),this.groundView=null,this.groundAndIMSurface=null,this.map=null,this._featureTileTreeClients=new ie,this._featureTiles=null,this._featureTreeDebugger=null,this.state=new I({view:this}),this.slice=new ft,this.spatialReference=null,this.preserveDrawingBufferEnabled=!1,this.supersampleScreenshotsEnabled=!0,this.type=`3d`,this.ui=new At,this._numUpdating=0,this._lastUpdateTime=0,this.updatingProgress=.5,this._importControllers=new Map,ye();let t=()=>this._updatingChanged();this.addHandles(s(ee(()=>this.map?.allLayers,async e=>{try{await e.when()}catch{}finally{t()}}))),this.addHandles([f(()=>this.map?.allLayers,`after-changes`,t,{onListenerAdd:t,onListenerRemove:t,sync:!0}),this.allLayerViews.on(`after-changes`,e=>this._updateUpdatingMonitors(e)),p(()=>this.scene,e=>e?.load().catch(()=>{}))]),this.inputManager=new Ue({view:this}),this.stateManager=new Ye({view:this}),this.screenSizePerspective=new Je({view:this})}initialize(){if(has(`enable-feature:esri-compress-textures`)&&has(`wasm-simd`)){let e=Dt(this,this.resourceController);this.addResolvingPromise(e.promise)}this.groundView=new ze({view:this}),this.groundAndIMSurface=new rt({view:this}),this._updateUpdatingMonitors(),this.updatingHandles.add(()=>this.qualitySettings.memoryLimit,e=>{this.resourceController&&(this.resourceController.memoryController.maxMemory=e)},m),this.updatingHandles.add(()=>this.qualitySettings.additionalCacheMemory,e=>{this.resourceController&&(this.resourceController.memoryController.additionalCacheMemory=e)},m),this.updatingHandles.add(()=>this.qualitySettings.frameRate??0,e=>oe(e>0?1e3/Math.ceil(e):0),m),this.addHandles([p(()=>this.spatialReference,()=>this.notifyChange(`clippingArea`),h),p(()=>({plane:this.slice.plane,isDecoration:this.slice.isDecoration}),()=>this._updateSlice(),h)])}destroy(){this.destroyed||(Ot(this),this.updatingHandles.removeAll(),this.basemapTerrain?.clearHandles(),this.elevationProvider.destroy(),this.ui.removeAllHandles(),this.layerViewManager.clearHandles(),this.invalidate(),this.layerViewManager.clear(),this._set(`analysisViewManager`,u(this.analysisViewManager)),this._exitSurface(),this._disposeGraphicsView(),this._disposeFocusAreasView(),this.sharedSymbolResources=u(this.sharedSymbolResources),this._set(`labeler`,u(this.labeler)),this._set(`deconflictor`,u(this.deconflictor)),this._resourceController=u(this._resourceController),this._set(`stateManager`,u(this.stateManager)),this._set(`inputManager`,u(this.inputManager)),this.state.destroy(),this.highlights.destroy(),this.removeHandles(`updatingMonitors`),this._set(`environmentView`,u(this.environmentView)),this._set(`environment`,u(this.environment)),this.groundView=u(this.groundView),this.groundAndIMSurface.destroy(),this.slice.destroy(),this._updatingObjectsWithProgress.length=0,this._updatingObjects.length=0,this.ui?.destroy(),this._set(`ui`,null),this._set(`renderCanvas`,null),this._set(`canvas`,null),this._canvas=null,this.screenSizePerspective.destroy(),this.attribution3D.destroy())}get stage(){return this._stage}get renderSpatialReference(){return this.renderCoordsHelper?.spatialReference}get groundSpatialReference(){return this.groundView?.spatialReference}get analyses(){return super.analyses}set analyses(e){super.analyses=e}get animation(){return this.state?.animation}get overlayManager(){return this.basemapTerrain?.overlayManager}get camera(){return this.stateManager?.camera}set camera(e){this.stateManager&&(this.stateManager.camera=e)}get contentCamera(){return this.stateManager?.contentCamera}set contentCamera(e){this.stateManager&&(this.stateManager.contentCamera=e)}installContentCameraReset(e={sticky:!1}){return this.stateManager.installContentCameraReset(e)}get canvas(){return this._canvas}get center(){return this.stateManager?.center}set center(e){this.stateManager&&(this.stateManager.center=y(S,e))}get clippingArea(){if(this.viewingMode===`global`)return null;let e=this.map,t=this._userClippingArea||te(e,`clippingArea`);return!(this._userClippingArea||te(e,`clippingEnabled`))||t==null?(this._clippingArea=null,null):t instanceof x?this.spatialReference&&(t=X(t,this.spatialReference),t==null)?(l.getLogger(this).error(`#clippingArea`,`setting clippingArea with incompatible SpatialReference`),this._clippingArea):(t=t.clone(),t.intersection(this._groundAndLayersExtent)??(t.xmin=t.xmax,t.ymin=t.ymax),t.zmin=void 0,t.zmax=void 0,t.equals(this._clippingArea)||(this._clippingArea=t),this._clippingArea):(l.getLogger(this).error(`#clippingArea`,`only clippingArea geometries of type Extent are supported`),this._clippingArea)}set clippingArea(e){this.ready&&this.viewingMode===`global`&&e!=null?l.getLogger(this).error(`#clippingArea=`,`Clipping area is only supported in local viewingMode`):this._userClippingArea=e}get renderDataExtent(){if(this.state.viewingMode===1)return null;let e=this.renderSpatialReference,t=this.dataExtent;return t==null||e==null||t.spatialReference.equals(e)?t:X(t,e)}get tileInfo(){return this.basemapTerrain?.tilingScheme?.toTileInfo()}get dataExtent(){let e=this._groundAndLayersExtent,t=this.spatialReference||w.WGS84,n=X(this.clippingArea,t);n!=null&&(e=e==null?n:e.intersection(n));let r=this._get(`dataExtent`);return e!=null&&e.equals(r)?r:e}get _groundAndLayersExtent(){let e=this.spatialReference||w.WGS84,t,n=n=>{let r=X(n,e);r!=null&&(t==null?t=r.clone():t.union(r))},{groundView:r}=this,i=r?.spatialReference,a=r?.fullGroundExtent;i&&a&&n(new x({xmin:a[0],ymin:a[1],zmin:0,xmax:a[2],ymax:a[3],zmax:0,spatialReference:i}));let o=e=>{e.fullExtent==null||e.type===`graphics`&&e.internal||n(e.fullExtent)};if(this.map?.allLayers.forEach(e=>o(e)),t==null)return null;t.hasZ?(t.zmin=Math.min(0,t.zmin??0),t.zmax=Math.max(0,t.zmax??0)):(t.zmin=0,t.zmax=0);let s=this._get(`_groundAndLayersExtent`);return t.equals(s)?s:t}get environment(){return this._environment}set environment(e){if(this._environment===e)return;let{_environment:t}=this;this._environment=null,t?.destroy(),this._environment=e,this.notifyChange(`environment`)}castEnvironment(e){return e?e instanceof F?e:e instanceof jt?this.environment?.cloneWithWebsceneEnvironment(e)??F.fromWebsceneEnvironment(e):y(F,e):new F}get extent(){return this.stateManager?.extent}set extent(e){this.stateManager&&(this.stateManager.extent=e)}get screenCenter(){return this.stateManager?.screenCenter}get frustum(){return this.stateManager?.frustum}get layerviewCollections(){return[this.basemapView?.baseLayerViews,this.basemapView?.groundLayerViews,this.groundView?.layerViews,this.layerViews,this.basemapView?.referenceLayerViews]}get _layerToLayerviewMapping(){return q._layerToLayerview}static{this._layerToLayerview=A._layerToLayerview.concat([[`view.map.ground.layers`,`view.groundView.layerViews`]])}get initialExtentRequired(){return this.stateManager&&!this.stateManager.hasInitialView}get defaultsFromMapSettings(){return{required:{tileInfo:!1,heightModelInfo:!0,extent:!1}}}get interacting(){return this.navigating||(this.toolViewManager?.interacting??!1)}get stationary(){return!this.animation&&!this.resizing&&(this.state?.stationary??!0)}get navigating(){return this.state?.navigating??!1}get scene(){return this.map&&Pe in this.map?this.map:null}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}get featureTiles(){return this._featureTiles}set qualityProfile(e){let t=R(e);t&&this._get(`qualityProfile`)!==e&&(this.qualitySettings=new z(t),this.stage?.renderView.updateQualitySettings(this.qualitySettings),this._set(`qualityProfile`,e))}get qualityProfile(){return this._get(`qualityProfile`)||st()}_updateSlice(){this.stage!=null&&(this.stage.renderer.slice=this.slice)}get typeSpecificPreconditionsReady(){return this.viewingMode?!!this.stateManager?.preinit(this.spatialReference):!1}get resolution(){let{scale:e,spatialReference:t}=this;return t?he(()=>De(e,t)):0}get scale(){return this.stateManager?.scale}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get terrainLevel(){let e=this.basemapTerrain?.tilingScheme,t=this.scale;if(!e||!t)return null;let n=e.levelAtScale(t)+this.qualitySettings.tiledSurface.lodBias,r=e.getMaxLod();return n<=0?null:Math.max(0,Math.min(n,r||1/0))}get heightModelInfo(){let e=this.getDefaultHeightModelInfo();if(!e)return null;let t=de(this.spatialReference);if(t&&e.heightUnit!==t)return new be({heightModel:e.heightModel,heightUnit:t,vertCRS:e.vertCRS,associatedSpatialReference:e.associatedSpatialReference});if(!e.associatedSpatialReference){let t=e.clone();return t.associatedSpatialReference=this.spatialReference,t}return e}get alphaCompositingEnabled(){return this._get(`alphaCompositingEnabled`)}set alphaCompositingEnabled(e){this._stage&&l.getLogger(this).warn(`alphaCompositingEnabled cannot be changed after the view has become ready`),this._set(`alphaCompositingEnabled`,e)}get updating(){if(this.destroying||this.destroyed)return!1;if(!this.initialized)return!0;let e=0,t=this.layerViewManager.updating,n=t?this.layerViewManager.updatingRemaining:0;this.allLayerViews.forEach(r=>{if(!r.isFulfilled())++n;else if(r.updating){if(t=!0,r.suspended||pt(r))return;++n,e+=r.updatingProgress}});let r=.1;for(let t of this._updatingObjects)t?.updating&&(n+=r,e+=.5*r);for(let t of this._updatingObjectsWithProgress)t?.updating&&(++n,e+=t.updatingProgress);let i=!this.stateManager.test.updatingIgnoreRenderState&&this.state.updating;if(t=!!(t||n>0||this.updatingHandles.updating||!this.ready||!this.stationary||i||this._importControllers.size>0||this.inputManager?.updating||this.map?.allLayers?.some(e=>!e.isFulfilled())),t?(this._numUpdating=Math.max(n,this._numUpdating),e+=this._numUpdating-n):this._numUpdating=0,this._numUpdating>0?e/=this._numUpdating:e=+!t,this._get(`updatingProgress`)!==e){let n=performance.now();if(e<1){let t=Math.min((n-this._lastUpdateTime)/2e3,1);e=this.updatingProgress*(1-t)+e*t}this._set(`updatingProgress`,e),this._lastUpdateTime=t&&e<1?n:0}return L.UPDATING&&console.log(`Updating:`,this._updatingObjectsToDebug.filter(e=>e!=null&&e.updating).map(({declaredClass:e})=>e)),t}get _updatingObjects(){return[this.graphicsView,this.basemapView,this.groundView,this._resourceController,this.stage,this.featureTiles,this.pointsOfInterest,this.environmentView,this.overlay,this._featureTreeDebugger,this.toolViewManager,this.analysisViewManager,this.focusAreasView]}get _updatingObjectsWithProgress(){return[this.deconflictor,this.labeler,this.basemapTerrain]}get _updatingObjectsToDebug(){return L.UPDATING?this._updatingObjects.concat(this._updatingObjectsWithProgress).concat(this.allLayerViews.toArray()):[]}get viewingMode(){let e=this._predeterminedViewingMode;if(e!=null)return j(e);let t=this.spatialReference;return t?this.defaultsFromMap?.viewingMode!=null&&t.equals(this.defaultsFromMap.spatialReference)?j(this.defaultsFromMap.viewingMode):Et(t,1)?`global`:`local`:`global`}set viewingMode(e){this.ready?l.getLogger(this).error(`#viewingMode`,`viewingMode cannot be set once view is ready`):this._overrideIfSome(`viewingMode`,e)}get viewpoint(){return this.stateManager?.viewpoint}set viewpoint(e){this.stateManager&&(this.stateManager.viewpoint=e)}get visibleArea(){return this.stateManager?.visibleArea}get zoom(){return this.stateManager.zoom}set zoom(e){this.stateManager&&(this.stateManager.zoom=e)}get resourceController(){return this._resourceController}get quality(){return this._resourceController?.memoryController?.memoryFactor??1}get resolutionScale(){return Math.sqrt(Math.min(1,this.quality/.75))}get performanceInfo(){return new ut(this)}on(e,t,n,r){return this.viewEvents.on(e,t,n,r)||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}toMap(e,t){if(!this.ready)return l.getLogger(this).error(`#toMap()`,`Scene view cannot be used before it is ready`),null;let n=G(e)?K(this,e):e;return it(this,n,t,this._defaultToMapOptions)}toScreen(e){if(!this.ready)return l.getLogger(this).error(`#toScreen()`,`Scene view cannot be used before it is ready`),null;let t=e;return e.z??(t=Ft,t.x=e.x,t.y=e.y,t.z=nt(this.elevationProvider,e)??0,t.spatialReference=e.spatialReference),T(t,Z,this.renderSpatialReference),this.state.camera.projectToScreen(Z,Q),ce(Q[0],Q[1])}pixelSizeAt(e,t){if(!this.ready)return l.getLogger(this).error(`#pixelSizeAt()`,`Scene view cannot be used before it is ready`),null;if(!e)return 0;let n=this.renderSpatialReference;T(e,Z,n);let r=this.state.camera.computeScreenPixelSizeAt(Z);return t&&n!==t?r*fe(n)/fe(t):r}overlayPixelSizeInMapUnits(e){return this.overlayManager?.overlayPixelSizeInMapUnits(e,()=>this.pixelSizeAt(e))??1}hitTest(e,t){if(!this.ready)return l.getLogger(this).error(`#hitTest()`,`Scene view cannot be used before it is ready`),null;let n=G(e)?K(this,e):e;return at(this,n,t,this._defaultHitTestOptions)}async popupHitTest(e){return ot(this,e)}goTo(e,t){return this.updatingHandles.addPromise(this.stateManager.goTo(e,t))}async zoomIn(){if(this.canZoomIn)return this.navigation.zoom(!0)}async zoomOut(){if(this.canZoomOut)return this.navigation.zoom(!1)}async whenAnalysisView(e){if(e.parent==null)throw new a(`view:no-analysisview-for-analysis`,`The analysis does not exist in view.analyses`,{analysis:e});switch(e.parent.type){case`line-of-sight`:case`dimension`:case`viewshed`:return(await this.whenLayerView(e.parent)).whenAnalysisView();default:return this.analysisViewManager.whenAnalysisView(e)}}whenLayerView(e){return super.whenLayerView(e)}async takeScreenshot(e){let t=await this._completeSettings(e);await this.whenReady();let n=(await this.stage.renderView.takeScreenshot(t))[0];return(await import(`./support/screenshotUtils.js`)).encode(n,t,this._pixelFormat())}async _takeScreenshot(e){let t=await this._completeSettings(e);await this.whenReady();let n=(await this.stage.renderView.takeScreenshot(t))[0];return(await import(`./support/screenshotUtils.js`)).encodeData(n,this._pixelFormat())}async _takeScreenshotWithObjectAndLayerId(e){let t=await this._completeSettings(e);t.olidColor=!0,await this.whenReady();let n=await this.stage.renderView.takeScreenshot(t),{encodeData:r}=await import(`./support/screenshotUtils.js`);return[r(n[0],this._pixelFormat()),r(n[1],this._pixelFormat())]}async _completeSettings(e){let{toRenderSettings:t,screenshotSuperSampleSettings:n}=await import(`./support/screenshotUtils.js`),r=t(e,this);return r.pixelRatio/=this.state.pixelRatio,n(r,this.supersampleScreenshotsEnabled,this.padding)}_pixelFormat(){return{flipY:!0,premultipliedAlpha:this.stage?.renderView.getAlpha()??!1}}get test(){}async takeScreenshotWithObjectAndLayerId(e){if(!yt())throw new a(`360vr:objectAndLayerId-rendering-disabled`,`has enable-feature:objectAndLayerId-rendering must be true`);let{encode:t}=await import(`./support/screenshotUtils.js`),n=await this._completeSettings(e);n.olidColor=!0,await this.whenReady();let r=await this.stage.renderView.takeScreenshot(n),i=t(r[0],n,this._pixelFormat()),o=await this._completeSettings(e);return o.format=`png`,[i,t(r[1],o,this._pixelFormat())]}getColorToObjectAndLayerIdMapping(){let e=this.stage.renderView.olidRenderHelper;if(e)return e.getColorToObjectAndLayerIdMapping();throw new a(`360vr:objectAndLayerId-rendering-disabled`,`has enable-feature:objectAndLayerId-rendering must be true`)}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}getAttributionItems(){return super.getAttributionItems().concat(this.attribution3D.attributionItems)}importLayerView(e){return N.importLayerView(e)}hasLayerViewModule(e){return N.hasLayerViewModule(e)}forceDOMReadyCycle(){this.forceReadyCycle()}getWebDocumentSpatialReference(){return this.scene?.initialViewProperties?.spatialReference}getDefaultTimeZone(){return this.scene?.initialViewProperties?.timeZone??null}getSurface(){return this.surface}get _predeterminedViewingMode(){let e=this._isOverridden(`viewingMode`)?this._get(`viewingMode`):this.scene?.initialViewProperties?.viewingMode;return e==null?null:M(e)}getSpatialReferenceSupport(e,t){let n=this._predeterminedViewingMode,r=r=>this._validateSpatialReferenceForViewingMode(e,t,r)?this._makeSpatialReferenceConstraints(e,t,r,n):null,i=n?r(n):[...r(1)??[],...r(2)??[]];return i?.length?{constraints:i}:null}_validateSpatialReferenceForViewingMode(e,t,n){return Et(e,n)?t==null||E(t)?!0:!(D(t)&&mt(t,e,n)==null||O(t)&&n===1):!1}_makeSpatialReferenceConstraints(e,t,n,r){if(t==null)return[{spatialReference:e,viewingMode:n}];let{isWebMercator:i,isWGS84:a,vcsWkid:o,latestVcsWkid:s}=e,c=()=>o==null?i?w.WGS84:w.WebMercator:new w({...i?Oe:ke,vcsWkid:o,latestVcsWkid:s});return E(t)&&(i||a)?!(a&&r!==2)||ht(t.tileInfo,t.fullExtent,e,1)===null?[{spatialReference:e,viewingMode:n},{spatialReference:c(),viewingMode:n}]:[{spatialReference:c(),viewingMode:n}]:!D(t)&&!O(t)&&(i||a)?[{spatialReference:e,viewingMode:n},{spatialReference:c(),viewingMode:n}]:D(t)&&i&&n!==1?[{spatialReference:e,viewingMode:n},{spatialReference:c(),viewingMode:2}]:[{spatialReference:e,viewingMode:n}]}_validateSpatialReference(e){let t=this.getSpatialReferenceSupport(e)!=null,n=this._predeterminedViewingMode;return t||(n==null?e.isGeographic&&l.getLogger(this).warnOnce(`Spatial reference is geographic but not supported.`):l.getLogger(this).warnOnce(`Spatial reference defined on view not supported in ${j(n)} viewing mode.`)),t}whenReady(){return new Promise(e=>{this.ready?e(this):this._resolveWhenReady.push(e)})}trackGraphicState(e){if(!e.graphic)return l.getLogger(this).error(`trackGraphicState`,`GraphicState.graphic must not be null or undefined to start tracking`),null;let t=this.getViewForGraphic(e.graphic),n=null,r=!1,i=t=>{!r&&t!=null&&`processor`in t&&t.processor?.type===`graphics-3d`&&t.processor.graphicsCore&&(n=t.processor.graphicsCore.trackGraphicState(e))};return t==null?this.whenViewForGraphic(e.graphic,{waitForLayer:!0}).then(e=>i(e),()=>{}).catch(()=>{}):i(t),c(()=>{r=!0,n!=null&&(n.remove(),n=null)})}maskOccludee(e){if(!e)return l.getLogger(this).error(`maskOccludee`,`GraphicState.graphic must not be null or undefined to mask an occludee`),null;let t=this.getViewForGraphic(e),n=null,r=!1,i=t=>{!r&&t!=null&&Tt(t)&&(n=t.maskOccludee(e))};return t==null?this.whenViewForGraphic(e,{waitForLayer:!0}).then(e=>i(e),()=>{}).catch(()=>{}):i(t),c(()=>{r=!0,n!=null&&(n.remove(),n=null)})}getViewForGraphic(e){return e.layer===this?this.graphicsView:e.layer?this.allLayerViews.filter(e=>e.type!==`media-3d`).find(t=>t.layer===e.layer):null}graphicChanged(e){this.graphicsView!=null&&this.graphicsView.graphicChanged(e)}async whenViewForGraphic(e,t){return e.layer===this?(await ae(()=>this.graphicsView),this.graphicsView):!e.layer||!this.map?null:!t||!t.waitForLayer||this.map.allLayers.includes(e.layer)?this.whenLayerView(e.layer):new Promise((t,n)=>{let r=this.map.allLayers.on(`change`,i=>{i.added.includes(e.layer)&&(r.remove(),this.whenLayerView(e.layer).then(t,n))})})}enableFeatureTiles(){let e=Symbol();return this._featureTileTreeClients.add(e),c(()=>this._featureTileTreeClients.delete(e))}async _importModule(e,t){let n=new AbortController;this._importControllers.set(e,n),this._updatingChanged();try{let r=await It[e]();if(t&&(ne(this),d(n.signal),await t(n.signal)),this.destroyed)throw re();return d(n.signal),r}catch{return null}finally{this._importControllers.delete(e),this._updatingChanged()}}_abortImport(e){this._importControllers.get(e)?.abort(),this._importControllers.delete(e),this._updatingChanged()}_initBasemapTerrain(){this._set(`basemapTerrain`,new V({view:this})),this.elevationProvider.register(0,this.basemapTerrain)}_exitBasemapTerrain(){let{basemapTerrain:e,elevationProvider:t}=this;e&&(this._set(`basemapTerrain`,null),t.unregister(e),e.destroy())}_initGlobe(){this._initCoordinateSystem(),this.state.createInitialCamera(),this._initBasemapTerrain(),this._set(`pointsOfInterest`,new B({view:this})),this.addHandles([this.updatingHandles.add(()=>L.FEATURE_TILE_TREE_SHOW_TILES,e=>{e&&!this._featureTreeDebugger?this.updatingHandles.addPromise(import(`./3d/layers/support/FeatureTileTree3DDebugger.js`)).then(({FeatureTileTree3DDebugger:e})=>{!this._featureTreeDebugger&&L.FEATURE_TILE_TREE_SHOW_TILES&&(this._featureTreeDebugger=new e({view:this}))}):e||(this._featureTreeDebugger=u(this._featureTreeDebugger))},g),this.updatingHandles.add(()=>({basemapExtent:this.groundView?.groundExtent,basemapSpatialReference:this.groundView?.spatialReference,clippingArea:this.clippingArea,featureTiles:this._featureTiles}),({basemapExtent:e,basemapSpatialReference:t,clippingArea:n,featureTiles:r})=>{if(!r)return;let i=!!e;if(!n&&!i)r.filterExtent=null;else if(!i||!t)r.filterExtent=n;else{let i=e&&t?C(we(e,t),this.spatialReference):null;r.filterExtent=n?n.intersection(i):i}},g),this.updatingHandles.add(()=>this._featureTileTreeClients.size>0,e=>{e?this.updatingHandles.consumePromise(this._ensureFeatureTileTree()):this._featureTiles=u(this._featureTiles)},h)],Nt),this.stateManager.init()}async _ensureFeatureTileTree(){if(this._featureTiles||this._importControllers.has(`FeatureTileTree3D`))return;let e=(await this.updatingHandles.addPromise(this._importModule(`FeatureTileTree3D`)))?.FeatureTileTree3D;e&&(this._featureTiles=new e({renderCoordsHelper:this.renderCoordsHelper,pointsOfInterest:this.pointsOfInterest,viewState:this.state,scheduler:this._resourceController.scheduler,terrain:this.basemapTerrain}),this._updatingChanged())}_exitTerrain(){this.stateManager.exit(),this.removeHandles(J),this.removeHandles(Nt),this._featureTiles=u(this.featureTiles),this._set(`pointsOfInterest`,u(this.pointsOfInterest)),this._exitBasemapTerrain(),this.state.reset(),this._exitCoordinateSystem()}_initCoordinateSystem(){if(this.spatialReference){let e=this.spatialReference,t=this.state.isGlobal,n=Ee(t,e);n!==this.renderSpatialReference&&(this._set(`renderCoordsHelper`,ct.create(this.state.viewingMode,n)),t||this.addHandles(p(()=>this.groundView?.groundExtent,e=>{let t=this.renderCoordsHelper.spatialReference;e!=null&&(e[0]!==0||e[1]!==0||e[2]!==0||e[3]!==0)&&Ce(e,this.groundView.spatialReference,$,t)&&(this.renderCoordsHelper.extent=$)},h),J),this.sceneIntersectionHelper&&this.sceneIntersectionHelper.setTolerance(H/this.renderCoordsHelper.unitInMeters))}else this._set(`renderCoordsHelper`,null)}_exitCoordinateSystem(){this.removeHandles(J),this._set(`renderCoordsHelper`,null)}_updatingChanged(){this.notifyChange(`updating`)}_updateUpdatingMonitors(e=null){(e==null||e.type!==4)&&(this.removeHandles(`updatingMonitors`),this.allLayerViews.forEach(e=>{e.destroyed||(this.addHandles(p(()=>[e.updating,e.updatingProgress],()=>this._updatingChanged(),h),`updatingMonitors`),e.when(()=>this._updatingChanged(),()=>this._updatingChanged()))}),this._updatingChanged())}async _prepareScreenshotOverlay(){this.overlay&&await this.overlay.prepare()}_renderScreenshotOverlay(e,t,n){if(!this.overlay||!this.overlay.hasVisibleItems)return n;let r=e.getContext(`2d`,{willReadFrequently:!0});return r.putImageData(n,0,0),this.overlay.renderCanvas(e,{disableDecorations:t}),r.getImageData(0,0,n.width,n.height)}_initStage(){let e={deactivatedWebGLExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions,alpha:this.alphaCompositingEnabled,preserveDrawingBuffer:this.preserveDrawingBufferEnabled,canvas:this.renderCanvas,screenshot:{prepareOverlay:()=>this._prepareScreenshotOverlay(),renderOverlay:(e,t,n)=>this._renderScreenshotOverlay(e,t,n)}},t=new Qe(this.state.viewingMode,e=>this.stage.layers.forEach(e),this);this._set(`sceneIntersectionHelper`,t);let n=i(this.surface);this._stage=new vt({view:this,options:e,container:n}),this.notifyChange(`stage`),this._updateSlice(),this.addHandles([this.on(`pointer-move`,()=>this.stage?.renderer.resetAnimation()),o(this.stage.renderView.canvas,`webglcontextlost`,e=>{this.fatalError=new a(`webgl-context-lost`,e.statusMessage||`WebGL context lost`)})],`stage`),this.renderCoordsHelper&&this.sceneIntersectionHelper.setTolerance(H/this.renderCoordsHelper.unitInMeters),this._set(`canvas`,this.stage.renderView.canvas)}_exitStage(){this.sceneIntersectionHelper?.destroy(),this._set(`sceneIntersectionHelper`,null),this._stage=u(this.stage),this._set(`stage`,null),this.removeHandles(`stage`),this._set(`canvas`,null)}_initSurface(){this._exitSurface(),this._initStage(),this._initGlobe(),this.sharedSymbolResources=new dt({view:this,resourceController:this._resourceController})}_exitSurface(){this.sharedSymbolResources&&(this.sharedSymbolResources.objectResourceCache.destroy(),this.sharedSymbolResources.destroy(),this.sharedSymbolResources=null,this._exitTerrain(),this._exitStage())}async _ensureGraphicsView(){if(this.graphicsView||this._importControllers.has(`GraphicsView3D`)||this.graphics.length===0)return;this.removeHandles(`GraphicsView3D`);let e=(await this.updatingHandles.addPromise(this._importModule(`GraphicsView3D`,e=>ae(()=>this.groundView?.ready,e))))?.default;e&&this._set(`graphicsView`,new e({view:this,getGraphics:()=>this.graphics})),this._updatingChanged()}_disposeGraphicsView(){this._abortImport(`GraphicsView3D`),this.removeHandles(`GraphicsView3D`),this.graphicsView&&(this.removeHandles(this.graphicsView.processor.layer.id),this.graphicsView.destroy(),this._set(`graphicsView`,null))}_disposeFocusAreasView(){this._abortImport(`FocusAreasView`),this.removeHandles(`FocusAreasView`),this.focusAreasView=u(this.focusAreasView)}async _ensureFocusAreasView(e){if(this.focusAreasView||this._importControllers.has(`FocusAreasView`)||e===0)return;this.removeHandles(`FocusAreasView`);let t=(await this.updatingHandles.addPromise(this._importModule(`FocusAreasView`)))?.FocusAreasView;t&&(this.focusAreasView=new t({view:this})),this._updatingChanged()}_startup(){M(this.viewingMode)===1&&(this._clippingArea=null),this._initSurface(),this._set(`ready`,!0),this.addHandles(f(()=>this.graphics,`after-changes`,()=>this._ensureGraphicsView()),`GraphicsView3D`),this._ensureGraphicsView(),this.addHandles(this.updatingHandles.add(()=>this.map?.focusAreas?.areas.length??0,e=>this._ensureFocusAreasView(e),{initial:!0}),`FocusAreasView`);let e=this.scene?.initialViewProperties??null,t=e?.environment;t&&(this._overrideDefaultEnvironmentOnly?me(this.environment,t):this.environment=this.environment.cloneWithWebsceneEnvironment(t)),this.timeExtent=e?.timeExtent,e?.analyses.applyTo(this),this.labeler.setup(),this.environmentView.connectView(this),this.inputManager.connect();let n=this._resolveWhenReady;this._resolveWhenReady=[],n.forEach(e=>e(this))}_teardown(){this.inputManager.disconnect(),this.environmentView.disconnectView(),this._overrideDefaultEnvironmentOnly=!1,this.labeler.dispose(),this._disposeGraphicsView(),this._disposeFocusAreasView(),this._exitSurface(),this._set(`ready`,!1)}get _defaultToMapOptions(){let e={include:new Set};if(!this.map)return e;this.map.ground&&e.include.add(U);for(let t of this.allLayerViews)(k(t.layer)&&(!has(`enable-feature:im-as-ground`)||t.layer.isUsedAsGroundLayer)||je(t.layer))&&e.include.add(t.uid);return e}get _defaultHitTestOptions(){let e={exclude:new Set};if(!this.map)return e;this.map.ground&&this.map.ground.opacity<1&&e.exclude.add(U);for(let t of this.allLayerViews)(has(`enable-feature:im-as-ground`)?k(t.layer)&&t.layer.isUsedAsGroundLayer:k(t.layer))&&t.fullOpacity<1&&e.exclude.add(t.uid);return e}static{this.type=`3d`}static clearStatics(){Mt(),ge(),ue(),St(),Xe(),Ve(),Se(),wt(),Ne(),_t(),xt(),Ze(),$e(),ve(),se(),bt(),gt(),Ke.cleanupI3SLodHandling(),Me.cleanupTilemapCache(),I.cleanupViewstate(),V.cleanupTerrainSurface()}};e([_({nonNullable:!0}),v(Pt)],Y.prototype,`options`,void 0),e([_()],Y.prototype,`_userClippingArea`,void 0),e([_()],Y.prototype,`_resourceController`,void 0),e([_()],Y.prototype,`stage`,null),e([_({readOnly:!0})],Y.prototype,`deconflictor`,void 0),e([_({readOnly:!0})],Y.prototype,`labeler`,void 0),e([_()],Y.prototype,`navigation`,void 0),e([_({type:Re,readOnly:!0})],Y.prototype,`animation`,null),e([_({readOnly:!0})],Y.prototype,`basemapTerrain`,void 0),e([_({readOnly:!0})],Y.prototype,`overlayManager`,null),e([_({readOnly:!0})],Y.prototype,`elevationProvider`,void 0),e([_()],Y.prototype,`camera`,null),e([_({type:t})],Y.prototype,`contentCamera`,null),e([_({readOnly:!0})],Y.prototype,`canvas`,null),e([_({type:S,useTypeForAutocast:!1})],Y.prototype,`center`,null),e([_({type:x})],Y.prototype,`clippingArea`,null),e([_({type:P,nonNullable:!0})],Y.prototype,`constraints`,void 0),e([_({type:x,readOnly:!0})],Y.prototype,`renderDataExtent`,null),e([_({readOnly:!0})],Y.prototype,`tileInfo`,null),e([_({type:x,readOnly:!0})],Y.prototype,`dataExtent`,null),e([_({type:x,readOnly:!0})],Y.prototype,`_groundAndLayersExtent`,null),e([_({type:F})],Y.prototype,`environment`,null),e([v(`environment`)],Y.prototype,`castEnvironment`,null),e([_({readOnly:!0})],Y.prototype,`environmentView`,void 0),e([_({type:x})],Y.prototype,`extent`,null),e([_({type:r})],Y.prototype,`floors`,void 0),e([_()],Y.prototype,`screenCenter`,null),e([_()],Y.prototype,`frustum`,null),e([_({type:Number,readOnly:!0})],Y.prototype,`fullOpacity`,void 0),e([_({readOnly:!0})],Y.prototype,`graphicsView`,void 0),e([_()],Y.prototype,`analysisViewManager`,void 0),e([_()],Y.prototype,`groundView`,void 0),e([_({readOnly:!0})],Y.prototype,`layerviewCollections`,null),e([_({type:Boolean})],Y.prototype,`initialExtentRequired`,null),e([_()],Y.prototype,`defaultsFromMapSettings`,null),e([_()],Y.prototype,`interacting`,null),e([_()],Y.prototype,`stationary`,null),e([_()],Y.prototype,`navigating`,null),e([_()],Y.prototype,`map`,void 0),e([_()],Y.prototype,`padding`,null),e([_({type:B,readOnly:!0})],Y.prototype,`pointsOfInterest`,void 0),e([_()],Y.prototype,`_featureTiles`,void 0),e([_()],Y.prototype,`featureTiles`,null),e([_()],Y.prototype,`_featureTreeDebugger`,void 0),e([_({constructOnly:!0})],Y.prototype,`deactivatedWebGLExtensions`,void 0),e([_({constructOnly:!0})],Y.prototype,`debugWebGLExtensions`,void 0),e([_({constructOnly:!0})],Y.prototype,`renderCanvas`,void 0),e([_({constructOnly:!0})],Y.prototype,`state`,void 0),e([_()],Y.prototype,`screenSizePerspective`,void 0),e([_({readOnly:!0})],Y.prototype,`inputManager`,void 0),e([_({readOnly:!0})],Y.prototype,`stateManager`,void 0),e([_({type:[`low`,`medium`,`high`]})],Y.prototype,`qualityProfile`,null),e([_({type:z,get(){let e=this._get(`qualitySettings`);if(!e){let t=R(this.qualityProfile);e=new z(t)}return e}})],Y.prototype,`qualitySettings`,void 0),e([_()],Y.prototype,`slice`,void 0),e([_({readOnly:!0})],Y.prototype,`typeSpecificPreconditionsReady`,null),e([_({readOnly:!0})],Y.prototype,`renderCoordsHelper`,void 0),e([_({readOnly:!0})],Y.prototype,`sceneIntersectionHelper`,void 0),e([_({type:Number,readOnly:!0})],Y.prototype,`resolution`,null),e([_({type:Number})],Y.prototype,`scale`,null),e([_({readOnly:!0,type:Number})],Y.prototype,`terrainLevel`,null),e([_()],Y.prototype,`heightModelInfo`,null),e([_({type:w})],Y.prototype,`spatialReference`,void 0),e([_({type:Boolean,value:!1})],Y.prototype,`alphaCompositingEnabled`,null),e([_({constructOnly:!0})],Y.prototype,`preserveDrawingBufferEnabled`,void 0),e([_({type:Boolean})],Y.prototype,`supersampleScreenshotsEnabled`,void 0),e([_({readOnly:!0})],Y.prototype,`type`,void 0),e([_(),v(e=>e instanceof kt?e:b(At,e))],Y.prototype,`ui`,void 0),e([_({type:Boolean,readOnly:!0})],Y.prototype,`updating`,null),e([_()],Y.prototype,`_updatingObjects`,null),e([_()],Y.prototype,`_updatingObjectsWithProgress`,null),e([_()],Y.prototype,`_updatingObjectsToDebug`,null),e([_({type:Number,readOnly:!0})],Y.prototype,`updatingProgress`,void 0),e([_({type:[`global`,`local`]})],Y.prototype,`viewingMode`,null),e([_({type:n})],Y.prototype,`viewpoint`,null),e([_({readOnly:!0})],Y.prototype,`visibleArea`,null),e([_({type:Number})],Y.prototype,`zoom`,null),e([_({readOnly:!0})],Y.prototype,`quality`,null),e([_({readOnly:!0})],Y.prototype,`resolutionScale`,null),e([_()],Y.prototype,`focusAreasView`,void 0),e([_()],Y.prototype,`_defaultToMapOptions`,null),e([_()],Y.prototype,`_defaultHitTestOptions`,null),Y=q=e([pe(`esri.views.SceneView`)],Y);function X(e,t){return e!=null&&xe(e.spatialReference,t)?C(e,t):null}const Z=_e(),Q=le(),$=Te(),Ft=Ae(0,0,0,w.WebMercator),It={GraphicsView3D:()=>import(`./3d/layers/GraphicsView3D.js`),FocusAreasView:()=>import(`./3d/FocusAreasView.js`),FeatureTileTree3D:()=>import(`./3d/layers/support/FeatureTileTree3D.js`)},Lt=Y;export{Lt as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import n from"../../../core/Accessor.js";import{createTask as r}from"../../../core/asyncUtils.js";import i from"../../../core/Collection.js";import{makeHandle as a}from"../../../core/handleUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{ignoreAbortErrors as s,isAborted as c,throwIfAborted as l}from"../../../core/promiseUtils.js";import{pausable as u,sync as d,watch as f,syncAndInitial as p}from"../../../core/reactiveUtils.js";import{property as m,subclass as h}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as g}from"../../../core/support/UpdatingHandles.js";import _ from"../../../layers/GraphicsLayer.js";import v from"../../../symbols/CIMSymbol.js";import y from"../../../symbols/SimpleLineSymbol.js";import b from"../../../symbols/support/ElevationInfo.js";import{ExclusiveOperationManager as x}from"../ExclusiveOperationManager.js";import{isPolyline as S,isValidInputGraphic as C,isInternalGraphic as w}from"./elevationProfileGeometryUtils.js";import{ViewEventPriorities as T}from"../../input/InputManager.js";import{isCancelEvent as E}from"../../interactive/interactiveToolUtils.js";import{makeGeometryAnalysisSnappingOptions as D}from"../../interactive/snapping/allLayerSnapping.js";import O from"../../../widgets/Sketch/SketchViewModel.js";let k=class extends n{constructor(e){super(e),this._sketchViewModels=new i,this._updatingHandles=new g,this._operationManager=new x}initialize(){let{view:e}=this;this._allLayerSnappingOptions=D(e),this._graphicsLayer=new _({listMode:`hide`,internal:!0}),this._externalGeometryChangeHandle=u(()=>this._analysis.geometry,()=>this._ensureUpdatedSketchGraphic(),d),this.addHandles([f(()=>({map:e.map,internalGraphicsLayer:this._graphicsLayer,state:this.state,geometryVisualizationVisible:this._analysis.viewOptions.geometryVisualizationVisible,visible:this.analysisViewData.visible}),({map:e,internalGraphicsLayer:t,state:n,geometryVisualizationVisible:r,visible:i})=>{j(e,t);let a=this.sketchGraphic;switch(a&&(a.visible=i),n){case`idle`:case`reshaping-disabled`:a&&!r&&(a.visible=!1),this._operationManager.stop(),this._ensureUpdatedSketchGraphic();break;case`reshaping`:s(this._startReshape());break;case`awaiting-sketch`:this.analysisViewData.interactive=!0}},p),f(()=>this._analysis.elevationInfo,e=>{this._graphicsLayer.elevationInfo=e},p),this._allLayerSnappingOptions,this._externalGeometryChangeHandle])}destroy(){this._operationManager.destroy(),this._sketchViewModels.drain(e=>o(e));let e=this._graphicsLayer;this.view.map?.remove(e),e.destroy()}get sketchGraphic(){return this._get(`sketchGraphic`)}set sketchGraphic(e){e!==this._get(`sketchGraphic`)&&(this._set(`sketchGraphic`,e),this._updateAnalysisFromSketchGraphic())}get state(){let{visible:e,interactive:t}=this.analysisViewData;if(!e)return`idle`;switch(this._operationManager.currentOperationType){case`place`:return this._sketching?`sketching`:`awaiting-sketch`;case`pick-feature`:return`picking`;default:return this._analysis.geometry?t?`reshaping`:`reshaping-disabled`:`idle`}}get updating(){return this._sketchViewModels.some(e=>e.updating)||this._updatingHandles.updating}get _sketching(){return this._sketchViewModels.some(e=>e.createGraphic===this.sketchGraphic)}get _analysis(){return this.analysisViewData.analysis}get _lineSymbol(){return A(this.view.type)}place(e){return this._operationManager.start(`place`,async t=>{let n=this._createSketchViewModel(),r=this._analysis.clone();this._ensureUpdatedSketchGraphic();let i=this.sketchGraphic,o=this._analysis.elevationInfo,l=a(()=>{this.sketchGraphic===i&&(this._graphicsLayer.elevationInfo=o)}),u=n.on(`create`,e=>{switch(e.state){case`start`:this._graphicsLayer.removeAll(),this.sketchGraphic=e.graphic,this._analysis.elevationInfo=this._graphicsLayer.elevationInfo;break;case`active`:this._updateAnalysisFromSketchGraphic();break;case`complete`:this.sketchGraphic&&(this._updateAnalysisFromSketchGraphic(),this._addSketchGraphic(this.sketchGraphic)),t.stop();break;case`cancel`:t.stop()}});t.handles.push(u,a(()=>{if(
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import n from"../../../core/Accessor.js";import{createTask as r}from"../../../core/asyncUtils.js";import i from"../../../core/Collection.js";import{makeHandle as a}from"../../../core/handleUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{ignoreAbortErrors as s,isAborted as c,throwIfAborted as l}from"../../../core/promiseUtils.js";import{pausable as u,sync as d,watch as f,syncAndInitial as p}from"../../../core/reactiveUtils.js";import{property as m,subclass as h}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as g}from"../../../core/support/UpdatingHandles.js";import _ from"../../../layers/GraphicsLayer.js";import v from"../../../symbols/CIMSymbol.js";import y from"../../../symbols/SimpleLineSymbol.js";import b from"../../../symbols/support/ElevationInfo.js";import{ExclusiveOperationManager as x}from"../ExclusiveOperationManager.js";import{isPolyline as S,isValidInputGraphic as C,isInternalGraphic as w}from"./elevationProfileGeometryUtils.js";import{ViewEventPriorities as T}from"../../input/InputManager.js";import{isCancelEvent as E}from"../../interactive/interactiveToolUtils.js";import{makeGeometryAnalysisSnappingOptions as D}from"../../interactive/snapping/allLayerSnapping.js";import O from"../../../widgets/Sketch/SketchViewModel.js";let k=class extends n{constructor(e){super(e),this.canStopPlacing=!1,this._sketchViewModels=new i,this._updatingHandles=new g,this._operationManager=new x}initialize(){let{view:e}=this;this._allLayerSnappingOptions=D(e),this._graphicsLayer=new _({listMode:`hide`,internal:!0}),this._externalGeometryChangeHandle=u(()=>this._analysis.geometry,()=>this._ensureUpdatedSketchGraphic(),d),this.addHandles([f(()=>({map:e.map,internalGraphicsLayer:this._graphicsLayer,state:this.state,geometryVisualizationVisible:this._analysis.viewOptions.geometryVisualizationVisible,visible:this.analysisViewData.visible}),({map:e,internalGraphicsLayer:t,state:n,geometryVisualizationVisible:r,visible:i})=>{j(e,t);let a=this.sketchGraphic;switch(a&&(a.visible=i),n){case`idle`:case`reshaping-disabled`:a&&!r&&(a.visible=!1),this._operationManager.stop(),this._ensureUpdatedSketchGraphic();break;case`reshaping`:s(this._startReshape());break;case`awaiting-sketch`:this.analysisViewData.interactive=!0}},p),f(()=>this._analysis.elevationInfo,e=>{this._graphicsLayer.elevationInfo=e},p),this._allLayerSnappingOptions,this._externalGeometryChangeHandle])}destroy(){this._operationManager.destroy(),this._sketchViewModels.drain(e=>o(e));let e=this._graphicsLayer;this.view.map?.remove(e),e.destroy()}get sketchGraphic(){return this._get(`sketchGraphic`)}set sketchGraphic(e){e!==this._get(`sketchGraphic`)&&(this._set(`sketchGraphic`,e),this._updateAnalysisFromSketchGraphic())}get state(){let{visible:e,interactive:t}=this.analysisViewData;if(!e)return`idle`;switch(this._operationManager.currentOperationType){case`place`:return this._sketching?`sketching`:`awaiting-sketch`;case`pick-feature`:return`picking`;default:return this._analysis.geometry?t?`reshaping`:`reshaping-disabled`:`idle`}}get updating(){return this._sketchViewModels.some(e=>e.updating)||this._updatingHandles.updating}get _sketching(){return this._sketchViewModels.some(e=>e.createGraphic===this.sketchGraphic)}get _analysis(){return this.analysisViewData.analysis}get _lineSymbol(){return A(this.view.type)}place(e){return this._operationManager.start(`place`,async t=>{let n=this._createSketchViewModel(),r=this._analysis.clone();this._ensureUpdatedSketchGraphic();let i=this.sketchGraphic,o=this._analysis.elevationInfo,l=a(()=>{this.sketchGraphic===i&&(this._graphicsLayer.elevationInfo=o)}),u=()=>{let{activeComponent:e}=n;this.canStopPlacing=(e?.type===`draw-2d`||e?.type===`draw-3d`)&&e.drawOperation.numCommittedVertices>=2},d=n.on(`create`,e=>{switch(u(),e.state){case`start`:this._graphicsLayer.removeAll(),this.sketchGraphic=e.graphic,this._analysis.elevationInfo=this._graphicsLayer.elevationInfo;break;case`active`:this._updateAnalysisFromSketchGraphic();break;case`complete`:this.sketchGraphic&&(this._updateAnalysisFromSketchGraphic(),this._addSketchGraphic(this.sketchGraphic)),t.stop();break;case`cancel`:t.stop()}});t.handles.push(d,n.on([`undo`,`redo`],u),a(()=>{if(d.remove(),this.canStopPlacing=!1,n.destroy(),this._sketchViewModels.remove(n),this._updateAnalysisFromSketchGraphic(),!this._analysis.valid)return this._clear(),t.reject();if(c(e)||r.equals(this._analysis))return t.reject();t.resolve({})}),l),this._graphicsLayer.elevationInfo=M,await this._updatingHandles.addPromise(s(n.create(`polyline`)))},e)}async pickFeature(e){return this._operationManager.start(`pick-feature`,async e=>{let{view:t}=this;t.closePopup();let n=null;e.handles.push(t.on(`immediate-click`,i=>{i.defer(async()=>{n?.abort(),n=r(async n=>{let{results:r}=await t.hitTest(i);l(n);let a=null;for(let e of r)if(e.type===`graphic`&&C(e.graphic)&&!w(e.graphic)){a=e.graphic;break}a&&(i.preventDefault(),i.stopPropagation(),this._externalGeometryChangeHandle.pause(),this.sketchGraphic=null,this._analysis.setGeometryFromFeature(a),this._externalGeometryChangeHandle.resume(),e.resolve({feature:a}),e.stop())}),await n.promise})},T.TOOL),t.on(`key-down`,t=>{E(t)&&(e.reject(),e.stop())},T.TOOL),t.acquireCursor(`crosshair`,`high`),a(()=>{n?.abort(),e.reject()})),t.focus()},e)}_startReshape(){let e=this._createSketchViewModel();return this._sketchViewModels.add(e),this._operationManager.start(`reshape`,async t=>{let n=()=>{let t=this._ensureUpdatedSketchGraphic();return t?this._updatingHandles.addPromise(e.update(t,{tool:`reshape`})):Promise.resolve()};if(!this._ensureUpdatedSketchGraphic())return;let r=e.on(`update`,e=>{this._updateAnalysisFromSketchGraphic(),e.state===`complete`&&(this.state===`reshaping`?s(n()):t.resolve())});t.handles.push(r,a(()=>{r.remove(),this._sketchViewModels.remove(e),e.destroy(),t.resolve()})),await n()})}_createSketchViewModel(){return new O({layer:this._graphicsLayer,view:this.view,defaultCreateOptions:{mode:`click`,hasZ:!0},updateOnGraphicClick:!1,defaultUpdateOptions:{enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,enableZ:!1,highlightOptions:{enabled:!1},multipleSelectionEnabled:!1,reshapeOptions:{shapeOperation:`none`},toggleToolOnClick:!1,tool:`reshape`},polylineSymbol:this._lineSymbol,activeLineSymbol:this._lineSymbol,snappingOptions:this._allLayerSnappingOptions.options})}_ensureUpdatedSketchGraphic(){let{geometry:e}=this._analysis;if(!e)return this.sketchGraphic=null,this._graphicsLayer.removeAll(),null;let n=this.sketchGraphic??=new t({symbol:this._lineSymbol,geometry:e});return n.geometry=e,this._addSketchGraphic(n),n}_addSketchGraphic(e){let{graphics:t}=this._graphicsLayer;t.includes(e)||t.add(e),t.length!==1&&t.removeMany(t.filter(t=>t!==e))}_clear(){this.sketchGraphic=null,this._analysis.clear()}_updateAnalysisFromSketchGraphic(){this._externalGeometryChangeHandle.pause();let e=this.sketchGraphic?.geometry;S(e)||(e=null);let t=this._analysis;t.geometry!==e&&(t.geometry=e),this._externalGeometryChangeHandle.resume()}};e([m({constructOnly:!0})],k.prototype,`analysisViewData`,void 0),e([m({constructOnly:!0})],k.prototype,`view`,void 0),e([m()],k.prototype,`canStopPlacing`,void 0),e([m()],k.prototype,`sketchGraphic`,null),e([m({nonNullable:!0})],k.prototype,`state`,null),e([m()],k.prototype,`updating`,null),e([m()],k.prototype,`_sketching`,null),e([m()],k.prototype,`_analysis`,null),e([m()],k.prototype,`_lineSymbol`,null),k=e([h(`esri.views.analysis.ElevationProfile.ElevationProfileTool`)],k);function A(e){if(e===`2d`){let e={type:`CIMSolidStroke`,enable:!0,capStyle:`Butt`,joinStyle:`Round`,width:1.5};return new v({data:{type:`CIMSymbolReference`,symbol:{type:`CIMLineSymbol`,symbolLayers:[{...e,effects:[{type:`CIMGeometricEffectDashes`,dashTemplate:[5,4],lineDashEnding:`FullGap`,controlPointEnding:`NoConstraint`}],color:[0,0,0,255]},{...e,color:[255,255,255,255]}]}}})}return new y({color:[0,0,0,0]})}function j(e,t){t&&(t.removeFromParent(),e?.add(t))}const M=new b({mode:`on-the-ground`,offset:0});export{k as ElevationProfileTool};
|
package/views/types.d.ts
CHANGED
|
@@ -870,6 +870,7 @@ export interface HitTestOptions3D {
|
|
|
870
870
|
* > Please refer to the [styling guide](https://developers.arcgis.com/javascript/latest/styling/#view-size-css-classes) for additional
|
|
871
871
|
* > information on working with this.
|
|
872
872
|
*
|
|
873
|
+
* @deprecated since 5.2. Use alternative responsive design techniques such as a [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) instead.
|
|
873
874
|
* @since 5.0
|
|
874
875
|
* @see [BreakpointsOwner.breakpoints](https://developers.arcgis.com/javascript/latest/references/core/views/BreakpointsOwner/#breakpoints)
|
|
875
876
|
*/
|
|
@@ -941,6 +942,7 @@ export interface Breakpoints {
|
|
|
941
942
|
* landscape | The [width](https://developers.arcgis.com/javascript/latest/references/core/views/View2D/#width) of the view is greater than its [height](https://developers.arcgis.com/javascript/latest/references/core/views/View2D/#height).
|
|
942
943
|
* portrait | The [width](https://developers.arcgis.com/javascript/latest/references/core/views/View2D/#width) of the view is equal to or smaller than its [height](https://developers.arcgis.com/javascript/latest/references/core/views/View2D/#height).
|
|
943
944
|
*
|
|
945
|
+
* @deprecated since 5.2. Use alternative responsive design techniques such as a [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) instead.
|
|
944
946
|
* @since 5.0
|
|
945
947
|
*/
|
|
946
948
|
export type BreakpointOrientation = "landscape" | "portrait";
|
|
@@ -960,6 +962,7 @@ export type BreakpointOrientation = "landscape" | "portrait";
|
|
|
960
962
|
* large | The width or height of the view is between the values set in the `medium` and `large` [breakpoints](https://developers.arcgis.com/javascript/latest/references/core/views/BreakpointsOwner/#breakpoints). | 993 - 1200
|
|
961
963
|
* xlarge | The width or height of the view is larger than the value set in the `large` [breakpoint](https://developers.arcgis.com/javascript/latest/references/core/views/BreakpointsOwner/#breakpoints). | > 1200
|
|
962
964
|
*
|
|
965
|
+
* @deprecated since 5.2. Use alternative responsive design techniques such as a [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) instead.
|
|
963
966
|
* @since 5.0
|
|
964
967
|
* @see [widthBreakpoint](https://developers.arcgis.com/javascript/latest/references/core/views/BreakpointsOwner/#widthBreakpoint)
|
|
965
968
|
* @see [heightBreakpoint](https://developers.arcgis.com/javascript/latest/references/core/views/BreakpointsOwner/#heightBreakpoint)
|
package/views/ui/UI.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{getLocale as t,onLocaleChange as n}from"../../intl.js";import r from"../../core/Accessor.js";import{isSome as i}from"../../core/arrayUtils.js";import{EventedAccessor as a}from"../../core/Evented.js";import{makeHandle as o}from"../../core/handleUtils.js";import{watch as s,initial as c}from"../../core/reactiveUtils.js";import{property as l,cast as u,subclass as d}from"../../core/accessorSupport/decorators.js";import{setCalciteModeClass as f}from"../../support/modeUtils.js";import p from"./Component.js";import{isRTL as m}from"../../widgets/support/widget.js";const h={left:0,top:0,bottom:0,right:0},g={bottom:30,top:15,right:15,left:15},_=`esri-ui`,v={ui:_,corner:`${_}-corner`,innerContainer:`${_}-inner-container`,manualContainer:`${_}-manual-container`,cornerContainer:`${_}-corner-container`,topLeft:`${_}-top-left`,topRight:`${_}-top-right`,bottomLeft:`${_}-bottom-left`,bottomRight:`${_}-bottom-right`};function y(e){return e&&!e._started&&typeof e.postMixInProperties==`function`&&typeof e.buildRendering==`function`&&typeof e.postCreate==`function`&&typeof e.startup==`function`}function b(e){return e===0?`0`:`${e}px`}function x(e){let t=typeof e==`object`&&!!e&&Object.getPrototypeOf(e);return(t===null||t===Object.prototype)&&(`component`in e||`index`in e||`position`in e)?e:null}function S(e,{top:t,bottom:n,left:r,right:i}){e.style.top=t,e.style.bottom=n,e.style.left=r,e.style.right=i}let C=class extends a{constructor(e){super(e),this._cornerNameToContainerLookup={},this._positionNameToContainerLookup={},this._components=[],this._componentMap=new Map,this._removeWidgetHandleKey=Symbol(`componentOnRemoveSymbol`),this._locale=t(),this.view=null,this._applyViewPadding=()=>{let e=this.container;e&&S(e,this._toPixelPosition(this._getViewPadding()))},this._applyUIPadding=()=>{let e=this._innerContainer;e&&S(e,this._toPixelPosition(this.padding))},this._initContainers()}initialize(){this.addHandles([s(()=>[this.view?.padding,this.container],this._applyViewPadding,c),s(()=>this.padding,this._applyUIPadding,c),s(()=>[this.container,this._locale],([e,t])=>{e&&e.setAttribute(`lang`,t)},c),n(e=>{this._locale=e})])}destroy(){this.removeAllHandles(),this.container=null;for(let e of this._components)e.destroy();this._components.length=0,this._componentMap.clear(),this.view=null,this._set(`view`,null)}set container(e){let t=this._get(`container`);e!==t&&(e&&(e.classList.add(v.ui),f(e),this._attachContainers(e)),t&&(t.classList.remove(v.ui),S(t,{top:``,bottom:``,left:``,right:``}),t.textContent=``),this._set(`container`,e))}get height(){let e=this.view?.height??0;if(e===0)return e;let{top:t,bottom:n}=this._getViewPadding();return Math.max(e-t-n,0)}get padding(){return this._get(`padding`)}set padding(e){this._overrideIfSome(`padding`,e)}castPadding(e){return typeof e==`number`?{bottom:e,top:e,right:e,left:e}:{...g,...e}}get width(){let e=this.view?.width??0;if(e===0)return e;let{left:t,right:n}=this._getViewPadding();return Math.max(e-t-n,0)}add(e,t){let n,r,i;if(Array.isArray(e)){e.forEach(e=>this.add(e,t));return}let a=x(e);a&&({index:n,position:t,component:e,key:r}=a),t&&typeof t==`object`&&({index:n,key:r,position:t,internal:i}=t),!(!e||t&&!this._isValidPosition(t))&&this._add(e,t,n??this._getNumComponentsAtPosition(t),r,i)}remove(e,t){if(!e)return;if(Array.isArray(e))return e.map(e=>this.remove(e,t));let n=this._find(e);if(n){let e=this._componentMap.get(n);if(!e||e.key!==t)return;let r=this._components.indexOf(n);return n.node.parentNode?.removeChild(n.node),this._componentMap.delete(n),n.widget?.removeHandlesReference(this._removeWidgetHandleKey),this._components.forEach(t=>{let n=this._componentMap.get(t);n&&n.position===e.position&&n.index>e.index&&n.index--}),this._components.splice(r,1)[0]}}empty(e,t={removeInternal:!1}){if(Array.isArray(e)){for(let n of e)this.empty(n,t);return}let n=this._positionNameToContainerLookup[e??`manual`],r=Array.prototype.slice.call(n.children).map(e=>this._findByNode(e)).filter(e=>e==null?!1:!(this._componentMap.get(e)?.internal??!1)||t.removeInternal);for(let e of r)this.remove(e)}move(e,t){if(Array.isArray(e)&&e.forEach(e=>this.move(e,t)),!e)return;let n,r=x(e)||x(t);if(r&&(n=r.index,t=r.position,e=r.component||e),t&&!this._isValidPosition(t))return;let i=this.remove(e);i&&this.add(i,{position:t,index:n})}find(e){if(!e)return null;let t=this._findById(e);return t&&(t.widget||t.node)}getComponents(e,t={includeInternal:!1}){return e?Array.isArray(e)?e.flatMap(e=>this._getComponentsAtPosition(e,t)):this._getComponentsAtPosition(e,t):this._components.filter(e=>t.includeInternal||!(this._componentMap.get(e)?.internal??!1)).map(({widget:e,node:t})=>e??t)}getPosition(e){for(let t in this._positionNameToContainerLookup)if(this._positionNameToContainerLookup[t].contains(e))return t;return null}_add(e,t,n,i,a){e instanceof p||(e=new p({node:e}));let{widget:s}=e;s!=null&&s instanceof r&&s.addHandles(o(()=>{queueMicrotask(()=>this.remove(e))}),this._removeWidgetHandleKey);let c=this._positionNameToContainerLookup[t];this._components.some(e=>{let t=this._componentMap.get(e)?.position,r=t?this._positionNameToContainerLookup[t]:null;return c===r&&this._componentMap.get(e)?.index===n})&&this._components.forEach(e=>{let t=this._componentMap.get(e),r=t?.position,i=r?this._positionNameToContainerLookup[r]:null;t&&i===c&&t.index>=n&&t.index++}),this._place({component:e,position:t,index:n}),this._components.push(e),this._componentMap.set(e,{key:i,position:t,internal:a,index:n})}_find(e){return e?e instanceof p?this._findByComponent(e):typeof e==`string`?this._findById(e):`domNode`in e?this._findByNode(e.domNode):this._findByNode(e):null}_getViewPadding(){return this.view?.padding??h}_attachContainers(e){e.appendChild(this._innerContainer),e.appendChild(this._manualContainer)}_initContainers(){let e=document.createElement(`div`);e.classList.add(v.innerContainer,v.cornerContainer);let t=document.createElement(`div`);t.classList.add(v.innerContainer,v.manualContainer);let n=document.createElement(`div`);n.classList.add(v.topLeft,v.corner),e.appendChild(n);let r=document.createElement(`div`);r.classList.add(v.topRight,v.corner),e.appendChild(r);let i=document.createElement(`div`);i.classList.add(v.bottomLeft,v.corner),e.appendChild(i);let a=document.createElement(`div`);a.classList.add(v.bottomRight,v.corner),e.appendChild(a),this._innerContainer=e,this._manualContainer=t;let o=m();this._cornerNameToContainerLookup={"top-left":n,"top-right":r,"bottom-left":i,"bottom-right":a,"top-leading":o?r:n,"top-trailing":o?n:r,"bottom-leading":o?a:i,"bottom-trailing":o?i:a},this._positionNameToContainerLookup={manual:t,...this._cornerNameToContainerLookup}}_isValidPosition(e){return!!this._positionNameToContainerLookup[e]}_place(e){let t=e.position??`manual`,{component:n,index:r}=e,i=this._positionNameToContainerLookup[t],a=r!=null&&r>-1;if(y(n.widget)&&n.widget.startup(),!a){i.appendChild(n.node);return}let o=Array.from(i.children);if(o.length===0)i.appendChild(n.node);else{for(let e of o){let t=this._findByNode(e);if(t&&r<(this._componentMap.get(t)?.index??0)){e.parentNode?.insertBefore(n.node,e);return}}i.appendChild(n.node)}}_toPixelPosition(e){return{top:b(e.top),left:b(e.left),right:b(e.right),bottom:b(e.bottom)}}_findByComponent(e){return this._components.find(t=>t===e)??null}_findById(e){return this._components.find(({id:t})=>t===e)??null}_findByNode(e){return e?this._components.find(({node:t})=>t===e):null}_getComponentsAtPosition(e,t){let n=this._positionNameToContainerLookup[e];return Array.prototype.slice.call(n.children).map(e=>this._findByNode(e)).filter(i).filter(e=>t.includeInternal||!(this._componentMap.get(e)?.internal??!1)).map(({widget:e,node:t})=>e??t)}_getNumComponentsAtPosition(e){return this._positionNameToContainerLookup[e]?.children.length??0}};e([l()],C.prototype,`_locale`,void 0),e([l()],C.prototype,`container`,null),e([l()],C.prototype,`height`,null),e([l({value:g})],C.prototype,`padding`,null),e([u(`padding`)],C.prototype,`castPadding`,null),e([l()],C.prototype,`view`,void 0),e([l()],C.prototype,`width`,null),C=e([d(`esri.views.ui.UI`)],C);const w=C;export{w as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{getLocale as t,onLocaleChange as n}from"../../intl.js";import r from"../../core/Accessor.js";import{isSome as i}from"../../core/arrayUtils.js";import{EventedAccessor as a}from"../../core/Evented.js";import{makeHandle as o}from"../../core/handleUtils.js";import{watch as s,initial as c}from"../../core/reactiveUtils.js";import{property as l,cast as u,subclass as d}from"../../core/accessorSupport/decorators.js";import{setCalciteModeClass as f}from"../../support/modeUtils.js";import p from"./Component.js";import{isRTL as m}from"../../widgets/support/widget.js";const h={left:0,top:0,bottom:0,right:0},g={bottom:30,top:15,right:15,left:15},_=`esri-ui`,v={ui:_,corner:`${_}-corner`,innerContainer:`${_}-inner-container`,manualContainer:`${_}-manual-container`,cornerContainer:`${_}-corner-container`,topLeft:`${_}-top-left`,topRight:`${_}-top-right`,bottomLeft:`${_}-bottom-left`,bottomRight:`${_}-bottom-right`};function y(e){return e&&!e._started&&typeof e.postMixInProperties==`function`&&typeof e.buildRendering==`function`&&typeof e.postCreate==`function`&&typeof e.startup==`function`}function b(e){return e===0?`0`:`${e}px`}function x(e){let t=typeof e==`object`&&!!e&&Object.getPrototypeOf(e);return(t===null||t===Object.prototype)&&(`component`in e||`index`in e||`position`in e)?e:null}function S(e,{top:t,bottom:n,left:r,right:i}){e.style.top=t,e.style.bottom=n,e.style.left=r,e.style.right=i}let C=class extends a{constructor(e){super(e),this._cornerNameToContainerLookup={},this._positionNameToContainerLookup={},this._components=[],this._componentMap=new Map,this._removeWidgetHandleKey=Symbol(`componentOnRemoveSymbol`),this._locale=t(),this.view=null,this._applyViewPadding=()=>{let e=this.container;e&&S(e,this._toPixelPosition(this._getViewPadding()))},this._applyUIPadding=()=>{let e=this._innerContainer;e&&S(e,this._toPixelPosition(this.padding))},this._initContainers()}initialize(){this.addHandles([s(()=>[this.view?.padding,this.container],this._applyViewPadding,c),s(()=>this.padding,this._applyUIPadding,c),s(()=>[this.container,this._locale],([e,t])=>{e&&e.setAttribute(`lang`,t)},c),n(e=>{this._locale=e})])}destroy(){this.removeAllHandles(),this.container=null;for(let e of this._components.slice())e.node?.remove(),e.destroy();this._components.length=0,this._componentMap.clear(),this._innerContainer=null,this._manualContainer=null,this._cornerNameToContainerLookup={},this._positionNameToContainerLookup={},this.view=null,this._set(`view`,null)}set container(e){let t=this._get(`container`);e!==t&&(e&&(e.classList.add(v.ui),f(e),this._attachContainers(e)),t&&(t.classList.remove(v.ui),S(t,{top:``,bottom:``,left:``,right:``}),t.textContent=``),this._set(`container`,e))}get height(){let e=this.view?.height??0;if(e===0)return e;let{top:t,bottom:n}=this._getViewPadding();return Math.max(e-t-n,0)}get padding(){return this._get(`padding`)}set padding(e){this._overrideIfSome(`padding`,e)}castPadding(e){return typeof e==`number`?{bottom:e,top:e,right:e,left:e}:{...g,...e}}get width(){let e=this.view?.width??0;if(e===0)return e;let{left:t,right:n}=this._getViewPadding();return Math.max(e-t-n,0)}add(e,t){let n,r,i;if(Array.isArray(e)){e.forEach(e=>this.add(e,t));return}let a=x(e);a&&({index:n,position:t,component:e,key:r}=a),t&&typeof t==`object`&&({index:n,key:r,position:t,internal:i}=t),!(!e||t&&!this._isValidPosition(t))&&this._add(e,t,n??this._getNumComponentsAtPosition(t),r,i)}remove(e,t){if(!e)return;if(Array.isArray(e))return e.map(e=>this.remove(e,t));let n=this._find(e);if(n){let e=this._componentMap.get(n);if(!e||e.key!==t)return;let r=this._components.indexOf(n);return n.node.parentNode?.removeChild(n.node),this._componentMap.delete(n),n.widget?.removeHandlesReference(this._removeWidgetHandleKey),this._components.forEach(t=>{let n=this._componentMap.get(t);n&&n.position===e.position&&n.index>e.index&&n.index--}),this._components.splice(r,1)[0]}}empty(e,t={removeInternal:!1}){if(Array.isArray(e)){for(let n of e)this.empty(n,t);return}let n=this._positionNameToContainerLookup[e??`manual`],r=Array.prototype.slice.call(n.children).map(e=>this._findByNode(e)).filter(e=>e==null?!1:!(this._componentMap.get(e)?.internal??!1)||t.removeInternal);for(let e of r)this.remove(e)}move(e,t){if(Array.isArray(e)&&e.forEach(e=>this.move(e,t)),!e)return;let n,r=x(e)||x(t);if(r&&(n=r.index,t=r.position,e=r.component||e),t&&!this._isValidPosition(t))return;let i=this.remove(e);i&&this.add(i,{position:t,index:n})}find(e){if(!e)return null;let t=this._findById(e);return t&&(t.widget||t.node)}getComponents(e,t={includeInternal:!1}){return e?Array.isArray(e)?e.flatMap(e=>this._getComponentsAtPosition(e,t)):this._getComponentsAtPosition(e,t):this._components.filter(e=>t.includeInternal||!(this._componentMap.get(e)?.internal??!1)).map(({widget:e,node:t})=>e??t)}getPosition(e){for(let t in this._positionNameToContainerLookup)if(this._positionNameToContainerLookup[t].contains(e))return t;return null}_add(e,t,n,i,a){e instanceof p||(e=new p({node:e}));let{widget:s}=e;s!=null&&s instanceof r&&s.addHandles(o(()=>{queueMicrotask(()=>this.remove(e))}),this._removeWidgetHandleKey);let c=this._positionNameToContainerLookup[t];this._components.some(e=>{let t=this._componentMap.get(e)?.position,r=t?this._positionNameToContainerLookup[t]:null;return c===r&&this._componentMap.get(e)?.index===n})&&this._components.forEach(e=>{let t=this._componentMap.get(e),r=t?.position,i=r?this._positionNameToContainerLookup[r]:null;t&&i===c&&t.index>=n&&t.index++}),this._place({component:e,position:t,index:n}),this._components.push(e),this._componentMap.set(e,{key:i,position:t,internal:a,index:n})}_find(e){return e?e instanceof p?this._findByComponent(e):typeof e==`string`?this._findById(e):`domNode`in e?this._findByNode(e.domNode):this._findByNode(e):null}_getViewPadding(){return this.view?.padding??h}_attachContainers(e){e.appendChild(this._innerContainer),e.appendChild(this._manualContainer)}_initContainers(){let e=document.createElement(`div`);e.classList.add(v.innerContainer,v.cornerContainer);let t=document.createElement(`div`);t.classList.add(v.innerContainer,v.manualContainer);let n=document.createElement(`div`);n.classList.add(v.topLeft,v.corner),e.appendChild(n);let r=document.createElement(`div`);r.classList.add(v.topRight,v.corner),e.appendChild(r);let i=document.createElement(`div`);i.classList.add(v.bottomLeft,v.corner),e.appendChild(i);let a=document.createElement(`div`);a.classList.add(v.bottomRight,v.corner),e.appendChild(a),this._innerContainer=e,this._manualContainer=t;let o=m();this._cornerNameToContainerLookup={"top-left":n,"top-right":r,"bottom-left":i,"bottom-right":a,"top-leading":o?r:n,"top-trailing":o?n:r,"bottom-leading":o?a:i,"bottom-trailing":o?i:a},this._positionNameToContainerLookup={manual:t,...this._cornerNameToContainerLookup}}_isValidPosition(e){return!!this._positionNameToContainerLookup[e]}_place(e){let t=e.position??`manual`,{component:n,index:r}=e,i=this._positionNameToContainerLookup[t],a=r!=null&&r>-1;if(y(n.widget)&&n.widget.startup(),!a){i.appendChild(n.node);return}let o=Array.from(i.children);if(o.length===0)i.appendChild(n.node);else{for(let e of o){let t=this._findByNode(e);if(t&&r<(this._componentMap.get(t)?.index??0)){e.parentNode?.insertBefore(n.node,e);return}}i.appendChild(n.node)}}_toPixelPosition(e){return{top:b(e.top),left:b(e.left),right:b(e.right),bottom:b(e.bottom)}}_findByComponent(e){return this._components.find(t=>t===e)??null}_findById(e){return this._components.find(({id:t})=>t===e)??null}_findByNode(e){return e?this._components.find(({node:t})=>t===e):null}_getComponentsAtPosition(e,t){let n=this._positionNameToContainerLookup[e];return Array.prototype.slice.call(n.children).map(e=>this._findByNode(e)).filter(i).filter(e=>t.includeInternal||!(this._componentMap.get(e)?.internal??!1)).map(({widget:e,node:t})=>e??t)}_getNumComponentsAtPosition(e){return this._positionNameToContainerLookup[e]?.children.length??0}};e([l()],C.prototype,`_locale`,void 0),e([l()],C.prototype,`container`,null),e([l()],C.prototype,`height`,null),e([l({value:g})],C.prototype,`padding`,null),e([u(`padding`)],C.prototype,`castPadding`,null),e([l()],C.prototype,`view`,void 0),e([l()],C.prototype,`width`,null),C=e([d(`esri.views.ui.UI`)],C);const w=C;export{w as default};
|
|
@@ -16,7 +16,7 @@ ${o.join(`
|
|
|
16
16
|
`)}
|
|
17
17
|
${s.join(`
|
|
18
18
|
`)}`}generateBind(e){let t=new Map;this.vertex.uniforms.entries.forEach(e=>{let n=e.bind[0];n&&t.set(e.name,n)}),this.fragment.uniforms.entries.forEach(e=>{let n=e.bind[0];n&&t.set(e.name,n)});let n=Array.from(t.values()),r=n.length;return t=>{for(let i=0;i<r;++i)n[i](e,t)}}generateBindPass(e){let t=new Map;this.vertex.uniforms.entries.forEach(e=>{let n=e.bind[1];n&&t.set(e.name,n)}),this.fragment.uniforms.entries.forEach(e=>{let n=e.bind[1];n&&t.set(e.name,n)});let n=Array.from(t.values()),r=n.length;return(t,i)=>{for(let a=0;a<r;++a)n[a](e,i,t)}}generateBindDraw(e){let t=new Map;this.vertex.uniforms.entries.forEach(e=>{let n=e.bind[2];n&&t.set(e.name,n)}),this.fragment.uniforms.entries.forEach(e=>{let n=e.bind[2];n&&t.set(e.name,n)});let n=Array.from(t.values()),r=n.length;return(t,i,a)=>{for(let o=0;o<r;++o)n[o](e,a,t,i)}}}class a{constructor(e){this._stage=e,this._entries=new Map}add(...e){for(let t of e)this._add(t);return this._stage}get(e){return this._entries.get(e)}_add(t){if(t==null)n().error(`Trying to add null Uniform from ${Error().stack}.`);else{if(this._entries.has(t.name)&&!this._entries.get(t.name).equals(t))throw new e(`shaderbuilder:duplicate-uniform`,`Duplicate uniform name ${t.name} for different uniform type`);this._entries.set(t.name,t)}}generateSource(){return Array.from(this._entries.values()).map(({name:e,arraySize:t,type:n})=>t==null?`uniform ${n} ${e};`:`uniform ${n} ${e}[${t}];`)}get entries(){return Array.from(this._entries.values())}}class o{constructor(){this._entries=new Map}add(t,n){if(this._entries.has(t))throw new e(`shaderbuilder:duplicate-input`,`Duplicate input for ${t}`);this._entries.set(t,n)}get(t){let n=this._entries.get(t);if(n==null)throw new e(`shaderbuilder:input-resolver-error`,`No resolver for input ${t} found.`);return n()}}class s{constructor(e){this._stage=e,this._bodies=[]}add(e){return this._bodies.push(e),this._stage}generateSource(t){if(this._bodies.length>0){let e=[];for(let t of this._bodies)typeof t==`string`?e.push(t):e.push(...t());return[`void main() {\n ${e.join(`
|
|
19
|
-
`)||``} \n}`]}if(t)throw new e(`shaderbuilder:missing-main`,`Shader does not contain main function body.`);return[]}}class c{constructor(e){this._stage=e,this._entries=[]}add(e){return this._entries.push(e),this._stage}generateSource(){let e=[];for(let t of this._entries)typeof t==`string`?e.push(t):e.push(...t());return e}}class l extends r{constructor(){super(...arguments),this.uniforms=new a(this),this.main=new s(this),this.code=new c(this),this.constants=new p(this),this.inputs=new o}get builder(){return this}}class u{constructor(){this._entries=[]}add(e,t){this._entries.push([e,t])}generateSource(e){return e===`fragment`?[]:this._entries.map(e=>`in ${e[1]} ${e[0]};`)}get names(){return this._entries.map(([e])=>e)}}class d{constructor(){this._entries=new Map}add(e,t,r){this._entries.has(e)?n().warn(`Ignoring duplicate varying ${t} ${e}`):this._entries.set(e,{type:t,invariant:r?.invariant??!1})}generateSource(e){let t=[];return this._entries.forEach((n,r)=>t.push((n.invariant&&e===`vertex`?`invariant `:``)+(n.
|
|
19
|
+
`)||``} \n}`]}if(t)throw new e(`shaderbuilder:missing-main`,`Shader does not contain main function body.`);return[]}}class c{constructor(e){this._stage=e,this._entries=[]}add(e){return this._entries.push(e),this._stage}generateSource(){let e=[];for(let t of this._entries)typeof t==`string`?e.push(t):e.push(...t());return e}}class l extends r{constructor(){super(...arguments),this.uniforms=new a(this),this.main=new s(this),this.code=new c(this),this.constants=new p(this),this.inputs=new o}get builder(){return this}}class u{constructor(){this._entries=[]}add(e,t){this._entries.push([e,t])}generateSource(e){return e===`fragment`?[]:this._entries.map(e=>`in ${e[1]} ${e[0]};`)}get names(){return this._entries.map(([e])=>e)}}class d{constructor(){this._entries=new Map}add(e,t,r){this._entries.has(e)?n().warn(`Ignoring duplicate varying ${t} ${e}`):this._entries.set(e,{type:t,flat:r?.flat??!1,invariant:r?.invariant??!1})}generateSource(e){let t=[];return this._entries.forEach((n,r)=>t.push((n.invariant&&e===`vertex`?`invariant `:``)+(n.flat?`flat `:``)+(e===`vertex`?`out`:`in`)+` ${n.type} ${r};`)),t}}class f{constructor(){this._entries=new Map}add(e,t,r=0){let i=this._entries.get(r);i?.name===e&&i?.type===t?n().warn(`Fragment shader output location ${r} occupied`):this._entries.set(r,{name:e,type:t})}static{this.DEFAULT_TYPE=`vec4`}static{this.DEFAULT_NAME=`fragColor`}generateSource(e){if(e===`vertex`)return[];this._entries.size===0&&this._entries.set(0,{name:f.DEFAULT_NAME,type:f.DEFAULT_TYPE});let t=[];return this._entries.forEach((e,n)=>t.push(`layout(location = ${n}) out ${e.type} ${e.name};`)),t}}class p{constructor(e){this._stage=e,this._entries=new Set}add(e,t,n){let r=`ERROR_CONSTRUCTOR_STRING`;switch(t){case`float`:r=p._numberToFloatStr(n);break;case`int`:r=p._numberToIntStr(n);break;case`uint`:r=p._numberToUintStr(n);break;case`bool`:r=n.toString();break;case`vec2`:r=`vec2(${p._numberToFloatStr(n[0])},\
|
|
20
20
|
${p._numberToFloatStr(n[1])})`;break;case`vec3`:r=`vec3(${p._numberToFloatStr(n[0])},\
|
|
21
21
|
${p._numberToFloatStr(n[1])},\
|
|
22
22
|
${p._numberToFloatStr(n[2])})`;break;case`vec4`:r=`vec4(${p._numberToFloatStr(n[0])},\
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{deprecateUnnecessaryViewModel as t}from"../../core/deprecate.js";import{EventedAccessor as n}from"../../core/Evented.js";import{makeHandle as r}from"../../core/handleUtils.js";import i from"../../core/Logger.js";import{removeMaybe as a}from"../../core/maybe.js";import{when as o,initial as s,watch as c,on as l,syncAndInitial as u}from"../../core/reactiveUtils.js";import{schedule as d}from"../../core/scheduling.js";import{truncateLocalTime as f,isValidDate as p,resetUTCDate as m,offsetDate as h}from"../../core/timeUtils.js";import{property as g,subclass as _}from"../../core/accessorSupport/decorators.js";import v from"../../views/3d/environment/SunLighting.js";import y from"../../views/3d/environment/VirtualLighting.js";import{positionToTimezoneInfo as b}from"../../views/3d/support/earthUtils.js";import{dateTimeToSliderPos as x,sliderPosToDateTime as S,getSeasonFromDate as C,getNorthernHemisphereSeason as w,getSeasonDate as T,calculatePlaySpeed as E}from"./support/daylightUtils.js";import{SliderWithDropdownViewModel as D}from"./support/SliderWithDropdownViewModel.js";import{formatSliderLabel as O,getSunriseAndSunsetTimes as k}from"../support/timeWidgetUtils.js";let A=class extends n{constructor(e){super(e),this.view=null,this.timeSliderViewModel=new D({suppressDeprecationWarning:!0,min:0,max:1439,values:[0],labelFormatFunction:O,inputFormatFunction:O}),this.lightingUpdateInterval=200,this._oldLighting=null,this.playSpeedMultiplier=1,this._lastTime=null,this._sunrise=null,this._sunset=null,this._cachedLightingDateUTC=new Date(0),this._cachedDisplayUTCOffset=0,this._lastLightingUpdate=0,this._lightingUpdateHandle=null,e?.suppressDeprecationWarning||t(i.getLogger(this),`Daylight`,`arcgis-daylight`,{version:`4.34`})}normalizeCtorArgs(e={}){let{suppressDeprecationWarning:t,...n}=e;return n}initialize(){this.addHandles([o(()=>this.view,e=>e.when(()=>this._updateLighting()),s),c(()=>{let e=this._lighting;return e?.type===`sun`?e.date:null},e=>this._scheduleLightingUpdate(e)),l(()=>this._lighting,`timezone-will-change`,e=>this._timezoneWillChange(e),{onListenerAdd:()=>this._timezoneWillChange(null)}),c(()=>this.view?.stationary===!0,()=>{(this.dayPlaying||this.yearPlaying)&&this._updateSunriseAndSunset()},s),c(()=>{let e=this.timeSliderViewModel;return{vm:e,state:e.state,sliderPosition:this.timeSliderPosition}},({vm:e,state:t,sliderPosition:n})=>{t===`ready`&&e.setValue(0,n)}),c(()=>this.timeSliderViewModel?.utcOffset,e=>{e!=null&&(this.utcOffset=e)}),c(()=>({utcOffset:this.utcOffset,sliderViewModel:this.timeSliderViewModel}),({utcOffset:e,sliderViewModel:t})=>{t&&(t.utcOffset=e)},u),c(()=>this.timeSliderViewModel.timezonePickerOpen,()=>this.stopPlaying()),c(()=>this.timeSliderViewModel.values,e=>this._setTimeSliderPosition(e?.[0]??0,{forceLightingUpdate:!1}))])}destroy(){this._cancelLightingUpdate(),this.view=null}get isSupported(){return this.view==null||this.view.type===`3d`}get utcOffset(){return this._cachedDisplayUTCOffset}set utcOffset(e){e!==this.utcOffset&&this._lighting!=null&&this._lighting.type!==`virtual`&&(this._lighting.displayUTCOffset=e,this._updateLighting())}get localDate(){return f(this._lightingDateDisplay)}set localDate(e){this.view?.ready?p(e)&&e.getTime()!==this.localDate.getTime()&&(this._lightingDateDisplay=m(this._lightingDateDisplay,e)):i.getLogger(this).error(`The localDate property cannot be set before the view and the widget are ready.`)}get timeSliderPosition(){return x(this._lightingDateDisplay)}set timeSliderPosition(e){!this.view?.ready||this.timeSliderViewModel?.state!==`ready`?i.getLogger(this).error(`The timeSliderPosition property cannot be set before the view and the widget are ready.`):this._setTimeSliderPosition(e,{forceLightingUpdate:!0})}_setTimeSliderPosition(e,t){Math.abs(e-this.timeSliderPosition)<=1/60||(this.stopPlaying(),this._onUserDateTimeChange(),t.forceLightingUpdate&&(this._cancelLightingUpdate(),this._updateLighting()),this._lightingDateDisplay=S(this._lightingDateDisplay,e))}_timezoneFromCamera(e,t){if(t==null||!e.cameraTrackingEnabled)return 0;let n=b([t.longitude,t.latitude]);return n==null?0:Math.round(n.hours+n.minutes/60+n.seconds/3600)}get directShadowsEnabled(){return this._lighting?.directShadowsEnabled??!1}set directShadowsEnabled(e){let t=this._lighting;t&&(t.directShadowsEnabled=e)}get sunLightingEnabled(){return this._lightingType===`sun`}set sunLightingEnabled(e){let t=this._environment;if(e===this._get(`sunLightingEnabled`)||t==null)return;let n=t.lighting,r=this._oldLighting;this._oldLighting=n;let i={directShadowsEnabled:n.directShadowsEnabled,cameraTrackingEnabled:n.cameraTrackingEnabled},a=e?`sun`:`virtual`,o;o=r!=null&&r.type===a?r:e?new v:new y,o.set(i),t.lighting=o,e||(this.stopPlaying(),this.timeSliderViewModel.timezonePickerOpen=!1)}set playingState(e){this.playingState!==e&&(this._set(`playingState`,e),e!==`none`&&this.sunLightingEnabled&&(this._updateSunriseAndSunset(),this._lastTime=Date.now(),this._play(),this._onUserDateTimeChange()))}get dayPlaying(){return this.playingState===`day`}set dayPlaying(e){e?this.playingState=`day`:this.dayPlaying&&(this.playingState=`none`)}get yearPlaying(){return this.playingState===`year`}set yearPlaying(e){e?this.playingState=`year`:this.yearPlaying&&(this.playingState=`none`)}get currentSeason(){return C(this.localDate,this._currentHemisphere)}set currentSeason(e){this.stopPlaying(),this._onUserDateTimeChange();let t=w(e,this._currentHemisphere);this.localDate=T(this.localDate,t,0)}get _currentHemisphere(){let e=this.view?.camera?.position?.latitude;return e==null||e>=0?0:1}get _environment(){return this.view?.environment}get _lighting(){return this._environment?.lighting}get _lightingType(){return this._lighting?.type}get _lightingDateDisplay(){return h(this._cachedLightingDateUTC,this._cachedDisplayUTCOffset,`hours`)}set _lightingDateDisplay(e){let t=this._lighting;if(t==null||!this.sunLightingEnabled||t.type===`virtual`||!p(e))return;let n=t.date,r=h(e,-this._cachedDisplayUTCOffset,`hours`);r.getTime()!==n.getTime()&&(t.date=r,this._updateLighting())}stopPlaying(){this.playingState=`none`}toggleDayPlaying(){this.dayPlaying=!this.dayPlaying}toggleYearPlaying(){this.yearPlaying=!this.yearPlaying}toggleSunLightingEnabled(){this.stopPlaying(),this.sunLightingEnabled=!this.sunLightingEnabled}toggleDirectShadowsEnabled(){this.stopPlaying(),this.directShadowsEnabled=!this.directShadowsEnabled}onDateChange(e){this.dayPlaying=!1,this.localDate=e,this._onUserDateTimeChange()}_updateLighting(e){let t=Date.now();this._lastLightingUpdate=t;let{view:n}=this,r=this._lighting;if(n==null||r==null||r.type===`virtual`)return;e??=r.date;let i=r.displayUTCOffset??this._timezoneFromCamera(r,n.camera?.position);this._cachedLightingDateUTC.getTime()!==e.getTime()&&(this._cachedLightingDateUTC=new Date(e)),this._cachedDisplayUTCOffset!==i&&(this._cachedDisplayUTCOffset=i)}_timezoneWillChange(e){let t=this._lighting;if(t==null||t.type===`virtual`||!t.cameraTrackingEnabled)return;let n;if(e)n=e.timezoneOffset;else{if(t.displayUTCOffset!=null)return;n=v.calculateTimezoneOffset(t.positionTimezoneInfo)}t.displayUTCOffset=n,this._scheduleLightingUpdate()}_scheduleLightingUpdate(e){if(e&&(this._lightingUpdateHandle=a(this._lightingUpdateHandle),!p(e))||this._lightingUpdateHandle)return;let t=Date.now()-this._lastLightingUpdate,n=this.lightingUpdateInterval-t,i=null,o=()=>{this._updateLighting(e),this._lightingUpdateHandle===i&&(this._lightingUpdateHandle=null)};if(n<=0)this._lightingUpdateHandle=i=d(o);else{let e=setTimeout(o,n);this._lightingUpdateHandle=i=r(()=>clearTimeout(e))}}_cancelLightingUpdate(){this._lightingUpdateHandle=a(this._lightingUpdateHandle)}_play(){let e=this._lighting;if(e==null||!this.sunLightingEnabled||e.type===`virtual`)return;let t=e.date;if(this.dayPlaying||this.yearPlaying){let n=Date.now()-(this._lastTime??0);if(this.dayPlaying){this._lastTime=Date.now();let r=E(this._sunrise,this._sunset,t)*this.playSpeedMultiplier/100*n;if(r>0){let n=new Date(t.getTime()+r),i=e.displayUTCOffset??0;((n.getUTCHours()+i)%24+24)%24<((t.getUTCHours()+i)%24+24)%24&&(n=new Date(t.getTime()+r-864e5)),e.date=n}}else if(n>1e3){this._lastTime=Date.now();let n=(t.getUTCMonth()+1)%12,r=new Date(t);r.setUTCMonth(n),e.date=r}requestAnimationFrame(()=>this._play())}}_updateSunriseAndSunset(){let e=this._lighting;if(e==null||e.type===`virtual`||!this.sunLightingEnabled)return;let t=this.view?.camera?.position;if(t==null)return;let{latitude:n,longitude:r}=t,{date:i,displayUTCOffset:a}=e,o=k(i,n,r,a??0);o&&(this._sunrise=new Date(o.sunrise),this._sunset=new Date(o.sunset))}_onUserDateTimeChange(){this.emit(`user-date-time-change`,{})}};e([g()],A.prototype,`view`,void 0),e([g({type:D,nonNullable:!0})],A.prototype,`timeSliderViewModel`,void 0),e([g()],A.prototype,`isSupported`,null),e([g()],A.prototype,`lightingUpdateInterval`,void 0),e([g()],A.prototype,`utcOffset`,null),e([g({type:Date})],A.prototype,`localDate`,null),e([g()],A.prototype,`timeSliderPosition`,null),e([g()],A.prototype,`directShadowsEnabled`,null),e([g()],A.prototype,`sunLightingEnabled`,null),e([g({type:[`none`,`day`,`year`],value:`none`})],A.prototype,`playingState`,null),e([g()],A.prototype,`dayPlaying`,null),e([g()],A.prototype,`yearPlaying`,null),e([g()],A.prototype,`playSpeedMultiplier`,void 0),e([g()],A.prototype,`currentSeason`,null),e([g()],A.prototype,`_lastTime`,void 0),e([g()],A.prototype,`_sunrise`,void 0),e([g()],A.prototype,`_sunset`,void 0),e([g()],A.prototype,`_cachedLightingDateUTC`,void 0),e([g()],A.prototype,`_cachedDisplayUTCOffset`,void 0),e([g()],A.prototype,`_currentHemisphere`,null),e([g()],A.prototype,`_environment`,null),e([g()],A.prototype,`_lighting`,null),e([g()],A.prototype,`_lightingType`,null),e([g()],A.prototype,`_lightingDateDisplay`,null),A=e([_(`esri.widgets.Daylight.DaylightViewModel`)],A);const j=A;export{j as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{deprecateUnnecessaryViewModel as t}from"../../core/deprecate.js";import{EventedAccessor as n}from"../../core/Evented.js";import{makeHandle as r}from"../../core/handleUtils.js";import i from"../../core/Logger.js";import{removeMaybe as a}from"../../core/maybe.js";import{when as o,initial as s,watch as c,on as l,syncAndInitial as u}from"../../core/reactiveUtils.js";import{schedule as d}from"../../core/scheduling.js";import{truncateLocalTime as f,isValidDate as p,resetUTCDate as m,offsetDate as h}from"../../core/timeUtils.js";import{property as g,subclass as _}from"../../core/accessorSupport/decorators.js";import v from"../../views/3d/environment/SunLighting.js";import y from"../../views/3d/environment/VirtualLighting.js";import{positionToTimezoneInfo as b}from"../../views/3d/support/earthUtils.js";import{dateTimeToSliderPos as x,sliderPosToDateTime as S,getSeasonFromDate as C,getNorthernHemisphereSeason as w,getSeasonDate as T,calculatePlaySpeed as E}from"./support/daylightUtils.js";import{SliderWithDropdownViewModel as D}from"./support/SliderWithDropdownViewModel.js";import{formatSliderLabel as O,getSunriseAndSunsetTimes as k}from"../support/timeWidgetUtils.js";let A=class extends n{constructor(e){super(e),this.view=null,this.timeSliderViewModel=new D({suppressDeprecationWarning:!0,min:0,max:1439,values:[0],labelFormatFunction:O,inputFormatFunction:O}),this.lightingUpdateInterval=200,this._oldLighting=null,this.playSpeedMultiplier=1,this._lastTime=null,this._sunrise=null,this._sunset=null,this._cachedLightingDateUTC=new Date(0),this._cachedDisplayUTCOffset=0,this._lastLightingUpdate=0,this._lightingUpdateHandle=null,e?.suppressDeprecationWarning||t(i.getLogger(this),`Daylight`,`arcgis-daylight`,{version:`4.34`})}normalizeCtorArgs(e={}){let{suppressDeprecationWarning:t,...n}=e;return n}initialize(){this.addHandles([o(()=>this.view,e=>e.when(()=>this._updateLighting()),s),c(()=>{let e=this._lighting;return e?.type===`sun`?e.date:null},e=>this._scheduleLightingUpdate(e)),l(()=>this._lighting,`timezone-will-change`,e=>this._timezoneWillChange(e),{onListenerAdd:()=>this._timezoneWillChange(null)}),c(()=>this.view?.stationary===!0,()=>{(this.dayPlaying||this.yearPlaying)&&this._updateSunriseAndSunset()},s),c(()=>{let e=this.timeSliderViewModel;return{vm:e,state:e.state,sliderPosition:this.timeSliderPosition}},({vm:e,state:t,sliderPosition:n})=>{t===`ready`&&e.setValue(0,n)}),c(()=>this.timeSliderViewModel?.utcOffset,e=>{e!=null&&(this.utcOffset=e)}),c(()=>({utcOffset:this.utcOffset,sliderViewModel:this.timeSliderViewModel}),({utcOffset:e,sliderViewModel:t})=>{t&&(t.utcOffset=e)},u),c(()=>this.timeSliderViewModel.timezonePickerOpen,()=>this.stopPlaying()),c(()=>this.timeSliderViewModel.values,e=>this._setTimeSliderPosition(e?.[0]??0,{forceLightingUpdate:!1}))])}destroy(){this._cancelLightingUpdate(),this.view=null}get isSupported(){return this.view==null||this.view.type===`3d`}get utcOffset(){return this._cachedDisplayUTCOffset}set utcOffset(e){e!==this.utcOffset&&this._lighting!=null&&this._lighting.type!==`virtual`&&(this._lighting.displayUTCOffset=e,this._updateLighting())}get localDate(){return f(this._lightingDateDisplay)}set localDate(e){this.view?.ready?p(e)&&e.getTime()!==this.localDate.getTime()&&(this._lightingDateDisplay=m(this._lightingDateDisplay,e)):i.getLogger(this).error(`The localDate property cannot be set before the view and the widget are ready.`)}get timeSliderPosition(){return x(this._lightingDateDisplay)}set timeSliderPosition(e){!this.view?.ready||this.timeSliderViewModel?.state!==`ready`?i.getLogger(this).error(`The timeSliderPosition property cannot be set before the view and the widget are ready.`):this._setTimeSliderPosition(e,{forceLightingUpdate:!0})}_setTimeSliderPosition(e,t){Math.abs(e-this.timeSliderPosition)<=1/60||(this.stopPlaying(),this._onUserDateTimeChange(),t.forceLightingUpdate&&(this._cancelLightingUpdate(),this._updateLighting()),this._lightingDateDisplay=S(this._lightingDateDisplay,e))}_timezoneFromCamera(e,t){if(t==null||!e.cameraTrackingEnabled)return 0;let n=b([t.longitude,t.latitude]);return n==null?0:Math.round(n.hours+n.minutes/60+n.seconds/3600)}get directShadowsEnabled(){return this._lighting?.directShadowsEnabled??!1}set directShadowsEnabled(e){let t=this._lighting;t&&(t.directShadowsEnabled=e)}get sunLightingEnabled(){return this._lightingType===`sun`}set sunLightingEnabled(e){let t=this._environment;if(e===this._get(`sunLightingEnabled`)||t==null)return;let n=t.lighting,r=this._oldLighting;this._oldLighting=n;let i={directShadowsEnabled:n.directShadowsEnabled,cameraTrackingEnabled:n.cameraTrackingEnabled,globalIllumination:n.globalIllumination},a=e?`sun`:`virtual`,o;o=r!=null&&r.type===a?r:e?new v:new y,o.set(i),t.lighting=o,e||(this.stopPlaying(),this.timeSliderViewModel.timezonePickerOpen=!1)}set playingState(e){this.playingState!==e&&(this._set(`playingState`,e),e!==`none`&&this.sunLightingEnabled&&(this._updateSunriseAndSunset(),this._lastTime=Date.now(),this._play(),this._onUserDateTimeChange()))}get dayPlaying(){return this.playingState===`day`}set dayPlaying(e){e?this.playingState=`day`:this.dayPlaying&&(this.playingState=`none`)}get yearPlaying(){return this.playingState===`year`}set yearPlaying(e){e?this.playingState=`year`:this.yearPlaying&&(this.playingState=`none`)}get currentSeason(){return C(this.localDate,this._currentHemisphere)}set currentSeason(e){this.stopPlaying(),this._onUserDateTimeChange();let t=w(e,this._currentHemisphere);this.localDate=T(this.localDate,t,0)}get _currentHemisphere(){let e=this.view?.camera?.position?.latitude;return e==null||e>=0?0:1}get _environment(){return this.view?.environment}get _lighting(){return this._environment?.lighting}get _lightingType(){return this._lighting?.type}get _lightingDateDisplay(){return h(this._cachedLightingDateUTC,this._cachedDisplayUTCOffset,`hours`)}set _lightingDateDisplay(e){let t=this._lighting;if(t==null||!this.sunLightingEnabled||t.type===`virtual`||!p(e))return;let n=t.date,r=h(e,-this._cachedDisplayUTCOffset,`hours`);r.getTime()!==n.getTime()&&(t.date=r,this._updateLighting())}stopPlaying(){this.playingState=`none`}toggleDayPlaying(){this.dayPlaying=!this.dayPlaying}toggleYearPlaying(){this.yearPlaying=!this.yearPlaying}toggleSunLightingEnabled(){this.stopPlaying(),this.sunLightingEnabled=!this.sunLightingEnabled}toggleDirectShadowsEnabled(){this.stopPlaying(),this.directShadowsEnabled=!this.directShadowsEnabled}onDateChange(e){this.dayPlaying=!1,this.localDate=e,this._onUserDateTimeChange()}_updateLighting(e){let t=Date.now();this._lastLightingUpdate=t;let{view:n}=this,r=this._lighting;if(n==null||r==null||r.type===`virtual`)return;e??=r.date;let i=r.displayUTCOffset??this._timezoneFromCamera(r,n.camera?.position);this._cachedLightingDateUTC.getTime()!==e.getTime()&&(this._cachedLightingDateUTC=new Date(e)),this._cachedDisplayUTCOffset!==i&&(this._cachedDisplayUTCOffset=i)}_timezoneWillChange(e){let t=this._lighting;if(t==null||t.type===`virtual`||!t.cameraTrackingEnabled)return;let n;if(e)n=e.timezoneOffset;else{if(t.displayUTCOffset!=null)return;n=v.calculateTimezoneOffset(t.positionTimezoneInfo)}t.displayUTCOffset=n,this._scheduleLightingUpdate()}_scheduleLightingUpdate(e){if(e&&(this._lightingUpdateHandle=a(this._lightingUpdateHandle),!p(e))||this._lightingUpdateHandle)return;let t=Date.now()-this._lastLightingUpdate,n=this.lightingUpdateInterval-t,i=null,o=()=>{this._updateLighting(e),this._lightingUpdateHandle===i&&(this._lightingUpdateHandle=null)};if(n<=0)this._lightingUpdateHandle=i=d(o);else{let e=setTimeout(o,n);this._lightingUpdateHandle=i=r(()=>clearTimeout(e))}}_cancelLightingUpdate(){this._lightingUpdateHandle=a(this._lightingUpdateHandle)}_play(){let e=this._lighting;if(e==null||!this.sunLightingEnabled||e.type===`virtual`)return;let t=e.date;if(this.dayPlaying||this.yearPlaying){let n=Date.now()-(this._lastTime??0);if(this.dayPlaying){this._lastTime=Date.now();let r=E(this._sunrise,this._sunset,t)*this.playSpeedMultiplier/100*n;if(r>0){let n=new Date(t.getTime()+r),i=e.displayUTCOffset??0;((n.getUTCHours()+i)%24+24)%24<((t.getUTCHours()+i)%24+24)%24&&(n=new Date(t.getTime()+r-864e5)),e.date=n}}else if(n>1e3){this._lastTime=Date.now();let n=(t.getUTCMonth()+1)%12,r=new Date(t);r.setUTCMonth(n),e.date=r}requestAnimationFrame(()=>this._play())}}_updateSunriseAndSunset(){let e=this._lighting;if(e==null||e.type===`virtual`||!this.sunLightingEnabled)return;let t=this.view?.camera?.position;if(t==null)return;let{latitude:n,longitude:r}=t,{date:i,displayUTCOffset:a}=e,o=k(i,n,r,a??0);o&&(this._sunrise=new Date(o.sunrise),this._sunset=new Date(o.sunset))}_onUserDateTimeChange(){this.emit(`user-date-time-change`,{})}};e([g()],A.prototype,`view`,void 0),e([g({type:D,nonNullable:!0})],A.prototype,`timeSliderViewModel`,void 0),e([g()],A.prototype,`isSupported`,null),e([g()],A.prototype,`lightingUpdateInterval`,void 0),e([g()],A.prototype,`utcOffset`,null),e([g({type:Date})],A.prototype,`localDate`,null),e([g()],A.prototype,`timeSliderPosition`,null),e([g()],A.prototype,`directShadowsEnabled`,null),e([g()],A.prototype,`sunLightingEnabled`,null),e([g({type:[`none`,`day`,`year`],value:`none`})],A.prototype,`playingState`,null),e([g()],A.prototype,`dayPlaying`,null),e([g()],A.prototype,`yearPlaying`,null),e([g()],A.prototype,`playSpeedMultiplier`,void 0),e([g()],A.prototype,`currentSeason`,null),e([g()],A.prototype,`_lastTime`,void 0),e([g()],A.prototype,`_sunrise`,void 0),e([g()],A.prototype,`_sunset`,void 0),e([g()],A.prototype,`_cachedLightingDateUTC`,void 0),e([g()],A.prototype,`_cachedDisplayUTCOffset`,void 0),e([g()],A.prototype,`_currentHemisphere`,null),e([g()],A.prototype,`_environment`,null),e([g()],A.prototype,`_lighting`,null),e([g()],A.prototype,`_lightingType`,null),e([g()],A.prototype,`_lightingDateDisplay`,null),A=e([_(`esri.widgets.Daylight.DaylightViewModel`)],A);const j=A;export{j as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{createTask as n}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import a from"../../core/Logger.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{watch as s,initial as c,syncAndInitial as l}from"../../core/reactiveUtils.js";import{Milliseconds as u}from"../../core/time.js";import{isBlobProtocol as d}from"../../core/urlUtils.js";import{property as f,subclass as p}from"../../core/accessorSupport/decorators.js";import m from"../../geometry/Polygon.js";import h from"../../webdoc/Widgets.js";import g from"../../webdoc/widgets/FloorFilter.js";import{isWebMap as _}from"../../webmap/utils.js";import{GoTo as v}from"../support/GoTo.js";function y(e){return e.declaredClass===`esri.WebScene`}let b=class extends v(t){constructor(e){super(e),this.filterMenuOpen=!1,this.filterMenuType=`site`,this.filterMode=`base-floors`,this.levelsExpanded=!0,this.searchTerm=null,this.view=null,this._updateFloorFilterTask=null,this._viewHeightBreakpoint=null,this._viewWidthBreakpoint=null}initialize(){this.addHandles([s(()=>this.view?.map,e=>{this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=n(async t=>{await this._updateFloorFilterFromMap(e),o(t),this._setInitialViewState(e)})},c),s(()=>this.view,(e,t)=>{this._unregisterWidget(t),this._registerWidget(e),this._watchSearchResults(e)},l),s(()=>this.mediaLayer,e=>{this._watchLayerVisibility(e)},l),s(()=>this.view?.widthBreakpoint??null,e=>{this._viewWidthBreakpoint=e}),s(()=>this.view?.heightBreakpoint??null,e=>{this._viewHeightBreakpoint=e}),s(()=>this.facility,()=>void this.getOverlays()),s(()=>this.level,e=>this._updateMediaLayer(e))])}destroy(){if(this._unregisterWidget(this.view),this.mediaLayer&&this.view?.map.remove(this.mediaLayer),this.overlaysByLevel){for(let e of this.overlaysByLevel.values()){let t=e.image.image;d(t)&&URL.revokeObjectURL(t)}this.overlaysByFacility?.clear(),this.overlaysByLevel.clear()}this.view=null,this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null)}set enabled(e){this._callOverride(`enabled`,e)}set facility(e){if(e&&this._isOverridden(`facility`)){let t=this.getFacility(e);this.hasMultipleSites&&(this.site=t?.siteId||null)}this._callOverride(`facility`,e)}set filterFeatures(e){this._callOverride(`filterFeatures`,e)}set filterLayers(e){this._callOverride(`filterLayers`,e)}get floorVisibilityMode(){return this.view&&y(this.view?.map)?this.view.map.widgets?.floorFilter?.floorVisibilityMode??`belowSelected`:`belowSelected`}get hasFacilities(){return this.filterLayers?.facilityLayer!=null&&this.filterFeatures?.facilities?.facilitiesInfo?.length>0}get hasLevels(){return this.filterLayers?.levelLayer!=null&&this.filterFeatures?.levels?.levelsInfo?.length>0}get hasMultipleSites(){return this.filterLayers?.siteLayer!=null&&this.filterFeatures?.sites?.sitesInfo?.length>1}get isNormalMode(){let e=!0,t=this._viewWidthBreakpoint;return(this._viewHeightBreakpoint===`xsmall`||t===`xsmall`)&&(e=!1),e}set level(e){if(!e){this._callOverride(`level`,e),this.facility=null,this.site=null,this.setFloors(null);return}let t=null,n=null,r=e?.split(`--`);r?.length>1&&r[0]===`all`?(n=r[1],t={id:e,facilityId:n,shortName:null,longName:null,levelNumber:null,verticalOrder:null}):(t=this.getLevel(e),n=t?.facilityId??null),this.level===e&&!this.isNormalMode&&!this.levelsExpanded?this.getFacilityLevels(n)?.length>1&&(this.levelsExpanded=!0):(t&&this.hasFacilities&&this.hasLevels?(this.facility=n,this.hasMultipleSites&&(this.site=this.getFacility(n)?.siteId||null),this.setFloors(t)):this._isOverridden(`level`)&&(this.facility=null,this.site=null,this.hasMultipleSites&&(this.filterMenuType=`site`),this.setFloors(null)),this._callOverride(`level`,e))}set longNames(e){this._callOverride(`longNames`,e)}set minimized(e){this._callOverride(`minimized`,e)}set pinnedLevels(e){this._callOverride(`pinnedLevels`,e)}get selectedVerticalOrder(){return _(this.view?.map)?this.view.map.resourceInfo?.widgets?.floorFilter?.selectedVerticalOrder??null:null}set site(e){this._callOverride(`site`,e)}get state(){return this.view&&this.filterFeatures&&this.hasFacilities&&this.hasLevels?`ready`:this.view&&!this.filterFeatures?`loading`:`disabled`}get useVerticalOrder(){return this.view?.map==null?!1:_(this.view?.map)||y(this.view.map)?this.view.map.widgets?.floorFilter?.useVerticalOrder??!1:!1}filterFacilities(e){let t=e;return this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{let{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),this.site&&(t=t.filter(e=>e.siteId===this.site)),t.sort((e,t)=>{let n=e.name,r=t.name;return n.localeCompare(r,void 0,{sensitivity:`base`})})}filterSites(e){let t=e;return this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{let{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),t.sort((e,t)=>{let n=e.name,r=t.name;return n.localeCompare(r,void 0,{sensitivity:`base`})})}getBaseLevel(e){let t=this.filterFeatures?.levels?.levelsInfo,n=null;if(e){let{id:r}=e;if(t&&t.length>0&&(t.forEach(e=>{e.verticalOrder===0&&e.facilityId===r&&(n=e)}),!n)){let e=null;t.forEach(t=>{t.facilityId===r&&(e?(t.verticalOrder??0)>=0?e.verticalOrder!=null&&(e.verticalOrder<0||(t.verticalOrder??0)<e.verticalOrder)&&(e=t):e.verticalOrder!=null&&t.verticalOrder!=null&&e.verticalOrder<0&&t.verticalOrder>e.verticalOrder&&(e=t):e=t)}),e&&(n=e)}}return n}getFacility(e){return this.filterFeatures?.facilities?.facilitiesInfo?.find(t=>t.id===e)??null}getFacilityLevels(e){return!e||!this.filterFeatures?.levels?.levelsInfo?[]:this.filterFeatures.levels.levelsInfo.filter(t=>t.facilityId===e).sort((e,t)=>{let n=e.verticalOrder??0,r=t.verticalOrder??0;return n>r?-1:n===r?0:1})}getLevel(e){return this.filterFeatures?.levels?.levelsInfo?.find(t=>t.id===e)??null}async getOverlays(e=!1){let{facility:t,level:n,mediaLayer:i,overlaysByFacility:a,overlaysByLevel:o,view:s}=this;if(_(s?.map)&&i){if((i?.source).elements.removeAll(),t?.length&&(!a?.has(t)||e)){a?.set(t,new r);let e=s.map.floorInfo?.levelLayer?.layerId,n=s.map.findLayerById(e??``);if(!n||s.type!==`2d`)return;let i=await this._getAttachments(n,t),{default:c}=await import(`../../request.js`),l=Object.keys(i).map(async e=>{let r=i[e],s=r.find(e=>e.contentType===`application/json`);if(!s?.url)return;let l=new URL(s.url);n.gdbVersion?.length&&l.searchParams.set(`gdbVersion`,n.gdbVersion);let{data:u}=await c(l.toString(),{responseType:`json`}),d=r.find(e=>e.name===u.name),f=d?.url??``;if(f?.length>0){let e=new URL(f);e.searchParams.delete(`token`),n.gdbVersion?.length&&e.searchParams.set(`gdbVersion`,n.gdbVersion);let{default:r}=await import(`../../layers/support/ControlPointsGeoreference.js`),i=r.fromJSON(u.georeference),c=await this.toImageElement(e.toString(),i,u.opacity,u.clipImage,u.geometry);await c.load();let l={...u,attachments:[s,d],facilityId:t,image:c,source:JSON.stringify(u),url:e.toString()};o?.set(l.levelId,l),a?.get(t)?.push(l)}});await Promise.all(l)}this._updateMediaLayer(n)}}getSite(e){return this.filterFeatures?.sites?.sitesInfo?.find(t=>t.id===e)??null}async goTo(e){let{view:t}=this;if(!t||!e)return;let{geometry:n}=e;if(n?.extent){let e=e=>{this.callGoTo({target:e,options:{duration:u(1e3),easing:`quad-in-out-coast`}})};if(n.hasZ&&n.spatialReference?.vcsWkid!==t.spatialReference?.vcsWkid){let{projectIsLoaded:r,projectLoad:i,projectExecute:a}=await import(`../../geometry/operators/projectOperator.js`);r()||await i();let o=a(n.extent,t.spatialReference.clone(),{zConversionDisabled:!0});o&&e(o)}else e(n.extent)}}setFloors(e){let{view:t}=this;t&&(t?.map?.allLayers?.forEach(e=>{e.type===`feature`&&this._computeViewAllModeFloors(e)}),t.floors=new r(this._computeFloors(e)))}async toImageElement(e,t,n,r,i){let{default:o}=await import(`../../layers/support/ImageElement.js`),{facility:s}=this,c=()=>new o({image:e,georeference:t,opacity:n});if(r)try{let r=i?m.fromJSON(i):this.getFacility(s)?.geometry;if(r==null)return c();let{pixelRings:a,width:l,height:u}=await this._polygonToImagePixels(t,r),d=await this._imagePolygonToBlob(e,a,l,u);return new o({image:URL.createObjectURL(d),georeference:t,opacity:n})}catch(e){return a.getLogger(this).warn(`Unable to clip image; using full image instead: ${e.message}`,e),c()}return c()}updateWebDocument(e){if(_(e)||y(e)){let t={enabled:this.enabled,longNames:this.longNames,minimized:this.minimized,pinnedLevels:this.pinnedLevels,site:this.site??null,facility:this.facility??null,level:this.level??null,useVerticalOrder:this.useVerticalOrder,selectedVerticalOrder:this.selectedVerticalOrder};y(e)&&(t.floorVisibilityMode=this.floorVisibilityMode);let n=new g(t);e.widgets??=new h,e.widgets.floorFilter=n}}_computeFloors(e){if(this.filterMode===`single-floor`)this._computeSingleFloor(e);else if(this.filterMode===`base-floors`)return this.view?.type===`3d`?this._computeBaseFloors3D(e):this._computeBaseFloors(e);return this._computeEmptyFloors()}_computeSingleFloor(e){if(!e)return this._computeEmptyFloors();let t=[];return e?.id===`all`?this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&t.push(e.id)}):e&&t.push(e.id),t}_computeBaseFloors(e){let t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();let n=[];e?.id===`all`?this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&n.push(e.id)}):e&&n.push(e.id);let r=e?.facilityId,i=e?.verticalOrder,a=(e,t)=>{e===0&&n.push(t)};return t.forEach(e=>{let{id:t,facilityId:o,verticalOrder:s}=e;!r&&!n.includes(t)?a(s,t):o!==r&&!n.includes(t)&&(this.useVerticalOrder?s===i&&n.push(t):a(s,t))}),n}_computeBaseFloors3D(e){let t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();let n=[],r=e?.id.split(`--`)??[],i=r?.length>1&&r[0]===`all`;i?this.getFacilityLevels(e?.facilityId).forEach(e=>{e.id&&n.push(e.id)}):e&&n.push(e.id);let a=e?.facilityId,o=e?.verticalOrder;return t.forEach(e=>{let{id:t,facilityId:r,verticalOrder:s}=e;if(!a&&!n.includes(t))n.push(t);else if(!n.includes(t)){let{floorVisibilityMode:e,useVerticalOrder:c}=this,l=s<=o;r===a?e===`belowSelected`&&l&&n.push(t):(i||!c||e===`selectedOnly`&&s===o||e===`belowSelected`&&l)&&n.push(t)}}),n}_computeEmptyFloors(){return[]}async _setFilterLayers(){let{view:e}=this;if(e&&!this._isOverridden(`filterLayers`)){if(!_(e.map)&&!y(e.map))throw new i(`floorfilter:unsupported-map`,`Map must be a webmap or webscene`);{let t=e.map,n=t?.allLayers;if(n?.items?.length>0){let e={siteLayer:null,facilityLayer:null,levelLayer:null},r=t.floorInfo?.siteLayer?.layerId,i=t.floorInfo?.facilityLayer?.layerId,a=t.floorInfo?.levelLayer?.layerId,o=t.floorInfo?.siteLayer?.sublayerId||t.floorInfo?.facilityLayer?.sublayerId||t.floorInfo?.levelLayer?.sublayerId;if(!i||!a)return;let s=n.items.filter(e=>e.type===`feature`||e.type===`scene`),c=n.items.filter(e=>e.type===`map-image`);if(c?.length>0&&o){await Promise.all(c.map(e=>e.load()));let n=t.floorInfo?.siteLayer?.sublayerId,o=t.floorInfo?.facilityLayer?.sublayerId,s=t.floorInfo?.levelLayer?.sublayerId;c.forEach(t=>{let c=t.id,l=t?.allSublayers,u=l?.items;(c===r||c===i||c===a)&&u?.length>0&&l.items.forEach(t=>{let i=t.id;c===r&&i===n?e.siteLayer=t:i===o?e.facilityLayer=t:i===s&&(e.levelLayer=t)})})}s?.length>0&&s.forEach(t=>{let n=t.id;n===r?e.siteLayer=t:n===i?e.facilityLayer=t:n===a&&(e.levelLayer=t)}),this.filterLayers=e}}}}async _getAttachments(e,t){let{view:n}=this;if(_(n?.map)){let{facilityIdField:r}=n.map.floorInfo?.levelLayer??{};if(e&&n.type===`2d`&&t?.length>0&&e.capabilities.data.supportsAttachment)return e.queryAttachments({returnMetadata:!0,where:`${r} = '${t}'`})}return{}}async _getFilterFeatures(){if(this._isOverridden(`filterFeatures`))return this.filterFeatures;let[e,t,n]=await Promise.all([this._getSites(),this._getFacilities(),this._getLevels()]);return{sites:e,facilities:t,levels:n}}async _getSites(){let e={sitesInfo:[]},{filterLayers:t,view:n}=this,r=n?.map,{siteLayer:i}=t;if(!i||!r?.floorInfo?.siteLayer)return e;let a=i.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0,`type`in i&&i.type===`scene`&&(a.multipatchOption=`xyFootprint`);let{siteIdField:o,nameField:s}=r.floorInfo.siteLayer,c=await i.queryFeatures(a);if(c?.features?.length>0){let t=c.features,n=i?.fieldsIndex.get(o)?.name||o,r=i?.fieldsIndex.get(s)?.name||s;n!=null&&r!=null&&t.forEach(t=>{let i=t.attributes,a=t.geometry,o=i[n],s=i[r];o&&s&&e.sitesInfo.push({id:o,name:s,geometry:a})})}return e}async _getFacilities(){let{filterLayers:e,view:t}=this,n=t?.map,{facilityLayer:r}=e,i={facilitiesInfo:[]};if(!r||!n?.floorInfo?.facilityLayer)return i;let a=r.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0,`type`in r&&r.type===`scene`&&(a.multipatchOption=`xyFootprint`);let{facilityIdField:o,siteIdField:s,nameField:c}=n.floorInfo.facilityLayer,l=await r.queryFeatures(a);if(l?.features?.length>0){let e=l.features,t=r?.fieldsIndex.get(o)?.name||o,n=r?.fieldsIndex.get(s)?.name||s,a=r?.fieldsIndex.get(c)?.name||c;t&&n&&a&&e.forEach(e=>{let r=e.attributes,o=e.geometry,s=r[t],c=r[n],l=r[a];s&&l&&i.facilitiesInfo.push({id:s,siteId:c,name:l,geometry:o})})}return i}async _getLevels(){let{filterLayers:e,view:t}=this,n=t?.map,{levelLayer:r}=e,i={levelsInfo:[]};if(!r||!n?.floorInfo?.levelLayer)return i;let a=r.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0;let{levelIdField:o,facilityIdField:s,longNameField:c,shortNameField:l,levelNumberField:u,verticalOrderField:d}=n.floorInfo.levelLayer,f=await r.queryFeatures(a);if(f?.features?.length>0){let e=f.features,t=r?.fieldsIndex.get(o)?.name||o,n=r?.fieldsIndex.get(s)?.name||s,a=r?.fieldsIndex.get(c)?.name||c,p=r?.fieldsIndex.get(l)?.name||l,m=r?.fieldsIndex.get(u)?.name||u,h=r?.fieldsIndex.get(d)?.name||d;t&&n&&a&&p&&m&&h&&e.forEach(e=>{let r=e.attributes,o=r[t],s=r[n],c=r[a],l=r[p],u=r[m],d=r[h];o&&s&&c&&l&&typeof u==`number`&&typeof d==`number`&&i.levelsInfo.push({id:o,facilityId:s,longName:c,shortName:l,levelNumber:u,verticalOrder:d})})}return i}async _imagePolygonToBlob(e,t,n,r){let{getImageData:a}=await import(`../../core/imageUtils.js`),o=await a(e),s=new OffscreenCanvas(n,r),c=s.getContext(`2d`);if(!c)throw new i(`floorfilter:floor-plan-overlay`,`Unable to obtain a rendering context from the canvas.`);let l=new Path2D;for(let e of t)if(!(e.length<3)){l.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++)l.lineTo(e[t].x,e[t].y);l.closePath()}return c.save(),c.clip(l,`evenodd`),c.drawImage(o,0,0,n,r),c.restore(),await s.convertToBlob({type:`image/png`})}async _polygonToImagePixels(e,t){if(e?.type!==`control-points`)throw new i(`floorfilter:floor-plan-overlay`,"Expected a `ControlPointsGeoreference`.");let{default:n}=await import(`../../geometry/Point.js`);return{pixelRings:t.rings.map(r=>r.map(([r,a])=>{let o=new n({x:r,y:a,spatialReference:t.spatialReference}),s=e.toSource(o);if(!s)throw new i(`floorfilter:floor-plan-overlay`,`toSource() returned null; check spatial references and projectOperator.`);return{x:s.x,y:s.y}})),width:e.width,height:e.height}}_registerWidget(e){e?.registerComponent(this)}_unregisterWidget(e){e?.unregisterComponent(this)}_watchLayerVisibility(e){if(this.filterLayers?.levelLayer?.type===`feature`&&e){let t=this.filterLayers?.levelLayer;this.addHandles(s(()=>t.visible,t=>{e.visible=t},l))}}_watchSearchResults(e){e?.on(`select-result-floor`,e=>{let t=this.getLevel(e);t&&this.level!==e&&(this.level=e,this.setFloors(t))})}async _setInitialViewState(e){if(this.view)try{await this.view.when(),await this._setFilterLayers();let t=await this._getFilterFeatures();if(!t)return;if(this.filterFeatures=t,!this.hasFacilities||!this.hasLevels){a.getLogger(this).error(`Facilities and Levels are required for the Floor Filter widget`);return}if(this.hasMultipleSites||(this.filterMenuType=`facility`),this.facility&&this.level){this.filterMenuType=`facility`;let e=this.getFacility(this.facility),t=this.getLevel(this.level);this.site||=e?.siteId||void 0,this.setFloors(t)}else if(this.facility&&!this.level){this.filterMenuType=`facility`;let e=this.getFacility(this.facility),t=this.getBaseLevel(e);this.site||=e?.siteId||void 0,this.level=t?.id||void 0,this.setFloors(t)}else if(!this.facility&&this.level){this.filterMenuType=`facility`;let e=this.getLevel(this.level),t=this.getFacility(e?.facilityId);this.facility=t?.id||void 0,this.site||=t?.siteId||void 0,this.setFloors(e)}else if(this.site&&!this.facility&&!this.level)this.filterMenuType=`site`,this.setFloors(null);else{if(!e||!_(e)){this.setFloors(null);return}let t=e?.widgets?.floorFilter;if(!t){this.setFloors(null);return}t.site&&!this.site&&(this.site=t.site,this.filterMenuType=`facility`),this.setFloors(null)}if(this.filterLayers?.levelLayer?.type===`feature`&&this.filterLayers.levelLayer.capabilities.data.supportsAttachment&&this.mediaLayer==null){let{levelLayer:e}=this.filterLayers,{default:t}=await import(`../../layers/MediaLayer.js`);this.mediaLayer=new t({blendMode:`normal`,listMode:`hide`,maxScale:e.maxScale,minScale:e.minScale,spatialReference:this.view.spatialReference.clone(),title:`floor-filter-media-layer`,visible:e.visible}),this.overlaysByFacility=new Map,this.overlaysByLevel=new Map,this.view.map.add(this.mediaLayer),this.getOverlays(!0)}}catch(e){a.getLogger(this).error(`Couldn't retrieve sites, facilities, and levels`,e)}}_callOverride(e,t){this._override(e,t)}async _updateFloorFilterFromMap(e){if(!e||!_(e))return;await this.view?.when();let t=e?.widgets?.floorFilter;t&&(this._isOverridden(`enabled`)||(this.enabled=t.enabled),this._isOverridden(`longNames`)||(this.longNames=t.longNames),this._isOverridden(`minimized`)||(this.minimized=t.minimized),this._isOverridden(`pinnedLevels`)||(this.pinnedLevels=t.pinnedLevels),this._isOverridden(`site`)||(this.site=t.site),this._isOverridden(`facility`)||(this.facility=t.facility),this._isOverridden(`level`)||(this.level=t.level))}_updateMediaLayer(e){let{mediaLayer:t,overlaysByLevel:n}=this;if(t&&n&&e?.length){let r=t.source;r.elements.removeAll(),n.get(e)?.visible===!0&&r.elements.push(n.get(e)?.image)}}_computeViewAllModeFloors(e){let{filterFeatures:t}=this;if(e.floorInfo?.viewAllMode&&this.hasLevels&&this.hasFacilities&&this.filterMode===`base-floors`){let{level:n,facility:i}=this,a=[];t.levels.levelsInfo.forEach(e=>{let{id:t,facilityId:r}=e;i&&r===i?n&&t===n&&a.push(t):a.push(t)}),e.floorInfo.viewAllLevelIds=new r(a)}}};e([f({value:!1})],b.prototype,`enabled`,null),e([f({value:void 0})],b.prototype,`facility`,null),e([f({value:null})],b.prototype,`filterFeatures`,null),e([f({value:null})],b.prototype,`filterLayers`,null),e([f()],b.prototype,`filterMenuOpen`,void 0),e([f()],b.prototype,`filterMenuType`,void 0),e([f()],b.prototype,`filterMode`,void 0),e([f({readOnly:!0,value:`belowSelected`})],b.prototype,`floorVisibilityMode`,null),e([f()],b.prototype,`hasFacilities`,null),e([f()],b.prototype,`hasLevels`,null),e([f()],b.prototype,`hasMultipleSites`,null),e([f({readOnly:!0})],b.prototype,`isNormalMode`,null),e([f({value:void 0})],b.prototype,`level`,null),e([f({value:!1})],b.prototype,`longNames`,null),e([f()],b.prototype,`levelsExpanded`,void 0),e([f()],b.prototype,`mediaLayer`,void 0),e([f({value:!1})],b.prototype,`minimized`,null),e([f()],b.prototype,`overlaysByFacility`,void 0),e([f()],b.prototype,`overlaysByLevel`,void 0),e([f({value:!1})],b.prototype,`pinnedLevels`,null),e([f()],b.prototype,`searchTerm`,void 0),e([f({readOnly:!0})],b.prototype,`selectedVerticalOrder`,null),e([f({value:void 0})],b.prototype,`site`,null),e([f({readOnly:!0})],b.prototype,`state`,null),e([f({readOnly:!0,value:!1})],b.prototype,`useVerticalOrder`,null),e([f()],b.prototype,`view`,void 0),e([f()],b.prototype,`_viewHeightBreakpoint`,void 0),e([f()],b.prototype,`_viewWidthBreakpoint`,void 0),e([f()],b.prototype,`updateWebDocument`,null),b=e([p(`esri.widgets.FloorFilter.FloorFilterViewModel`)],b);const x=b;export{x as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{createTask as n}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import a from"../../core/Logger.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{watch as s,initial as c,syncAndInitial as l}from"../../core/reactiveUtils.js";import{Milliseconds as u}from"../../core/time.js";import{isBlobProtocol as d}from"../../core/urlUtils.js";import{property as f,subclass as p}from"../../core/accessorSupport/decorators.js";import m from"../../geometry/Polygon.js";import h from"../../webdoc/Widgets.js";import g from"../../webdoc/widgets/FloorFilter.js";import{isWebMap as _}from"../../webmap/utils.js";import{GoTo as v}from"../support/GoTo.js";function y(e){return e.declaredClass===`esri.WebScene`}let b=class extends v(t){constructor(e){super(e),this.filterMenuOpen=!1,this.filterMenuType=`site`,this.filterMode=`base-floors`,this.levelsExpanded=!0,this.searchTerm=null,this.view=null,this._updateFloorFilterTask=null,this._viewHeightBreakpoint=null,this._viewWidthBreakpoint=null}initialize(){this.addHandles([s(()=>this.view?.map,e=>{this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=n(async t=>{await this._updateFloorFilterFromMap(e),o(t),this._setInitialViewState(e)}),this._watchMapLayers(e)},c),s(()=>this.view,(e,t)=>{this._unregisterWidget(t),this._registerWidget(e),this._watchSearchResults(e)},l),s(()=>this.mediaLayer,e=>{this._watchLayerVisibility(e)},l),s(()=>this.view?.widthBreakpoint??null,e=>{this._viewWidthBreakpoint=e}),s(()=>this.view?.heightBreakpoint??null,e=>{this._viewHeightBreakpoint=e}),s(()=>this.facility,()=>void this.getOverlays()),s(()=>this.level,e=>this._updateMediaLayer(e))])}destroy(){if(this._unregisterWidget(this.view),this.mediaLayer&&this.view?.map.remove(this.mediaLayer),this.overlaysByLevel){for(let e of this.overlaysByLevel.values()){let t=e.image.image;d(t)&&URL.revokeObjectURL(t)}this.overlaysByFacility?.clear(),this.overlaysByLevel.clear()}this.view=null,this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null)}set enabled(e){this._callOverride(`enabled`,e)}set facility(e){if(e&&this._isOverridden(`facility`)){let t=this.getFacility(e);this.hasMultipleSites&&(this.site=t?.siteId||null)}this._callOverride(`facility`,e)}set filterFeatures(e){this._callOverride(`filterFeatures`,e)}set filterLayers(e){this._callOverride(`filterLayers`,e)}get floorVisibilityMode(){return this.view&&y(this.view?.map)?this.view.map.widgets?.floorFilter?.floorVisibilityMode??`belowSelected`:`belowSelected`}get hasFacilities(){return this.filterLayers?.facilityLayer!=null&&this.filterFeatures?.facilities?.facilitiesInfo?.length>0}get hasLevels(){return this.filterLayers?.levelLayer!=null&&this.filterFeatures?.levels?.levelsInfo?.length>0}get hasMultipleSites(){return this.filterLayers?.siteLayer!=null&&this.filterFeatures?.sites?.sitesInfo?.length>1}get isNormalMode(){let e=!0,t=this._viewWidthBreakpoint;return(this._viewHeightBreakpoint===`xsmall`||t===`xsmall`)&&(e=!1),e}set level(e){if(!e){this._callOverride(`level`,e),this.facility=null,this.site=null,this.setFloors(null);return}let t=null,n=null,r=e?.split(`--`);r?.length>1&&r[0]===`all`?(n=r[1],t={id:e,facilityId:n,shortName:null,longName:null,levelNumber:null,verticalOrder:null}):(t=this.getLevel(e),n=t?.facilityId??null),this.level===e&&!this.isNormalMode&&!this.levelsExpanded?this.getFacilityLevels(n)?.length>1&&(this.levelsExpanded=!0):(t&&this.hasFacilities&&this.hasLevels?(this.facility=n,this.hasMultipleSites&&(this.site=this.getFacility(n)?.siteId||null),this.setFloors(t)):this._isOverridden(`level`)&&(this.facility=null,this.site=null,this.hasMultipleSites&&(this.filterMenuType=`site`),this.setFloors(null)),this._callOverride(`level`,e))}set longNames(e){this._callOverride(`longNames`,e)}set minimized(e){this._callOverride(`minimized`,e)}set pinnedLevels(e){this._callOverride(`pinnedLevels`,e)}get selectedVerticalOrder(){return _(this.view?.map)?this.view.map.resourceInfo?.widgets?.floorFilter?.selectedVerticalOrder??null:null}set site(e){this._callOverride(`site`,e)}get state(){return this.view&&this.filterFeatures&&this.hasFacilities&&this.hasLevels?`ready`:this.view&&!this.filterFeatures?`loading`:`disabled`}get useVerticalOrder(){return this.view?.map==null?!1:_(this.view?.map)||y(this.view.map)?this.view.map.widgets?.floorFilter?.useVerticalOrder??!1:!1}filterFacilities(e){let t=e;return this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{let{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),this.site&&(t=t.filter(e=>e.siteId===this.site)),t.sort((e,t)=>{let n=e.name,r=t.name;return n.localeCompare(r,void 0,{sensitivity:`base`})})}filterSites(e){let t=e;return this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{let{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),t.sort((e,t)=>{let n=e.name,r=t.name;return n.localeCompare(r,void 0,{sensitivity:`base`})})}getBaseLevel(e){let t=this.filterFeatures?.levels?.levelsInfo,n=null;if(e){let{id:r}=e;if(t&&t.length>0&&(t.forEach(e=>{e.verticalOrder===0&&e.facilityId===r&&(n=e)}),!n)){let e=null;t.forEach(t=>{t.facilityId===r&&(e?(t.verticalOrder??0)>=0?e.verticalOrder!=null&&(e.verticalOrder<0||(t.verticalOrder??0)<e.verticalOrder)&&(e=t):e.verticalOrder!=null&&t.verticalOrder!=null&&e.verticalOrder<0&&t.verticalOrder>e.verticalOrder&&(e=t):e=t)}),e&&(n=e)}}return n}getFacility(e){return this.filterFeatures?.facilities?.facilitiesInfo?.find(t=>t.id===e)??null}getFacilityLevels(e){return!e||!this.filterFeatures?.levels?.levelsInfo?[]:this.filterFeatures.levels.levelsInfo.filter(t=>t.facilityId===e).sort((e,t)=>{let n=e.verticalOrder??0,r=t.verticalOrder??0;return n>r?-1:n===r?0:1})}getLevel(e){return this.filterFeatures?.levels?.levelsInfo?.find(t=>t.id===e)??null}async getOverlays(e=!1){let{facility:t,level:n,mediaLayer:i,overlaysByFacility:a,overlaysByLevel:o,view:s}=this;if(_(s?.map)&&i){if((i?.source).elements.removeAll(),t?.length&&(!a?.has(t)||e)){a?.set(t,new r);let e=s.map.floorInfo?.levelLayer?.layerId,n=s.map.findLayerById(e??``);if(!n||s.type!==`2d`)return;let i=await this._getAttachments(n,t),{default:c}=await import(`../../request.js`),l=Object.keys(i).map(async e=>{let r=i[e],s=r.find(e=>e.contentType===`application/json`);if(!s?.url)return;let l=new URL(s.url);n.gdbVersion?.length&&l.searchParams.set(`gdbVersion`,n.gdbVersion);let{data:u}=await c(l.toString(),{responseType:`json`}),d=r.find(e=>e.name===u.name),f=d?.url??``;if(f?.length>0){let e=new URL(f);e.searchParams.delete(`token`),n.gdbVersion?.length&&e.searchParams.set(`gdbVersion`,n.gdbVersion);let{default:r}=await import(`../../layers/support/ControlPointsGeoreference.js`),i=r.fromJSON(u.georeference),c=await this.toImageElement(e.toString(),i,u.opacity,u.clipImage,u.geometry);await c.load();let l={...u,attachments:[s,d],facilityId:t,image:c,source:JSON.stringify(u),url:e.toString()};o?.set(l.levelId,l),a?.get(t)?.push(l)}});await Promise.all(l)}this._updateMediaLayer(n)}}getSite(e){return this.filterFeatures?.sites?.sitesInfo?.find(t=>t.id===e)??null}async goTo(e){let{view:t}=this;if(!t||!e)return;let{geometry:n}=e;if(n?.extent){let e=e=>{this.callGoTo({target:e,options:{duration:u(1e3),easing:`quad-in-out-coast`}})};if(n.hasZ&&n.spatialReference?.vcsWkid!==t.spatialReference?.vcsWkid){let{projectIsLoaded:r,projectLoad:i,projectExecute:a}=await import(`../../geometry/operators/projectOperator.js`);r()||await i();let o=a(n.extent,t.spatialReference.clone(),{zConversionDisabled:!0});o&&e(o)}else e(n.extent)}}setFloors(e){let{view:t}=this;t&&(t?.map?.allLayers?.forEach(e=>{e.type===`feature`&&this._computeViewAllModeFloors(e)}),t.floors=new r(this._computeFloors(e)))}async toImageElement(e,t,n,r,i){let{default:o}=await import(`../../layers/support/ImageElement.js`),{facility:s}=this,c=()=>new o({image:e,georeference:t,opacity:n});if(r)try{let r=i?m.fromJSON(i):this.getFacility(s)?.geometry;if(r==null)return c();let{pixelRings:a,width:l,height:u}=await this._polygonToImagePixels(t,r),d=await this._imagePolygonToBlob(e,a,l,u);return new o({image:URL.createObjectURL(d),georeference:t,opacity:n})}catch(e){return a.getLogger(this).warn(`Unable to clip image; using full image instead: ${e.message}`,e),c()}return c()}updateWebDocument(e){if(_(e)||y(e)){let t={enabled:this.enabled,longNames:this.longNames,minimized:this.minimized,pinnedLevels:this.pinnedLevels,site:this.site??null,facility:this.facility??null,level:this.level??null,useVerticalOrder:this.useVerticalOrder,selectedVerticalOrder:this.selectedVerticalOrder};y(e)&&(t.floorVisibilityMode=this.floorVisibilityMode);let n=new g(t);e.widgets??=new h,e.widgets.floorFilter=n}}_computeFloors(e){if(this.filterMode===`single-floor`)this._computeSingleFloor(e);else if(this.filterMode===`base-floors`)return this.view?.type===`3d`?this._computeBaseFloors3D(e):this._computeBaseFloors(e);return this._computeEmptyFloors()}_computeSingleFloor(e){if(!e)return this._computeEmptyFloors();let t=[];return e?.id===`all`?this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&t.push(e.id)}):e&&t.push(e.id),t}_computeBaseFloors(e){let t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();let n=[];e?.id===`all`?this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&n.push(e.id)}):e&&n.push(e.id);let r=e?.facilityId,i=e?.verticalOrder,a=(e,t)=>{e===0&&n.push(t)};return t.forEach(e=>{let{id:t,facilityId:o,verticalOrder:s}=e;!r&&!n.includes(t)?a(s,t):o!==r&&!n.includes(t)&&(this.useVerticalOrder?s===i&&n.push(t):a(s,t))}),n}_computeBaseFloors3D(e){let t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();let n=[],r=e?.id.split(`--`)??[],i=r?.length>1&&r[0]===`all`;i?this.getFacilityLevels(e?.facilityId).forEach(e=>{e.id&&n.push(e.id)}):e&&n.push(e.id);let a=e?.facilityId,o=e?.verticalOrder;return t.forEach(e=>{let{id:t,facilityId:r,verticalOrder:s}=e;if(!a&&!n.includes(t))n.push(t);else if(!n.includes(t)){let{floorVisibilityMode:e,useVerticalOrder:c}=this,l=s<=o;r===a?e===`belowSelected`&&l&&n.push(t):(i||!c||e===`selectedOnly`&&s===o||e===`belowSelected`&&l)&&n.push(t)}}),n}_computeEmptyFloors(){return[]}async _setFilterLayers(){let{view:e}=this;if(e&&!this._isOverridden(`filterLayers`)){if(!_(e.map)&&!y(e.map))throw new i(`floorfilter:unsupported-map`,`Map must be a webmap or webscene`);{let t=e.map,n=t?.allLayers;if(n?.items?.length>0){let e={siteLayer:null,facilityLayer:null,levelLayer:null},r=t.floorInfo?.siteLayer?.layerId,i=t.floorInfo?.facilityLayer?.layerId,a=t.floorInfo?.levelLayer?.layerId,o=t.floorInfo?.siteLayer?.sublayerId||t.floorInfo?.facilityLayer?.sublayerId||t.floorInfo?.levelLayer?.sublayerId;if(!i||!a)return;let s=n.items.filter(e=>e.type===`feature`||e.type===`scene`),c=n.items.filter(e=>e.type===`map-image`);if(c?.length>0&&o){await Promise.all(c.map(e=>e.load()));let n=t.floorInfo?.siteLayer?.sublayerId,o=t.floorInfo?.facilityLayer?.sublayerId,s=t.floorInfo?.levelLayer?.sublayerId;c.forEach(t=>{let c=t.id,l=t?.allSublayers,u=l?.items;(c===r||c===i||c===a)&&u?.length>0&&l.items.forEach(t=>{let i=t.id;c===r&&i===n?e.siteLayer=t:i===o?e.facilityLayer=t:i===s&&(e.levelLayer=t)})})}s?.length>0&&s.forEach(t=>{let n=t.id;n===r?e.siteLayer=t:n===i?e.facilityLayer=t:n===a&&(e.levelLayer=t)}),this.filterLayers=e}}}}async _getAttachments(e,t){let{view:n}=this;if(_(n?.map)){let{facilityIdField:r}=n.map.floorInfo?.levelLayer??{};if(e&&n.type===`2d`&&t?.length>0&&e.capabilities.data.supportsAttachment)return e.queryAttachments({returnMetadata:!0,where:`${r} = '${t}'`})}return{}}async _getFilterFeatures(){if(this._isOverridden(`filterFeatures`))return this.filterFeatures;let[e,t,n]=await Promise.all([this._getSites(),this._getFacilities(),this._getLevels()]);return{sites:e,facilities:t,levels:n}}async _getSites(){let e={sitesInfo:[]},{filterLayers:t,view:n}=this,r=n?.map,{siteLayer:i}=t;if(!i||!r?.floorInfo?.siteLayer)return e;let a=i.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0,`type`in i&&i.type===`scene`&&(a.multipatchOption=`xyFootprint`);let{siteIdField:o,nameField:s}=r.floorInfo.siteLayer,c=await i.queryFeatures(a);if(c?.features?.length>0){let t=c.features,n=i?.fieldsIndex.get(o)?.name||o,r=i?.fieldsIndex.get(s)?.name||s;n!=null&&r!=null&&t.forEach(t=>{let i=t.attributes,a=t.geometry,o=i[n],s=i[r];o&&s&&e.sitesInfo.push({id:o,name:s,geometry:a})})}return e}async _getFacilities(){let{filterLayers:e,view:t}=this,n=t?.map,{facilityLayer:r}=e,i={facilitiesInfo:[]};if(!r||!n?.floorInfo?.facilityLayer)return i;let a=r.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0,`type`in r&&r.type===`scene`&&(a.multipatchOption=`xyFootprint`);let{facilityIdField:o,siteIdField:s,nameField:c}=n.floorInfo.facilityLayer,l=await r.queryFeatures(a);if(l?.features?.length>0){let e=l.features,t=r?.fieldsIndex.get(o)?.name||o,n=r?.fieldsIndex.get(s)?.name||s,a=r?.fieldsIndex.get(c)?.name||c;t&&n&&a&&e.forEach(e=>{let r=e.attributes,o=e.geometry,s=r[t],c=r[n],l=r[a];s&&l&&i.facilitiesInfo.push({id:s,siteId:c,name:l,geometry:o})})}return i}async _getLevels(){let{filterLayers:e,view:t}=this,n=t?.map,{levelLayer:r}=e,i={levelsInfo:[]};if(!r||!n?.floorInfo?.levelLayer)return i;let a=r.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0;let{levelIdField:o,facilityIdField:s,longNameField:c,shortNameField:l,levelNumberField:u,verticalOrderField:d}=n.floorInfo.levelLayer,f=await r.queryFeatures(a);if(f?.features?.length>0){let e=f.features,t=r?.fieldsIndex.get(o)?.name||o,n=r?.fieldsIndex.get(s)?.name||s,a=r?.fieldsIndex.get(c)?.name||c,p=r?.fieldsIndex.get(l)?.name||l,m=r?.fieldsIndex.get(u)?.name||u,h=r?.fieldsIndex.get(d)?.name||d;t&&n&&a&&p&&m&&h&&e.forEach(e=>{let r=e.attributes,o=r[t],s=r[n],c=r[a],l=r[p],u=r[m],d=r[h];o&&s&&c&&l&&typeof u==`number`&&typeof d==`number`&&i.levelsInfo.push({id:o,facilityId:s,longName:c,shortName:l,levelNumber:u,verticalOrder:d})})}return i}async _imagePolygonToBlob(e,t,n,r){let{getImageData:a}=await import(`../../core/imageUtils.js`),o=await a(e),s=new OffscreenCanvas(n,r),c=s.getContext(`2d`);if(!c)throw new i(`floorfilter:floor-plan-overlay`,`Unable to obtain a rendering context from the canvas.`);let l=new Path2D;for(let e of t)if(!(e.length<3)){l.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++)l.lineTo(e[t].x,e[t].y);l.closePath()}return c.save(),c.clip(l,`evenodd`),c.drawImage(o,0,0,n,r),c.restore(),await s.convertToBlob({type:`image/png`})}async _polygonToImagePixels(e,t){if(e?.type!==`control-points`)throw new i(`floorfilter:floor-plan-overlay`,"Expected a `ControlPointsGeoreference`.");let{default:n}=await import(`../../geometry/Point.js`);return{pixelRings:t.rings.map(r=>r.map(([r,a])=>{let o=new n({x:r,y:a,spatialReference:t.spatialReference}),s=e.toSource(o);if(!s)throw new i(`floorfilter:floor-plan-overlay`,`toSource() returned null; check spatial references and projectOperator.`);return{x:s.x,y:s.y}})),width:e.width,height:e.height}}_registerWidget(e){e?.registerComponent(this)}_unregisterWidget(e){e?.unregisterComponent(this)}_watchLayerVisibility(e){if(this.filterLayers?.levelLayer?.type===`feature`&&e){let t=this.filterLayers?.levelLayer;this.addHandles(s(()=>t.visible,t=>{e.visible=t},l))}}_watchMapLayers(e){this.removeHandles(`layers-handle`),e&&this.addHandles(e.allLayers.on(`after-remove`,t=>{if(t.item){let r=e.floorInfo,i=r?.siteLayer?.layerId??``,a=r?.facilityLayer?.layerId??``,s=r?.levelLayer?.layerId??``;(t.item.id===a||t.item.id===s||t.item.id===i)&&(this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=n(async t=>{o(t),this.level=null,this.filterMenuOpen=!1,this._clearOverride(`filterLayers`),this._clearOverride(`filterFeatures`),this._setInitialViewState(e)}))}}),`layers-handle`)}_watchSearchResults(e){e?.on(`select-result-floor`,e=>{let t=this.getLevel(e);t&&this.level!==e&&(this.level=e,this.setFloors(t))})}async _setInitialViewState(e){if(this.view)try{await this.view.when(),await this._setFilterLayers();let t=await this._getFilterFeatures();if(!t)return;if(this.filterFeatures=t,!this.hasFacilities||!this.hasLevels){a.getLogger(this).error(`Facilities and Levels are required for the Floor Filter widget`);return}if(this.hasMultipleSites||(this.filterMenuType=`facility`),this.facility&&this.level){this.filterMenuType=`facility`;let e=this.getFacility(this.facility),t=this.getLevel(this.level);this.site||=e?.siteId||void 0,this.setFloors(t)}else if(this.facility&&!this.level){this.filterMenuType=`facility`;let e=this.getFacility(this.facility),t=this.getBaseLevel(e);this.site||=e?.siteId||void 0,this.level=t?.id||void 0,this.setFloors(t)}else if(!this.facility&&this.level){this.filterMenuType=`facility`;let e=this.getLevel(this.level),t=this.getFacility(e?.facilityId);this.facility=t?.id||void 0,this.site||=t?.siteId||void 0,this.setFloors(e)}else if(this.site&&!this.facility&&!this.level)this.filterMenuType=`site`,this.setFloors(null);else{if(!e||!_(e)){this.setFloors(null);return}let t=e?.widgets?.floorFilter;if(!t){this.setFloors(null);return}t.site&&!this.site&&(this.site=t.site,this.filterMenuType=`facility`),this.setFloors(null)}if(this.filterLayers?.levelLayer?.type===`feature`&&this.filterLayers.levelLayer.capabilities.data.supportsAttachment&&this.mediaLayer==null){let{levelLayer:e}=this.filterLayers,{default:t}=await import(`../../layers/MediaLayer.js`);this.mediaLayer=new t({blendMode:`normal`,listMode:`hide`,maxScale:e.maxScale,minScale:e.minScale,spatialReference:this.view.spatialReference.clone(),title:`floor-filter-media-layer`,visible:e.visible}),this.overlaysByFacility=new Map,this.overlaysByLevel=new Map,this.view.map.add(this.mediaLayer),this.getOverlays(!0)}}catch(e){a.getLogger(this).error(`Couldn't retrieve sites, facilities, and levels`,e)}}_callOverride(e,t){this._override(e,t)}async _updateFloorFilterFromMap(e){if(!e||!_(e))return;await this.view?.when();let t=e?.widgets?.floorFilter;t&&(this._isOverridden(`enabled`)||(this.enabled=t.enabled),this._isOverridden(`longNames`)||(this.longNames=t.longNames),this._isOverridden(`minimized`)||(this.minimized=t.minimized),this._isOverridden(`pinnedLevels`)||(this.pinnedLevels=t.pinnedLevels),this._isOverridden(`site`)||(this.site=t.site),this._isOverridden(`facility`)||(this.facility=t.facility),this._isOverridden(`level`)||(this.level=t.level))}_updateMediaLayer(e){let{mediaLayer:t,overlaysByLevel:n}=this;if(t&&n&&e?.length){let r=t.source;r.elements.removeAll(),n.get(e)?.visible===!0&&r.elements.push(n.get(e)?.image)}}_computeViewAllModeFloors(e){let{filterFeatures:t}=this;if(e.floorInfo?.viewAllMode&&this.hasLevels&&this.hasFacilities&&this.filterMode===`base-floors`){let{level:n,facility:i}=this,a=[];t.levels.levelsInfo.forEach(e=>{let{id:t,facilityId:r}=e;i&&r===i?n&&t===n&&a.push(t):a.push(t)}),e.floorInfo.viewAllLevelIds=new r(a)}}};e([f({value:!1})],b.prototype,`enabled`,null),e([f({value:void 0})],b.prototype,`facility`,null),e([f({value:null})],b.prototype,`filterFeatures`,null),e([f({value:null})],b.prototype,`filterLayers`,null),e([f()],b.prototype,`filterMenuOpen`,void 0),e([f()],b.prototype,`filterMenuType`,void 0),e([f()],b.prototype,`filterMode`,void 0),e([f({readOnly:!0,value:`belowSelected`})],b.prototype,`floorVisibilityMode`,null),e([f()],b.prototype,`hasFacilities`,null),e([f()],b.prototype,`hasLevels`,null),e([f()],b.prototype,`hasMultipleSites`,null),e([f({readOnly:!0})],b.prototype,`isNormalMode`,null),e([f({value:void 0})],b.prototype,`level`,null),e([f({value:!1})],b.prototype,`longNames`,null),e([f()],b.prototype,`levelsExpanded`,void 0),e([f()],b.prototype,`mediaLayer`,void 0),e([f({value:!1})],b.prototype,`minimized`,null),e([f()],b.prototype,`overlaysByFacility`,void 0),e([f()],b.prototype,`overlaysByLevel`,void 0),e([f({value:!1})],b.prototype,`pinnedLevels`,null),e([f()],b.prototype,`searchTerm`,void 0),e([f({readOnly:!0})],b.prototype,`selectedVerticalOrder`,null),e([f({value:void 0})],b.prototype,`site`,null),e([f({readOnly:!0})],b.prototype,`state`,null),e([f({readOnly:!0,value:!1})],b.prototype,`useVerticalOrder`,null),e([f()],b.prototype,`view`,void 0),e([f()],b.prototype,`_viewHeightBreakpoint`,void 0),e([f()],b.prototype,`_viewWidthBreakpoint`,void 0),e([f()],b.prototype,`updateWebDocument`,null),b=e([p(`esri.widgets.FloorFilter.FloorFilterViewModel`)],b);const x=b;export{x as default};
|