@arcgis/core 4.34.0-next.1 → 4.34.0-next.2
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/Map.js +1 -1
- package/WebScene.js +1 -1
- package/analysis/DimensionAnalysis.js +1 -1
- package/analysis/LineOfSightAnalysis.js +1 -1
- package/analysis/ViewshedAnalysis.js +1 -1
- package/arcade/Voxel.js +1 -1
- package/arcade/functions/knowledgegraph.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{253bcc3cc7bc4c2dc6ea.js → 03db109e9b695528c35d.js} +1 -1
- package/assets/esri/core/workers/chunks/{fa63b0f7fa799cb2f81d.js → 07e58dff44fcbb3b3539.js} +1 -1
- package/assets/esri/core/workers/chunks/{fc61d02286b6ff5447cc.js → 09da6b3085fc84cd69d5.js} +1 -1
- package/assets/esri/core/workers/chunks/0fd826e7f64a37aaaa1e.js +1 -0
- package/assets/esri/core/workers/chunks/{1c86aa3802d9ae0230ae.js → 28e31ac00dc95a1318e9.js} +1 -1
- package/assets/esri/core/workers/chunks/{0d23610475c85385fbff.js → 355e6bcdb401ada71f39.js} +1 -1
- package/assets/esri/core/workers/chunks/{bba6d7615d8f3862fe70.js → 36f0046ff6b46adce7b7.js} +1 -1
- package/assets/esri/core/workers/chunks/{42d9989b2aad3ac28d4d.js → 397b15d46f22718c9f38.js} +1 -1
- package/assets/esri/core/workers/chunks/{b0522dffa5600345c07e.js → 3e85e63148b5e93d3074.js} +1 -1
- package/assets/esri/core/workers/chunks/{d2ebb72a43d995ed368a.js → 42bb9bb6fe44a47d9b81.js} +1 -1
- package/assets/esri/core/workers/chunks/{6ee41e9c92ed8ba4c763.js → 4dd0a5f327fa5fc7249d.js} +1 -1
- package/assets/esri/core/workers/chunks/{36b0d6b4089a96475201.js → 51ba7345c31e6eb79060.js} +1 -1
- package/assets/esri/core/workers/chunks/{66e79aa02b3aa12b3778.js → 5200be8bce60fa831026.js} +1 -1
- package/assets/esri/core/workers/chunks/{6b23ca6570357f9fb724.js → 52a57106a41b8c9483d7.js} +1 -1
- package/assets/esri/core/workers/chunks/{585c7b485c42555ec554.js → 61f9747c960d959b571b.js} +2 -2
- package/assets/esri/core/workers/chunks/{9fc35ec8185beba96715.js → 632d1a1287dde980479e.js} +1 -1
- package/assets/esri/core/workers/chunks/{1d043965dcdc11b3aeaa.js → 63852887b3f07d50f7c9.js} +1 -1
- package/assets/esri/core/workers/chunks/{c16e0da7a19310c71e8b.js → 677af0281e4fc9f3bd98.js} +1 -1
- package/assets/esri/core/workers/chunks/{6ecc3a3737ae8622dfa4.js → 7b12607633bbdc318936.js} +1 -1
- package/assets/esri/core/workers/chunks/{d839a237d5edc243d645.js → 8aa8f9986b966ccb64e2.js} +1 -1
- package/assets/esri/core/workers/chunks/{67338948e470c1251d8a.js → 8d14e957219364a81d5f.js} +3 -3
- package/assets/esri/core/workers/chunks/92a5dccb328229a9336b.js +1 -0
- package/assets/esri/core/workers/chunks/{631205dc4d73d49ec9ed.js → 95507ff0a243e451b99e.js} +1 -1
- package/assets/esri/core/workers/chunks/{1051a5a57b2fb843a555.js → 9cd55043f3d789f41815.js} +1 -1
- package/assets/esri/core/workers/chunks/{2b1486a466760d2152f5.js → a0f2df8ca7cd14bfa013.js} +1 -1
- package/assets/esri/core/workers/chunks/{06eb4832b6c86744e52e.js → aba19485b6cdcb70dac6.js} +1 -1
- package/assets/esri/core/workers/chunks/{9a06476b834584d00d5c.js → b160dcbea6256e0cf689.js} +1 -1
- package/assets/esri/core/workers/chunks/b2a6afa0cd537805b4b8.js +1 -0
- package/assets/esri/core/workers/chunks/{571252c9822d73cf7b01.js → b845586219f284a215b2.js} +1 -1
- package/assets/esri/core/workers/chunks/{97c148adf0347c69a79c.js → c9604f8df909ec4fad46.js} +1 -1
- package/assets/esri/core/workers/chunks/{b87fec1753f164c845c5.js → ca76950d81ab4ebb65e1.js} +1 -1
- package/assets/esri/core/workers/chunks/{faa40ef04604c7cce706.js → cb63ea6a53d3c2fc3179.js} +1 -1
- package/assets/esri/core/workers/chunks/{55f087bca75c3f2a4515.js → d3c0d7799c92c6f0e7d3.js} +1 -1
- package/assets/esri/core/workers/chunks/{ca60b34c3e1ed2ff5934.js → dd2b316baae02bbdddac.js} +1 -1
- package/assets/esri/core/workers/chunks/{80b596496800e8d60eb8.js → ed75e0962358523f4439.js} +1 -1
- package/assets/esri/core/workers/chunks/{0cf979a093e9744d1e80.js → ef7955a2509be0f03ca2.js} +1 -1
- package/assets/esri/core/workers/chunks/{b5d68d8460b7c15001dd.js → f1c6df5cf2ccb6ac47a1.js} +1 -1
- package/assets/esri/core/workers/chunks/{523046e04679e301797d.js → f3d97a4c4f433adbdab5.js} +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_en.json +1 -1
- package/chunks/FocusAreaColor.glsl.js +10 -8
- package/chunks/persistableUrlUtils.js +1 -1
- package/config.js +1 -1
- package/core/accessorSupport/decorators/persistable.js +1 -1
- package/geometry/projection/projectPointToVector.js +1 -1
- package/geometry/projection/projectVectorToPoint.js +1 -1
- package/geometry/projection/projectVectorToVector.js +1 -1
- package/geometry/projection.js +1 -1
- package/geometry/projectionUtils.js +5 -0
- package/geometry/support/meshUtils/elevation.js +1 -1
- package/geometry/support/meshUtils/extent.js +1 -1
- package/interfaces.d.ts +34 -2
- package/kernel.js +1 -1
- package/layers/MapNotesLayer.js +1 -1
- package/layers/RouteLayer.js +1 -1
- package/layers/graphics/applyEditsUtils.js +1 -1
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/graphics/data/projectionSupport.js +1 -1
- package/layers/graphics/data/queryUtils.js +1 -1
- package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/ogc/wfsUtils.js +1 -1
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/orientedImagery/transformations/updateElevationUtils.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/support/ControlPointsGeoreference.js +1 -1
- package/layers/support/CornersGeoreference.js +1 -1
- package/layers/support/ElevationQuery.js +1 -1
- package/layers/support/ExtentAndRotationGeoreference.js +1 -1
- package/layers/support/GeoreferenceBase.js +1 -1
- package/layers/support/LocalMediaElementSource.js +1 -1
- package/layers/support/MediaElementView.js +1 -1
- package/layers/support/PolygonCollection.js +1 -1
- package/layers/support/SceneModification.js +1 -1
- package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
- package/package.json +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/portal/schemas/webScene.js +1 -1
- package/portal/support/portalItemUtils.js +1 -1
- package/renderers/support/AuthoringInfoVisualVariable.js +1 -1
- package/smartMapping/renderers/size.js +1 -1
- package/smartMapping/renderers/support/spikeUtils.js +1 -1
- package/smartMapping/statistics/histogram.js +1 -1
- package/smartMapping/statistics/summaryStatistics.js +1 -1
- package/support/persistableUrlUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/ViewStateManager.js +1 -1
- package/views/2d/constraints/GeometryConstraint.js +1 -1
- package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
- package/views/2d/grid/GridView2D.js +1 -1
- package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/layers/KMLLayerView2D.js +1 -1
- package/views/2d/viewpointUtils.js +1 -1
- package/views/3d/FocusAreasView.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/analysis/support/projectionUtils.js +1 -1
- package/views/3d/environment/EnvironmentManager.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
- package/views/3d/interactive/editingTools/media/MediaElementControllerControlPoints.js +1 -1
- package/views/3d/interactive/editingTools/media/MediaElementControllerShape.js +1 -1
- package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
- package/views/3d/interactive/visualElements/support/Segment.js +1 -1
- package/views/3d/layers/FeatureLayerView3D.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
- package/views/3d/layers/SceneLayerWorker.js +1 -1
- package/views/3d/layers/TileLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFeatureStore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/focusAreaStyle.js +1 -1
- package/views/3d/layers/graphics/graphicUtils.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
- package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
- package/views/3d/layers/i3s/I3SUtil.js +1 -1
- package/views/3d/layers/support/ImageHighlightHelper3D.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/support/cameraUtils.js +1 -1
- package/views/3d/support/viewpointUtils.js +1 -1
- package/views/3d/terrain/ExtentHelper.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaEffect.js +5 -0
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/shaders/FocusAreaColor.glsl.js +1 -1
- package/views/FocusArea.js +1 -1
- package/views/FocusAreaOutline.js +1 -1
- package/views/FocusAreas.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/View2D.js +1 -1
- package/views/interactive/GraphicManipulator.js +1 -1
- package/views/interactive/dragEventPipeline.js +1 -1
- package/views/interactive/snapping/GridSnappingEngine.js +1 -1
- package/views/interactive/snapping/SnappingManager.js +1 -1
- package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
- package/views/layers/SceneLayerView.js +1 -1
- package/views/support/projectionUtils.js +1 -1
- package/webscene/Slide.js +1 -1
- package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
- package/widgets/BasemapToggle/BasemapToggleViewModel.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/CoordinateConversion/support/Format.js +1 -1
- package/widgets/Editor/Upload.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
- package/widgets/support/AnchorElementViewModel.js +1 -1
- package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
- package/widgets/support/tests.js +1 -1
- package/assets/esri/core/workers/chunks/3a743653b786b010a57f.js +0 -1
- package/assets/esri/core/workers/chunks/6d1e1a4fcb90ea8b6848.js +0 -1
- package/assets/esri/core/workers/chunks/87fc7b6c3e2d4f7775e2.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{equals as a,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import c from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import{equalsShallow as u}from"../../core/lang.js";import h from"../../core/Logger.js";import{clamp as m}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as p}from"../../core/maybe.js";import g from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as v,waitTick as f}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{whenOnce as F,on as b,watch as M,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as k}from"../../core/unitUtils.js";import{property as S}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as V}from"../../core/accessorSupport/decorators/subclass.js";import{distance as A}from"../../core/libs/gl-matrix-2/math/vec2.js";import{isSerializable as C}from"../../core/support/jsonUtils.js";import{UpdatingHandles as G}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import{union as R}from"../../geometry/geometryEngineAsync.js";import O from"../../geometry/Multipoint.js";import T from"../../geometry/Point.js";import j from"../../geometry/Polygon.js";import B from"../../geometry/Polyline.js";import{projectWithZConversion as x}from"../../geometry/projection.js";import E from"../../geometry/SpatialReference.js";import{isClockwise as z}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as H}from"../../geometry/support/webMercatorUtils.js";import D from"../../layers/GraphicsLayer.js";import U from"../../layers/MediaLayer.js";import{searchImages as N,getSortedLayerFeatures as W}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as q}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as $,computePolygonForInspection as J,resizePolygon as Z,checkIfPolygonContainsSelectedPoint as K}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as Q,isElevationSource as X}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{convertGeographicToWebMercator as Y}from"../../layers/orientedImagery/core/utils.js";import{imageToWorld as ee,imageToWorldPanoramic as te}from"../../layers/orientedImagery/transformations/imageToWorld.js";import ae from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as ie}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as re,getInitialAngle as se,convertPixelToHeadingPitch as oe,convertHeadingPitchToSphereVertex as ne,getImageToWorldProperties as ce,getUpdateElevationProps as le,isElevationSampler as ue,getImageToWorldPanoramicProperties as he,pointToArray as me,transformGraphicCoordinatesToPixel as de,getWorldToImageProperties as pe}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as ge,worldToImagePanoramic as ye}from"../../layers/orientedImagery/transformations/worldToImage.js";import ve from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as fe}from"../../layers/support/floorFilterUtils.js";import we from"../../layers/support/VideoElement.js";import Fe from"../../symbols/SimpleLineSymbol.js";import be from"../../views/MapView.js";import Me from"../../views/draw/Draw.js";import{scale as _e}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as Pe}from"../../views/input/InputManager.js";import Ie from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as ke,videoExtent as Se,invalidCameraHeading as Ve,sectorsInOrder as Ae,sectorsRadii as Ce,sampleExtent as Ge}from"./constants.js";import{configureSketchTool as Le,extractFieldsFromDataCaptureLayer as Re,isValidDataCaptureLayer as Oe,constructGraphicFromImageGeometry as Te}from"./dataCaptureUtils.js";import{isFeatureAttachment as je,getImageSourceFromAttachment as Be}from"./galleryUtils.js";import{formatPixels as xe,heightMeasurementPanoramic as Ee,heightMeasurement2D as ze,calculateHeightAccuracyPanoramic as He,calculateHeightAccuracy as De,pixelAreaMeasurement2D as Ue,pixelAreaMeasurementPanoramic as Ne,pixelDistanceMeasurement2D as We,pixelDistanceMeasurementPanoramic as qe,generateCombinations as $e,getRootOfSumOfSquaredErrors as Je,generateCombinationsPanoramic as Ze,calculateLocationAccuracyFromDeviations as Ke,calculateReferenceImagePointPanoramic as Qe,calculateAnglePano as Xe,calculateTempImagePoint as Ye,calculateAngle as et,computeTriangulatedAreaMeasurement as tt,computeTriangulatedDistanceMeasurement as at,getModeCorrectedPoint as it,calculateCorrectedPixel as rt,calculateHeightFromTemporaryDistance as st,computeTriangulatedVector as ot,computeTriangulatedPoint as nt}from"./imageMeasurementUtils.js";import{crossSymbol as ct,crossSymbol3D as lt,measurementPolygonSymbol as ut,polylineSymbolPanoramic as ht,measurementPolylineSymbol as mt,sourcePointSymbol as dt,diamondSymbol as pt,diamondSymbol3D as gt,locationSymbol as yt,locationSymbol3D as vt,activeSourcePointSymbol as ft}from"./symbols.js";import{isNoAttachmentError as wt,getContentType as Ft,isTifOrMrf as bt,filterOILLayerView as Mt,assignElevationSampleToFeatures as _t,calculateDirection as Pt,calculateSegment as It,isSceneView as kt,isGraphic as St}from"./utils.js";import Vt from"./components/ImageViewer.js";import At from"./components/NavigationNode.js";import Ct from"./components/OrientedImageryVideoViewModel.js";import{NoActiveViewerError as Gt,NoFeatureFoundWithObjectIdError as Lt}from"./navigation/errors.js";import{queryFeatureByObjectIds as Rt}from"./navigation/queries.js";import Ot from"../Sketch/SketchViewModel.js";const Tt={click:"view-click",imageClick:"image-click",triangularImageClick:"triangular-click",interactionHandles:"interaction-handles",hittestHandles:"hittest-handles"},jt=new Set(["JPG","JPEG"]),Bt=/\.(\w+)$/,xt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let Et=class extends(c.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.allLayerFeatures=[],this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=ke,this.cameraPitchThreshold=ke,this.videoViewModel=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadImage(a)}catch(o){y(o)||(this.loadImageError(o),h.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,a)=>{if(this.view?.closePopup(),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(a)}catch(i){y(i)||(this.loadImageError(i),h.getLogger(this).error("#loadIImage()","error occured while loading image",i))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.imageMeasurementViewer=new Vt,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.measurementVectors=[],this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.preserveAngle=!1,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t)=>{"default"===this.mode&&"image-loaded"!==this.state||"video"===this.mode&&!this.videoElement?.content||await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new be({map:new Map}),this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new Vt,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._correctedLocationPointOnImage=null,this._overlays=new D({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new Ie,this._previousCursor=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._featureToSector=null,this._updatingHandles=new G,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:a}=await t;return v(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const a=this.additionalFeatures.find((({attributes:t})=>t.objectId===e));if(a)this.currentBestFeature=a;else{const{layer:a,layerFloorFilterClause:r}=this;if(!a)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const s=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(a,e,r,t));try{await s,await this.selectBestFeature(e,t)}catch(i){y(i)||(h.getLogger(this).error("oriented-imagery-viewer:show-image",i),"NoFeatureFoundWithObjectIdError"===i.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",i.message))}}},this.getSectorFeatureById=e=>this._suitabilities?.find((({feature:{attributes:{objectId:t}}})=>t===e)),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{activeViewer:a}=this;if(!a)throw new Gt;return await a.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(v(t),this.currentBestFeature=this.features?.find((({attributes:t})=>`${t.objectId}`==`${e}`)),F((()=>"image-loaded"===this.state),t)),this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=r((async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,c=new t({geometry:n,attributes:o.toJSON(),layer:r});v(e),await s.openPopup({features:[c],location:o.location.clone()})}))},this.updateSuitabilities=(e,t=!0)=>{e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const a=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(a,t),this._groupFeaturesBySectors()},this._createViewClickHandle=()=>{if(this.removeHandles(Tt.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,Pe.WIDGET),Tt.click)},this._createImageClickHandle=()=>{this.removeHandles(Tt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;const n=a.clickAction;a.clickAction="pixel-location";const c=l((()=>{a.clickAction=n}));let u=null;const h=b((()=>a),"pixel-location",(e=>{this.plotReferencePointOnImage(e),u?.abort(),u=r((async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return re(!t,e.spatialReference.equals(t))?e:x(e,t)}));v(a),this.plotReferencePointOnGround(r)}))}));this.addHandles([h,c],Tt.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(Tt.triangularImageClick);const e=this.imageMeasurementViewer?.imageSize;this.triangularMeasurementActive&&"none"!==this.mode&&e&&this.currentBestFeature&&this.addHandles(this.imageMeasurementViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),Tt.triangularImageClick)},this._createTriangularImageLocationHandle=()=>{this.removeHandles(Tt.triangularImageClick);const{imageLocationToolState:e,mode:t,imageMeasurementViewer:a}=this,i=a?.imageSize;if(!e||"none"===t||!i)return;a.clickAction="pixel-location";let s=null;const o=b((()=>a),"pixel-location",(e=>{1===this.measurementVectors.length&&(this.plotLocationPointOnImage(e,!0),s?.abort(),s=r((async a=>{if(!e||this.triangulatedPoint||2===this.measurementVectors?.length||!this.currentBestFeatureMeasurementImage)return;let r=await this.getMapPoint(e,{feature:this.currentBestFeatureMeasurementImage,imageSize:i,mode:t});v(a);const s=this.currentBestFeatureMeasurementImage.geometry.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),v(a)),await this._calculateTriangulatedPointFromGroundPoint(r,{signal:a}),v(a)})))}));this.addHandles(o,Tt.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(Tt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;a.clickAction="pixel-location";let n=null;const c=b((()=>a),"pixel-location",(e=>{this.pixelCoordinates=e,this.plotLocationPointOnImage(e),n?.abort(),n=r((async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});v(a);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),v(a)),this.groundCoordinates=r,this.triangularMeasurementActive&&r&&this._triangulatedLocationWorkflow(r);const n=await this.calculateLocationAccuracy(e,r,t,a);v(a),n&&(this.groundCoordinatesAccuracy=n)}))}));this.addHandles(c,Tt.imageClick)},this._handleImageHitTestResponse=async e=>{const{layer:t}=this;if(!t)return;const a=e.results.find((({graphic:{attributes:e}})=>e&&!e[`${t.imageReferenceField}`]&&!e[`${t.imageGeometryField}`]));if(!a)return;const i=a.graphic.attributes[t.objectIdField];await this.showImageByObjectId(i)},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i||"video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:u,cameraOrientation:m,location:d}=r,p=(c??0)+(o??0),g=d.spatialReference.isWGS84&&4!==m?.type?H(d):new T(d);let f=s;if(je(s))try{f=await Be(a,u,e)}catch(w){if(y(w))return;return wt(w)?(h.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${u}`)):(h.getLogger(this).error(w,{[a.objectIdField]:u,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${u}`))}try{await this.loadImageFromSource(f,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:c}=new URL(o);let l=s?n.match(Bt)?.[1]:e.datasetFormat;if(!l)try{l=await Ft(o,{...t.options})}catch(u){y(u)||h.getLogger(this).error("#getContentType()",u)}switch(l??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,l,o,c,i,r):await this._setImageSource(this._imageViewer,l,o,c,i,r);break;case"panoramic":if(jt.has(l.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let c=i??0;"number"==typeof n?c=n-c:s&&e&&(c=await se(s,e)-c),this._panoramicViewer.pitch=a??0,this._panoramicViewer.yaw=c,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:l});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:i}=this;if(this.imageMeasurementViewer.clearGraphics(),!a||!t||"none"===i||"video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:u,cameraOrientation:m,location:d}=r,p=(c??0)+(o??0),g=d.spatialReference.isWGS84&&4!==m?.type?H(d):new T(d);let f=s;if(je(s))try{f=await Be(a,u,e)}catch(w){if(y(w))return;return wt(w)?(h.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${u}`)):(h.getLogger(this).error(w,{[a.objectIdField]:u,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${u}`))}try{await this.loadImageFromSource(f,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");v(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");v(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:i,triangulatedMeasurementGraphic:r}=this;t&&a&&i&&r&&"active"!==t.state&&(t.update([r],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r((async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,a)=>{if(await f(a),!e)return;const i=new T({...C(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:ct}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._crossSymbol=new t({geometry:new T(n,E.WebMercator),symbol:lt}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([M((()=>this.view),(()=>{this.load()}),_),M((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),P),M((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),M((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),M((()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage]),(()=>{this._createTriangularImageClickHandle()}),_),M((()=>[this.state,this.imageLocationToolState,this.view]),((e,t)=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();e[1]!==t?.[1]&&this._setMeasurementCursor()}),_),M((()=>this.measureType),(()=>{this.clearPreviousMeasurements()}),_),M((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),M((()=>this.currentBestFeature),(async(e,t)=>{d(this._featureChangedTask),this._featureChangedTask=r((async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}]))),await this._featureChangedTask.promise}),{sync:!0}),M((()=>this.currentBestFeatureMeasurementImage),(async(e,t)=>{d(this._featureChangedTask),t&&e!==t&&(this.measurementVectors=[],this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll()),this._featureChangedTask=r((async a=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:a}),v(a),this._reorderTriangularSketchLayer()}))}),_),M((()=>this.triangularMeasurementActive),(async(e,t)=>{t&&!e&&(this.measurementVectors=[],this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics())})),M((()=>this.mode),(e=>{switch(this.removeHandles(Tt.interactionHandles),e){case"default":this.addHandles(M((()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null}),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>a(e,t,u)}),Tt.interactionHandles);break;case"video":this.addHandles(M((()=>{const{footprintExtent:e}=this;if(e)return Se}),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>a(e,t,u)}),Tt.interactionHandles);break;case"panoramic":this.addHandles(M((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:a,vfov:i,hfov:r,pitch:s,yaw:o}=this._panoramicViewer;return e&&a&&!t.includes("loading")?[i,r,o,s]:null}),(e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;this.currentNode&&(this.currentNode.currentHeading=i+(this.currentNode.heading??0),this.currentNode.currentPitch=s+(this.currentNode.pitch??0)),d(this._updateFootprintTask),this._updateFootprintTask=r((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>a(e,t,u)}),Tt.interactionHandles)}}),_),M((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)}),_),M((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)})),M((()=>this.activeViewer),(e=>{this.removeHandles(Tt.hittestHandles),e&&this.addHandles(b((()=>e),"hittest-response",this._handleImageHitTestResponse),Tt.hittestHandles)}))]),this.when().finally((()=>{this.notifyChange("state")}))}destroy(){this._updateFootprintTask=d(this._updateFootprintTask),this._clickTask=d(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=p(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this._referencePointOnImage=p(this._referencePointOnImage),this._locationPointOnImage=p(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:a}=this;switch(a){case"default":return e;case"panoramic":return t;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every((e=>0===e))??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",m(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",m(e,-10,10))}get currentNode(){const{currentBestFeature:e,navigationNodes:t}=this;return t.find((t=>t.id===e?.attributes.objectId))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return bt(t)||je(t)}get imageLoaded(){return o(h.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===Ve}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(Mt(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?fe(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";if(e.orientedImageryType?.includes("video"))return"video";const{horizontalFieldOfView:t,isSpherical:a}=e;return 360===t||a?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Ae.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",m(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:a},_featureChangedTask:i}=this;if(t)return"disabled";if(!this.isFulfilled()||a||!1===i?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:i}})=>{const r=e?.trim();return bt(r)||je(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new D({elevationInfo:{mode:"absolute-height"}});case"default":return new D;default:return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}beforeLoad(){this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._overlays?.removeAll()}async computeHeight(e,t,a=!0){const{currentBestFeature:i,activeViewer:r,layer:s,footprintExtent:o}=this,n=r?.imageSize,c=i?.attributes,l=s?.orientationAccuracy;if(!c||!n||!e||e.length<2||!l)return;const u="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ce(c,n[0],n[1]),h=e.at(0),m=e.at(-1);if(!(u&&h&&m&&l&&o))return;const d=[m,h],p=xe(d,!1),g="panoramic"===t?await Ee(d,u,l,i,!0,!1):await ze(d,u,l,!0,a);if(!g)return;const y="panoramic"===t?await He(l,p,u,g,i,!0):await De(l,p,u,g,!0);return y?{value:g,accuracy:y}:{value:g}}async calculateAreaMeasurement(e,t,a){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const i="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return v(a),i?"default"===t?await Ue(e,i,!0):await Ne(e,i,!0,a):null}async calculateDistanceMeasurement(e,t,a){const{currentBestFeature:i,activeViewer:r}=this;if(e.length<2||!i||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return v(a),s?"default"===t?await We([e.at(0),e.at(-1)],s,!0):await qe([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s}=this,o=i?.orientationAccuracy,n=o?.every((e=>0===e))||!o?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||n)return null;let c=null;if(this.triangularMeasurementActive&&this.currentBestFeatureMeasurementImage&&this.imageMeasurementViewer?c=await this.getMeasurementProperties(this.currentBestFeatureMeasurementImage,this.imageMeasurementViewer):(c=await this.getMeasurementProperties(),v(a)),!c)return null;const l="area"===t?await Ue(e,c,!0):await We([e.at(0),e.at(-1)],c,!0);v(a);const{updateElevationProps:u,...h}=c,m=$e(h,o);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async i=>{const r="area"===t?await Ue(e,i,!0):await We([e.at(0),e.at(-1)],i,!0);if(v(a),r&&l){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-l.area):null}return Math.abs(r-l)}return null})),p=await Promise.all(d);v(a);const g=p.filter((e=>null!==e));return 0===g.length?null:Je(g)}async calculateLocationAccuracy(e,t,a="default",i){const{layer:r,currentBestFeature:s}=this,o=r?.orientationAccuracy,n=this.view?.spatialReference,c=o?.every((e=>0===e))||!o?.length;if(!s||c)return null;const l="default"===a?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();if(v(i),!l)return null;const{updateElevationProps:u,...h}=l,m="default"===a?$e(h,o):Ze(h,o);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async r=>{const{updateElevationProps:s,...o}=r;let c="default"===a?await ee(e,o,s):await te(e,o,s);return v(i),n&&!c.spatialReference.equals(n)&&(c=await x(c,n),v(i)),c&&t?[Math.abs(c.x-t.x),Math.abs(c.y-t.y),c.z&&t.z?Math.abs(c.z-t.z):0]:null})),p=await Promise.all(d);if(v(i),!p?.length)return null;const g=p.map((e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0])),[y,f,w]=Ke(g);return{x:y,y:f,z:w}}async calculateAccuracyPanoramic(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s,mode:o}=this,n=i?.orientationAccuracy,c=n?.every((e=>0===e))||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||c||"panoramic"!==o)return null;const l=await this.getMeasurementPropertiesPanoramic();if(v(a),!l)return null;const u="area"===t?await Ne(e,l,!0):await qe([e.at(0),e.at(-1)],l,!0);v(a);const{updateElevationProps:h,...m}=l,d=Ze(m,n);if(!d?.length)return null;const p=d.map((e=>({...e,updateElevationProps:h}))).map((async i=>{const r="area"===t?await Ne(e,i,!0):await qe([e.at(0),e.at(-1)],i,!0);if(v(a),r&&u){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-u.area):null}return Math.abs(r-u)}return null})),g=await Promise.all(p);v(a);const y=g.filter((e=>null!==e));return 0===y.length?null:Je(y)}async calculateHeightMeasurementInfo(e,t,a){const{currentBestFeature:i,activeViewer:r}=this,s=r?.imageSize;if(!i||!r||!s?.length||"none"===t)return;const{attributes:o}=i,[n]=xe([e],"panoramic"!==t),c="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ce(o,s[0],s[1]);if("panoramic"===t){if(!c)return;const e=await Qe(n,c,i,a);if(!e)return;e?.heading>180&&(e.heading-=360);const t=Xe(n,e),r=A([n.x,n.y],[e.x,e.y]);if(!t||!r)return;return{measurementAngle:t,tempDistance:r}}const l=await Ye(n,c,a);if(!l)return;const u=et(n,l),h=A([n.x,n.y],[l.x,l.y]);return u&&h?{measurementAngle:u,tempDistance:h}:void 0}async calculateTriangulatedMeasurements(e){switch(this.measureType){case"distance":{this.triangulatedDistanceMeasurement=await at(this.measurementVectors);const t=await this.calculateAccuracy(e,"distance");if(t&&this.triangulatedDistanceMeasurement?.distance){const e=Math.atan(t/this.triangulatedDistanceMeasurement.distance);this.triangulatedDistanceAccuracy={distanceAccuracy:t,angleAccuracy:e}}break}case"area":if(this.currentBestFeatureMeasurementImage?.geometry.spatialReference){const t=await tt(this.measurementVectors,this.currentBestFeatureMeasurementImage.geometry.spatialReference);this.triangulatedAreaMeasurement=t,this.triangulatedAreaAccuracy=await this.calculateAccuracy(e,"area")??this.triangulatedAreaAccuracy}}}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:a,dataCaptureLayer:i}=this;if(!a)throw xt();Le(i,e,a),await a.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw xt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw xt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw xt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw xt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw xt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw xt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t,a=!1){const i=[],r=[],s=[];return e.forEach((e=>{const{layer:{coveragePercent:o},attributes:n}=e;let c;const l=k(e.geometry.spatialReference);n.cameraHeight/=l,n.farDistance/=l,n.nearDistance/=l,Q(n.elevationSource)&&(n.elevationSource.constantElevation/=l);const{polygon:u,frustum:h}=$(n);if(c=u.clone(),n.isInspection&&(c=J(n)),o&&(c=Z(c,o)),a||!t||K(c,t)){s.push(e);const{geometry:t,objectId:a,cameraHeight:o,cameraHeading:c}=n,l=t.clone();l.z=o,l.imageID=a,this.pointSources.push(l),c!==Ve&&(i.push(u),h&&r.push(h))}})),{features:s,polygons:i,frustums:r}}getMeasurementProperties(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ce(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,E.WebMercator):Promise.resolve(n)).then((e=>(n=e,le((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ue(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=he(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,E.WebMercator):Promise.resolve(n)).then((e=>(n=e,le((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ue(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimagery","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then((({features:e})=>t.applyEdits({deleteFeatures:e})))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[Ae[e]],a=t?.at(0);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t],r=i?.at(a);r&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(r):this._updateCurrentBestFeature(r))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s}=this,o=s?.imageSize;if(!e.vertices||!o)return;const n=it(e.vertices.at(-1),r,o);if(i.length<1||!n||!a||!t||"none"===r)return;const c=rt(i[0],n,t);if(!c?.length)return;this.heightMeasurementPixels.push(c),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const l=st(this.heightMeasurementPixels,a);l&&(this.heightMeasurementResult=l)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=it(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.selectedPoint=Y(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}loadImageError(e){h.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:a}=await t;v(e),this.sketch=new a({layer:this._sketchGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:a}=await t;if(v(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async loadTriangulatedMeasurementAdapter(e){if(!this.triangulatedMeasurementAdapter){const t=import("./adapters/sketch/TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(v(e),this.triangulatedMeasurementAdapter=new a({viewModel:this}),!this.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.triangulatedMeasurementAdapter}async processFeatureResponse(e,t,a){const{features:i}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(i))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t,a?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,a);v(a),await this._updateElevationOfSelectedPointAndLocations(r,t,n),v(a),_t(r,n);const c=this._processSuitableFeatures(r,t);this.updateSuitabilities(c,a?.loadBestImage)}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=ut(o),this.sketch.polylineSymbol="panoramic"===s?ht:mt(o,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new Me({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],(e=>this.handleDrawEvents(e)))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new B({paths:[e],spatialReference:a});else{const i=new B({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:mt(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=oe(i,a[0],a[1]),{heading:n,pitch:c}=oe(r,a[0],a[1]),l=[[...ne(s,o)],[...ne(n,c)]];if(this.heightGraphic)this.heightGraphic.geometry=new B({paths:[l],spatialReference:e});else{const a=new B({paths:[l],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:ht}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async editOverlayedGraphics(e){this.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.sketchTriangularGraphicsLayer.add(e),this.sketchTriangular||(this._initializeSketchTriangular(),await this.loadTriangulatedMeasurementAdapter()),this.updateOverlayedGeometry(e)}updateOverlayedGeometry(e){this.sketchTriangular?.update([e],{tool:"reshape"})}async processMeasurementVectors(e){this.triangularMeasurementActive&&this.currentBestFeature&&(this.measurementVectors?.length<2&&await this.updateMeasurementVectorsArray(e),2===this.measurementVectors.length&&await this.calculateTriangulatedMeasurements(e))}async updateMeasurementVectorsArray(e){const t=this.measurementVectors.length?this.currentBestFeatureMeasurementImage:this.currentBestFeature;if(t){const a=await this.computeMeasurementVector(e,t);a&&this.measurementVectors.push(a)}}async computeMeasurementVector(e,t){const{activeViewer:a,mode:i}=this,r=a?.imageSize;if(!e||!t||!r)return;const s=e.map((e=>[e[0]-.5,-.5-e[1]])),o=this.view?.spatialReference,n=[];for(let c=0;c<s.length;c++){const e={x:s[c][0],y:s[c][1]};let a=await this.getMapPoint(e,{feature:t,imageSize:r,mode:i});o&&!a.spatialReference.equals(o)&&(a=await x(a,o)),n.push(a)}return ot(n,t)}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n,layerFloorFilterClause:c}=this,l=a?.imageSize;if(!l||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:u}=$(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:I(`${s.objectIdField} <> ${i.attributes.objectId}`,I(s.definitionExpression,c)),geometry:u,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:l,mode:o}),n=dt.clone();return n.outline=new Fe({color:[0,0,0],width:1}),new t({attributes:a,symbol:n,geometry:s})})));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:c,layer:l}=this,u=r?.imageSize;if(!u||!o||"none"===n||"video"===n||c.includes("loading")||!l)return;const{polygon:m}=$(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Re(e,l.imageGeometryField,l.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:d}=await e.queryFeatures({geometry:m,returnGeometry:!0,outFields:["*"]}),p=new s((await Promise.all(d.map((async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:c}=i,l=c,{imageGeometryField:m,oiObjectIdField:d}=this;if(m&&d&&Oe(e,m,d)&&`${s[d]}`==`${o.attributes.objectId}`)try{return Te(s,m,e,a,u,n,r)}catch(g){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(l?.type){case"point":{const i=await this.getPixels(l,{feature:o,imageSize:u,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:c}=l,h=i.map((e=>e.map((([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))))),m=await Promise.all(h.map((async e=>this.getPixels(e,{feature:o,imageSize:u,mode:n}).then((e=>e.map(me))))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({rings:m,spatialReference:E.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:c}=l,h=i.map((e=>e.map((([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))))),m=await Promise.all(h.map((async e=>this.getPixels(e,{feature:o,imageSize:u,mode:n}).then((e=>e.map(me))))));return new t({attributes:s,layer:e,symbol:r,geometry:new B({paths:m,spatialReference:E.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:c}=l,h=i.map((([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))),m=await this.getPixels(h,{feature:o,imageSize:u,mode:n}).then((e=>e.map(me)));return new t({attributes:s,layer:e,symbol:r,geometry:new O({points:m,spatialReference:E.WebMercator}),visible:e.visible&&a})}}return null})))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,p)}async getPixels(e,t){const{imageSize:a,mode:i}=t,r=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===i)return new T({x:e.x-.5,y:.5-e.y,spatialReference:E.WebMercator});const[t,r]=a,{heading:s,pitch:o}=oe(e,t,r),n=ne(s,o);return new T(n,E.WebMercator)}));return Array.isArray(e)?r:r[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:c,elevation:l,cameraHeight:u}=o;let h=c.clone();h.spatialReference.isGeographic&&(h=await x(h,E.WebMercator));const m=await le(l??(c.z??0)-u,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;if("elevationSample"in m&&ue(m.elevationSample)&&(a.elevationSample=m.elevationSample),"default"===i){const t=ce(o,r[0],r[1]);d=await ee(Array.isArray(e)?e:[e],{...t,cameraLocation:h},m)}else{const t=he(o,r[0],r[1]);d=await te(Array.isArray(e)?e:[e],{...t,cameraLocation:h},m)}return Array.isArray(e)?d:d[0]}getActiveSectors(){return Ae.filter((e=>this._sectorData?.[e]?.length))}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new T({...e.toJSON()}),symbol:pt}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=C(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new T({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:pt}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new T(n,E.WebMercator),symbol:gt}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e,t=!1){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(t),this.mode){case"default":this._plotLocationPointOnDefaultImage(e,t);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=d(this._clickTask)}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.measurementVectors=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce(((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:c}=n;return r?t.error.push(n):(a&&(c[e.objectIdField]=a),i&&e.globalIdField&&(c[e.globalIdField]=i),t.success.push(n)),t}),{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s||"video"===s)throw new n("orientedimagery","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimagery","Data capture layer is not available");const c=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,c=r.hasZ,l=r.geometryType,u=n!==l,h=u?await import("./transformers.js"):null,m=h?.default[l],d=u?m?.(i):i;if(d)switch(d.type){case"point":return t.geometry=await this.getMapPoint(de(s,d,o),{feature:a,imageSize:o,mode:s}),c||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(d.rings.map((async e=>this.getMapPoint(e.map((([e,t,a])=>de(s,{x:e,y:t,z:a},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new j({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,rings:e.map((e=>e.map(me)))}),t}case"polyline":{const e=await Promise.all(d.paths.map((async e=>this.getMapPoint(e.map((([e,t,a])=>de(s,{x:e,y:t,z:a},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new B({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,paths:e.map((e=>e.map(me)))}),t}}}))),l=c.filter(i);return r.applyEdits({addFeatures:l}).then((e=>{const{addFeatureResults:t}=e;let a=0;const i=c.map((e=>{const i=t[a++];return e?i:{error:new n("orientedimagery","Error in saving data capture features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:i}}))}async searchBestImage(e,t){try{const a=await N(e,t);a&&await this.processFeatureResponse(a,e.point,t)}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),h.getLogger(this).error("error occurred while finding best image",a))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],c=[],l=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?c.push(s):l.push(s);this.overlayGraphicsOnImage(e.id,new s(l)),this.collectionId=e.id;const u=await this.loadSketch(t),h=await this.loadDataCaptureAdapter(t);v(t),u.layer.addMany(c),u.layer.blendMode="source-atop",h.savedGraphics.addMany(c);a.ui.find("zoom").visible=!1,a.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const a=this.overlayedMapFeatures.get(e);a&&this._toggleVisiblity(a,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:a}=e;let i=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);i=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);r=s.extent.contains(e);break}}if(!i&&!r)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,a);if(o)return v(a),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}async _calculateTriangulatedPointFromGroundPoint(e,t){if(this.currentBestFeatureMeasurementImage&&e){const{currentBestFeatureMeasurementImage:a}=this,i=ot(e,a);i&&this.measurementVectors.push(i);const r=await nt(this.measurementVectors);v(t),this.triangulatedPoint=r??this.triangulatedPoint}}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),h.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:a,invalidCameraHeading:i}=this,r=a.at(0);if(!e||!t||!r||!a||i)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const h of Ae)this._sectorData[h]=new s;const n=e.map(((e,t)=>({...e,featureIndex:t})));n.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const c=n.map((({distance:e})=>e)),l=Math.max(...c),u=a.reduce(((e,t)=>Math.max(e,t.attributes.location.z??0)),-1/0);n.forEach((e=>{const{distance:t,angle:i,featureIndex:s}=e,n=t/l*Ce[2],c=It(t,l),h=Pt(i);if(!this._sectorData)return;const m=Ce[3]+n*Math.sin(i*Math.PI/180),d=Ce[3]+n*Math.cos(i*Math.PI/180);let p;const g=a.at(s),y=(g.attributes.location.z??0)/u*Ce[2],v=g===r,{cameraPitch:f}=g.attributes,w=f<5;if(v&&w)p=-90;else{const e=m-Ce[3],t=d-Ce[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),p=i}const F=""===c?h:`${c}_${h}`;v&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=w?null:{x:m,y:d,direction:h}),o[`${g.attributes.objectId}`]=F;const b=this._sectorData[F];b.add({angle:i,featureIndex:s,x:m,y:d,z:y,objectID:g.attributes.objectId,sector:F,featureIndexInSector:b.length})}))}_handleDestroyedTriangularSketchLayer(){this.sketchTriangularGraphicsLayer&&(this.imageMeasurementViewer.imageRenderer.map.layers.remove(this.sketchTriangularGraphicsLayer),this.sketchTriangularGraphicsLayer=new D,this.imageMeasurementViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer),this.sketchTriangular&&(this.sketchTriangular.layer=this.sketchTriangularGraphicsLayer,this.sketchTriangular.view=this.imageMeasurementViewer.imageRenderer))}_initializeSketchTriangular(){this.sketchTriangular=new Ot({view:this.imageMeasurementViewer.imageRenderer,layer:this.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1}})}_initializeSketchTriangularGraphicsLayer(){this.sketchTriangularGraphicsLayer=new D,this.imageMeasurementViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer)}_initializeVideo(){if(this.videoElement)return;this.videoElement=new we({video:this.layer?.imagePathPrefix,georeference:new ve({extent:new L(Ge)})});const e=new U({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.videoViewModel=new Ct({oiViewModel:this})}_plotLocationPointOnDefaultImage(e,a=!1){const i=C(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,a?(this._correctedLocationPointOnImage=new t({geometry:new T({spatialReference:E.WebMercator,...i}),symbol:yt}),this.imageMeasurementViewer.addGraphic(this._correctedLocationPointOnImage,0)):(this._locationPointOnImage=new t({geometry:new T({spatialReference:E.WebMercator,...i}),symbol:yt}),this._imageViewer.addGraphic(this._locationPointOnImage,0))}_plotLocationPointOnPanoramicImage(e){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._locationPointOnImage=new t({geometry:new T(n,E.WebMercator),symbol:vt}),this._panoramicViewer.addGraphic(this._locationPointOnImage,0)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.setMessage("noImageError","error"),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,a){if(!e[0])return;const i=await R(e);if(this._updateFootprintWithFeatures(t,i),this.view?.supportsGround)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(r){y(r)||h.getLogger(this).error(r)}}async processElevationSample(e,t,a){const{elevationSource:i}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,a);return r||(i&&this.footprintExtent&&X(i)?await ie({extent:this.footprintExtent,lod:i.lod,url:i.url,rasterFunction:i.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return q({features:e,selectedPoint:t,camera:kt(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;const{layerFloorFilterClause:n}=this,c=e.spatialReference.equals(o.spatialReference)?o:await x(o,e.spatialReference),l=c.spatialReference.isGeographic?H(c):c,u=I("1=1",I(e.definitionExpression,n)),h=l.spatialReference.isGeographic?1:k(l.spatialReference),m={layerInstanceOrURL:e,point:l,queryParams:{where:u,maximumDistance:e.maximumDistance?e.maximumDistance/h:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(m,a)}async _queryAndLoadByObjectId(e,t,a,i){this.displayMessage=null;const{response:r}=await Rt(e,t,a,i);if(v(i),!r?.features?.length)throw new Lt(t);const s=Y($(r.features[0].attributes).polygon.centroid),o=k(s.spatialReference);this.selectedPoint=s;const n={layerInstanceOrURL:e,point:s,queryParams:{where:I("1=1",I(e.definitionExpression,a)),maximumDistance:e.maximumDistance?e.maximumDistance/o:void 0}};return await this.searchBestImage(n,{...i,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}_resetCursor(){const{activeViewer:e,imageMeasurementViewer:t}=this;e&&(e.imageRenderer.cursor=this._previousCursor),t&&(t.imageRenderer.cursor=this._previousCursor)}async _setImageSource(e,t,a,i,r,s){e.imageSource={datasetFormat:t.toUpperCase(),url:a.split("?")[0]},e.customParameters=Object.fromEntries(i),e.imageRotation=r??0,await e.loadImage(s)}_setMeasurementCursor(){const{activeViewer:e,imageMeasurementViewer:t,triangularMeasurementActive:a}=this;e&&(this._previousCursor=e.imageRenderer.cursor,e.imageRenderer.cursor="crosshair"),t&&a&&(t.imageRenderer.cursor="crosshair")}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_triangulatedLocationWorkflow(e){if(this.currentBestFeature&&e){const{currentBestFeature:t}=this;this.triangulatedPoint&&(this.measurementVectors=[],this.triangulatedPoint=null,this.clearLocationPointOnImage(!0));const a=ot(e,t);if(!a)return;this.measurementVectors.push(a),this.plotReferenceLocationPoint(e),this._createTriangularImageLocationHandle()}}async _updateElevationOfSelectedPointAndLocations(e,t,a,i){const r=ue(a),s=await le((e[0].attributes.location.z??0)-e[0].attributes.cameraHeight,{elevationSample:r?a:void 0,elevationSource:r?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},i);v(i);const[o,...n]=await ae([t,...e.map((e=>e.attributes.geometry.clone()))],s);v(i),t.elevation=o.z,e.forEach(((e,t)=>{e.attributes.elevation=n[t].z}))}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.navigationNodes.removeAll(),this.navigationNodes.addMany(e.map((e=>new At({geometry:e.geometry,attributes:e.attributes})))),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0]),"video"===this.mode&&(this._initializeVideo(),this.videoViewModel?.playVideoFromSelectedLocation(e[0]))}_updateFootprintWithFeatures(e,t){const a=[];for(const{geometry:i}of e)t.contains(i)||a.push([i.x,i.y]);a.sort(((e,t)=>+z([e,t]))),t.addRing(a),this.footprintExtent=_e(t.extent,2,2)}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),v(e);for(const e of a)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:ft,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:dt,visible:s}));if("video"===o&&n&&!this.allLayerFeatures.length){const e=await W(n,i.geometry.spatialReference);e.features?.length&&(this.allLayerFeatures=e.features)}}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(t)a=-90;else{const t=e.x-Ce[3],i=e.y-Ce[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage))}clearLocationPointOnImage(e=!1){this._locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=p(this._locationPointOnImage)),this._correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this._correctedLocationPointOnImage),this._correctedLocationPointOnImage=p(this._correctedLocationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}plotReferenceLocationPoint(e){if(this.currentBestFeatureMeasurementImage){const t=this.imageMeasurementViewer.imageSize[0],a=this.imageMeasurementViewer.imageSize[1],i=pe(this.currentBestFeatureMeasurementImage.attributes,t,a),r=ge(e,i);this.plotLocationPointOnImage(r,!0)}}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,e),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||h.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t){const{footprintExtent:a}=this,{imageSize:i}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!i||!a)return;const{attributes:{location:r,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:c},elevationSample:l}=this.currentBestFeature;let u=r.clone();const h=await le(n??(r.z??0)-c,{elevationSample:l,elevationSource:s});this.currentBestFeature.elevationSample=h.elevationSample;const m=Array.isArray(e)?e:[e];let d,p=await Promise.all(m.map((e=>new Promise((t=>{if(!e.hasZ)return t(ae(e,h));t(e)})))));if(r.spatialReference.isGeographic&&(u=await x(u,E.WebMercator,t)),p=await Promise.all(p.map((async e=>u.spatialReference.equals(e.spatialReference)?e:await x(e,u.spatialReference,t)))),v(t),"panoramic"===this.mode)d=ye(p,{imageHeight:i[1],imageWidth:i[0],cameraHeading:o,cameraLocation:u});else{const e=pe(this.currentBestFeature.attributes,i[0],i[1]);d=ge(p,{...e,cameraLocation:u})}return Array.isArray(e)?d:d[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:c,_adapter:l,mode:u}=this,{attributes:{objectId:h},elevationSample:m}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),c){const e=[...a,...i,s].filter(St);c.supportsGround&&m&&l?.updateGroundElevation&&(this._updateGroundElevation&&l.updateGroundElevation(e,m),"panoramic"===u&&l.updateGroundElevation([this.bestFeatureCurrentFootprint],m)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:ct.clone(),attributes:{imageID:h}}))),this._overlays.graphics.addMany(e)}}else if(c){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,c?.supportsGround&&m&&l?.updateGroundElevation&&"panoramic"===u&&l.updateGroundElevation([e],m),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],Et.prototype,"activeLayer",null),e([S({readOnly:!0})],Et.prototype,"activeViewer",null),e([S()],Et.prototype,"accuracyParametersMissing",null),e([S()],Et.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],Et.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],Et.prototype,"additionalFootprints",void 0),e([S()],Et.prototype,"areaMeasurementResult",void 0),e([S()],Et.prototype,"areaMeasurementAccuracy",void 0),e([S()],Et.prototype,"allLayerFeatures",void 0),e([S()],Et.prototype,"bestFeatureAngle",void 0),e([S()],Et.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],Et.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],Et.prototype,"brightness",null),e([S()],Et.prototype,"cameraHeadingThreshold",void 0),e([S()],Et.prototype,"cameraPitchThreshold",void 0),e([S()],Et.prototype,"videoViewModel",void 0),e([S()],Et.prototype,"collectionId",void 0),e([S({type:Number})],Et.prototype,"contrast",null),e([S()],Et.prototype,"conversionProps",void 0),e([S()],Et.prototype,"coverageFrustums",void 0),e([S()],Et.prototype,"coveragePolygons",void 0),e([S()],Et.prototype,"currentBestFeature",void 0),e([S()],Et.prototype,"currentBestFeatureMeasurementImage",void 0),e([S()],Et.prototype,"currentBestFeatureLocation",void 0),e([S()],Et.prototype,"currentCoverageVisible",void 0),e([S()],Et.prototype,"currentNode",null),e([S()],Et.prototype,"navigationNodes",void 0),e([S({json:{write:!1}})],Et.prototype,"determineWorkflowForFeature",void 0),e([S({json:{write:!1}})],Et.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([S()],Et.prototype,"disabled",void 0),e([S()],Et.prototype,"displayMessage",void 0),e([S()],Et.prototype,"displayNewMeasurementButton",void 0),e([S()],Et.prototype,"distanceMeasurementResult",void 0),e([S()],Et.prototype,"distanceAccuracyArray",void 0),e([S()],Et.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],Et.prototype,"featureCount",null),e([S()],Et.prototype,"features",void 0),e([S()],Et.prototype,"groundCoordinates",void 0),e([S()],Et.prototype,"groundCoordinatesAccuracy",void 0),e([S()],Et.prototype,"heightMeasurementPixels",void 0),e([S()],Et.prototype,"heightGraphic",void 0),e([S()],Et.prototype,"heightMeasurementResult",void 0),e([S()],Et.prototype,"heightMeasurementAccuracy",void 0),e([S()],Et.prototype,"measurementAngle",void 0),e([S()],Et.prototype,"tempDistance",void 0),e([S({readOnly:!0})],Et.prototype,"imageGalleryEnabled",null),e([S()],Et.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],Et.prototype,"imageLoaded",null),e([S()],Et.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],Et.prototype,"invalidCameraHeading",null),e([S()],Et.prototype,"imagePointsInView",null),e([S()],Et.prototype,"imageMeasurementViewer",void 0),e([S()],Et.prototype,"isAdditionalCoverageVisible",void 0),e([S()],Et.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],Et.prototype,"measurementVectors",void 0),e([S()],Et.prototype,"layer",void 0),e([S()],Et.prototype,"layerView",null),e([S({readOnly:!0})],Et.prototype,"layerFloorFilterClause",null),e([S({type:Number})],Et.prototype,"localPort",void 0),e([S()],Et.prototype,"mapImageConversionToolState",void 0),e([S()],Et.prototype,"measureType",void 0),e([S()],Et.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],Et.prototype,"mode",null),e([S()],Et.prototype,"navigationMode",void 0),e([S()],Et.prototype,"navigatorCurrentBestFeature",void 0),e([S()],Et.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],Et.prototype,"overlayedCameraLocations",void 0),e([S()],Et.prototype,"overlayedMapFeatures",void 0),e([S()],Et.prototype,"pixelCoordinates",void 0),e([S()],Et.prototype,"preserveAngle",void 0),e([S()],Et.prototype,"pointSources",void 0),e([S({readOnly:!0})],Et.prototype,"popupEnabled",null),e([S()],Et.prototype,"previousFeatureAngle",void 0),e([S()],Et.prototype,"referencePoint",null),e([S({readOnly:!0})],Et.prototype,"sectorData",null),e([S()],Et.prototype,"selectedPoint",void 0),e([S({type:Number})],Et.prototype,"sharpness",null),e([S()],Et.prototype,"shouldShowSelectedImage",void 0),e([S()],Et.prototype,"sketch",void 0),e([S()],Et.prototype,"sketchTriangular",void 0),e([S()],Et.prototype,"sketchTriangularGraphicsLayer",void 0),e([S()],Et.prototype,"draw",void 0),e([S()],Et.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],Et.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],Et.prototype,"state",null),e([S({readOnly:!0})],Et.prototype,"thumbnails",null),e([S()],Et.prototype,"triangularMeasurementActive",void 0),e([S()],Et.prototype,"triangulatedDistanceMeasurement",void 0),e([S()],Et.prototype,"triangulatedDistanceAccuracy",void 0),e([S()],Et.prototype,"triangulatedAreaMeasurement",void 0),e([S()],Et.prototype,"triangulatedAreaAccuracy",void 0),e([S()],Et.prototype,"triangulatedMeasurementGraphic",void 0),e([S()],Et.prototype,"triangulatedPoint",void 0),e([S()],Et.prototype,"triangulatedMeasurementAdapter",void 0),e([S()],Et.prototype,"updateFootprint",void 0),e([S()],Et.prototype,"updateFootprintPanorama",void 0),e([S()],Et.prototype,"updatingTriangularMeasurementState",void 0),e([S({value:null})],Et.prototype,"view",null),e([S()],Et.prototype,"videoElement",void 0),e([S()],Et.prototype,"videoLayer",void 0),e([S()],Et.prototype,"videoMapView",void 0),e([S()],Et.prototype,"_adapter",void 0),e([S()],Et.prototype,"_sketchGraphicsLayer",null),e([S()],Et.prototype,"_highlightedFeatureHandle",void 0),e([S()],Et.prototype,"_imageViewer",void 0),e([S()],Et.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],Et.prototype,"_locationPointOnImage",void 0),e([S()],Et.prototype,"_correctedLocationPointOnImage",void 0),e([S()],Et.prototype,"_overlays",void 0),e([S({readOnly:!0})],Et.prototype,"_overlaysView",null),e([S()],Et.prototype,"_panoramicViewer",void 0),e([S()],Et.prototype,"_previousCursor",void 0),e([S()],Et.prototype,"_referencePointOnGround",void 0),e([S()],Et.prototype,"_referencePointOnImage",void 0),e([S()],Et.prototype,"_sectorData",void 0),e([S()],Et.prototype,"_featureToSector",void 0),e([S({readOnly:!0})],Et.prototype,"_updatingHandles",void 0),e([S()],Et.prototype,"footprintExtent",void 0),e([S()],Et.prototype,"_featureChangedTask",void 0),Et=e([V("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],Et);const zt=Et;export{zt as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{equals as a,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import c from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import{equalsShallow as u}from"../../core/lang.js";import h from"../../core/Logger.js";import{clamp as m}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as p}from"../../core/maybe.js";import g from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as v,waitTick as f}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{whenOnce as F,on as b,watch as M,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as k}from"../../core/unitUtils.js";import{property as S}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as V}from"../../core/accessorSupport/decorators/subclass.js";import{distance as A}from"../../core/libs/gl-matrix-2/math/vec2.js";import{isSerializable as C}from"../../core/support/jsonUtils.js";import{UpdatingHandles as G}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import{union as R}from"../../geometry/geometryEngineAsync.js";import O from"../../geometry/Multipoint.js";import T from"../../geometry/Point.js";import j from"../../geometry/Polygon.js";import B from"../../geometry/Polyline.js";import{projectWithZConversion as x}from"../../geometry/projectionUtils.js";import E from"../../geometry/SpatialReference.js";import{isClockwise as z}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as H}from"../../geometry/support/webMercatorUtils.js";import D from"../../layers/GraphicsLayer.js";import U from"../../layers/MediaLayer.js";import{searchImages as N,getSortedLayerFeatures as W}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as q}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as $,computePolygonForInspection as J,resizePolygon as Z,checkIfPolygonContainsSelectedPoint as K}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as Q,isElevationSource as X}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{convertGeographicToWebMercator as Y}from"../../layers/orientedImagery/core/utils.js";import{imageToWorld as ee,imageToWorldPanoramic as te}from"../../layers/orientedImagery/transformations/imageToWorld.js";import ae from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as ie}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as re,getInitialAngle as se,convertPixelToHeadingPitch as oe,convertHeadingPitchToSphereVertex as ne,getImageToWorldProperties as ce,getUpdateElevationProps as le,isElevationSampler as ue,getImageToWorldPanoramicProperties as he,pointToArray as me,transformGraphicCoordinatesToPixel as de,getWorldToImageProperties as pe}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as ge,worldToImagePanoramic as ye}from"../../layers/orientedImagery/transformations/worldToImage.js";import ve from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as fe}from"../../layers/support/floorFilterUtils.js";import we from"../../layers/support/VideoElement.js";import Fe from"../../symbols/SimpleLineSymbol.js";import be from"../../views/MapView.js";import Me from"../../views/draw/Draw.js";import{scale as _e}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as Pe}from"../../views/input/InputManager.js";import Ie from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as ke,videoExtent as Se,invalidCameraHeading as Ve,sectorsInOrder as Ae,sectorsRadii as Ce,sampleExtent as Ge}from"./constants.js";import{configureSketchTool as Le,extractFieldsFromDataCaptureLayer as Re,isValidDataCaptureLayer as Oe,constructGraphicFromImageGeometry as Te}from"./dataCaptureUtils.js";import{isFeatureAttachment as je,getImageSourceFromAttachment as Be}from"./galleryUtils.js";import{formatPixels as xe,heightMeasurementPanoramic as Ee,heightMeasurement2D as ze,calculateHeightAccuracyPanoramic as He,calculateHeightAccuracy as De,pixelAreaMeasurement2D as Ue,pixelAreaMeasurementPanoramic as Ne,pixelDistanceMeasurement2D as We,pixelDistanceMeasurementPanoramic as qe,generateCombinations as $e,getRootOfSumOfSquaredErrors as Je,generateCombinationsPanoramic as Ze,calculateLocationAccuracyFromDeviations as Ke,calculateReferenceImagePointPanoramic as Qe,calculateAnglePano as Xe,calculateTempImagePoint as Ye,calculateAngle as et,computeTriangulatedAreaMeasurement as tt,computeTriangulatedDistanceMeasurement as at,getModeCorrectedPoint as it,calculateCorrectedPixel as rt,calculateHeightFromTemporaryDistance as st,computeTriangulatedVector as ot,computeTriangulatedPoint as nt}from"./imageMeasurementUtils.js";import{crossSymbol as ct,crossSymbol3D as lt,measurementPolygonSymbol as ut,polylineSymbolPanoramic as ht,measurementPolylineSymbol as mt,sourcePointSymbol as dt,diamondSymbol as pt,diamondSymbol3D as gt,locationSymbol as yt,locationSymbol3D as vt,activeSourcePointSymbol as ft}from"./symbols.js";import{isNoAttachmentError as wt,getContentType as Ft,isTifOrMrf as bt,filterOILLayerView as Mt,assignElevationSampleToFeatures as _t,calculateDirection as Pt,calculateSegment as It,isSceneView as kt,isGraphic as St}from"./utils.js";import Vt from"./components/ImageViewer.js";import At from"./components/NavigationNode.js";import Ct from"./components/OrientedImageryVideoViewModel.js";import{NoActiveViewerError as Gt,NoFeatureFoundWithObjectIdError as Lt}from"./navigation/errors.js";import{queryFeatureByObjectIds as Rt}from"./navigation/queries.js";import Ot from"../Sketch/SketchViewModel.js";const Tt={click:"view-click",imageClick:"image-click",triangularImageClick:"triangular-click",interactionHandles:"interaction-handles",hittestHandles:"hittest-handles"},jt=new Set(["JPG","JPEG"]),Bt=/\.(\w+)$/,xt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let Et=class extends(c.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.allLayerFeatures=[],this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=ke,this.cameraPitchThreshold=ke,this.videoViewModel=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadImage(a)}catch(o){y(o)||(this.loadImageError(o),h.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,a)=>{if(this.view?.closePopup(),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(a)}catch(i){y(i)||(this.loadImageError(i),h.getLogger(this).error("#loadIImage()","error occured while loading image",i))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.imageMeasurementViewer=new Vt,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.measurementVectors=[],this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.preserveAngle=!1,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t)=>{"default"===this.mode&&"image-loaded"!==this.state||"video"===this.mode&&!this.videoElement?.content||await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new be({map:new Map}),this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new Vt,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._correctedLocationPointOnImage=null,this._overlays=new D({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new Ie,this._previousCursor=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._featureToSector=null,this._updatingHandles=new G,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:a}=await t;return v(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const a=this.additionalFeatures.find((({attributes:t})=>t.objectId===e));if(a)this.currentBestFeature=a;else{const{layer:a,layerFloorFilterClause:r}=this;if(!a)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const s=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(a,e,r,t));try{await s,await this.selectBestFeature(e,t)}catch(i){y(i)||(h.getLogger(this).error("oriented-imagery-viewer:show-image",i),"NoFeatureFoundWithObjectIdError"===i.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",i.message))}}},this.getSectorFeatureById=e=>this._suitabilities?.find((({feature:{attributes:{objectId:t}}})=>t===e)),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{activeViewer:a}=this;if(!a)throw new Gt;return await a.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(v(t),this.currentBestFeature=this.features?.find((({attributes:t})=>`${t.objectId}`==`${e}`)),F((()=>"image-loaded"===this.state),t)),this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=r((async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,c=new t({geometry:n,attributes:o.toJSON(),layer:r});v(e),await s.openPopup({features:[c],location:o.location.clone()})}))},this.updateSuitabilities=(e,t=!0)=>{e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const a=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(a,t),this._groupFeaturesBySectors()},this._createViewClickHandle=()=>{if(this.removeHandles(Tt.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,Pe.WIDGET),Tt.click)},this._createImageClickHandle=()=>{this.removeHandles(Tt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;const n=a.clickAction;a.clickAction="pixel-location";const c=l((()=>{a.clickAction=n}));let u=null;const h=b((()=>a),"pixel-location",(e=>{this.plotReferencePointOnImage(e),u?.abort(),u=r((async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return re(!t,e.spatialReference.equals(t))?e:x(e,t)}));v(a),this.plotReferencePointOnGround(r)}))}));this.addHandles([h,c],Tt.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(Tt.triangularImageClick);const e=this.imageMeasurementViewer?.imageSize;this.triangularMeasurementActive&&"none"!==this.mode&&e&&this.currentBestFeature&&this.addHandles(this.imageMeasurementViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),Tt.triangularImageClick)},this._createTriangularImageLocationHandle=()=>{this.removeHandles(Tt.triangularImageClick);const{imageLocationToolState:e,mode:t,imageMeasurementViewer:a}=this,i=a?.imageSize;if(!e||"none"===t||!i)return;a.clickAction="pixel-location";let s=null;const o=b((()=>a),"pixel-location",(e=>{1===this.measurementVectors.length&&(this.plotLocationPointOnImage(e,!0),s?.abort(),s=r((async a=>{if(!e||this.triangulatedPoint||2===this.measurementVectors?.length||!this.currentBestFeatureMeasurementImage)return;let r=await this.getMapPoint(e,{feature:this.currentBestFeatureMeasurementImage,imageSize:i,mode:t});v(a);const s=this.currentBestFeatureMeasurementImage.geometry.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),v(a)),await this._calculateTriangulatedPointFromGroundPoint(r,{signal:a}),v(a)})))}));this.addHandles(o,Tt.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(Tt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;a.clickAction="pixel-location";let n=null;const c=b((()=>a),"pixel-location",(e=>{this.pixelCoordinates=e,this.plotLocationPointOnImage(e),n?.abort(),n=r((async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});v(a);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),v(a)),this.groundCoordinates=r,this.triangularMeasurementActive&&r&&this._triangulatedLocationWorkflow(r);const n=await this.calculateLocationAccuracy(e,r,t,a);v(a),n&&(this.groundCoordinatesAccuracy=n)}))}));this.addHandles(c,Tt.imageClick)},this._handleImageHitTestResponse=async e=>{const{layer:t}=this;if(!t)return;const a=e.results.find((({graphic:{attributes:e}})=>e&&!e[`${t.imageReferenceField}`]&&!e[`${t.imageGeometryField}`]));if(!a)return;const i=a.graphic.attributes[t.objectIdField];await this.showImageByObjectId(i)},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i||"video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:u,cameraOrientation:m,location:d}=r,p=(c??0)+(o??0),g=d.spatialReference.isWGS84&&4!==m?.type?H(d):new T(d);let f=s;if(je(s))try{f=await Be(a,u,e)}catch(w){if(y(w))return;return wt(w)?(h.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${u}`)):(h.getLogger(this).error(w,{[a.objectIdField]:u,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${u}`))}try{await this.loadImageFromSource(f,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:c}=new URL(o);let l=s?n.match(Bt)?.[1]:e.datasetFormat;if(!l)try{l=await Ft(o,{...t.options})}catch(u){y(u)||h.getLogger(this).error("#getContentType()",u)}switch(l??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,l,o,c,i,r):await this._setImageSource(this._imageViewer,l,o,c,i,r);break;case"panoramic":if(jt.has(l.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let c=i??0;"number"==typeof n?c=n-c:s&&e&&(c=await se(s,e)-c),this._panoramicViewer.pitch=a??0,this._panoramicViewer.yaw=c,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:l});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:i}=this;if(this.imageMeasurementViewer.clearGraphics(),!a||!t||"none"===i||"video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:u,cameraOrientation:m,location:d}=r,p=(c??0)+(o??0),g=d.spatialReference.isWGS84&&4!==m?.type?H(d):new T(d);let f=s;if(je(s))try{f=await Be(a,u,e)}catch(w){if(y(w))return;return wt(w)?(h.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${u}`)):(h.getLogger(this).error(w,{[a.objectIdField]:u,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${u}`))}try{await this.loadImageFromSource(f,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");v(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");v(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:i,triangulatedMeasurementGraphic:r}=this;t&&a&&i&&r&&"active"!==t.state&&(t.update([r],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r((async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,a)=>{if(await f(a),!e)return;const i=new T({...C(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:ct}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._crossSymbol=new t({geometry:new T(n,E.WebMercator),symbol:lt}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([M((()=>this.view),(()=>{this.load()}),_),M((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),P),M((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),M((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),M((()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage]),(()=>{this._createTriangularImageClickHandle()}),_),M((()=>[this.state,this.imageLocationToolState,this.view]),((e,t)=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();e[1]!==t?.[1]&&this._setMeasurementCursor()}),_),M((()=>this.measureType),(()=>{this.clearPreviousMeasurements()}),_),M((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),M((()=>this.currentBestFeature),(async(e,t)=>{d(this._featureChangedTask),this._featureChangedTask=r((async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}]))),await this._featureChangedTask.promise}),{sync:!0}),M((()=>this.currentBestFeatureMeasurementImage),(async(e,t)=>{d(this._featureChangedTask),t&&e!==t&&(this.measurementVectors=[],this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll()),this._featureChangedTask=r((async a=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:a}),v(a),this._reorderTriangularSketchLayer()}))}),_),M((()=>this.triangularMeasurementActive),(async(e,t)=>{t&&!e&&(this.measurementVectors=[],this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics())})),M((()=>this.mode),(e=>{switch(this.removeHandles(Tt.interactionHandles),e){case"default":this.addHandles(M((()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null}),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>a(e,t,u)}),Tt.interactionHandles);break;case"video":this.addHandles(M((()=>{const{footprintExtent:e}=this;if(e)return Se}),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>a(e,t,u)}),Tt.interactionHandles);break;case"panoramic":this.addHandles(M((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:a,vfov:i,hfov:r,pitch:s,yaw:o}=this._panoramicViewer;return e&&a&&!t.includes("loading")?[i,r,o,s]:null}),(e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;this.currentNode&&(this.currentNode.currentHeading=i+(this.currentNode.heading??0),this.currentNode.currentPitch=s+(this.currentNode.pitch??0)),d(this._updateFootprintTask),this._updateFootprintTask=r((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>a(e,t,u)}),Tt.interactionHandles)}}),_),M((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)}),_),M((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)})),M((()=>this.activeViewer),(e=>{this.removeHandles(Tt.hittestHandles),e&&this.addHandles(b((()=>e),"hittest-response",this._handleImageHitTestResponse),Tt.hittestHandles)}))]),this.when().finally((()=>{this.notifyChange("state")}))}destroy(){this._updateFootprintTask=d(this._updateFootprintTask),this._clickTask=d(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=p(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this._referencePointOnImage=p(this._referencePointOnImage),this._locationPointOnImage=p(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:a}=this;switch(a){case"default":return e;case"panoramic":return t;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every((e=>0===e))??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",m(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",m(e,-10,10))}get currentNode(){const{currentBestFeature:e,navigationNodes:t}=this;return t.find((t=>t.id===e?.attributes.objectId))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return bt(t)||je(t)}get imageLoaded(){return o(h.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===Ve}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(Mt(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?fe(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";if(e.orientedImageryType?.includes("video"))return"video";const{horizontalFieldOfView:t,isSpherical:a}=e;return 360===t||a?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Ae.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",m(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:a},_featureChangedTask:i}=this;if(t)return"disabled";if(!this.isFulfilled()||a||!1===i?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:i}})=>{const r=e?.trim();return bt(r)||je(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new D({elevationInfo:{mode:"absolute-height"}});case"default":return new D;default:return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}beforeLoad(){this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._overlays?.removeAll()}async computeHeight(e,t,a=!0){const{currentBestFeature:i,activeViewer:r,layer:s,footprintExtent:o}=this,n=r?.imageSize,c=i?.attributes,l=s?.orientationAccuracy;if(!c||!n||!e||e.length<2||!l)return;const u="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ce(c,n[0],n[1]),h=e.at(0),m=e.at(-1);if(!(u&&h&&m&&l&&o))return;const d=[m,h],p=xe(d,!1),g="panoramic"===t?await Ee(d,u,l,i,!0,!1):await ze(d,u,l,!0,a);if(!g)return;const y="panoramic"===t?await He(l,p,u,g,i,!0):await De(l,p,u,g,!0);return y?{value:g,accuracy:y}:{value:g}}async calculateAreaMeasurement(e,t,a){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const i="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return v(a),i?"default"===t?await Ue(e,i,!0):await Ne(e,i,!0,a):null}async calculateDistanceMeasurement(e,t,a){const{currentBestFeature:i,activeViewer:r}=this;if(e.length<2||!i||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return v(a),s?"default"===t?await We([e.at(0),e.at(-1)],s,!0):await qe([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s}=this,o=i?.orientationAccuracy,n=o?.every((e=>0===e))||!o?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||n)return null;let c=null;if(this.triangularMeasurementActive&&this.currentBestFeatureMeasurementImage&&this.imageMeasurementViewer?c=await this.getMeasurementProperties(this.currentBestFeatureMeasurementImage,this.imageMeasurementViewer):(c=await this.getMeasurementProperties(),v(a)),!c)return null;const l="area"===t?await Ue(e,c,!0):await We([e.at(0),e.at(-1)],c,!0);v(a);const{updateElevationProps:u,...h}=c,m=$e(h,o);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async i=>{const r="area"===t?await Ue(e,i,!0):await We([e.at(0),e.at(-1)],i,!0);if(v(a),r&&l){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-l.area):null}return Math.abs(r-l)}return null})),p=await Promise.all(d);v(a);const g=p.filter((e=>null!==e));return 0===g.length?null:Je(g)}async calculateLocationAccuracy(e,t,a="default",i){const{layer:r,currentBestFeature:s}=this,o=r?.orientationAccuracy,n=this.view?.spatialReference,c=o?.every((e=>0===e))||!o?.length;if(!s||c)return null;const l="default"===a?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();if(v(i),!l)return null;const{updateElevationProps:u,...h}=l,m="default"===a?$e(h,o):Ze(h,o);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async r=>{const{updateElevationProps:s,...o}=r;let c="default"===a?await ee(e,o,s):await te(e,o,s);return v(i),n&&!c.spatialReference.equals(n)&&(c=await x(c,n),v(i)),c&&t?[Math.abs(c.x-t.x),Math.abs(c.y-t.y),c.z&&t.z?Math.abs(c.z-t.z):0]:null})),p=await Promise.all(d);if(v(i),!p?.length)return null;const g=p.map((e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0])),[y,f,w]=Ke(g);return{x:y,y:f,z:w}}async calculateAccuracyPanoramic(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s,mode:o}=this,n=i?.orientationAccuracy,c=n?.every((e=>0===e))||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||c||"panoramic"!==o)return null;const l=await this.getMeasurementPropertiesPanoramic();if(v(a),!l)return null;const u="area"===t?await Ne(e,l,!0):await qe([e.at(0),e.at(-1)],l,!0);v(a);const{updateElevationProps:h,...m}=l,d=Ze(m,n);if(!d?.length)return null;const p=d.map((e=>({...e,updateElevationProps:h}))).map((async i=>{const r="area"===t?await Ne(e,i,!0):await qe([e.at(0),e.at(-1)],i,!0);if(v(a),r&&u){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-u.area):null}return Math.abs(r-u)}return null})),g=await Promise.all(p);v(a);const y=g.filter((e=>null!==e));return 0===y.length?null:Je(y)}async calculateHeightMeasurementInfo(e,t,a){const{currentBestFeature:i,activeViewer:r}=this,s=r?.imageSize;if(!i||!r||!s?.length||"none"===t)return;const{attributes:o}=i,[n]=xe([e],"panoramic"!==t),c="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ce(o,s[0],s[1]);if("panoramic"===t){if(!c)return;const e=await Qe(n,c,i,a);if(!e)return;e?.heading>180&&(e.heading-=360);const t=Xe(n,e),r=A([n.x,n.y],[e.x,e.y]);if(!t||!r)return;return{measurementAngle:t,tempDistance:r}}const l=await Ye(n,c,a);if(!l)return;const u=et(n,l),h=A([n.x,n.y],[l.x,l.y]);return u&&h?{measurementAngle:u,tempDistance:h}:void 0}async calculateTriangulatedMeasurements(e){switch(this.measureType){case"distance":{this.triangulatedDistanceMeasurement=await at(this.measurementVectors);const t=await this.calculateAccuracy(e,"distance");if(t&&this.triangulatedDistanceMeasurement?.distance){const e=Math.atan(t/this.triangulatedDistanceMeasurement.distance);this.triangulatedDistanceAccuracy={distanceAccuracy:t,angleAccuracy:e}}break}case"area":if(this.currentBestFeatureMeasurementImage?.geometry.spatialReference){const t=await tt(this.measurementVectors,this.currentBestFeatureMeasurementImage.geometry.spatialReference);this.triangulatedAreaMeasurement=t,this.triangulatedAreaAccuracy=await this.calculateAccuracy(e,"area")??this.triangulatedAreaAccuracy}}}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:a,dataCaptureLayer:i}=this;if(!a)throw xt();Le(i,e,a),await a.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw xt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw xt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw xt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw xt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw xt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw xt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t,a=!1){const i=[],r=[],s=[];return e.forEach((e=>{const{layer:{coveragePercent:o},attributes:n}=e;let c;const l=k(e.geometry.spatialReference);n.cameraHeight/=l,n.farDistance/=l,n.nearDistance/=l,Q(n.elevationSource)&&(n.elevationSource.constantElevation/=l);const{polygon:u,frustum:h}=$(n);if(c=u.clone(),n.isInspection&&(c=J(n)),o&&(c=Z(c,o)),a||!t||K(c,t)){s.push(e);const{geometry:t,objectId:a,cameraHeight:o,cameraHeading:c}=n,l=t.clone();l.z=o,l.imageID=a,this.pointSources.push(l),c!==Ve&&(i.push(u),h&&r.push(h))}})),{features:s,polygons:i,frustums:r}}getMeasurementProperties(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ce(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,E.WebMercator):Promise.resolve(n)).then((e=>(n=e,le((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ue(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=he(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,E.WebMercator):Promise.resolve(n)).then((e=>(n=e,le((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ue(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimagery","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then((({features:e})=>t.applyEdits({deleteFeatures:e})))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[Ae[e]],a=t?.at(0);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t],r=i?.at(a);r&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(r):this._updateCurrentBestFeature(r))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s}=this,o=s?.imageSize;if(!e.vertices||!o)return;const n=it(e.vertices.at(-1),r,o);if(i.length<1||!n||!a||!t||"none"===r)return;const c=rt(i[0],n,t);if(!c?.length)return;this.heightMeasurementPixels.push(c),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const l=st(this.heightMeasurementPixels,a);l&&(this.heightMeasurementResult=l)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=it(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.selectedPoint=Y(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}loadImageError(e){h.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:a}=await t;v(e),this.sketch=new a({layer:this._sketchGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:a}=await t;if(v(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async loadTriangulatedMeasurementAdapter(e){if(!this.triangulatedMeasurementAdapter){const t=import("./adapters/sketch/TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(v(e),this.triangulatedMeasurementAdapter=new a({viewModel:this}),!this.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.triangulatedMeasurementAdapter}async processFeatureResponse(e,t,a){const{features:i}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(i))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t,a?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,a);v(a),await this._updateElevationOfSelectedPointAndLocations(r,t,n),v(a),_t(r,n);const c=this._processSuitableFeatures(r,t);this.updateSuitabilities(c,a?.loadBestImage)}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=ut(o),this.sketch.polylineSymbol="panoramic"===s?ht:mt(o,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new Me({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],(e=>this.handleDrawEvents(e)))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new B({paths:[e],spatialReference:a});else{const i=new B({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:mt(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=oe(i,a[0],a[1]),{heading:n,pitch:c}=oe(r,a[0],a[1]),l=[[...ne(s,o)],[...ne(n,c)]];if(this.heightGraphic)this.heightGraphic.geometry=new B({paths:[l],spatialReference:e});else{const a=new B({paths:[l],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:ht}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async editOverlayedGraphics(e){this.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.sketchTriangularGraphicsLayer.add(e),this.sketchTriangular||(this._initializeSketchTriangular(),await this.loadTriangulatedMeasurementAdapter()),this.updateOverlayedGeometry(e)}updateOverlayedGeometry(e){this.sketchTriangular?.update([e],{tool:"reshape"})}async processMeasurementVectors(e){this.triangularMeasurementActive&&this.currentBestFeature&&(this.measurementVectors?.length<2&&await this.updateMeasurementVectorsArray(e),2===this.measurementVectors.length&&await this.calculateTriangulatedMeasurements(e))}async updateMeasurementVectorsArray(e){const t=this.measurementVectors.length?this.currentBestFeatureMeasurementImage:this.currentBestFeature;if(t){const a=await this.computeMeasurementVector(e,t);a&&this.measurementVectors.push(a)}}async computeMeasurementVector(e,t){const{activeViewer:a,mode:i}=this,r=a?.imageSize;if(!e||!t||!r)return;const s=e.map((e=>[e[0]-.5,-.5-e[1]])),o=this.view?.spatialReference,n=[];for(let c=0;c<s.length;c++){const e={x:s[c][0],y:s[c][1]};let a=await this.getMapPoint(e,{feature:t,imageSize:r,mode:i});o&&!a.spatialReference.equals(o)&&(a=await x(a,o)),n.push(a)}return ot(n,t)}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n,layerFloorFilterClause:c}=this,l=a?.imageSize;if(!l||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:u}=$(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:I(`${s.objectIdField} <> ${i.attributes.objectId}`,I(s.definitionExpression,c)),geometry:u,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:l,mode:o}),n=dt.clone();return n.outline=new Fe({color:[0,0,0],width:1}),new t({attributes:a,symbol:n,geometry:s})})));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:c,layer:l}=this,u=r?.imageSize;if(!u||!o||"none"===n||"video"===n||c.includes("loading")||!l)return;const{polygon:m}=$(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Re(e,l.imageGeometryField,l.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:d}=await e.queryFeatures({geometry:m,returnGeometry:!0,outFields:["*"]}),p=new s((await Promise.all(d.map((async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:c}=i,l=c,{imageGeometryField:m,oiObjectIdField:d}=this;if(m&&d&&Oe(e,m,d)&&`${s[d]}`==`${o.attributes.objectId}`)try{return Te(s,m,e,a,u,n,r)}catch(g){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(l?.type){case"point":{const i=await this.getPixels(l,{feature:o,imageSize:u,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:c}=l,h=i.map((e=>e.map((([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))))),m=await Promise.all(h.map((async e=>this.getPixels(e,{feature:o,imageSize:u,mode:n}).then((e=>e.map(me))))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({rings:m,spatialReference:E.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:c}=l,h=i.map((e=>e.map((([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))))),m=await Promise.all(h.map((async e=>this.getPixels(e,{feature:o,imageSize:u,mode:n}).then((e=>e.map(me))))));return new t({attributes:s,layer:e,symbol:r,geometry:new B({paths:m,spatialReference:E.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:c}=l,h=i.map((([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))),m=await this.getPixels(h,{feature:o,imageSize:u,mode:n}).then((e=>e.map(me)));return new t({attributes:s,layer:e,symbol:r,geometry:new O({points:m,spatialReference:E.WebMercator}),visible:e.visible&&a})}}return null})))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,p)}async getPixels(e,t){const{imageSize:a,mode:i}=t,r=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===i)return new T({x:e.x-.5,y:.5-e.y,spatialReference:E.WebMercator});const[t,r]=a,{heading:s,pitch:o}=oe(e,t,r),n=ne(s,o);return new T(n,E.WebMercator)}));return Array.isArray(e)?r:r[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:c,elevation:l,cameraHeight:u}=o;let h=c.clone();h.spatialReference.isGeographic&&(h=await x(h,E.WebMercator));const m=await le(l??(c.z??0)-u,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;if("elevationSample"in m&&ue(m.elevationSample)&&(a.elevationSample=m.elevationSample),"default"===i){const t=ce(o,r[0],r[1]);d=await ee(Array.isArray(e)?e:[e],{...t,cameraLocation:h},m)}else{const t=he(o,r[0],r[1]);d=await te(Array.isArray(e)?e:[e],{...t,cameraLocation:h},m)}return Array.isArray(e)?d:d[0]}getActiveSectors(){return Ae.filter((e=>this._sectorData?.[e]?.length))}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new T({...e.toJSON()}),symbol:pt}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=C(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new T({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:pt}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new T(n,E.WebMercator),symbol:gt}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e,t=!1){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(t),this.mode){case"default":this._plotLocationPointOnDefaultImage(e,t);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=d(this._clickTask)}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.measurementVectors=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce(((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:c}=n;return r?t.error.push(n):(a&&(c[e.objectIdField]=a),i&&e.globalIdField&&(c[e.globalIdField]=i),t.success.push(n)),t}),{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s||"video"===s)throw new n("orientedimagery","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimagery","Data capture layer is not available");const c=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,c=r.hasZ,l=r.geometryType,u=n!==l,h=u?await import("./transformers.js"):null,m=h?.default[l],d=u?m?.(i):i;if(d)switch(d.type){case"point":return t.geometry=await this.getMapPoint(de(s,d,o),{feature:a,imageSize:o,mode:s}),c||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(d.rings.map((async e=>this.getMapPoint(e.map((([e,t,a])=>de(s,{x:e,y:t,z:a},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new j({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,rings:e.map((e=>e.map(me)))}),t}case"polyline":{const e=await Promise.all(d.paths.map((async e=>this.getMapPoint(e.map((([e,t,a])=>de(s,{x:e,y:t,z:a},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new B({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,paths:e.map((e=>e.map(me)))}),t}}}))),l=c.filter(i);return r.applyEdits({addFeatures:l}).then((e=>{const{addFeatureResults:t}=e;let a=0;const i=c.map((e=>{const i=t[a++];return e?i:{error:new n("orientedimagery","Error in saving data capture features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:i}}))}async searchBestImage(e,t){try{const a=await N(e,t);a&&await this.processFeatureResponse(a,e.point,t)}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),h.getLogger(this).error("error occurred while finding best image",a))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],c=[],l=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?c.push(s):l.push(s);this.overlayGraphicsOnImage(e.id,new s(l)),this.collectionId=e.id;const u=await this.loadSketch(t),h=await this.loadDataCaptureAdapter(t);v(t),u.layer.addMany(c),u.layer.blendMode="source-atop",h.savedGraphics.addMany(c);a.ui.find("zoom").visible=!1,a.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const a=this.overlayedMapFeatures.get(e);a&&this._toggleVisiblity(a,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:a}=e;let i=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);i=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);r=s.extent.contains(e);break}}if(!i&&!r)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,a);if(o)return v(a),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}async _calculateTriangulatedPointFromGroundPoint(e,t){if(this.currentBestFeatureMeasurementImage&&e){const{currentBestFeatureMeasurementImage:a}=this,i=ot(e,a);i&&this.measurementVectors.push(i);const r=await nt(this.measurementVectors);v(t),this.triangulatedPoint=r??this.triangulatedPoint}}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),h.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:a,invalidCameraHeading:i}=this,r=a.at(0);if(!e||!t||!r||!a||i)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const h of Ae)this._sectorData[h]=new s;const n=e.map(((e,t)=>({...e,featureIndex:t})));n.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const c=n.map((({distance:e})=>e)),l=Math.max(...c),u=a.reduce(((e,t)=>Math.max(e,t.attributes.location.z??0)),-1/0);n.forEach((e=>{const{distance:t,angle:i,featureIndex:s}=e,n=t/l*Ce[2],c=It(t,l),h=Pt(i);if(!this._sectorData)return;const m=Ce[3]+n*Math.sin(i*Math.PI/180),d=Ce[3]+n*Math.cos(i*Math.PI/180);let p;const g=a.at(s),y=(g.attributes.location.z??0)/u*Ce[2],v=g===r,{cameraPitch:f}=g.attributes,w=f<5;if(v&&w)p=-90;else{const e=m-Ce[3],t=d-Ce[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),p=i}const F=""===c?h:`${c}_${h}`;v&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=w?null:{x:m,y:d,direction:h}),o[`${g.attributes.objectId}`]=F;const b=this._sectorData[F];b.add({angle:i,featureIndex:s,x:m,y:d,z:y,objectID:g.attributes.objectId,sector:F,featureIndexInSector:b.length})}))}_handleDestroyedTriangularSketchLayer(){this.sketchTriangularGraphicsLayer&&(this.imageMeasurementViewer.imageRenderer.map.layers.remove(this.sketchTriangularGraphicsLayer),this.sketchTriangularGraphicsLayer=new D,this.imageMeasurementViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer),this.sketchTriangular&&(this.sketchTriangular.layer=this.sketchTriangularGraphicsLayer,this.sketchTriangular.view=this.imageMeasurementViewer.imageRenderer))}_initializeSketchTriangular(){this.sketchTriangular=new Ot({view:this.imageMeasurementViewer.imageRenderer,layer:this.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1}})}_initializeSketchTriangularGraphicsLayer(){this.sketchTriangularGraphicsLayer=new D,this.imageMeasurementViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer)}_initializeVideo(){if(this.videoElement)return;this.videoElement=new we({video:this.layer?.imagePathPrefix,georeference:new ve({extent:new L(Ge)})});const e=new U({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.videoViewModel=new Ct({oiViewModel:this})}_plotLocationPointOnDefaultImage(e,a=!1){const i=C(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,a?(this._correctedLocationPointOnImage=new t({geometry:new T({spatialReference:E.WebMercator,...i}),symbol:yt}),this.imageMeasurementViewer.addGraphic(this._correctedLocationPointOnImage,0)):(this._locationPointOnImage=new t({geometry:new T({spatialReference:E.WebMercator,...i}),symbol:yt}),this._imageViewer.addGraphic(this._locationPointOnImage,0))}_plotLocationPointOnPanoramicImage(e){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._locationPointOnImage=new t({geometry:new T(n,E.WebMercator),symbol:vt}),this._panoramicViewer.addGraphic(this._locationPointOnImage,0)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.setMessage("noImageError","error"),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,a){if(!e[0])return;const i=await R(e);if(this._updateFootprintWithFeatures(t,i),this.view?.supportsGround)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(r){y(r)||h.getLogger(this).error(r)}}async processElevationSample(e,t,a){const{elevationSource:i}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,a);return r||(i&&this.footprintExtent&&X(i)?await ie({extent:this.footprintExtent,lod:i.lod,url:i.url,rasterFunction:i.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return q({features:e,selectedPoint:t,camera:kt(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;const{layerFloorFilterClause:n}=this,c=e.spatialReference.equals(o.spatialReference)?o:await x(o,e.spatialReference),l=c.spatialReference.isGeographic?H(c):c,u=I("1=1",I(e.definitionExpression,n)),h=l.spatialReference.isGeographic?1:k(l.spatialReference),m={layerInstanceOrURL:e,point:l,queryParams:{where:u,maximumDistance:e.maximumDistance?e.maximumDistance/h:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(m,a)}async _queryAndLoadByObjectId(e,t,a,i){this.displayMessage=null;const{response:r}=await Rt(e,t,a,i);if(v(i),!r?.features?.length)throw new Lt(t);const s=Y($(r.features[0].attributes).polygon.centroid),o=k(s.spatialReference);this.selectedPoint=s;const n={layerInstanceOrURL:e,point:s,queryParams:{where:I("1=1",I(e.definitionExpression,a)),maximumDistance:e.maximumDistance?e.maximumDistance/o:void 0}};return await this.searchBestImage(n,{...i,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}_resetCursor(){const{activeViewer:e,imageMeasurementViewer:t}=this;e&&(e.imageRenderer.cursor=this._previousCursor),t&&(t.imageRenderer.cursor=this._previousCursor)}async _setImageSource(e,t,a,i,r,s){e.imageSource={datasetFormat:t.toUpperCase(),url:a.split("?")[0]},e.customParameters=Object.fromEntries(i),e.imageRotation=r??0,await e.loadImage(s)}_setMeasurementCursor(){const{activeViewer:e,imageMeasurementViewer:t,triangularMeasurementActive:a}=this;e&&(this._previousCursor=e.imageRenderer.cursor,e.imageRenderer.cursor="crosshair"),t&&a&&(t.imageRenderer.cursor="crosshair")}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_triangulatedLocationWorkflow(e){if(this.currentBestFeature&&e){const{currentBestFeature:t}=this;this.triangulatedPoint&&(this.measurementVectors=[],this.triangulatedPoint=null,this.clearLocationPointOnImage(!0));const a=ot(e,t);if(!a)return;this.measurementVectors.push(a),this.plotReferenceLocationPoint(e),this._createTriangularImageLocationHandle()}}async _updateElevationOfSelectedPointAndLocations(e,t,a,i){const r=ue(a),s=await le((e[0].attributes.location.z??0)-e[0].attributes.cameraHeight,{elevationSample:r?a:void 0,elevationSource:r?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},i);v(i);const[o,...n]=await ae([t,...e.map((e=>e.attributes.geometry.clone()))],s);v(i),t.elevation=o.z,e.forEach(((e,t)=>{e.attributes.elevation=n[t].z}))}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.navigationNodes.removeAll(),this.navigationNodes.addMany(e.map((e=>new At({geometry:e.geometry,attributes:e.attributes})))),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0]),"video"===this.mode&&(this._initializeVideo(),this.videoViewModel?.playVideoFromSelectedLocation(e[0]))}_updateFootprintWithFeatures(e,t){const a=[];for(const{geometry:i}of e)t.contains(i)||a.push([i.x,i.y]);a.sort(((e,t)=>+z([e,t]))),t.addRing(a),this.footprintExtent=_e(t.extent,2,2)}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),v(e);for(const e of a)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:ft,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:dt,visible:s}));if("video"===o&&n&&!this.allLayerFeatures.length){const e=await W(n,i.geometry.spatialReference);e.features?.length&&(this.allLayerFeatures=e.features)}}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(t)a=-90;else{const t=e.x-Ce[3],i=e.y-Ce[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage))}clearLocationPointOnImage(e=!1){this._locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=p(this._locationPointOnImage)),this._correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this._correctedLocationPointOnImage),this._correctedLocationPointOnImage=p(this._correctedLocationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}plotReferenceLocationPoint(e){if(this.currentBestFeatureMeasurementImage){const t=this.imageMeasurementViewer.imageSize[0],a=this.imageMeasurementViewer.imageSize[1],i=pe(this.currentBestFeatureMeasurementImage.attributes,t,a),r=ge(e,i);this.plotLocationPointOnImage(r,!0)}}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,e),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||h.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t){const{footprintExtent:a}=this,{imageSize:i}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!i||!a)return;const{attributes:{location:r,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:c},elevationSample:l}=this.currentBestFeature;let u=r.clone();const h=await le(n??(r.z??0)-c,{elevationSample:l,elevationSource:s});this.currentBestFeature.elevationSample=h.elevationSample;const m=Array.isArray(e)?e:[e];let d,p=await Promise.all(m.map((e=>new Promise((t=>{if(!e.hasZ)return t(ae(e,h));t(e)})))));if(r.spatialReference.isGeographic&&(u=await x(u,E.WebMercator,t)),p=await Promise.all(p.map((async e=>u.spatialReference.equals(e.spatialReference)?e:await x(e,u.spatialReference,t)))),v(t),"panoramic"===this.mode)d=ye(p,{imageHeight:i[1],imageWidth:i[0],cameraHeading:o,cameraLocation:u});else{const e=pe(this.currentBestFeature.attributes,i[0],i[1]);d=ge(p,{...e,cameraLocation:u})}return Array.isArray(e)?d:d[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:c,_adapter:l,mode:u}=this,{attributes:{objectId:h},elevationSample:m}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),c){const e=[...a,...i,s].filter(St);c.supportsGround&&m&&l?.updateGroundElevation&&(this._updateGroundElevation&&l.updateGroundElevation(e,m),"panoramic"===u&&l.updateGroundElevation([this.bestFeatureCurrentFootprint],m)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:ct.clone(),attributes:{imageID:h}}))),this._overlays.graphics.addMany(e)}}else if(c){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,c?.supportsGround&&m&&l?.updateGroundElevation&&"panoramic"===u&&l.updateGroundElevation([e],m),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],Et.prototype,"activeLayer",null),e([S({readOnly:!0})],Et.prototype,"activeViewer",null),e([S()],Et.prototype,"accuracyParametersMissing",null),e([S()],Et.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],Et.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],Et.prototype,"additionalFootprints",void 0),e([S()],Et.prototype,"areaMeasurementResult",void 0),e([S()],Et.prototype,"areaMeasurementAccuracy",void 0),e([S()],Et.prototype,"allLayerFeatures",void 0),e([S()],Et.prototype,"bestFeatureAngle",void 0),e([S()],Et.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],Et.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],Et.prototype,"brightness",null),e([S()],Et.prototype,"cameraHeadingThreshold",void 0),e([S()],Et.prototype,"cameraPitchThreshold",void 0),e([S()],Et.prototype,"videoViewModel",void 0),e([S()],Et.prototype,"collectionId",void 0),e([S({type:Number})],Et.prototype,"contrast",null),e([S()],Et.prototype,"conversionProps",void 0),e([S()],Et.prototype,"coverageFrustums",void 0),e([S()],Et.prototype,"coveragePolygons",void 0),e([S()],Et.prototype,"currentBestFeature",void 0),e([S()],Et.prototype,"currentBestFeatureMeasurementImage",void 0),e([S()],Et.prototype,"currentBestFeatureLocation",void 0),e([S()],Et.prototype,"currentCoverageVisible",void 0),e([S()],Et.prototype,"currentNode",null),e([S()],Et.prototype,"navigationNodes",void 0),e([S({json:{write:!1}})],Et.prototype,"determineWorkflowForFeature",void 0),e([S({json:{write:!1}})],Et.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([S()],Et.prototype,"disabled",void 0),e([S()],Et.prototype,"displayMessage",void 0),e([S()],Et.prototype,"displayNewMeasurementButton",void 0),e([S()],Et.prototype,"distanceMeasurementResult",void 0),e([S()],Et.prototype,"distanceAccuracyArray",void 0),e([S()],Et.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],Et.prototype,"featureCount",null),e([S()],Et.prototype,"features",void 0),e([S()],Et.prototype,"groundCoordinates",void 0),e([S()],Et.prototype,"groundCoordinatesAccuracy",void 0),e([S()],Et.prototype,"heightMeasurementPixels",void 0),e([S()],Et.prototype,"heightGraphic",void 0),e([S()],Et.prototype,"heightMeasurementResult",void 0),e([S()],Et.prototype,"heightMeasurementAccuracy",void 0),e([S()],Et.prototype,"measurementAngle",void 0),e([S()],Et.prototype,"tempDistance",void 0),e([S({readOnly:!0})],Et.prototype,"imageGalleryEnabled",null),e([S()],Et.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],Et.prototype,"imageLoaded",null),e([S()],Et.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],Et.prototype,"invalidCameraHeading",null),e([S()],Et.prototype,"imagePointsInView",null),e([S()],Et.prototype,"imageMeasurementViewer",void 0),e([S()],Et.prototype,"isAdditionalCoverageVisible",void 0),e([S()],Et.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],Et.prototype,"measurementVectors",void 0),e([S()],Et.prototype,"layer",void 0),e([S()],Et.prototype,"layerView",null),e([S({readOnly:!0})],Et.prototype,"layerFloorFilterClause",null),e([S({type:Number})],Et.prototype,"localPort",void 0),e([S()],Et.prototype,"mapImageConversionToolState",void 0),e([S()],Et.prototype,"measureType",void 0),e([S()],Et.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],Et.prototype,"mode",null),e([S()],Et.prototype,"navigationMode",void 0),e([S()],Et.prototype,"navigatorCurrentBestFeature",void 0),e([S()],Et.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],Et.prototype,"overlayedCameraLocations",void 0),e([S()],Et.prototype,"overlayedMapFeatures",void 0),e([S()],Et.prototype,"pixelCoordinates",void 0),e([S()],Et.prototype,"preserveAngle",void 0),e([S()],Et.prototype,"pointSources",void 0),e([S({readOnly:!0})],Et.prototype,"popupEnabled",null),e([S()],Et.prototype,"previousFeatureAngle",void 0),e([S()],Et.prototype,"referencePoint",null),e([S({readOnly:!0})],Et.prototype,"sectorData",null),e([S()],Et.prototype,"selectedPoint",void 0),e([S({type:Number})],Et.prototype,"sharpness",null),e([S()],Et.prototype,"shouldShowSelectedImage",void 0),e([S()],Et.prototype,"sketch",void 0),e([S()],Et.prototype,"sketchTriangular",void 0),e([S()],Et.prototype,"sketchTriangularGraphicsLayer",void 0),e([S()],Et.prototype,"draw",void 0),e([S()],Et.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],Et.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],Et.prototype,"state",null),e([S({readOnly:!0})],Et.prototype,"thumbnails",null),e([S()],Et.prototype,"triangularMeasurementActive",void 0),e([S()],Et.prototype,"triangulatedDistanceMeasurement",void 0),e([S()],Et.prototype,"triangulatedDistanceAccuracy",void 0),e([S()],Et.prototype,"triangulatedAreaMeasurement",void 0),e([S()],Et.prototype,"triangulatedAreaAccuracy",void 0),e([S()],Et.prototype,"triangulatedMeasurementGraphic",void 0),e([S()],Et.prototype,"triangulatedPoint",void 0),e([S()],Et.prototype,"triangulatedMeasurementAdapter",void 0),e([S()],Et.prototype,"updateFootprint",void 0),e([S()],Et.prototype,"updateFootprintPanorama",void 0),e([S()],Et.prototype,"updatingTriangularMeasurementState",void 0),e([S({value:null})],Et.prototype,"view",null),e([S()],Et.prototype,"videoElement",void 0),e([S()],Et.prototype,"videoLayer",void 0),e([S()],Et.prototype,"videoMapView",void 0),e([S()],Et.prototype,"_adapter",void 0),e([S()],Et.prototype,"_sketchGraphicsLayer",null),e([S()],Et.prototype,"_highlightedFeatureHandle",void 0),e([S()],Et.prototype,"_imageViewer",void 0),e([S()],Et.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],Et.prototype,"_locationPointOnImage",void 0),e([S()],Et.prototype,"_correctedLocationPointOnImage",void 0),e([S()],Et.prototype,"_overlays",void 0),e([S({readOnly:!0})],Et.prototype,"_overlaysView",null),e([S()],Et.prototype,"_panoramicViewer",void 0),e([S()],Et.prototype,"_previousCursor",void 0),e([S()],Et.prototype,"_referencePointOnGround",void 0),e([S()],Et.prototype,"_referencePointOnImage",void 0),e([S()],Et.prototype,"_sectorData",void 0),e([S()],Et.prototype,"_featureToSector",void 0),e([S({readOnly:!0})],Et.prototype,"_updatingHandles",void 0),e([S()],Et.prototype,"footprintExtent",void 0),e([S()],Et.prototype,"_featureChangedTask",void 0),Et=e([V("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],Et);const zt=Et;export{zt as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../Graphic.js";import{createTask as a}from"../../../../core/asyncUtils.js";import s from"../../../../core/Promise.js";import{throwIfAborted as i}from"../../../../core/promiseUtils.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 o}from"../../../../core/accessorSupport/decorators/subclass.js";import n from"../../../../geometry/Polygon.js";import c from"../../../../geometry/Polyline.js";import{load as l}from"../../../../geometry/
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../Graphic.js";import{createTask as a}from"../../../../core/asyncUtils.js";import s from"../../../../core/Promise.js";import{throwIfAborted as i}from"../../../../core/promiseUtils.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 o}from"../../../../core/accessorSupport/decorators/subclass.js";import n from"../../../../geometry/Polygon.js";import c from"../../../../geometry/Polyline.js";import{load as l}from"../../../../geometry/projectionUtils.js";import m from"../../../../geometry/SpatialReference.js";import{imageToWorld as u}from"../../../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as h}from"../../../../layers/orientedImagery/transformations/utils.js";import{worldToImage as d}from"../../../../layers/orientedImagery/transformations/worldToImage.js";import{formatPixels as p}from"../../imageMeasurementUtils.js";import{SketchHandlerMixin as y}from"../../mixins/SketchHandlerMixin.js";let M=[],g=[],w=0,v=class extends(y(s)){constructor(e){super(e),this.type="measurement",this.measurementArray=[],this.pixelMeasurement=0,this.pixelAreaMeasurement=0,this.polygonVertices=[],this._calculationTask=null,this._distanceCalculation=0,this._areaCalculation=null}initialize(){this.addResolvingPromise(l())}async handleCreate(e){const t=e.toolEventInfo;switch(e.tool){case"polyline":this.handlePolylineEvents(e,t);break;case"polygon":this.handlePolygonEvents(e,t)}}handleDelete(e){this.resetDistanceMeasurements(),this.resetAreaMeasurements()}handleDestroy(){this.resetDistanceMeasurements(),this.resetAreaMeasurements()}cursorUpdatePolylineHandler(e){const{mode:t,activeViewer:a}=this.viewModel;if("none"===t||!a?.imageSize)return;if("default"===t)this.measurementArray.push(e.coordinates);else{const t={x:e.coordinates[0],y:e.coordinates[1],z:e.coordinates[2]},s=h(t,a.imageSize[0],a.imageSize[1]);this.measurementArray.push([s.x,s.y])}const s=g.reduce(((e,t)=>e+t),0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=s}async cursorUpdatePolygonHandler(e){const{mode:t,activeViewer:a}=this.viewModel;if("none"===t||!a?.imageSize)return;const s=e.coordinates;if(M=[...this.polygonVertices],"default"===t)M.push(s);else{const e={x:s[0],y:s[1],z:s[2]},t=h(e,a?.imageSize[0],a?.imageSize[1]);M.push([t.x,t.y])}if(M.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const i=M[0];M=M.filter(((e,t)=>0===t||t===M.length-1||JSON.stringify(e)!==JSON.stringify(i)));const r=await this._getAreaFromTask(M);r?.area&&r?.perimeter&&(w=r.area)}async handlePolylineEvents(e,t){const a=!this.viewModel.accuracyParametersMissing;if("cancel"===e.state)return this.resetDistanceMeasurements(),this.viewModel.distanceMeasurementResult=0,this.viewModel.distanceAccuracyArray=[],void(this.viewModel.displayNewMeasurementButton=!0);if("complete"===e.state&&e.graphic){if(this.viewModel.activeViewer?.addGraphic(e.graphic),this.viewModel.triangularMeasurementActive){const t=e.graphic.geometry;await this.viewModel.processMeasurementVectors(t.paths[0]),await this._overlayFirstMeasurement(e.graphic,e.tool)}return this.viewModel.measurementGraphic=e.graphic,void this.resetDistanceMeasurements()}switch(t?.type){case"cursor-update":this.cursorUpdatePolylineHandler(t);break;case"vertex-add":if(this.measurementArray.length&&a){const e=await this._getAccuracyFromTask();e&&this.viewModel.distanceAccuracyArray.push(e)}this.vertexUpdatePolylineHandler()}const s=await this._getDistanceFromTask();this.pixelMeasurement=s??this.pixelMeasurement}async handlePolygonEvents(e,t){const a=!this.viewModel.accuracyParametersMissing;if("cancel"===e.state)return this.resetAreaMeasurements(),this.viewModel.areaMeasurementResult=0,this.viewModel.areaMeasurementAccuracy=0,void(this.viewModel.displayNewMeasurementButton=!0);if("complete"===e.state&&e.graphic){if(this.viewModel.activeViewer?.addGraphic(e.graphic),a){const e=await this._getAreaAccuracyFromTask(this.polygonVertices);this.viewModel.areaMeasurementAccuracy=e&&e>this.viewModel.areaMeasurementAccuracy?e:this.viewModel.areaMeasurementAccuracy}if(this.viewModel.triangularMeasurementActive){const t=e.graphic.geometry;await this.viewModel.processMeasurementVectors(t.rings[0]),await this._overlayFirstMeasurement(e.graphic,e.tool)}return this.viewModel.measurementGraphic=e.graphic,void this.resetAreaMeasurements()}switch(t?.type){case"vertex-add":await this.vertexAddPolygonHandler(t);break;case"cursor-update":await this.cursorUpdatePolygonHandler(t)}this.viewModel.areaMeasurementResult=w>0?w:this.pixelAreaMeasurement}async vertexAddPolygonHandler(e){const{mode:t,activeViewer:a}=this.viewModel,s=e.added,i=s[s.length-1];if(!Array.isArray(i)||"none"===t||!a?.imageSize)return;if("default"===t)this.polygonVertices.push(i);else{const e={x:i[0],y:i[1],z:i[2]},t=h(e,a?.imageSize[0],a?.imageSize[1]);this.polygonVertices.push([t.x,t.y])}if(this.polygonVertices.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const r=this.polygonVertices[0];this.polygonVertices=this.polygonVertices.filter(((e,t)=>0===t||t===this.polygonVertices.length-1||JSON.stringify(e)!==JSON.stringify(r)));const o=await this._getAreaFromTask(this.polygonVertices);if(!o?.area||!o?.perimeter)return;const{area:n}=o;this.pixelAreaMeasurement=n}vertexUpdatePolylineHandler(){this.measurementArray=this.measurementArray.slice(-1);const e=g.reduce(((e,t)=>e+t),0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=e,this.pixelMeasurement>0&&g.push(this.pixelMeasurement)}resetDistanceMeasurements(){this.measurementArray=[],this.pixelMeasurement=0,g=[]}resetAreaMeasurements(){this.polygonVertices=[],this.pixelAreaMeasurement=0,w=0}async _overlayFirstMeasurement(e,t){switch(t){case"polyline":this._overlayFirstDistanceMeasurement(e);break;case"polygon":this._overlayFirstAreaGeometry(e)}}async _overlayFirstDistanceMeasurement(e){const a=e.geometry?.clone(),s=e.symbol?.clone(),i=[...a.paths[0]],r=p(i,!0),o=await this.viewModel.getMeasurementProperties(),n=await this.viewModel.getMeasurementProperties(this.viewModel.currentBestFeatureMeasurementImage,this.viewModel.imageMeasurementViewer);if(r?.length&&o&&n){const{updateElevationProps:e,...a}=o,{updateElevationProps:i,...l}=n,h=await u(r,a,e),p=d(h,l).map((e=>[e.x-.5,-.5-e.y])),y=new c({paths:[p],spatialReference:m.WebMercator}),M=new t({geometry:y,symbol:s});this.viewModel.editOverlayedGraphics(M)}}async _overlayFirstAreaGeometry(e){const a=e.geometry?.clone(),s=e.symbol?.clone(),i=[...a.rings[0]],r=p(i,!0),o=await this.viewModel.getMeasurementProperties(),c=await this.viewModel.getMeasurementProperties(this.viewModel.currentBestFeatureMeasurementImage,this.viewModel.imageMeasurementViewer);if(r?.length&&o&&c){const{updateElevationProps:e,...a}=o,{updateElevationProps:i,...l}=c,h=await u(r,a,e),p=d(h,l).map((e=>[e.x-.5,-.5-e.y])),y=new n({rings:[p],spatialReference:m.WebMercator}),M=new t({geometry:y,symbol:s});this.viewModel.editOverlayedGraphics(M)}}async _getAreaFromTask(e){const{mode:t}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=a((async a=>{this._areaCalculation=null;const s=await this.viewModel.calculateAreaMeasurement(e,t,a);i(a),this._areaCalculation=s})),await this._calculationTask.promise,this._areaCalculation}async _getDistanceFromTask(){const{mode:e}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=a((async t=>{this._distanceCalculation=0;const a=await this.viewModel.calculateDistanceMeasurement(this.measurementArray,e,t);i(t),this._distanceCalculation=a})),await this._calculationTask.promise,this._distanceCalculation}async _getAccuracyFromTask(){const{mode:e}=this.viewModel;return"none"===e?null:(this._calculationTask?.abort(),this._calculationTask=a((async t=>{this._distanceCalculation=0;const a="default"===e?await this.viewModel.calculateAccuracy(this.measurementArray,"distance",t):await this.viewModel.calculateAccuracyPanoramic(this.measurementArray,"distance",t);i(t),this._distanceCalculation=a})),await this._calculationTask.promise,this._distanceCalculation)}async _getAreaAccuracyFromTask(e){const{mode:t}=this.viewModel;return"none"===t?null:(this._calculationTask?.abort(),this._calculationTask=a((async a=>{this._distanceCalculation=0;const s="default"===t?await this.viewModel.calculateAccuracy(e,"area",a):await this.viewModel.calculateAccuracyPanoramic(e,"area",a);i(a),this._distanceCalculation=s})),await this._calculationTask.promise,this._distanceCalculation)}};e([r()],v.prototype,"type",void 0),e([r()],v.prototype,"measurementArray",void 0),e([r()],v.prototype,"pixelMeasurement",void 0),e([r()],v.prototype,"pixelAreaMeasurement",void 0),e([r()],v.prototype,"polygonVertices",void 0),v=e([o("esri.widgets.OrientedImageryViewer.adapters.sketch.MeasurementAdapter")],v);const f=v;export{f as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Promise.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 r}from"../../../../core/accessorSupport/decorators/subclass.js";import{projectWithZConversion as s}from"../../../../geometry/
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Promise.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 r}from"../../../../core/accessorSupport/decorators/subclass.js";import{projectWithZConversion as s}from"../../../../geometry/projectionUtils.js";import{computeTriangulatedVector as i,computeTriangulatedAreaMeasurement as o,computeTriangulatedDistanceMeasurement as c}from"../../imageMeasurementUtils.js";import{TriangulatedSketchHandlerMixin as n}from"../../mixins/TriangulatedSketchHandlerMixin.js";let u=[],m=class extends(n(t)){constructor(e){super(e),this.type="measurement"}async handleUpdate(e){const{measureType:t,updatingTriangularMeasurementState:a}=this.viewModel;if("distance"===t){const t=e.graphics[0].geometry;u=t.paths[0]}else if("area"===t){const t=e.graphics[0].geometry;u=t.rings[0]}"complete"===e.state&&(this.viewModel.triangulatedMeasurementGraphic=e.graphics.at(-1),a?this._updateTriangularMeasurements(u):await this.viewModel.processMeasurementVectors(u))}async _computeMeasurementVector(e,t){const{activeViewer:a,mode:r,view:o}=this.viewModel,c=a?.imageSize;if(!e||!t||!c)return;const n=e.map((e=>[e[0]-.5,-.5-e[1]])),u=o?.spatialReference,m=[];for(let i=0;i<n.length;i++){const e={x:n[i][0],y:n[i][1]};let a=await this.viewModel.getMapPoint(e,{feature:t,imageSize:c,mode:r});u&&!a.spatialReference.equals(u)&&(a=await s(a,u)),m.push(a)}return i(m,t)}async _updateTriangularMeasurements(e){const{measureType:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:r,updatingTriangularMeasurementState:s}=this.viewModel;if(!a||!r||!s||2!==this.viewModel.measurementVectors?.length)return;this.viewModel.measurementVectors.splice(-1);const i=await this._computeMeasurementVector(e,r);if(i&&this.viewModel.measurementVectors.push(i),2===this.viewModel.measurementVectors.length){switch(t){case"distance":{this.viewModel.triangulatedDistanceMeasurement=await c(this.viewModel.measurementVectors);const t=await this.viewModel.calculateAccuracy(e,"distance");if(t&&this.viewModel.triangulatedDistanceMeasurement?.distance){const e=Math.atan(t/this.viewModel.triangulatedDistanceMeasurement.distance);this.viewModel.triangulatedDistanceAccuracy={distanceAccuracy:t,angleAccuracy:e}}break}case"area":if(r?.geometry.spatialReference){const t=await o(this.viewModel.measurementVectors,r.geometry.spatialReference);this.viewModel.triangulatedAreaMeasurement=t,this.viewModel.triangulatedAreaAccuracy=await this.viewModel.calculateAccuracy(e,"area")??this.viewModel.triangulatedAreaAccuracy}}this.viewModel.updatingTriangularMeasurementState=!1}}};e([a()],m.prototype,"type",void 0),m=e([r("esri.widgets.OrientedImageryViewer.adapters.sketch.TriangulatedMeasurementAdapter")],m);const l=m;export{l as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Graphic.js";import{isSome as t}from"../../../../core/arrayUtils.js";import{throwIfAborted as i,waitTick as r}from"../../../../core/promiseUtils.js";import o from"../../../../geometry/Mesh.js";import a from"../../../../geometry/Point.js";import{projectWithZConversion as s}from"../../../../geometry/
|
|
5
|
+
import e from"../../../../Graphic.js";import{isSome as t}from"../../../../core/arrayUtils.js";import{throwIfAborted as i,waitTick as r}from"../../../../core/promiseUtils.js";import o from"../../../../geometry/Mesh.js";import a from"../../../../geometry/Point.js";import{projectWithZConversion as s}from"../../../../geometry/projectionUtils.js";import{MeshVertexAttributes as n}from"../../../../geometry/support/MeshVertexAttributes.js";import{projectVertices as l,updateFrustum as c,createCoveragePolygon as m}from"../../../../layers/orientedImagery/core/coverageUtils.js";import{activeFrustumSymbol as u,additionalFrustumSymbol as p}from"../../symbols.js";class d{constructor(a){this.viewModel=a,this._updateBestFeatureFootprintElevation=!1,this.createFootprints=async r=>{const{coverageFrustums:a,currentBestFeature:c,isAdditionalCoverageVisible:m,view:d}=this.viewModel,f=a.filter(t);for(const t of f){let a=t.clone();if(!d.spatialReference.equals(a.spatialReference)){const{components:e,spatialReference:t,origin:c,vertexAttributes:m,vertexSpace:u}=a;if("local"===u.type){const e=await s(c,d.spatialReference,r);i(r),a.centerAt(e)}else{const s=m.position,c=Float64Array.from(await l([...s],t.clone(),d.spatialReference.clone(),r));i(r),a=new o({vertexAttributes:new n({position:c}),components:e,spatialReference:d.spatialReference.clone()})}}t.imageID===c.attributes.objectId?(this.viewModel.bestFeatureFootprint=new e({attributes:{imageID:t.imageID},geometry:a,symbol:u.clone(),visible:!1}),this._updateBestFeatureFootprintElevation=!0):this.viewModel.additionalFootprints.push(new e({attributes:{imageID:t.imageID},geometry:a,symbol:p.clone(),visible:m}))}},this.updateFootprint=async(r,o)=>{const{bestFeatureFootprint:a,currentBestFeature:n,activeViewer:l,footprintExtent:m,view:p}=this.viewModel,d=l?.imageSize;if(!(n&&a?.geometry&&d&&m))return void this.viewModel.updateCurrentCoveragePolygon(null);const{attributes:{cameraHeight:w,location:v,cameraPitch:g,horizontalFieldOfView:h,verticalFieldOfView:y,cameraRoll:b},elevationSample:F}=n;F&&this._updateBestFeatureFootprintElevation&&(this.updateGroundElevation([a],F),this._updateBestFeatureFootprintElevation=!1);const M=v.toArray(),{vertexAttributes:{position:R},spatialReference:V}=a.geometry,j=await f(R,V,v.spatialReference),A=await this.viewModel.getMapPoint(r,{feature:n,mode:"default",imageSize:d});i(o);let I=A.filter(t);if(!I.length)return;I[0].spatialReference.equals(v.spatialReference)||(I=await Promise.all(I.map((async e=>{const t=await s(e,v.spatialReference,o);return i(o),t}))));const P=await c(r.map((({x:e,y:t})=>[e,t])),I.map((e=>e.toArray())),{cameraHeight:w,cameraLocation:M,cameraPitch:g,frustumVertices:j,horizontalFieldOfView:h,imageHeight:d[1],imageWidth:d[0],inSRS:{wkid:v.spatialReference.wkid},outSRS:{wkid:p.spatialReference.wkid},verticalFieldOfView:y,cameraRoll:b??0,options:o});this.viewModel.updateCurrentCoveragePolygon(new e({attributes:{imageID:n.attributes.objectId},geometry:P,symbol:u.clone(),visible:this.viewModel.currentCoverageVisible}))},this.updateFootprintPanorama=async(t,i)=>{await r(i);const{horizontalFieldOfView:o,pitch:a,verticalFieldOfView:s,yaw:n}=t,l=this.viewModel.currentBestFeature?.clone();if(!l)return;const{attributes:c}=l;c.orientedImageryType=null,c.cameraHeading=(n+c.cameraHeading)%360,c.cameraPitch=a,c.horizontalFieldOfView=o,c.verticalFieldOfView=s,c.cameraRoll=0;const{frustum:p}=m(c);p?this.viewModel.updateCurrentCoveragePolygon(new e({attributes:{imageID:c.objectId},geometry:p,symbol:u.clone(),visible:this.viewModel.currentCoverageVisible})):this.viewModel.updateCurrentCoveragePolygon(null)}}updateGroundElevation(e,t){const{geometry:i}=this.viewModel.currentBestFeature,r=t.queryElevation(i);e.forEach((e=>{const{geometry:t}=e;switch(t?.type){case"mesh":{const{vertexAttributes:{position:e}}=t,i=Math.floor(e.length/3);for(let t=0;t<i;t+=1)e[3*t+2]+=r?.z??0;break}case"point":t.z=(t.z??0)+(r?.z??0)}}))}}async function f(e,t,i,r){return Float64Array.from((await Promise.all(e.reduce(((e,t,i)=>{const r=Math.floor(i/3);return e[r]=e[r]??[],e[r].push(t),e}),new Array).map((async e=>(await s(new a(e,t),i,r)).toArray())))).flat())}export{d as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{rad2deg as t}from"../../core/mathUtils.js";import{throwIfAborted as e}from"../../core/promiseUtils.js";import{formatArea as n,formatLength as r}from"../../core/quantityFormatUtils.js";import{createArea as a,createLength as o}from"../../core/quantityUtils.js";import{set as s,determinant as i}from"../../core/libs/gl-matrix-2/math/mat3.js";import{create as c}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as u,fromValues as l}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as f}from"../../core/libs/gl-matrix-2/math/vec2.js";import{i as m,h as p,a as h}from"../../chunks/vec32.js";import y from"../../geometry/Point.js";import g from"../../geometry/Polygon.js";import x from"../../geometry/Polyline.js";import{projectWithZConversion as w,project as M}from"../../geometry/projection.js";import R from"../../geometry/SpatialReference.js";import{e as z}from"../../chunks/areaOperator.js";import{l as d,e as P}from"../../chunks/geodeticAreaOperator.js";import{l as v,e as j}from"../../chunks/geodeticDensifyOperator.js";import{l as b,e as O}from"../../chunks/geodeticLengthOperator.js";import{e as E}from"../../chunks/lengthOperator.js";import{execute as q}from"../../geometry/operators/projectOperator.js";import{e as W}from"../../chunks/simplifyOperator.js";import{isSupported as k,geodesicLengths as I,geodesicAreas as G}from"../../geometry/support/geodesicUtils.js";import{imageToWorldPanoramic as L,imageToWorld as A}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as D,scaleWithFactor as S}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as U,worldToImage as B}from"../../layers/orientedImagery/transformations/worldToImage.js";const F=1e5;function T(t,e){let n=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function H(t,e){let n=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function V(t,e,n){if(!t?.length||!e?.length||!n)return;const[r,a]=t,[,o]=e,s=o-a;return[r+s*Math.cos(n),a+s*Math.sin(n)]}async function C(t,e,n){if(await v(),k(t)){const t=I([e],"meters")[0];return{area:G([n],"square-meters")[0],perimeter:t}}const r=R.WGS84,a=M(e,r),o=M(n,r);let s=j(o,F);if(s=s?W(s):null,!s)return null;const i=I([a],"meters")[0];return{area:G([s],"square-meters")[0],perimeter:i}}async function J(t,n,r,a,o=!1,s){if(n.length<2||!a||!r||!t)return null;const i=dt(r,t);if(!i)return null;const c=n.map((t=>[t.x,t.y])),u=c.at(0),l=c.at(-1);if(!u||!l)return null;const f=i.map((e=>Et([u,l],e,t,o,!1))),m=await Promise.all(f);e(s);let p=0;for(const e of m){if(!e)return null;const t=Math.abs(e-a);p=Math.max(t,p)}return p}async function K(t,n,r,a,o,s=!1,i){if(n.length<2||!a||!r||!t)throw new Error("Missing parameters");const c=Pt(r,t),u=n.map((t=>[t.x,t.y])),l=u.at(0),f=u.at(-1),m=c.map((e=>qt([l,f],e,t,o,s,!1))),p=await Promise.all(m);e(i);let h=0;for(const e of p){if(!e)return 0;const t=Math.abs(e-a);h=Math.max(t,h)}return h}function N(t,e){const n=Rt(t,!1);if(!n?.length)return;return 20*f([n[0].x,n[0].y],[n.at(-1).x,n.at(-1).y])/e}async function Q(t){await b();const e=t.spatialReference;if(e.isGeographic){if(k(e))return I([t],"meters")[0];const n=M(t,R.WGS84);return I([n],"meters")[0]}return e.isWebMercator?O(t):E(t)}function X(t){if(!t?.length)throw new Error("Invalid deviations array");const[e,n,r]=[0,1,2].map((e=>t.map((t=>t[e])).filter((t=>null!==t)))).map((t=>t.length?bt(t):0));return[e,n,r]}function Y(t,e){const n=W(e);if(!n)return null;const r=E(t);return{area:z(n),perimeter:r}}function Z(t,e){return[(t[1][0]-t[0][0])/e,(t[1][1]-t[0][1])/e,(t[1][2]-t[0][2])/e]}async function $(t,e){await Promise.all([d(),v(),b()]);let n=j(e,F);if(n=n?W(n):null,!n)return null;const r=O(t);return{area:P(n),perimeter:r}}async function _(t,n,r){if(!n||!t)throw new Error("Missing required parameters");const a=await A(t,n);e(r);const o=a.clone();o.z?o.z+=20:o.z=20;const{averageElevation:s,cameraPitch:i,cameraRoll:c,farDistance:u,...l}=n;return B(o,l)}async function tt(t,n,r,a){const{attributes:o}=r,{location:s}=o,{updateElevationProps:i,...c}=n;if(!t||!n)throw new Error("Missing parameters");let u=s.clone();u.spatialReference.isGeographic&&(u=await w(u,R.WebMercator));const l=await L(t,{...c,cameraLocation:u},i);e(a);const f=l.clone();return f.z?f.z+=20:f.z=20,U(f,c)}function et(t,e,n,r,a=0,o=1,s){const{averageElevation:i,cameraPitch:c,cameraRoll:u,farDistance:l,...m}=r;if(a>=5||o<=.1)return{value:t};const p=new y({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=B(p,m),g=f([n[0].x,n[0].y],[h.x,h.y]),x=n.at(0),w=n.at(-1);if(!x||!w)return null;const M=f([x.x,x.y],[w.x,w.y])*t/g;return et(M,e,n,r,a+1,Math.abs(t-M))}function nt(t,e,n,r,a=0,o=1,s){const{averageElevation:i,horizontalFieldOfView:c,verticalFieldOfView:u,farDistance:l,...m}=r;if(a>=5||o<=.1)return{value:t};const p=new y({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=U(p,m),g=f([n[0].x,n[0].y],[h.x,h.y]),x=n.at(0),w=n.at(-1);if(!x||!w)return null;const M=f([x.x,x.y],[w.x,w.y])*t/g;return nt(M,e,n,r,a+1,Math.abs(t-M))}function rt(t,e,n){return new x({paths:[[[t.x,t.y,t.z??0],[e.x,e.y,e.z??0]]],spatialReference:n})}function at(t){return 1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/6378137)))}function ot(t,e){return Math.sqrt((Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/e)**2+(t[0][2]-t[1][2])**2)}function st(t,e,n){return Math.sqrt((t.z??0-(e.z??0))**2+(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)/n)**2)*n}function it(t,e,n,r){return Ut(St([t.x,t.y,t.z??0],[e.x,e.y,e.z??0]),1/n,1/r)}function ct(t,e){return Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/e}function ut(e){return t(Math.atan((e[1][2]-e[0][2])/Math.sqrt((e[1][0]-e[0][0])**2+(e[1][1]-e[0][1])**2)))}function lt(e){let n=90-t(Math.atan2(e[1][1]-e[0][1],e[1][0]-e[0][0]));return n<0&&(n+=360),n}function ft(t,e){return new y({x:(t.pointOnA[0]+t.pointOnB[0])/2,y:(t.pointOnA[1]+t.pointOnB[1])/2,z:(t.pointOnA[2]+t.pointOnB[2])/2,spatialReference:e})}async function mt(t){if(2===t?.length){const e=[];let n=1;const[r,a]=t,o=r.camera.spatialReference,{measurePoints:s}=r;for(let t=0;t<s.length;t++){const s=rt(r.camera,r.measurePoints[t],o),i=rt(a.camera,a.measurePoints[t],o),c=await Lt(s,i);if(!c)return null;const u=ft(c,o);u.spatialReference.isWebMercator&&(n=at(u.y)),e.push([u.x,u.y,u.z??0])}if(e?.length>1){return{distance:ot(e,n),horizontalDistance:ct(e,n),verticalDistance:Math.abs(e[0][2]-e[1][2]),slope:ut(e),aspect:lt(e)}}}return null}async function pt(t){const e=t[0].camera.spatialReference;if(2!==t?.length)return null;const[n,r]=t,{camera:a,measurePoints:o}=n,{camera:s,measurePoints:i}=r,c=rt(a,o[0],e),u=rt(s,i[0],e),l=await Lt(c,u);return l?ft(l,e)??null:null}async function ht(t,e){if(!t?.length)return null;const n=[],r=t[0],a=t[1],o=r.camera.spatialReference,{measurePoints:s}=r;for(let l=0;l<s.length;l++){const t=rt(r.camera,r.measurePoints[l],o),e=rt(a.camera,a.measurePoints[l],o),s=await Lt(t,e);if(!s)return null;const i=ft(s,o);n.push([i.x,i.y,i.z??0])}if(n?.length<2)return null;const i=new x({paths:[n],spatialReference:e}),c=new g({rings:[n],spatialReference:e});if(e.isGeographic){const t=await C(e,i,c);return t?.area??null}if(e.isWebMercator){const t=await $(i,c);return t?.area??null}const u=Y(i,c);return u?.area??null}function yt(t,e){if(!t)return null;const n=e.geometry.clone(),r=Array.isArray(t)?t:[t],a=[];return r.forEach((t=>{let e=!1;t.spatialReference.isWGS84&&(t=q(t,new R({wkid:3857})),e=!0);const r=t.spatialReference.isWebMercator?at(t.y):1,o=st(t,n,r),s=it(t,n,o,r),i=((t.z??0)-(n.z??0))/s[2]*r;let c=new y({spatialReference:t.spatialReference,x:n.x+i*s[0],y:n.y+i*s[1],z:(n.z??0)+i*s[2]/r});e&&(c=q(c,new R({wkid:4326}))),a.push(c)})),{camera:n,measurePoints:r,tempMeasurePoints:a}}async function gt(t,e){const{updateElevationProps:n,...r}=e;return await A(t,r,n)}async function xt(t,e){const{updateElevationProps:n,...r}=e;return L(t,r,n)}function wt(t){navigator.clipboard.writeText(t).catch((t=>{throw t}))}function Mt(t){const e=t.map((t=>[t.x,t.y])),n=t[0].spatialReference;return new x({paths:[e],spatialReference:n})}function Rt(t,e){return t.map((t=>({x:e?.5+t[0]:t[0],y:e?.5-t[1]:t[1]})))}function zt(t,e,n,a,s){const i="measurement"===t?e:n;if(s&&i)return r(a,o(i,"meters"),s,3)||null}function dt(t,e){const{cameraPitch:n,cameraRoll:r,cameraLocation:a}=t,{x:o,y:s,z:i,spatialReference:c}=a;if(e.every((t=>0===t))||!e||!e.length)return null;const[u,l,,f,m]=e,p=[-f,0,f],h=[-m,0,m],g=[-u,0,u],x=[-l,0,l],w=[];for(const M of p)for(const e of h)for(const a of g)for(const u of g)for(const l of x){const f={...t};f.cameraPitch=n+M,f.cameraRoll=r+e,f.cameraLocation=new y({x:o+a,y:s+u,z:i?i+l:0,spatialReference:{wkid:c.wkid}}),w.push(f)}return w}function Pt(t,e){const{cameraHeading:n,cameraLocation:r}=t,{x:a,y:o,z:s,spatialReference:i}=r;if(e.every((t=>0===t))||!e||!e.length)throw new Error("Invalid parameters");const[c,u,l]=e,f=l>0?[-l,0,l]:[],m=c>0?[-c,0,c]:[],p=u>0?[-u,0,u]:[],h=[];for(const g of f)for(const e of m)for(const r of m)for(const c of p){const u={...t};u.cameraHeading=n+g,u.cameraLocation=new y({x:a+e,y:o+r,z:s?s+c:0,spatialReference:{wkid:i.wkid}}),h.push(u)}return h}function vt(t,e,n,a,s){const i="measurement"===t?e:bt(n);if(s&&i)return r(a,o(i,"meters"),s,3)||null}function jt(t,e,r,o,s){const i="measurement"===t?e:r;if(s&&i)return n(o,a(i,"square-meters"),s,3)||null}function bt(t){return Math.sqrt(t.reduce(((t,e)=>t+e**2),0))}function Ot(t,e,n){if("default"===e)return t;const r={x:t[0],y:t[1],z:t[2]},a=D(r,n[0],n[1]);return[a.x,a.y]}async function Et(t,n,r,a=!1,o=!1,s){if(!t||!n||t.length<2)return null;const i=Rt(t,a);if(!i||i.length<2)return null;const[c,u]=[i[0],i.at(-1)];if(!u)return null;const l=[c],m=await A(c,n);e(s);const p=m.clone();p.z?p.z+=20:p.z=20;const{averageElevation:h,cameraPitch:y,cameraRoll:g,farDistance:x,...w}=n,M=B(p,w),R=f([c.x,c.y],[M.x,M.y]),z=T(c,M);if(!z)return;const d=V([c.x,c.y],[u.x,u.y],z);if(!d?.length)return;l.push({x:d[0],y:d[1]});const P=20*f([l[0].x,l[0].y],[l[1].x,l[1].y])/R;if(!o)return P;const v=et(P,m,l,n,0,1);return v?.value}async function qt(t,n,r,a,o=!1,s=!1,i){const{attributes:c}=a,{location:u}=c,{updateElevationProps:l,...m}=n;if(!t||!n||t.length<2)throw new Error("Invalid parameters");const p=Rt(t,o),[h,y]=[p[0],p.at(-1)],g=[h];let x=u.clone();x.spatialReference.isGeographic&&(x=await w(x,R.WebMercator));const M=await L(h,{...m,cameraLocation:x},l);e(i);const z=M.clone();z.z?z.z+=20:z.z=20;const d=U(z,m),P=f([h.x,h.y],[d.x,d.y]),v=T(h,d);if(!v)return;const j=V([h.x,h.y],[y.x,y.y],v);if(!j?.length)return;g.push({x:j[0],y:j[1]});const b=20*f([g[0].x,g[0].y],[g[1].x,g[1].y])/P;if(!s)return b;const O=nt(b,M,g,n,0,1);return O?.value}async function Wt(t,e,n=!1){if(t.length<3)return null;const r=Rt(t,n),a=await gt(r,e),o=a.map((({x:t,y:e})=>[t,e]));t.push(t[0]),o.push(o[0]);const s=a[0].spatialReference,i=new x({paths:[o],spatialReference:s}),c=new g({rings:[o],spatialReference:s});return s.isGeographic?C(s,i,c):s.isWebMercator?$(i,c):Y(i,c)}async function kt(t,n,r=!1,a){if(t.length<3)return null;const o=Rt(t,r),s=await xt(o,n);e(a);const i=s.map((({x:t,y:e})=>[t,e]));t.push(t[0]),i.push(i[0]);const c=s[0].spatialReference,u=new x({paths:[i],spatialReference:c}),l=new g({rings:[i],spatialReference:c});return c.isGeographic?C(c,u,l):c.isWebMercator?$(u,l):Y(u,l)}async function It(t,e,n=!1){const r=Rt(t,n);return Q(Mt(await gt(r,e)))}async function Gt(t,n,r=!1,a){const o=Rt(t,r),s=await xt(o,n);e(a);return Q(Mt(s))}async function Lt(t,e){const n=c(),r=t.paths[0][0],a=e.paths[0][0];let o,u;t.spatialReference.isWGS84||t.spatialReference.isWebMercator?(await b(),o=O(t),u=O(e)):(o=E(t),u=E(e));const l=Z(t.paths[0],o),f=Z(e.paths[0],u),m=At(l,f),[p,h,y]=l,[g,x,w]=f.map((t=>-t)),[M,R,z]=m,[d,P,v]=[a[0]-r[0],a[1]-r[1],a[2]-r[2]];s(n,p,g,M,h,x,R,y,w,z);const j=i(n);if(0===j)return null;s(n,d,g,M,P,x,R,v,w,z);const q=i(n);s(n,p,d,M,h,P,R,y,v,z);const W=i(n);s(n,p,g,d,h,x,P,y,w,v);const k=q/j,I=W/j,G=i(n)/j;return{distance:Math.abs(G/Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2])),pointOnA:Dt(r,k,l),pointOnB:Dt(a,I,f)}}function At(t,e){const n=u(),r=m(u(),t[0],t[1],t[2]),a=m(u(),e[0],e[1],e[2]),o=p(n,r,a);return[o[0],o[1],o[2]]}function Dt(t,e,n){return[t[0]+e*n[0],t[1]+e*n[1],t[2]+e*n[2]]}function St(t,e){const n=l(t[0],t[1],t[2]),r=l(e[0],e[1],e[2]);return h(u(),n,r)}function Ut(t,e,n){const r=S(t,e,n);return[r[0],r[1],r[2]]}export{T as calculateAngle,H as calculateAnglePano,V as calculateCorrectedPixel,J as calculateHeightAccuracy,K as calculateHeightAccuracyPanoramic,N as calculateHeightFromTemporaryDistance,X as calculateLocationAccuracyFromDeviations,tt as calculateReferenceImagePointPanoramic,_ as calculateTempImagePoint,et as computeHeightIteratively,nt as computeHeightIterativelyPanoramic,ht as computeTriangulatedAreaMeasurement,mt as computeTriangulatedDistanceMeasurement,pt as computeTriangulatedPoint,yt as computeTriangulatedVector,wt as copyToClipboard,Rt as formatPixels,dt as generateCombinations,Pt as generateCombinationsPanoramic,jt as getConvertedArea,vt as getConvertedDistance,zt as getConvertedHeight,Ot as getModeCorrectedPoint,bt as getRootOfSumOfSquaredErrors,Et as heightMeasurement2D,qt as heightMeasurementPanoramic,Wt as pixelAreaMeasurement2D,kt as pixelAreaMeasurementPanoramic,It as pixelDistanceMeasurement2D,Gt as pixelDistanceMeasurementPanoramic,Ut as scale,Lt as solveSkewLinesIntersection,St as subtract};
|
|
5
|
+
import{rad2deg as t}from"../../core/mathUtils.js";import{throwIfAborted as e}from"../../core/promiseUtils.js";import{formatArea as n,formatLength as r}from"../../core/quantityFormatUtils.js";import{createArea as a,createLength as o}from"../../core/quantityUtils.js";import{set as s,determinant as i}from"../../core/libs/gl-matrix-2/math/mat3.js";import{create as c}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as u,fromValues as l}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as f}from"../../core/libs/gl-matrix-2/math/vec2.js";import{i as m,h as p,a as h}from"../../chunks/vec32.js";import y from"../../geometry/Point.js";import g from"../../geometry/Polygon.js";import x from"../../geometry/Polyline.js";import{projectWithZConversion as w,project as M}from"../../geometry/projectionUtils.js";import R from"../../geometry/SpatialReference.js";import{e as z}from"../../chunks/areaOperator.js";import{l as d,e as P}from"../../chunks/geodeticAreaOperator.js";import{l as v,e as j}from"../../chunks/geodeticDensifyOperator.js";import{l as b,e as O}from"../../chunks/geodeticLengthOperator.js";import{e as E}from"../../chunks/lengthOperator.js";import{execute as q}from"../../geometry/operators/projectOperator.js";import{e as W}from"../../chunks/simplifyOperator.js";import{isSupported as k,geodesicLengths as I,geodesicAreas as G}from"../../geometry/support/geodesicUtils.js";import{imageToWorldPanoramic as L,imageToWorld as A}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as D,scaleWithFactor as U}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as S,worldToImage as B}from"../../layers/orientedImagery/transformations/worldToImage.js";const F=1e5;function T(t,e){let n=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function H(t,e){let n=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function V(t,e,n){if(!t?.length||!e?.length||!n)return;const[r,a]=t,[,o]=e,s=o-a;return[r+s*Math.cos(n),a+s*Math.sin(n)]}async function C(t,e,n){if(await v(),k(t)){const t=I([e],"meters")[0];return{area:G([n],"square-meters")[0],perimeter:t}}const r=R.WGS84,a=M(e,r),o=M(n,r);let s=j(o,F);if(s=s?W(s):null,!s)return null;const i=I([a],"meters")[0];return{area:G([s],"square-meters")[0],perimeter:i}}async function J(t,n,r,a,o=!1,s){if(n.length<2||!a||!r||!t)return null;const i=dt(r,t);if(!i)return null;const c=n.map((t=>[t.x,t.y])),u=c.at(0),l=c.at(-1);if(!u||!l)return null;const f=i.map((e=>Et([u,l],e,t,o,!1))),m=await Promise.all(f);e(s);let p=0;for(const e of m){if(!e)return null;const t=Math.abs(e-a);p=Math.max(t,p)}return p}async function K(t,n,r,a,o,s=!1,i){if(n.length<2||!a||!r||!t)throw new Error("Missing parameters");const c=Pt(r,t),u=n.map((t=>[t.x,t.y])),l=u.at(0),f=u.at(-1),m=c.map((e=>qt([l,f],e,t,o,s,!1))),p=await Promise.all(m);e(i);let h=0;for(const e of p){if(!e)return 0;const t=Math.abs(e-a);h=Math.max(t,h)}return h}function N(t,e){const n=Rt(t,!1);if(!n?.length)return;return 20*f([n[0].x,n[0].y],[n.at(-1).x,n.at(-1).y])/e}async function Q(t){await b();const e=t.spatialReference;if(e.isGeographic){if(k(e))return I([t],"meters")[0];const n=M(t,R.WGS84);return I([n],"meters")[0]}return e.isWebMercator?O(t):E(t)}function X(t){if(!t?.length)throw new Error("Invalid deviations array");const[e,n,r]=[0,1,2].map((e=>t.map((t=>t[e])).filter((t=>null!==t)))).map((t=>t.length?bt(t):0));return[e,n,r]}function Y(t,e){const n=W(e);if(!n)return null;const r=E(t);return{area:z(n),perimeter:r}}function Z(t,e){return[(t[1][0]-t[0][0])/e,(t[1][1]-t[0][1])/e,(t[1][2]-t[0][2])/e]}async function $(t,e){await Promise.all([d(),v(),b()]);let n=j(e,F);if(n=n?W(n):null,!n)return null;const r=O(t);return{area:P(n),perimeter:r}}async function _(t,n,r){if(!n||!t)throw new Error("Missing required parameters");const a=await A(t,n);e(r);const o=a.clone();o.z?o.z+=20:o.z=20;const{averageElevation:s,cameraPitch:i,cameraRoll:c,farDistance:u,...l}=n;return B(o,l)}async function tt(t,n,r,a){const{attributes:o}=r,{location:s}=o,{updateElevationProps:i,...c}=n;if(!t||!n)throw new Error("Missing parameters");let u=s.clone();u.spatialReference.isGeographic&&(u=await w(u,R.WebMercator));const l=await L(t,{...c,cameraLocation:u},i);e(a);const f=l.clone();return f.z?f.z+=20:f.z=20,S(f,c)}function et(t,e,n,r,a=0,o=1,s){const{averageElevation:i,cameraPitch:c,cameraRoll:u,farDistance:l,...m}=r;if(a>=5||o<=.1)return{value:t};const p=new y({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=B(p,m),g=f([n[0].x,n[0].y],[h.x,h.y]),x=n.at(0),w=n.at(-1);if(!x||!w)return null;const M=f([x.x,x.y],[w.x,w.y])*t/g;return et(M,e,n,r,a+1,Math.abs(t-M))}function nt(t,e,n,r,a=0,o=1,s){const{averageElevation:i,horizontalFieldOfView:c,verticalFieldOfView:u,farDistance:l,...m}=r;if(a>=5||o<=.1)return{value:t};const p=new y({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=S(p,m),g=f([n[0].x,n[0].y],[h.x,h.y]),x=n.at(0),w=n.at(-1);if(!x||!w)return null;const M=f([x.x,x.y],[w.x,w.y])*t/g;return nt(M,e,n,r,a+1,Math.abs(t-M))}function rt(t,e,n){return new x({paths:[[[t.x,t.y,t.z??0],[e.x,e.y,e.z??0]]],spatialReference:n})}function at(t){return 1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/6378137)))}function ot(t,e){return Math.sqrt((Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/e)**2+(t[0][2]-t[1][2])**2)}function st(t,e,n){return Math.sqrt((t.z??0-(e.z??0))**2+(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)/n)**2)*n}function it(t,e,n,r){return St(Ut([t.x,t.y,t.z??0],[e.x,e.y,e.z??0]),1/n,1/r)}function ct(t,e){return Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/e}function ut(e){return t(Math.atan((e[1][2]-e[0][2])/Math.sqrt((e[1][0]-e[0][0])**2+(e[1][1]-e[0][1])**2)))}function lt(e){let n=90-t(Math.atan2(e[1][1]-e[0][1],e[1][0]-e[0][0]));return n<0&&(n+=360),n}function ft(t,e){return new y({x:(t.pointOnA[0]+t.pointOnB[0])/2,y:(t.pointOnA[1]+t.pointOnB[1])/2,z:(t.pointOnA[2]+t.pointOnB[2])/2,spatialReference:e})}async function mt(t){if(2===t?.length){const e=[];let n=1;const[r,a]=t,o=r.camera.spatialReference,{measurePoints:s}=r;for(let t=0;t<s.length;t++){const s=rt(r.camera,r.measurePoints[t],o),i=rt(a.camera,a.measurePoints[t],o),c=await Lt(s,i);if(!c)return null;const u=ft(c,o);u.spatialReference.isWebMercator&&(n=at(u.y)),e.push([u.x,u.y,u.z??0])}if(e?.length>1){return{distance:ot(e,n),horizontalDistance:ct(e,n),verticalDistance:Math.abs(e[0][2]-e[1][2]),slope:ut(e),aspect:lt(e)}}}return null}async function pt(t){const e=t[0].camera.spatialReference;if(2!==t?.length)return null;const[n,r]=t,{camera:a,measurePoints:o}=n,{camera:s,measurePoints:i}=r,c=rt(a,o[0],e),u=rt(s,i[0],e),l=await Lt(c,u);return l?ft(l,e)??null:null}async function ht(t,e){if(!t?.length)return null;const n=[],r=t[0],a=t[1],o=r.camera.spatialReference,{measurePoints:s}=r;for(let l=0;l<s.length;l++){const t=rt(r.camera,r.measurePoints[l],o),e=rt(a.camera,a.measurePoints[l],o),s=await Lt(t,e);if(!s)return null;const i=ft(s,o);n.push([i.x,i.y,i.z??0])}if(n?.length<2)return null;const i=new x({paths:[n],spatialReference:e}),c=new g({rings:[n],spatialReference:e});if(e.isGeographic){const t=await C(e,i,c);return t?.area??null}if(e.isWebMercator){const t=await $(i,c);return t?.area??null}const u=Y(i,c);return u?.area??null}function yt(t,e){if(!t)return null;const n=e.geometry.clone(),r=Array.isArray(t)?t:[t],a=[];return r.forEach((t=>{let e=!1;t.spatialReference.isWGS84&&(t=q(t,new R({wkid:3857})),e=!0);const r=t.spatialReference.isWebMercator?at(t.y):1,o=st(t,n,r),s=it(t,n,o,r),i=((t.z??0)-(n.z??0))/s[2]*r;let c=new y({spatialReference:t.spatialReference,x:n.x+i*s[0],y:n.y+i*s[1],z:(n.z??0)+i*s[2]/r});e&&(c=q(c,new R({wkid:4326}))),a.push(c)})),{camera:n,measurePoints:r,tempMeasurePoints:a}}async function gt(t,e){const{updateElevationProps:n,...r}=e;return await A(t,r,n)}async function xt(t,e){const{updateElevationProps:n,...r}=e;return L(t,r,n)}function wt(t){navigator.clipboard.writeText(t).catch((t=>{throw t}))}function Mt(t){const e=t.map((t=>[t.x,t.y])),n=t[0].spatialReference;return new x({paths:[e],spatialReference:n})}function Rt(t,e){return t.map((t=>({x:e?.5+t[0]:t[0],y:e?.5-t[1]:t[1]})))}function zt(t,e,n,a,s){const i="measurement"===t?e:n;if(s&&i)return r(a,o(i,"meters"),s,3)||null}function dt(t,e){const{cameraPitch:n,cameraRoll:r,cameraLocation:a}=t,{x:o,y:s,z:i,spatialReference:c}=a;if(e.every((t=>0===t))||!e||!e.length)return null;const[u,l,,f,m]=e,p=[-f,0,f],h=[-m,0,m],g=[-u,0,u],x=[-l,0,l],w=[];for(const M of p)for(const e of h)for(const a of g)for(const u of g)for(const l of x){const f={...t};f.cameraPitch=n+M,f.cameraRoll=r+e,f.cameraLocation=new y({x:o+a,y:s+u,z:i?i+l:0,spatialReference:{wkid:c.wkid}}),w.push(f)}return w}function Pt(t,e){const{cameraHeading:n,cameraLocation:r}=t,{x:a,y:o,z:s,spatialReference:i}=r;if(e.every((t=>0===t))||!e||!e.length)throw new Error("Invalid parameters");const[c,u,l]=e,f=l>0?[-l,0,l]:[],m=c>0?[-c,0,c]:[],p=u>0?[-u,0,u]:[],h=[];for(const g of f)for(const e of m)for(const r of m)for(const c of p){const u={...t};u.cameraHeading=n+g,u.cameraLocation=new y({x:a+e,y:o+r,z:s?s+c:0,spatialReference:{wkid:i.wkid}}),h.push(u)}return h}function vt(t,e,n,a,s){const i="measurement"===t?e:bt(n);if(s&&i)return r(a,o(i,"meters"),s,3)||null}function jt(t,e,r,o,s){const i="measurement"===t?e:r;if(s&&i)return n(o,a(i,"square-meters"),s,3)||null}function bt(t){return Math.sqrt(t.reduce(((t,e)=>t+e**2),0))}function Ot(t,e,n){if("default"===e)return t;const r={x:t[0],y:t[1],z:t[2]},a=D(r,n[0],n[1]);return[a.x,a.y]}async function Et(t,n,r,a=!1,o=!1,s){if(!t||!n||t.length<2)return null;const i=Rt(t,a);if(!i||i.length<2)return null;const[c,u]=[i[0],i.at(-1)];if(!u)return null;const l=[c],m=await A(c,n);e(s);const p=m.clone();p.z?p.z+=20:p.z=20;const{averageElevation:h,cameraPitch:y,cameraRoll:g,farDistance:x,...w}=n,M=B(p,w),R=f([c.x,c.y],[M.x,M.y]),z=T(c,M);if(!z)return;const d=V([c.x,c.y],[u.x,u.y],z);if(!d?.length)return;l.push({x:d[0],y:d[1]});const P=20*f([l[0].x,l[0].y],[l[1].x,l[1].y])/R;if(!o)return P;const v=et(P,m,l,n,0,1);return v?.value}async function qt(t,n,r,a,o=!1,s=!1,i){const{attributes:c}=a,{location:u}=c,{updateElevationProps:l,...m}=n;if(!t||!n||t.length<2)throw new Error("Invalid parameters");const p=Rt(t,o),[h,y]=[p[0],p.at(-1)],g=[h];let x=u.clone();x.spatialReference.isGeographic&&(x=await w(x,R.WebMercator));const M=await L(h,{...m,cameraLocation:x},l);e(i);const z=M.clone();z.z?z.z+=20:z.z=20;const d=S(z,m),P=f([h.x,h.y],[d.x,d.y]),v=T(h,d);if(!v)return;const j=V([h.x,h.y],[y.x,y.y],v);if(!j?.length)return;g.push({x:j[0],y:j[1]});const b=20*f([g[0].x,g[0].y],[g[1].x,g[1].y])/P;if(!s)return b;const O=nt(b,M,g,n,0,1);return O?.value}async function Wt(t,e,n=!1){if(t.length<3)return null;const r=Rt(t,n),a=await gt(r,e),o=a.map((({x:t,y:e})=>[t,e]));t.push(t[0]),o.push(o[0]);const s=a[0].spatialReference,i=new x({paths:[o],spatialReference:s}),c=new g({rings:[o],spatialReference:s});return s.isGeographic?C(s,i,c):s.isWebMercator?$(i,c):Y(i,c)}async function kt(t,n,r=!1,a){if(t.length<3)return null;const o=Rt(t,r),s=await xt(o,n);e(a);const i=s.map((({x:t,y:e})=>[t,e]));t.push(t[0]),i.push(i[0]);const c=s[0].spatialReference,u=new x({paths:[i],spatialReference:c}),l=new g({rings:[i],spatialReference:c});return c.isGeographic?C(c,u,l):c.isWebMercator?$(u,l):Y(u,l)}async function It(t,e,n=!1){const r=Rt(t,n);return Q(Mt(await gt(r,e)))}async function Gt(t,n,r=!1,a){const o=Rt(t,r),s=await xt(o,n);e(a);return Q(Mt(s))}async function Lt(t,e){const n=c(),r=t.paths[0][0],a=e.paths[0][0];let o,u;t.spatialReference.isWGS84||t.spatialReference.isWebMercator?(await b(),o=O(t),u=O(e)):(o=E(t),u=E(e));const l=Z(t.paths[0],o),f=Z(e.paths[0],u),m=At(l,f),[p,h,y]=l,[g,x,w]=f.map((t=>-t)),[M,R,z]=m,[d,P,v]=[a[0]-r[0],a[1]-r[1],a[2]-r[2]];s(n,p,g,M,h,x,R,y,w,z);const j=i(n);if(0===j)return null;s(n,d,g,M,P,x,R,v,w,z);const q=i(n);s(n,p,d,M,h,P,R,y,v,z);const W=i(n);s(n,p,g,d,h,x,P,y,w,v);const k=q/j,I=W/j,G=i(n)/j;return{distance:Math.abs(G/Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2])),pointOnA:Dt(r,k,l),pointOnB:Dt(a,I,f)}}function At(t,e){const n=u(),r=m(u(),t[0],t[1],t[2]),a=m(u(),e[0],e[1],e[2]),o=p(n,r,a);return[o[0],o[1],o[2]]}function Dt(t,e,n){return[t[0]+e*n[0],t[1]+e*n[1],t[2]+e*n[2]]}function Ut(t,e){const n=l(t[0],t[1],t[2]),r=l(e[0],e[1],e[2]);return h(u(),n,r)}function St(t,e,n){const r=U(t,e,n);return[r[0],r[1],r[2]]}export{T as calculateAngle,H as calculateAnglePano,V as calculateCorrectedPixel,J as calculateHeightAccuracy,K as calculateHeightAccuracyPanoramic,N as calculateHeightFromTemporaryDistance,X as calculateLocationAccuracyFromDeviations,tt as calculateReferenceImagePointPanoramic,_ as calculateTempImagePoint,et as computeHeightIteratively,nt as computeHeightIterativelyPanoramic,ht as computeTriangulatedAreaMeasurement,mt as computeTriangulatedDistanceMeasurement,pt as computeTriangulatedPoint,yt as computeTriangulatedVector,wt as copyToClipboard,Rt as formatPixels,dt as generateCombinations,Pt as generateCombinationsPanoramic,jt as getConvertedArea,vt as getConvertedDistance,zt as getConvertedHeight,Ot as getModeCorrectedPoint,bt as getRootOfSumOfSquaredErrors,Et as heightMeasurement2D,qt as heightMeasurementPanoramic,Wt as pixelAreaMeasurement2D,kt as pixelAreaMeasurementPanoramic,It as pixelDistanceMeasurement2D,Gt as pixelDistanceMeasurementPanoramic,St as scale,Lt as solveSkewLinesIntersection,Ut as subtract};
|