@arcgis/core 4.33.0-next.20250501 → 4.33.0-next.20250503

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.
Files changed (179) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{0219c3f9408d3fa3c9a0.js → 03ee9d0407c230b885ed.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{de16b771d2c8d816c738.js → 05c80002c37002ac99e8.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{5d40c4783f58af1ae0dc.js → 0e8181e7fc1386d08ffc.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{96e5d192c8d23c1e324f.js → 13e68c43acc8916520db.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{e6a5911ea21bef32834b.js → 1bc22af4cc4effcbcf2b.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{84f972d7851d982701a0.js → 1ca7e0d519ecbfe6976f.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{9b2ab27159500315fbc1.js → 26850ec0917ee355ddb7.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{1bd4fe77ba6fb25322e7.js → 29e2b105f55adafc3a6d.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{5d63dfa5a60c88e03b28.js → 2c77a543a174e5bc736a.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{d0ddf4f1c6a351b447c7.js → 30d7d2c7d6e9e5e2ecb9.js} +1 -1
  12. package/assets/esri/core/workers/chunks/3fb25912b274f264c84e.js +1 -0
  13. package/assets/esri/core/workers/chunks/{febae745a29a17ca130a.js → 4480e4b61affb3b2e9d6.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{4d4a271351fd288277d2.js → 49085a0b3a74e158f32f.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{392e64a573f67817db02.js → 4cb199b547e5b97e65fb.js} +1 -1
  16. package/assets/esri/core/workers/chunks/4df36ee2406861c7afa8.js +1 -0
  17. package/assets/esri/core/workers/chunks/{9652cfd4668b95036c87.js → 532088a72c3ddc50f3be.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{ba917175ca2a6681501e.js → 563594357f3648652a5c.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{abfc5f9ac16c3e885c5f.js → 56db71ea7eb8a5652d98.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{e56647e61296643c5f84.js → 5719471414810b6a9aec.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{235efd948ae470a6f238.js → 60b1365d25581ccf0485.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{3795793643f4db64af0e.js → 63c25455b9cf1b3df76a.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{909be86782af3deb448e.js → 654fe135d41af81daa13.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{cd9343c78a7c3acdbbcd.js → 681b2662f6ce936afd7e.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{65f2b22d8fc12e6d4a87.js → 7000d9158da929a16071.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{7551011117c3d36ff3db.js → 743cdbff5c4616ddc2b4.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{968956284f44187f0622.js → 8540fb31bd0b29ff1906.js} +1 -1
  28. package/assets/esri/core/workers/chunks/8c5cea49e48f8858f115.js +1 -0
  29. package/assets/esri/core/workers/chunks/{237a965bd41ba8903e03.js → 921c040d0497031fd8ff.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{96d2a0777f5c418055fb.js → 92b48e3365d1cc933113.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{5d485c07848164099859.js → 95a4da3150ad8e8e36d8.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{46fb6ba8900286d18b6f.js → 9d564f79b82d427fc1da.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{00612d6e05b1c8647668.js → 9fff43ffcd5602ccc50f.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{653ff3e631fea8ad393a.js → a0db1f3ca29e34dfa16f.js} +12 -12
  35. package/assets/esri/core/workers/chunks/{1cc5c566e68f2255d035.js → a6ca68ef6311ffc365b2.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{5a51c75a2932d9da001a.js → a8d043b73e087bee7c40.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{581180668e0229dcdc14.js → bf190d672dcbaedc1a41.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{ebfa4a0334401f5e004a.js → c12765e0c8b44e349c2a.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{afddb94ff4e1a70022c7.js → c3b2b05996e2008adbe3.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{4fb4884d2de42792abe3.js → d1a9e8db5ba403abe721.js} +1 -1
  41. package/assets/esri/core/workers/chunks/d35cd309ba7bb8968a22.js +1 -0
  42. package/assets/esri/core/workers/chunks/{6e6422eda398774acbc7.js → d60da671aba70485050e.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{7a8df1225abd54ff68ed.js → db298b292a4e43cba72d.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{2bda2cfc6e81818d7d33.js → dcaeb57c69d432118604.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{fb455fd89b74b70a6a2b.js → e613df03ceb39e29befa.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{05d7d8ff3e4cbad32580.js → e8dcaa7837b6fe7bff20.js} +1 -1
  47. package/assets/esri/core/workers/chunks/ec1a4b82cbc44ba45f83.js +1 -0
  48. package/assets/esri/core/workers/chunks/ec778cc7a55068f51937.js +1 -0
  49. package/assets/esri/core/workers/chunks/{51339193abddfe37745d.js → f2b63597ae956db74eb3.js} +1 -1
  50. package/assets/esri/geometry/support/pe-wasm.wasm +0 -0
  51. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +14 -1
  52. package/assets/esri/themes/base/widgets/_SelectionList.scss +34 -0
  53. package/assets/esri/themes/base/widgets/_SelectionToolbar.scss +6 -0
  54. package/assets/esri/themes/dark/main.css +1 -1
  55. package/assets/esri/themes/light/main.css +1 -1
  56. package/assets/esri/themes/light/view.css +1 -1
  57. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
  58. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
  59. package/assets/esri/widgets/support/SelectionList/t9n/SelectionList.json +1 -1
  60. package/assets/esri/widgets/support/SelectionList/t9n/SelectionList_en.json +1 -1
  61. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar.json +1 -1
  62. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_en.json +1 -1
  63. package/chunks/Bufferer-CicaNej1.js +1 -1
  64. package/chunks/Distance2DCalculator-C1KHhZwD.js +1 -1
  65. package/chunks/Envelope.js +1 -1
  66. package/chunks/Envelope2D.js +1 -1
  67. package/chunks/GeodeticDistanceCalculator-CcF1gMZX.js +1 -1
  68. package/chunks/Geometry.js +1 -1
  69. package/chunks/GeometryCleaner-BEJM7I4l.js +1 -1
  70. package/chunks/OperatorClip.js +1 -1
  71. package/chunks/OperatorCrosses.js +1 -1
  72. package/chunks/OperatorCut.js +1 -1
  73. package/chunks/OperatorGeneralize.js +1 -1
  74. package/chunks/OperatorGeodesicBuffer.js +1 -1
  75. package/chunks/OperatorGeodeticArea.js +1 -1
  76. package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
  77. package/chunks/OperatorGeodeticDistance.js +1 -1
  78. package/chunks/OperatorGeodeticLength.js +1 -1
  79. package/chunks/OperatorIntersects.js +1 -1
  80. package/chunks/OperatorMultiPartToSinglePart.js +1 -1
  81. package/chunks/OperatorOverlaps.js +1 -1
  82. package/chunks/OperatorProximity.js +1 -1
  83. package/chunks/OperatorProximityGeodesic.js +1 -1
  84. package/chunks/OperatorShapePreservingLength.js +1 -1
  85. package/chunks/OperatorShapePreservingProject.js +1 -1
  86. package/chunks/OperatorSimplifyOGC.js +1 -1
  87. package/chunks/OperatorTouches.js +1 -1
  88. package/chunks/OperatorWithin.js +1 -1
  89. package/chunks/Point2D.js +1 -1
  90. package/chunks/ProjectionTransformation.js +1 -1
  91. package/chunks/QuadraticBezier.js +1 -1
  92. package/chunks/SideCalculator2D-BNwb5gvz.js +1 -1
  93. package/chunks/Transformation2D.js +1 -1
  94. package/chunks/containsOperator.js +1 -1
  95. package/chunks/disjointOperator.js +1 -1
  96. package/chunks/equalsOperator.js +1 -1
  97. package/chunks/pe-wasm.js +1 -1
  98. package/chunks/pe.js +1 -1
  99. package/geometry/coordinateFormatter.js +1 -1
  100. package/geometry/operators/extendOperator.js +1 -1
  101. package/geometry/operators/gx/operatorAlphaShape.js +1 -1
  102. package/geometry/operators/gx/operatorAutoComplete.js +1 -1
  103. package/geometry/operators/gx/operatorBuffer.js +1 -1
  104. package/geometry/operators/gx/operatorDifference.js +1 -1
  105. package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
  106. package/geometry/operators/gx/operatorIntegrate.js +1 -1
  107. package/geometry/operators/gx/operatorIntersection.js +1 -1
  108. package/geometry/operators/gx/operatorLabelPoint.js +1 -1
  109. package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
  110. package/geometry/operators/gx/operatorLocateBetween.js +1 -1
  111. package/geometry/operators/gx/operatorMinimumBoundingCircle.js +1 -1
  112. package/geometry/operators/gx/operatorOffset.js +1 -1
  113. package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
  114. package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
  115. package/geometry/operators/gx/operatorSimplify.js +1 -1
  116. package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
  117. package/geometry/operators/gx/operatorUnion.js +1 -1
  118. package/geometry/operators/isNearOperator.js +1 -1
  119. package/geometry/operators/json/containsOperator.js +1 -1
  120. package/geometry/operators/json/disjointOperator.js +1 -1
  121. package/geometry/operators/reshapeOperator.js +1 -1
  122. package/geometry/operators/support/apiConverter.js +1 -1
  123. package/geometry/operators/support/initNoPeFactory.js +1 -1
  124. package/geometry/operators/support/jsonConverter.js +1 -1
  125. package/geometry/support/WKIDUnitConversion.js +1 -1
  126. package/interfaces.d.ts +31 -0
  127. package/package.json +1 -1
  128. package/support/revision.js +1 -1
  129. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/utils.js +1 -1
  130. package/views/3d/interactive/Manipulator3D.js +1 -1
  131. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  132. package/views/3d/layers/DrapedSubView3D.js +1 -1
  133. package/views/3d/layers/I3SMeshView3D.js +1 -1
  134. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  135. package/views/3d/layers/MediaLayerView3D.js +1 -1
  136. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  137. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  138. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  139. package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
  140. package/views/3d/layers/graphics/pipeline/rendering/LodRenderer.js +1 -1
  141. package/views/3d/support/StreamTextureCollection.js +1 -1
  142. package/views/3d/support/TextureCollection.js +1 -1
  143. package/views/3d/webgl-engine/Stage.js +1 -1
  144. package/views/3d/webgl-engine/lib/ModelDirtySet.js +1 -1
  145. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  146. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  147. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  148. package/views/3d/webgl-engine/lib/WebGLLayer.js +1 -1
  149. package/views/3d/webgl-engine/parts/Model.js +1 -1
  150. package/widgets/Directions/css.js +5 -0
  151. package/widgets/Directions.js +1 -1
  152. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  153. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  154. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  155. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +5 -0
  156. package/widgets/OrientedImageryViewer/components/ImageMeasurementWidget.js +1 -1
  157. package/widgets/OrientedImageryViewer/css.js +1 -1
  158. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  159. package/widgets/OrientedImageryViewer/mixins/SketchHandlerMixin.js +1 -1
  160. package/widgets/OrientedImageryViewer/mixins/TriangulatedImageMeasurementMixin.js +5 -0
  161. package/widgets/OrientedImageryViewer/mixins/TriangulatedSketchHandlerMixin.js +5 -0
  162. package/widgets/OrientedImageryViewer.js +1 -1
  163. package/widgets/Sketch.js +1 -1
  164. package/widgets/support/SelectionList/LayerItem.js +1 -1
  165. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  166. package/widgets/support/SelectionList/VisibleElements.js +1 -1
  167. package/widgets/support/SelectionList.js +1 -1
  168. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
  169. package/widgets/support/SelectionToolbar/VisibleElements.js +5 -0
  170. package/widgets/support/SelectionToolbar.js +1 -1
  171. package/widgets/support/Selector2D/SelectionOperation.js +1 -1
  172. package/assets/esri/core/workers/chunks/11b55e7e76e50fe11bbe.js +0 -1
  173. package/assets/esri/core/workers/chunks/7bfa18dd8771d4932533.js +0 -1
  174. package/assets/esri/core/workers/chunks/84d7ed2cf5fe23a0888f.js +0 -1
  175. package/assets/esri/core/workers/chunks/86931186095c23e47c0c.js +0 -1
  176. package/assets/esri/core/workers/chunks/a79511b926a2830bb160.js +0 -1
  177. package/assets/esri/core/workers/chunks/e3ef0451dcdc2e966628.js +0 -1
  178. package/views/3d/webgl-engine/lib/ContentObject.js +0 -5
  179. package/views/3d/webgl-engine/lib/ContentObjectType.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{isSome as i,equals as a}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 l from"../../core/Evented.js";import{equalsShallow as c}from"../../core/lang.js";import h from"../../core/Logger.js";import{clamp as u,deg2rad as p}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as d}from"../../core/maybe.js";import g from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as f,waitTick as v}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{whenOnce as b,on as F,watch as _,syncAndInitial as P,initial as I}from"../../core/reactiveUtils.js";import{sqlAnd as M}from"../../core/sql.js";import{getMetersPerUnitForSR as S}from"../../core/unitUtils.js";import{property as C}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{distance as A}from"../../core/libs/gl-matrix-2/math/vec2.js";import{isSerializable as V}from"../../core/support/jsonUtils.js";import{UpdatingHandles as G}from"../../core/support/UpdatingHandles.js";import{union as R}from"../../geometry/geometryEngineAsync.js";import O from"../../geometry/Multipoint.js";import L from"../../geometry/Point.js";import x from"../../geometry/Polygon.js";import j from"../../geometry/Polyline.js";import{projectWithZConversion as E}from"../../geometry/projection.js";import z from"../../geometry/SpatialReference.js";import{isClockwise as B}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as D}from"../../geometry/support/webMercatorUtils.js";import H from"../../layers/GraphicsLayer.js";import{searchImages as T}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as N}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as U,computePolygonForInspection as W,resizePolygon as q,checkIfPolygonContainsSelectedPoint as $}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as J,isElevationSource as Z}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as K,imageToWorldPanoramic as Q}from"../../layers/orientedImagery/transformations/imageToWorld.js";import X from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Y}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as ee,convertPixelToHeadingPitch as te,getImageToWorldProperties as ie,getUpdateElevationProps as ae,isElevationSampler as re,getImageToWorldPanoramicProperties as se,pointToArray as oe,transformGraphicCoordinatesToPixel as ne,getWorldToImageProperties as le,convertHeadingPitchToSphereVertex as ce,or as he}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as ue,worldToImage as pe}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as me}from"../../layers/support/floorFilterUtils.js";import de from"../../symbols/SimpleLineSymbol.js";import ge from"../../views/draw/Draw.js";import{scale as ye}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as fe}from"../../views/input/InputManager.js";import ve from"../PanoramicViewer.js";import{invalidCameraHeading as we,sectorsInOrder as be,sectorsRadii as Fe}from"./constants.js";import{configureSketchTool as _e,extractFieldsFromDataCaptureLayer as Pe,isValidDataCaptureLayer as Ie,constructGraphicFromImageGeometry as Me}from"./dataCaptureUtils.js";import{isFeatureAttachment as Se,getImageSourceFromAttachment as Ce}from"./galleryUtils.js";import{formatPixels as ke,heightMeasurementPanoramic as Ae,heightMeasurement2D as Ve,calculateHeightAccuracyPanoramic as Ge,calculateHeightAccuracy as Re,pixelAreaMeasurement2D as Oe,pixelAreaMeasurementPanoramic as Le,pixelDistanceMeasurement2D as xe,pixelDistanceMeasurementPanoramic as je,generateCombinations as Ee,getRootOfSumOfSquaredErrors as ze,generateCombinationsPanoramic as Be,calculateLocationAccuracyFromDeviations as De,calculateReferenceImagePointPanoramic as He,calculateAnglePano as Te,calculateTempImagePoint as Ne,calculateAngle as Ue,getModeCorrectedPoint as We,calculateCorrectedPixel as qe,calculateHeightFromTemporaryDistance as $e}from"./imageMeasurementUtils.js";import{crossSymbol as Je,crossSymbol3D as Ze,measurementPolygonSymbol as Ke,polylineSymbolPanoramic as Qe,measurementPolylineSymbol as Xe,sourcePointSymbol as Ye,diamondSymbol as et,diamondSymbol3D as tt,locationSymbol as it,locationSymbol3D as at,activeSourcePointSymbol as rt}from"./symbols.js";import{isNoAttachmentError as st,getContentType as ot,isTifOrMrf as nt,filterOILLayerView as lt,assignElevationSampleToFeatures as ct,isSceneView as ht,isGraphic as ut,calculateSegment as pt,calculateDirection as mt}from"./utils.js";import dt from"./components/ImageViewer.js";import gt from"./components/NavigationNode.js";const yt={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles",sketchHandles:"sketch-handles"},ft=new Set(["JPG","JPEG"]),vt=/\.(\w+)$/,wt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first"),bt=5;let Ft=class extends(l.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.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:a,selectedPoint:r,view:s}=this;if(s?.closePopup(),a&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(i),await this._loadImage(i)}catch(o){y(o)||(this.loadImageError(o),h.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},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.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,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.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.draw=null,this.sketchAdapter=null,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new dt,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._overlays=new H({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new ve,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:i}=await t;return f(e),this.sketchAdapter=new i({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.afterNavigate=async(e,t,i)=>this.selectBestFeature(t.id,i).then((i=>(this._panoramicViewer.yaw=e.currentHeading-t.heading,this._panoramicViewer.pitch=e.currentPitch-t.pitch,i))),this.queryAndProcessNavigationNode=async(e,t,i)=>{const{layer:a,layerFloorFilterClause:r}=this;if(!a)return null;const{currentHeading:s,currentPitch:o}=e,{attributes:{farDistance:n},geometry:l}=t,{x:c,y:h,spatialReference:u}=l,m=u.isGeographic?1:S(u),d=n/(bt*m),g=d*Math.sin(p(s))*Math.sin(p(o)),y=d*Math.sin(p(o))*Math.cos(p(s)),v=M("1=1",M(a.definitionExpression,r)),w=new L(c+g,h+y,u);this.selectedPoint=w;const b=await T({layerInstanceOrURL:a,point:w,queryParams:{where:v,maximumDistance:a.maximumDistance?a.maximumDistance/m:void 0}},i);return f(i),await this._processFeatureResponse(b,w,{loadBestImage:!1,signal:i?.signal}),f(i),this.afterNavigate(e,t)},this.navigate=async(e,t)=>{const{currentNode:i}=this;if(!i)return null;const a=this.currentNode?.[e];if(!a)return null;const r=this._suitabilities.find((e=>e.feature.attributes.objectId===a.id)),s=this._featureToSector[`${a.id}`],[o,n]=s.split("_"),l=`NEAR_${n}`,c=`FAR_${n}`,h=this._activeSectors?.includes(l),u=this._activeSectors?.includes(c);return r&&(n===s&&!h&&!u||s===l&&!u||s===c)?this.queryAndProcessNavigationNode(i,a,t):this.afterNavigate(i,a,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(f(t),this.currentBestFeature=this.features?.find((({attributes:t})=>`${t.objectId}`==`${e}`)),b((()=>"image-loaded"===this.state),t)),this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r((async e=>{const{currentBestFeature:i,popupEnabled:a,layer:r,view:s}=this;if(s?.closePopup(),!(s&&i&&a&&r))return;const{attributes:o,geometry:n}=i,l=new t({geometry:n,attributes:o.toJSON(),layer:r});f(e),await s.openPopup({features:[l],location:o.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(yt.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,fe.WIDGET),yt.click)},this._createImageClickHandle=()=>{this.removeHandles(yt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:i,currentBestFeature:a,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&a))return;i.clickAction="pixel-location";let n=null;const l=F((()=>i),"pixel-location",(e=>{this.plotReferencePointOnImage(e),n?.abort(),n=r((async i=>{if(!e)return;const r=await this.getMapPoint(e,{feature:a,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return he(!t,e.spatialReference.equals(t))?e:E(e,t)}));f(i),this.plotReferencePointOnGround(r)}))}));this.addHandles(l,yt.imageClick)},this._createImageLocationHandle=()=>{this.removeHandles(yt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:i,currentBestFeature:a,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&a))return;i.clickAction="pixel-location";let n=null;const l=F((()=>i),"pixel-location",(e=>{this.pixelCoordinates=e,this.plotLocationPointOnImage(e),n?.abort(),n=r((async i=>{if(!e)return;let r=await this.getMapPoint(e,{feature:a,imageSize:o,mode:t});f(i);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await E(r,s),f(i)),this.groundCoordinates=r;const n=await this.calculateLocationAccuracy(e,r,t,i);f(i),n&&(this.groundCoordinatesAccuracy=n)}))}));this.addHandles(l,yt.imageClick)},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:a}=this;if(this.clearGraphics(),!i||!t||"none"===a)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:u,cameraOrientation:p,location:m}=r,d=(l??0)+(o??0),g=m.spatialReference.isWGS84&&4!==p?.type?D(m):new L(m);let v=s;if(Se(s))try{v=await Ce(i,u,e)}catch(w){if(y(w))return;return st(w)?(h.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${i.objectIdField}: ${u}`)):(h.getLogger(this).error(w,{[i.objectIdField]:u,layer:i}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${i.objectIdField} ${u}`))}try{await this.loadImageFromSource(v,{imageRotation:d,options:e,pitch:c,yaw:n,mode:a,cameraLocation:g}),f(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:i,imageRotation:a,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(vt)?.[1]:e.datasetFormat;if(!c)try{c=await ot(o,{...t.options})}catch(u){y(u)||h.getLogger(this).error("#getContentType()",u)}switch(c??="UNKNOWN FORMAT",i){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:o.split("?")[0]},this._imageViewer.customParameters=Object.fromEntries(l),this._imageViewer.imageRotation=a??0,await this._imageViewer.loadImage(r);break;case"panoramic":if(ft.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:i,yaw:a,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=a??0;"number"==typeof n?l=n-l:s&&e&&(l=await ee(s,e)-l),this._panoramicViewer.pitch=i??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");f(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");f(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._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r((async t=>{const{pointerType:i,button:a,mapPoint:r}=e;if(("mouse"!==i||0===a)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,i)=>{if(await v(i),!e)return;const a=new L({...V(e)?e.toJSON():e});if("default"===this.mode)a.x-=.5,a.y=.5-a.y,a.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:a,symbol:Je}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=te(e,a,r),n=ce(s,o);this._crossSymbol=new t({geometry:new L(n,z.WebMercator),symbol:Ze}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this)}initialize(){this.addHandles([_((()=>this.view),(()=>{this.load()}),P),_((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),I),_((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),I),_((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),P),_((()=>[this.state,this.imageLocationToolState,this.view]),(()=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();this._setMeasurementCursor()}),P),_((()=>this.measureType),(()=>{this.clearPreviousMeasurements()}),P),_((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),P),_((()=>this.currentBestFeature),(async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r((async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}]))),await this._featureChangedTask.promise}),{sync:!0}),_((()=>this.mode),(e=>{switch(this.removeHandles(yt.interactionHandles),e){case"default":this.addHandles(_((()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null}),(e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{...P,equals:(e,t)=>a(e,t,c)}),yt.interactionHandles);break;case"panoramic":this.addHandles(_((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:i,vfov:a,hfov:r,pitch:s,yaw:o}=this._panoramicViewer;return e&&i&&!t.includes("loading")?[a,r,o,s]:null}),(e=>{if(!e||this.state.includes("loading"))return;const[t,i,a,s]=e;this.currentNode&&(this.currentNode.currentHeading=a+(this.currentNode.heading??0),this.currentNode.currentPitch=s+(this.currentNode.pitch??0)),m(this._updateFootprintTask),this._updateFootprintTask=r((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:a,pitch:s},{signal:e})}))}),{...P,equals:(e,t)=>a(e,t,c)}),yt.interactionHandles)}}),P),_((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:a,sharpness:r}=this;"default"===a&&(e.brightness=t,e.contrast=i,e.sharpness=r)}),P),_((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)})),F((()=>this.features),"change",(()=>{this.navigationNodes.removeAll(),this.features.forEach((e=>{const t=new gt({geometry:e.geometry,attributes:e.attributes});this.navigationNodes.add(t)}))}))]),this.when().finally((()=>{this.notifyChange("state")}))}destroy(){this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=d(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._crossSymbol=d(this._crossSymbol),this._referencePointOnGround=d(this._referencePointOnGround),this._referencePointOnImage=d(this._referencePointOnImage),this._locationPointOnImage=d(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.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:i}=this;switch(i){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",u(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",u(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 nt(t)||Se(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===we}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(lt(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?me(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:i}=e;return 360===t||i?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?be.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",u(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:i},_featureChangedTask:a}=this;if(t)return"disabled";if(!this.isFulfilled()||i||!1===a?.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}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:a}})=>{const r=e?.trim();return nt(r)||Se(r)?{url:r,objectId:t,rotation:(i??0)+(a??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new H({elevationInfo:{mode:"absolute-height"}});case"default":return new H;case"none":return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}get _activeSectors(){return be.filter((e=>this._sectorData?.[e]?.length))}async computeHeight(e,t,i=!0){const{currentBestFeature:a,activeViewer:r,layer:s,footprintExtent:o}=this,n=r?.imageSize,l=a?.attributes,c=s?.orientationAccuracy;if(!l||!n||!e||e.length<2||!c)return;const h="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ie(l,n[0],n[1]),u=e.at(0),p=e.at(-1);if(!(h&&u&&p&&c&&o))return;const m=[p,u],d=ke(m,!1),g="panoramic"===t?await Ae(m,h,c,a,!0,!1):await Ve(m,h,c,!0,i);if(!g)return;const y="panoramic"===t?await Ge(c,d,h,g,a,!0):await Re(c,d,h,g,!0);return y?{value:g,accuracy:y}:{value:g}}async calculateAreaMeasurement(e,t,i){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const a="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(i),a?"default"===t?await Oe(e,a,!0):await Le(e,a,!0,i):null}async calculateDistanceMeasurement(e,t,i){const{currentBestFeature:a,activeViewer:r}=this;if(e.length<2||!a||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(i),s?"default"===t?await xe([e.at(0),e.at(-1)],s,!0):await je([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,i){const{layer:a,currentBestFeature:r,activeViewer:s}=this,o=a?.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;const l=await this.getMeasurementProperties();if(f(i),!l)return null;const c="area"===t?await Oe(e,l,!0):await xe([e.at(0),e.at(-1)],l,!0);f(i);const{updateElevationProps:h,...u}=l,p=Ee(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async a=>{const r="area"===t?await Oe(e,a,!0):await xe([e.at(0),e.at(-1)],a,!0);if(f(i),r&&c){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-c.area):null}return Math.abs(r-c)}return null})),d=await Promise.all(m);f(i);const g=d.filter((e=>null!==e));return 0===g.length?null:ze(g)}async calculateLocationAccuracy(e,t,i="default",a){const{layer:r,currentBestFeature:s}=this,o=r?.orientationAccuracy,n=this.view?.spatialReference,l=o?.every((e=>0===e))||!o?.length;if(!s||l)return null;const c="default"===i?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();if(f(a),!c)return null;const{updateElevationProps:h,...u}=c,p="default"===i?Ee(u,o):Be(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async r=>{const{updateElevationProps:s,...o}=r;let l="default"===i?await K(e,o,s):await Q(e,o,s);return f(a),n&&!l.spatialReference.equals(n)&&(l=await E(l,n),f(a)),l&&t?[Math.abs(l.x-t.x),Math.abs(l.y-t.y),l.z&&t.z?Math.abs(l.z-t.z):0]:null})),d=await Promise.all(m);if(f(a),!d?.length)return null;const g=d.map((e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0])),[y,v,w]=De(g);return{x:y,y:v,z:w}}async calculateAccuracyPanoramic(e,t,i){const{layer:a,currentBestFeature:r,activeViewer:s,mode:o}=this,n=a?.orientationAccuracy,l=n?.every((e=>0===e))||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||l||"panoramic"!==o)return null;const c=await this.getMeasurementPropertiesPanoramic();if(f(i),!c)return null;const h="area"===t?await Le(e,c,!0):await je([e.at(0),e.at(-1)],c,!0);f(i);const{updateElevationProps:u,...p}=c,m=Be(p,n);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async a=>{const r="area"===t?await Le(e,a,!0):await je([e.at(0),e.at(-1)],a,!0);if(f(i),r&&h){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-h.area):null}return Math.abs(r-h)}return null})),g=await Promise.all(d);f(i);const y=g.filter((e=>null!==e));return 0===y.length?null:ze(y)}async calculateHeightMeasurementInfo(e,t,i){const{currentBestFeature:a,activeViewer:r}=this,s=r?.imageSize;if(!a||!r||!s?.length||"none"===t)return;const{attributes:o}=a,[n]=ke([e],"panoramic"!==t),l="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ie(o,s[0],s[1]);if("panoramic"===t){if(!l)return;const e=await He(n,l,a,i);if(!e)return;e?.heading>180&&(e.heading-=360);const t=Te(n,e),r=A([n.x,n.y],[e.x,e.y]);if(!t||!r)return;return{measurementAngle:t,tempDistance:r}}const c=await Ne(n,l,i);if(!c)return;const h=Ue(n,c),u=A([n.x,n.y],[c.x,c.y]);return h&&u?{measurementAngle:h,tempDistance:u}:void 0}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)}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:i,dataCaptureLayer:a}=this;if(!i)throw wt();_e(a,e,i),await i.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw wt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw wt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw wt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw wt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw wt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw wt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:i,mode:a}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(i,a);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t){const i=[],a=[],r=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:o}=e;let n;const l=S(e.geometry.spatialReference);o.cameraHeight/=l,o.farDistance/=l,o.nearDistance/=l,J(o.elevationSource)&&(o.elevationSource.constantElevation/=l);const{polygon:c,frustum:h}=U(o);if(n=c.clone(),o.isInspection&&(n=W(o)),s&&(n=q(n,s)),!t||$(n,t)){r.push(e);const{geometry:t,objectId:s,cameraHeight:n,cameraHeading:l}=o,u=t.clone();u.z=n,u.imageID=s,this.pointSources.push(u),l!==we&&(i.push(c),h&&a.push(h))}})),{features:r,polygons:i,frustums:a}}getMeasurementProperties(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:i,attributes:a}=e,{elevationSource:r,cameraHeight:s}=a,o=ie(a,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?E(n,z.WebMercator):Promise.resolve(n)).then((e=>(n=e,ae((n.z??0)-s,{elevationSample:i,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&re(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:i,attributes:a}=e,{elevationSource:r,cameraHeight:s}=a,o=se(a,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?E(n,z.WebMercator):Promise.resolve(n)).then((e=>(n=e,ae((n.z??0)-s,{elevationSample:i,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&re(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?.[be[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const a=this._sectorData?.[t];a?.length&&this._updateCurrentBestFeature(a.at(i))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:i,heightMeasurementPixels:a,mode:r,activeViewer:s}=this,o=s?.imageSize;if(!e.vertices||!o)return;const n=We(e.vertices.at(-1),r,o);if(a.length<1||!n||!i||!t||"none"===r)return;const l=qe(a[0],n,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const c=$e(this.heightMeasurementPixels,i);c&&(this.heightMeasurementResult=c)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:i,activeViewer:a,heightMeasurementPixels:r,mode:s}=this;if(!i||!a||!e.vertices?.length||"none"===s)return;const o=a?.imageSize;if(!r.length&&o){const i=We(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(i);const a=await this.calculateHeightMeasurementInfo(i,s,t);if(!a?.measurementAngle||!a?.tempDistance)return;this.measurementAngle=a.measurementAngle,this.tempDistance=a.tempDistance}}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.imageLocationToolState=!1,this.selectedPoint=e.spatialReference.isGeographic?D(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),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:i}=await t;f(e),this.sketch=new i({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:i}=await t;if(f(e),this.sketchAdapter=new i({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async startMeasurement(e,t){await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:i,sketchAdapter:a,activeViewer:r,mode:s}=this;if(!i||!a||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(i.defaultCreateOptions.defaultZ=0),await i.create(e),"panoramic"===s){const{drawOperation:e}=i.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=Ke(o),this.sketch.polylineSymbol="panoramic"===s?Qe:Xe(o))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new ge({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)],i=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[e],spatialReference:i});else{const a=new j({paths:[e],spatialReference:i}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:a,symbol:Xe(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,i=this.activeViewer?.imageSize;if(!i)return;const a={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}=te(a,i[0],i[1]),{heading:n,pitch:l}=te(r,i[0],i[1]),c=[[...ce(s,o)],[...ce(n,l)]];if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[c],spatialReference:e});else{const i=new j({paths:[c],spatialReference:e});this.heightGraphic=new t({geometry:i,symbol:Qe}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}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:i,currentBestFeature:a,overlayedCameraLocations:r,layer:s,mode:o,state:n}=this,l=i?.imageSize;if(!l||!a||!s||"none"===o||n.includes("loading"))return;const{polygon:c}=U(a.attributes);if(i.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:`${s.objectIdField} <> ${a.attributes.objectId}`,geometry:c,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:i,geometry:r}=e,s=await this.getPixels(r,{feature:a,imageSize:l,mode:o}),n=Ye.clone();return n.outline=new de({color:[0,0,0],width:1}),new t({attributes:i,symbol:n,geometry:s})})));r.addMany(n),i.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:l,layer:c}=this,u=r?.imageSize;if(!u||!o||"none"===n||l.includes("loading")||!c)return;const{polygon:p}=U(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=Pe(e,c.imageGeometryField,c.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(g){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:p,returnGeometry:!0,outFields:["*"]}),d=new s((await Promise.all(m.map((async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:l}=i,c=l,{imageGeometryField:p,oiObjectIdField:m}=this;if(p&&m&&Ie(e,p,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Me(s,p,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(c?.type){case"point":{const i=await this.getPixels(c,{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:l}=c,h=i.map((e=>e.map((([e,t,i])=>new L({x:e,y:t,z:i,spatialReference:l}))))),p=await Promise.all(h.map((async e=>this.getPixels(e,{feature:o,imageSize:u,mode:n}).then((e=>e.map(oe))))));return new t({attributes:s,layer:e,symbol:r,geometry:new x({rings:p,spatialReference:z.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:l}=c,h=i.map((e=>e.map((([e,t,i])=>new L({x:e,y:t,z:i,spatialReference:l}))))),p=await Promise.all(h.map((async e=>this.getPixels(e,{feature:o,imageSize:u,mode:n}).then((e=>e.map(oe))))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({paths:p,spatialReference:z.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:l}=c,h=i.map((([e,t,i])=>new L({x:e,y:t,z:i,spatialReference:l}))),p=await this.getPixels(h,{feature:o,imageSize:u,mode:n}).then((e=>e.map(oe)));return new t({attributes:s,layer:e,symbol:r,geometry:new O({points:p,spatialReference:z.WebMercator}),visible:e.visible&&a})}}return null})))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,d)}async getPixels(e,t){const{imageSize:i,mode:a}=t,r=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===a)return new L({x:e.x-.5,y:.5-e.y,spatialReference:z.WebMercator});const[t,r]=i,{heading:s,pitch:o}=te(e,t,r),n=ce(s,o);return new L(n,z.WebMercator)}));return Array.isArray(e)?r:r[0]}async getMapPoint(e,t){const{feature:i,mode:a,imageSize:r}=t,{elevationSample:s,attributes:o}=i,{elevationSource:n,location:l,elevation:c,cameraHeight:h}=o;let u=l.clone();u.spatialReference.isGeographic&&(u=await E(u,z.WebMercator));const p=await ae(c??(l.z??0)-h,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let m;if("elevationSample"in p&&re(p.elevationSample)&&(i.elevationSample=p.elevationSample),"default"===a){const t=ie(o,r[0],r[1]);m=await K(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}else{const t=se(o,r[0],r[1]);m=await Q(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}return Array.isArray(e)?m:m[0]}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 L({...e.toJSON()}),symbol:et}),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 i=V(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._referencePointOnImage=new t({geometry:new L({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:et}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=te(e,a,r),n=ce(s,o);this._referencePointOnImage=new t({geometry:new L(n,z.WebMercator),symbol:tt}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(),this.mode){case"default":this._plotLocationPointOnDefaultImage(e);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=m(this._clickTask)}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:i,savedGraphics:a}=t,r=i.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce(((t,{objectId:i,globalId:a,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(i&&(l[e.objectIdField]=i),a&&e.globalIdField&&(l[e.globalIdField]=a),t.success.push(n)),t}),{success:[],error:[]});a.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)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 l=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,l=r.hasZ,c=r.geometryType,h=n!==c,u=h?await import("./transformers.js"):null,p=u?.default[c],m=h?p?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(ne(s,m,o),{feature:a,imageSize:o,mode:s}),l||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map((async e=>this.getMapPoint(e.map((([e,t,i])=>ne(s,{x:e,y:t,z:i},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new x({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,rings:e.map((e=>e.map(oe)))}),t}case"polyline":{const e=await Promise.all(m.paths.map((async e=>this.getMapPoint(e.map((([e,t,i])=>ne(s,{x:e,y:t,z:i},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new j({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,paths:e.map((e=>e.map(oe)))}),t}}}))),c=l.filter(i);return r.applyEdits({addFeatures:c}).then((e=>{const{addFeatureResults:t}=e;let i=0;const a=l.map((e=>{const a=t[i++];return e?a:{error:new n("orientedimagery","Error in saving data capture features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:a}}))}async searchBestImage(e,t){try{const i=await T(e,t);i&&await this._processFeatureResponse(i,e.point,t)}catch(i){y(i)||(this.setMessage("imageLoadError","error",i.message),h.getLogger(this).error("error occurred while finding best image",i))}}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}async startDataCapture(e,t){const i=this.activeViewer?.imageRenderer,{oiObjectIdField:a,currentBestFeature:r}=this;if(!i||!r||!a)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(a)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);f(t),h.layer.addMany(l),h.layer.blendMode="source-atop",u.savedGraphics.addMany(l);i.ui.find("zoom").visible=!1,i.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=d(this.sketchAdapter),this.sketch=d(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,i=this.activeViewer?.imageRenderer;if(!i||i.destroyed)return;i.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const a=i.ui.find("zoom");a&&(a.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 i=this.overlayedMapFeatures.get(e);i&&this._toggleVisiblity(i,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e;let a=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await E(t,s.spatialReference);a=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await E(t,s.spatialReference);r=s.extent.contains(e);break}}if(!a&&!r)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,i);if(o)return f(i),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}updateSuitabilities(e,t=!0){e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const i=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(i,t),this._groupFeaturesBySectors()}async _fetchFeatures(e,t){if(!this.view)return;const i=this.layer;if(i){const a={include:i},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,a);return this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(y(i))return;this.setMessage("imageLoadError","error"),h.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:i,features:a,invalidCameraHeading:r}=this;if(!e||!t||!i||!a||r)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const u of be)this._sectorData[u]=new s;const n=e.map(((e,t)=>({...e,featureIndex:t})));n.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const l=n.map((({distance:e})=>e)),c=Math.max(...l),h=a.reduce(((e,t)=>Math.max(e,t.attributes.location.z??0)),-1/0);n.forEach((e=>{const{distance:t,angle:i,featureIndex:r}=e,s=t/c*Fe[2],n=pt(t,c),l=mt(i);if(!this._sectorData)return;const u=Fe[3]+s*Math.sin(i*Math.PI/180),p=Fe[3]+s*Math.cos(i*Math.PI/180);let m;const d=a.at(r),g=(d.attributes.location.z??0)/h*Fe[2],y=d===this.currentBestFeature,f=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(y&&f)m=-90;else{const e=u-Fe[3],t=p-Fe[3],i=t/Math.sqrt(e**2+t**2);let a=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(a*=-1),m=a}const v=""===n?l:`${n}_${l}`;y&&(m===this.bestFeatureAngle?this.previousFeatureAngle=m:this.bestFeatureAngle=m,this.navigatorCurrentBestFeature=f?null:{x:u,y:p,direction:l}),o[`${d.attributes.objectId}`]=v;const w=this._sectorData[v];w.add({angle:i,featureIndex:r,x:u,y:p,z:g,objectID:d.attributes.objectId,sector:v,featureIndexInSector:w.length})}))}_plotLocationPointOnDefaultImage(e){const i=V(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._locationPointOnImage=new t({geometry:new L({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:it}),this._imageViewer.addGraphic(this._locationPointOnImage,0)}_plotLocationPointOnPanoramicImage(e){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=te(e,a,r),n=ce(s,o);this._locationPointOnImage=new t({geometry:new L(n,z.WebMercator),symbol:at}),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,i){if(!e[0])return;const a=await R(e);if(this._updateFootprintWithFeatures(t,a),this.view?.supportsGround)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(r){y(r)||h.getLogger(this).error(r)}}async processElevationSample(e,t,i){const{elevationSource:a}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,i);return r||(a&&this.footprintExtent&&Z(a)?await Y({extent:this.footprintExtent,lod:a.lod,url:a.url,rasterFunction:a.rasterFunction}):void 0)}async _processFeatureResponse(e,t,i){const{features:a}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(a))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(a,t);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,i);f(i),await this._updateElevationOfSelectedPointAndLocations(r,t,n),f(i),ct(r,n),this._processSuitableFeatures(r,t),this._updateSuitabilities(i?.loadBestImage)}_processSuitableFeatures(e,t){this._suitabilities=N({features:e,selectedPoint:t,camera:ht(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,i){const{screenPoint:a,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(a);if(!o)return;const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await E(o,e.spatialReference),c=l.spatialReference.isGeographic?D(l):l,h=M("1=1",M(e.definitionExpression,n)),u=c.spatialReference.isGeographic?1:S(c.spatialReference),p={layerInstanceOrURL:e,point:c,queryParams:{where:h,maximumDistance:e.maximumDistance?e.maximumDistance/u:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(p,i)}_resetCursor(){const{activeViewer:e}=this;e&&(e.imageRenderer.cursor=this._previousCursor)}_setMeasurementCursor(){const{activeViewer:e}=this;e&&(this._previousCursor=e.imageRenderer.cursor,e.imageRenderer.cursor="crosshair")}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}async _updateElevationOfSelectedPointAndLocations(e,t,i,a){const r=re(i),s=await ae((e[0].attributes.location.z??0)-e[0].attributes.cameraHeight,{elevationSample:r?i:void 0,elevationSource:r?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},a);f(a);const[o,...n]=await X([t,...e.map((e=>e.attributes.geometry.clone()))],s);f(a),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),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0])}_updateFootprintWithFeatures(e,t){const i=[];for(const{geometry:a}of e)t.contains(a)||i.push([a.x,a.y]);i.sort(((e,t)=>+B([e,t]))),t.addRing(i),this.footprintExtent=ye(t.extent,2,2)}_updateSuitabilities(e){const{_suitabilities:t}=this;t&&this.updateSuitabilities(t,e)}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:a,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s}=this;if(a&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),f(e);for(const e of i)e.imageID===a.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:rt,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:Ye,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-Fe[3],a=e.y-Fe[3],r=a/Math.sqrt(t**2+a**2);let s=180*Math.acos(r)/Math.PI;(t<0&&a<0||t<0&&a>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=d(this._referencePointOnImage))}clearLocationPointOnImage(){this._locationPointOnImage&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=d(this._locationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,a){this.displayMessage={key:e,type:t,data:i,map:a}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:i,selectedPoint:a,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=d(this._crossSymbol)),!a||!t||"image-loaded"!==r?.state||i)return;let s;try{s=await this.worldToImage(a,e),f(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:a,feature:t})}}async worldToImage(e,t){const{footprintExtent:i}=this,{imageSize:a}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!a||!i)return;const{attributes:{location:r,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:l},elevationSample:c}=this.currentBestFeature;let h=r.clone();const u=await ae(n??(r.z??0)-l,{elevationSample:c,elevationSource:s});this.currentBestFeature.elevationSample=u.elevationSample;const p=Array.isArray(e)?e:[e];let m,d=await Promise.all(p.map((e=>new Promise((t=>{if(!e.hasZ)return t(X(e,u));t(e)})))));if(r.spatialReference.isGeographic&&(h=await E(h,z.WebMercator,t)),d=await Promise.all(d.map((async e=>h.spatialReference.equals(e.spatialReference)?e:await E(e,h.spatialReference,t)))),f(t),"panoramic"===this.mode)m=ue(d,{imageHeight:a[1],imageWidth:a[0],cameraHeading:o,cameraLocation:h});else{const e=le(this.currentBestFeature.attributes,a[0],a[1]);m=pe(d,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:a,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:h}=this,{attributes:{objectId:u},elevationSample:p}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...a,s].filter(ut);l.supportsGround&&p&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e,p),"panoramic"===h&&c.updateGroundElevation([this.bestFeatureCurrentFootprint],p)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:Je.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&p&&c?.updateGroundElevation&&"panoramic"===h&&c.updateGroundElevation([e],p),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([C()],Ft.prototype,"activeLayer",null),e([C({readOnly:!0})],Ft.prototype,"activeViewer",null),e([C()],Ft.prototype,"accuracyParametersMissing",null),e([C()],Ft.prototype,"additionalFeatures",void 0),e([C({type:s.ofType(t)})],Ft.prototype,"additionalCameraLocations",void 0),e([C({type:s.ofType(t)})],Ft.prototype,"additionalFootprints",void 0),e([C()],Ft.prototype,"areaMeasurementResult",void 0),e([C()],Ft.prototype,"areaMeasurementAccuracy",void 0),e([C()],Ft.prototype,"bestFeatureAngle",void 0),e([C()],Ft.prototype,"bestFeatureCurrentFootprint",void 0),e([C({type:t})],Ft.prototype,"bestFeatureFootprint",void 0),e([C({type:Number})],Ft.prototype,"brightness",null),e([C()],Ft.prototype,"collectionId",void 0),e([C({type:Number})],Ft.prototype,"contrast",null),e([C()],Ft.prototype,"conversionProps",void 0),e([C()],Ft.prototype,"coverageFrustums",void 0),e([C()],Ft.prototype,"coveragePolygons",void 0),e([C()],Ft.prototype,"currentBestFeature",void 0),e([C()],Ft.prototype,"currentBestFeatureLocation",void 0),e([C()],Ft.prototype,"currentCoverageVisible",void 0),e([C()],Ft.prototype,"currentNode",null),e([C()],Ft.prototype,"navigationNodes",void 0),e([C({json:{write:!1}})],Ft.prototype,"determineWorkflowForFeature",void 0),e([C()],Ft.prototype,"disabled",void 0),e([C()],Ft.prototype,"displayMessage",void 0),e([C()],Ft.prototype,"displayNewMeasurementButton",void 0),e([C()],Ft.prototype,"distanceMeasurementResult",void 0),e([C()],Ft.prototype,"distanceAccuracyArray",void 0),e([C()],Ft.prototype,"dataCaptureLayer",void 0),e([C({readOnly:!0})],Ft.prototype,"featureCount",null),e([C()],Ft.prototype,"features",void 0),e([C()],Ft.prototype,"groundCoordinates",void 0),e([C()],Ft.prototype,"groundCoordinatesAccuracy",void 0),e([C()],Ft.prototype,"heightMeasurementPixels",void 0),e([C()],Ft.prototype,"heightGraphic",void 0),e([C()],Ft.prototype,"heightMeasurementResult",void 0),e([C()],Ft.prototype,"heightMeasurementAccuracy",void 0),e([C()],Ft.prototype,"measurementAngle",void 0),e([C()],Ft.prototype,"tempDistance",void 0),e([C({readOnly:!0})],Ft.prototype,"imageGalleryEnabled",null),e([C()],Ft.prototype,"imageGeometryField",void 0),e([C({readOnly:!0})],Ft.prototype,"imageLoaded",null),e([C()],Ft.prototype,"imageLocationToolState",void 0),e([C({readOnly:!0})],Ft.prototype,"invalidCameraHeading",null),e([C()],Ft.prototype,"imagePointsInView",null),e([C()],Ft.prototype,"isAdditionalCoverageVisible",void 0),e([C()],Ft.prototype,"isAdditionalPointSourcesVisible",void 0),e([C()],Ft.prototype,"layer",void 0),e([C()],Ft.prototype,"layerView",null),e([C({readOnly:!0})],Ft.prototype,"layerFloorFilterClause",null),e([C({type:Number})],Ft.prototype,"localPort",void 0),e([C()],Ft.prototype,"mapImageConversionToolState",void 0),e([C()],Ft.prototype,"measureType",void 0),e([C()],Ft.prototype,"measurementGraphic",void 0),e([C({readOnly:!0,value:"none"})],Ft.prototype,"mode",null),e([C()],Ft.prototype,"navigatorCurrentBestFeature",void 0),e([C()],Ft.prototype,"oiObjectIdField",void 0),e([C({type:s.ofType(t)})],Ft.prototype,"overlayedCameraLocations",void 0),e([C()],Ft.prototype,"overlayedMapFeatures",void 0),e([C()],Ft.prototype,"pixelCoordinates",void 0),e([C()],Ft.prototype,"pointSources",void 0),e([C({readOnly:!0})],Ft.prototype,"popupEnabled",null),e([C()],Ft.prototype,"previousFeatureAngle",void 0),e([C()],Ft.prototype,"referencePoint",null),e([C({readOnly:!0})],Ft.prototype,"sectorData",null),e([C()],Ft.prototype,"selectedPoint",void 0),e([C({type:Number})],Ft.prototype,"sharpness",null),e([C()],Ft.prototype,"shouldShowSelectedImage",void 0),e([C()],Ft.prototype,"sketch",void 0),e([C()],Ft.prototype,"draw",void 0),e([C()],Ft.prototype,"sketchAdapter",void 0),e([C({readOnly:!0})],Ft.prototype,"sketchGraphicsLayer",null),e([C({readOnly:!0})],Ft.prototype,"state",null),e([C({readOnly:!0})],Ft.prototype,"thumbnails",null),e([C()],Ft.prototype,"updateFootprint",void 0),e([C()],Ft.prototype,"updateFootprintPanorama",void 0),e([C({value:null})],Ft.prototype,"view",null),e([C()],Ft.prototype,"_adapter",void 0),e([C()],Ft.prototype,"_sketchGraphicsLayer",null),e([C()],Ft.prototype,"_highlightedFeatureHandle",void 0),e([C()],Ft.prototype,"_imageViewer",void 0),e([C()],Ft.prototype,"_initialCurrentCoverageUpdate",void 0),e([C()],Ft.prototype,"_locationPointOnImage",void 0),e([C()],Ft.prototype,"_overlays",void 0),e([C({readOnly:!0})],Ft.prototype,"_overlaysView",null),e([C()],Ft.prototype,"_panoramicViewer",void 0),e([C()],Ft.prototype,"_previousCursor",void 0),e([C()],Ft.prototype,"_referencePointOnGround",void 0),e([C()],Ft.prototype,"_referencePointOnImage",void 0),e([C()],Ft.prototype,"_sectorData",void 0),e([C()],Ft.prototype,"_featureToSector",void 0),e([C()],Ft.prototype,"_activeSectors",null),e([C({readOnly:!0})],Ft.prototype,"_updatingHandles",void 0),e([C()],Ft.prototype,"footprintExtent",void 0),e([C()],Ft.prototype,"_featureChangedTask",void 0),Ft=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],Ft);const _t=Ft;export{_t as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{isSome as a,equals as r}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as n}from"../../core/deprecate.js";import o from"../../core/Error.js";import c from"../../core/Evented.js";import{equalsShallow as l}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as h,deg2rad as m}from"../../core/mathUtils.js";import{abortMaybe as p,destroyMaybe as d}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 b,on as F,watch as _,syncAndInitial as M,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as S}from"../../core/unitUtils.js";import{property as k}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as A}from"../../core/accessorSupport/decorators/subclass.js";import{distance as C}from"../../core/libs/gl-matrix-2/math/vec2.js";import{isSerializable as V}from"../../core/support/jsonUtils.js";import{UpdatingHandles as G}from"../../core/support/UpdatingHandles.js";import{union as R}from"../../geometry/geometryEngineAsync.js";import L from"../../geometry/Multipoint.js";import O from"../../geometry/Point.js";import T from"../../geometry/Polygon.js";import j from"../../geometry/Polyline.js";import{projectWithZConversion as x}from"../../geometry/projection.js";import B from"../../geometry/SpatialReference.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as z}from"../../geometry/support/webMercatorUtils.js";import D from"../../layers/GraphicsLayer.js";import{searchImages as H}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as N}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as U,computePolygonForInspection as W,resizePolygon as q,checkIfPolygonContainsSelectedPoint as $}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as J,isElevationSource as Z}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as K,imageToWorldPanoramic as Q}from"../../layers/orientedImagery/transformations/imageToWorld.js";import X from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Y}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as ee,convertPixelToHeadingPitch as te,getImageToWorldProperties as ae,getUpdateElevationProps as re,isElevationSampler as ie,getImageToWorldPanoramicProperties as se,pointToArray as ne,transformGraphicCoordinatesToPixel as oe,getWorldToImageProperties as ce,convertHeadingPitchToSphereVertex as le,or as ue}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as he,worldToImage as me}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as pe}from"../../layers/support/floorFilterUtils.js";import de from"../../symbols/SimpleLineSymbol.js";import ge from"../../views/draw/Draw.js";import{scale as ye}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ve}from"../../views/input/InputManager.js";import fe from"../PanoramicViewer.js";import{invalidCameraHeading as we,sectorsInOrder as be,sectorsRadii as Fe}from"./constants.js";import{configureSketchTool as _e,extractFieldsFromDataCaptureLayer as Me,isValidDataCaptureLayer as Pe,constructGraphicFromImageGeometry as Ie}from"./dataCaptureUtils.js";import{isFeatureAttachment as Se,getImageSourceFromAttachment as ke}from"./galleryUtils.js";import{formatPixels as Ae,heightMeasurementPanoramic as Ce,heightMeasurement2D as Ve,calculateHeightAccuracyPanoramic as Ge,calculateHeightAccuracy as Re,pixelAreaMeasurement2D as Le,pixelAreaMeasurementPanoramic as Oe,pixelDistanceMeasurement2D as Te,pixelDistanceMeasurementPanoramic as je,generateCombinations as xe,getRootOfSumOfSquaredErrors as Be,generateCombinationsPanoramic as Ee,calculateLocationAccuracyFromDeviations as ze,calculateReferenceImagePointPanoramic as De,calculateAnglePano as He,calculateTempImagePoint as Ne,calculateAngle as Ue,computeTriangulatedAreaMeasurement as We,computeTriangulatedDistanceMeasurement as qe,getModeCorrectedPoint as $e,calculateCorrectedPixel as Je,calculateHeightFromTemporaryDistance as Ze,computeTriangulatedVector as Ke}from"./imageMeasurementUtils.js";import{crossSymbol as Qe,crossSymbol3D as Xe,measurementPolygonSymbol as Ye,polylineSymbolPanoramic as et,measurementPolylineSymbol as tt,sourcePointSymbol as at,diamondSymbol as rt,diamondSymbol3D as it,locationSymbol as st,locationSymbol3D as nt,activeSourcePointSymbol as ot}from"./symbols.js";import{isNoAttachmentError as ct,getContentType as lt,isTifOrMrf as ut,filterOILLayerView as ht,assignElevationSampleToFeatures as mt,isSceneView as pt,isGraphic as dt,calculateSegment as gt,calculateDirection as yt}from"./utils.js";import vt from"./components/ImageViewer.js";import ft from"./components/NavigationNode.js";import wt from"../Sketch/SketchViewModel.js";const bt={click:"view-click",imageClick:"image-click",triangularImageClick:"triangular-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles",sketchHandles:"sketch-handles"},Ft=new Set(["JPG","JPEG"]),_t=/\.(\w+)$/,Mt=()=>new o("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first"),Pt=5;let It=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.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=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:r,selectedPoint:i,view:s}=this;if(s?.closePopup(),r&&i){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadImage(a)}catch(n){y(n)||(this.loadImageError(n),u.getLogger(this).error("#loadIImage()","error occured while loading image",n))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,a)=>{if(this.view?.closePopup(),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(a)}catch(r){y(r)||(this.loadImageError(r),u.getLogger(this).error("#loadIImage()","error occured while loading image",r))}},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.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.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new vt,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._overlays=new D({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new fe,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.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.afterNavigate=async(e,t,a)=>this.selectBestFeature(t.id,a).then((a=>(this._panoramicViewer.yaw=e.currentHeading-t.heading,this._panoramicViewer.pitch=e.currentPitch-t.pitch,a))),this.queryAndProcessNavigationNode=async(e,t,a)=>{const{layer:r,layerFloorFilterClause:i}=this;if(!r)return null;const{currentHeading:s,currentPitch:n}=e,{attributes:{farDistance:o},geometry:c}=t,{x:l,y:u,spatialReference:h}=c,p=h.isGeographic?1:S(h),d=o/(Pt*p),g=d*Math.sin(m(s))*Math.sin(m(n)),y=d*Math.sin(m(n))*Math.cos(m(s)),f=I("1=1",I(r.definitionExpression,i)),w=new O(l+g,u+y,h);this.selectedPoint=w;const b=await H({layerInstanceOrURL:r,point:w,queryParams:{where:f,maximumDistance:r.maximumDistance?r.maximumDistance/p:void 0}},a);return v(a),await this._processFeatureResponse(b,w,{loadBestImage:!1,signal:a?.signal}),v(a),this.afterNavigate(e,t)},this.navigate=async(e,t)=>{const{currentNode:a}=this;if(!a)return null;const r=this.currentNode?.[e];if(!r)return null;const i=this._suitabilities.find((e=>e.feature.attributes.objectId===r.id)),s=this._featureToSector[`${r.id}`],[n,o]=s.split("_"),c=`NEAR_${o}`,l=`FAR_${o}`,u=this._activeSectors?.includes(c),h=this._activeSectors?.includes(l);return i&&(o===s&&!u&&!h||s===c&&!h||s===l)?this.queryAndProcessNavigationNode(a,r,t):this.afterNavigate(a,r,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}`)),b((()=>"image-loaded"===this.state),t)),this.toggleImageAttributes=()=>{p(this._openPopupTask),this._openPopupTask=i((async e=>{const{currentBestFeature:a,popupEnabled:r,layer:i,view:s}=this;if(s?.closePopup(),!(s&&a&&r&&i))return;const{attributes:n,geometry:o}=a,c=new t({geometry:o,attributes:n.toJSON(),layer:i});v(e),await s.openPopup({features:[c],location:n.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(bt.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,ve.WIDGET),bt.click)},this._createImageClickHandle=()=>{this.removeHandles(bt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:r,footprintExtent:s}=this,n=a?.imageSize;if(!(e&&"none"!==t&&n&&s&&r))return;a.clickAction="pixel-location";let o=null;const c=F((()=>a),"pixel-location",(e=>{this.plotReferencePointOnImage(e),o?.abort(),o=i((async a=>{if(!e)return;const i=await this.getMapPoint(e,{feature:r,imageSize:n,mode:t}).then((e=>{const t=this.view?.spatialReference;return ue(!t,e.spatialReference.equals(t))?e:x(e,t)}));v(a),this.plotReferencePointOnGround(i)}))}));this.addHandles(c,bt.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(bt.triangularImageClick);const e=this.imageMeasurementViewer?.imageSize;this.triangularMeasurementActive&&"none"!==this.mode&&e&&this.currentBestFeature&&this.addHandles(this.imageMeasurementViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),bt.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(bt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:r,footprintExtent:s}=this,n=a?.imageSize;if(!(e&&"none"!==t&&n&&s&&r))return;a.clickAction="pixel-location";let o=null;const c=F((()=>a),"pixel-location",(e=>{this.pixelCoordinates=e,this.plotLocationPointOnImage(e),o?.abort(),o=i((async a=>{if(!e)return;let i=await this.getMapPoint(e,{feature:r,imageSize:n,mode:t});v(a);const s=this.view?.spatialReference;s&&!i.spatialReference.equals(s)&&(i=await x(i,s),v(a)),this.groundCoordinates=i;const o=await this.calculateLocationAccuracy(e,i,t,a);v(a),o&&(this.groundCoordinatesAccuracy=o)}))}));this.addHandles(c,bt.imageClick)},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:r}=this;if(this.clearGraphics(),!a||!t||"none"===r)return;const{attributes:i}=t,{imagePath:s,imageRotation:n,cameraHeading:o,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:m,location:p}=i,d=(c??0)+(n??0),g=p.spatialReference.isWGS84&&4!==m?.type?z(p):new O(p);let f=s;if(Se(s))try{f=await ke(a,h,e)}catch(w){if(y(w))return;return ct(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(f,{imageRotation:d,options:e,pitch:l,yaw:o,mode:r,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:r,options:i}=t,s="string"==typeof e,n=s?e:e.url,{pathname:o,searchParams:c}=new URL(n);let l=s?o.match(_t)?.[1]:e.datasetFormat;if(!l)try{l=await lt(n,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(l??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,l,n,c,r,i):await this._setImageSource(this._imageViewer,l,n,c,r,i);break;case"panoramic":if(Ft.has(l.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:r,cameraLocation:s,viewAngle:o}=t;this._panoramicViewer.imageSource=n;let c=r??0;"number"==typeof o?c=o-c:s&&e&&(c=await ee(s,e)-c),this._panoramicViewer.pitch=a??0,this._panoramicViewer.yaw=c,await this._panoramicViewer.loadImage(i)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:l});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:r}=this;if(this.imageMeasurementViewer.clearGraphics(),!a||!t||"none"===r)return;const{attributes:i}=t,{imagePath:s,imageRotation:n,cameraHeading:o,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:m,location:p}=i,d=(c??0)+(n??0),g=p.spatialReference.isWGS84&&4!==m?.type?z(p):new O(p);let f=s;if(Se(s))try{f=await ke(a,h,e)}catch(w){if(y(w))return;return ct(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(f,{imageRotation:d,options:e,pitch:l,yaw:o,mode:r,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:r,triangulatedMeasurementGraphic:i}=this;t&&a&&r&&i&&"active"!==t.state&&(t.update([i],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=i((async t=>{const{pointerType:a,button:r,mapPoint:i}=e;if(("mouse"!==a||0===r)&&i)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(i,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,a)=>{if(await f(a),!e)return;const r=new O({...V(e)?e.toJSON():e});if("default"===this.mode)r.x-=.5,r.y=.5-r.y,r.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:r,symbol:Qe}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[r,i]=a,{heading:s,pitch:n}=te(e,r,i),o=le(s,n);this._crossSymbol=new t({geometry:new O(o,B.WebMercator),symbol:Xe}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this)}initialize(){this.addHandles([_((()=>this.view),(()=>{this.load()}),M),_((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),P),_((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),_((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),M),_((()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage]),(()=>{this._createTriangularImageClickHandle()}),M),_((()=>[this.state,this.imageLocationToolState,this.view]),(()=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();this._setMeasurementCursor()}),M),_((()=>this.measureType),(()=>{this.clearPreviousMeasurements()}),M),_((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),M),_((()=>this.currentBestFeature),(async(e,t)=>{p(this._featureChangedTask),this._featureChangedTask=i((async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}]))),await this._featureChangedTask.promise}),{sync:!0}),_((()=>this.currentBestFeatureMeasurementImage),(async(e,t)=>{p(this._featureChangedTask),t&&e!==t&&(this.measurementVectors=[],this.sketchTriangularGraphicsLayer?.graphics.destroyAll()),this._featureChangedTask=i((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.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics())})),_((()=>this.mode),(e=>{switch(this.removeHandles(bt.interactionHandles),e){case"default":this.addHandles(_((()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null}),(e=>{e&&(p(this._updateFootprintTask),this._updateFootprintTask=i((async t=>{await this.updateFootprint(e,{signal:t})})))}),{...M,equals:(e,t)=>r(e,t,l)}),bt.interactionHandles);break;case"panoramic":this.addHandles(_((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:a,vfov:r,hfov:i,pitch:s,yaw:n}=this._panoramicViewer;return e&&a&&!t.includes("loading")?[r,i,n,s]:null}),(e=>{if(!e||this.state.includes("loading"))return;const[t,a,r,s]=e;this.currentNode&&(this.currentNode.currentHeading=r+(this.currentNode.heading??0),this.currentNode.currentPitch=s+(this.currentNode.pitch??0)),p(this._updateFootprintTask),this._updateFootprintTask=i((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:r,pitch:s},{signal:e})}))}),{...M,equals:(e,t)=>r(e,t,l)}),bt.interactionHandles)}}),M),_((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:r,sharpness:i}=this;"default"===r&&(e.brightness=t,e.contrast=a,e.sharpness=i)}),M),_((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)})),F((()=>this.features),"change",(()=>{this.navigationNodes.removeAll(),this.features.forEach((e=>{const t=new ft({geometry:e.geometry,attributes:e.attributes});this.navigationNodes.add(t)}))}))]),this.when().finally((()=>{this.notifyChange("state")}))}destroy(){this._updateFootprintTask=p(this._updateFootprintTask),this._clickTask=p(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=d(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._crossSymbol=d(this._crossSymbol),this._referencePointOnGround=d(this._referencePointOnGround),this._referencePointOnImage=d(this._referencePointOnImage),this._locationPointOnImage=d(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 n(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){n(u.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",h(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",h(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 ut(t)||Se(t)}get imageLoaded(){return n(u.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===we}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(ht(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?pe(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";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?be.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",h(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:a},_featureChangedTask:r}=this;if(t)return"disabled";if(!this.isFulfilled()||a||!1===r?.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}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:r}})=>{const i=e?.trim();return ut(i)||Se(i)?{url:i,objectId:t,rotation:(a??0)+(r??0)}:null})).filter(a)):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;case"none":return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}get _activeSectors(){return be.filter((e=>this._sectorData?.[e]?.length))}async computeHeight(e,t,a=!0){const{currentBestFeature:r,activeViewer:i,layer:s,footprintExtent:n}=this,o=i?.imageSize,c=r?.attributes,l=s?.orientationAccuracy;if(!c||!o||!e||e.length<2||!l)return;const u="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ae(c,o[0],o[1]),h=e.at(0),m=e.at(-1);if(!(u&&h&&m&&l&&n))return;const p=[m,h],d=Ae(p,!1),g="panoramic"===t?await Ce(p,u,l,r,!0,!1):await Ve(p,u,l,!0,a);if(!g)return;const y="panoramic"===t?await Ge(l,d,u,g,r,!0):await Re(l,d,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 r="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return v(a),r?"default"===t?await Le(e,r,!0):await Oe(e,r,!0,a):null}async calculateDistanceMeasurement(e,t,a){const{currentBestFeature:r,activeViewer:i}=this;if(e.length<2||!r||!i?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return v(a),s?"default"===t?await Te([e.at(0),e.at(-1)],s,!0):await je([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,a){const{layer:r,currentBestFeature:i,activeViewer:s}=this,n=r?.orientationAccuracy,o=n?.every((e=>0===e))||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!i||!s?.imageSize||o)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 Le(e,c,!0):await Te([e.at(0),e.at(-1)],c,!0);v(a);const{updateElevationProps:u,...h}=c,m=xe(h,n);if(!m?.length)return null;const p=m.map((e=>({...e,updateElevationProps:u}))).map((async r=>{const i="area"===t?await Le(e,r,!0):await Te([e.at(0),e.at(-1)],r,!0);if(v(a),i&&l){if("area"===t){const e="number"!=typeof i?i.area:null;return e?Math.abs(e-l.area):null}return Math.abs(i-l)}return null})),d=await Promise.all(p);v(a);const g=d.filter((e=>null!==e));return 0===g.length?null:Be(g)}async calculateLocationAccuracy(e,t,a="default",r){const{layer:i,currentBestFeature:s}=this,n=i?.orientationAccuracy,o=this.view?.spatialReference,c=n?.every((e=>0===e))||!n?.length;if(!s||c)return null;const l="default"===a?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();if(v(r),!l)return null;const{updateElevationProps:u,...h}=l,m="default"===a?xe(h,n):Ee(h,n);if(!m?.length)return null;const p=m.map((e=>({...e,updateElevationProps:u}))).map((async i=>{const{updateElevationProps:s,...n}=i;let c="default"===a?await K(e,n,s):await Q(e,n,s);return v(r),o&&!c.spatialReference.equals(o)&&(c=await x(c,o),v(r)),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})),d=await Promise.all(p);if(v(r),!d?.length)return null;const g=d.map((e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0])),[y,f,w]=ze(g);return{x:y,y:f,z:w}}async calculateAccuracyPanoramic(e,t,a){const{layer:r,currentBestFeature:i,activeViewer:s,mode:n}=this,o=r?.orientationAccuracy,c=o?.every((e=>0===e))||!o?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!i||!s?.imageSize||c||"panoramic"!==n)return null;const l=await this.getMeasurementPropertiesPanoramic();if(v(a),!l)return null;const u="area"===t?await Oe(e,l,!0):await je([e.at(0),e.at(-1)],l,!0);v(a);const{updateElevationProps:h,...m}=l,p=Ee(m,o);if(!p?.length)return null;const d=p.map((e=>({...e,updateElevationProps:h}))).map((async r=>{const i="area"===t?await Oe(e,r,!0):await je([e.at(0),e.at(-1)],r,!0);if(v(a),i&&u){if("area"===t){const e="number"!=typeof i?i.area:null;return e?Math.abs(e-u.area):null}return Math.abs(i-u)}return null})),g=await Promise.all(d);v(a);const y=g.filter((e=>null!==e));return 0===y.length?null:Be(y)}async calculateHeightMeasurementInfo(e,t,a){const{currentBestFeature:r,activeViewer:i}=this,s=i?.imageSize;if(!r||!i||!s?.length||"none"===t)return;const{attributes:n}=r,[o]=Ae([e],"panoramic"!==t),c="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ae(n,s[0],s[1]);if("panoramic"===t){if(!c)return;const e=await De(o,c,r,a);if(!e)return;e?.heading>180&&(e.heading-=360);const t=He(o,e),i=C([o.x,o.y],[e.x,e.y]);if(!t||!i)return;return{measurementAngle:t,tempDistance:i}}const l=await Ne(o,c,a);if(!l)return;const u=Ue(o,l),h=C([o.x,o.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 qe(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?.spatialReference){const t=await We(this.measurementVectors,this.currentBestFeatureMeasurementImage.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:r}=this;if(!a)throw Mt();_e(r,e,a),await a.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw Mt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw Mt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw Mt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw Mt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw Mt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw Mt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:r}=this,i=t?.imageSize,s=e?.attributes;if(!s||!i)return;const n=await this.computeHeight(a,r);n?.value&&n?.accuracy&&(this.heightMeasurementResult=n.value,this.heightMeasurementAccuracy=n.accuracy)}filterByFootprints(e,t){const a=[],r=[],i=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:n}=e;let o;const c=S(e.geometry.spatialReference);n.cameraHeight/=c,n.farDistance/=c,n.nearDistance/=c,J(n.elevationSource)&&(n.elevationSource.constantElevation/=c);const{polygon:l,frustum:u}=U(n);if(o=l.clone(),n.isInspection&&(o=W(n)),s&&(o=q(o,s)),!t||$(o,t)){i.push(e);const{geometry:t,objectId:s,cameraHeight:o,cameraHeading:c}=n,h=t.clone();h.z=o,h.imageID=s,this.pointSources.push(h),c!==we&&(a.push(l),u&&r.push(u))}})),{features:i,polygons:a,frustums:r}}getMeasurementProperties(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:r}=e,{elevationSource:i,cameraHeight:s}=r,n=ae(r,t.imageSize[0],t.imageSize[1]);let o=n.cameraLocation;return(o.spatialReference.isGeographic?x(o,B.WebMercator):Promise.resolve(o)).then((e=>(o=e,re((o.z??0)-s,{elevationSample:a,elevationSource:i,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ie(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...n,cameraLocation:o,updateElevationProps:t})))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:r}=e,{elevationSource:i,cameraHeight:s}=r,n=se(r,t.imageSize[0],t.imageSize[1]);let o=n.cameraLocation;return(o.spatialReference.isGeographic?x(o,B.WebMercator):Promise.resolve(o)).then((e=>(o=e,re((o.z??0)-s,{elevationSample:a,elevationSource:i,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ie(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...n,cameraLocation:o,updateElevationProps:t})))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new o("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?.[be[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 r=this._sectorData?.[t],i=r?.at(a);i&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(i):this._updateCurrentBestFeature(i))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:r,mode:i,activeViewer:s}=this,n=s?.imageSize;if(!e.vertices||!n)return;const o=$e(e.vertices.at(-1),i,n);if(r.length<1||!o||!a||!t||"none"===i)return;const c=Je(r[0],o,t);if(!c?.length)return;this.heightMeasurementPixels.push(c),"panoramic"===i?this.createPolylineGraphicPano():this.createPolylineGraphic();const l=Ze(this.heightMeasurementPixels,a);l&&(this.heightMeasurementResult=l)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:r,heightMeasurementPixels:i,mode:s}=this;if(!a||!r||!e.vertices?.length||"none"===s)return;const n=r?.imageSize;if(!i.length&&n){const a=$e(e.vertices.at(-1),s,n);this.heightMeasurementPixels.push(a);const r=await this.calculateHeightMeasurementInfo(a,s,t);if(!r?.measurementAngle||!r?.tempDistance)return;this.measurementAngle=r.measurementAngle,this.tempDistance=r.tempDistance}}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.selectedPoint=e.spatialReference.isGeographic?z(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.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 startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:r,activeViewer:i,mode:s}=this;if(!a||!r||!i||"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 n=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;n&&this.sketch&&(this.sketch.polygonSymbol=Ye(n),this.sketch.polylineSymbol="panoramic"===s?et:tt(n,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new ge({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 j({paths:[e],spatialReference:a});else{const r=new j({paths:[e],spatialReference:a}),i=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:r,symbol:tt(i,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const r={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},i={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:n}=te(r,a[0],a[1]),{heading:o,pitch:c}=te(i,a[0],a[1]),l=[[...le(s,n)],[...le(o,c)]];if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[l],spatialReference:e});else{const a=new j({paths:[l],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:et}),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:r}=this,i=a?.imageSize;if(!e||!t||!i)return;const s=e.map((e=>[e[0]-.5,-.5-e[1]])),n=this.view?.spatialReference,o=[];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:i,mode:r});n&&!a.spatialReference.equals(n)&&(a=await x(a,n)),o.push(a)}return Ke(o,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:r,overlayedCameraLocations:i,layer:s,mode:n,state:o}=this,c=a?.imageSize;if(!c||!r||!s||"none"===n||o.includes("loading"))return;const{polygon:l}=U(r.attributes);if(a.removeManyGraphics(i.toArray()),i.removeAll(),e){const{features:e}=await s.queryFeatures({where:`${s.objectIdField} <> ${r.attributes.objectId}`,geometry:l,returnGeometry:!0,outFields:[s.objectIdField]}),o=await Promise.all(e.map((async e=>{const{attributes:a,geometry:i}=e,s=await this.getPixels(i,{feature:r,imageSize:c,mode:n}),o=at.clone();return o.outline=new de({color:[0,0,0],width:1}),new t({attributes:a,symbol:o,geometry:s})})));i.addMany(o),a.addManyGraphics(i.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,r=!1){const{activeViewer:i,currentBestFeature:n,mode:o,state:c,layer:l}=this,h=i?.imageSize;if(!h||!n||"none"===o||c.includes("loading")||!l)return;const{polygon:m}=U(n.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Me(e,l.imageGeometryField,l.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:p}=await e.queryFeatures({geometry:m,returnGeometry:!0,outFields:["*"]}),d=new s((await Promise.all(p.map((async a=>{const i=a.symbol?.clone()??e.renderer?.getSymbol(a)?.clone(),{attributes:s,geometry:c}=a,l=c,{imageGeometryField:m,oiObjectIdField:p}=this;if(m&&p&&Pe(e,m,p)&&`${s[p]}`==`${n.attributes.objectId}`)try{return Ie(s,m,e,r,h,o,i)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:a,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(l?.type){case"point":{const a=await this.getPixels(l,{feature:n,imageSize:h,mode:o});return new t({attributes:s,layer:e,symbol:i,geometry:a,visible:e.visible&&r})}case"polygon":{const{rings:a,spatialReference:c}=l,u=a.map((e=>e.map((([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c}))))),m=await Promise.all(u.map((async e=>this.getPixels(e,{feature:n,imageSize:h,mode:o}).then((e=>e.map(ne))))));return new t({attributes:s,layer:e,symbol:i,geometry:new T({rings:m,spatialReference:B.WebMercator}),visible:e.visible&&r})}case"polyline":{const{paths:a,spatialReference:c}=l,u=a.map((e=>e.map((([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c}))))),m=await Promise.all(u.map((async e=>this.getPixels(e,{feature:n,imageSize:h,mode:o}).then((e=>e.map(ne))))));return new t({attributes:s,layer:e,symbol:i,geometry:new j({paths:m,spatialReference:B.WebMercator}),visible:e.visible&&r})}case"multipoint":{const{points:a,spatialReference:c}=l,u=a.map((([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c}))),m=await this.getPixels(u,{feature:n,imageSize:h,mode:o}).then((e=>e.map(ne)));return new t({attributes:s,layer:e,symbol:i,geometry:new L({points:m,spatialReference:B.WebMercator}),visible:e.visible&&r})}}return null})))).filter(a));this.overlayGraphicsOnImage(`${e.id}`,d)}async getPixels(e,t){const{imageSize:a,mode:r}=t,i=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===r)return new O({x:e.x-.5,y:.5-e.y,spatialReference:B.WebMercator});const[t,i]=a,{heading:s,pitch:n}=te(e,t,i),o=le(s,n);return new O(o,B.WebMercator)}));return Array.isArray(e)?i:i[0]}async getMapPoint(e,t){const{feature:a,mode:r,imageSize:i}=t,{elevationSample:s,attributes:n}=a,{elevationSource:o,location:c,elevation:l,cameraHeight:u}=n;let h=c.clone();h.spatialReference.isGeographic&&(h=await x(h,B.WebMercator));const m=await re(l??(c.z??0)-u,{elevationSample:s,elevationSource:o,extent:this.footprintExtent});let p;if("elevationSample"in m&&ie(m.elevationSample)&&(a.elevationSample=m.elevationSample),"default"===r){const t=ae(n,i[0],i[1]);p=await K(Array.isArray(e)?e:[e],{...t,cameraLocation:h},m)}else{const t=se(n,i[0],i[1]);p=await Q(Array.isArray(e)?e:[e],{...t,cameraLocation:h},m)}return Array.isArray(e)?p:p[0]}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 O({...e.toJSON()}),symbol:rt}),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=V(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new O({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:rt}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[r,i]=a,{heading:s,pitch:n}=te(e,r,i),o=le(s,n);this._referencePointOnImage=new t({geometry:new O(o,B.WebMercator),symbol:it}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(),this.mode){case"default":this._plotLocationPointOnDefaultImage(e);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=p(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:r}=t,i=a.get(e.id),s=i?.toArray();if(!i||!s?.length)return;const{addFeatureResults:n}=await this.saveDataCaptureFeatures(s),o=n.reduce(((t,{objectId:a,globalId:r,error:i},n)=>{const o=s[n],{attributes:c}=o;return i?t.error.push(o):(a&&(c[e.objectIdField]=a),r&&e.globalIdField&&(c[e.globalIdField]=r),t.success.push(o)),t}),{success:[],error:[]});r.addMany(o.success),i.removeAll(),i.addMany(o.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:r,dataCaptureLayer:i,mode:s}=this,n=t?.imageSize;if(!n||!r||"none"===s)throw new o("orientedimagery","Image size, current best feature and mode are required to save data capture features");if(!i)throw new o("orientedimagery","Data capture layer is not available");const c=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:a}=t;if(!a)return;const o=a.type,c=i.hasZ,l=i.geometryType,u=o!==l,h=u?await import("./transformers.js"):null,m=h?.default[l],p=u?m?.(a):a;if(p)switch(p.type){case"point":return t.geometry=await this.getMapPoint(oe(s,p,n),{feature:r,imageSize:n,mode:s}),c||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(p.rings.map((async e=>this.getMapPoint(e.map((([e,t,a])=>oe(s,{x:e,y:t,z:a},n))),{feature:r,imageSize:n,mode:s}))));return t.geometry=new T({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,rings:e.map((e=>e.map(ne)))}),t}case"polyline":{const e=await Promise.all(p.paths.map((async e=>this.getMapPoint(e.map((([e,t,a])=>oe(s,{x:e,y:t,z:a},n))),{feature:r,imageSize:n,mode:s}))));return t.geometry=new j({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,paths:e.map((e=>e.map(ne)))}),t}}}))),l=c.filter(a);return i.applyEdits({addFeatures:l}).then((e=>{const{addFeatureResults:t}=e;let a=0;const r=c.map((e=>{const r=t[a++];return e?r:{error:new o("orientedimagery","Error in saving data capture features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:r}}))}async searchBestImage(e,t){try{const a=await H(e,t);a&&await this._processFeatureResponse(a,e.point,t)}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),u.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}async startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:r,currentBestFeature:i}=this;if(!a||!i||!r)return;const{attributes:{objectId:n}}=i,o=this.overlayedMapFeatures.get(e.id)?.toArray()??[],c=[],l=[];for(const s of o)`${s.getAttribute(r)}`==`${n}`?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=d(this.sketchAdapter),this.sketch=d(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 r=a.ui.find("zoom");r&&(r.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 r=!1,i=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);r=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);i=s.extent.contains(e);break}}if(!r&&!i)return void this.clearReferencePointOnImage();const n=await this.worldToImage(t,a);if(n)return v(a),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}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()}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const r={include:a},i=this.view.toScreen(e);if(!i)return;const s=await this.view.hitTest(i,r);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"),u.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:a,features:r,invalidCameraHeading:i}=this;if(!e||!t||!a||!r||i)return void(this._sectorData=null);this._sectorData={};const n={};this._featureToSector=n;for(const h of be)this._sectorData[h]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const c=o.map((({distance:e})=>e)),l=Math.max(...c),u=r.reduce(((e,t)=>Math.max(e,t.attributes.location.z??0)),-1/0);o.forEach((e=>{const{distance:t,angle:a,featureIndex:i}=e,s=t/l*Fe[2],o=gt(t,l),c=yt(a);if(!this._sectorData)return;const h=Fe[3]+s*Math.sin(a*Math.PI/180),m=Fe[3]+s*Math.cos(a*Math.PI/180);let p;const d=r.at(i),g=(d.attributes.location.z??0)/u*Fe[2],y=d===this.currentBestFeature,v=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(y&&v)p=-90;else{const e=h-Fe[3],t=m-Fe[3],a=t/Math.sqrt(e**2+t**2);let r=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(r*=-1),p=r}const f=""===o?c:`${o}_${c}`;y&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=v?null:{x:h,y:m,direction:c}),n[`${d.attributes.objectId}`]=f;const w=this._sectorData[f];w.add({angle:a,featureIndex:i,x:h,y:m,z:g,objectID:d.attributes.objectId,sector:f,featureIndexInSector:w.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 wt({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)}_plotLocationPointOnDefaultImage(e){const a=V(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._locationPointOnImage=new t({geometry:new O({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:st}),this._imageViewer.addGraphic(this._locationPointOnImage,0)}_plotLocationPointOnPanoramicImage(e){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[r,i]=a,{heading:s,pitch:n}=te(e,r,i),o=le(s,n);this._locationPointOnImage=new t({geometry:new O(o,B.WebMercator),symbol:nt}),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 r=await R(e);if(this._updateFootprintWithFeatures(t,r),this.view?.supportsGround)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(i){y(i)||u.getLogger(this).error(i)}}async processElevationSample(e,t,a){const{elevationSource:r}=t[0].attributes,i=await this._getElevationSampleFromGround(e,t,a);return i||(r&&this.footprintExtent&&Z(r)?await Y({extent:this.footprintExtent,lod:r.lod,url:r.url,rasterFunction:r.rasterFunction}):void 0)}async _processFeatureResponse(e,t,a){const{features:r}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(r))return;const{features:i,polygons:s,frustums:n}=this.filterByFootprints(r,t);if(!this._checkFeatures(i))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(n);const o=await this.processElevationSample(s,i,a);v(a),await this._updateElevationOfSelectedPointAndLocations(i,t,o),v(a),mt(i,o),this._processSuitableFeatures(i,t),this._updateSuitabilities(a?.loadBestImage)}_processSuitableFeatures(e,t){this._suitabilities=N({features:e,selectedPoint:t,camera:pt(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,a){const{screenPoint:r,results:[i]}=t,s="graphic"===i?.type&&this.shouldShowSelectedImage,n=i?.mapPoint??this.view?.toMap(r);if(!n)return;const{layerFloorFilterClause:o}=this,c=e.spatialReference.equals(n.spatialReference)?n:await x(n,e.spatialReference),l=c.spatialReference.isGeographic?z(c):c,u=I("1=1",I(e.definitionExpression,o)),h=l.spatialReference.isGeographic?1:S(l.spatialReference),m={layerInstanceOrURL:e,point:l,queryParams:{where:u,maximumDistance:e.maximumDistance?e.maximumDistance/h:void 0,objectIds:s?[i.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(m,a)}_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,r,i,s){e.imageSource={datasetFormat:t.toUpperCase(),url:a.split("?")[0]},e.customParameters=Object.fromEntries(r),e.imageRotation=i??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}))}async _updateElevationOfSelectedPointAndLocations(e,t,a,r){const i=ie(a),s=await re((e[0].attributes.location.z??0)-e[0].attributes.cameraHeight,{elevationSample:i?a:void 0,elevationSource:i?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},r);v(r);const[n,...o]=await X([t,...e.map((e=>e.attributes.geometry.clone()))],s);v(r),t.elevation=n.z,e.forEach(((e,t)=>{e.attributes.elevation=o[t].z}))}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0])}_updateFootprintWithFeatures(e,t){const a=[];for(const{geometry:r}of e)t.contains(r)||a.push([r.x,r.y]);a.sort(((e,t)=>+E([e,t]))),t.addRing(a),this.footprintExtent=ye(t.extent,2,2)}_updateSuitabilities(e){const{_suitabilities:t}=this;t&&this.updateSuitabilities(t,e)}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:r,currentCoverageVisible:i,isAdditionalPointSourcesVisible:s}=this;if(r&&(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===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:ot,visible:i}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:at,visible:s}))}}_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-Fe[3],r=e.y-Fe[3],i=r/Math.sqrt(t**2+r**2);let s=180*Math.acos(i)/Math.PI;(t<0&&r<0||t<0&&r>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=d(this._referencePointOnImage))}clearLocationPointOnImage(){this._locationPointOnImage&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=d(this._locationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,a,r){this.displayMessage={key:e,type:t,data:a,map:r}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:r,activeViewer:i}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=d(this._crossSymbol)),!r||!t||"image-loaded"!==i?.state||a)return;let s;try{s=await this.worldToImage(r,e),v(e),await this.plotSelectedPointOnImage(s,e)}catch(n){y(n)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:n,selectedPoint:r,feature:t})}}async worldToImage(e,t){const{footprintExtent:a}=this,{imageSize:r}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!r||!a)return;const{attributes:{location:i,elevationSource:s,cameraHeading:n,elevation:o,cameraHeight:c},elevationSample:l}=this.currentBestFeature;let u=i.clone();const h=await re(o??(i.z??0)-c,{elevationSample:l,elevationSource:s});this.currentBestFeature.elevationSample=h.elevationSample;const m=Array.isArray(e)?e:[e];let p,d=await Promise.all(m.map((e=>new Promise((t=>{if(!e.hasZ)return t(X(e,h));t(e)})))));if(i.spatialReference.isGeographic&&(u=await x(u,B.WebMercator,t)),d=await Promise.all(d.map((async e=>u.spatialReference.equals(e.spatialReference)?e:await x(e,u.spatialReference,t)))),v(t),"panoramic"===this.mode)p=he(d,{imageHeight:r[1],imageWidth:r[0],cameraHeading:n,cameraLocation:u});else{const e=ce(this.currentBestFeature.attributes,r[0],r[1]);p=me(d,{...e,cameraLocation:u})}return Array.isArray(e)?p:p[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:r,currentBestFeature:i,currentBestFeatureLocation:s,currentCoverageVisible:n,selectedPoint:o,view:c,_adapter:l,mode:u}=this,{attributes:{objectId:h},elevationSample:m}=i;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=n,this.bestFeatureCurrentFootprint=e),c){const e=[...a,...r,s].filter(dt);c.supportsGround&&m&&l?.updateGroundElevation&&(this._updateGroundElevation&&l.updateGroundElevation(e,m),"panoramic"===u&&l.updateGroundElevation([this.bestFeatureCurrentFootprint],m)),this._updateGroundElevation=!1,o&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:o.clone(),symbol:Qe.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=d(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([k()],It.prototype,"activeLayer",null),e([k({readOnly:!0})],It.prototype,"activeViewer",null),e([k()],It.prototype,"accuracyParametersMissing",null),e([k()],It.prototype,"additionalFeatures",void 0),e([k({type:s.ofType(t)})],It.prototype,"additionalCameraLocations",void 0),e([k({type:s.ofType(t)})],It.prototype,"additionalFootprints",void 0),e([k()],It.prototype,"areaMeasurementResult",void 0),e([k()],It.prototype,"areaMeasurementAccuracy",void 0),e([k()],It.prototype,"bestFeatureAngle",void 0),e([k()],It.prototype,"bestFeatureCurrentFootprint",void 0),e([k({type:t})],It.prototype,"bestFeatureFootprint",void 0),e([k({type:Number})],It.prototype,"brightness",null),e([k()],It.prototype,"collectionId",void 0),e([k({type:Number})],It.prototype,"contrast",null),e([k()],It.prototype,"conversionProps",void 0),e([k()],It.prototype,"coverageFrustums",void 0),e([k()],It.prototype,"coveragePolygons",void 0),e([k()],It.prototype,"currentBestFeature",void 0),e([k()],It.prototype,"currentBestFeatureMeasurementImage",void 0),e([k()],It.prototype,"currentBestFeatureLocation",void 0),e([k()],It.prototype,"currentCoverageVisible",void 0),e([k()],It.prototype,"currentNode",null),e([k()],It.prototype,"navigationNodes",void 0),e([k({json:{write:!1}})],It.prototype,"determineWorkflowForFeature",void 0),e([k({json:{write:!1}})],It.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([k()],It.prototype,"disabled",void 0),e([k()],It.prototype,"displayMessage",void 0),e([k()],It.prototype,"displayNewMeasurementButton",void 0),e([k()],It.prototype,"distanceMeasurementResult",void 0),e([k()],It.prototype,"distanceAccuracyArray",void 0),e([k()],It.prototype,"dataCaptureLayer",void 0),e([k({readOnly:!0})],It.prototype,"featureCount",null),e([k()],It.prototype,"features",void 0),e([k()],It.prototype,"groundCoordinates",void 0),e([k()],It.prototype,"groundCoordinatesAccuracy",void 0),e([k()],It.prototype,"heightMeasurementPixels",void 0),e([k()],It.prototype,"heightGraphic",void 0),e([k()],It.prototype,"heightMeasurementResult",void 0),e([k()],It.prototype,"heightMeasurementAccuracy",void 0),e([k()],It.prototype,"measurementAngle",void 0),e([k()],It.prototype,"tempDistance",void 0),e([k({readOnly:!0})],It.prototype,"imageGalleryEnabled",null),e([k()],It.prototype,"imageGeometryField",void 0),e([k({readOnly:!0})],It.prototype,"imageLoaded",null),e([k()],It.prototype,"imageLocationToolState",void 0),e([k({readOnly:!0})],It.prototype,"invalidCameraHeading",null),e([k()],It.prototype,"imagePointsInView",null),e([k()],It.prototype,"imageMeasurementViewer",void 0),e([k()],It.prototype,"isAdditionalCoverageVisible",void 0),e([k()],It.prototype,"isAdditionalPointSourcesVisible",void 0),e([k()],It.prototype,"measurementVectors",void 0),e([k()],It.prototype,"layer",void 0),e([k()],It.prototype,"layerView",null),e([k({readOnly:!0})],It.prototype,"layerFloorFilterClause",null),e([k({type:Number})],It.prototype,"localPort",void 0),e([k()],It.prototype,"mapImageConversionToolState",void 0),e([k()],It.prototype,"measureType",void 0),e([k()],It.prototype,"measurementGraphic",void 0),e([k({readOnly:!0,value:"none"})],It.prototype,"mode",null),e([k()],It.prototype,"navigatorCurrentBestFeature",void 0),e([k()],It.prototype,"oiObjectIdField",void 0),e([k({type:s.ofType(t)})],It.prototype,"overlayedCameraLocations",void 0),e([k()],It.prototype,"overlayedMapFeatures",void 0),e([k()],It.prototype,"pixelCoordinates",void 0),e([k()],It.prototype,"pointSources",void 0),e([k({readOnly:!0})],It.prototype,"popupEnabled",null),e([k()],It.prototype,"previousFeatureAngle",void 0),e([k()],It.prototype,"referencePoint",null),e([k({readOnly:!0})],It.prototype,"sectorData",null),e([k()],It.prototype,"selectedPoint",void 0),e([k({type:Number})],It.prototype,"sharpness",null),e([k()],It.prototype,"shouldShowSelectedImage",void 0),e([k()],It.prototype,"sketch",void 0),e([k()],It.prototype,"sketchTriangular",void 0),e([k()],It.prototype,"sketchTriangularGraphicsLayer",void 0),e([k()],It.prototype,"draw",void 0),e([k()],It.prototype,"sketchAdapter",void 0),e([k({readOnly:!0})],It.prototype,"sketchGraphicsLayer",null),e([k({readOnly:!0})],It.prototype,"state",null),e([k({readOnly:!0})],It.prototype,"thumbnails",null),e([k()],It.prototype,"triangularMeasurementActive",void 0),e([k()],It.prototype,"triangulatedDistanceMeasurement",void 0),e([k()],It.prototype,"triangulatedDistanceAccuracy",void 0),e([k()],It.prototype,"triangulatedAreaMeasurement",void 0),e([k()],It.prototype,"triangulatedAreaAccuracy",void 0),e([k()],It.prototype,"triangulatedMeasurementGraphic",void 0),e([k()],It.prototype,"triangulatedMeasurementAdapter",void 0),e([k()],It.prototype,"updateFootprint",void 0),e([k()],It.prototype,"updateFootprintPanorama",void 0),e([k()],It.prototype,"updatingTriangularMeasurementState",void 0),e([k({value:null})],It.prototype,"view",null),e([k()],It.prototype,"_adapter",void 0),e([k()],It.prototype,"_sketchGraphicsLayer",null),e([k()],It.prototype,"_highlightedFeatureHandle",void 0),e([k()],It.prototype,"_imageViewer",void 0),e([k()],It.prototype,"_initialCurrentCoverageUpdate",void 0),e([k()],It.prototype,"_locationPointOnImage",void 0),e([k()],It.prototype,"_overlays",void 0),e([k({readOnly:!0})],It.prototype,"_overlaysView",null),e([k()],It.prototype,"_panoramicViewer",void 0),e([k()],It.prototype,"_previousCursor",void 0),e([k()],It.prototype,"_referencePointOnGround",void 0),e([k()],It.prototype,"_referencePointOnImage",void 0),e([k()],It.prototype,"_sectorData",void 0),e([k()],It.prototype,"_featureToSector",void 0),e([k()],It.prototype,"_activeSectors",null),e([k({readOnly:!0})],It.prototype,"_updatingHandles",void 0),e([k()],It.prototype,"footprintExtent",void 0),e([k()],It.prototype,"_featureChangedTask",void 0),It=e([A("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],It);const St=It;export{St 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{createTask as t}from"../../../../core/asyncUtils.js";import a from"../../../../core/Promise.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{load as o}from"../../../../geometry/projection.js";import{convertSphereVertexToPixelLocation as n}from"../../../../layers/orientedImagery/transformations/utils.js";import{SketchHandlerMixin as c}from"../../mixins/SketchHandlerMixin.js";let l=[],u=[],h=0,m=class extends(c(a)){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(o())}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=n(t,a.imageSize[0],a.imageSize[1]);this.measurementArray.push([s.x,s.y])}const s=u.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(l=[...this.polygonVertices],"default"===t)l.push(s);else{const e={x:s[0],y:s[1],z:s[2]},t=n(e,a?.imageSize[0],a?.imageSize[1]);l.push([t.x,t.y])}if(l.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const i=l[0];l=l.filter(((e,t)=>0===t||t===l.length-1||JSON.stringify(e)!==JSON.stringify(i)));const r=await this._getAreaFromTask(l);r?.area&&r?.perimeter&&(h=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)return this.viewModel.activeViewer?.addGraphic(e.graphic),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}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=h>0?h: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=n(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:c}=o;this.pixelAreaMeasurement=c}vertexUpdatePolylineHandler(){this.measurementArray=this.measurementArray.slice(-1);const e=u.reduce(((e,t)=>e+t),0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=e,this.pixelMeasurement>0&&u.push(this.pixelMeasurement)}resetDistanceMeasurements(){this.measurementArray=[],this.pixelMeasurement=0,u=[]}resetAreaMeasurements(){this.polygonVertices=[],this.pixelAreaMeasurement=0,h=0}async _getAreaFromTask(e){const{mode:a}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._areaCalculation=null;const i=await this.viewModel.calculateAreaMeasurement(e,a,t);s(t),this._areaCalculation=i})),await this._calculationTask.promise,this._areaCalculation}async _getDistanceFromTask(){const{mode:e}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._distanceCalculation=0;const a=await this.viewModel.calculateDistanceMeasurement(this.measurementArray,e,t);s(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=t((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);s(t),this._distanceCalculation=a})),await this._calculationTask.promise,this._distanceCalculation)}async _getAreaAccuracyFromTask(e){const{mode:a}=this.viewModel;return"none"===a?null:(this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._distanceCalculation=0;const i="default"===a?await this.viewModel.calculateAccuracy(e,"area",t):await this.viewModel.calculateAccuracyPanoramic(e,"area",t);s(t),this._distanceCalculation=i})),await this._calculationTask.promise,this._distanceCalculation)}};e([i()],m.prototype,"type",void 0),e([i()],m.prototype,"measurementArray",void 0),e([i()],m.prototype,"pixelMeasurement",void 0),e([i()],m.prototype,"pixelAreaMeasurement",void 0),e([i()],m.prototype,"polygonVertices",void 0),m=e([r("esri.widgets.OrientedImageryViewer.adapters.sketch.MeasurementAdapter")],m);const d=m;export{d as default};
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/projection.js";import{imageToWorld as m}from"../../../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as u}from"../../../../layers/orientedImagery/transformations/utils.js";import{worldToImage as h}from"../../../../layers/orientedImagery/transformations/worldToImage.js";import{formatPixels as d}from"../../imageMeasurementUtils.js";import{SketchHandlerMixin as p}from"../../mixins/SketchHandlerMixin.js";let y=[],M=[],g=0,w=class extends(p(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=u(t,a.imageSize[0],a.imageSize[1]);this.measurementArray.push([s.x,s.y])}const s=M.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(y=[...this.polygonVertices],"default"===t)y.push(s);else{const e={x:s[0],y:s[1],z:s[2]},t=u(e,a?.imageSize[0],a?.imageSize[1]);y.push([t.x,t.y])}if(y.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const i=y[0];y=y.filter(((e,t)=>0===t||t===y.length-1||JSON.stringify(e)!==JSON.stringify(i)));const r=await this._getAreaFromTask(y);r?.area&&r?.perimeter&&(g=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=g>0?g: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=u(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=M.reduce(((e,t)=>e+t),0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=e,this.pixelMeasurement>0&&M.push(this.pixelMeasurement)}resetDistanceMeasurements(){this.measurementArray=[],this.pixelMeasurement=0,M=[]}resetAreaMeasurements(){this.polygonVertices=[],this.pixelAreaMeasurement=0,g=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=d(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,u=await m(r,a,e),d=h(u,l).map((e=>[e.x-.5,-.5-e.y])),p=new c({paths:[d],spatialReference:this.viewModel.imageMeasurementViewer.imageRenderer.spatialReference}),y=new t({geometry:p,symbol:s});this.viewModel.editOverlayedGraphics(y)}}async _overlayFirstAreaGeometry(e){const a=e.geometry?.clone(),s=e.symbol?.clone(),i=[...a.rings[0]],r=d(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,u=await m(r,a,e),d=h(u,l).map((e=>[e.x-.5,-.5-e.y])),p=new n({rings:[d],spatialReference:this.viewModel.imageMeasurementViewer.imageRenderer.spatialReference}),y=new t({geometry:p,symbol:s});this.viewModel.editOverlayedGraphics(y)}}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()],w.prototype,"type",void 0),e([r()],w.prototype,"measurementArray",void 0),e([r()],w.prototype,"pixelMeasurement",void 0),e([r()],w.prototype,"pixelAreaMeasurement",void 0),e([r()],w.prototype,"polygonVertices",void 0),w=e([o("esri.widgets.OrientedImageryViewer.adapters.sketch.MeasurementAdapter")],w);const v=w;export{v as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
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/projection.js";import{computeTriangulatedVector as i,computeTriangulatedAreaMeasurement as c,computeTriangulatedDistanceMeasurement as o}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:c}=this.viewModel,o=a?.imageSize;if(!e||!t||!o)return;const n=e.map((e=>[e[0]-.5,-.5-e[1]])),u=c?.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:o,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 o(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?.spatialReference){const t=await c(this.viewModel.measurementVectors,r.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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{measurementLengthUnits as t,measurementAreaUnits as s}from"../../../core/unitUtils.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 n}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../Widget.js";import{css as i}from"../css.js";import{ImageMeasurementMixin as c}from"../mixins/ImageMeasurementMixin.js";import{loadCalciteComponents as m}from"../../support/componentsUtils.js";import{tsx as o}from"../../support/jsxFactory.js";import{UnitSelect as l}from"../../support/UnitSelect.js";let u=class extends(c(a)){constructor(e){super(e)}loadDependencies(){return m({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),table:()=>import("@esri/calcite-components/dist/components/calcite-table"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),"table-row":()=>import("@esri/calcite-components/dist/components/calcite-table-row"),"table-header":()=>import("@esri/calcite-components/dist/components/calcite-table-header"),"table-cell":()=>import("@esri/calcite-components/dist/components/calcite-table-cell")})}get _measurementResult(){const{measurementType:e,oiViewModel:t}=this,{areaMeasurementResult:s,heightMeasurementResult:r,distanceMeasurementResult:n}=t;switch(e){case"area":return s;case"height":return r;case"distance":return n}}get _measurementAccuracy(){const{measurementType:e,oiViewModel:t}=this,{areaMeasurementAccuracy:s,heightMeasurementAccuracy:r,distanceAccuracyArray:n}=t;switch(e){case"area":return s;case"height":return r;case"distance":return n}}get _measurementUnit(){const{measurementType:e,pixelAreaMeasurementUnit:t,pixelMeasurementUnit:s}=this;return"area"===e?t:s}get _measurementUnitOptions(){const{measurementType:e}=this;return"area"===e?s:t}_convertedMeasurement(){const{measurementType:e}=this;switch(e){case"area":return this.getConvertedAreaString("measurement");case"height":return this.getConvertedHeightString("measurement");case"distance":return this.getConvertedDistanceString("measurement")}}_measurementUnitChangeHandler(e){const{measurementType:t}=this;if("area"===t)this.pixelAreaMeasurementUnit=e;else this.pixelMeasurementUnit=e}_renderUnitSelect(){const{_measurementUnit:e,_measurementResult:t,_measurementUnitOptions:s}=this;return t?o("div",{class:i.measurementsBar},o(l,{options:s,selectLabel:"",value:e,onChange:e=>this._measurementUnitChangeHandler(e)}),t?o("calcite-action",{bind:this,icon:"copy-to-clipboard",label:"copy",onclick:()=>this.copyMeasurementResult(this.measurementType),scale:"s",text:""}):null):null}_renderMeasurementResults(){const{_measurementResult:e,_measurementAccuracy:t,messages:s,measurementType:r}=this;return e?o("calcite-table",{bordered:!0,caption:s.measurementTable,class:i.measurementsTable,scale:"s"},o("calcite-table-row",{slot:"table-header"},o("calcite-table-header",{alignment:"center",heading:s.value}),o("calcite-table-header",{alignment:"center",heading:s.accuracy})),o("calcite-table-row",null,o("calcite-table-cell",{alignment:"center"},this._convertedMeasurement()),o("calcite-table-cell",{alignment:"center"},"distance"===r&&Array.isArray(t)&&t?.length||"area"===r&&t||"height"===r&&t?this.getAccuracy(this.measurementType):o("calcite-icon",{icon:"hourglass-active",scale:"s"})))):null}_renderNewMeasurementButton(){const{messages:e,measurementType:t}=this;return o("calcite-button",{class:i.measurementsButton,onclick:()=>this.oiViewModel.initializeMeasurement(t)},e.newMeasurement)}_renderStartMeasurementMessage(){const{oiViewModel:{displayNewMeasurementButton:e},messages:t,_measurementResult:s}=this;return!e&&!s&&o("div",{class:i.measurementDisplay,key:`start-measurement-${this.measurementType}`},t.startMeasurement)}render(){return o("calcite-panel",{class:i.measurementResults,key:`measurement-result-container-${this.measurementType}`},this._renderStartMeasurementMessage(),this._renderNewMeasurementButton(),this._renderUnitSelect(),this._renderMeasurementResults())}};e([r()],u.prototype,"_measurementResult",null),e([r()],u.prototype,"_measurementAccuracy",null),e([r()],u.prototype,"_measurementUnit",null),e([r()],u.prototype,"_measurementUnitOptions",null),u=e([n("esri.widgets.OrientedImageryViewer.components.ImageMeasurementWidget")],u);const p=u;export{p as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{measurementLengthUnits as t,measurementAreaUnits as a}from"../../../core/unitUtils.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 n}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../Widget.js";import{css as s}from"../css.js";import{TriangulatedImageMeasurementMixin as i}from"../mixins/TriangulatedImageMeasurementMixin.js";import{loadCalciteComponents as l}from"../../support/componentsUtils.js";import{tsx as u}from"../../support/jsxFactory.js";import{UnitSelect as o}from"../../support/UnitSelect.js";let m=class extends(i(c)){constructor(e){super(e)}loadDependencies(){return l({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),table:()=>import("@esri/calcite-components/dist/components/calcite-table"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),"table-row":()=>import("@esri/calcite-components/dist/components/calcite-table-row"),"table-header":()=>import("@esri/calcite-components/dist/components/calcite-table-header"),"table-cell":()=>import("@esri/calcite-components/dist/components/calcite-table-cell")})}get _measurementResult(){const{measurementType:e,oiViewModel:t}=this,{areaMeasurementResult:a,heightMeasurementResult:r,distanceMeasurementResult:n}=t;switch(e){case"area":return a;case"height":return r;case"distance":return n}}get _measurementAccuracy(){const{measurementType:e,oiViewModel:t}=this,{areaMeasurementAccuracy:a,heightMeasurementAccuracy:r,distanceAccuracyArray:n}=t;switch(e){case"area":return a;case"height":return r;case"distance":return n}}get _measurementUnit(){const{measurementType:e,pixelAreaMeasurementUnit:t,pixelMeasurementUnit:a}=this;return"area"===e?t:a}get _measurementUnitOptions(){const{measurementType:e}=this;return"area"===e?a:t}_convertedMeasurement(){const{measurementType:e}=this;switch(e){case"area":return this.getConvertedAreaString("measurement");case"height":return this.getConvertedHeightString("measurement");case"distance":return this.getConvertedDistanceString("measurement")}}_measurementUnitChangeHandler(e){const{measurementType:t}=this;if("area"===t)this.pixelAreaMeasurementUnit=e;else this.pixelMeasurementUnit=e}_renderUnitSelect(){const{_measurementUnit:e,_measurementResult:t,_measurementUnitOptions:a,oiViewModel:r}=this,{triangularMeasurementActive:n}=r;return t?u("div",{class:s.measurementsBar},u(o,{options:a,selectLabel:"",value:e,onChange:e=>this._measurementUnitChangeHandler(e)}),t?u("calcite-action",{bind:this,icon:"copy-to-clipboard",label:"copy",onclick:()=>this.copyActiveMeasurementResults(this.measurementType,n),scale:"s",text:""}):null):null}_renderMeasurementResults(){const{_measurementResult:e,_measurementAccuracy:t,messages:a,measurementType:r}=this,{measurementTable:n,value:c,accuracy:i}=a;return e?u("calcite-table",{bordered:!0,caption:n,class:s.measurementsTable,scale:"s"},u("calcite-table-row",{slot:"table-header"},u("calcite-table-header",{alignment:"center",heading:c}),u("calcite-table-header",{alignment:"center",heading:i})),u("calcite-table-row",null,u("calcite-table-cell",{alignment:"center"},this._convertedMeasurement()),u("calcite-table-cell",{alignment:"center"},"distance"===r&&Array.isArray(t)&&t?.length||"area"===r&&t||"height"===r&&t?this.getAccuracy(this.measurementType):u("calcite-icon",{icon:"hourglass-active",scale:"s"})))):null}_renderActiveMeasurementResults(){const{oiViewModel:e}=this,{triangularMeasurementActive:t,measureType:a}=e;if(t)switch(a){case"area":return this._renderTriangularAreaMeasurementResults();case"distance":return this._renderTriangularDistanceMeasurementResults()}return this._renderMeasurementResults()}_renderNewMeasurementButton(){const{messages:e,measurementType:t}=this;return u("calcite-button",{class:s.measurementsButton,onclick:()=>this.oiViewModel.initializeMeasurement(t)},e.newMeasurement)}_renderStartMeasurementMessage(){const{oiViewModel:{displayNewMeasurementButton:e},messages:t,_measurementResult:a}=this;return!e&&!a&&u("div",{class:s.measurementDisplay,key:`start-measurement-${this.measurementType}`},t.startMeasurement)}_renderTriangularAreaMeasurementResults(){const{messages:e,oiViewModel:t}=this,{measurementTable:a,value:r,accuracy:n}=e,{triangulatedAreaMeasurement:c}=t;return c?u("calcite-table",{bordered:!0,caption:a,class:s.measurementsTable,scale:"s"},u("calcite-table-row",{slot:"table-header"},u("calcite-table-header",{alignment:"center",heading:r}),u("calcite-table-header",{alignment:"center",heading:n})),u("calcite-table-row",null,this._renderTriangularAreaCell("measurement"),this._renderTriangularAreaCell("accuracy"))):null}_renderTriangularDistanceAccuracyCell(){const{oiViewModel:e}=this,{triangulatedDistanceAccuracy:t}=e;return u("calcite-table-cell",{alignment:"center"},t?.distanceAccuracy?this.getConvertedTriangularDistanceMeasurementString(t.distanceAccuracy):u("calcite-icon",{icon:"hourglass-active",scale:"s"}))}_renderTriangularAreaCell(e){const{oiViewModel:t}=this,{triangulatedAreaMeasurement:a}=t;return u("calcite-table-cell",{alignment:"center"},a?this.getConvertedTriangularAreaString(e):u("calcite-icon",{icon:"hourglass-active",scale:"s"}))}_renderTriangularDistanceAngleAccuracyCell(){const{oiViewModel:e}=this,{triangulatedDistanceAccuracy:t}=e;return u("calcite-table-cell",{alignment:"center"},t?.angleAccuracy?this.getConvertedTriangularDistanceAngularResultsString(t.angleAccuracy):u("calcite-icon",{icon:"hourglass-active",scale:"s"}))}_renderTriangularDistanceMeasurementResults(){const{oiViewModel:e,messages:t}=this,{distance:a,horizontal:r,vertical:n,slope:c,aspect:i,measurementTable:l,value:o,accuracy:m}=t,{triangulatedDistanceMeasurement:g,triangularMeasurementActive:d,measureType:h}=e;return d&&"distance"===h&&g?u("calcite-table",{bordered:!0,caption:l,class:s.measurementsTable,scale:"s"},u("calcite-table-row",{slot:"table-header"},u("calcite-table-header",{alignment:"center",heading:"Type"}),u("calcite-table-header",{alignment:"center",heading:o}),u("calcite-table-header",{alignment:"center",heading:m})),u("calcite-table-row",null,u("calcite-table-cell",{alignment:"center"},a),u("calcite-table-cell",{alignment:"center"},g?.distance?this.getConvertedTriangularDistanceMeasurementString(g.distance):u("calcite-icon",{icon:"hourglass-active",scale:"s"})),this._renderTriangularDistanceAccuracyCell()),u("calcite-table-row",null,u("calcite-table-cell",{alignment:"center"},r),u("calcite-table-cell",{alignment:"center"},g?.horizontalDistance?this.getConvertedTriangularDistanceMeasurementString(g.horizontalDistance):u("calcite-icon",{icon:"hourglass-active",scale:"s"})),this._renderTriangularDistanceAccuracyCell()),u("calcite-table-row",null,u("calcite-table-cell",{alignment:"center"},n),u("calcite-table-cell",{alignment:"center"},g?.verticalDistance?this.getConvertedTriangularDistanceMeasurementString(g.verticalDistance):u("calcite-icon",{icon:"hourglass-active",scale:"s"})),this._renderTriangularDistanceAccuracyCell()),u("calcite-table-row",null,u("calcite-table-cell",{alignment:"center"},c),u("calcite-table-cell",{alignment:"center"},g?.slope?this.getConvertedTriangularDistanceAngularResultsString(g.slope):u("calcite-icon",{icon:"hourglass-active",scale:"s"})),this._renderTriangularDistanceAngleAccuracyCell()),u("calcite-table-row",null,u("calcite-table-cell",{alignment:"center"},i),u("calcite-table-cell",{alignment:"center"},g?.aspect?this.getConvertedTriangularDistanceAngularResultsString(g.aspect):u("calcite-icon",{icon:"hourglass-active",scale:"s"})),this._renderTriangularDistanceAngleAccuracyCell())):null}render(){return u("calcite-panel",{class:s.measurementResults,key:`measurement-result-container-${this.measurementType}`},this._renderStartMeasurementMessage(),this._renderNewMeasurementButton(),this._renderUnitSelect(),this._renderActiveMeasurementResults())}};e([r()],m.prototype,"_measurementResult",null),e([r()],m.prototype,"_measurementAccuracy",null),e([r()],m.prototype,"_measurementUnit",null),e([r()],m.prototype,"_measurementUnitOptions",null),m=e([n("esri.widgets.OrientedImageryViewer.components.ImageMeasurementWidget")],m);const g=m;export{g 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.33/esri/copyright.txt for details.
4
4
  */
5
- const e="esri-oriented-imagery-viewer",t=`${e}__carousel`,a=`${e}__image-enhancement`,o=`${e}__navigation`,r="--oi-navigation-tool-rotation-from",n="--oi-navigation-tool-rotation-to",i=`${o}-ui`,s=`${i}__direction`,$=`${e}__image-overlays`,m={alert:`${e}__alert`,addCoverage:`${e}__body-additional-coverage`,addExpPoints:`${e}__body-additional-camera-locations`,body:`${e}__body`,carousel:`${e}__carousel`,carouselContainer:`${t}-container`,carouselContent:`${t}-content`,carouselItem:`${t}-item`,carouselItemWrapper:`${t}-item-wrapper`,close:`${e}__close`,currentCoverage:`${e}__body-current-coverage`,feature:`${o}-feature`,footprint:`${e}__body-footprint`,imageEnhancementToolContainer:`${a}-tool-container`,imageEnhancementTools:`${a}-tools`,imageEnhancementWrapper:`${a}-wrapper`,imageOverlays:$,imageOverlaysContainer:`${$}-container`,imageOverlaysNoResult:`${$}-no-result`,imageOverlaysIncreasedHeight:`${$}-increased-height`,imageOverlaysLayerList:`${$}-layer-list`,measurementResults:`${e}__measurement-results`,measurementsBar:`${e}__measurements-bar`,measurementsButton:`${e}__measurements-button`,measurementsTable:`${e}__measurements-table`,measurementDisplay:`${e}__measurement-display`,messageBox:`${e}__message-box`,navigationPathOffset0:`${o}-feature-path-stop-offset-0`,navigationPathOffset1:`${o}-feature-path-stop-offset-1`,navigationWrapper:`${o}-wrapper`,navigationZoomed:`${o}-wrapper--zoomed`,north:`${o}-pointer-north`,outerSector:`${o}-sector-outer`,overlaysSwitch:`${$}-switch`,pointer:`${o}-pointer`,rotateWithAnimation:`${o}-animate`,sector:`${o}-sector`,sectorCross:`${o}-sector-cross`,sectorDisabled:`${o}-sector-disabled`,sectorEnabled:`${o}-sector-enabled`,sectorSeparator:`${o}-sector-separator`,selectedFeaturePath:`${o}-feature-path`,sketchTools:`${e}__sketch-tools`,submenu:`${e}__submenu`,viewer:`${e}__viewer`,viewerHidden:`${e}__viewer--hidden`,viewerContainer:`${e}__viewer-container`,navigationUI:i,navigationDirection:s,navigationDirectionPad:`${s}-pad`,navigationTop:`${s}--top`,navigationBottom:`${s}--bottom`,navigationLeft:`${s}--left`,navigationRight:`${s}--right`};export{t as carousel,m as css,a as imageEnhancement,o as navigation,r as navigationToolRotationFrom,n as navigationToolRotationTo,e as root};
5
+ const e="esri-oriented-imagery-viewer",t=`${e}__carousel`,a=`${e}__image-enhancement`,o=`${e}__navigation`,r="--oi-navigation-tool-rotation-from",n="--oi-navigation-tool-rotation-to",i=`${o}-ui`,s=`${i}__direction`,$=`${e}__image-overlays`,m={alert:`${e}__alert`,addCoverage:`${e}__body-additional-coverage`,addExpPoints:`${e}__body-additional-camera-locations`,body:`${e}__body`,carousel:`${e}__carousel`,carouselContainer:`${t}-container`,carouselContent:`${t}-content`,carouselItem:`${t}-item`,carouselItemWrapper:`${t}-item-wrapper`,close:`${e}__close`,currentCoverage:`${e}__body-current-coverage`,feature:`${o}-feature`,footprint:`${e}__body-footprint`,imageEnhancementToolContainer:`${a}-tool-container`,imageEnhancementTools:`${a}-tools`,imageEnhancementWrapper:`${a}-wrapper`,imageOverlays:$,imageOverlaysContainer:`${$}-container`,imageOverlaysNoResult:`${$}-no-result`,imageOverlaysIncreasedHeight:`${$}-increased-height`,imageOverlaysLayerList:`${$}-layer-list`,measurementResults:`${e}__measurement-results`,measurementsBar:`${e}__measurements-bar`,measurementsButton:`${e}__measurements-button`,measurementsTable:`${e}__measurements-table`,measurementDisplay:`${e}__measurement-display`,messageBox:`${e}__message-box`,navigationPathOffset0:`${o}-feature-path-stop-offset-0`,navigationPathOffset1:`${o}-feature-path-stop-offset-1`,navigationWrapper:`${o}-wrapper`,navigationZoomed:`${o}-wrapper--zoomed`,north:`${o}-pointer-north`,outerSector:`${o}-sector-outer`,overlaysSwitch:`${$}-switch`,pointer:`${o}-pointer`,rotateWithAnimation:`${o}-animate`,sector:`${o}-sector`,sectorCross:`${o}-sector-cross`,sectorDisabled:`${o}-sector-disabled`,sectorEnabled:`${o}-sector-enabled`,sectorSeparator:`${o}-sector-separator`,selectedFeaturePath:`${o}-feature-path`,sketchTools:`${e}__sketch-tools`,submenu:`${e}__submenu`,viewer:`${e}__viewer`,viewerHidden:`${e}__viewer--hidden`,viewerContainer:`${e}__viewer-container`,viewerContainerMeasurement:`${e}__viewer-container-measurement`,navigationUI:i,navigationDirection:s,navigationDirectionPad:`${s}-pad`,navigationTop:`${s}--top`,navigationBottom:`${s}--bottom`,navigationLeft:`${s}--left`,navigationRight:`${s}--right`};export{t as carousel,m as css,a as imageEnhancement,o as navigation,r as navigationToolRotationFrom,n as navigationToolRotationTo,e as root};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{throwIfAborted as t}from"../../core/promiseUtils.js";import{formatLength as e,formatArea as r}from"../../core/quantityFormatUtils.js";import{createLength as n,createArea as a}from"../../core/quantityUtils.js";import{distance as o}from"../../core/libs/gl-matrix-2/math/vec2.js";import{geodesicDensify as i,simplify as s,geodesicLength as c,planarLength as u,planarArea as l,geodesicArea as f}from"../../geometry/geometryEngine.js";import m from"../../geometry/Point.js";import p from"../../geometry/Polygon.js";import y from"../../geometry/Polyline.js";import{projectWithZConversion as h,project as g}from"../../geometry/projection.js";import x from"../../geometry/SpatialReference.js";import{isSupported as w,geodesicLengths as d,geodesicAreas as v}from"../../geometry/support/geodesicUtils.js";import{imageToWorld as R,imageToWorldPanoramic as z}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as M}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as P,worldToImagePanoramic as j}from"../../layers/orientedImagery/transformations/worldToImage.js";const E=1e5;function b(t,e){let r=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return r<0&&(r+=180),r*Math.PI/180}function I(t,e){let r=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return r<0&&(r+=180),r*Math.PI/180}function q(t,e,r){if(!t?.length||!e?.length||!r)return;const[n,a]=t,[,o]=e,i=o-a;return[n+i*Math.cos(r),a+i*Math.sin(r)]}function L(t,e,r){if(w(t)){const t=d([e],"meters")[0];return{area:v([r],"square-meters")[0],perimeter:t}}const n=x.WGS84,a=g(e,n),o=g(r,n);let c=i(o,E);if(c=s(c),!c)return null;const u=d([a],"meters")[0];return{area:v([c],"square-meters")[0],perimeter:u}}async function W(e,r,n,a,o=!1,i){if(r.length<2||!a||!n||!e)return null;const s=Q(n,e);if(!s)return null;const c=r.map((t=>[t.x,t.y])),u=c.at(0),l=c.at(-1);if(!u||!l)return null;const f=s.map((t=>tt([u,l],t,e,o,!1))),m=await Promise.all(f);t(i);let p=0;for(const t of m){if(!t)return null;const e=Math.abs(t-a);p=Math.max(e,p)}return p}async function G(e,r,n,a,o,i=!1,s){if(r.length<2||!a||!n||!e)throw new Error("Missing parameters");const c=X(n,e),u=r.map((t=>[t.x,t.y])),l=u.at(0),f=u.at(-1),m=c.map((t=>et([l,f],t,e,o,i,!1))),p=await Promise.all(m);t(s);let y=0;for(const t of p){if(!t)return 0;const e=Math.abs(t-a);y=Math.max(e,y)}return y}function k(t,e){const r=K(t,!1);if(!r?.length)return;return 20*o([r[0].x,r[0].y],[r.at(-1).x,r.at(-1).y])/e}function D(t){const e=t.spatialReference;if(e.isGeographic){if(w(e))return d([t],"meters")[0];const r=g(t,x.WGS84);return d([r],"meters")[0]}return e.isWebMercator?c(t,"meters"):u(t,"meters")}function U(t){if(!t?.length)throw new Error("Invalid deviations array");const[e,r,n]=[0,1,2].map((e=>t.map((t=>t[e])).filter((t=>null!==t)))).map((t=>t.length?$(t):0));return[e,r,n]}function F(t,e){const r=s(e);if(!r)return null;const n=u(t,"meters");return{area:l(r,"square-meters"),perimeter:n}}function S(t,e){let r=i(e,E,"meters");if(r=s(r),!r)return null;const n=c(t,"meters");return{area:f(r,"square-meters"),perimeter:n}}async function T(e,r,n){if(!r||!e)throw new Error("Missing required parameters");const a=await R(e,r);t(n);const o=a.clone();o.z?o.z+=20:o.z=20;const{averageElevation:i,cameraPitch:s,cameraRoll:c,farDistance:u,...l}=r;return P(o,l)}async function H(e,r,n,a){const{attributes:o}=n,{location:i}=o,{updateElevationProps:s,...c}=r;if(!e||!r)throw new Error("Missing parameters");let u=i.clone();u.spatialReference.isGeographic&&(u=await h(u,x.WebMercator));const l=await z(e,{...c,cameraLocation:u},s);t(a);const f=l.clone();return f.z?f.z+=20:f.z=20,j(f,c)}function O(t,e,r,n,a=0,i=1,s){const{averageElevation:c,cameraPitch:u,cameraRoll:l,farDistance:f,...p}=n;if(a>=5||i<=.1)return{value:t};const y=new m({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:n.cameraLocation.spatialReference}),h=P(y,p),g=o([r[0].x,r[0].y],[h.x,h.y]),x=r.at(0),w=r.at(-1);if(!x||!w)return null;const d=o([x.x,x.y],[w.x,w.y])*t/g;return O(d,e,r,n,a+1,Math.abs(t-d))}function V(t,e,r,n,a=0,i=1,s){const{averageElevation:c,horizontalFieldOfView:u,verticalFieldOfView:l,farDistance:f,...p}=n;if(a>=5||i<=.1)return{value:t};const y=new m({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:n.cameraLocation.spatialReference}),h=j(y,p),g=o([r[0].x,r[0].y],[h.x,h.y]),x=r.at(0),w=r.at(-1);if(!x||!w)return null;const d=o([x.x,x.y],[w.x,w.y])*t/g;return V(d,e,r,n,a+1,Math.abs(t-d))}async function A(t,e){const{updateElevationProps:r,...n}=e;return await R(t,n,r)}async function B(t,e){const{updateElevationProps:r,...n}=e;return z(t,n,r)}function C(t){navigator.clipboard.writeText(t).catch((t=>{throw t}))}function J(t){const e=t.map((t=>[t.x,t.y])),r=t[0].spatialReference;return new y({paths:[e],spatialReference:r})}function K(t,e){return t.map((t=>({x:e?.5+t[0]:t[0],y:e?.5-t[1]:t[1]})))}function N(t,r,a,o,i){const s="measurement"===t?r:a;if(i&&s)return e(o,n(s,"meters"),i,3)||null}function Q(t,e){const{cameraPitch:r,cameraRoll:n,cameraLocation:a}=t,{x:o,y:i,z:s,spatialReference:c}=a;if(e.every((t=>0===t))||!e||!e.length)return null;const[u,l,,f,p]=e,y=[-f,0,f],h=[-p,0,p],g=[-u,0,u],x=[-l,0,l],w=[];for(const d of y)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=r+d,f.cameraRoll=n+e,f.cameraLocation=new m({x:o+a,y:i+u,z:s?s+l:0,spatialReference:{wkid:c.wkid}}),w.push(f)}return w}function X(t,e){const{cameraHeading:r,cameraLocation:n}=t,{x:a,y:o,z:i,spatialReference:s}=n;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]:[],p=c>0?[-c,0,c]:[],y=u>0?[-u,0,u]:[],h=[];for(const g of f)for(const e of p)for(const n of p)for(const c of y){const u={...t};u.cameraHeading=r+g,u.cameraLocation=new m({x:a+e,y:o+n,z:i?i+c:0,spatialReference:{wkid:s.wkid}}),h.push(u)}return h}function Y(t,r,a,o,i){const s="measurement"===t?r:$(a);if(i&&s)return e(o,n(s,"meters"),i,3)||null}function Z(t,e,n,o,i){const s="measurement"===t?e:n;if(i&&s)return r(o,a(s,"square-meters"),i,3)||null}function $(t){return Math.sqrt(t.reduce(((t,e)=>t+e**2),0))}function _(t,e,r){if("default"===e)return t;const n={x:t[0],y:t[1],z:t[2]},a=M(n,r[0],r[1]);return[a.x,a.y]}async function tt(e,r,n,a=!1,i=!1,s){if(!e||!r||e.length<2)return null;const c=K(e,a);if(!c||c.length<2)return null;const[u,l]=[c[0],c.at(-1)];if(!l)return null;const f=[u],m=await R(u,r);t(s);const p=m.clone();p.z?p.z+=20:p.z=20;const{averageElevation:y,cameraPitch:h,cameraRoll:g,farDistance:x,...w}=r,d=P(p,w),v=o([u.x,u.y],[d.x,d.y]),z=b(u,d);if(!z)return;const M=q([u.x,u.y],[l.x,l.y],z);if(!M?.length)return;f.push({x:M[0],y:M[1]});const j=20*o([f[0].x,f[0].y],[f[1].x,f[1].y])/v;if(!i)return j;const E=O(j,m,f,r,0,1);return E?.value}async function et(e,r,n,a,i=!1,s=!1,c){const{attributes:u}=a,{location:l}=u,{updateElevationProps:f,...m}=r;if(!e||!r||e.length<2)throw new Error("Invalid parameters");const p=K(e,i),[y,g]=[p[0],p.at(-1)],w=[y];let d=l.clone();d.spatialReference.isGeographic&&(d=await h(d,x.WebMercator));const v=await z(y,{...m,cameraLocation:d},f);t(c);const R=v.clone();R.z?R.z+=20:R.z=20;const M=j(R,m),P=o([y.x,y.y],[M.x,M.y]),E=b(y,M);if(!E)return;const I=q([y.x,y.y],[g.x,g.y],E);if(!I?.length)return;w.push({x:I[0],y:I[1]});const L=20*o([w[0].x,w[0].y],[w[1].x,w[1].y])/P;if(!s)return L;const W=V(L,v,w,r,0,1);return W?.value}async function rt(t,e,r=!1){if(t.length<3)return null;const n=K(t,r),a=await A(n,e),o=a.map((({x:t,y:e})=>[t,e]));t.push(t[0]),o.push(o[0]);const i=a[0].spatialReference,s=new y({paths:[o],spatialReference:i}),c=new p({rings:[o],spatialReference:i});return i.isGeographic?L(i,s,c):i.isWebMercator?S(s,c):F(s,c)}async function nt(e,r,n=!1,a){if(e.length<3)return null;const o=K(e,n),i=await B(o,r);t(a);const s=i.map((({x:t,y:e})=>[t,e]));e.push(e[0]),s.push(s[0]);const c=i[0].spatialReference,u=new y({paths:[s],spatialReference:c}),l=new p({rings:[s],spatialReference:c});return c.isGeographic?L(c,u,l):c.isWebMercator?S(u,l):F(u,l)}async function at(t,e,r=!1){const n=K(t,r);return D(J(await A(n,e)))}async function ot(e,r,n=!1,a){const o=K(e,n),i=await B(o,r);t(a);return D(J(i))}export{b as calculateAngle,I as calculateAnglePano,q as calculateCorrectedPixel,W as calculateHeightAccuracy,G as calculateHeightAccuracyPanoramic,k as calculateHeightFromTemporaryDistance,U as calculateLocationAccuracyFromDeviations,H as calculateReferenceImagePointPanoramic,T as calculateTempImagePoint,O as computeHeightIteratively,V as computeHeightIterativelyPanoramic,C as copyToClipboard,K as formatPixels,Q as generateCombinations,X as generateCombinationsPanoramic,Z as getConvertedArea,Y as getConvertedDistance,N as getConvertedHeight,_ as getModeCorrectedPoint,$ as getRootOfSumOfSquaredErrors,tt as heightMeasurement2D,et as heightMeasurementPanoramic,rt as pixelAreaMeasurement2D,nt as pixelAreaMeasurementPanoramic,at as pixelDistanceMeasurement2D,ot as pixelDistanceMeasurementPanoramic};
5
+ import{rad2deg as t}from"../../core/mathUtils.js";import{throwIfAborted as e}from"../../core/promiseUtils.js";import{formatLength as n,formatArea as r}from"../../core/quantityFormatUtils.js";import{createLength as a,createArea 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,e 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 z from"../../geometry/SpatialReference.js";import{e as R}from"../../chunks/areaOperator.js";import{l as d,e as v}from"../../chunks/geodeticAreaOperator.js";import{l as P,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{imageToWorld as L,imageToWorldPanoramic as A}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as D,scaleWithFactor as S}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as U,worldToImagePanoramic 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 P(),k(t)){const t=I([e],"meters")[0];return{area:G([n],"square-meters")[0],perimeter:t}}const r=z.WGS84,a=M(e,r),o=M(n,r);let s=j(o,F);if(s=W(s),!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=Rt(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=>Ot([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=dt(r,t),u=n.map((t=>[t.x,t.y])),l=u.at(0),f=u.at(-1),m=c.map((e=>Et([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=Mt(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,z.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?jt(t):0));return[e,n,r]}function Y(t,e){const n=W(e);if(!n)return null;const r=E(t);return{area:R(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(),P(),b()]);let n=j(e,F);if(n=W(n),!n)return null;const r=O(t);return{area:v(n),perimeter:r}}async function _(t,n,r){if(!n||!t)throw new Error("Missing required parameters");const a=await L(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 U(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,z.WebMercator));const l=await A(t,{...c,cameraLocation:u},i);e(a);const f=l.clone();return f.z?f.z+=20:f.z=20,B(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=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 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=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 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(Dt([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 Gt(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,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 Gt(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 ht(t,e){if(!t)return null;const n=new y({x:e.geometry.x,y:e.geometry.y,z:e.geometry.z,spatialReference:e.spatialReference}),r=Array.isArray(t)?t:[t],a=[];return r.forEach((t=>{let e=!1;t.spatialReference.isWGS84&&(t=q(t,new z({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 z({wkid:4326}))),a.push(c)})),{camera:n,measurePoints:r,tempMeasurePoints:a}}async function yt(t,e){const{updateElevationProps:n,...r}=e;return await L(t,r,n)}async function gt(t,e){const{updateElevationProps:n,...r}=e;return A(t,r,n)}function xt(t){navigator.clipboard.writeText(t).catch((t=>{throw t}))}function wt(t){const e=t.map((t=>[t.x,t.y])),n=t[0].spatialReference;return new x({paths:[e],spatialReference:n})}function Mt(t,e){return t.map((t=>({x:e?.5+t[0]:t[0],y:e?.5-t[1]:t[1]})))}function zt(t,e,r,o,s){const i="measurement"===t?e:r;if(s&&i)return n(o,a(i,"meters"),s,3)||null}function Rt(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 dt(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,r,o,s){const i="measurement"===t?e:jt(r);if(s&&i)return n(o,a(i,"meters"),s,3)||null}function Pt(t,e,n,a,s){const i="measurement"===t?e:n;if(s&&i)return r(a,o(i,"square-meters"),s,3)||null}function jt(t){return Math.sqrt(t.reduce(((t,e)=>t+e**2),0))}function bt(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 Ot(t,n,r,a=!1,o=!1,s){if(!t||!n||t.length<2)return null;const i=Mt(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 L(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=U(p,w),z=f([c.x,c.y],[M.x,M.y]),R=T(c,M);if(!R)return;const d=V([c.x,c.y],[u.x,u.y],R);if(!d?.length)return;l.push({x:d[0],y:d[1]});const v=20*f([l[0].x,l[0].y],[l[1].x,l[1].y])/z;if(!o)return v;const P=et(v,m,l,n,0,1);return P?.value}async function Et(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=Mt(t,o),[h,y]=[p[0],p.at(-1)],g=[h];let x=u.clone();x.spatialReference.isGeographic&&(x=await w(x,z.WebMercator));const M=await A(h,{...m,cameraLocation:x},l);e(i);const R=M.clone();R.z?R.z+=20:R.z=20;const d=B(R,m),v=f([h.x,h.y],[d.x,d.y]),P=T(h,d);if(!P)return;const j=V([h.x,h.y],[y.x,y.y],P);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])/v;if(!s)return b;const O=nt(b,M,g,n,0,1);return O?.value}async function qt(t,e,n=!1){if(t.length<3)return null;const r=Mt(t,n),a=await yt(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 Wt(t,n,r=!1,a){if(t.length<3)return null;const o=Mt(t,r),s=await gt(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 kt(t,e,n=!1){const r=Mt(t,n);return Q(wt(await yt(r,e)))}async function It(t,n,r=!1,a){const o=Mt(t,r),s=await gt(o,n);e(a);return Q(wt(s))}async function Gt(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=Lt(l,f),[p,h,y]=l,[g,x,w]=f.map((t=>-t)),[M,z,R]=m,[d,v,P]=[a[0]-r[0],a[1]-r[1],a[2]-r[2]];s(n,p,g,M,h,x,z,y,w,R);const j=i(n);if(0===j)return null;s(n,d,g,M,v,x,z,P,w,R);const q=i(n);s(n,p,d,M,h,v,z,y,P,R);const W=i(n);s(n,p,g,d,h,x,v,y,w,P);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:At(r,k,l),pointOnB:At(a,I,f)}}function Lt(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 At(t,e,n){return[t[0]+e*n[0],t[1]+e*n[1],t[2]+e*n[2]]}function Dt(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=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,pt as computeTriangulatedAreaMeasurement,mt as computeTriangulatedDistanceMeasurement,ht as computeTriangulatedVector,xt as copyToClipboard,Mt as formatPixels,Rt as generateCombinations,dt as generateCombinationsPanoramic,Pt as getConvertedArea,vt as getConvertedDistance,zt as getConvertedHeight,bt as getModeCorrectedPoint,jt as getRootOfSumOfSquaredErrors,Ot as heightMeasurement2D,Et as heightMeasurementPanoramic,qt as pixelAreaMeasurement2D,Wt as pixelAreaMeasurementPanoramic,kt as pixelDistanceMeasurement2D,It as pixelDistanceMeasurementPanoramic,St as scale,Gt as solveSkewLinesIntersection,Dt as subtract};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{watch as t,syncAndInitial as o}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";const a={sketchHandles:"sketch-handles"},r=r=>{let n=class extends r{initialize(){this.addHandles(t((()=>this.viewModel?.sketch),(e=>{this.removeHandles(a.sketchHandles),e&&this.addHandles([e.on("create",(e=>this.handleCreate(e))),e.on("update",(e=>this.handleUpdate(e))),e.on("undo",(e=>this.handleUndo(e))),e.on("redo",(e=>this.handleRedo(e))),e.on("delete",(e=>this.handleDelete(e))),e.on("destroy",(()=>this.handleDestroy())),e.on("duplicate",(e=>this.handleDuplicate(e))),t((()=>e.activeComponent),(e=>{"draw-2d"!==e?.type&&"draw-3d"!==e?.type||(e.elevationLockOnVertexAddDisabled=!0)}),o)],a.sketchHandles)}),o))}handleCreate(e){}handleUpdate(e){}handleUndo(e){}handleRedo(e){}handleDelete(e){}handleDestroy(){}handleDuplicate(e){}};return e([s()],n.prototype,"type",void 0),e([s()],n.prototype,"viewModel",void 0),n=e([d("esri.widgets.OrientedImageryViewer.mixins.SketchHandlerMixin")],n),n};export{r as SketchHandlerMixin};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{watch as t,syncAndInitial as o}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";const r={sketchHandles:"sketch-handles"},a=a=>{let n=class extends a{initialize(){this.addHandles(t((()=>this.sketch),(e=>{this.removeHandles(r.sketchHandles),e&&this.addHandles([e.on("create",(e=>this.handleCreate(e))),e.on("update",(e=>this.handleUpdate(e))),e.on("undo",(e=>this.handleUndo(e))),e.on("redo",(e=>this.handleRedo(e))),e.on("delete",(e=>this.handleDelete(e))),e.on("destroy",(()=>this.handleDestroy())),e.on("duplicate",(e=>this.handleDuplicate(e))),t((()=>e.activeComponent),(e=>{"draw-2d"!==e?.type&&"draw-3d"!==e?.type||(e.elevationLockOnVertexAddDisabled=!0)}),o)],r.sketchHandles)}),o))}get sketch(){return this.viewModel?.sketch}handleCreate(e){}handleUpdate(e){}handleUndo(e){}handleRedo(e){}handleDelete(e){}handleDestroy(){}handleDuplicate(e){}};return e([s()],n.prototype,"sketch",null),e([s()],n.prototype,"type",void 0),e([s()],n.prototype,"viewModel",void 0),n=e([d("esri.widgets.OrientedImageryViewer.mixins.SketchHandlerMixin")],n),n};export{a as SketchHandlerMixin};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
+ */
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{formatLength as t,formatAngle as r}from"../../../core/quantityFormatUtils.js";import{createLength as a,createAngle as s}from"../../../core/quantityUtils.js";import"../../../core/Logger.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import"../../../core/Error.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{copyToClipboard as i,getConvertedArea as c}from"../imageMeasurementUtils.js";import{ImageMeasurementMixin as u}from"./ImageMeasurementMixin.js";import{substitute as o}from"../../../intl/substitute.js";const g=g=>{let m=class extends(u(g)){copyActiveMeasurementResults(e,t){t?this.copyTriangularMeasurementResult(e):this.copyGroundMeasurementResult(e)}copyGroundMeasurementResult(e){let t,r;switch(e){case"area":t={measurement:this.getConvertedAreaString("measurement"),accuracy:this.getConvertedAreaString("accuracy")},r="{measurement} ± {accuracy}";break;case"distance":t={measurement:this.getConvertedDistanceString("measurement"),accuracy:this.getConvertedDistanceString("accuracy")},r="{measurement} ± {accuracy}";break;case"height":t={measurement:this.getConvertedHeightString("measurement"),accuracy:this.getConvertedHeightString("accuracy")},r="{measurement} ± {accuracy}"}const a=o(r,t);i(a)}copyTriangularMeasurementResult(e){let t=null;switch(e){case"area":t=this.copyTriangularAreaMeasurements();break;case"distance":t=this.copyTriangularDistanceMeasurements()}t&&i(t)}copyTriangularAreaMeasurements(){const e={measurement:this.getConvertedTriangularAreaString("measurement"),accuracy:this.getConvertedTriangularAreaString("accuracy")};return o("{measurement} ± {accuracy}",e)}copyTriangularDistanceMeasurements(){const{oiViewModel:e}=this,{triangulatedDistanceMeasurement:t,triangulatedDistanceAccuracy:r}=e;if(!t)return;const{distance:a,horizontalDistance:s,verticalDistance:n,slope:i,aspect:c}=t,{distanceAccuracy:u=0,angleAccuracy:g=0}=r??{},m={distance:this.getConvertedTriangularDistanceMeasurementString(a),distanceAccuracy:this.getConvertedTriangularDistanceMeasurementString(u),horizontal:this.getConvertedTriangularDistanceMeasurementString(s),vertical:this.getConvertedTriangularDistanceMeasurementString(n),slope:this.getConvertedTriangularDistanceAngularResultsString(i),angleAccuracy:this.getConvertedTriangularDistanceAngularResultsString(g),aspect:this.getConvertedTriangularDistanceAngularResultsString(c)};return o(" Distance : {distance} ± {distanceAccuracy} , Horizontal : {horizontal} ± {distanceAccuracy}, Vertical : {vertical} ± {distanceAccuracy}, Slope : {slope} ± {angleAccuracy}, Aspect : {aspect} ± {angleAccuracy}",m)}getConvertedTriangularDistanceMeasurementString(e){const{measurementUnitMessages:r,pixelMeasurementUnit:s}=this;return t(r,a(e,"meters"),s,3)||null}getConvertedTriangularDistanceAngularResultsString(e){return r(s(e,"degrees"),"arithmetic",3)||null}getConvertedTriangularAreaString(e){const{oiViewModel:t,measurementUnitMessages:r,pixelAreaMeasurementUnit:a,messages:s}=this,{triangulatedAreaAccuracy:n,triangulatedAreaMeasurement:i}=t;return c(e,i,n,r,a)??s.startMeasurement}};return m=e([n("esri.widgets.OrientedImageryViewer.mixins.TriangulatedImageMeasurementMixin")],m),m};export{g as TriangulatedImageMeasurementMixin};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
+ */
5
+ import{_ as r}from"../../../chunks/tslib.es6.js";import{property as e}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{SketchHandlerMixin as s}from"./SketchHandlerMixin.js";const t=t=>{let i=class extends(s(t)){get sketch(){return this.viewModel?.sketchTriangular}};return r([e()],i.prototype,"sketch",null),i=r([o("esri.widgets.OrientedImageryViewer.mixins.TriangulatedSketchHandlerMixin")],i),i};export{t as TriangulatedSketchHandlerMixin};