@arcgis/core 4.29.0 → 4.29.1
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/arcade/treeAnalysis.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{b43fde3e25d0c3b020b5.js → 039a872509872ce67ba4.js} +1 -1
- package/assets/esri/core/workers/chunks/{5243f9ff21e768c620c2.js → 23a5d750d93a7829174f.js} +1 -1
- package/assets/esri/core/workers/chunks/{47e6119be4a4a5ed640d.js → 2447a4d5886aeb0ff72a.js} +1 -1
- package/assets/esri/core/workers/chunks/{7f45a9e9bdbcffc2d6e0.js → 348bcc57b99a975902a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{8c9fb2601488998013ba.js → 3523789a2948a4ab8cc8.js} +1 -1
- package/assets/esri/core/workers/chunks/{24649b410b757599a549.js → 48db6e0bbb1a9c043193.js} +1 -1
- package/assets/esri/core/workers/chunks/{752082be991f1cc8558f.js → 4984e2b79d862114d6a6.js} +1 -1
- package/assets/esri/core/workers/chunks/{8d9736fd15cdb54d9855.js → 5227f9eea6988aadad7f.js} +1 -1
- package/assets/esri/core/workers/chunks/58723274ef657fe212eb.js +1 -0
- package/assets/esri/core/workers/chunks/60ab18c6a04d4b2f1d4c.js +1 -0
- package/assets/esri/core/workers/chunks/647515801d94180b8402.js +1 -0
- package/assets/esri/core/workers/chunks/6c3ae96ec90e9ed7dd50.js +1 -0
- package/assets/esri/core/workers/chunks/7a8bba91769ee18cc39f.js +1 -0
- package/assets/esri/core/workers/chunks/7a98d2e026f63a581b1e.js +1 -0
- package/assets/esri/core/workers/chunks/8c360923cd1850767d3e.js +1 -0
- package/assets/esri/core/workers/chunks/{1a25ba411b89e050fbb7.js → a61f337802ae963d7f65.js} +1 -1
- package/assets/esri/core/workers/chunks/{d0c5318d7ef2e923aad0.js → a8ac511280f873960d46.js} +1 -1
- package/assets/esri/core/workers/chunks/b125ab84b7761e761734.js +1 -0
- package/assets/esri/core/workers/chunks/{b34d6e58b125fe111f91.js → b42a83db83851cb57d44.js} +1 -1
- package/assets/esri/core/workers/chunks/{1497dd943df7eede0704.js → b9c55ff1f21db198ce03.js} +1 -1
- package/assets/esri/core/workers/chunks/bb3322ddb89c0bd444f0.js +1 -0
- package/assets/esri/core/workers/chunks/becfdaeeb07f089d8be7.js +1 -0
- package/assets/esri/core/workers/chunks/{b26e39a399963c176d33.js → c527692694688a5b3b07.js} +2 -2
- package/assets/esri/core/workers/chunks/{210a93e0b96c5bff44a3.js → c556644bb0cf88770939.js} +1 -1
- package/assets/esri/core/workers/chunks/{a5e7b4acae17f88e2208.js → ce93027b6b81428ce9b0.js} +1 -1
- package/assets/esri/core/workers/chunks/{b8ece275abac93f3dccf.js → d14f16bfa6c12909929c.js} +1 -1
- package/assets/esri/core/workers/chunks/{1594f06a2d7d9439c62e.js → e2147c99cc5839654be1.js} +1 -1
- package/assets/esri/core/workers/chunks/{d33ed3a2a0d4b640bd4a.js → e4c7d8c69e4957c9d27c.js} +1 -1
- package/assets/esri/core/workers/chunks/{7709248f59520aee6f51.js → eceaa46f622f6fa31128.js} +1 -1
- package/assets/esri/core/workers/chunks/{2286db4c83ff1b6fb088.js → ef3e6209e6ac6a56960b.js} +1 -1
- package/assets/esri/core/workers/chunks/f59b5ea05caca8a1a398.js +1 -0
- package/chunks/Laserlines.glsl.js +3 -3
- package/chunks/Precipitation.glsl.js +1 -1
- package/chunks/SSAOBlur.glsl.js +2 -2
- package/chunks/boundedPlane.js +1 -1
- package/chunks/cameraUtilsSpherical.js +1 -1
- package/chunks/sphere.js +1 -1
- package/chunks/terrainUtilsPlanar.js +1 -1
- package/chunks/vec32.js +1 -1
- package/core/libs/gl-matrix-2/math/quat.js +1 -1
- package/core/libs/gl-matrix-2/math/vec3.js +1 -1
- package/core/libs/gl-matrix-2/vec3.js +1 -1
- package/geometry/support/axisAngleDegrees.js +1 -1
- package/geometry/support/coordinateSystem.js +1 -1
- package/geometry/support/lineSegment.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/geometry/support/meshUtils/georeference.js +1 -1
- package/geometry/support/meshUtils/merge.js +1 -1
- package/geometry/support/meshUtils/rotate.js +1 -1
- package/geometry/support/meshUtils/scale.js +1 -1
- package/geometry/support/meshUtils/vertexSpaceConversion.js +5 -0
- package/geometry/support/meshVertexSpaceUtils.js +1 -1
- package/geometry/support/plane.js +1 -1
- package/geometry/support/ray.js +1 -1
- package/geometry/support/triangle.js +1 -1
- package/geometry/support/vector.js +1 -1
- package/interfaces.d.ts +6 -6
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/mixins/FeatureReductionLayer.js +1 -1
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/video/VideoCameraSensorModel.js +1 -1
- package/layers/voxel/VoxelVolume.js +1 -1
- package/layers/voxel/voxelPlaneUtils.js +1 -1
- package/libs/linkchartlayout/LinkChartLayout.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/views/2d/arcade/callExpressionWithCursor.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/createTestMeshData.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriterInputEvaluator.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/aggregation/GeohashSpatialIndex.js +1 -1
- package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
- package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
- package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/DrillDownTileSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/PagedTileSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/StreamSourceChunk.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
- package/views/2d/layers/features/support/GraphicsReader.js +1 -1
- package/views/2d/layers/features/support/Tile.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/2d/tiling/TileKey.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
- package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/analysis/support/measurementUtils.js +1 -1
- package/views/3d/animation/pointToPoint/Camera.js +1 -1
- package/views/3d/camera/constraintUtils/common.js +1 -1
- package/views/3d/camera/constraintUtils/distance.js +1 -1
- package/views/3d/camera/constraintUtils/tilt.js +1 -1
- package/views/3d/camera/intersectionUtils.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/environment/MarsAtmosphere.js +1 -1
- package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
- package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
- package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/edgeOffsetUtils.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ExtentScale.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/extentUtils.js +1 -1
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/support/Segment.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudWorker.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/LoDUtil.js +1 -1
- package/views/3d/layers/i3s/PointRenderer.js +1 -1
- package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/layers/support/uvUtils.js +1 -1
- package/views/3d/state/Frustum.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/global/ZoomController.js +1 -1
- package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
- package/views/3d/state/controllers/local/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/local/ZoomController.js +1 -1
- package/views/3d/state/controllers/local/ZoomStepController.js +1 -1
- package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/state/utils/viewUtils.js +1 -1
- package/views/3d/support/FrustumExtentIntersection.js +1 -1
- package/views/3d/support/cameraUtils.js +1 -1
- package/views/3d/support/cameraUtilsInternal.js +1 -1
- package/views/3d/support/intersectionUtils.js +1 -1
- package/views/3d/support/mathUtils.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/Focus.js +1 -1
- package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
- package/views/3d/support/sunUtils.js +1 -1
- package/views/3d/support/viewpointUtils.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
- package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/core/util/TwoVectorPosition.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/PathVertex.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
- package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
- package/views/3d/webgl-engine/lib/intersectorUtils.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
- package/views/3d/webgl-engine/lighting/SceneLighting.js +1 -1
- package/views/3d/webgl-engine/lighting/SphericalHarmonics.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/pbrUtils.js +1 -1
- package/views/SelectionManager.js +1 -1
- package/views/draw/support/createUtils.js +1 -1
- package/views/draw/support/surfaceCoordinateSystems.js +1 -1
- package/views/interactive/GraphicManipulator.js +1 -1
- package/views/interactive/SegmentLabels.js +1 -1
- package/views/interactive/coordinateHelper.js +1 -1
- package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
- package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
- package/views/interactive/sketch/constraints.js +1 -1
- package/views/interactive/snapping/RightAngleSnapper.js +1 -1
- package/views/interactive/snapping/candidates/ParallelLineSnappingCandidate.js +1 -1
- package/views/interactive/snapping/candidates/RightAngleTriangleSnappingCandidate.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
- package/views/interactive/snapping/hints/IntersectionSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/ParallelSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/PointSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/RightAngleSnappingHint.js +1 -1
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
- package/views/support/angularMeasurementUtils.js +1 -1
- package/views/support/euclideanAreaMeasurementUtils.js +1 -1
- package/views/support/euclideanLengthMeasurementUtils.js +1 -1
- package/views/support/geometry3dUtils.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/FeatureTable/support/ColumnTemplateBase.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/utils.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/support/Selector2D/SelectionOperation.js +1 -1
- package/widgets/support/Selector2D/selectorUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0e83f3718a0b45652b5e.js +0 -1
- package/assets/esri/core/workers/chunks/1fa5c8af69a09a3730b3.js +0 -1
- package/assets/esri/core/workers/chunks/4736f79b5c94ce103d43.js +0 -1
- package/assets/esri/core/workers/chunks/65f7adaaf1f535310c11.js +0 -1
- package/assets/esri/core/workers/chunks/79c041b292648c5eaecc.js +0 -1
- package/assets/esri/core/workers/chunks/7c4c2c0beddabac672b6.js +0 -1
- package/assets/esri/core/workers/chunks/9307d485a9e5f9fa77d1.js +0 -1
- package/assets/esri/core/workers/chunks/9a758de08dfa57735879.js +0 -1
- package/assets/esri/core/workers/chunks/a4c3da057ec2a07bbbe8.js +0 -1
- package/assets/esri/core/workers/chunks/b252270b100351779f1f.js +0 -1
- package/assets/esri/core/workers/chunks/dc57aa9f2fc69e654559.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import r from"../../core/Logger.js";import{throwIfAborted as i}from"../../core/promiseUtils.js";import{watch as o,syncAndInitial as s,on as n}from"../../core/reactiveUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{combinedViewLayerTimeExtentProperty as u}from"../../layers/support/commonProperties.js";import p from"../../layers/support/FeatureEffect.js";import d from"../../layers/support/FeatureFilter.js";import{fixFields as f,unpackFieldNames as m,collectLabelingFields as c,collectElevationFields as y,collectFilterFields as h,collectFeatureReductionFields as g,collectOrderByInfos as F,collectFields as w,collectField as E,featureHasFields as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import r from"../../core/Logger.js";import{throwIfAborted as i}from"../../core/promiseUtils.js";import{watch as o,syncAndInitial as s,on as n}from"../../core/reactiveUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{combinedViewLayerTimeExtentProperty as u}from"../../layers/support/commonProperties.js";import p from"../../layers/support/FeatureEffect.js";import d from"../../layers/support/FeatureFilter.js";import{fixFields as f,unpackFieldNames as m,collectLabelingFields as c,collectElevationFields as y,collectFilterFields as h,collectFeatureReductionFields as g,collectOrderByInfos as F,collectFields as w,collectField as E,featureHasFields as I}from"../../layers/support/fieldUtils.js";import{getFloorFilterClause as b}from"../../layers/support/floorFilterUtils.js";import x from"../../rest/support/Query.js";import{loadArcade as v}from"../../support/arcadeOnDemand.js";import{getFetchPopupTemplate as R,getRequiredFields as _}from"./support/popupUtils.js";const j=j=>{let q=class extends j{constructor(...e){super(...e),this._updatingRequiredFieldsPromise=null,this.dataUpdating=!1,this.filter=null,this.timeExtent=null,this.layer=null,this.requiredFields=[],this.view=null}initialize(){this.addHandles([o((()=>{const e=this.layer;return[e&&"elevationInfo"in e?e.elevationInfo?.featureExpressionInfo:null,e&&"displayField"in e?e.displayField:null,e&&"timeInfo"in e&&e.timeInfo,e&&"renderer"in e&&e.renderer,e&&"labelingInfo"in e&&e.labelingInfo,e&&"floorInfo"in e&&e.floorInfo,this.filter,this.featureEffect,this.timeExtent]}),(()=>this._handleRequiredFieldsChange()),s),n((()=>this.view?.floors),"change",(()=>this._handleRequiredFieldsChange())),n((()=>{const e=this.layer;return e&&"sublayers"in e?e.sublayers:null}),"change",(()=>this._handleRequiredFieldsChange()))])}get availableFields(){if(!this.layer)return[];const{layer:e,layer:{fieldsIndex:t},requiredFields:r}=this;return"outFields"in e&&e.outFields?f(t,[...m(t,e.outFields),...r]):f(t,r)}get featureEffect(){return this.layer&&"featureEffect"in this.layer?this.layer.featureEffect:null}set featureEffect(e){this._override("featureEffect",e)}get maximumNumberOfFeatures(){return 0}set maximumNumberOfFeatures(e){r.getLogger(this).error("#maximumNumberOfFeatures=","Setting maximum number of features is not supported")}get maximumNumberOfFeaturesExceeded(){return!1}highlight(e){throw new Error("missing implementation")}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference},t=null!=this.filter?this.filter.createQuery(e):new x(e);if("floorInfo"in this.layer&&this.layer.floorInfo){const e=b(this);null!=e&&(t.where=t.where?`(${t.where}) AND (${e})`:e)}return null!=this.timeExtent&&(t.timeExtent=null!=t.timeExtent?t.timeExtent.intersection(this.timeExtent):this.timeExtent.clone()),t}createAggregateQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return new x(e)}queryFeatures(e,t){throw new Error("missing implementation")}queryObjectIds(e,t){throw new Error("missing implementation")}queryFeatureCount(e,t){throw new Error("missing implementation")}queryExtent(e,t){throw new Error("missing implementation")}async fetchPopupFeaturesFromGraphics(e,t){return this._validateFetchPopupFeatures(e,t),this._fetchPopupFeatures(e,t)}_loadArcadeModules(e){return e.expressionInfos?.length||Array.isArray(e.content)&&e.content.some((e=>"expression"===e.type))?v():Promise.resolve()}_handleRequiredFieldsChange(){const e=this._updateRequiredFields();this._set("_updatingRequiredFieldsPromise",e),e.then((()=>{this._updatingRequiredFieldsPromise===e&&this._set("_updatingRequiredFieldsPromise",null)}))}async _updateRequiredFields(){if(!this.layer||!this.view)return;const e="3d"===this.view.type,{layer:t,layer:{fieldsIndex:i,objectIdField:o}}=this,s="renderer"in t&&t.renderer,n="orderBy"in t&&t.orderBy,l="featureReduction"in t?t.featureReduction:null,a=new Set,u=await Promise.allSettled([s?s.collectRequiredFields(a,i):null,c(a,t),e&&"elevationInfo"in t?y(a,t):null,null!=this.filter?h(a,t,this.filter):null,e||null==this.featureEffect?null:h(a,t,this.featureEffect.filter),!e&&l?g(a,t,l):null,!e&&n?F(a,t,n):null]);if("timeInfo"in t&&t.timeInfo&&this.timeExtent&&w(a,t.fieldsIndex,[t.timeInfo.startField,t.timeInfo.endField]),"floorInfo"in t&&t.floorInfo&&w(a,t.fieldsIndex,[t.floorInfo.floorField]),"feature"===t.type&&e&&null!=t.infoFor3D&&(null==t.globalIdField&&r.getLogger(this).error("globalIdField missing on 3DObjectFeatureLayer"),w(a,t.fieldsIndex,[t.globalIdField])),"subtype-group"===t.type){E(a,i,t.subtypeField);const e=t.sublayers.map((e=>Promise.all([e.renderer?.collectRequiredFields(a,i),c(a,e)])));await Promise.allSettled(e)}"catalog-footprint"===t.type&&w(a,i,[t.parent.itemSourceField,t.parent.itemTypeField]);for(const d of u)"rejected"===d.status&&r.getLogger(this).error(d.reason);E(a,i,o),e&&"displayField"in t&&t.displayField&&E(a,i,t.displayField);const p=Array.from(a).sort();this._set("requiredFields",p)}_validateFetchPopupFeatures(e,r){if(null!=r)for(const i of e){const e=i.origin&&"layer"in i.origin?i.origin.layer:i.layer;if("popupEnabled"in e&&!e.popupEnabled)throw new t("featurelayerview:fetchPopupFeatures","Popups are disabled",{layer:e});if(i.isAggregate){const r="featureReduction"in e?e.featureReduction:null;if(!(r&&"popupTemplate"in r&&r.popupEnabled&&r.popupTemplate))throw new t("featurelayerview:fetchPopupFeatures","Popups are disabled",{layer:e})}else if("popupTemplate"in e){if(!R(e,r))throw new t("featurelayerview:fetchPopupFeatures","Layer does not define a popup template",{layer:e})}}}_popupFeatureHasRequiredFields(e,t){return I(t,e)}async _fetchPopupFeatures(e,t){const r=new Array(e.length),o=new Map,s=await this._createPopupQuery(e.map((e=>e.origin?.layer??e.layer)),t);for(let n=0;n<e.length;n++){const l=e[n];if(l.isAggregate){r[n]=l;continue}const a=l.origin?.layer??l.layer;if(!a||!("popupEnabled"in a))continue;const u=m(this.layer.fieldsIndex,s.outFields),p=R(a,t);if(null==p)continue;const d=await this._loadArcadeModules(p);i(t);d&&d.arcadeUtils.hasGeometryOperations(p)||!this._popupFeatureHasRequiredFields(l,u)?o.set(l.getObjectId(),{graphic:l,index:n}):r[n]=l}if("stream"===this.layer.type||0===o.size)return r.filter(Boolean);s.objectIds=Array.from(o.keys());try{const e=await this.layer.queryFeatures(s,t);for(const t of e.features){const{graphic:{geometry:e,origin:i},index:s}=o.get(t.getObjectId());t.geometry||=e,t.origin=i,r[s]=t}}catch{}return r.filter(Boolean)}async _createPopupQuery(e,t){const r=this.layer.createQuery(),o=new Set;let s=!1;const n=e??[this.layer];for(const l of n){if(!("popupEnabled"in l))continue;const e=R(l,t);if(null==e)continue;const r=await this._loadArcadeModules(e);i(t);const n=r&&r.arcadeUtils.hasGeometryOperations(e);s=!("point"!==this.layer.geometryType&&!n);const a=await _(this.layer,e);i(t);for(const t of a)o.add(t)}if(r.returnGeometry=s,r.returnZ=s,r.returnM=s,r.outFields=Array.from(o),r.outSpatialReference=this.view.spatialReference,"floorInfo"in this.layer&&this.layer.floorInfo){const e=b(this);null!=e&&(r.where=r.where?`(${r.where}) AND (${e})`:e)}return r}canResume(){return!!super.canResume()&&(null==this.timeExtent||!this.timeExtent.isEmpty)}getTest(){return{createPopupQuery:e=>this._createPopupQuery(void 0,e)}}get test(){return this.getTest()}};return e([l()],q.prototype,"_updatingRequiredFieldsPromise",void 0),e([l({readOnly:!0})],q.prototype,"availableFields",null),e([l({readOnly:!0})],q.prototype,"dataUpdating",void 0),e([l({type:p})],q.prototype,"featureEffect",null),e([l({type:d})],q.prototype,"filter",void 0),e([l(u)],q.prototype,"timeExtent",void 0),e([l()],q.prototype,"layer",void 0),e([l({type:Number})],q.prototype,"maximumNumberOfFeatures",null),e([l({readOnly:!0,type:Boolean})],q.prototype,"maximumNumberOfFeaturesExceeded",null),e([l({readOnly:!0})],q.prototype,"requiredFields",void 0),e([l()],q.prototype,"suspended",void 0),e([l()],q.prototype,"view",void 0),q=e([a("esri.views.layers.FeatureLayerView")],q),q};export{j as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{create as t}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{
|
|
5
|
+
import{create as t}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as e,n as i,c as s}from"../../chunks/vec32.js";import{create as a}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{rotationAngleAndAxisDirectRotation as l,rotationAnglesAndAxesHeadingPreserving as n}from"../3d/state/utils/navigationUtils.js";import{FilteredFiniteDifference as r}from"./FilteredFiniteDifference.js";import{FilteredValue as h}from"./FilteredValue.js";import{Momentum as _}from"./Momentum.js";const m=1e-5;class u extends _{constructor(t,e,i,s,a,l=0,n){super(t,e,i),this._angularVelocity1=s,this.axis1=a,this.angularVelocity2=l,this.axis2=n}value1(t){return super.valueFromInitialVelocity(this._angularVelocity1,t)}value2(t){return super.valueFromInitialVelocity(this.angularVelocity2,t)}}class o{constructor(e=300,i=12,s=.84){this._minimumInitialVelocity=e,this._stopVelocity=i,this._friction=s,this.enabled=!0,this._tmpAxis1=a(),this._tmpAxis2=a(),this._tmpAngles=t(),this._time=new r(.3),this._screen=[new r(.4),new r(.4)],this._angle1=new h(.6),this._angle2=new h(.6),this._axis1=a(),this._axis2=a(),this._lastScene=a()}addMomentumDirectRotation(t,a,n,r,h,_){if(this.enabled){if(this._time.hasLastValue()){if(this._time.computeDelta(n)<.01)return;let t=l(this._lastScene,a,this._tmpAxis2,r,h,_);this._angle2.update(0),e(this._tmpAxis2)<m?t=0:i(this._axis1,this._tmpAxis2),this._angle1.update(t),s(this._lastScene,a)}this._screen[0].update(t[0]),this._screen[1].update(t[1]),this._time.update(n)}}addMomentumPreserveHeading(t,a,l,r,h,_,u){if(this.enabled){if(this._time.hasLastValue()){if(this._time.computeDelta(l)<.01)return;n(this._lastScene,a,this._tmpAxis2,this._tmpAxis1,this._tmpAngles,r,h,_,u,!1),e(this._tmpAxis2)<m?(this._angle1.update(0),this._angle2.update(0)):(this._angle1.update(this._tmpAngles[1]),this._angle2.update(this._tmpAngles[0]),i(this._axis1,this._tmpAxis1),i(this._axis2,this._tmpAxis2)),s(this._lastScene,a)}this._screen[0].update(t[0]),this._screen[1].update(t[1]),this._time.update(l)}}reset(){this._screen[0].reset(),this._screen[1].reset(),this._angle1.reset(),this._angle2.reset(),this._time.reset()}evaluateMomentum(){if(!this.enabled||!this._screen[0].hasFilteredDelta())return null;const t=this._screen[0].filteredDelta,e=this._screen[1].filteredDelta,i=null==t||null==e?null:Math.sqrt(t*t+e*e),s=this._time.filteredDelta,a=null==i||null==s?0:i/s;return Math.abs(a)<this._minimumInitialVelocity?null:this.createMomentum(a,this._stopVelocity,this._friction)}createMomentum(t,e,i){const s=this._time.filteredDelta,a=this._angle1.filteredValue,l=this._angle2.filteredValue,n=null==s||null==l?0:l/s;return new u(t,e,i,null==s||null==a?0:a/s,this._axis1,n,this._axis2)}}export{u as PanSphericalMomentum,o as PanSphericalMomentumEstimator};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{cyclicalDegrees as e,Cyclical as r}from"../../core/Cyclical.js";import{createAngle as t,convertRotationType as i}from"../../core/quantityUtils.js";import{convertUnit as o}from"../../core/unitUtils.js";import{angle as n}from"../../core/libs/gl-matrix-2/math/vec2.js";import{UNIT_Y as s,create as a}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as c,
|
|
5
|
+
import{cyclicalDegrees as e,Cyclical as r}from"../../core/Cyclical.js";import{createAngle as t,convertRotationType as i}from"../../core/quantityUtils.js";import{convertUnit as o}from"../../core/unitUtils.js";import{angle as n}from"../../core/libs/gl-matrix-2/math/vec2.js";import{UNIT_Y as s,create as a}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as c,j as l,c as u}from"../../chunks/vec32.js";import{create as m}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectVectorToVector as f}from"../../geometry/projection/projectVectorToVector.js";import{geodesicCompatibleSpatialReference as g,inverseGeodeticSolver as p,directGeodeticSolver as v,InverseGeodeticSolverResult as d}from"../../geometry/support/geodesicUtils.js";import{equals as h}from"../../geometry/support/spatialReferenceUtils.js";var j;function R(e,r){if(null==e||null==r)return;const i=b(e,r);return null!=i?t(i,"radians","geographic"):void 0}!function(e){e.Absolute="absolute",e.Relative="relative",e.RelativeBilateral="relative-bilateral"}(j||(j={}));const b=(()=>{const e=m(),r=m();return(t,i)=>(c(e,t.x,t.y,t.z??0),c(r,i.x,i.y,i.z??0),y(e,r,t.spatialReference,i.spatialReference))})(),y=(()=>{const e=a(),r=m(),t=m();return(i,a,c,u)=>{if(l(i,a))return;const m=g(c),v=g(u);if(m&&v&&h(m,v)&&f(i,c,r,m)&&f(a,u,t,v)){const{azimuth:e}=p(M,r,t,m);return null!=e?o(e,"degrees","radians"):void 0}e[0]=a[0]-i[0],e[1]=a[1]-i[1];let d=n(s,e);return e[0]<0&&(d=U-d),d}})();function x(e,r,t,i=j.Absolute){if(r&&t)switch(i){case j.Absolute:return R(r,t);case j.Relative:return w(z(e,r,t),j.Relative);case j.RelativeBilateral:return w(z(e,r,t),j.RelativeBilateral)}}function z(e,r,i){if(!e||!r||!i)return;const o=b(e,r),n=b(r,i);return null!=o&&null!=n?t(n-o,"radians","geographic"):void 0}function w(e,r){if(null==e)return;const i=B(e);switch(r){case j.Absolute:{const e=T.normalize(i,0,!0);return t(e,"degrees","geographic")}case j.Relative:{let e=V.normalize(i,0,!0);return-180===e&&(e=180),t(e,"degrees","geographic")}case j.RelativeBilateral:{const e=Math.abs(V.normalize(i,0,!0));return t(e,"degrees","geographic")}}}const A=(()=>{const e=m();return(r,t,n,s,a,l="geodesic")=>{u(e,t);const m=B(a);if("geodesic"===l){const i=g(n);if(i&&f(e,n,e,i))return v(r,e,m,s,i),r[2]=t[2],!!f(r,i,r,n)}const p=i(m,"geographic","arithmetic"),d=o(p,"degrees","radians"),h=t[0]+s*Math.cos(d),j=t[1]+s*Math.sin(d),R=t[2];return c(r,h,j,R),!0}})();function B(e){return null!=e?i(o(e.value,e.unit,"degrees"),e.rotationType,"geographic"):void 0}const M=new d,U=2*Math.PI,T=e,V=new r(-180,180);export{j as DirectionMode,R as directionBetweenPoints,x as directionForVertices,B as getDegreesGeographic,w as getNormalizedDirection,A as pointFromDistanceAlongAzimuth,y as radiansGeographicBetweenVec};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{createArea as t}from"../../core/quantityUtils.js";import{areaUnitFromSpatialReference as o}from"../../core/unitUtils.js";import{e as r}from"../../chunks/earcut.js";import{s as n,
|
|
5
|
+
import{createArea as t}from"../../core/quantityUtils.js";import{areaUnitFromSpatialReference as o}from"../../core/unitUtils.js";import{e as r}from"../../chunks/earcut.js";import{s as n,r as e,p as s}from"../../chunks/vec32.js";import{create as i}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectVectorToVector as c}from"../../geometry/projection/projectVectorToVector.js";import{fromPoints as f,wrap as l,getNormal as u,projectPointLocal as m}from"../../geometry/support/plane.js";import{areaPoints2d as p}from"../../geometry/support/triangle.js";import{computeEuclideanMeasurementSR as a}from"./measurementUtils.js";function g(t,o=U()){return h(t,o)}function j(t,o=U()){return h(t,o,!1)}function h(r,g,j=r.hasZ){const h=a(r.spatialReference),U=o(h);if(null==U)return null;const v=(t,o)=>!(o.length<2)&&(n(t,o[0],o[1],j&&o[2]||0),!0);let x=0;for(const t of r.rings){const o=t.length;if(o<3)continue;const{positionsWorldCoords:a}=g;for(;a.length<o;)a.push(i());const j=y,U=n(d,0,0,0),C=1/o;for(let n=0;n<o;n++){if(!v(j,t[n]))return null;if(!c(j,r.spatialReference,a[n],h))return null;e(U,U,a[n],C)}const R=f(a[0],a[1],U,l());if(0===s(u(R)))continue;for(let t=0;t<o;t++)m(R,U,a[t],a[t]);const V=k(a);for(let t=0;t<V.length;t+=3)x+=p(a[V[t]],a[V[t+1]],a[V[t+2]])}return t(x,U)}const y=i(),d=i();function U(){return{positionsWorldCoords:[]}}function k(t){return r(v(t),[],2)}function v(t){const o=new Float64Array(2*t.length);for(let r=0;r<t.length;++r){const n=t[r],e=2*r;o[e]=n[0],o[e+1]=n[1]}return o}export{h as computeEuclideanPlanarArea,U as createEuclideanPlanarAreaCache,j as euclideanHorizontalPlanarArea,g as euclideanPlanarArea,k as triangulate};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{createLength as t}from"../../core/quantityUtils.js";import{lengthUnitFromSpatialReference as n,verticalLengthUnitFromSpatialReference as r}from"../../core/unitUtils.js";import{
|
|
5
|
+
import{createLength as t}from"../../core/quantityUtils.js";import{lengthUnitFromSpatialReference as n,verticalLengthUnitFromSpatialReference as r}from"../../core/unitUtils.js";import{q as e,s as i}from"../../chunks/vec32.js";import{create as l}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectVectorToVector as o}from"../../geometry/projection/projectVectorToVector.js";import{equals as c}from"../../geometry/support/spatialReferenceUtils.js";import{computeEuclideanMeasurementSR as u}from"./measurementUtils.js";var a;function s(t){return p(t,a.Direct)}function f(t){return p(t,a.Horizontal)}function p(r,e){const{hasZ:i,spatialReference:l}=r,o=u(l);let c=0;const s=n(o);if(null==s)return null;const f=e===a.Direct?Z:j;for(const t of r.paths){if(t.length<2)continue;const n=t.length-1;for(let r=0;r<n;++r){const n=t[r];D[0]=n[0],D[1]=n[1],D[2]=i?n[2]:0;const e=t[r+1];H[0]=e[0],H[1]=e[1],H[2]=i?e[2]:0;const o=f(D,H,l);if(null==o)return null;c+=o.value}}return t(c,s)}function h(t,n){const{spatialReference:r}=t;return c(r,n.spatialReference)?(D[0]=t.x,D[1]=t.y,D[2]=t.hasZ?t.z:0,H[0]=n.x,H[1]=n.y,H[2]=n.hasZ?n.z:0,x(D,H,r)):null}function m(t,n){const{spatialReference:r}=t;return c(r,n.spatialReference)?(D[0]=t.x,D[1]=t.y,D[2]=t.hasZ?t.z:0,H[0]=n.x,H[1]=n.y,H[2]=n.hasZ?n.z:0,Z(D,H,r)):null}function z(t,n){const{spatialReference:r}=t;return c(r,n.spatialReference)?(D[0]=t.x,D[1]=t.y,D[2]=t.hasZ?t.z:0,H[0]=n.x,H[1]=n.y,H[2]=n.hasZ?n.z:0,j(D,H,r)):null}function y(t,n){const{spatialReference:r}=t;return c(r,n.spatialReference)?(D[0]=t.x,D[1]=t.y,D[2]=t.hasZ?t.z:0,H[0]=n.x,H[1]=n.y,H[2]=n.hasZ?n.z:0,g(D,H,r)):null}function R(t){return null!=t?v(t.hasZ?t.z:0,t.spatialReference):null}function v(n,e){const i=r(e);return null!=i?t(n??0,i):null}function x(n,r,e){const i=V(n,r,e);return null!=i?{direct:t(i.direct,i.unit),horizontal:t(i.horizontal,i.unit),vertical:t(i.vertical,i.unit)}:null}function Z(n,r,e){const i=V(n,r,e,a.Direct);return null!=i?t(i.direct,i.unit):null}function j(n,r,e){const i=V(n,r,e,a.Horizontal);return null!=i?t(i.horizontal,i.unit):null}function d(n,r,e){const i=V(n,r,e,a.Vertical);return null!=i?t(Math.abs(i.verticalSigned),i.unit):null}function g(n,r,e){const i=V(n,r,e,a.Vertical);return null!=i?t(i.verticalSigned,i.unit):null}function V(t,r,l,c){const s=u(l),f=n(s);if(null==f)return null;const p=r[2]-t[2];if(c===a.Vertical)return{verticalSigned:p,unit:f};if(!o(t,l,U,s)||!o(r,l,b,s))return null;if(c===a.Direct){return{direct:e(b,U),unit:f}}if(i(S,t[0],t[1],r[2]),!o(S,l,S,s))return null;const h=e(S,b);if(c===a.Horizontal)return{horizontal:h,unit:f};return{direct:e(b,U),horizontal:h,vertical:Math.abs(p),unit:f}}!function(t){t[t.Direct=0]="Direct",t[t.Horizontal=1]="Horizontal",t[t.Vertical=2]="Vertical"}(a||(a={}));const D=l(),H=l(),U=l(),b=l(),S=l();export{R as elevationFromPoint,v as elevationFromZ,Z as euclideanDirectDistance,m as euclideanDirectDistanceBetweenPoints,x as euclideanDistance,h as euclideanDistanceBetweenPoints,j as euclideanHorizontalDistance,z as euclideanHorizontalDistanceBetweenPoints,f as euclideanHorizontalLength,s as euclideanLength,d as verticalDistance,g as verticalSignedDistance,y as verticalSignedDistanceBetweenPoints};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{floatEqualAbsolute as t}from"../../core/mathUtils.js";import{subtract as n,squaredLength as r,dot as s,scaleAndAdd as e,sub as o,length as c,distance as i,squaredDistance as u,lerp as a,set as f}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as p,fromValues as m,ZEROS as L}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as h,
|
|
5
|
+
import{floatEqualAbsolute as t}from"../../core/mathUtils.js";import{subtract as n,squaredLength as r,dot as s,scaleAndAdd as e,sub as o,length as c,distance as i,squaredDistance as u,lerp as a,set as f}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as p,fromValues as m,ZEROS as L}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as h,z as A,k as d,r as l,q as E,b as N,D as y,c as P,f as b,x as j}from"../../chunks/vec32.js";import{create as M,clone as I}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEpsilon as x}from"../../core/libs/gl-matrix-2/math/common.js";import{create as R,fromPositionAndNormal as Y,distance as g,intersectLine as q,isPointInside as v}from"../../geometry/support/plane.js";import{tangentFrame as F}from"../3d/support/mathUtils.js";import{LineType as H,intersectLineLikeAndCircle as _}from"./geometry2dUtils.js";function k({start:t,end:o,type:c},i,u){const a=[],f=n(et,o,t),m=n(ot,t,i),L=r(f),h=2*s(f,m),A=h*h-4*L*(r(m)-u*u);if(0===A){const n=-h/(2*L);(c===rt.PLANE||n>=0)&&a.push(e(p(),t,f,n))}else if(A>0){const n=Math.sqrt(A),r=(-h+n)/(2*L);(c===rt.PLANE||r>=0)&&a.push(e(p(),t,f,r));const s=(-h-n)/(2*L);(c===rt.PLANE||s>=0)&&a.push(e(p(),t,f,s))}return a}function U(t,r){const e=t.start,c=t.end,i=n(et,c,e),u=h(it,-i[1],i[0],0),a=r.start,f=r.end,p=A(ut,f,a),m=d(p,u),L=h(at,e[0],e[1],0),E=A(ft,L,a),N=d(E,u),y=x();if(Math.abs(m)<y)return Math.abs(N),[];const P=l(pt,a,p,N/m);if(r.type===H.RAY){const t=A(mt,P,a);if(d(t,p)<-y)return[]}if(t.type===rt.HALF_PLANE){const t=o(ot,P,e);if(s(t,i)<-y)return[]}return[I(P)]}function w(t,n){return T(X(ht,n[2],t),n)}function z(t,n){const r=0;return S(X(ht,r,t),X(At,r,n)).map((([t,n])=>m(t,n)))}function C(t,n){return J(t,X(ht,t[2],n))}function D(t,n){return K(X(ht,t[2],n),t)}function B(t,r,s){const o=n(et,t,r),i=c(o),u=0===i?1:s/i,a=M();return e(a,r,o,u),a[2]=t[2],a}function G(t,n,r){return i(t,n)-r}function J(t,{start:n,end:r,type:s},e=M()){const o=A(ct,t,n),c=A(it,r,n),i=d(o,c)/d(c,c);return l(e,n,c,s===H.RAY?Math.max(i,0):i)}function K({start:t,end:n,type:r},s){const e=A(ct,s,t),o=A(it,n,t);if(r===H.RAY&&d(o,e)<-x())return E(t,s);const c=N(ut,o,e);return y(c)/y(o)}const O=(()=>{const t=M(),n=M(),r=M();return({start:s,end:e},{center:o,radius:c,normal:i,slicePlane:u})=>{const a=Y(o,i,Lt);if($(g(a,s),0)&&$(g(a,e),0)){F(i,t,n);const a=(s,e)=>(b(r,e,o),f(s,d(r,t),d(r,n)),s),p=_({start:a(et,s),end:a(ot,e),type:H.LINE},L,c),m=[];for(const[r,s]of p){const e=P(M(),o);l(e,e,t,r),l(e,e,n,s),u&&!nt(u,e)||m.push(e)}return m}const p=M();return q(a,s,e,p)?!$(E(p,o),c)||u&&!nt(u,p)?[]:[p]:[]}})();function Q({start:t,end:e,type:o},c,i){const u=[],a=b(ct,e,t),f=n(ot,t,c),p=r(a),m=2*s(a,f),L=m*m-4*p*(r(f)-i*i);if(0===L){const n=-m/(2*p);(o===H.LINE||n>=0)&&u.push(l(M(),t,a,n))}else if(L>0){const n=Math.sqrt(L),r=(-m+n)/(2*p);(o===H.LINE||r>=0)&&u.push(l(M(),t,a,r));const s=(-m-n)/(2*p);(o===H.LINE||s>=0)&&u.push(l(M(),t,a,s))}return u}function S(t,n){const r=t.start,s=t.end,e=n.start,o=n.end,c=A(ct,s,r),i=A(it,o,e),u=A(ut,e,r),a=N(at,c,i);if(!$(d(u,a),0))return[];const f=j(a);if($(f,0))return[];const p=N(ft,u,i),m=d(p,a)/f,L=l(pt,r,c,m);if(t.type===H.RAY){const t=A(mt,L,r);if(d(c,t)<-x())return[]}if(n.type===H.RAY){const t=A(mt,L,e);if(d(i,t)<-x())return[]}return[I(L)]}function T({start:t,end:n,type:r},s){const e=A(ct,s,t),o=A(it,n,t),c=N(ut,o,e),i=j(c)/j(o),u=x();if(i<u)switch(r){case H.LINE:return[I(s)];case H.RAY:return d(o,e)<-u?[]:[I(s)]}return[]}function V(t,n,r){return $(u(r,t),n*n)?[I(r)]:[]}function W(t,n,r,s){const[e,o]=t,[c,i]=r,u=c-e,f=i-o,p=u*u+f*f,L=Math.sqrt(p);if(L>n+s)return[];if(L<Math.abs(n-s))return[];if($(L,0)&&$(n,s))return[];const h=(n*n-s*s+p)/(2*L),A=Math.sqrt(n*n-h*h),d=A*f/L,l=A*u/L,[E,N]=a(et,t,r,h/L);return $(d,l)?[m(E,N)]:[m(E+d,N-l),m(E-d,N+l)]}function X(t,n,{start:r,end:s,type:e}){return h(t.start,r[0],r[1],n),h(t.end,s[0],s[1],n),t.type=st[e],t}function Z(t,n){return $(t[2],n[2])}function $(n,r){return t(Math.abs(n-r),0,x())}function tt(t,n){return n.filter((n=>nt(t,n)))}function nt(t,n){return v(t,n)}var rt;!function(t){t[t.PLANE=0]="PLANE",t[t.HALF_PLANE=1]="HALF_PLANE"}(rt||(rt={}));const st={[rt.PLANE]:H.LINE,[rt.HALF_PLANE]:H.RAY},et=p(),ot=p(),ct=M(),it=M(),ut=M(),at=M(),ft=M(),pt=M(),mt=M(),Lt=R(),ht={start:M(),end:M(),type:H.LINE},At={start:M(),end:M(),type:H.LINE};export{H as LineType,rt as VerticalPlaneType,T as intersectLineAndPoint,O as intersectLineLikeAndCircle,Q as intersectLineLikeAndVerticalCylinder,S as intersectLineLikes,V as intersectVerticalCylinderAndPoint,W as intersectVerticalCylinders,U as intersectVerticalPlaneAndLineLike,w as intersectVerticalPlaneAndPoint,k as intersectVerticalPlaneAndVerticalCylinder,z as intersectVerticalPlanes,$ as isClose,nt as isPointInsidePlane,K as pointToLineLikeDistance,G as pointToVerticalCylinderDistance,D as pointToVerticalPlaneDistance,tt as pointsInsidePlane,J as projectPointToLineLike,B as projectPointToVerticalCylinder,C as projectPointToVerticalPlane,Z as vectorsHaveCloseZ};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecatedProperty as r,deprecated as i}from"../../core/deprecate.js";import s from"../../core/Error.js";import o from"../../core/Evented.js";import{makeHandle as n}from"../../core/handleUtils.js";import l from"../../core/Logger.js";import{abortMaybe as p,removeMaybe as d,destroyMaybe as c}from"../../core/maybe.js";import{throwIfAborted as u,createResolver as h}from"../../core/promiseUtils.js";import{watch as w,on as f,when as m,whenOnce as y,syncAndInitial as k,initial as g,sync as v}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as W}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import I from"../../layers/GraphicsLayer.js";import{isEditableLayer as F}from"../../layers/support/editableLayers.js";import{isFeatureLayer as E,getOwningPortalUrl as M}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as C}from"../../portal/support/urlUtils.js";import V from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as O}from"../../views/interactive/snapping/SnappingManager.js";import U from"../../views/interactive/snapping/SnappingOptions.js";import T from"../Attachments/AttachmentsViewModel.js";import L from"./CreateFeaturesWorkflow.js";import A from"./UpdateWorkflow.js";import{whenEditorLayerView as j}from"./workflowUtils.js";import S from"./support/EditorItem.js";import P from"../FeatureTemplates/FeatureTemplatesViewModel.js";import R from"../Sketch/SketchViewModel.js";import H from"../Spinner/SpinnerViewModel.js";const x="esri.widgets.Editor.EditorViewModel",D=()=>l.getLogger(x),G=["create-features","update"];function q(t,e,a){D().error(new s(t,e,a))}function B(t,e){return t?.find((t=>t.layer===e))}let Q=class extends o.EventedAccessor{constructor(t){super(t),this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new I({listMode:"hide",internal:!0}),this._snappingManager=null,this._updateItemsTask=null,this._updatingHandles=new b,this._featureTemplatesViewModelLocked=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new T({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new P({disabledItemFunction:({layer:t})=>this._itemIsSuspended(t)}),this.ownSketchViewModel=new R({layer:this._sketchGraphicsLayer}),this.sketchOptions=new V,this.snappingOptions=new U,this.spinnerViewModel=new H,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t){if(t.submit(),!t.submittable)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return}await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([w((()=>{const t=this.view,e=t?.map?.editableLayers,a=t?.allLayerViews,r=a?.filter((t=>!!e?.includes(t.layer)));return[e,r,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditorItems()),k),w((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),f((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),f((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),f((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),m((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),g),f((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),w((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),w((()=>this.page),((t,e)=>{const a=[...this.pageStack];if(-1===a.indexOf(t))a.push(t);else for(;a.length&&a.at(-1)!==t;)a.pop();this.pageStack=a}),k),m((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),f((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this;if(a){if("update"===a.type&&"awaiting-feature-creation-info"===a.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(e,{emit:!1})}}if(!t)return;const r={layer:t.layer,template:t.template};if(t.supportsUpload)return this.featureTemplatesViewModel.select(e,{emit:!1}),this.startCreateFeaturesWorkflow(r);this.startCreateFeaturesWorkflowAtFeatureCreation(r)})),f((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(t.stopPropagation(),this.back())})),f((()=>this.sketchViewModel),["create","delete","update"],(t=>{const{activeWorkflow:e}=this,a="update"===e?.type,r=a?e.activeWorkflow?.layer:e?.layer,i=a?e?.activeWorkflow?.parentLayer:void 0,s=`sketch-${t.type}`;this.emit(s,{type:s,detail:t,layer:r,parentLayer:i})}),v),w((()=>this.view),(t=>{if(this._snappingManager=c(this._snappingManager),!t)return;const e=this.snappingOptions;this._snappingManager=new O({view:t,options:e})}),k),w((()=>this.snappingOptions),(t=>{this._snappingManager&&(this._snappingManager.options=t)}),k)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=d(this._sketchEventListenerHandle)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){r(l.getLogger(this),"allowedWorkflows",{replacement:"Editor.visibleElements",version:"4.29",warnOnce:!0}),t&&0!==t.length||(t=[...G]),this._set("allowedWorkflows",t)}get canCreate(){return this.editorItems.some((t=>t.supportsCreateFeaturesWorkflow))}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some((t=>t.supportsUpdateWorkflow))}get canUpdateVisible(){return this.editorItems.some((t=>t.supportsUpdateWorkflow&&t.visible))}get featureTemplatesLayers(){const t=new a;for(const e of this.editorItems){const a=e.supportsCreateFeaturesWorkflow&&!e.isTable,r=this.hideTemplatesForInactiveLayers&&!e.visible;a&&!r&&t.push(e.layer)}return t}get editableItems(){return r(l.getLogger(this),"editableItems",{replacement:"editorItems",version:"4.29",warnOnce:!0}),this.editorItems.map((t=>{const{capabilities:e,disabled:a,hasInvalidFormTemplate:r,layer:i}=t,s=[],o=e.create,n=e.update,l=e.delete;return o.enabled&&s.push("create"),n.enabled&&s.push("update"),l.enabled&&s.push("delete"),{layer:i,supports:s,suspended:a,attributeUpdatesEnabled:n.attributes,geometryUpdatesEnabled:n.geometry,attachmentsOnCreateEnabled:o.attachments.enabled,attachmentsOnUpdateEnabled:n.attachments.enabled,hasInvalidFormTemplate:r,hasAttachments:e.attachments.enabled}}))}get featureFormViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeFeatureFormViewModel:"create-features"===t?.type?t.featureFormViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(t){this.sketchOptions.labels=t}set layerInfos(t){const e=t?.some((t=>"allowAttachments"in t));e&&i(D(),"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),this._set("layerInfos",t)}get sketchViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeSketchViewModel:"create-features"===t?.type?t.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?.stepId?"update"===e.type&&e.activeWorkflow?.stepId?e.activeWorkflow.stepId:e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(t){this.sketchOptions.tooltips=t}get valueOptions(){return this.sketchOptions.values}set valueOptions(t){this.sketchOptions.values=t}set view(t){this.ownSketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;if("update"===t?.type&&"awaiting-feature-to-update"===t.stepId)return"ready";if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.upload;if(e)return"default"===e.state?"ready":"creating-features-upload-details"}return e??"disabled"}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t.activeEditorItem?.capabilities.update.attributes}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditorItem?.capabilities.delete.enabled}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await y((()=>!this.updating)),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const a=this._createUpdatingResolver();await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow(t,e);this._set("activeWorkflow",r),await r.start(),a.resolve()}async startCreateFeaturesWorkflowAtFeatureEdit(t){await y((()=>!this.updating));const e=this._createUpdatingResolver(),{initialFeature:a}=t,r=a.sourceLayer,i=r?this.findEditorItemForLayer(r):void 0;if(!i?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const o=this._createCreateFeaturesWorkflow({initialFeature:a,layer:i.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",o),await o.start(),e.resolve()}async startUpdateWorkflowAtFeatureSelection(){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start(),t.resolve()}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("awaiting-update-feature-candidate");a.data.candidates=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async startUpdateWorkflowAtFeatureEdit(t){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("editing-existing-feature");a.data.rootFeature=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():q("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warnIfNoWorkflow:!0,...t})}findEditorItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this.editorItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return null!=t&&!0===this.findEditorItemForLayer(t.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelLocked||(this.featureTemplatesViewModel.layers=this.featureTemplatesLayers.toArray())}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}lockFeatureTemplatesViewModel(){return this._featureTemplatesViewModelLocked=!0,n((()=>{this._featureTemplatesViewModelLocked=!1,this.syncFeatureTemplates()}))}async _getEditorItemCandidates(t){const{view:e}=this;if(!e?.map)return[];const{map:a}=e,r=a.editableLayers.toArray()??[],i=a.allTables.toArray().filter(E)??[];return await Promise.allSettled([...r.map((t=>"subtype-group"===t.type?t.loadAll():Promise.resolve())),...i.map((t=>t.load()))]),u(t),[...r.reverse(),...i.reverse()].filter((t=>F(t)&&("mesh"!==t.geometryType||"3d"===e.type))).flatMap((t=>"subtype-group"===t.type?t.sublayers.toArray():t))}_drainEditorItems(){this.editorItems.drain((t=>t.destroy()))}async _updateEditorItems(){p(this._updateItemsTask);const{view:t}=this,a=e((async e=>{if(!t?.map||!t?.allLayerViews)return;const a=await this._getEditorItemCandidates(e);if(!a.length)return void this._drainEditorItems();const r=[],i=[],s=[],{layerInfos:o}=this;for(const l of a){const e=B(o,l),a=await j(t,l).catch((()=>null));(e?r:a?i:s).push(new S({layer:l,layerInfo:e,layerView:a}))}o?.length&&r.sort(((t,e)=>o.findIndex((({layer:e})=>e===t.layer))-o.findIndex((({layer:t})=>t===e.layer))));const n=[...r,...i,...s];e.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(a.promise),this._updateItemsTask=a}_afterEditorItemsChange(){const{activeWorkflow:t}=this;if(this.syncFeatureTemplates(),!t)return;const{stepId:e}=t;"create-features"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===e&&!t.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t?.warnIfNoWorkflow&&q("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return L.create({viewModel:this,creationInfo:t,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createUpdateWorkflow(t){return A.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if(!("addAttachment"in t)||null==t.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await M(t.url):null,s={returnServiceEditsOption:(!i||!C(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const{view:a}=this;if(!a)return null;const i=await j(a,t).catch((()=>null));return r=await t.applyEdits(e,s),i&&await y((()=>!i.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t);const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if(null!=t&&"error"in t&&null!=t.error)throw t.error;if(null!=t&&"addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{q("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue)}))}_createUpdatingResolver(){const t=h();return this._updatingHandles.addPromise(t.promise),t}_itemIsSuspended(t){const e=this.findEditorItemForLayer(t);return null!=e&&(!e.visible||e.disabled)}};t([_({readOnly:!0})],Q.prototype,"activeWorkflow",void 0),t([_({readOnly:!0})],Q.prototype,"_activityQueue",void 0),t([_({value:[...G]})],Q.prototype,"allowedWorkflows",null),t([_({readOnly:!0})],Q.prototype,"canCreate",null),t([_()],Q.prototype,"canCreateVisible",null),t([_({readOnly:!0})],Q.prototype,"canUpdate",null),t([_()],Q.prototype,"canUpdateVisible",null),t([_()],Q.prototype,"featureTemplatesLayers",null),t([_()],Q.prototype,"editableItems",null),t([_()],Q.prototype,"editorItems",void 0),t([_({readOnly:!0})],Q.prototype,"failures",void 0),t([_()],Q.prototype,"hideTemplatesForInactiveLayers",void 0),t([_()],Q.prototype,"attachmentsViewModel",void 0),t([_()],Q.prototype,"featureFormViewModel",null),t([_()],Q.prototype,"featureTemplatesViewModel",void 0),t([_()],Q.prototype,"labelOptions",null),t([_()],Q.prototype,"layerInfos",null),t([_()],Q.prototype,"ownSketchViewModel",void 0),t([_()],Q.prototype,"sketchOptions",void 0),t([_()],Q.prototype,"sketchViewModel",null),t([_({type:U,nonNullable:!0})],Q.prototype,"snappingOptions",void 0),t([_()],Q.prototype,"spinnerViewModel",void 0),t([_()],Q.prototype,"state",null),t([_({readOnly:!0})],Q.prototype,"syncing",null),t([_()],Q.prototype,"updating",null),t([_()],Q.prototype,"tooltipOptions",null),t([_()],Q.prototype,"valueOptions",null),t([_()],Q.prototype,"view",null),t([_()],Q.prototype,"pageStack",void 0),t([_()],Q.prototype,"showDiscardEditsPrompt",void 0),t([_()],Q.prototype,"_candidateCommitted",void 0),t([_()],Q.prototype,"page",null),t([_()],Q.prototype,"featureFormDisabled",null),t([_()],Q.prototype,"canGoBack",null),t([_()],Q.prototype,"shouldShowDeleteButton",null),t([_()],Q.prototype,"hasPendingEdits",null),Q=t([W(x)],Q);const N=Q;export{N as default};
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecatedProperty as r,deprecated as i}from"../../core/deprecate.js";import s from"../../core/Error.js";import o from"../../core/Evented.js";import{makeHandle as n}from"../../core/handleUtils.js";import l from"../../core/Logger.js";import{abortMaybe as p,removeMaybe as d,destroyMaybe as c}from"../../core/maybe.js";import{throwIfAborted as u,createResolver as h}from"../../core/promiseUtils.js";import{watch as w,on as f,when as m,whenOnce as y,syncAndInitial as k,initial as g,sync as v}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as W}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import I from"../../layers/GraphicsLayer.js";import{isEditableLayer as F}from"../../layers/support/editableLayers.js";import{isFeatureLayer as E,getOwningPortalUrl as M}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as C}from"../../portal/support/urlUtils.js";import V from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as O}from"../../views/interactive/snapping/SnappingManager.js";import U from"../../views/interactive/snapping/SnappingOptions.js";import T from"../Attachments/AttachmentsViewModel.js";import L from"./CreateFeaturesWorkflow.js";import A from"./UpdateWorkflow.js";import{whenEditorLayerView as j}from"./workflowUtils.js";import S from"./support/EditorItem.js";import P from"../FeatureTemplates/FeatureTemplatesViewModel.js";import R from"../Sketch/SketchViewModel.js";import H from"../Spinner/SpinnerViewModel.js";const x="esri.widgets.Editor.EditorViewModel",D=()=>l.getLogger(x),G=["create-features","update"];function q(t,e,a){D().error(new s(t,e,a))}function B(t,e){return t?.find((t=>t.layer===e))}let Q=class extends o.EventedAccessor{constructor(t){super(t),this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new I({listMode:"hide",internal:!0}),this._snappingManager=null,this._updateItemsTask=null,this._updatingHandles=new b,this._featureTemplatesViewModelLocked=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new T({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new P({disabledItemFunction:({layer:t})=>this._itemIsSuspended(t)}),this.ownSketchViewModel=new R({layer:this._sketchGraphicsLayer}),this.sketchOptions=new V,this.snappingOptions=new U,this.spinnerViewModel=new H,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t){if(t.submit(),!t.submittable)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return}await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([w((()=>{const t=this.view,e=t?.map?.editableLayers,a=t?.allLayerViews,r=a?.filter((t=>!!e?.includes(t.layer)));return[e,r,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditorItems()),k),w((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),f((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),f((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),f((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),m((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),g),f((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),w((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),w((()=>this.page),((t,e)=>{const a=[...this.pageStack];if(-1===a.indexOf(t))a.push(t);else for(;a.length&&a.at(-1)!==t;)a.pop();this.pageStack=a}),k),m((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),f((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this;if(a){if("update"===a.type&&"awaiting-feature-creation-info"===a.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(e,{emit:!1})}}if(!t)return;const r={layer:t.layer,template:t.template};if(t.supportsUpload)return this.featureTemplatesViewModel.select(e,{emit:!1}),this.startCreateFeaturesWorkflow(r);this.startCreateFeaturesWorkflowAtFeatureCreation(r)})),f((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(t.stopPropagation(),this.back())})),f((()=>this.sketchViewModel),["create","delete","update"],(t=>{const{activeWorkflow:e}=this,a="update"===e?.type,r=a?e.activeWorkflow?.layer:e?.layer,i=a?e?.activeWorkflow?.parentLayer:void 0,s=`sketch-${t.type}`;this.emit(s,{type:s,detail:t,layer:r,parentLayer:i})}),v),w((()=>this.view),(t=>{if(this._snappingManager=c(this._snappingManager),!t)return;const e=this.snappingOptions;this._snappingManager=new O({view:t,options:e})}),k),w((()=>this.snappingOptions),(t=>{this._snappingManager&&(this._snappingManager.options=t)}),k)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=d(this._sketchEventListenerHandle)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){r(l.getLogger(this),"allowedWorkflows",{replacement:"Editor.visibleElements",version:"4.29",warnOnce:!0}),t&&0!==t.length||(t=[...G]),this._set("allowedWorkflows",t)}get canCreate(){return this.editorItems.some((t=>t.supportsCreateFeaturesWorkflow))}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some((t=>t.supportsUpdateWorkflow))}get canUpdateVisible(){return this.editorItems.some((t=>t.supportsUpdateWorkflow&&t.visible))}get featureTemplatesLayers(){const t=new a;for(const e of this.editorItems){const a=e.supportsCreateFeaturesWorkflow&&!e.isTable,r=this.hideTemplatesForInactiveLayers&&!e.visible;a&&!r&&t.push(e.layer)}return t}get editableItems(){return r(l.getLogger(this),"editableItems",{replacement:"editorItems",version:"4.29",warnOnce:!0}),this.editorItems.map((t=>{const{capabilities:e,disabled:a,hasInvalidFormTemplate:r,layer:i}=t,s=[],o=e.create,n=e.update,l=e.delete;return o.enabled&&s.push("create"),n.enabled&&s.push("update"),l.enabled&&s.push("delete"),{layer:i,supports:s,suspended:a,attributeUpdatesEnabled:n.attributes,geometryUpdatesEnabled:n.geometry,attachmentsOnCreateEnabled:o.attachments.enabled,attachmentsOnUpdateEnabled:n.attachments.enabled,hasInvalidFormTemplate:r,hasAttachments:e.attachments.enabled}}))}get featureFormViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeFeatureFormViewModel:"create-features"===t?.type?t.featureFormViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(t){this.sketchOptions.labels=t}set layerInfos(t){const e=t?.some((t=>"allowAttachments"in t));e&&i(D(),"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),this._set("layerInfos",t)}get sketchViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeSketchViewModel:"create-features"===t?.type?t.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?.stepId?"update"===e.type&&e.activeWorkflow?.stepId?e.activeWorkflow.stepId:e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(t){this.sketchOptions.tooltips=t}get valueOptions(){return this.sketchOptions.values}set valueOptions(t){this.sketchOptions.values=t}set view(t){this.ownSketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;if("update"===t?.type&&"awaiting-feature-to-update"===t.stepId)return"ready";if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.upload;if(e)return"default"===e.state?"ready":"creating-features-upload-details"}return e??"disabled"}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t.activeEditorItem?.capabilities.update.attributes}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditorItem?.capabilities.delete.enabled}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await y((()=>!this.updating)),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const a=this._createUpdatingResolver();await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow(t,e);this._set("activeWorkflow",r),await r.start(),a.resolve()}async startCreateFeaturesWorkflowAtFeatureEdit(t){await y((()=>!this.updating));const e=this._createUpdatingResolver(),{initialFeature:a}=t,r=a.sourceLayer,i=r?this.findEditorItemForLayer(r):void 0;if(!i?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const o=this._createCreateFeaturesWorkflow({initialFeature:a,layer:i.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",o),await o.start(),e.resolve()}async startUpdateWorkflowAtFeatureSelection(){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start(),t.resolve()}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("awaiting-update-feature-candidate");a.data.candidates=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async startUpdateWorkflowAtFeatureEdit(t){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("editing-existing-feature");a.data.rootFeature=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():q("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warnIfNoWorkflow:!0,...t})}findEditorItemForLayer(t){return this.editorItems.find((e=>e.layer===t))}itemHasInvalidFormTemplate(t){return null!=t&&!0===this.findEditorItemForLayer(t.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelLocked||(this.featureTemplatesViewModel.layers=this.featureTemplatesLayers.toArray())}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}lockFeatureTemplatesViewModel(){return this._featureTemplatesViewModelLocked=!0,n((()=>{this._featureTemplatesViewModelLocked=!1,this.syncFeatureTemplates()}))}async _getEditorItemCandidates(t){const{view:e}=this;if(!e?.map)return[];const{map:a}=e,r=a.editableLayers.toArray()??[],i=a.allTables.toArray().filter(E)??[];return await Promise.allSettled([...r.map((t=>"subtype-group"===t.type?t.loadAll():Promise.resolve())),...i.map((t=>t.load()))]),u(t),[...r.reverse(),...i.reverse()].filter((t=>F(t)&&("mesh"!==t.geometryType||"3d"===e.type))).flatMap((t=>"subtype-group"===t.type?t.sublayers.toArray():t))}_drainEditorItems(){this.editorItems.drain((t=>t.destroy()))}async _updateEditorItems(){p(this._updateItemsTask);const{view:t}=this,a=e((async e=>{if(!t?.map||!t?.allLayerViews)return;const a=await this._getEditorItemCandidates(e);if(!a.length)return void this._drainEditorItems();const r=[],i=[],s=[],{layerInfos:o}=this;for(const l of a){const e=B(o,l),a=await j(t,l).catch((()=>null));(e?r:a?i:s).push(new S({layer:l,layerInfo:e,layerView:a}))}o?.length&&r.sort(((t,e)=>o.findIndex((({layer:e})=>e===t.layer))-o.findIndex((({layer:t})=>t===e.layer))));const n=[...r,...i,...s];e.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(a.promise),this._updateItemsTask=a}_afterEditorItemsChange(){const{activeWorkflow:t}=this;if(this.syncFeatureTemplates(),!t)return;const{stepId:e}=t;"create-features"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===e&&!t.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t?.warnIfNoWorkflow&&q("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return L.create({viewModel:this,creationInfo:t,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createUpdateWorkflow(t){return A.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if(!("addAttachment"in t)||null==t.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await M(t.url):null,s={returnServiceEditsOption:(!i||!C(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const{view:a}=this;if(!a)return null;const i=await j(a,t).catch((()=>null));return r=await t.applyEdits(e,s),i&&await y((()=>!i.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t);const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if(null!=t&&"error"in t&&null!=t.error)throw t.error;if(null!=t&&"addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{q("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue)}))}_createUpdatingResolver(){const t=h();return this._updatingHandles.addPromise(t.promise),t}_itemIsSuspended(t){const e=this.findEditorItemForLayer(t);return null!=e&&(!e.visible||e.disabled)}};t([_({readOnly:!0})],Q.prototype,"activeWorkflow",void 0),t([_({readOnly:!0})],Q.prototype,"_activityQueue",void 0),t([_({value:[...G]})],Q.prototype,"allowedWorkflows",null),t([_({readOnly:!0})],Q.prototype,"canCreate",null),t([_()],Q.prototype,"canCreateVisible",null),t([_({readOnly:!0})],Q.prototype,"canUpdate",null),t([_()],Q.prototype,"canUpdateVisible",null),t([_()],Q.prototype,"featureTemplatesLayers",null),t([_()],Q.prototype,"editableItems",null),t([_()],Q.prototype,"editorItems",void 0),t([_({readOnly:!0})],Q.prototype,"failures",void 0),t([_()],Q.prototype,"hideTemplatesForInactiveLayers",void 0),t([_()],Q.prototype,"attachmentsViewModel",void 0),t([_()],Q.prototype,"featureFormViewModel",null),t([_()],Q.prototype,"featureTemplatesViewModel",void 0),t([_()],Q.prototype,"labelOptions",null),t([_()],Q.prototype,"layerInfos",null),t([_()],Q.prototype,"ownSketchViewModel",void 0),t([_()],Q.prototype,"sketchOptions",void 0),t([_()],Q.prototype,"sketchViewModel",null),t([_({type:U,nonNullable:!0})],Q.prototype,"snappingOptions",void 0),t([_()],Q.prototype,"spinnerViewModel",void 0),t([_()],Q.prototype,"state",null),t([_({readOnly:!0})],Q.prototype,"syncing",null),t([_()],Q.prototype,"updating",null),t([_()],Q.prototype,"tooltipOptions",null),t([_()],Q.prototype,"valueOptions",null),t([_()],Q.prototype,"view",null),t([_()],Q.prototype,"pageStack",void 0),t([_()],Q.prototype,"showDiscardEditsPrompt",void 0),t([_()],Q.prototype,"_candidateCommitted",void 0),t([_()],Q.prototype,"page",null),t([_()],Q.prototype,"featureFormDisabled",null),t([_()],Q.prototype,"canGoBack",null),t([_()],Q.prototype,"shouldShowDeleteButton",null),t([_()],Q.prototype,"hasPendingEdits",null),Q=t([W(x)],Q);const N=Q;export{N as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{lerp as e}from"../../../core/mathUtils.js";import{throwIfAborted as t}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as n}from"../../../core/unitUtils.js";import{distance as r,lerp as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{
|
|
5
|
+
import{lerp as e}from"../../../core/mathUtils.js";import{throwIfAborted as t}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as n}from"../../../core/unitUtils.js";import{distance as r,lerp as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{m as o}from"../../../chunks/vec32.js";import a from"../../../geometry/Polyline.js";import{initializeProjection as i,project as c}from"../../../geometry/projection.js";import u from"../../../geometry/SpatialReference.js";import{geodesicLengths as l,isSupported as f,inverseGeodeticSolver as h,directGeodeticSolver as p}from"../../../geometry/support/geodesicUtils.js";import{getElevationOffset as m}from"../../../support/elevationInfoUtils.js";import{ProfileGenerationError as d,ProfileGenerationErrorCause as g}from"./ProfileGenerationError.js";async function w(e,r,s,o,a,f,h){let p,m,w;const j=e.spatialReference,v=j.isGeographic||j.isWebMercator;let P=0;if(!v){const{planarLength:n}=await import("../../../geometry/geometryEngineAsync.js");t(h),P=await n(e,"meters"),t(h)}const Z=1/n(o),x=a.geodesicDistanceThreshold??1/0;if(v||P>=x){await i([{source:j,dest:o},{source:j,dest:u.WGS84}],h);const t=k(e);p=l([t],"meters")[0];const n=y(p,a);if(D(e,p,n)>f)throw new d(g.TooComplex);const v=R(t,r,s);({densifiedPath:m,distances:w}=b(v,n,Z)),m=c(m,o)}else{await i([{source:j,dest:o}],h),p=P;const n=y(p,a);if(D(e,p,n)>f)throw new d(g.TooComplex);const u=R(e,r,s);({densifiedPath:m,distances:w}=S(u,n,Z)),t(h),m=c(m,o)}return{densifiedPath:m,pathLength:p*Z,distances:w}}function y(e,t){const n=e/t.densificationMaxSamples;return Math.max(t.samplingDistance,n)}function R(e,t,n){if(null==t)return P(e);const r=e.spatialReference,s=t.mode,o=m(t,r);let i=null;switch(n.type){case"2d":i=j(e,s,o);break;case"3d":i=v(e,s,o,n)}return null==i?P(e):new a({hasZ:!0,hasM:!1,spatialReference:r,paths:Z(e.paths,i)})}function j({hasZ:e},t,n){return"absolute-height"===t?e?([e,t,r])=>[e,t,r+n]:([e,t])=>[e,t,n]:null}function v({spatialReference:e,hasZ:t},n,r,{elevationProvider:s}){const o=(t,n,r,o)=>s?.getElevation(t,n,r,e,o)??0;switch(n){case"on-the-ground":return([e,t])=>[e,t,o(e,t,0,"ground")];case"absolute-height":return t?([e,t,n])=>[e,t,n+r]:([e,t])=>[e,t,r];case"relative-to-ground":return t?([e,t,n])=>[e,t,n+o(e,t,n,"ground")+r]:([e,t])=>[e,t,o(e,t,0,"ground")+r];case"relative-to-scene":return t?([e,t,n])=>[e,t,n+o(e,t,n,"scene")+r]:([e,t])=>[e,t,o(e,t,0,"scene")+r];default:return null}}function P(e){return e.hasZ?new a({hasZ:!1,hasM:!1,spatialReference:e.spatialReference,paths:Z(e.paths,(([e,t])=>[e,t]))}):e}function Z(e,t){const n=e.length,r=new Array(n);for(let s=0;s<n;++s){const n=e[s],o=n.length,a=new Array(n.length);r[s]=a;for(let e=0;e<o;++e)a[e]=t(n[e])}return r}function x(e){return M(e)&&e.paths.length>0&&e.paths.every((e=>e.length>=2))}function M(e){return null!=e&&"polyline"===e.type}function A(e,t,r,s,o){const{spatialReference:i,hasZ:c}=e,u={from:null,to:null,distance:0,azimuth:0,reverseAzimuth:0,spatialReference:i,metersPerSR:n(i)},l=[],f=[];let h=0;for(let n=0;n<e.paths.length;++n){const a=e.paths[n],i=new Array,c=new Array;let p=0;for(let e=1;e<a.length;++e){const n=a[e-1],l=a[e],f=s(u,n,l);let m;for(m=p;m<f.distance;m+=t)i.push(o(f,m)),c.push((h+m)*r);p=m-f.distance,h+=f.distance,i.push(l),c.push(h*r)}l[n]=i,f[n]=c}return{densifiedPath:new a({spatialReference:i,hasZ:c,paths:l}),distances:f}}function S(e,t,n){const{hasZ:r}=e;return A(e,t,n,z,r?W:T)}function b(e,t,n){const{hasZ:r}=e;return A(e,t,n,U,r?E:G)}function U(e,t,n){return e.distance=0,h(e,t,n,e.spatialReference),e.from=t,e.to=n,e}function z(e,t,n){return e.from=t,e.to=n,e.distance=r(n,t)*e.metersPerSR,e}function G({from:e,azimuth:t,spatialReference:n},r){return p([0,0],e,t,r,n)}function E({from:t,to:n,azimuth:r,distance:s,spatialReference:o},a){const i=a/s,c=[0,0,e(t[2],n[2],i)];return p(c,t,r,a,o),c}function T({from:e,to:t,distance:n},r){return s([0,0],e,t,r/n)}function W({from:e,to:t,distance:n},r){return o([0,0,0],e,t,r/n)}function k(e){return f(e.spatialReference)?e:c(e,u.WGS84)}function C(e){return e.paths.reduce(((e,t)=>e+t.length),0)}function D(e,t,n){return C(e)+Math.floor(t/n)+Math.max(0,e.paths.reduce((e=>1+e),0)-1)}export{C as countPoints,w as densifyPath,M as isPolyline,x as isValidInputPath,R as toAbsoluteHeightElevation};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Handles.js";import{debounce as r,ignoreAbortErrors as o}from"../../core/promiseUtils.js";import{on as l,watch as n}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as d}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as m,system as g}from"../../time/timeZoneUtils.js";import{highlightsSupported as c}from"../../views/support/layerViewUtils.js";import p from"./AttachmentsColumn.js";import u from"./FieldColumn.js";import y from"./Grid/Column.js";import f from"./Grid/Grid.js";import b from"./Grid/GridViewModel.js";import _ from"./Grid/GroupColumn.js";import w from"./support/FeatureStore.js";import"../support/widgetUtils.js";import{messageBundle as v}from"../support/decorators/messageBundle.js";import{onLocaleChange as I}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as F}from"../../intl/date.js";import{fetchMessageBundle as E}from"../../intl/messages.js";let C=class extends b{constructor(e){super(e),this._debounceRefresh=r((()=>this._refresh())),this._highlights=new s,this.activeFilters=new i,this.attachmentsEnabled=!1,this.autoRefreshEnabled=!0,this.cellClassNameGenerator=(e,t)=>e.path||"",this.columns=new i,this.dataProvider=async(e,t)=>{const{store:i}=this,s=this._sortOrdersToLayerOrderByFields(e.sortOrders);t&&(i?(i.set({orderByFields:s}),"loaded"!==i.state&&"loading"!==i.state&&await i.load(),t&&t(await i.fetchItems(e))):t&&t([]))},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.layer=null,this.messagesCommon=null,this.messagesURIUtils=null,this.relatedRecordsEnabled=!1,this.returnGeometryEnabled=!1,this.store=null,this.tableTemplate=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new w),this._set("grid",new f({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await E("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await E("esri/t9n/common"),this.messagesURIUtils=await E("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([I((()=>{e(),this._generateColumns()})),l((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>{this.highlightIds.forEach((e=>this._highlight(e)))},onListenerRemove:()=>{this.highlightIds.forEach((e=>this._removeHighlight(e)))}}),n((()=>this.attachmentsEnabled),(e=>{this.store.attachmentsEnabled=e,this.layer?.loaded&&this._generateColumns()})),n((()=>this.layerView),(e=>{this._highlights.removeAll(),e&&this.highlightEnabled&&this.highlightIds?.forEach((e=>this._highlight(e)))})),n((()=>this.highlightEnabled),(e=>{this._highlights.removeAll(),e&&this.highlightIds?.forEach((e=>this._highlight(e)))})),n((()=>this.relatedRecordsEnabled),(e=>this.store.relatedRecordsEnabled=e)),n((()=>this.returnGeometryEnabled),(e=>this.store.returnGeometry=e)),n((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await i.reset()),this._drainColumns(),e&&(this.store.layer=e,e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),n((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),n((()=>this.store.state),(e=>{"loaded"===e&&this.grid?.scrollToTop()})),n((()=>[this.messages,this.tableTemplate]),(()=>this.layer?.loaded&&this._generateColumns())),n((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this.grid?.onColumnChange()})),n((()=>this.editingEnabled),(e=>{this.columns.forEach((t=>{"editingEnabled"in t&&(t.editingEnabled=e)})),this.grid?.onColumnChange()})),n((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),n((()=>this.layer&&"timeExtent"in this.layer&&this.layer.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),l((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e)))])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return d(this.layer)}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}set filterGeometry(e){if(!this.filterGeometry&&!e)return;const t=this.activeFilters.find((e=>"geometry"===e.type));t&&this.activeFilters.remove(t),this._set("filterGeometry",e),this.store.filterGeometry=e,e&&this.activeFilters.add({type:"geometry",geometry:e})}get hiddenFields(){return this._get("hiddenFields")??new i}set hiddenFields(e){Array.isArray(e)?this._set("hiddenFields",new i(e)):this._set("hiddenFields",e)}get highlightOnRowSelectEnabled(){return this.highlightEnabled}set highlightOnRowSelectEnabled(e){this.highlightEnabled=e}get layerView(){return this.view?.allLayerViews.find((e=>e.layer===this.layer))||null}set messages(e){this.grid?.set("messages",e),this._set("messages",e)}get state(){const{store:e}=this;return e&&"disabled"!==e.state?"loading"===e.state?"loading":"loaded"===e.state?"loaded":"ready":"disabled"}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}clearSelection(){this.grid?.clearSelection()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.deselectRows(i),await this.refresh())}deselectRows(e){const t=this._getStoreItemsFromSelectionParams(e);this.grid?.deselectRows(t)}filterBySelection(){const e=this.highlightIds.toArray();e.length&&(this.clearSelectionFilter(),this.store.objectIds=e,this.activeFilters.add({type:"selection",objectIds:e}))}getObjectIdIndex(e){return this.store?.getObjectIdIndex(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}get highlightIds(){return this._get("highlightIds")||new i}set highlightIds(e){Array.isArray(e)?this._set("highlightIds",new i(e)):this._set("highlightIds",e)}async refresh(){return o(this._debounceRefresh())}reset(){this.grid?.reset()}selectRows(e){const t=this._getStoreItemsFromSelectionParams(e);return this.grid?.selectRows(t)}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){this.store.objectIds=null;const e=this.activeFilters.find((e=>"selection"===e.type));e&&this.activeFilters.remove(e)}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const r=await e.queryFeatures(s);try{await t.goTo(r.features)}catch(o){"AbortError"!==o.name&&console.error(o)}}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.deselectRows(e[i])}))}this.grid?.refreshPageCache()}_onLayerLoad(){const e=this.layer.capabilities?.query.maxRecordCount;e&&e<this.pageSize&&this.grid&&(this.grid.pageSize=e),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const e=[],t=this.tableTemplate?.columnTemplates?this._generateColumnsFromTemplates(this.tableTemplate.columnTemplates):this._generateDefaultFieldColumns();e.push(...t),e.length&&this.attachmentsEnabled&&e.push(this._generateAttachmentsColumn()),this.columns.addMany([...e])}_generateColumnsFromTemplates(e){const{editingEnabled:t,grid:i,layer:s,messages:r,messagesCommon:o,messagesURIUtils:l,store:n,tableTemplate:a}=this,h=s?.fields??[],d=e=>{const t="fieldName"in e&&e.fieldName?.toLowerCase();return h.find((e=>t===e.name?.toLowerCase()))};return e.map((e=>({template:e,field:d(e)}))).filter((({template:e,field:t})=>null!=t||"group"===e.type&&"columnTemplates"in e||"column"===e.type)).map((({template:e,field:h})=>{if("fieldName"in e){const d=!1===e.visible||!0!==e.visible&&this._isFieldHidden(h?.name),{direction:m,formatFunction:g,initialSortPriority:c,invalid:p,menuConfig:y,sortable:f,textAlign:b}=e,_=a?.expressionInfos||null,{timeZone:w,timeZoneName:v}=this._getTimeZoneInfoForFieldColumn(h);return new u({sortable:!1!==f,direction:m,editingEnabled:t,expressionInfos:_,field:h,formatFunction:g,grid:i,hidden:d,initialSortPriority:c,invalid:p,layer:s,messages:r,messagesCommon:o,messagesURIUtils:l,menuConfig:y,store:n,template:e,textAlign:b,timeZone:w,timeZoneName:v})}if("group"===e.type&&"columnTemplates"in e){const t=this._generateColumnsFromTemplates(e.columnTemplates),i=!1===e.visible||!0!==e.visible&&this._isFieldHidden(e.label),{label:s}=e;return new _({header:s,columns:t,hidden:i})}return new y({...e,timeZone:this.timeZone})}))}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:r,messagesURIUtils:o,store:l}=this;return(this.layer?.fields??[]).map((n=>{const{timeZone:a,timeZoneName:h}=this._getTimeZoneInfoForFieldColumn(n);return new u({editingEnabled:e,field:n,grid:t,hidden:this._isFieldHidden(n.name),layer:i,store:l,messages:s,messagesCommon:r,messagesURIUtils:o,timeZone:a,timeZoneName:h})}))}_getTimeZoneInfoForFieldColumn(e){const{timeZone:t,view:i}=this;return!e||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:m("preferredTimeZone"in this.layer?this.layer.preferredTimeZone:null,"datesInUnknownTimezone"in this.layer&&this.layer.datesInUnknownTimezone,t??i?.timeZone??g,F("short-time"),e.type)}_generateAttachmentsColumn(){return new p({header:this.messages?.attachments??"Attachments"})}_sortOrdersToLayerOrderByFields(e){return e?.length?e.filter(((e,t,i)=>i.map((e=>e.path)).indexOf(e.path)===t)).filter((({direction:e})=>!!e)).map((({direction:e,path:t})=>t+" "+e?.toUpperCase())):[]}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_highlight(e){this.layerView&&c(this.layerView)&&this._highlights.add(this.layerView.highlight(e),e)}_removeHighlight(e){this._highlights.remove(e)}_getStoreItemsFromSelectionParams(e){const i=[];return this.layer?((e=e instanceof Array?e:[e]).forEach((e=>{let s=e instanceof t?e:null;const r=s?s.getObjectId():e;if("number"==typeof r||"string"==typeof r){if(!s){const e=this.store.getItemByObjectId(r);e&&(s=e.feature)}i.push({objectId:r,feature:s})}})),i):[]}_onHighlightIdsChange(e){const{highlightEnabled:t}=this,{added:i,removed:s}=e;t&&(i.forEach((e=>this._highlight(e))),s.forEach((e=>this._removeHighlight(e)))),this.emit("selection-change",{added:i,removed:s})}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}};e([a()],C.prototype,"_defaultHiddenFields",null),e([a({readOnly:!0})],C.prototype,"activeFilters",void 0),e([a({readOnly:!0})],C.prototype,"activeSortOrders",null),e([a()],C.prototype,"attachmentsEnabled",void 0),e([a()],C.prototype,"autoRefreshEnabled",void 0),e([a()],C.prototype,"cellClassNameGenerator",void 0),e([a({readOnly:!0})],C.prototype,"columns",void 0),e([a()],C.prototype,"dataProvider",void 0),e([a()],C.prototype,"editingEnabled",void 0),e([a()],C.prototype,"filterGeometry",null),e([a({readOnly:!0})],C.prototype,"grid",void 0),e([a()],C.prototype,"hiddenFields",null),e([a()],C.prototype,"highlightEnabled",void 0),e([a()],C.prototype,"highlightOnRowSelectEnabled",null),e([a({readOnly:!0})],C.prototype,"itemIdPath",void 0),e([a()],C.prototype,"layer",void 0),e([a()],C.prototype,"layerView",null),e([a()],C.prototype,"messages",null),e([a(),v("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([a(),v("esri/widgets/support/t9n/uriUtils")],C.prototype,"messagesURIUtils",void 0),e([a()],C.prototype,"relatedRecordsEnabled",void 0),e([a()],C.prototype,"returnGeometryEnabled",void 0),e([a({readOnly:!0})],C.prototype,"state",null),e([a({readOnly:!0,type:w})],C.prototype,"store",void 0),e([a()],C.prototype,"tableTemplate",void 0),e([a()],C.prototype,"timeExtent",null),e([a()],C.prototype,"timeZone",void 0),e([a()],C.prototype,"view",void 0),e([a()],C.prototype,"highlightIds",null),C=e([h("esri.widgets.FeatureTable.FeatureTableViewModel")],C);const j=C;export{j as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Handles.js";import{debounce as r,ignoreAbortErrors as o}from"../../core/promiseUtils.js";import{on as l,watch as n}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as d}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as m,system as g}from"../../time/timeZoneUtils.js";import{highlightsSupported as c}from"../../views/support/layerViewUtils.js";import p from"./AttachmentsColumn.js";import u from"./FieldColumn.js";import y from"./Grid/Column.js";import f from"./Grid/Grid.js";import b from"./Grid/GridViewModel.js";import _ from"./Grid/GroupColumn.js";import w from"./support/FeatureStore.js";import"../support/widgetUtils.js";import{messageBundle as v}from"../support/decorators/messageBundle.js";import{onLocaleChange as I}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as E}from"../../intl/date.js";import{fetchMessageBundle as F}from"../../intl/messages.js";let C=class extends b{constructor(e){super(e),this._debounceRefresh=r((()=>this._refresh())),this._highlights=new s,this.activeFilters=new i,this.attachmentsEnabled=!1,this.autoRefreshEnabled=!0,this.cellClassNameGenerator=(e,t)=>e.path||"",this.columns=new i,this.dataProvider=async(e,t)=>{const{store:i}=this,s=this._sortOrdersToLayerOrderByFields(e.sortOrders);t&&(i?(i.set({orderByFields:s}),"loaded"!==i.state&&"loading"!==i.state&&await i.load(),t&&t(await i.fetchItems(e))):t&&t([]))},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.layer=null,this.messagesCommon=null,this.messagesURIUtils=null,this.relatedRecordsEnabled=!1,this.returnGeometryEnabled=!1,this.store=null,this.tableTemplate=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new w),this._set("grid",new f({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await F("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await F("esri/t9n/common"),this.messagesURIUtils=await F("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([I((()=>{e(),this._generateColumns()})),l((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>{this.highlightIds.forEach((e=>this._highlight(e)))},onListenerRemove:()=>{this.highlightIds.forEach((e=>this._removeHighlight(e)))}}),n((()=>this.attachmentsEnabled),(e=>{this.store.attachmentsEnabled=e,this.layer?.loaded&&this._generateColumns()})),n((()=>this.layerView),(e=>{this._highlights.removeAll(),e&&this.highlightEnabled&&this.highlightIds?.forEach((e=>this._highlight(e)))})),n((()=>this.highlightEnabled),(e=>{this._highlights.removeAll(),e&&this.highlightIds?.forEach((e=>this._highlight(e)))})),n((()=>this.relatedRecordsEnabled),(e=>this.store.relatedRecordsEnabled=e)),n((()=>this.returnGeometryEnabled),(e=>this.store.returnGeometry=e)),n((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await i.reset()),this._drainColumns(),e&&(this.store.layer=e,e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),n((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),n((()=>this.store.state),(e=>{"loaded"===e&&this.grid?.scrollToTop()})),n((()=>[this.messages,this.tableTemplate]),(()=>this.layer?.loaded&&this._generateColumns())),n((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this.grid?.onColumnChange()})),n((()=>this.editingEnabled),(e=>{this.columns.forEach((t=>{"editingEnabled"in t&&(t.editingEnabled=e)})),this.grid?.onColumnChange()})),n((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),n((()=>this.layer&&"timeExtent"in this.layer&&this.layer.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),l((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e)))])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return d(this.layer)}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}set filterGeometry(e){if(!this.filterGeometry&&!e)return;const t=this.activeFilters.find((e=>"geometry"===e.type));t&&this.activeFilters.remove(t),this._set("filterGeometry",e),this.store.filterGeometry=e,e&&this.activeFilters.add({type:"geometry",geometry:e})}get hiddenFields(){return this._get("hiddenFields")??new i}set hiddenFields(e){Array.isArray(e)?this._set("hiddenFields",new i(e)):this._set("hiddenFields",e)}get highlightOnRowSelectEnabled(){return this.highlightEnabled}set highlightOnRowSelectEnabled(e){this.highlightEnabled=e}get layerView(){return this.view?.allLayerViews.find((e=>e.layer===this.layer))||null}set messages(e){this.grid?.set("messages",e),this._set("messages",e)}get state(){const{store:e}=this;return e&&"disabled"!==e.state?"loading"===e.state?"loading":"loaded"===e.state?"loaded":"ready":"disabled"}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}clearSelection(){this.grid?.clearSelection()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.deselectRows(i),await this.refresh())}deselectRows(e){const t=this._getStoreItemsFromSelectionParams(e);this.grid?.deselectRows(t)}filterBySelection(){const e=this.highlightIds.toArray();e.length&&(this.clearSelectionFilter(),this.store.objectIds=e,this.activeFilters.add({type:"selection",objectIds:e}))}getObjectIdIndex(e){return this.store?.getObjectIdIndex(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}get highlightIds(){return this._get("highlightIds")||new i}set highlightIds(e){Array.isArray(e)?this._set("highlightIds",new i(e)):this._set("highlightIds",e)}async refresh(){return o(this._debounceRefresh())}reset(){this.grid?.reset()}selectRows(e){const t=this._getStoreItemsFromSelectionParams(e);return this.grid?.selectRows(t)}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){this.store.objectIds=null;const e=this.activeFilters.find((e=>"selection"===e.type));e&&this.activeFilters.remove(e)}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const r=await e.queryFeatures(s);try{await t.goTo(r.features)}catch(o){"AbortError"!==o.name&&console.error(o)}}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.deselectRows(e[i])}))}this.grid?.refreshPageCache()}_onLayerLoad(){const e=this.layer.capabilities?.query.maxRecordCount;e&&e<this.pageSize&&this.grid&&(this.grid.pageSize=e),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const e=[],t=this.tableTemplate?.columnTemplates?this._generateColumnsFromTemplates(this.tableTemplate.columnTemplates):this._generateDefaultFieldColumns();e.push(...t),e.length&&this.attachmentsEnabled&&e.push(this._generateAttachmentsColumn()),this.columns.addMany([...e])}_generateColumnsFromTemplates(e){const{editingEnabled:t,grid:i,layer:s,messages:r,messagesCommon:o,messagesURIUtils:l,store:n,tableTemplate:a}=this,h=s?.fields??[],d=e=>{const t="fieldName"in e&&e.fieldName?.toLowerCase();return h.find((e=>t===e.name?.toLowerCase()))};return e.map((e=>({template:e,field:d(e)}))).filter((({template:e,field:t})=>null!=t||"group"===e.type&&"columnTemplates"in e||"column"===e.type)).map((({template:e,field:h})=>{if("fieldName"in e){const d=!1===e.visible||!0!==e.visible&&this._isFieldHidden(h?.name),{direction:m,formatFunction:g,frozen:c,frozenToEnd:p,initialSortPriority:y,invalid:f,menuConfig:b,sortable:_,textAlign:w}=e,v=a?.expressionInfos||null,{timeZone:I,timeZoneName:E}=this._getTimeZoneInfoForFieldColumn(h);return new u({sortable:!1!==_,direction:m,editingEnabled:t,expressionInfos:v,field:h,formatFunction:g,frozen:c,frozenToEnd:p,grid:i,hidden:d,initialSortPriority:y,invalid:f,layer:s,messages:r,messagesCommon:o,messagesURIUtils:l,menuConfig:b,store:n,template:e,textAlign:w,timeZone:I,timeZoneName:E})}if("group"===e.type&&"columnTemplates"in e){const t=this._generateColumnsFromTemplates(e.columnTemplates),i=!1===e.visible||!0!==e.visible&&this._isFieldHidden(e.label),{label:s}=e;return new _({header:s,columns:t,hidden:i})}return new y({...e,timeZone:this.timeZone})}))}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:r,messagesURIUtils:o,store:l}=this;return(this.layer?.fields??[]).map((n=>{const{timeZone:a,timeZoneName:h}=this._getTimeZoneInfoForFieldColumn(n);return new u({editingEnabled:e,field:n,grid:t,hidden:this._isFieldHidden(n.name),layer:i,store:l,messages:s,messagesCommon:r,messagesURIUtils:o,timeZone:a,timeZoneName:h})}))}_getTimeZoneInfoForFieldColumn(e){const{timeZone:t,view:i}=this;return!e||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:m("preferredTimeZone"in this.layer?this.layer.preferredTimeZone:null,"datesInUnknownTimezone"in this.layer&&this.layer.datesInUnknownTimezone,t??i?.timeZone??g,E("short-time"),e.type)}_generateAttachmentsColumn(){return new p({header:this.messages?.attachments??"Attachments"})}_sortOrdersToLayerOrderByFields(e){return e?.length?e.filter(((e,t,i)=>i.map((e=>e.path)).indexOf(e.path)===t)).filter((({direction:e})=>!!e)).map((({direction:e,path:t})=>t+" "+e?.toUpperCase())):[]}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_highlight(e){this.layerView&&c(this.layerView)&&this._highlights.add(this.layerView.highlight(e),e)}_removeHighlight(e){this._highlights.remove(e)}_getStoreItemsFromSelectionParams(e){const i=[];return this.layer?((e=e instanceof Array?e:[e]).forEach((e=>{let s=e instanceof t?e:null;const r=s?s.getObjectId():e;if("number"==typeof r||"string"==typeof r){if(!s){const e=this.store.getItemByObjectId(r);e&&(s=e.feature)}i.push({objectId:r,feature:s})}})),i):[]}_onHighlightIdsChange(e){const{highlightEnabled:t}=this,{added:i,removed:s}=e;t&&(i.forEach((e=>this._highlight(e))),s.forEach((e=>this._removeHighlight(e)))),this.emit("selection-change",{added:i,removed:s})}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}};e([a()],C.prototype,"_defaultHiddenFields",null),e([a({readOnly:!0})],C.prototype,"activeFilters",void 0),e([a({readOnly:!0})],C.prototype,"activeSortOrders",null),e([a()],C.prototype,"attachmentsEnabled",void 0),e([a()],C.prototype,"autoRefreshEnabled",void 0),e([a()],C.prototype,"cellClassNameGenerator",void 0),e([a({readOnly:!0})],C.prototype,"columns",void 0),e([a()],C.prototype,"dataProvider",void 0),e([a()],C.prototype,"editingEnabled",void 0),e([a()],C.prototype,"filterGeometry",null),e([a({readOnly:!0})],C.prototype,"grid",void 0),e([a()],C.prototype,"hiddenFields",null),e([a()],C.prototype,"highlightEnabled",void 0),e([a()],C.prototype,"highlightOnRowSelectEnabled",null),e([a({readOnly:!0})],C.prototype,"itemIdPath",void 0),e([a()],C.prototype,"layer",void 0),e([a()],C.prototype,"layerView",null),e([a()],C.prototype,"messages",null),e([a(),v("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([a(),v("esri/widgets/support/t9n/uriUtils")],C.prototype,"messagesURIUtils",void 0),e([a()],C.prototype,"relatedRecordsEnabled",void 0),e([a()],C.prototype,"returnGeometryEnabled",void 0),e([a({readOnly:!0})],C.prototype,"state",null),e([a({readOnly:!0,type:w})],C.prototype,"store",void 0),e([a()],C.prototype,"tableTemplate",void 0),e([a()],C.prototype,"timeExtent",null),e([a()],C.prototype,"timeZone",void 0),e([a()],C.prototype,"view",void 0),e([a()],C.prototype,"highlightIds",null),C=e([h("esri.widgets.FeatureTable.FeatureTableViewModel")],C);const j=C;export{j as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"@vaadin/grid/vaadin-grid.js";import"@vaadin/grid/vaadin-grid-column-group.js";import"@vaadin/grid/vaadin-grid-selection-column.js";import"@vaadin/grid/vaadin-grid-sorter.js";import{isSome as t}from"../../../core/arrayUtils.js";import{on as r}from"../../../core/events.js";import{assertIsSome as i}from"../../../core/maybe.js";import{watch as o,on as s}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../../core/accessorSupport/decorators/cast.js";import"../../../core/has.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../Widget.js";import h from"./GridViewModel.js";import{globalCss as c}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{messageBundle as m}from"../../support/decorators/messageBundle.js";import{tsx as u}from"../../support/jsxFactory.js";const g={selectionColumn:!0,columnMenus:!0},p="esri-grid",_="compact column-borders",v={base:p,content:`${p}__content`,grid:`${p}__grid`,noColumnMenu:`${p}--no-column-menu`};let f=class extends a{constructor(e,t){super(e,t),this._columnElements=[],this._grid=null,this.itemIdPath=null,this.messages=null,this.viewModel=new h,this.visibleElements={...g}}initialize(){this.addHandles([this.columns.on("before-changes",(()=>this.renderNow())),this.columns.on("change",(()=>this.onColumnChange())),o((()=>this.viewModel?.size),(()=>this._updateGridSize())),o((()=>this.store?.state),((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshPageCache()})),s((()=>this._grid?.$?.table),"scroll",(()=>this.viewModel?.closeColumnMenus()))])}destroy(){this.resetColumns(),this.columns.destroyed||this.columns.destroy()}resetColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}get _activeEditInfos(){return this._editorColumns.map((e=>e.activeEditInfo)).filter(t)}get _editorColumns(){return this.columns.filter((e=>"activeEditInfo"in e)).toArray()}get cellClassNameGenerator(){return this.viewModel.cellClassNameGenerator}set cellClassNameGenerator(e){this.viewModel.cellClassNameGenerator=e}get cellPartNameGenerator(){return this.viewModel.cellPartNameGenerator}set cellPartNameGenerator(e){this.viewModel.cellPartNameGenerator=e}get columns(){return this.viewModel.columns}set columns(e){this.viewModel.columns=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get dataProvider(){return this.viewModel.dataProvider}set dataProvider(e){this.viewModel.dataProvider=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get isEditingActive(){return!!this._activeEditInfos.length}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get rowDetailsRenderer(){return this.viewModel.rowDetailsRenderer}set rowDetailsRenderer(e){this.viewModel.rowDetailsRenderer=e}get size(){return this.viewModel.size}get sortOrders(){return this._grid?._sorters?this._grid._sorters.filter((e=>!!e&&e.path)).map((({direction:e,path:t})=>({direction:e,path:t}))):[]}get store(){return this.viewModel.store}set store(e){this.viewModel.store=e}castVisibleElements(e){return{...g,...e}}getColumnProps(e,t){const{id:r}=this,{autoWidth:i,direction:o,flexGrow:s,frozen:n,frozenToEnd:l,header:d,hidden:a,invalid:h,path:c,resizable:m,textAlign:u,width:g}=e,p=`${r}_${d}_${t??c}`,{renderFunction:_,footerRenderFunction:v,headerRenderFunction:f}=e,C=v?(e,t)=>v({root:e,column:t}):void 0,w=f?(e,t)=>f({root:e,column:t}):void 0,y=_?(e,t,r)=>_({root:e,column:t,rowData:r}):void 0;return{footerRenderer:C,headerRenderer:w,renderer:y,autoWidth:i,direction:o,flexGrow:s,frozen:n,frozenToEnd:l,header:d,hidden:a,key:p,path:c,resizable:m,bind:this,headerPartName:h?"invalid":void 0,"text-align":u,width:"number"==typeof g?`${g}px`:g,afterCreate:this._afterColumnCreate,afterRemoved:this._afterColumnRemoved}}clearSelection(){this._clearSelection(),this.scheduleRender()}clearSort(){let e=!1;if(this._grid){if(this._grid._sorters?.length&&(this._grid._sorters.forEach((e=>{e._order=null,e.direction=null})),e=!0),this.columns.length){this.columns.some((e=>!!e.direction))&&(this.columns.forEach((e=>e.direction=null)),e=!0)}e&&(this.notifyChange("sortOrders"),this.scheduleRender())}}findColumn(e){this.viewModel.findColumn(e)}generateCellClassNames(){this._grid?.generateCellClassNames()}generateCellPartNames(){this._grid?.generateCellPartNames()}getRowContainingNode(e){return this._grid?._getRowContainingNode(e)}getSlotElementByName(e){return this._grid?.shadowRoot?.querySelector(`slot[name='${e}']`)??null}hideColumn(e){this.viewModel?.hideColumn(e)}recalculateColumnWidths(){this._grid?.recalculateColumnWidths()}async reset(){this._clearSelection(),await(this.store?.reset()),this.scrollToTop()}refreshPageCache(){this._grid?.clearCache()}selectRows(e){const t=e?.filter((e=>!this.highlightIds.includes(e.objectId))),r=t.map((e=>e.objectId));r.length&&this.highlightIds.addMany(r)}deselectRows(e){const t=e?.map((e=>e.objectId))||[];t.length&&this.highlightIds.removeMany(t)}showColumn(e){this.viewModel?.showColumn(e)}sort({path:e,direction:t}){this.viewModel?.sortColumn(e,t),this.notifyChange("sortOrders")}scrollToIndex(e){this._grid?.scrollToIndex(e)}scrollToTop(){this._grid?.scrollToIndex(0)}onColumnChange(){this._columnElements.forEach((e=>{this._applyRenderersToColumnElement(e)})),this._grid?.requestContentUpdate()}render(){const{columnMenus:e}=this.visibleElements;return u("div",{bind:this,class:this.classes(v.base,c.widget,{[v.noColumnMenu]:!e})},u("div",{bind:this,class:v.content},this._renderGrid()))}_renderGrid(){const e=this.highlightIds.map((e=>this.store?.getLocalItemByKey(e)||{objectId:e})).toArray(),t=this.columnPerformanceModeEnabled?"lazy":"eager";return u("vaadin-grid",{afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellClassNameGenerator:this.cellClassNameGenerator,cellPartNameGenerator:this.cellPartNameGenerator,class:v.grid,columnRendering:t,columnReorderingAllowed:this.columnReorderingEnabled,dataProvider:this.dataProvider,id:`${this.id}_grid`,itemIdPath:this.itemIdPath,multiSort:this.multiSortEnabled,pageSize:this.pageSize,ref:"grid",rowDetailsRenderer:this.rowDetailsRenderer,selectedItems:e,size:this.size},this._renderAllColumns())}_renderAllColumns(){return"disabled"!==this.viewModel.state&&this.columns.length?[this._renderSelectionColumn(),this._renderColumns()]:null}_renderSelectionColumn(){return u("vaadin-grid-selection-column",{_selectAllHidden:!0,bind:this,dragSelect:!0,frozen:!0,hidden:!this.visibleElements.selectionColumn,selectAll:!1,sortable:!1,textAlign:"center"})}_renderColumns(){return Array.from(this.columns,((e,t)=>"columns"in e?this._renderGroupColumn(e,t):u("vaadin-grid-column",{...this.getColumnProps(e,t)}))).filter(t)}_renderGroupColumn(e,t){const r=this.getColumnProps(e,t);if(r.hidden||!e.columns)return null;const i=e.columns.filter((({hidden:e})=>!e));return i.length?u("vaadin-grid-column-group",{...r},i.map((e=>u("vaadin-grid-column",{...this.getColumnProps(e,t)})))):null}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",_),customElements.whenDefined("vaadin-grid").then((()=>{this._appendStyles(),this._addGridEventListeners()})),t.__updateSorter=e=>{const r=t._sorters,i=!r.includes(e);if(e.direction||!i)if(e._order=null,t.multiSort)t._removeArrayItem(r,e),e.direction&&(null!=e._initialOrder?(i?r[e._initialOrder]=e:r.splice(e._initialOrder,0,e),e._initialOrder=null):r.unshift(e)),t.__updateSortOrders();else if(e.direction){const i=r.filter((t=>t!==e));t._sorters=[e],i.forEach((e=>{e._order=null,e.direction=null}))}}}_appendStyles(){const e=this._grid?.shadowRoot,t=document.createElement("style");e&&(t.textContent='\n #items [part~="row"][editing], \n #items [part~="row"][editing][selected] { \n z-index: 2; \n }\n\n #items [part~="editing"],\n #items [part~="editing"][selected] {\n z-index: 3;\n }\n ',e.appendChild(t))}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_updateGridSize(){this._grid&&(this._grid.size=this.size||0,this.scheduleRender())}_addGridEventListeners(){const e=this._grid;i(e),this.addHandles([r(e,"click",(e=>this._onRowClick(e))),r(e,"selected-items-changed",(e=>this._onSelectedItemsChange(e))),r(e,"sorter-changed",(()=>this.notifyChange("sortOrders")))])}_onRowClick(e){const t=this._grid;i(t);const r=t.getEventContext(e),{item:o,section:s}=r;o&&s&&"details"!==s&&"header"!==s&&this.emit("row-click",{context:r,native:e})}_clearSelection(){this.highlightIds.removeAll()}_onSelectedItemsChange(e){const{highlightIds:t}=this,r=e.detail.value.map((e=>e.objectId)),i=r.filter((e=>!t.includes(e))),o=t.filter((e=>!r.includes(e)));t.removeMany(o),t.addMany(i)}_applyRenderersToColumnElement(e){const t=e?.path,r=null!=t?this.viewModel.findColumn(t):void 0;if(r)try{const{renderFunction:t,footerRenderFunction:i,headerRenderFunction:o}=r;t&&"renderer"in e&&(e.renderer=(e,r,i)=>t({root:e,column:r,rowData:i})),i&&(e.footerRenderer=(e,t)=>i({root:e,column:t})),o&&(e.headerRenderer=(e,t)=>o({root:e,column:t}))}catch(i){}}};e([n()],f.prototype,"_activeEditInfos",null),e([n()],f.prototype,"_columnElements",void 0),e([n()],f.prototype,"_editorColumns",null),e([n()],f.prototype,"_grid",void 0),e([n()],f.prototype,"cellClassNameGenerator",null),e([n()],f.prototype,"cellPartNameGenerator",null),e([n()],f.prototype,"columns",null),e([n()],f.prototype,"columnPerformanceModeEnabled",null),e([n()],f.prototype,"columnReorderingEnabled",null),e([n()],f.prototype,"dataProvider",null),e([n()],f.prototype,"highlightIds",null),e([n()],f.prototype,"isEditingActive",null),e([n()],f.prototype,"itemIdPath",void 0),e([n()],f.prototype,"label",null),e([n(),m("esri/widgets/FeatureTable/t9n/FeatureTable")],f.prototype,"messages",void 0),e([n()],f.prototype,"multiSortEnabled",null),e([n()],f.prototype,"pageSize",null),e([n()],f.prototype,"rowDetailsRenderer",null),e([n()],f.prototype,"size",null),e([n({readOnly:!0})],f.prototype,"sortOrders",null),e([n()],f.prototype,"store",null),e([n()],f.prototype,"viewModel",void 0),e([n()],f.prototype,"visibleElements",void 0),e([l("visibleElements")],f.prototype,"castVisibleElements",null),f=e([d("esri.widgets.FeatureTable.Grid.Grid")],f);const C=f;export{C as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"@vaadin/grid/vaadin-grid.js";import"@vaadin/grid/vaadin-grid-column-group.js";import"@vaadin/grid/vaadin-grid-selection-column.js";import"@vaadin/grid/vaadin-grid-sorter.js";import{isSome as t}from"../../../core/arrayUtils.js";import{on as r}from"../../../core/events.js";import{assertIsSome as i}from"../../../core/maybe.js";import{watch as o,on as n}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../../core/accessorSupport/decorators/cast.js";import"../../../core/has.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../Widget.js";import h from"./GridViewModel.js";import{globalCss as c}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{messageBundle as m}from"../../support/decorators/messageBundle.js";import{tsx as u}from"../../support/jsxFactory.js";const g={selectionColumn:!0,columnMenus:!0},p="esri-grid",_="compact column-borders",v={base:p,content:`${p}__content`,grid:`${p}__grid`,noColumnMenu:`${p}--no-column-menu`};let f=class extends a{constructor(e,t){super(e,t),this._columnElements=[],this._grid=null,this.itemIdPath=null,this.messages=null,this.viewModel=new h,this.visibleElements={...g}}initialize(){this.addHandles([this.columns.on("before-changes",(()=>this.renderNow())),this.columns.on("change",(()=>this.onColumnChange())),o((()=>this.viewModel?.size),(()=>this._updateGridSize())),o((()=>this.store?.state),((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshPageCache()})),n((()=>this._grid?.$?.table),"scroll",(()=>this.viewModel?.closeColumnMenus()))])}destroy(){this.resetColumns(),this.columns.destroyed||this.columns.destroy()}resetColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}get _activeEditInfos(){return this._editorColumns.map((e=>e.activeEditInfo)).filter(t)}get _editorColumns(){return this.columns.filter((e=>"activeEditInfo"in e)).toArray()}get cellClassNameGenerator(){return this.viewModel.cellClassNameGenerator}set cellClassNameGenerator(e){this.viewModel.cellClassNameGenerator=e}get cellPartNameGenerator(){return this.viewModel.cellPartNameGenerator}set cellPartNameGenerator(e){this.viewModel.cellPartNameGenerator=e}get columns(){return this.viewModel.columns}set columns(e){this.viewModel.columns=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get dataProvider(){return this.viewModel.dataProvider}set dataProvider(e){this.viewModel.dataProvider=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get isEditingActive(){return!!this._activeEditInfos.length}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get rowDetailsRenderer(){return this.viewModel.rowDetailsRenderer}set rowDetailsRenderer(e){this.viewModel.rowDetailsRenderer=e}get size(){return this.viewModel.size}get sortOrders(){return this._grid?._sorters?this._grid._sorters.filter((e=>!!e&&e.path)).map((({direction:e,path:t})=>({direction:e,path:t}))):[]}get store(){return this.viewModel.store}set store(e){this.viewModel.store=e}castVisibleElements(e){return{...g,...e}}getColumnProps(e,t){const{id:r}=this,{autoWidth:i,direction:o,flexGrow:n,frozen:s,frozenToEnd:l,header:d,hidden:a,invalid:h,path:c,resizable:m,textAlign:u,width:g}=e,p=`${r}_${d}_${t??c}`,{renderFunction:_,footerRenderFunction:v,headerRenderFunction:f}=e,C=v?(e,t)=>v({root:e,column:t}):void 0,w=f?(e,t)=>f({root:e,column:t}):void 0,y=_?(e,t,r)=>_({root:e,column:t,rowData:r}):void 0;return{footerRenderer:C,headerRenderer:w,renderer:y,autoWidth:i,direction:o,flexGrow:n,frozen:s,frozenToEnd:l,header:d,hidden:a,key:p,path:c,resizable:m,bind:this,headerPartName:h?"invalid":void 0,"text-align":u,width:"number"==typeof g?`${g}px`:g,afterCreate:this._afterColumnCreate,afterRemoved:this._afterColumnRemoved}}clearSelection(){this._clearSelection(),this.scheduleRender()}clearSort(){let e=!1;if(this._grid){if(this._grid._sorters?.length&&(this._grid._sorters.forEach((e=>{e._order=null,e.direction=null})),e=!0),this.columns.length){this.columns.some((e=>!!e.direction))&&(this.columns.forEach((e=>e.direction=null)),e=!0)}e&&(this.notifyChange("sortOrders"),this.scheduleRender())}}findColumn(e){this.viewModel.findColumn(e)}generateCellClassNames(){this._grid?.generateCellClassNames()}generateCellPartNames(){this._grid?.generateCellPartNames()}getRowContainingNode(e){return this._grid?._getRowContainingNode(e)}getSlotElementByName(e){return this._grid?.shadowRoot?.querySelector(`slot[name='${e}']`)??null}hideColumn(e){this.viewModel?.hideColumn(e)}recalculateColumnWidths(){this._grid?.recalculateColumnWidths()}async reset(){this._clearSelection(),await(this.store?.reset()),this.scrollToTop()}refreshPageCache(){this._grid?.clearCache()}selectRows(e){const t=e?.filter((e=>!this.highlightIds.includes(e.objectId))),r=t.map((e=>e.objectId));r.length&&this.highlightIds.addMany(r)}deselectRows(e){const t=e?.map((e=>e.objectId))||[];t.length&&this.highlightIds.removeMany(t)}showColumn(e){this.viewModel?.showColumn(e)}sort({path:e,direction:t}){this.viewModel?.sortColumn(e,t),this.notifyChange("sortOrders")}scrollToIndex(e){this._grid?.scrollToIndex(e)}scrollToTop(){this._grid?.scrollToIndex(0)}onColumnChange(){this._columnElements.forEach((e=>{this._applyRenderersToColumnElement(e)})),this._grid?.requestContentUpdate()}render(){const{columnMenus:e}=this.visibleElements;return u("div",{bind:this,class:this.classes(v.base,c.widget,{[v.noColumnMenu]:!e})},u("div",{bind:this,class:v.content},this._renderGrid()))}_renderGrid(){const e=this.highlightIds.map((e=>this.store?.getLocalItemByKey(e)||{objectId:e})).toArray(),t=this.columnPerformanceModeEnabled?"lazy":"eager";return u("vaadin-grid",{afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellClassNameGenerator:this.cellClassNameGenerator,cellPartNameGenerator:this.cellPartNameGenerator,class:v.grid,columnRendering:t,columnReorderingAllowed:this.columnReorderingEnabled,dataProvider:this.dataProvider,id:`${this.id}_grid`,itemIdPath:this.itemIdPath,multiSort:this.multiSortEnabled,pageSize:this.pageSize,ref:"grid",rowDetailsRenderer:this.rowDetailsRenderer,selectedItems:e,size:this.size},this._renderAllColumns())}_renderAllColumns(){return"disabled"!==this.viewModel.state&&this.columns.length?[this._renderSelectionColumn(),this._renderColumns()]:null}_renderSelectionColumn(){return u("vaadin-grid-selection-column",{_selectAllHidden:!0,bind:this,dragSelect:!0,frozen:!0,hidden:!this.visibleElements.selectionColumn,selectAll:!1,sortable:!1,textAlign:"center"})}_renderColumns(){return Array.from(this.columns,((e,t)=>"columns"in e?this._renderGroupColumn(e,t):u("vaadin-grid-column",{...this.getColumnProps(e,t)}))).filter(t)}_renderGroupColumn(e,t){const r=this.getColumnProps(e,t);if(r.hidden||!e.columns)return null;const i=e.columns.filter((({hidden:e})=>!e));return i.length?u("vaadin-grid-column-group",{...r},i.map((e=>u("vaadin-grid-column",{...this.getColumnProps(e,t)})))):null}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",_),customElements.whenDefined("vaadin-grid").then((()=>{this._appendStyles(),this._addGridEventListeners()})),t.__updateSorter=e=>{const r=t._sorters,i=!r.includes(e);if(e.direction||!i)if(e._order=null,t.multiSort)t._removeArrayItem(r,e),e.direction&&(null!=e._initialOrder?(i?r[e._initialOrder]=e:r.splice(e._initialOrder,0,e),e._initialOrder=null):r.unshift(e)),t.__updateSortOrders();else if(e.direction){const i=r.filter((t=>t!==e));t._sorters=[e],i.forEach((e=>{e._order=null,e.direction=null}))}}}_appendStyles(){const e=this._grid?.shadowRoot,t=document.createElement("style");e&&(t.textContent='\n #items [part~="row"][editing], \n #items [part~="row"][editing][selected] { \n z-index: 2; \n }\n\n #items [part~="editing"],\n #items [part~="editing"][selected] {\n z-index: 3;\n }\n\n [frozen], [frozen-to-end] {\n z-index: 4;\n }\n ',e.appendChild(t))}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_updateGridSize(){this._grid&&(this._grid.size=this.size||0,this.scheduleRender())}_addGridEventListeners(){const e=this._grid;i(e),this.addHandles([r(e,"click",(e=>this._onRowClick(e))),r(e,"selected-items-changed",(e=>this._onSelectedItemsChange(e))),r(e,"sorter-changed",(()=>this.notifyChange("sortOrders")))])}_onRowClick(e){const t=this._grid;i(t);const r=t.getEventContext(e),{item:o,section:n}=r;o&&n&&"details"!==n&&"header"!==n&&this.emit("row-click",{context:r,native:e})}_clearSelection(){this.highlightIds.removeAll()}_onSelectedItemsChange(e){const{highlightIds:t}=this,r=e.detail.value.map((e=>e.objectId)),i=r.filter((e=>!t.includes(e))),o=t.filter((e=>!r.includes(e)));t.removeMany(o),t.addMany(i)}_applyRenderersToColumnElement(e){const t=e?.path,r=null!=t?this.viewModel.findColumn(t):void 0;if(r)try{const{renderFunction:t,footerRenderFunction:i,headerRenderFunction:o}=r;t&&"renderer"in e&&(e.renderer=(e,r,i)=>t({root:e,column:r,rowData:i})),i&&(e.footerRenderer=(e,t)=>i({root:e,column:t})),o&&(e.headerRenderer=(e,t)=>o({root:e,column:t}))}catch(i){}}};e([s()],f.prototype,"_activeEditInfos",null),e([s()],f.prototype,"_columnElements",void 0),e([s()],f.prototype,"_editorColumns",null),e([s()],f.prototype,"_grid",void 0),e([s()],f.prototype,"cellClassNameGenerator",null),e([s()],f.prototype,"cellPartNameGenerator",null),e([s()],f.prototype,"columns",null),e([s()],f.prototype,"columnPerformanceModeEnabled",null),e([s()],f.prototype,"columnReorderingEnabled",null),e([s()],f.prototype,"dataProvider",null),e([s()],f.prototype,"highlightIds",null),e([s()],f.prototype,"isEditingActive",null),e([s()],f.prototype,"itemIdPath",void 0),e([s()],f.prototype,"label",null),e([s(),m("esri/widgets/FeatureTable/t9n/FeatureTable")],f.prototype,"messages",void 0),e([s()],f.prototype,"multiSortEnabled",null),e([s()],f.prototype,"pageSize",null),e([s()],f.prototype,"rowDetailsRenderer",null),e([s()],f.prototype,"size",null),e([s({readOnly:!0})],f.prototype,"sortOrders",null),e([s()],f.prototype,"store",null),e([s()],f.prototype,"viewModel",void 0),e([s()],f.prototype,"visibleElements",void 0),e([l("visibleElements")],f.prototype,"castVisibleElements",null),f=e([d("esri.widgets.FeatureTable.Grid.Grid")],f);const C=f;export{C as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as o}from"../../../chunks/tslib.es6.js";import{JSONSupport as t}from"../../../core/JSONSupport.js";import{property as
|
|
5
|
+
import{_ as o}from"../../../chunks/tslib.es6.js";import{JSONSupport as t}from"../../../core/JSONSupport.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";let e=class extends t{constructor(o){super(o),this.description=null,this.direction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.initialSortPriority=null,this.invalid=!1,this.label=null,this.menuConfig=null,this.sortable=!0,this.textAlign="start",this.type=null,this.visible=!0}};o([r()],e.prototype,"description",void 0),o([r()],e.prototype,"direction",void 0),o([r()],e.prototype,"formatFunction",void 0),o([r()],e.prototype,"frozen",void 0),o([r()],e.prototype,"frozenToEnd",void 0),o([r()],e.prototype,"initialSortPriority",void 0),o([r()],e.prototype,"invalid",void 0),o([r()],e.prototype,"label",void 0),o([r()],e.prototype,"menuConfig",void 0),o([r()],e.prototype,"sortable",void 0),o([r()],e.prototype,"textAlign",void 0),o([r({type:String,json:{read:!1,write:!0}})],e.prototype,"type",void 0),o([r()],e.prototype,"visible",void 0),e=o([i("esri.widgets.FeatureTable.support.ColumnTemplateBase")],e);const s=e;export{s as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as h,sync as u}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{initializeProjection as p,project as g}from"../../geometry/projection.js";import{getPointFromGeometry as f}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as m}from"../../geometry/support/webMercatorUtils.js";import y from"../../layers/Layer.js";import{fallbackObjectIDAttribute as w}from"../../layers/LayerConstants.js";import{getDisplayedSymbol as F}from"../../symbols/support/symbolUtils.js";import{highlightsSupported as v}from"../../views/support/layerViewUtils.js";import _ from"../Feature/FeatureViewModel.js";import{ActionsCollection as b,zoomToFeature as C,zoomToClusteredFeatures as P,browseClusteredFeatures as E}from"../Popup/actions.js";import{triggerAction as j,isClusterFeature as M,removeClusteredFeaturesForBrowsing as A,displayClusterExtent as L,browseAggregateFeatures as V,getSelectedTarget as I}from"../Popup/actionUtils.js";import S from"../support/AnchorElementViewModel.js";import{GoToMixin as O}from"../support/GoTo.js";import x from"../../symbols/SimpleFillSymbol.js";import T from"../../geometry/Point.js";const H=()=>[C.clone()],B=()=>[P.clone(),E.clone()];let R=null;function U(e,t){return"building-scene"===e||"2d"===t&&("map-image"===e||"tile"===e||"imagery"===e||"imagery-tile"===e)}let G=class extends(O(S)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightSelectedFeaturePromise=null,this._highlightActiveFeaturePromise=null,this._selectedClusterFeature=null,this._locationScaleHandle=null,this.actions=new b,this.activeFeature=null,this.autoCloseEnabled=!1,this.autoOpenEnabled=!0,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.selectedClusterBoundaryFeature=new t({symbol:new x({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=o((async e=>{const{view:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if("mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const{pendingFeatures:e}=await this._fetchFeaturesWithController({mapPoint:s}),i=(await Promise.all(e)).flat().filter(Boolean);if(!i.length)return;if(i.length!==this.features.length){const e=this._getHighlightLayer(this.selectedFeature),t="imagery"===e?.type?void 0:e&&"objectIdField"in e?e.objectIdField||w:null;if(t){const s=this.selectedFeature.getObjectId(),r=i.findIndex((i=>{const r=this._getHighlightLayer(i);return r?.uid===e?.uid&&i.attributes[t]===s}));this.features=i,this.selectedFeatureIndex=r}}const r=i[this.selectedFeatureIndex]?.geometry,o=("mesh"!==r?.type?r:null)??this.selectedFeature.geometry,a=g(o,t.spatialReference);R||(R=await import("../../geometry/geometryEngineAsync.js")),a&&!await R.intersects(a,s)&&(this.location=(await R.nearestCoordinate(a,s)).coordinate??s)}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=f(this.selectedFeature.geometry)??s}))}initialize(){this.addHandles([this.on("view-change",(()=>this._autoClose())),l((()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view]),(()=>this._highlightSelectedFeature())),l((()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view]),(()=>this._highlightActiveFeature())),l((()=>this.view?.animation?.state),(e=>this._animationStateChange(e))),l((()=>this.location),(e=>this._locationChange(e))),l((()=>this.selectedFeature),(e=>this._selectedFeatureChange(e))),l((()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage]),(()=>this._selectedFeatureIndexChange())),l((()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels]),(()=>this._setGraphicOnFeatureViewModels())),l((()=>this.featureViewModels),(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>j({event:e,viewModel:this,view:this.view}))),h((()=>!this.waitingForResult),(()=>this._waitingForResultChange()),u),l((()=>[this.features,this.view?.map,this.view?.spatialReference,this.view?.timeZone]),(()=>this._updateFeatureVMs())),l((()=>this.view?.scale),(()=>this._viewScaleChange())),h((()=>!this.visible),(()=>this.browseClusterEnabled=!1)),l((()=>this.browseClusterEnabled),(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this._locationScaleHandle?.remove(),this._locationScaleHandle=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new b;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,h=n?.overwriteActions?l:l?.concat(a)??a;return h?.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){const e=this._get("defaultActions")||new b;return e.removeAll(),e.addMany(M(this.selectedFeature)?B():H()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1)}set location(e){let t=e;const i=this.view?.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=m(e)),this._set("location",t)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice(0)).forEach((e=>this._pendingPromises.add(e))),e.reduce(((e,t)=>e.finally((()=>t.then((e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)})).finally((()=>this._pendingPromises.delete(t))).catch((()=>{}))))),Promise.resolve())):this._set("promises",[])}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;e=isNaN(e)||e<-1||!t?-1:(e+t)%t,this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get state(){return this.view?.ready?"ready":"disabled"}get waitingForContents(){return this.featureViewModels.some((e=>e.waitingForContent))}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=I(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex++,this}previous(){return this.selectedFeatureIndex--,this}disableClusterBrowsing(){A(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?M(t)?(await L(this),await V(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}handleViewClick(e){this.autoOpenEnabled&&this._fetchFeaturesAndOpen(e)}_animationStateChange(e){this.zoomToLocation||(C.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(M(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i}=this;i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>1?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>1?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null===i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach(((t,i)=>{t&&(t.graphic??=e[o+i])}))}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(e&&s){if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),M(e))return;return e.symbol=await F(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}if(e.symbol=await F(e),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=f(e.geometry)}}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s}=this;if(M(e)||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const r=i.slice(0),o=[];t.forEach(((t,i)=>{if(!t)return;let a=null;if(r.some(((e,i)=>(e&&e.graphic===t&&(a=e,r.splice(i,1)),!!a))),a)o[i]=a;else{const r=new _({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:s?.spatialReference,graphic:t===e?t:null,location:this.location,map:s?.map,view:s});o[i]=r}})),r.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",o)}async _getScreenPoint(e,t){const{view:i}=this;await(i?.when());const s=e?.spatialReference,r=i?.spatialReference;return s&&r?(await p(s,r,null,t),i.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch((()=>{})).then((()=>{this._fetchFeaturesController=null})),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e,{view:s}=this;this._locationScaleHandle?.remove(),this._locationScaleHandle=l((()=>this.view?.scale),(()=>this._debouncedLocationUpdate(t).catch((e=>{a(e)||r.getLogger(this).error(e)}))));const{pendingFeatures:o}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:o})}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t}_getHighlightTarget(e,t,i){if(U(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||w:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.view?.map?.allLayers?.includes(e)}async _highlightActiveFeature(){const e="highlight-active-feature";this.removeHandles(e);const{highlightEnabled:t,view:i,activeFeature:s,visible:r}=this;if(!(s&&i&&t&&r))return;const o=this._getHighlightLayer(s);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(i,o);this._highlightActiveFeaturePromise=a;const n=await a;if(!(n&&v(n)&&this._highlightActiveFeaturePromise===a&&this.activeFeature&&this.highlightEnabled))return;const l=n.highlight(this._getHighlightTarget(s,o,i.type));this.addHandles(l,e)}async _highlightSelectedFeature(){const e="highlight-selected-feature";this.removeHandles(e);const{selectedFeature:t,highlightEnabled:i,view:s,visible:r}=this;if(!(t&&s&&i&&r))return;const o=this._getHighlightLayer(t);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(s,o);this._highlightSelectedFeaturePromise=a;const n=await a;if(!(n&&v(n)&&this._highlightSelectedFeaturePromise===a&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const l=n.highlight(this._getHighlightTarget(t,o,s.type));this.addHandles(l,e)}_updateFeatures(e){const{features:t}=this,i=e.filter((e=>!t.includes(e)));i?.length&&(this.features=t.concat(i))}};e([c()],G.prototype,"_fetchFeaturesController",void 0),e([c({type:b})],G.prototype,"actions",void 0),e([c({readOnly:!0})],G.prototype,"active",null),e([c()],G.prototype,"activeFeature",void 0),e([c({readOnly:!0})],G.prototype,"allActions",null),e([c()],G.prototype,"autoCloseEnabled",void 0),e([c()],G.prototype,"autoOpenEnabled",void 0),e([c()],G.prototype,"browseClusterEnabled",void 0),e([c()],G.prototype,"content",void 0),e([c({type:b,readOnly:!0})],G.prototype,"defaultActions",null),e([c({type:Boolean})],G.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],G.prototype,"featureCount",null),e([c()],G.prototype,"featurePage",void 0),e([c({value:[]})],G.prototype,"features",null),e([c()],G.prototype,"featuresPerPage",void 0),e([c()],G.prototype,"featureMenuOpen",void 0),e([c()],G.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],G.prototype,"featureViewModels",void 0),e([c()],G.prototype,"highlightEnabled",void 0),e([c()],G.prototype,"includeDefaultActions",void 0),e([c({type:T})],G.prototype,"location",null),e([c({readOnly:!0})],G.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],G.prototype,"promiseCount",null),e([c()],G.prototype,"promises",null),e([c({readOnly:!0})],G.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],G.prototype,"selectedFeature",null),e([c({value:-1})],G.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],G.prototype,"selectedFeatureViewModel",null),e([c({readOnly:!0})],G.prototype,"state",null),e([c()],G.prototype,"title",void 0),e([c()],G.prototype,"updateLocationEnabled",void 0),e([c()],G.prototype,"view",void 0),e([c()],G.prototype,"visible",void 0),e([c({readOnly:!0})],G.prototype,"waitingForContents",null),e([c({readOnly:!0})],G.prototype,"waitingForResult",null),e([c()],G.prototype,"zoomFactor",void 0),e([c()],G.prototype,"zoomToLocation",void 0),e([c()],G.prototype,"centerAtLocation",null),G=e([d("esri.widgets.Features.FeaturesViewModel")],G);const z=G;export{z as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as h,sync as u}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{initializeProjection as p,project as g}from"../../geometry/projection.js";import{getPointFromGeometry as f}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as m}from"../../geometry/support/webMercatorUtils.js";import y from"../../layers/Layer.js";import{fallbackObjectIDAttribute as w}from"../../layers/LayerConstants.js";import{getDisplayedSymbol as F}from"../../symbols/support/symbolUtils.js";import{highlightsSupported as v}from"../../views/support/layerViewUtils.js";import _ from"../Feature/FeatureViewModel.js";import{ActionsCollection as b,zoomToFeature as C,zoomToClusteredFeatures as P,browseClusteredFeatures as E}from"../Popup/actions.js";import{triggerAction as j,isClusterFeature as M,removeClusteredFeaturesForBrowsing as A,displayClusterExtent as L,browseAggregateFeatures as V,getSelectedTarget as I}from"../Popup/actionUtils.js";import S from"../support/AnchorElementViewModel.js";import{GoToMixin as O}from"../support/GoTo.js";import x from"../../symbols/SimpleFillSymbol.js";import T from"../../geometry/Point.js";const H=()=>[C.clone()],B=()=>[P.clone(),E.clone()];let R=null;function U(e,t){return"building-scene"===e||"2d"===t&&("map-image"===e||"tile"===e||"imagery"===e||"imagery-tile"===e)}let G=class extends(O(S)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightSelectedFeaturePromise=null,this._highlightActiveFeaturePromise=null,this._selectedClusterFeature=null,this._locationScaleHandle=null,this.actions=new b,this.activeFeature=null,this.autoCloseEnabled=!1,this.autoOpenEnabled=!0,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.selectedClusterBoundaryFeature=new t({symbol:new x({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=o((async e=>{const{view:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if("mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const{pendingFeatures:e}=await this._fetchFeaturesWithController({mapPoint:s}),i=(await Promise.all(e)).flat().filter(Boolean);if(!i.length)return;if(i.length!==this.features.length){const e=this._getHighlightLayer(this.selectedFeature),t="imagery"===e?.type?void 0:e&&"objectIdField"in e?e.objectIdField||w:null;if(t){const s=this.selectedFeature.getObjectId(),r=i.findIndex((i=>{const r=this._getHighlightLayer(i);return r?.uid===e?.uid&&i.attributes[t]===s}));this.features=i,this.selectedFeatureIndex=r}}const r=i[this.selectedFeatureIndex]?.geometry,o=("mesh"!==r?.type?r:null)??this.selectedFeature.geometry,a=o?g(o,t.spatialReference):null;if(!a)return;R||(R=await import("../../geometry/geometryEngineAsync.js")),await R.intersects(a,s)||(this.location=(await R.nearestCoordinate(a,s)).coordinate??s)}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=f(this.selectedFeature.geometry)??s}))}initialize(){this.addHandles([this.on("view-change",(()=>this._autoClose())),l((()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view]),(()=>this._highlightSelectedFeature())),l((()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view]),(()=>this._highlightActiveFeature())),l((()=>this.view?.animation?.state),(e=>this._animationStateChange(e))),l((()=>this.location),(e=>this._locationChange(e))),l((()=>this.selectedFeature),(e=>this._selectedFeatureChange(e))),l((()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage]),(()=>this._selectedFeatureIndexChange())),l((()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels]),(()=>this._setGraphicOnFeatureViewModels())),l((()=>this.featureViewModels),(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>j({event:e,viewModel:this,view:this.view}))),h((()=>!this.waitingForResult),(()=>this._waitingForResultChange()),u),l((()=>[this.features,this.view?.map,this.view?.spatialReference,this.view?.timeZone]),(()=>this._updateFeatureVMs())),l((()=>this.view?.scale),(()=>this._viewScaleChange())),h((()=>!this.visible),(()=>this.browseClusterEnabled=!1)),l((()=>this.browseClusterEnabled),(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this._locationScaleHandle?.remove(),this._locationScaleHandle=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new b;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,h=n?.overwriteActions?l:l?.concat(a)??a;return h?.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){const e=this._get("defaultActions")||new b;return e.removeAll(),e.addMany(M(this.selectedFeature)?B():H()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1)}set location(e){let t=e;const i=this.view?.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=m(e)),this._set("location",t)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice(0)).forEach((e=>this._pendingPromises.add(e))),e.reduce(((e,t)=>e.finally((()=>t.then((e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)})).finally((()=>this._pendingPromises.delete(t))).catch((()=>{}))))),Promise.resolve())):this._set("promises",[])}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;e=isNaN(e)||e<-1||!t?-1:(e+t)%t,this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get state(){return this.view?.ready?"ready":"disabled"}get waitingForContents(){return this.featureViewModels.some((e=>e.waitingForContent))}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=I(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex++,this}previous(){return this.selectedFeatureIndex--,this}disableClusterBrowsing(){A(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?M(t)?(await L(this),await V(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}handleViewClick(e){this.autoOpenEnabled&&this._fetchFeaturesAndOpen(e)}_animationStateChange(e){this.zoomToLocation||(C.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(M(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i}=this;i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>1?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>1?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null===i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach(((t,i)=>{t&&(t.graphic??=e[o+i])}))}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(e&&s){if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),M(e))return;return e.symbol=await F(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}if(e.symbol=await F(e),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=f(e.geometry)}}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s}=this;if(M(e)||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const r=i.slice(0),o=[];t.forEach(((t,i)=>{if(!t)return;let a=null;if(r.some(((e,i)=>(e&&e.graphic===t&&(a=e,r.splice(i,1)),!!a))),a)o[i]=a;else{const r=new _({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:s?.spatialReference,graphic:t===e?t:null,location:this.location,map:s?.map,view:s});o[i]=r}})),r.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",o)}async _getScreenPoint(e,t){const{view:i}=this;await(i?.when());const s=e?.spatialReference,r=i?.spatialReference;return s&&r?(await p(s,r,null,t),i.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch((()=>{})).then((()=>{this._fetchFeaturesController=null})),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e,{view:s}=this;this._locationScaleHandle?.remove(),this._locationScaleHandle=l((()=>this.view?.scale),(()=>this._debouncedLocationUpdate(t).catch((e=>{a(e)||r.getLogger(this).error(e)}))));const{pendingFeatures:o}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:o})}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t}_getHighlightTarget(e,t,i){if(U(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||w:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.view?.map?.allLayers?.includes(e)}async _highlightActiveFeature(){const e="highlight-active-feature";this.removeHandles(e);const{highlightEnabled:t,view:i,activeFeature:s,visible:r}=this;if(!(s&&i&&t&&r))return;const o=this._getHighlightLayer(s);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(i,o);this._highlightActiveFeaturePromise=a;const n=await a;if(!(n&&v(n)&&this._highlightActiveFeaturePromise===a&&this.activeFeature&&this.highlightEnabled))return;const l=n.highlight(this._getHighlightTarget(s,o,i.type));this.addHandles(l,e)}async _highlightSelectedFeature(){const e="highlight-selected-feature";this.removeHandles(e);const{selectedFeature:t,highlightEnabled:i,view:s,visible:r}=this;if(!(t&&s&&i&&r))return;const o=this._getHighlightLayer(t);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(s,o);this._highlightSelectedFeaturePromise=a;const n=await a;if(!(n&&v(n)&&this._highlightSelectedFeaturePromise===a&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const l=n.highlight(this._getHighlightTarget(t,o,s.type));this.addHandles(l,e)}_updateFeatures(e){const{features:t}=this,i=e.filter((e=>!t.includes(e)));i?.length&&(this.features=t.concat(i))}};e([c()],G.prototype,"_fetchFeaturesController",void 0),e([c({type:b})],G.prototype,"actions",void 0),e([c({readOnly:!0})],G.prototype,"active",null),e([c()],G.prototype,"activeFeature",void 0),e([c({readOnly:!0})],G.prototype,"allActions",null),e([c()],G.prototype,"autoCloseEnabled",void 0),e([c()],G.prototype,"autoOpenEnabled",void 0),e([c()],G.prototype,"browseClusterEnabled",void 0),e([c()],G.prototype,"content",void 0),e([c({type:b,readOnly:!0})],G.prototype,"defaultActions",null),e([c({type:Boolean})],G.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],G.prototype,"featureCount",null),e([c()],G.prototype,"featurePage",void 0),e([c({value:[]})],G.prototype,"features",null),e([c()],G.prototype,"featuresPerPage",void 0),e([c()],G.prototype,"featureMenuOpen",void 0),e([c()],G.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],G.prototype,"featureViewModels",void 0),e([c()],G.prototype,"highlightEnabled",void 0),e([c()],G.prototype,"includeDefaultActions",void 0),e([c({type:T})],G.prototype,"location",null),e([c({readOnly:!0})],G.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],G.prototype,"promiseCount",null),e([c()],G.prototype,"promises",null),e([c({readOnly:!0})],G.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],G.prototype,"selectedFeature",null),e([c({value:-1})],G.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],G.prototype,"selectedFeatureViewModel",null),e([c({readOnly:!0})],G.prototype,"state",null),e([c()],G.prototype,"title",void 0),e([c()],G.prototype,"updateLocationEnabled",void 0),e([c()],G.prototype,"view",void 0),e([c()],G.prototype,"visible",void 0),e([c({readOnly:!0})],G.prototype,"waitingForContents",null),e([c({readOnly:!0})],G.prototype,"waitingForResult",null),e([c()],G.prototype,"zoomFactor",void 0),e([c()],G.prototype,"zoomToLocation",void 0),e([c()],G.prototype,"centerAtLocation",null),G=e([d("esri.widgets.Features.FeaturesViewModel")],G);const z=G;export{z as default};
|