@arcgis/core 5.0.0-next.17 → 5.0.0-next.19

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 (192) hide show
  1. package/AttributeBinsGraphic.js +1 -1
  2. package/analysis/ElevationProfile/ElevationProfileLineGround.js +1 -1
  3. package/analysis/ElevationProfile/ElevationProfileLineInput.js +1 -1
  4. package/analysis/ElevationProfile/ElevationProfileLineQuery.js +1 -1
  5. package/analysis/ElevationProfile/ElevationProfileLineScene.js +1 -1
  6. package/arcade/featureSetUtils.js +1 -1
  7. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  8. package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
  9. package/arcade/featureset/sources/FeatureLayerOGC.js +5 -0
  10. package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
  11. package/arcade/featureset/support/FeatureSet.js +1 -1
  12. package/arcade/featureset/support/shared.js +1 -1
  13. package/assets/esri/core/workers/RemoteClient.js +1 -1
  14. package/assets/esri/core/workers/chunks/057d59ee6144e5890780.js +1 -0
  15. package/assets/esri/core/workers/chunks/{adf7ccf4ef629211c7ee.js → 08aacbfb651cc2e1c054.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{31b5900119dd7cd9e7d3.js → 0a6ad58ca4ca0cba2fa0.js} +1 -1
  17. package/assets/esri/core/workers/chunks/0d8d3d0de49064971874.js +1 -0
  18. package/assets/esri/core/workers/chunks/{b87bc987983b31c13f64.js → 0f1b9d69961dad0b922f.js} +1 -1
  19. package/assets/esri/core/workers/chunks/110cc01dd6af7ee125d4.js +1 -0
  20. package/assets/esri/core/workers/chunks/11687718c8635eb7bf37.js +1 -0
  21. package/assets/esri/core/workers/chunks/{5f6df4a3376b52ead53f.js → 14f994b1dd682bf2d61a.js} +1 -1
  22. package/assets/esri/core/workers/chunks/3538eb39ebb58acedd67.js +1 -0
  23. package/assets/esri/core/workers/chunks/{658cd45b5fb304fd840a.js → 3aa77696c5ea54a238da.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{49571d6875de1f2e7e25.js → 4b9dfdc23ba3d6ebcc1b.js} +2 -2
  25. package/assets/esri/core/workers/chunks/{02a22dd6d208a925cc5a.js → 52cf643621662712dc85.js} +1 -1
  26. package/assets/esri/core/workers/chunks/5755b11272b777507612.js +1 -0
  27. package/assets/esri/core/workers/chunks/{d69265ceabfa92b40bb7.js → 58969dde8c3d0b2a9829.js} +1 -1
  28. package/assets/esri/core/workers/chunks/6e4829b52ade3e41ccc4.js +1 -0
  29. package/assets/esri/core/workers/chunks/{4a89e120be142ab58a27.js → 7224b321606116fd691c.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{888f188541f8bd68e33e.js → 72f1c3d97e7b9546c113.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{a4518f25b9f8fe704286.js → 76e945da8f30d8641c3d.js} +4 -4
  32. package/assets/esri/core/workers/chunks/{257f17b3836a623a9dbe.js → 795b09ff7a8f4e91f4dc.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{3ac7562ea90f91a9f30c.js → 82b2741e75c2e9b88252.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{5d2e5774768d8f290343.js → b656e8fd374113523404.js} +1 -1
  35. package/assets/esri/core/workers/chunks/bccb9ac572bc093fb177.js +1 -0
  36. package/assets/esri/core/workers/chunks/{79dbfa2b9b332ca0002f.js → c52161b94c0fb071747e.js} +1 -1
  37. package/assets/esri/core/workers/chunks/db76958fd9f54b6bd324.js +1 -0
  38. package/assets/esri/core/workers/chunks/e61d7762b56e36dc7e8a.js +1 -0
  39. package/assets/esri/core/workers/chunks/{b30897952494a3e5b9fe.js → e69c2b613bd0210e25ba.js} +1 -1
  40. package/assets/esri/core/workers/chunks/f43e1e1a1b2eb737e00c.js +1 -0
  41. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  42. package/chunks/GlowComposition.glsl.js +46 -46
  43. package/chunks/ImageMaterial.glsl.js +1 -1
  44. package/chunks/ShadedColorMaterial.glsl.js +10 -10
  45. package/config.js +1 -1
  46. package/editing/templateUtils.js +1 -1
  47. package/interfaces.d.ts +167 -51
  48. package/intl/locale.js +1 -1
  49. package/kernel.js +1 -1
  50. package/layers/BingMapsLayer.js +1 -1
  51. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  52. package/layers/PointCloudLayer.js +1 -1
  53. package/layers/SceneLayer.js +1 -1
  54. package/layers/VideoLayer.js +1 -1
  55. package/layers/graphics/sources/OGCFeatureSource.js +1 -1
  56. package/layers/mixins/SceneService.js +1 -1
  57. package/layers/ogc/ogcFeatureUtils.js +1 -1
  58. package/libs/parquet/parquet.js +1 -1
  59. package/package.json +1 -1
  60. package/renderers/support/RasterSymbolizer.js +1 -1
  61. package/rest/support/QueryMixin.js +1 -1
  62. package/support/revision.js +1 -1
  63. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  64. package/symbols/cim/cimAnalyzer.js +1 -1
  65. package/undoredo/support/ServiceVersionInfo.js +1 -1
  66. package/undoredo/support/Services.js +1 -1
  67. package/views/2d/LabelManager.js +1 -1
  68. package/views/2d/engine/webgl/FeatureTile.js +1 -1
  69. package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
  70. package/views/2d/engine/webgl/VideoScreenRenderer.js +1 -1
  71. package/views/2d/engine/webgl/animations/store/AnimationStore.js +1 -1
  72. package/views/2d/engine/webgl/shaderGraph/techniques/colorize/ColorizeTechnique.js +1 -1
  73. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityResources.js +1 -1
  74. package/views/2d/engine/webgl/shaderGraph/techniques/drop-shadow/DropShadowTechnique.js +1 -1
  75. package/views/2d/engine/webgl/shaderGraph/techniques/opacity/OpacityTechnique.js +1 -1
  76. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
  77. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterHighlightTechnique.js +1 -1
  78. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/textureUtils.js +1 -1
  79. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/BaseRasterHighlightShader.js +5 -0
  80. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterRangeHighlightShader.js +1 -1
  81. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterXYBandHighlightShader.js +5 -0
  82. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/math.js +1 -1
  83. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/stretch.js +1 -1
  84. package/views/2d/engine/webgl/textureUtils.js +1 -1
  85. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  86. package/views/2d/layers/features/FeatureContainer.js +1 -1
  87. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  88. package/views/3d/GroundView3D.js +1 -1
  89. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  90. package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
  91. package/views/3d/analysis/images/Factory.js +1 -1
  92. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  93. package/views/3d/environment/EnvironmentManager.js +1 -1
  94. package/views/3d/environment/SceneViewEnvironment.js +1 -1
  95. package/views/3d/environment/SunLighting.js +1 -1
  96. package/views/3d/environment/VirtualLighting.js +1 -1
  97. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  98. package/views/3d/layers/DrapedSubView3D.js +1 -1
  99. package/views/3d/layers/FlowSubView3D.js +1 -1
  100. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  101. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  102. package/views/3d/layers/MediaLayerView3D.js +1 -1
  103. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  104. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  105. package/views/3d/layers/SceneLayerView3D.js +1 -1
  106. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  107. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  108. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  109. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  110. package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
  111. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  112. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  113. package/views/3d/support/QualityProfile.js +5 -0
  114. package/views/3d/support/QualitySettings.js +1 -1
  115. package/views/3d/support/StreamTextureCollection.js +1 -1
  116. package/views/3d/support/TextureCollection.js +1 -1
  117. package/views/3d/support/engineContent/marker.js +1 -1
  118. package/views/3d/support/engineContent/sdfPrimitives.js +1 -1
  119. package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
  120. package/views/3d/terrain/OverlayRenderer.js +1 -1
  121. package/views/3d/terrain/TerrainSurface.js +1 -1
  122. package/views/3d/terrain/TileCompositor.js +1 -1
  123. package/views/3d/webgl-engine/Stage.js +1 -1
  124. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  125. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  126. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  127. package/views/3d/webgl-engine/core/material/MaterialBase.js +1 -1
  128. package/views/3d/webgl-engine/core/material/RenderTexture.js +1 -1
  129. package/views/3d/webgl-engine/effects/glow/GlowRenderNode.js +1 -1
  130. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  131. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  132. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  133. package/views/3d/webgl-engine/lib/AnimationTimeStep.js +1 -1
  134. package/views/3d/webgl-engine/lib/BasisUtil.js +1 -1
  135. package/views/3d/webgl-engine/lib/DDSUtil.js +1 -1
  136. package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
  137. package/views/3d/webgl-engine/lib/ManagedTexture.js +5 -0
  138. package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
  139. package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
  140. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  141. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  142. package/views/3d/webgl-engine/lib/TextTextureFactory.js +1 -1
  143. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  144. package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
  145. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  146. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  147. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  148. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  149. package/views/3d/webgl-engine/materials/internal/WaterTextureRepository.js +1 -1
  150. package/views/3d/webgl-engine/materials/stippleTextureRepository.js +1 -1
  151. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  152. package/views/GroundView.js +1 -1
  153. package/views/SceneView.js +1 -1
  154. package/views/support/layerViewUtils.js +1 -1
  155. package/views/webgl/Texture.js +1 -1
  156. package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
  157. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  158. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  159. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  160. package/widgets/Editor/VisibleElements.js +1 -1
  161. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  162. package/widgets/Editor/workflowUtils.js +1 -1
  163. package/widgets/Editor.js +1 -1
  164. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  165. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +1 -1
  166. package/widgets/FeatureTable/FieldColumn.js +1 -1
  167. package/widgets/FeatureTable/Grid/Column.js +1 -1
  168. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  169. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  170. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  171. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  172. package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
  173. package/widgets/OrientedImageryViewer.js +1 -1
  174. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  175. package/widgets/smartMapping/SizeSlider.js +1 -1
  176. package/widgets/support/SelectionList/VisibleElements.js +1 -1
  177. package/widgets/support/SelectionList.js +1 -1
  178. package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
  179. package/assets/esri/core/workers/chunks/080268f78436a2f0d996.js +0 -1
  180. package/assets/esri/core/workers/chunks/18474c017ddacd1d3d2c.js +0 -1
  181. package/assets/esri/core/workers/chunks/27e6a6c5610007ac6a54.js +0 -1
  182. package/assets/esri/core/workers/chunks/5415fbcc7ed203fc5575.js +0 -1
  183. package/assets/esri/core/workers/chunks/631fb2e62e48f8be4051.js +0 -1
  184. package/assets/esri/core/workers/chunks/722da7a39a0ad9300752.js +0 -1
  185. package/assets/esri/core/workers/chunks/9595aabbaf411eceea1e.js +0 -1
  186. package/assets/esri/core/workers/chunks/a470f662d73aa8d5d90f.js +0 -1
  187. package/assets/esri/core/workers/chunks/a57751f3d78524c876cd.js +0 -1
  188. package/assets/esri/core/workers/chunks/ac366221e8636b60aee5.js +0 -1
  189. package/assets/esri/core/workers/chunks/dec336700cfb83abbbeb.js +0 -1
  190. package/views/3d/support/DisplayQualityProfile.js +0 -5
  191. package/views/3d/webgl-engine/lib/Texture.js +0 -5
  192. /package/views/3d/webgl-engine/lib/{ITexture.js → IManagedTexture.js} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../Graphic.js";import{createTask as a}from"../../../../core/asyncUtils.js";import{EsriPromise as i}from"../../../../core/Promise.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import n from"../../../../geometry/Polygon.js";import c from"../../../../geometry/Polyline.js";import{load as l}from"../../../../geometry/projectionUtils.js";import m from"../../../../geometry/SpatialReference.js";import{convertSphereVertexToPixelLocation as u,convertPixelToHeadingPitch as h,convertHeadingPitchToSphereVertex as d}from"../../../../layers/orientedImagery/transformations/utils.js";import{getModeCorrectedPoint as p,formatPixels as y}from"../../imageMeasurementUtils.js";import{SketchHandlerMixin as M}from"../../mixins/SketchHandlerMixin.js";let w=[],g=[],v=0,f=class extends(M(i)){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":await this.handlePolylineEvents(e,t);break;case"polygon":await 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]},i=u(t,a.imageSize[0],a.imageSize[1]);this.measurementArray.push([i.x,i.y])}const i=g.reduce((e,t)=>e+t,0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=i}async cursorUpdatePolygonHandler(e){const{mode:t,activeViewer:a}=this.viewModel;if("none"===t||!a?.imageSize)return;const i=e.coordinates;if(w=[...this.polygonVertices],"default"===t)w.push(i);else{const e={x:i[0],y:i[1],z:i[2]},t=u(e,a?.imageSize[0],a?.imageSize[1]);w.push([t.x,t.y])}if(w.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const s=w[0];w=w.filter((e,t)=>0===t||t===w.length-1||JSON.stringify(e)!==JSON.stringify(s));const r=await this._getAreaFromTask(w);r?.area&&r?.perimeter&&(v=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 i=await this._getDistanceFromTask();this.pixelMeasurement=i??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=v>0?v:this.pixelAreaMeasurement}async vertexAddPolygonHandler(e){const{mode:t,activeViewer:a}=this.viewModel,i=e.added,s=i[i.length-1];if(!Array.isArray(s)||"none"===t||!a?.imageSize)return;if("default"===t)this.polygonVertices.push(s);else{const e={x:s[0],y:s[1],z:s[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=g.reduce((e,t)=>e+t,0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=e,this.pixelMeasurement>0&&g.push(this.pixelMeasurement)}resetDistanceMeasurements(){this.measurementArray=[],this.pixelMeasurement=0,g=[]}resetAreaMeasurements(){this.polygonVertices=[],this.pixelAreaMeasurement=0,v=0}async _overlayFirstMeasurement(e,t){switch(t){case"polyline":await this._overlayFirstDistanceMeasurement(e);break;case"polygon":await this._overlayFirstAreaGeometry(e)}}async _overlayFirstDistanceMeasurement(e){const{mode:a,activeTriangulatedViewer:i}=this.viewModel,s=e.geometry?.clone(),r=e.symbol?.clone(),o=i?.imageSize,n=[...s.paths[0]],l="default"===a;if("none"===a||"video"===a||!o)return;const u=l?n:n.map(e=>p(e,"panoramic",o)),h=y(u,!0),d=l?await this.viewModel.getMeasurementProperties():await this.viewModel.getMeasurementPropertiesPanoramic(),M=l?await this.viewModel.getMeasurementProperties(this.viewModel.currentBestFeatureMeasurementImage,this.viewModel.imageMeasurementViewer):await this.viewModel.getMeasurementPropertiesPanoramic(this.viewModel.currentBestFeatureMeasurementImage,this.viewModel.activeTriangulatedViewer);if(h?.length&&d&&M){const e=l?await this.viewModel.imageToImageTransform(h,d,M):await this.viewModel.imageToImageTransformPanoramic(h,d,M),a=e.map(e=>[e.x-.5,-.5-e.y]),i=e.map(({x:e,y:t})=>({x:e-.5,y:-.5-t})).slice(0,2).map(e=>_(e,o)),s=new c({paths:l?[a]:[i],spatialReference:m.WebMercator}),n=new t({geometry:s,symbol:r});await this.viewModel.editOverlayedGraphics(n)}}async _overlayFirstAreaGeometry(e){const{mode:a,activeTriangulatedViewer:i}=this.viewModel,s=e.geometry?.clone(),r=e.symbol?.clone(),o=i?.imageSize,c=[...s.rings[0]],l="default"===a;if("none"===a||"video"===a||!o)return;const u=l?c:c.map(e=>p(e,"panoramic",o)),h=y(u,!0),d=l?await this.viewModel.getMeasurementProperties():await this.viewModel.getMeasurementPropertiesPanoramic(),M=l?await this.viewModel.getMeasurementProperties(this.viewModel.currentBestFeatureMeasurementImage,this.viewModel.imageMeasurementViewer):await this.viewModel.getMeasurementPropertiesPanoramic(this.viewModel.currentBestFeatureMeasurementImage,this.viewModel.activeTriangulatedViewer);if(h?.length&&d&&M){const e=l?await this.viewModel.imageToImageTransform(h,d,M):await this.viewModel.imageToImageTransformPanoramic(h,d,M),a=e.map(e=>[e.x-.5,-.5-e.y]),i=e.map(({x:e,y:t})=>({x:e-.5,y:-.5-t})),s=i.slice(0,l?2:i.length).map(e=>_(e,o)),c=new n({rings:l?[a]:[s],spatialReference:m.WebMercator}),u=new t({geometry:c,symbol:r});await this.viewModel.editOverlayedGraphics(u)}}async _getAreaFromTask(e){const{mode:t}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=a(async a=>{this._areaCalculation=null;const i=await this.viewModel.calculateAreaMeasurement(e,t,a);s(a),this._areaCalculation=i}),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);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=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);s(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 i="default"===t?await this.viewModel.calculateAccuracy(e,"area",a):await this.viewModel.calculateAccuracyPanoramic(e,"area",a);s(a),this._distanceCalculation=i}),await this._calculationTask.promise,this._distanceCalculation)}};e([r()],f.prototype,"type",void 0),e([r()],f.prototype,"measurementArray",void 0),e([r()],f.prototype,"pixelMeasurement",void 0),e([r()],f.prototype,"pixelAreaMeasurement",void 0),e([r()],f.prototype,"polygonVertices",void 0),f=e([o("esri.widgets.OrientedImageryViewer.adapters.sketch.MeasurementAdapter")],f);const A=f,_=(e,t)=>{const{heading:a,pitch:i}=h(e,t[0],t[1]);return d(a,i)};export{A as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../../Graphic.js";import{createTask as a}from"../../../../core/asyncUtils.js";import{EsriPromise as i}from"../../../../core/Promise.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import n from"../../../../geometry/Polygon.js";import c from"../../../../geometry/Polyline.js";import{load as l}from"../../../../geometry/projectionUtils.js";import m from"../../../../geometry/SpatialReference.js";import{convertSphereVertexToPixelLocation as u,convertPixelToHeadingPitch as h,convertHeadingPitchToSphereVertex as d}from"../../../../layers/orientedImagery/transformations/utils.js";import{getPixelLocationFromSphereVertices as p,formatPixels as y}from"../../imageMeasurementUtils.js";import{SketchHandlerMixin as M}from"../../mixins/SketchHandlerMixin.js";let w=[],g=[],v=0,f=class extends(M(i)){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":await this.handlePolylineEvents(e,t);break;case"polygon":await 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]},i=u(t,a.imageSize[0],a.imageSize[1]);this.measurementArray.push([i.x,i.y])}const i=g.reduce((e,t)=>e+t,0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=i}async cursorUpdatePolygonHandler(e){const{mode:t,activeViewer:a}=this.viewModel;if("none"===t||!a?.imageSize)return;const i=e.coordinates;if(w=[...this.polygonVertices],"default"===t)w.push(i);else{const e={x:i[0],y:i[1],z:i[2]},t=u(e,a?.imageSize[0],a?.imageSize[1]);w.push([t.x,t.y])}if(w.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const s=w[0];w=w.filter((e,t)=>0===t||t===w.length-1||JSON.stringify(e)!==JSON.stringify(s));const r=await this._getAreaFromTask(w);r?.area&&r?.perimeter&&(v=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 i=await this._getDistanceFromTask();this.pixelMeasurement=i??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=v>0?v:this.pixelAreaMeasurement}async vertexAddPolygonHandler(e){const{mode:t,activeViewer:a}=this.viewModel,i=e.added,s=i[i.length-1];if(!Array.isArray(s)||"none"===t||!a?.imageSize)return;if("default"===t)this.polygonVertices.push(s);else{const e={x:s[0],y:s[1],z:s[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=g.reduce((e,t)=>e+t,0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=e,this.pixelMeasurement>0&&g.push(this.pixelMeasurement)}resetDistanceMeasurements(){this.measurementArray=[],this.pixelMeasurement=0,g=[]}resetAreaMeasurements(){this.polygonVertices=[],this.pixelAreaMeasurement=0,v=0}async _overlayFirstMeasurement(e,t){switch(t){case"polyline":await this._overlayFirstDistanceMeasurement(e);break;case"polygon":await this._overlayFirstAreaGeometry(e)}}async _overlayFirstDistanceMeasurement(e){const{mode:a,activeTriangulatedViewer:i}=this.viewModel,s=e.geometry?.clone(),r=e.symbol?.clone(),o=i?.imageSize,n=[...s.paths[0]],l="default"===a;if("none"===a||"video"===a||!o)return;const u=l?n:p(n,o),h=l?y(u,!0):u,d=l?await this.viewModel.getMeasurementProperties():await this.viewModel.getMeasurementPropertiesPanoramic(),M=l?await this.viewModel.getMeasurementProperties(this.viewModel.currentBestFeatureMeasurementImage,this.viewModel.imageMeasurementViewer):await this.viewModel.getMeasurementPropertiesPanoramic(this.viewModel.currentBestFeatureMeasurementImage,this.viewModel.activeTriangulatedViewer);if(h?.length&&d&&M){const e=l?await this.viewModel.imageToImageTransform(h,d,M):await this.viewModel.imageToImageTransformPanoramic(h,d,M),a=e.map(e=>[e.x-.5,-.5-e.y]),i=e.slice(0,2).map(e=>_(e,o)),s=new c({paths:l?[a]:[i],spatialReference:m.WebMercator}),n=new t({geometry:s,symbol:r});await this.viewModel.editOverlayedGraphics(n)}}async _overlayFirstAreaGeometry(e){const{mode:a,activeTriangulatedViewer:i}=this.viewModel,s=e.geometry?.clone(),r=e.symbol?.clone(),o=i?.imageSize,c=[...s.rings[0]],l="default"===a;if("none"===a||"video"===a||!o)return;const u=l?c:p(c,o),h=l?y(u,!0):u,d=l?await this.viewModel.getMeasurementProperties():await this.viewModel.getMeasurementPropertiesPanoramic(),M=l?await this.viewModel.getMeasurementProperties(this.viewModel.currentBestFeatureMeasurementImage,this.viewModel.imageMeasurementViewer):await this.viewModel.getMeasurementPropertiesPanoramic(this.viewModel.currentBestFeatureMeasurementImage,this.viewModel.activeTriangulatedViewer);if(h?.length&&d&&M){const e=l?await this.viewModel.imageToImageTransform(h,d,M):await this.viewModel.imageToImageTransformPanoramic(h,d,M),a=e.map(e=>[e.x-.5,-.5-e.y]),i=e.slice(0,l?2:e.length).map(e=>_(e,o)),s=new n({rings:l?[a]:[i],spatialReference:m.WebMercator}),c=new t({geometry:s,symbol:r});await this.viewModel.editOverlayedGraphics(c)}}async _getAreaFromTask(e){const{mode:t}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=a(async a=>{this._areaCalculation=null;const i=await this.viewModel.calculateAreaMeasurement(e,t,a);s(a),this._areaCalculation=i}),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);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=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",void 0,t);s(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 i="default"===t?await this.viewModel.calculateAccuracy(e,"area",a):await this.viewModel.calculateAccuracyPanoramic(e,"area",void 0,a);s(a),this._distanceCalculation=i}),await this._calculationTask.promise,this._distanceCalculation)}};e([r()],f.prototype,"type",void 0),e([r()],f.prototype,"measurementArray",void 0),e([r()],f.prototype,"pixelMeasurement",void 0),e([r()],f.prototype,"pixelAreaMeasurement",void 0),e([r()],f.prototype,"polygonVertices",void 0),f=e([o("esri.widgets.OrientedImageryViewer.adapters.sketch.MeasurementAdapter")],f);const A=f,_=(e,t)=>{const{heading:a,pitch:i}=h(e,t[0],t[1]);return d(a,i)};export{A 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{EsriPromise as t}from"../../../../core/Promise.js";import{throwIfAborted as a}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 i}from"../../../../core/accessorSupport/decorators/subclass.js";import{projectWithZConversion as s}from"../../../../geometry/projectionUtils.js";import{convertSphereVertexToPixelLocation as o}from"../../../../layers/orientedImagery/transformations/utils.js";import{getModeCorrectedPoints as c,computeTriangulatedVector as n,computeTriangulatedAreaMeasurement as u,computeTriangulatedDistanceMeasurement as l}from"../../imageMeasurementUtils.js";import{TriangulatedSketchHandlerMixin as m}from"../../mixins/TriangulatedSketchHandlerMixin.js";let d=[],p=class extends(m(t)){constructor(e){super(e),this.type="measurement"}async handleUpdate(e){const{measureType:t,updatingTriangularMeasurementState:a}=this.viewModel;if(this._preventLeftMouseDrag(),"distance"===t){const t=e.graphics[0].geometry;d=t.paths[0]}else if("area"===t){const t=e.graphics[0].geometry;d=t.rings[0]}"complete"===e.state&&(this.viewModel.triangulatedMeasurementGraphic=e.graphics.at(-1),a?await this._updateTriangularMeasurements(d):await this.viewModel.processMeasurementVectors(d))}async _computeMeasurementVector(e,t){const{activeViewer:a,mode:r,view:i}=this.viewModel,o=a?.imageSize;if(!e||!t||!o)return;const u=c(e,r,o),l=i?.spatialReference,m=[];for(let c=0;c<u.length;c++){const e={x:u[c][0],y:u[c][1]};let a=await this.viewModel.getMapPoint(e,{feature:t,imageSize:o,mode:r});l&&!a.spatialReference.equals(l)&&(a=await s(a,l)),m.push(a)}return n(m,t)}async _updateTriangularMeasurements(e,t){const{measureType:r,mode:i,activeTriangulatedViewer:s,triangularMeasurementActive:c,currentBestFeatureMeasurementImage:n,updatingTriangularMeasurementState:m}=this.viewModel;if(!(c&&n&&m&&s?.imageSize&&2===this.viewModel.measurementVectors?.length))return;const[d,p]=s.imageSize;this.viewModel.measurementVectors.splice(-1);const g=await this._computeMeasurementVector(e,n);if(a(t),g&&this.viewModel.measurementVectors.push(g),2===this.viewModel.measurementVectors.length){switch(r){case"distance":{this.viewModel.triangulatedDistanceMeasurement=await l(this.viewModel.measurementVectors),a(t);const r=e.map(([e,t,a])=>{const{x:r,y:i}=o({x:e,y:t,z:a},d,p);return[r,i]}),s="default"===i?await this.viewModel.calculateAccuracy(e,"distance"):await this.viewModel.calculateAccuracyPanoramic(r,"distance");if(a(t),s&&this.viewModel.triangulatedDistanceMeasurement?.distance){const e=Math.atan(s/this.viewModel.triangulatedDistanceMeasurement.distance);this.viewModel.triangulatedDistanceAccuracy={distanceAccuracy:s,angleAccuracy:e}}break}case"area":if(n?.geometry.spatialReference){const r=await u(this.viewModel.measurementVectors,n.geometry.spatialReference);if(a(t),this.viewModel.triangulatedAreaMeasurement=r,"default"===i)this.viewModel.triangulatedAreaAccuracy=await this.viewModel.calculateAccuracy(e,"area")??this.viewModel.triangulatedAreaAccuracy,a(t);else if("panoramic"===i){const r=e.map(([e,t,a])=>{const{x:r,y:i}=o({x:e,y:t,z:a},d,p);return[r,i]});this.viewModel.triangulatedAreaAccuracy=await this.viewModel.calculateAccuracyPanoramic(r,"area")??this.viewModel.triangulatedAreaAccuracy,a(t)}}}if(this.viewModel.updatingTriangularMeasurementState=!1,"panoramic"===this.viewModel.mode){this.viewModel.activeTriangulatedViewer.viewModel.restoreNavigationHandles()}}}_preventLeftMouseDrag(){const{mode:e,activeTriangulatedViewer:t}=this.viewModel;if("panoramic"!==e||!t)return;let a=null;t.imageRenderer.on("pointer-down",e=>{a=e.button}),t.imageRenderer.on("drag",e=>{0===a&&e.stopPropagation()})}};e([r()],p.prototype,"type",void 0),p=e([i("esri.widgets.OrientedImageryViewer.adapters.sketch.TriangulatedMeasurementAdapter")],p);const g=p;export{g as default};
5
+ import{__decorate as e}from"tslib";import{EsriPromise as t}from"../../../../core/Promise.js";import{throwIfAborted as a}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 i}from"../../../../core/accessorSupport/decorators/subclass.js";import{projectWithZConversion as s}from"../../../../geometry/projectionUtils.js";import{convertSphereVertexToPixelLocation as o}from"../../../../layers/orientedImagery/transformations/utils.js";import{getModeCorrectedPoints as c,computeTriangulatedVector as n,computeTriangulatedAreaMeasurement as u,computeTriangulatedDistanceMeasurement as l}from"../../imageMeasurementUtils.js";import{TriangulatedSketchHandlerMixin as m}from"../../mixins/TriangulatedSketchHandlerMixin.js";let d=[],p=class extends(m(t)){constructor(e){super(e),this.type="measurement"}async handleUpdate(e){const{measureType:t,updatingTriangularMeasurementState:a}=this.viewModel;if(this._preventLeftMouseDrag(),"distance"===t){const t=e.graphics[0].geometry;d=t.paths[0]}else if("area"===t){const t=e.graphics[0].geometry;d=t.rings[0]}"complete"===e.state&&(this.viewModel.triangulatedMeasurementGraphic=e.graphics.at(-1),a?await this._updateTriangularMeasurements(d):await this.viewModel.processMeasurementVectors(d))}async _computeMeasurementVector(e,t){const{activeViewer:a,mode:r,view:i}=this.viewModel,o=a?.imageSize;if(!e||!t||!o)return;const u=c(e,r,o),l=i?.spatialReference,m=[];for(let c=0;c<u.length;c++){const e={x:u[c][0],y:u[c][1]};let a=await this.viewModel.getMapPoint(e,{feature:t,imageSize:o,mode:r});l&&!a.spatialReference.equals(l)&&(a=await s(a,l)),m.push(a)}return n(m,t)}async _updateTriangularMeasurements(e,t){const{measureType:r,mode:i,activeTriangulatedViewer:s,triangularMeasurementActive:c,currentBestFeatureMeasurementImage:n,updatingTriangularMeasurementState:m}=this.viewModel;if(!(c&&n&&m&&s?.imageSize&&2===this.viewModel.measurementVectors?.length))return;const[d,p]=s.imageSize;this.viewModel.measurementVectors.splice(-1);const g=await this._computeMeasurementVector(e,n);if(a(t),g&&this.viewModel.measurementVectors.push(g),2===this.viewModel.measurementVectors.length){switch(r){case"distance":{this.viewModel.triangulatedDistanceMeasurement=await l(this.viewModel.measurementVectors),a(t);const r=e.map(([e,t,a])=>{const{x:r,y:i}=o({x:e,y:t,z:a},d,p);return[r,i]}),s="default"===i?await this.viewModel.calculateAccuracy(e,"distance"):await this.viewModel.calculateAccuracyPanoramic(r,"distance",!0);if(a(t),s&&this.viewModel.triangulatedDistanceMeasurement?.distance){const e=Math.atan(s/this.viewModel.triangulatedDistanceMeasurement.distance);this.viewModel.triangulatedDistanceAccuracy={distanceAccuracy:s,angleAccuracy:e}}break}case"area":if(n?.geometry.spatialReference){const r=await u(this.viewModel.measurementVectors,n.geometry.spatialReference);if(a(t),this.viewModel.triangulatedAreaMeasurement=r,"default"===i)this.viewModel.triangulatedAreaAccuracy=await this.viewModel.calculateAccuracy(e,"area")??this.viewModel.triangulatedAreaAccuracy,a(t);else if("panoramic"===i){const r=e.map(([e,t,a])=>{const{x:r,y:i}=o({x:e,y:t,z:a},d,p);return[r,i]});this.viewModel.triangulatedAreaAccuracy=await this.viewModel.calculateAccuracyPanoramic(r,"area",!0)??this.viewModel.triangulatedAreaAccuracy,a(t)}}}if(this.viewModel.updatingTriangularMeasurementState=!1,"panoramic"===this.viewModel.mode){this.viewModel.activeTriangulatedViewer.viewModel.restoreNavigationHandles()}}}_preventLeftMouseDrag(){const{mode:e,activeTriangulatedViewer:t}=this.viewModel;if("panoramic"!==e||!t)return;let a=null;t.imageRenderer.on("pointer-down",e=>{a=e.button}),t.imageRenderer.on("drag",e=>{0===a&&e.stopPropagation()})}};e([r()],p.prototype,"type",void 0),p=e([i("esri.widgets.OrientedImageryViewer.adapters.sketch.TriangulatedMeasurementAdapter")],p);const g=p;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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{rad2deg as t}from"../../core/mathUtils.js";import{throwIfAborted as n}from"../../core/promiseUtils.js";import{formatArea as e,formatLength as r}from"../../core/quantityFormatUtils.js";import{createArea as a,createLength as o}from"../../core/quantityUtils.js";import{set as i,determinant as s}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{j as m,i as p,a as h}from"../../chunks/vec32.js";import y from"../../geometry/Point.js";import g from"../../geometry/Polygon.js";import x from"../../geometry/Polyline.js";import{projectWithZConversion as w,project as M}from"../../geometry/projectionUtils.js";import R from"../../geometry/SpatialReference.js";import{e as d}from"../../chunks/areaOperator.js";import{l as z,e as P}from"../../chunks/geodeticAreaOperator.js";import{l as v,e as j}from"../../chunks/geodeticDensifyOperator.js";import{l as b,e as O}from"../../chunks/geodeticLengthOperator.js";import{e as E}from"../../chunks/lengthOperator.js";import{e as L}from"../../chunks/simplifyOperator.js";import{isSupported as I,geodesicLengths as W,geodesicAreas as k}from"../../geometry/support/geodesicUtils.js";import{imageToWorldPanoramic as q,imageToWorld as G}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as A,scaleWithFactor as D}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as U,worldToImage as B}from"../../layers/orientedImagery/transformations/worldToImage.js";const S=1e5,F="meters",T="square-meters";function H(t,n){let e=180*Math.atan2(-t.y+n.y,t.x-n.x)/Math.PI;return e<0&&(e+=180),e*Math.PI/180}function V(t,n){let e=180*Math.atan2(-t.y+n.y,t.x-n.x)/Math.PI;return e<0&&(e+=180),e*Math.PI/180}function C(t,n,e){if(!t?.length||!n?.length||!e)return;const[r,a]=t,[,o]=n,i=o-a;return[r+i*Math.cos(e),a+i*Math.sin(e)]}async function J(t,n,e){if(await v(),I(t)){const t=W([n],F)[0];return{area:k([e],T)[0],perimeter:t}}const r=R.WGS84,a=M(n,r),o=M(e,r);let i=j(o,S);if(i=i?L(i):null,!i)return null;const s=W([a],F)[0];return{area:k([i],T)[0],perimeter:s}}async function K(t,e,r,a,o=!1,i){if(e.length<2||!a||!r||!t)return null;const s=dt(r,t);if(!s)return null;const c=e.map(t=>[t.x,t.y]),u=c.at(0),l=c.at(-1);if(!u||!l)return null;const f=s.map(n=>Lt([u,l],n,t,o,!1)),m=await Promise.all(f);n(i);let p=0;for(const n of m){if(!n)return null;const t=Math.abs(n-a);p=Math.max(t,p)}return p}async function N(t,e,r,a,o,i=!1,s){if(e.length<2||!a||!r||!t)throw new Error("Missing parameters");const c=zt(r,t),u=e.map(t=>[t.x,t.y]),l=u.at(0),f=u.at(-1),m=c.map(n=>It([l,f],n,t,o,i,!1)),p=await Promise.all(m);n(s);let h=0;for(const n of p){if(!n)return 0;const t=Math.abs(n-a);h=Math.max(t,h)}return h}function Q(t,n,e=1){const r=Mt(t,!1);if(!r?.length)return;return 20*f([r[0].x,r[0].y],[r.at(-1).x,r.at(-1).y])*e/n}async function X(t){await b();const n=t.spatialReference;if(n.isGeographic){if(I(n))return W([t],F)[0];const e=M(t,R.WGS84);return W([e],F)[0]}return n.isWebMercator?O(t,{unit:F}):E(t,{unit:F})}function Y(t){if(!t?.length)throw new Error("Invalid deviations array");const[n,e,r]=[0,1,2].map(n=>t.map(t=>t[n]).filter(t=>null!==t)).map(t=>t.length?jt(t):0);return[n,e,r]}function Z(t,n){const e=L(n);if(!e)return null;const r=E(t,{unit:F});return{area:d(e,{unit:T}),perimeter:r}}function $(t,n){return[(t[1][0]-t[0][0])/n,(t[1][1]-t[0][1])/n,(t[1][2]-t[0][2])/n]}async function _(t,n){await Promise.all([z(),v(),b()]);let e=j(n,S);if(e=e?L(e):null,!e)return null;const r=O(t,{unit:F});return{area:P(e,{unit:T}),perimeter:r}}async function tt(t,e,r){if(!e||!t)throw new Error("Missing required parameters");const a=await G(t,e);n(r);const o=a.clone();o.z?o.z+=20:o.z=20;const{averageElevation:i,cameraPitch:s,cameraRoll:c,farDistance:u,...l}=e;return B(o,l)}async function nt(t,e,r,a){const{attributes:o}=r,{location:i}=o,{updateElevationProps:s,...c}=e;if(!t||!e)throw new Error("Missing parameters");let u=i.clone();u.spatialReference.isGeographic&&(u=await w(u,R.WebMercator));const l=await q(t,{...c,cameraLocation:u},s);n(a);const f=l.clone();return f.z?f.z+=20:f.z=20,U(f,c)}function et(t,n,e,r,a=0,o=1,i){const{averageElevation:s,cameraPitch:c,cameraRoll:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Ot(r.cameraLocation.spatialReference)}}const p=new y({x:n.x,y:n.y,z:n.z?n.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=B(p,m),g=f([e[0].x,e[0].y],[h.x,h.y]),x=e.at(0),w=e.at(-1);if(!x||!w)return null;const M=f([x.x,x.y],[w.x,w.y])*t/g;return et(M,n,e,r,a+1,Math.abs(t-M))}function rt(t,n,e,r,a=0,o=1,i){const{averageElevation:s,horizontalFieldOfView:c,verticalFieldOfView:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Ot(r.cameraLocation.spatialReference)}}const p=new y({x:n.x,y:n.y,z:n.z?n.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=U(p,m),g=f([e[0].x,e[0].y],[h.x,h.y]),x=e.at(0),w=e.at(-1);if(!x||!w)return null;const M=f([x.x,x.y],[w.x,w.y])*t/g;return rt(M,n,e,r,a+1,Math.abs(t-M))}function at(t,n,e){return new x({paths:[[[t.x,t.y,t.z??0],[n.x,n.y,n.z??0]]],spatialReference:e})}function ot(t){return 1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/6378137)))}function it(t,n){return Math.sqrt((Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/n)**2+(t[0][2]-t[1][2])**2)}function st(t,n){return Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/n}function ct(n){return t(Math.atan((n[1][2]-n[0][2])/Math.sqrt((n[1][0]-n[0][0])**2+(n[1][1]-n[0][1])**2)))}function ut(n){let e=90-t(Math.atan2(n[1][1]-n[0][1],n[1][0]-n[0][0]));return e<0&&(e+=360),e}function lt(t,n){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:n})}async function ft(t){if(2===t?.length){const n=[];let e=1;const[r,a]=t,o=r.camera.spatialReference,{measurePoints:i}=r;for(let t=0;t<i.length;t++){const i=at(r.camera,r.measurePoints[t],o),s=at(a.camera,a.measurePoints[t],o),c=await At(i,s);if(!c)return null;const u=lt(c,o);u.spatialReference.isWebMercator&&(e=ot(u.y)),n.push([u.x,u.y,u.z??0])}if(n?.length>1){return{distance:it(n,e),horizontalDistance:st(n,e),verticalDistance:Math.abs(n[0][2]-n[1][2]),slope:ct(n),aspect:ut(n)}}}return null}async function mt(t){const n=t[0].camera.spatialReference;if(2!==t?.length)return null;const[e,r]=t,{camera:a,measurePoints:o}=e,{camera:i,measurePoints:s}=r,c=at(a,o[0],n),u=at(i,s[0],n),l=await At(c,u);return l?lt(l,n)??null:null}async function pt(t,n){if(!t?.length)return null;const e=[],r=t[0],a=t[1],o=r.camera.spatialReference,{measurePoints:i}=r;for(let l=0;l<i.length;l++){const t=at(r.camera,r.measurePoints[l],o),n=at(a.camera,a.measurePoints[l],o),i=await At(t,n);if(!i)return null;const s=lt(i,o);e.push([s.x,s.y,s.z??0])}if(e?.length<2)return null;const s=new x({paths:[e],spatialReference:n}),c=new g({rings:[e],spatialReference:n});if(n.isGeographic){const t=await J(n,s,c);return t?.area??null}if(n.isWebMercator){const t=await _(s,c);return t?.area??null}const u=Z(s,c);return u?.area??null}function ht(t,n){if(!t)return null;return{camera:n.geometry.clone(),measurePoints:Array.isArray(t)?t:[t]}}async function yt(t,n){const{updateElevationProps:e,...r}=n;return await G(t,r,e)}async function gt(t,n){const{updateElevationProps:e,...r}=n;return q(t,r,e)}function xt(t){navigator.clipboard.writeText(t).catch(t=>{throw t})}function wt(t){const n=t.map(t=>[t.x,t.y]),e=t[0].spatialReference;return new x({paths:[n],spatialReference:e})}function Mt(t,n){return t.map(t=>({x:n?.5+t[0]:t[0],y:n?.5-t[1]:t[1]}))}function Rt(t,n,e,a,i){const s="measurement"===t?n:e;if(i&&s)return r(a,o(s,F),i,3)||null}function dt(t,n){const{cameraPitch:e,cameraRoll:r,cameraLocation:a}=t,{x:o,y:i,z:s,spatialReference:c}=a;if(n.every(t=>0===t)||!n||!n.length)return null;const[u,l,,f,m]=n,p=[-f,0,f],h=[-m,0,m],g=[-u,0,u],x=[-l,0,l],w=[];for(const M of p)for(const n of h)for(const a of g)for(const u of g)for(const l of x){const f={...t};f.cameraPitch=e+M,f.cameraRoll=r+n,f.cameraLocation=new y({x:o+a,y:i+u,z:s?s+l:0,spatialReference:{wkid:c.wkid}}),w.push(f)}return w}function zt(t,n){const{cameraHeading:e,cameraLocation:r}=t,{x:a,y:o,z:i,spatialReference:s}=r;if(n.every(t=>0===t)||!n||!n.length)throw new Error("Invalid parameters");const[c,u,l]=n,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 n of m)for(const r of m)for(const c of p){const u={...t};u.cameraHeading=e+g,u.cameraLocation=new y({x:a+n,y:o+r,z:i?i+c:0,spatialReference:{wkid:s.wkid}}),h.push(u)}return h}function Pt(t,n,e,a,i){const s="measurement"===t?n:jt(e);if(i&&s)return r(a,o(s,F),i,3)||null}function vt(t,n,r,o,i){const s="measurement"===t?n:r;if(i&&s)return e(o,a(s,T),i,3)||null}function jt(t){return Math.sqrt(t.reduce((t,n)=>t+n**2,0))}function bt(t,n,e){if("default"===n)return t;const r={x:t[0],y:t[1],z:t[2]},a=A(r,e[0],e[1]);return[a.x,a.y]}function Ot(t){return t.metersPerUnit}function Et(t,n,e){let r=[];return r="panoramic"===n?t.map(([t,n,r])=>{const{x:a,y:o}=A({x:t,y:n,z:r},e[0],e[1]);return[a-.5,-.5-o]}):t.map(([t,n])=>[t-.5,-.5-n]),r}async function Lt(t,e,r,a=!1,o=!1,i){if(!t||!e||t.length<2)return null;const s=Mt(t,a);if(!s||s.length<2)return null;const[c,u]=[s[0],s.at(-1)];if(!u)return null;const l=[c],m=await G(c,e);n(i);const p=m.clone();p.z?p.z+=20:p.z=20;const{averageElevation:h,cameraPitch:y,cameraRoll:g,farDistance:x,...w}=e,M=B(p,w),R=f([c.x,c.y],[M.x,M.y]),d=H(c,M);if(!d)return;const z=C([c.x,c.y],[u.x,u.y],d);if(!z?.length)return;l.push({x:z[0],y:z[1]});const P=20*f([l[0].x,l[0].y],[l[1].x,l[1].y])*Ot(e.cameraLocation.spatialReference)/R;if(!o)return P;const v=et(P,m,l,e,0,1);return v?.value}async function It(t,e,r,a,o=!1,i=!1,s){const{attributes:c}=a,{location:u}=c,{updateElevationProps:l,...m}=e;if(!t||!e||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,R.WebMercator));const M=await q(h,{...m,cameraLocation:x},l);n(s);const d=M.clone();d.z?d.z+=20:d.z=20;const z=U(d,m),P=f([h.x,h.y],[z.x,z.y]),v=H(h,z);if(!v)return;const j=C([h.x,h.y],[y.x,y.y],v);if(!j?.length)return;g.push({x:j[0],y:j[1]});const b=20*f([g[0].x,g[0].y],[g[1].x,g[1].y])*Ot(e.cameraLocation.spatialReference)/P;if(!i)return b;const O=rt(b,M,g,e,0,1);return O?.value}async function Wt(t,n,e=!1){if(t.length<3)return null;const r=Mt(t,e),a=await yt(r,n),o=a.map(({x:t,y:n})=>[t,n]);t.push(t[0]),o.push(o[0]);const i=a[0].spatialReference,s=new x({paths:[o],spatialReference:i}),c=new g({rings:[o],spatialReference:i});return i.isGeographic?J(i,s,c):i.isWebMercator?_(s,c):Z(s,c)}async function kt(t,e,r=!1,a){if(t.length<3)return null;const o=Mt(t,r),i=await gt(o,e);n(a);const s=i.map(({x:t,y:n})=>[t,n]);t.push(t[0]),s.push(s[0]);const c=i[0].spatialReference,u=new x({paths:[s],spatialReference:c}),l=new g({rings:[s],spatialReference:c});return c.isGeographic?J(c,u,l):c.isWebMercator?_(u,l):Z(u,l)}async function qt(t,n,e=!1){const r=Mt(t,e);return X(wt(await yt(r,n)))}async function Gt(t,e,r=!1,a){const o=Mt(t,r),i=await gt(o,e);n(a);return X(wt(i))}async function At(t,n){const e=c(),r=t.paths[0][0],a=n.paths[0][0];let o,u;t.spatialReference.isWGS84||t.spatialReference.isWebMercator?(await b(),o=O(t),u=O(n)):(o=E(t),u=E(n));const l=$(t.paths[0],o),f=$(n.paths[0],u),m=Dt(l,f),[p,h,y]=l,[g,x,w]=f.map(t=>-t),[M,R,d]=m,[z,P,v]=[a[0]-r[0],a[1]-r[1],a[2]-r[2]];i(e,p,g,M,h,x,R,y,w,d);const j=s(e);if(0===j)return null;i(e,z,g,M,P,x,R,v,w,d);const L=s(e);i(e,p,z,M,h,P,R,y,v,d);const I=s(e);i(e,p,g,z,h,x,P,y,w,v);const W=L/j,k=I/j,q=s(e)/j;return{distance:Math.abs(q/Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2])),pointOnA:Ut(r,W,l),pointOnB:Ut(a,k,f)}}function Dt(t,n){const e=u(),r=m(u(),t[0],t[1],t[2]),a=m(u(),n[0],n[1],n[2]),o=p(e,r,a);return[o[0],o[1],o[2]]}function Ut(t,n,e){return[t[0]+n*e[0],t[1]+n*e[1],t[2]+n*e[2]]}function Bt(t,n){const e=l(t[0],t[1],t[2]),r=l(n[0],n[1],n[2]);return h(u(),e,r)}function St(t,n,e){const r=D(t,n,e);return[r[0],r[1],r[2]]}export{H as calculateAngle,V as calculateAnglePano,C as calculateCorrectedPixel,K as calculateHeightAccuracy,N as calculateHeightAccuracyPanoramic,Q as calculateHeightFromTemporaryDistance,Y as calculateLocationAccuracyFromDeviations,nt as calculateReferenceImagePointPanoramic,tt as calculateTempImagePoint,et as computeHeightIteratively,rt as computeHeightIterativelyPanoramic,pt as computeTriangulatedAreaMeasurement,ft as computeTriangulatedDistanceMeasurement,mt as computeTriangulatedPoint,ht as computeTriangulatedVector,xt as copyToClipboard,Mt as formatPixels,dt as generateCombinations,zt as generateCombinationsPanoramic,vt as getConvertedArea,Pt as getConvertedDistance,Rt as getConvertedHeight,bt as getModeCorrectedPoint,Et as getModeCorrectedPoints,jt as getRootOfSumOfSquaredErrors,Ot as getUnitRateFromSpatialReference,Lt as heightMeasurement2D,It as heightMeasurementPanoramic,Wt as pixelAreaMeasurement2D,kt as pixelAreaMeasurementPanoramic,qt as pixelDistanceMeasurement2D,Gt as pixelDistanceMeasurementPanoramic,St as scale,At as solveSkewLinesIntersection,Bt as subtract};
5
+ import{rad2deg as t}from"../../core/mathUtils.js";import{throwIfAborted as n}from"../../core/promiseUtils.js";import{formatArea as e,formatLength as r}from"../../core/quantityFormatUtils.js";import{createArea as a,createLength as o}from"../../core/quantityUtils.js";import{set as i,determinant as s}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{j as m,i as p,a as h}from"../../chunks/vec32.js";import y from"../../geometry/Point.js";import g from"../../geometry/Polygon.js";import x from"../../geometry/Polyline.js";import{projectWithZConversion as w,project as M}from"../../geometry/projectionUtils.js";import R from"../../geometry/SpatialReference.js";import{e as z}from"../../chunks/areaOperator.js";import{l as d,e as P}from"../../chunks/geodeticAreaOperator.js";import{l as v,e as j}from"../../chunks/geodeticDensifyOperator.js";import{l as b,e as O}from"../../chunks/geodeticLengthOperator.js";import{e as E}from"../../chunks/lengthOperator.js";import{e as L}from"../../chunks/simplifyOperator.js";import{isSupported as I,geodesicLengths as W,geodesicAreas as k}from"../../geometry/support/geodesicUtils.js";import{imageToWorldPanoramic as q,imageToWorld as G}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as A,scaleWithFactor as D}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as U,worldToImage as B}from"../../layers/orientedImagery/transformations/worldToImage.js";const S=1e5,F="meters",T="square-meters";function H(t,n){let e=180*Math.atan2(-t.y+n.y,t.x-n.x)/Math.PI;return e<0&&(e+=180),e*Math.PI/180}function V(t,n){let e=180*Math.atan2(-t.y+n.y,t.x-n.x)/Math.PI;return e<0&&(e+=180),e*Math.PI/180}function C(t,n,e){if(!t?.length||!n?.length||!e)return;const[r,a]=t,[,o]=n,i=o-a;return[r+i*Math.cos(e),a+i*Math.sin(e)]}async function J(t,n,e){if(await v(),I(t)){const t=W([n],F)[0];return{area:k([e],T)[0],perimeter:t}}const r=R.WGS84,a=M(n,r),o=M(e,r);let i=j(o,S);if(i=i?L(i):null,!i)return null;const s=W([a],F)[0];return{area:k([i],T)[0],perimeter:s}}async function K(t,e,r,a,o=!1,i){if(e.length<2||!a||!r||!t)return null;const s=zt(r,t);if(!s)return null;const c=e.map(t=>[t.x,t.y]),u=c.at(0),l=c.at(-1);if(!u||!l)return null;const f=s.map(n=>It([u,l],n,t,o,!1)),m=await Promise.all(f);n(i);let p=0;for(const n of m){if(!n)return null;const t=Math.abs(n-a);p=Math.max(t,p)}return p}async function N(t,e,r,a,o,i=!1,s){if(e.length<2||!a||!r||!t)throw new Error("Missing parameters");const c=dt(r,t),u=e.map(t=>[t.x,t.y]),l=u.at(0),f=u.at(-1),m=c.map(n=>Wt([l,f],n,t,o,i,!1)),p=await Promise.all(m);n(s);let h=0;for(const n of p){if(!n)return 0;const t=Math.abs(n-a);h=Math.max(t,h)}return h}function Q(t,n,e=1){const r=Mt(t,!1);if(!r?.length)return;return 20*f([r[0].x,r[0].y],[r.at(-1).x,r.at(-1).y])*e/n}async function X(t){await b();const n=t.spatialReference;if(n.isGeographic){if(I(n))return W([t],F)[0];const e=M(t,R.WGS84);return W([e],F)[0]}return n.isWebMercator?O(t,{unit:F}):E(t,{unit:F})}function Y(t){if(!t?.length)throw new Error("Invalid deviations array");const[n,e,r]=[0,1,2].map(n=>t.map(t=>t[n]).filter(t=>null!==t)).map(t=>t.length?jt(t):0);return[n,e,r]}function Z(t,n){const e=L(n);if(!e)return null;const r=E(t,{unit:F});return{area:z(e,{unit:T}),perimeter:r}}function $(t,n){return[(t[1][0]-t[0][0])/n,(t[1][1]-t[0][1])/n,(t[1][2]-t[0][2])/n]}async function _(t,n){await Promise.all([d(),v(),b()]);let e=j(n,S);if(e=e?L(e):null,!e)return null;const r=O(t,{unit:F});return{area:P(e,{unit:T}),perimeter:r}}async function tt(t,e,r){if(!e||!t)throw new Error("Missing required parameters");const a=await G(t,e);n(r);const o=a.clone();o.z?o.z+=20:o.z=20;const{averageElevation:i,cameraPitch:s,cameraRoll:c,farDistance:u,...l}=e;return B(o,l)}async function nt(t,e,r,a){const{attributes:o}=r,{location:i}=o,{updateElevationProps:s,...c}=e;if(!t||!e)throw new Error("Missing parameters");let u=i.clone();u.spatialReference.isGeographic&&(u=await w(u,R.WebMercator));const l=await q(t,{...c,cameraLocation:u},s);n(a);const f=l.clone();return f.z?f.z+=20:f.z=20,U(f,c)}function et(t,n,e,r,a=0,o=1,i){const{averageElevation:s,cameraPitch:c,cameraRoll:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Ot(r.cameraLocation.spatialReference)}}const p=new y({x:n.x,y:n.y,z:n.z?n.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=B(p,m),g=f([e[0].x,e[0].y],[h.x,h.y]),x=e.at(0),w=e.at(-1);if(!x||!w)return null;const M=f([x.x,x.y],[w.x,w.y])*t/g;return et(M,n,e,r,a+1,Math.abs(t-M))}function rt(t,n,e,r,a=0,o=1,i){const{averageElevation:s,horizontalFieldOfView:c,verticalFieldOfView:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Ot(r.cameraLocation.spatialReference)}}const p=new y({x:n.x,y:n.y,z:n.z?n.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=U(p,m),g=f([e[0].x,e[0].y],[h.x,h.y]),x=e.at(0),w=e.at(-1);if(!x||!w)return null;const M=f([x.x,x.y],[w.x,w.y])*t/g;return rt(M,n,e,r,a+1,Math.abs(t-M))}function at(t,n,e){return new x({paths:[[[t.x,t.y,t.z??0],[n.x,n.y,n.z??0]]],spatialReference:e})}function ot(t){return 1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/6378137)))}function it(t,n){return Math.sqrt((Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/n)**2+(t[0][2]-t[1][2])**2)}function st(t,n){return Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/n}function ct(n){return t(Math.atan((n[1][2]-n[0][2])/Math.sqrt((n[1][0]-n[0][0])**2+(n[1][1]-n[0][1])**2)))}function ut(n){let e=90-t(Math.atan2(n[1][1]-n[0][1],n[1][0]-n[0][0]));return e<0&&(e+=360),e}function lt(t,n){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:n})}async function ft(t){if(2===t?.length){const n=[];let e=1;const[r,a]=t,o=r.camera.spatialReference,{measurePoints:i}=r;for(let t=0;t<i.length;t++){const i=at(r.camera,r.measurePoints[t],o),s=at(a.camera,a.measurePoints[t],o),c=await Dt(i,s);if(!c)return null;const u=lt(c,o);u.spatialReference.isWebMercator&&(e=ot(u.y)),n.push([u.x,u.y,u.z??0])}if(n?.length>1){return{distance:it(n,e),horizontalDistance:st(n,e),verticalDistance:Math.abs(n[0][2]-n[1][2]),slope:ct(n),aspect:ut(n)}}}return null}async function mt(t){const n=t[0].camera.spatialReference;if(2!==t?.length)return null;const[e,r]=t,{camera:a,measurePoints:o}=e,{camera:i,measurePoints:s}=r,c=at(a,o[0],n),u=at(i,s[0],n),l=await Dt(c,u);return l?lt(l,n)??null:null}async function pt(t,n){if(!t?.length)return null;const e=[],r=t[0],a=t[1],o=r.camera.spatialReference,{measurePoints:i}=r;for(let l=0;l<i.length;l++){const t=at(r.camera,r.measurePoints[l],o),n=at(a.camera,a.measurePoints[l],o),i=await Dt(t,n);if(!i)return null;const s=lt(i,o);e.push([s.x,s.y,s.z??0])}if(e?.length<2)return null;const s=new x({paths:[e],spatialReference:n}),c=new g({rings:[e],spatialReference:n});if(n.isGeographic){const t=await J(n,s,c);return t?.area??null}if(n.isWebMercator){const t=await _(s,c);return t?.area??null}const u=Z(s,c);return u?.area??null}function ht(t,n){if(!t)return null;return{camera:n.geometry.clone(),measurePoints:Array.isArray(t)?t:[t]}}async function yt(t,n){const{updateElevationProps:e,...r}=n;return await G(t,r,e)}async function gt(t,n){const{updateElevationProps:e,...r}=n;return q(t,r,e)}function xt(t){navigator.clipboard.writeText(t).catch(t=>{throw t})}function wt(t){const n=t.map(t=>[t.x,t.y]),e=t[0].spatialReference;return new x({paths:[n],spatialReference:e})}function Mt(t,n){return t.map(t=>({x:n?.5+t[0]:t[0],y:n?.5-t[1]:t[1]}))}function Rt(t,n,e,a,i){const s="measurement"===t?n:e;if(i&&s)return r(a,o(s,F),i,3)||null}function zt(t,n){const{cameraPitch:e,cameraRoll:r,cameraLocation:a}=t,{x:o,y:i,z:s,spatialReference:c}=a;if(n.every(t=>0===t)||!n||!n.length)return null;const[u,l,,f,m]=n,p=[-f,0,f],h=[-m,0,m],g=[-u,0,u],x=[-l,0,l],w=[];for(const M of p)for(const n of h)for(const a of g)for(const u of g)for(const l of x){const f={...t};f.cameraPitch=e+M,f.cameraRoll=r+n,f.cameraLocation=new y({x:o+a,y:i+u,z:s?s+l:0,spatialReference:{wkid:c.wkid}}),w.push(f)}return w}function dt(t,n){const{cameraHeading:e,cameraLocation:r}=t,{x:a,y:o,z:i,spatialReference:s}=r;if(n.every(t=>0===t)||!n||!n.length)throw new Error("Invalid parameters");const[c,u,l]=n,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 n of m)for(const r of m)for(const c of p){const u={...t};u.cameraHeading=e+g,u.cameraLocation=new y({x:a+n,y:o+r,z:i?i+c:0,spatialReference:{wkid:s.wkid}}),h.push(u)}return h}function Pt(t,n,e,a,i){const s="measurement"===t?n:jt(e);if(i&&s)return r(a,o(s,F),i,3)||null}function vt(t,n,r,o,i){const s="measurement"===t?n:r;if(i&&s)return e(o,a(s,T),i,3)||null}function jt(t){return Math.sqrt(t.reduce((t,n)=>t+n**2,0))}function bt(t,n,e){if("default"===n)return t;const r={x:t[0],y:t[1],z:t[2]},a=A(r,e[0],e[1]);return[a.x,a.y]}function Ot(t){return t.metersPerUnit}function Et(t,n,e){let r=[];return r="panoramic"===n?t.map(([t,n,r])=>{const{x:a,y:o}=A({x:t,y:n,z:r},e[0],e[1]);return[a-.5,-.5-o]}):t.map(([t,n])=>[t-.5,-.5-n]),r}function Lt(t,n){return t.map(t=>A({x:t[0],y:t[1],z:t[2]},n[0],n[1]))}async function It(t,e,r,a=!1,o=!1,i){if(!t||!e||t.length<2)return null;const s=Mt(t,a);if(!s||s.length<2)return null;const[c,u]=[s[0],s.at(-1)];if(!u)return null;const l=[c],m=await G(c,e);n(i);const p=m.clone();p.z?p.z+=20:p.z=20;const{averageElevation:h,cameraPitch:y,cameraRoll:g,farDistance:x,...w}=e,M=B(p,w),R=f([c.x,c.y],[M.x,M.y]),z=H(c,M);if(!z)return;const d=C([c.x,c.y],[u.x,u.y],z);if(!d?.length)return;l.push({x:d[0],y:d[1]});const P=20*f([l[0].x,l[0].y],[l[1].x,l[1].y])*Ot(e.cameraLocation.spatialReference)/R;if(!o)return P;const v=et(P,m,l,e,0,1);return v?.value}async function Wt(t,e,r,a,o=!1,i=!1,s){const{attributes:c}=a,{location:u}=c,{updateElevationProps:l,...m}=e;if(!t||!e||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,R.WebMercator));const M=await q(h,{...m,cameraLocation:x},l);n(s);const z=M.clone();z.z?z.z+=20:z.z=20;const d=U(z,m),P=f([h.x,h.y],[d.x,d.y]),v=H(h,d);if(!v)return;const j=C([h.x,h.y],[y.x,y.y],v);if(!j?.length)return;g.push({x:j[0],y:j[1]});const b=20*f([g[0].x,g[0].y],[g[1].x,g[1].y])*Ot(e.cameraLocation.spatialReference)/P;if(!i)return b;const O=rt(b,M,g,e,0,1);return O?.value}async function kt(t,n,e=!1){if(t.length<3)return null;const r=Mt(t,e),a=await yt(r,n),o=a.map(({x:t,y:n})=>[t,n]);t.push(t[0]),o.push(o[0]);const i=a[0].spatialReference,s=new x({paths:[o],spatialReference:i}),c=new g({rings:[o],spatialReference:i});return i.isGeographic?J(i,s,c):i.isWebMercator?_(s,c):Z(s,c)}async function qt(t,e,r=!1,a){if(t.length<3)return null;const o=Mt(t,r),i=await gt(o,e);n(a);const s=i.map(({x:t,y:n})=>[t,n]);t.push(t[0]),s.push(s[0]);const c=i[0].spatialReference,u=new x({paths:[s],spatialReference:c}),l=new g({rings:[s],spatialReference:c});return c.isGeographic?J(c,u,l):c.isWebMercator?_(u,l):Z(u,l)}async function Gt(t,n,e=!1){const r=Mt(t,e);return X(wt(await yt(r,n)))}async function At(t,e,r=!1,a){const o=Mt(t,r),i=await gt(o,e);n(a);return X(wt(i))}async function Dt(t,n){const e=c(),r=t.paths[0][0],a=n.paths[0][0];let o,u;t.spatialReference.isWGS84||t.spatialReference.isWebMercator?(await b(),o=O(t),u=O(n)):(o=E(t),u=E(n));const l=$(t.paths[0],o),f=$(n.paths[0],u),m=Ut(l,f),[p,h,y]=l,[g,x,w]=f.map(t=>-t),[M,R,z]=m,[d,P,v]=[a[0]-r[0],a[1]-r[1],a[2]-r[2]];i(e,p,g,M,h,x,R,y,w,z);const j=s(e);if(0===j)return null;i(e,d,g,M,P,x,R,v,w,z);const L=s(e);i(e,p,d,M,h,P,R,y,v,z);const I=s(e);i(e,p,g,d,h,x,P,y,w,v);const W=L/j,k=I/j,q=s(e)/j;return{distance:Math.abs(q/Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2])),pointOnA:Bt(r,W,l),pointOnB:Bt(a,k,f)}}function Ut(t,n){const e=u(),r=m(u(),t[0],t[1],t[2]),a=m(u(),n[0],n[1],n[2]),o=p(e,r,a);return[o[0],o[1],o[2]]}function Bt(t,n,e){return[t[0]+n*e[0],t[1]+n*e[1],t[2]+n*e[2]]}function St(t,n){const e=l(t[0],t[1],t[2]),r=l(n[0],n[1],n[2]);return h(u(),e,r)}function Ft(t,n,e){const r=D(t,n,e);return[r[0],r[1],r[2]]}export{H as calculateAngle,V as calculateAnglePano,C as calculateCorrectedPixel,K as calculateHeightAccuracy,N as calculateHeightAccuracyPanoramic,Q as calculateHeightFromTemporaryDistance,Y as calculateLocationAccuracyFromDeviations,nt as calculateReferenceImagePointPanoramic,tt as calculateTempImagePoint,et as computeHeightIteratively,rt as computeHeightIterativelyPanoramic,pt as computeTriangulatedAreaMeasurement,ft as computeTriangulatedDistanceMeasurement,mt as computeTriangulatedPoint,ht as computeTriangulatedVector,xt as copyToClipboard,Mt as formatPixels,zt as generateCombinations,dt as generateCombinationsPanoramic,vt as getConvertedArea,Pt as getConvertedDistance,Rt as getConvertedHeight,bt as getModeCorrectedPoint,Et as getModeCorrectedPoints,Lt as getPixelLocationFromSphereVertices,jt as getRootOfSumOfSquaredErrors,Ot as getUnitRateFromSpatialReference,It as heightMeasurement2D,Wt as heightMeasurementPanoramic,kt as pixelAreaMeasurement2D,qt as pixelAreaMeasurementPanoramic,Gt as pixelDistanceMeasurement2D,At as pixelDistanceMeasurementPanoramic,Ft as scale,Dt as solveSkewLinesIntersection,St 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{throwIfAborted as e}from"../../../core/promiseUtils.js";import{distance as t}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{projectWithZConversion as a}from"../../../geometry/projectionUtils.js";import{imageToWorld as i,imageToWorldPanoramic as r}from"../../../layers/orientedImagery/transformations/imageToWorld.js";import{getImageToWorldProperties as n,convertSphereVertexToPixelLocation as s}from"../../../layers/orientedImagery/transformations/utils.js";import{formatPixels as l,heightMeasurementPanoramic as c,heightMeasurement2D as o,calculateHeightAccuracyPanoramic as u,calculateHeightAccuracy as m,pixelAreaMeasurement2D as w,pixelAreaMeasurementPanoramic as d,pixelDistanceMeasurement2D as h,pixelDistanceMeasurementPanoramic as M,generateCombinations as g,getRootOfSumOfSquaredErrors as v,generateCombinationsPanoramic as p,calculateLocationAccuracyFromDeviations as f,calculateReferenceImagePointPanoramic as y,calculateAnglePano as _,calculateTempImagePoint as P,calculateAngle as A,computeTriangulatedAreaMeasurement as z,computeTriangulatedDistanceMeasurement as x}from"../imageMeasurementUtils.js";class b{constructor(e){this._viewModel=e}async computeHeight(e,t,a=!0){const{currentBestFeature:i,activeViewer:r,layer:s,footprintExtent:w}=this._viewModel,d=r?.imageSize,h=i?.attributes,M=s?.orientationAccuracy;if(!h||!d||!e||e.length<2||!M)return;const g="panoramic"===t?await this._viewModel.getMeasurementPropertiesPanoramic():n(h,d[0],d[1]),v=e.at(0),p=e.at(-1);if(!(g&&v&&p&&M&&w))return;const f=[p,v],y=l(f,!1),_="panoramic"===t?await c(f,g,M,i,!0,!1):await o(f,g,M,!0,a);if(!_)return;const P="panoramic"===t?await u(M,y,g,_,i,!0):await m(M,y,g,_,!0);return P?{value:_,accuracy:P}:{value:_}}async calculateAreaMeasurement(t,a,i){if(t.length<3||!this._viewModel.currentBestFeature||!this._viewModel.activeViewer?.imageSize||"none"===this._viewModel.mode)return null;const r="default"===a?await this._viewModel.getMeasurementProperties():await this._viewModel.getMeasurementPropertiesPanoramic();return e(i),r?"default"===a?await w(t,r,!0):await d(t,r,!0,i):null}async calculateDistanceMeasurement(t,a,i){const{currentBestFeature:r,activeViewer:n}=this._viewModel;if(t.length<2||!r||!n?.imageSize||"none"===a)return null;const s="default"===a?await this._viewModel.getMeasurementProperties():await this._viewModel.getMeasurementPropertiesPanoramic();return e(i),s?"default"===a?await h([t.at(0),t.at(-1)],s,!0):await M([t.at(0),t.at(-1)],s,!0):null}async calculateAccuracy(t,a,i){const{layer:r,currentBestFeature:n,activeViewer:s,currentBestFeatureMeasurementImage:l,triangularMeasurementActive:c,imageMeasurementViewer:o}=this._viewModel,u=r?.orientationAccuracy,m=u?.every(e=>0===e)||!u?.length;if("area"===a&&t.length<3||"distance"===a&&t.length<2||!n||!s?.imageSize||m)return null;let d=null;if(c&&l&&o?d=await this._viewModel.getMeasurementProperties(l,o):(d=await this._viewModel.getMeasurementProperties(),e(i)),!d)return null;const M="area"===a?await w(t,d,!0):await h([t.at(0),t.at(-1)],d,!0);e(i);const{updateElevationProps:p,...f}=d,y=g(f,u);if(!y?.length)return null;const _=y.map(e=>({...e,updateElevationProps:p})).map(async r=>{const n="area"===a?await w(t,r,!0):await h([t.at(0),t.at(-1)],r,!0);if(e(i),n&&M){if("area"===a){const e="number"!=typeof n?n.area:null;return e?Math.abs(e-M.area):null}return Math.abs(n-M)}return null}),P=await Promise.all(_);e(i);const A=P.filter(e=>null!==e);return 0===A.length?null:v(A)}async calculateLocationAccuracy(t,n,s="default",l){const{layer:c,currentBestFeature:o}=this._viewModel,u=c?.orientationAccuracy,m=this._viewModel.view?.spatialReference,w=u?.every(e=>0===e)||!u?.length;if(!o||w)return null;const d="default"===s?await this._viewModel.getMeasurementProperties():await this._viewModel.getMeasurementPropertiesPanoramic();if(e(l),!d)return null;const{updateElevationProps:h,...M}=d,v="default"===s?g(M,u):p(M,u);if(!v?.length)return null;const y=v.map(e=>({...e,updateElevationProps:h})).map(async c=>{const{updateElevationProps:o,...u}=c;let w="default"===s?await i(t,u,o):await r(t,u,o);return e(l),m&&!w.spatialReference.equals(m)&&(w=await a(w,m),e(l)),w&&n?[Math.abs(w.x-n.x),Math.abs(w.y-n.y),w.z&&n.z?Math.abs(w.z-n.z):0]:null}),_=await Promise.all(y);if(e(l),!_?.length)return null;const P=_.map(e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0]),[A,z,x]=f(P);return{x:A,y:z,z:x}}async calculateAccuracyPanoramic(t,a,i){const{layer:r,currentBestFeature:n,activeViewer:s,mode:l}=this._viewModel,c=r?.orientationAccuracy,o=c?.every(e=>0===e)||!c?.length;if("area"===a&&t.length<3||"distance"===a&&t.length<2||!n||!s?.imageSize||o||"panoramic"!==l)return null;const u=await this._viewModel.getMeasurementPropertiesPanoramic();if(e(i),!u)return null;const m="area"===a?await d(t,u,!0):await M([t.at(0),t.at(-1)],u,!0);e(i);const{updateElevationProps:w,...h}=u,g=p(h,c);if(!g?.length)return null;const f=g.map(e=>({...e,updateElevationProps:w})).map(async r=>{const n="area"===a?await d(t,r,!0):await M([t.at(0),t.at(-1)],r,!0);if(e(i),n&&m){if("area"===a){const e="number"!=typeof n?n.area:null;return e?Math.abs(e-m.area):null}return Math.abs(n-m)}return null}),y=await Promise.all(f);e(i);const _=y.filter(e=>null!==e);return 0===_.length?null:v(_)}async calculateHeightMeasurementInfo(e,a,i){const{currentBestFeature:r,activeViewer:s}=this._viewModel,c=s?.imageSize;if(!r||!s||!c?.length||"none"===a)return;const{attributes:o}=r,[u]=l([e],"panoramic"!==a),m="panoramic"===a?await this._viewModel.getMeasurementPropertiesPanoramic():n(o,c[0],c[1]);if("panoramic"===a){if(!m)return;const e=await y(u,m,r,i);if(!e)return;e?.heading>180&&(e.heading-=360);const a=_(u,e),n=t([u.x,u.y],[e.x,e.y]);if(!a||!n)return;return{measurementAngle:a,tempDistance:n}}const w=await P(u,m,i);if(!w)return;const d=A(u,w),h=t([u.x,u.y],[w.x,w.y]);return d&&h?{measurementAngle:d,tempDistance:h}:void 0}async calculateTriangulatedMeasurements(e){if(!this._viewModel.activeTriangulatedViewer?.imageSize)return;const[t,a]=this._viewModel.activeTriangulatedViewer.imageSize;switch(this._viewModel.measureType){case"distance":{this._viewModel.triangulatedDistanceMeasurement=await x(this._viewModel.measurementVectors);const i=e.map(([e,i,r])=>s({x:e,y:i,z:r},t,a)).map(({x:e,y:t})=>[e,t]),r="default"===this._viewModel.mode?await this.calculateAccuracy(e,"distance"):await this.calculateAccuracyPanoramic(i,"distance");if(r&&this._viewModel.triangulatedDistanceMeasurement?.distance){const e=Math.atan(r/this._viewModel.triangulatedDistanceMeasurement.distance);this._viewModel.triangulatedDistanceAccuracy={distanceAccuracy:r,angleAccuracy:e}}break}case"area":if(this._viewModel.currentBestFeatureMeasurementImage?.geometry.spatialReference)if(this._viewModel.triangulatedAreaMeasurement=await z(this._viewModel.measurementVectors,this._viewModel.currentBestFeatureMeasurementImage.geometry.spatialReference),"default"===this._viewModel.mode)this._viewModel.triangulatedAreaAccuracy=await this.calculateAccuracy(e,"area")??this._viewModel.triangulatedAreaAccuracy;else if("panoramic"===this._viewModel.mode){const i=e.map(([e,i,r])=>s({x:e,y:i,z:r},t,a)).map(({x:e,y:t})=>[e,t]);this._viewModel.triangulatedAreaAccuracy=await this.calculateAccuracyPanoramic(i,"area")??this._viewModel.triangulatedAreaAccuracy}}if("panoramic"===this._viewModel.mode){this._viewModel.activeTriangulatedViewer.viewModel.restoreNavigationHandles()}}}export{b as ImageMeasurementService};
5
+ import{throwIfAborted as e}from"../../../core/promiseUtils.js";import{distance as t}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{projectWithZConversion as a}from"../../../geometry/projectionUtils.js";import{imageToWorld as i,imageToWorldPanoramic as r}from"../../../layers/orientedImagery/transformations/imageToWorld.js";import{getImageToWorldProperties as n,convertSphereVertexToPixelLocation as s}from"../../../layers/orientedImagery/transformations/utils.js";import{formatPixels as l,heightMeasurementPanoramic as c,heightMeasurement2D as o,calculateHeightAccuracyPanoramic as u,calculateHeightAccuracy as m,pixelAreaMeasurement2D as w,pixelAreaMeasurementPanoramic as d,pixelDistanceMeasurement2D as M,pixelDistanceMeasurementPanoramic as h,generateCombinations as g,getRootOfSumOfSquaredErrors as v,generateCombinationsPanoramic as p,calculateLocationAccuracyFromDeviations as f,calculateReferenceImagePointPanoramic as y,calculateAnglePano as _,calculateTempImagePoint as P,calculateAngle as A,computeTriangulatedAreaMeasurement as z,computeTriangulatedDistanceMeasurement as x}from"../imageMeasurementUtils.js";class b{constructor(e){this._viewModel=e}async computeHeight(e,t,a=!0){const{currentBestFeature:i,activeViewer:r,layer:s,footprintExtent:w}=this._viewModel,d=r?.imageSize,M=i?.attributes,h=s?.orientationAccuracy;if(!M||!d||!e||e.length<2||!h)return;const g="panoramic"===t?await this._viewModel.getMeasurementPropertiesPanoramic():n(M,d[0],d[1]),v=e.at(0),p=e.at(-1);if(!(g&&v&&p&&h&&w))return;const f=[p,v],y=l(f,!1),_="panoramic"===t?await c(f,g,h,i,!0,!1):await o(f,g,h,!0,a);if(!_)return;const P="panoramic"===t?await u(h,y,g,_,i,!0):await m(h,y,g,_,!0);return P?{value:_,accuracy:P}:{value:_}}async calculateAreaMeasurement(t,a,i){if(t.length<3||!this._viewModel.currentBestFeature||!this._viewModel.activeViewer?.imageSize||"none"===this._viewModel.mode)return null;const r="default"===a?await this._viewModel.getMeasurementProperties():await this._viewModel.getMeasurementPropertiesPanoramic();return e(i),r?"default"===a?await w(t,r,!0):await d(t,r,!0,i):null}async calculateDistanceMeasurement(t,a,i){const{currentBestFeature:r,activeViewer:n}=this._viewModel;if(t.length<2||!r||!n?.imageSize||"none"===a)return null;const s="default"===a?await this._viewModel.getMeasurementProperties():await this._viewModel.getMeasurementPropertiesPanoramic();return e(i),s?"default"===a?await M([t.at(0),t.at(-1)],s,!0):await h([t.at(0),t.at(-1)],s,!0):null}async calculateAccuracy(t,a,i){const{layer:r,currentBestFeature:n,activeViewer:s,currentBestFeatureMeasurementImage:l,triangularMeasurementActive:c,imageMeasurementViewer:o}=this._viewModel,u=r?.orientationAccuracy,m=u?.every(e=>0===e)||!u?.length;if("area"===a&&t.length<3||"distance"===a&&t.length<2||!n||!s?.imageSize||m)return null;let d=null;if(c&&l&&o?d=await this._viewModel.getMeasurementProperties(l,o):(d=await this._viewModel.getMeasurementProperties(),e(i)),!d)return null;const h="area"===a?await w(t,d,!0):await M([t.at(0),t.at(-1)],d,!0);e(i);const{updateElevationProps:p,...f}=d,y=g(f,u);if(!y?.length)return null;const _=y.map(e=>({...e,updateElevationProps:p})).map(async r=>{const n="area"===a?await w(t,r,!0):await M([t.at(0),t.at(-1)],r,!0);if(e(i),n&&h){if("area"===a){const e="number"!=typeof n?n.area:null;return e?Math.abs(e-h.area):null}return Math.abs(n-h)}return null}),P=await Promise.all(_);e(i);const A=P.filter(e=>null!==e);return 0===A.length?null:v(A)}async calculateLocationAccuracy(t,n,s="default",l){const{layer:c,currentBestFeature:o}=this._viewModel,u=c?.orientationAccuracy,m=this._viewModel.view?.spatialReference,w=u?.every(e=>0===e)||!u?.length;if(!o||w)return null;const d="default"===s?await this._viewModel.getMeasurementProperties():await this._viewModel.getMeasurementPropertiesPanoramic();if(e(l),!d)return null;const{updateElevationProps:M,...h}=d,v="default"===s?g(h,u):p(h,u);if(!v?.length)return null;const y=v.map(e=>({...e,updateElevationProps:M})).map(async c=>{const{updateElevationProps:o,...u}=c;let w="default"===s?await i(t,u,o):await r(t,u,o);return e(l),m&&!w.spatialReference.equals(m)&&(w=await a(w,m),e(l)),w&&n?[Math.abs(w.x-n.x),Math.abs(w.y-n.y),w.z&&n.z?Math.abs(w.z-n.z):0]:null}),_=await Promise.all(y);if(e(l),!_?.length)return null;const P=_.map(e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0]),[A,z,x]=f(P);return{x:A,y:z,z:x}}async calculateAccuracyPanoramic(t,a,i=!1,r){const{layer:n,currentBestFeature:s,activeViewer:l,mode:c,currentBestFeatureMeasurementImage:o,activeTriangulatedViewer:u}=this._viewModel,m=n?.orientationAccuracy,w=m?.every(e=>0===e)||!m?.length;if("area"===a&&t.length<3||"distance"===a&&t.length<2||!s||!l?.imageSize||w||"panoramic"!==c)return null;const M=i&&o&&u?await this._viewModel.getMeasurementPropertiesPanoramic(o,u):await this._viewModel.getMeasurementPropertiesPanoramic();if(e(r),!M)return null;const g="area"===a?await d(t,M,!0):await h([t.at(0),t.at(-1)],M,!0);e(r);const{updateElevationProps:f,...y}=M,_=p(y,m);if(!_?.length)return null;const P=_.map(e=>({...e,updateElevationProps:f})).map(async i=>{const n="area"===a?await d(t,i,!0):await h([t.at(0),t.at(-1)],i,!0);if(e(r),n&&g){if("area"===a){const e="number"!=typeof n?n.area:null;return e?Math.abs(e-g.area):null}return Math.abs(n-g)}return null}),A=await Promise.all(P);e(r);const z=A.filter(e=>null!==e);return 0===z.length?null:v(z)}async calculateHeightMeasurementInfo(e,a,i){const{currentBestFeature:r,activeViewer:s}=this._viewModel,c=s?.imageSize;if(!r||!s||!c?.length||"none"===a)return;const{attributes:o}=r,[u]=l([e],"panoramic"!==a),m="panoramic"===a?await this._viewModel.getMeasurementPropertiesPanoramic():n(o,c[0],c[1]);if("panoramic"===a){if(!m)return;const e=await y(u,m,r,i);if(!e)return;e?.heading>180&&(e.heading-=360);const a=_(u,e),n=t([u.x,u.y],[e.x,e.y]);if(!a||!n)return;return{measurementAngle:a,tempDistance:n}}const w=await P(u,m,i);if(!w)return;const d=A(u,w),M=t([u.x,u.y],[w.x,w.y]);return d&&M?{measurementAngle:d,tempDistance:M}:void 0}async calculateTriangulatedMeasurements(e){if(!this._viewModel.activeTriangulatedViewer?.imageSize)return;const[t,a]=this._viewModel.activeTriangulatedViewer.imageSize;switch(this._viewModel.measureType){case"distance":{this._viewModel.triangulatedDistanceMeasurement=await x(this._viewModel.measurementVectors);const i=e.map(([e,i,r])=>s({x:e,y:i,z:r},t,a)).map(({x:e,y:t})=>[e,t]),r="default"===this._viewModel.mode?await this.calculateAccuracy(e,"distance"):await this.calculateAccuracyPanoramic(i,"distance",!0);if(r&&this._viewModel.triangulatedDistanceMeasurement?.distance){const e=Math.atan(r/this._viewModel.triangulatedDistanceMeasurement.distance);this._viewModel.triangulatedDistanceAccuracy={distanceAccuracy:r,angleAccuracy:e}}break}case"area":if(this._viewModel.currentBestFeatureMeasurementImage?.geometry.spatialReference)if(this._viewModel.triangulatedAreaMeasurement=await z(this._viewModel.measurementVectors,this._viewModel.currentBestFeatureMeasurementImage.geometry.spatialReference),"default"===this._viewModel.mode)this._viewModel.triangulatedAreaAccuracy=await this.calculateAccuracy(e,"area")??this._viewModel.triangulatedAreaAccuracy;else if("panoramic"===this._viewModel.mode){const i=e.map(([e,i,r])=>s({x:e,y:i,z:r},t,a)).map(({x:e,y:t})=>[e,t]);this._viewModel.triangulatedAreaAccuracy=await this.calculateAccuracyPanoramic(i,"area",!0)??this._viewModel.triangulatedAreaAccuracy}}if("panoramic"===this._viewModel.mode){this._viewModel.activeTriangulatedViewer.viewModel.restoreNavigationHandles()}}}export{b as ImageMeasurementService};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{prefersReducedMotion as i}from"../core/a11yUtils.js";import{createTask as a}from"../core/asyncUtils.js";import o from"../core/Collection.js";import{deprecatedProperty as s}from"../core/deprecate.js";import n from"../core/Logger.js";import{isAbortError as r}from"../core/promiseUtils.js";import{watch as l,initial as d,syncAndInitial as c,whenOnce as g}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{or as u}from"../layers/orientedImagery/transformations/utils.js";import v from"./Expand.js";import p from"./PanoramicVideoViewer.js";import y from"./PanoramicViewer.js";import w from"./Widget.js";import{getAllArcPath as _}from"./OrientedImageryViewer/arcUtils.js";import{getDelegatedEvents as M,defaultImageGeometryField as T,defaultOIObjectIDField as b,segmentArcs as C,featureCircleRadius as A,navigationToolDimensionLength as I,sectorsRadii as f}from"./OrientedImageryViewer/constants.js";import{css as L,navigation as V,navigationToolRotationFrom as k,navigationToolRotationTo as S,root as O}from"./OrientedImageryViewer/css.js";import{loadImageForAttachment as F,getThumbnailPixelBlock as E,isFeatureAttachment as P,renderImageWithRotation as x}from"./OrientedImageryViewer/galleryUtils.js";import H from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import j from"./OrientedImageryViewer/OrientedImageryViewerVisibleElements.js";import{loadAlertComponents as N,Alert as D}from"./OrientedImageryViewer/components/Alert.js";import G from"./OrientedImageryViewer/components/ImageLocationWidget.js";import $ from"./OrientedImageryViewer/components/ImageViewer.js";import B from"./OrientedImageryViewer/components/NavigationAction.js";import{loadNavigationActionsComponents as R,NavigationActionsCollection as W,NavigationActions as U}from"./OrientedImageryViewer/components/NavigationActions.js";import{loadVideoEnhancementComponents as z,renderEnhancementSlider as q,VideoEnhancementTools as Z}from"./OrientedImageryViewer/components/VideoEnhancementTools.js";import{NoImageLoadedError as J}from"./OrientedImageryViewer/navigation/errors.js";import{loadCalciteComponents as K}from"./support/componentsUtils.js";import{globalCss as Q}from"./support/globalCss.js";import{vmEvent as X,messageBundle as Y,tsx as ee}from"./support/widget.js";const te={overlayed:"overlayed"};let ie=class extends w{constructor(e,t){super(e,t),this.dataCaptureEnabled=!1,this.galleryOpened=!1,this.imageEnhancementToolActive=!1,this.videoEnhancementToolActive=!1,this.imageOverlaysOpened=!1,this.navigationToolActive=!1,this.viewModel=new H,this.messagesCommon=null,this.messagesSketch=null,this.pixelMeasurementUnit="meters",this.pixelAreaMeasurementUnit="square-meters",this.showCameraLocations=!1,this.showMapFeatures=!1,this.visibleElements=new j,this._imageOverlaysLoaderTask=null,this._imageMeasurementToolsLoaderTask=null,this._navigationSettingsLoaderTask=null,this._clearMeasurements=()=>{this.viewModel.measureType=null,this.viewModel.triangularMeasurementActive=!1,this.viewModel.clearPreviousMeasurements()},this._clearImageLocation=()=>{this.imageLocationToolActive=!1,this.triangularMeasurementActive=!1},this._navigationToolExpanded=!1,this._navigationTool=null,this._galleryController=new AbortController,this._galleryObserver=new IntersectionObserver(this._lazyLoadImage.bind(this)),this._overlayedLayers=new o,this._previousAction=null,this._handleDataCaptureLayerChange=async e=>{if(this.dataCaptureLayer&&await this.stopDataCapture(!0),this.dataCaptureLayer=this.dataCaptureLayer===e?null:e,this.dataCaptureLayer)return this.startDataCapture(this.dataCaptureLayer)},this._handleNavigationSettingsInputChange=(e,t)=>{this.set(`${e}Threshold`,t)},this._handleNavigationSettingsToggle=e=>{this.viewModel.preserveAngle=e},this._handleOverlayLayerDeselect=e=>{const t=e.layer;t===this.dataCaptureLayer&&(this.stopDataCapture(),this.dataCaptureLayer=null),this.removeOverlayedGraphicsOnImage(`${t.id}`)},this._handleOverlayLayerSelect=e=>{const t=e.layer;this.viewModel.overlayMapFeatures(t,this.showMapFeatures),this.addHandles(l(()=>t.visible,()=>{this.viewModel.toggleOverlayMapFeatures(t.id,t.visible,this.showMapFeatures)}),`${te.overlayed}-${t.id}`)},this._highlight=e=>{const t=e.target?.dataset.objectid;t&&this.viewModel.highlight(t)},this._onAction=e=>{const{target:t}=e,{dataset:{action:i}}=t,{_previousAction:a}=this,o=a?.dataset.action,s=o?.includes("draw")??!1,n="select-feature"===o,r=o!==i;switch(i){case"draw-point":case"draw-polygon":case"draw-polyline":{a&&u(n,s&&r)&&(a.active=!1),t.active=!t.active;const e=i.replace("draw-","");this.viewModel.digitizeCreate(e),this._previousAction=t.active?t:null;break}case"save":this.viewModel.saveDrawing();break;case"select-feature":s&&(this._previousAction.active=!1),t.active=!t.active,this.viewModel.toggleSelection(t.active),this._previousAction=t.active?t:null;break;case"delete-feature":this.viewModel.digitizeDelete()}},this._onImageOverlayClosed=()=>{this.imageOverlaysOpened=!1},this._onShowCameraLocationsChanged=e=>{this.showCameraLocations=e},this._onShowMapFeaturesChanged=e=>{this.showMapFeatures=e},this._removeHighlight=()=>this.viewModel.removeHighlight(),this._restoreOverlays=async()=>Promise.all(this._overlayedLayers.map(e=>this.viewModel.overlayMapFeatures(e,this.showMapFeatures))),this._scaleNavigationTool=()=>{this._navigationToolExpanded=!this._navigationToolExpanded},this._sketchLoaderTask=null,this._settingsToggle=null,this._toggleImageNavigation=async e=>{const t=this.navigationMode;this._closeAllImageTools(),this.navigationMode=t!==e?e:null;const{activeViewer:i}=this.viewModel;if(!i)return;const{mode:a,preserveAngle:o}=this.viewModel;if("default"===a)if("directional"===this.navigationMode){const e=await this._loadNavigationSettings(),t="heading"===o||"both"===o,i="pitch"===o||"both"===o,{messages:a,messagesCommon:s}=this,n=new e({cameraHeadingThreshold:this.cameraHeadingThreshold,cameraPitchThreshold:this.cameraPitchThreshold,uiStrings:{configureNavigation:a.configureNavigation,preserveHeading:a.preserveHeading,preserveHeadingDescription:a.preserveHeadingDescription,preservePitch:a.preservePitch,preservePitchDescription:a.preservePitchDescription,settings:s.settings,thresholdLabel:a.thresholdLabel},onInputChange:this._handleNavigationSettingsInputChange,onToggle:this._handleNavigationSettingsToggle,preserveHeading:t,preservePitch:i});this._settingsToggle=new v({content:n,expandIcon:"configure"}),this.viewModel.activeViewer?.ui.add(this._settingsToggle,{position:"top-left"})}else this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))},this._toggleImageAttributes=()=>{this.viewModel.toggleImageAttributes()},this.navigate=async e=>{let t=null;try{const{currentNode:i}=this.viewModel;if(!i)throw new J;t=await this.viewModel.navigate(i,e)}catch(i){r(i)||n.getLogger(this).error("Error occurred while navigating",i)}return t},this.reset=()=>{this._closeAllImageTools(),this.viewModel.reset()},this._loadImageFromGallery=this._loadImageFromGallery.bind(this),this._registerGalleryItem=this._registerGalleryItem.bind(this),this._unregisterGalleryItem=this._unregisterGalleryItem.bind(this),this.loadImageFromSource=this.loadImageFromSource.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this._handleVideoBrightnessChange=this._handleVideoBrightnessChange.bind(this),this._handleVideoContrastChange=this._handleVideoContrastChange.bind(this),this._handleBrightnessChange=this._handleBrightnessChange.bind(this),this._handleContrastChange=this._handleContrastChange.bind(this),this._handleSharpnessChange=this._handleSharpnessChange.bind(this),this._resetVideoTools=this._resetVideoTools.bind(this),this._toggleEnhancementToolState=this._toggleEnhancementToolState.bind(this)}initialize(){this.addHandles([l(()=>[this.viewModel?.bestFeatureAngle,this._navigationTool],([e,t])=>{t&&this._updateNavigationTool(t)},d),l(()=>this.currentCoverageVisible,e=>this._onCurrentCoverageVisibilityChange(e)),l(()=>this.isAdditionalCoverageVisible,e=>this._onAdditionalCoverageVisibilityChange(e)),l(()=>this.isAdditionalPointSourcesVisible,e=>this._onAdditionalCameraLocationsVisibility(e)),l(()=>({features:this.currentBestFeature,showCameraLocations:this.showCameraLocations,state:this.viewModel.state}),({showCameraLocations:e,state:t})=>{"image-loaded"===t&&this.viewModel.overlayCameraLocations(e)},c),l(()=>({feature:this.currentBestFeature,showMapFeatures:this.showMapFeatures,state:this.viewModel.state}),async(e,t)=>{if(e.showMapFeatures!==t?.showMapFeatures&&this.viewModel.toggleAllOverlayMapFeatures(e.showMapFeatures),null!=e.feature&&e.feature!==t?.feature){if(this.viewModel.removeAllOverlayMapFeatures(),await g(()=>"image-loaded"===this.viewModel.state),this.dataCaptureLayer&&this.stopDataCapture(),await this._restoreOverlays(),!this.dataCaptureLayer)return;await this.startDataCapture(this.dataCaptureLayer),this._previousAction?.active&&(this._previousAction.active=!1,this._previousAction=null)}},d)])}loadDependencies(){return Promise.all([R(),z(),K({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),shell:()=>import("@esri/calcite-components/dist/components/calcite-shell"),dialog:()=>import("@esri/calcite-components/dist/components/calcite-dialog"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider")}),N()])}destroy(){this._galleryController.abort(),this._galleryObserver.disconnect(),this.currentBestFeature=null}get accuracyParametersMissing(){return this.viewModel.accuracyParametersMissing}get activeLayer(){return s(n.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){s(n.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeVideoIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?t.videoPaused?"play":"pause":"play"}get activeAudioIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?.videoMuted?"sound-off":"sound"}get cameraHeadingThreshold(){return this.viewModel.cameraHeadingThreshold}set cameraHeadingThreshold(e){this.viewModel.cameraHeadingThreshold=e}get cameraPitchThreshold(){return this.viewModel.cameraPitchThreshold}set cameraPitchThreshold(e){this.viewModel.cameraPitchThreshold=e}get canNavigateSequentially(){const{layer:e}=this;if(!e)return!1;const{fields:t,sequenceOrderField:i}=e;return t.some(({name:e})=>e.toLowerCase()===`${i??"sequenceorder"}`.toLowerCase())}get currentBestFeature(){return this.viewModel.currentBestFeature}set currentBestFeature(e){this.viewModel.currentBestFeature=e}get currentCoverageVisible(){return this.viewModel.currentCoverageVisible}set currentCoverageVisible(e){this.viewModel.currentCoverageVisible=e}get dataCaptureLayer(){return this.viewModel.dataCaptureLayer}set dataCaptureLayer(e){this.viewModel.dataCaptureLayer=e}get depthImageNotSupported(){return this.viewModel.depthImageNotSupported}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get displayMessage(){return this.viewModel.displayMessage}get enhancementToolActive(){return"video"===this.viewModel.mode?this.videoEnhancementToolActive:this.imageEnhancementToolActive}set enhancementToolActive(e){"video"===this.viewModel.mode?this.videoEnhancementToolActive=e:this.imageEnhancementToolActive=e}get features(){return this.viewModel.features}get imagePointsInView(){return this.viewModel.imagePointsInView}get icon(){return"oriented-imagery-widget"}set icon(e){this._overrideIfSome("icon",e)}get imageGalleryEnabled(){return this.viewModel.imageGalleryEnabled}get imageLocationToolActive(){return this.viewModel.imageLocationToolState}set imageLocationToolActive(e){this.viewModel.imageLocationToolState=e}get invalidCameraHeading(){return this.viewModel.invalidCameraHeading}get isAdditionalCoverageVisible(){return this.viewModel.isAdditionalCoverageVisible}set isAdditionalCoverageVisible(e){this.viewModel.isAdditionalCoverageVisible=e}get isAdditionalPointSourcesVisible(){return this.viewModel.isAdditionalPointSourcesVisible}set isAdditionalPointSourcesVisible(e){this.viewModel.isAdditionalPointSourcesVisible=e}get mapImageConversionToolState(){return this.viewModel.mapImageConversionToolState}set mapImageConversionToolState(e){this.viewModel.mapImageConversionToolState=e}get measureType(){return this.viewModel.measureType}set measureType(e){this.viewModel.measureType=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get navigationMode(){return this.viewModel.navigationMode}set navigationMode(e){this.viewModel.navigationMode=e}get popupEnabled(){const{popupEnabled:e,state:t}=this.viewModel;return("image-loaded"===t||this.videoLoaded)&&e}get referencePoint(){return this.viewModel.referencePoint??null}get sketchViewModel(){return this.viewModel.sketch}get triangularMeasurementActive(){return this.viewModel.triangularMeasurementActive}set triangularMeasurementActive(e){this.viewModel.triangularMeasurementActive=e}get videoLoaded(){const{mode:e,videoElement:t,panoramicVideoLoaded:i}=this.viewModel;return("video"===e&&!0===t?.loaded||i)??!1}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set determineWorkflowForFeature(e){this.viewModel.determineWorkflowForFeature=e}get determineWorkflowForFeature(){return this.viewModel.determineWorkflowForFeature}set updateFootprint(e){this.viewModel.updateFootprint=e}get updateFootprint(){return this.viewModel.updateFootprint}_renderActionBar(){return ee("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},ee("calcite-action-group",null,this._currentFootprintToggle(),this._additionalFootprintToggle(),this._additionalPointSourcesToggle()),ee("calcite-action-group",null,this._directionToolToggle(),this._mapImageConversionToggle(),this._navigationToolToggle(),this._imageEnhancementsToggle(),this._videoEnhancementsToggle()),ee("calcite-action-group",null,this._measurementToolsToggle(),this._imageGalleryToggle(),this._imageOverlaysToggle(),this._openPopupAction()))}get _activeMeasurementIcon(){const{measureType:e,imageLocationToolActive:t}=this;if(t)return"pin-tear";switch(e){case"area":return"measure-area";case"height":return"measure-building-height-top-base";default:return"measure-line"}}get _activeMeasurementHeading(){const{measureType:e,messages:t,triangularMeasurementActive:i}=this,{groundArea:a,heightAboveGround:o,groundDistance:s,triangulatedAreaHeading:n,triangulatedDistanceHeading:r}=t;if(i)return"area"===e?n:r;switch(e){case"area":return a;case"height":return o;default:return s}}_additionalFootprintToggle(){const{isAdditionalCoverageVisible:e,invalidCameraHeading:t,visibleElements:{additionalFootprintToggle:i}}=this;return i?ee("calcite-action",{active:e,bind:this,class:L.addCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleAdditionalCoverage,text:this.messages.additionalFootprints,title:this.messages.additionalFootprints}):null}_additionalPointSourcesToggle(){const{isAdditionalPointSourcesVisible:e,invalidCameraHeading:t,visibleElements:{additionalCameraLocationsToggle:i}}=this;return i?ee("calcite-action",{active:e,bind:this,class:L.addExpPoints,disabled:t,icon:"circle-area",onclick:this._toggleAdditionalCameraLocations,text:this.messages.additionalCameraLocations,title:this.messages.additionalCameraLocations}):null}get _measurementToggle(){const{viewModel:{state:e,measureType:t,currentBestFeatureMeasurementImage:i},triangularMeasurementActive:a,id:o}=this;if("image-loaded"!==e||!t||a&&!i)return;this._imageMeasurementToolsLoaderTask||this._loadImageMeasurementResources();const s=this._imageMeasurementToolsLoaderTask?.value;return s?ee("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:this._activeMeasurementHeading,id:`${o}-${t}-measurement`,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearMeasurements},ee(s,{measurementType:t,measurementUnitMessages:this.measurementUnitMessages,messages:this.messages,oiViewModel:this.viewModel})):null}get _renderRoot(){const{viewModel:{state:e},triangularMeasurementActive:t}=this;return ee("calcite-panel",{bind:this,class:t?L.viewerContainerMeasurement:L.viewerContainer,heading:this.visibleElements.title?this.messages.title:void 0,loading:e.includes("loading")&&!t},this.visibleElements.menu?this._renderActionBar():null,ee("calcite-shell",null,ee("calcite-panel",null,this._imageViewer,this._panoramicViewer,this._panoramicVideoViewer,this._videoViewer,this._messageBox,this.invalidCameraHeading?null:[this._imageGalleryPanel,this._renderNavigation,this._imageOverlaysPanel()],this._imageEnhancementTools,this._videoEnhancementTools,this._renderSketch()),this._imageViewerTriangular,this._measurementToggle,this._locationToggle,this.invalidCameraHeading?this._renderWarning(this.messages.invalidCameraHeadingWarningTitle,this.messages.invalidCameraHeadingWarningDescription):null,this.depthImageNotSupported?this._renderWarning(this.messages.depthImageNotSupportedTitle,this.messages.depthImageNotSupportedDescription):null))}_currentFootprintToggle(){const{currentCoverageVisible:e,invalidCameraHeading:t}=this,{currentFootprintToggle:i}=this.visibleElements;return i?ee("calcite-action",{active:e,bind:this,class:L.currentCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleCurrentCoverage,text:this.messages.currentFootprint,title:this.messages.currentFootprint}):null}get _imageEnhancementTools(){const{enhancementToolActive:e,viewModel:{brightness:t,contrast:i,sharpness:a,state:o}}=this;return e&&"image-loaded"===o?ee("calcite-panel",{bind:this,class:L.imageEnhancementWrapper,closable:!0,closed:!e,heading:this.messages.imageEnhancement,key:this.messages.imageEnhancement,onCalcitePanelClose:this._toggleEnhancementToolState},ee("div",{class:L.imageEnhancementTools},q({title:this.messages.brightness,value:t,max:10,min:-10,ticks:5,handleChange:this._handleBrightnessChange}),q({title:this.messages.contrast,value:i,max:10,min:-10,ticks:5,handleChange:this._handleContrastChange}),q({title:this.messages.sharpness,value:a,max:1,min:0,ticks:.5,step:.1,handleChange:this._handleSharpnessChange})),ee("calcite-action",{bind:this,icon:"reset",onclick:this._resetImageTools,slot:"header-actions-end",text:this.messagesCommon.reset,title:this.messagesCommon.reset})):null}get _videoEnhancementTools(){const{enhancementToolActive:e,viewModel:{videoViewModel:t,mode:i},messages:{videoEnhancement:a,brightness:o,contrast:s},messagesCommon:{reset:n}}=this;return e&&"video"===i&&t?ee(Z,{brightness:t.videoBrightness,constrast:t.videoContrast,handleBrightnessChange:this._handleVideoBrightnessChange,handleContrastChange:this._handleVideoContrastChange,resetTools:this._resetVideoTools,uiStrings:{videoEnhancement:a,brightness:o,contrast:s,reset:n},videoEnhancementToolActive:e,onClose:this._toggleEnhancementToolState}):null}_imageEnhancementsToggle(){const{state:e,mode:t}=this.viewModel,{imageEnhancement:i}=this.visibleElements;return i&&"video"!==t?ee("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"default"!==t||"image-loaded"!==e,icon:"sliders-horizontal",onclick:this._toggleEnhancementToolState,text:this.messages.imageEnhancement,title:this.messages.imageEnhancement}):null}_videoEnhancementsToggle(){const{mode:e}=this.viewModel,{videoEnhancement:t}=this.messages;return"video"===e?ee("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"video"!==e,icon:"sliders-horizontal",onclick:this._toggleEnhancementToolState,text:t,title:t}):null}get _imageGalleryPanel(){const{container:e,galleryOpened:t,imageGalleryEnabled:i}=this;return i&&t&&e?this._imageGalleryContext:null}get _imageGalleryContext(){const{galleryOpened:e,invalidCameraHeading:t}=this;return ee("calcite-panel",{bind:this,class:L.carousel,closable:!0,closed:!e,disabled:t,heading:this.messages.imageGallery,key:this.messages.imageGallery,onCalcitePanelClose:this._toggleImageGallery},ee("div",{class:L.carouselContainer},this._renderThumbnails))}_imageGalleryToggle(){const{imageGalleryEnabled:e,invalidCameraHeading:t,visibleElements:{imageGallery:i}}=this;return i?ee("calcite-action",{active:this.galleryOpened,bind:this,disabled:!e||t,icon:"images",onclick:this._toggleImageGallery,text:this.messages.imageGallery,title:this.messages.imageGallery}):null}get _imageOverlaysComponent(){const{_imageOverlayMessages:e,_imageOverlaysLoaderTask:t,_overlayedLayers:i,dataCaptureEnabled:o,dataCaptureLayer:s,imageOverlaysOpened:n,showCameraLocations:r,showMapFeatures:l,view:d,layer:c}=this;if(!c)return null;const g=c.imageGeometryField?.length?c.imageGeometryField:T,h=c.imageReferenceField?.length?c.imageReferenceField:b;t||(this._imageOverlaysLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/ImageOverlays.js")).default));const m=this._imageOverlaysLoaderTask?.value;return m?ee(m,{closed:!n,dataCaptureEnabled:o,dataCaptureLayer:s,imageGeometryField:g,imageReferenceField:h,messages:e,overlayedLayers:i,showCameraLocations:r,showMapFeatures:l,view:d,onDataCaptureLayerChanged:this._handleDataCaptureLayerChange,onFilterCapturedFeatures:this.viewModel.filterCapturedFeatures,onImageOverlaysClosed:this._onImageOverlayClosed,onLayerDeselected:this._handleOverlayLayerDeselect,onLayerSelected:this._handleOverlayLayerSelect,onShowCameraLocationsChanged:this._onShowCameraLocationsChanged,onShowMapFeaturesChanged:this._onShowMapFeaturesChanged}):null}get _imageOverlayMessages(){return{...this.messages,...this.messagesSketch}}get _imageSketchToolsMessages(){return{...this.messagesSketch,...this.messagesCommon}}_imageOverlaysPanel(){const{imageOverlaysOpened:e,viewModel:{state:t}}=this,i=this.classes({[L.imageOverlaysContainer]:!0,[Q.hidden]:!e||"image-loaded"!==t});return ee("div",{class:i,key:this.messages.imageOverlays},this._imageOverlaysComponent)}_imageOverlaysToggle(){const{viewModel:{state:e},imageOverlaysOpened:t,invalidCameraHeading:i,visibleElements:{imageOverlays:a}}=this;return a?ee("calcite-action",{active:t,bind:this,disabled:"image-loaded"!==e||i,icon:"layers",onclick:this._toggleImageOverlays,text:this.messages.imageOverlays,title:this.messages.imageOverlays}):null}get _imageViewer(){const{displayMessage:e,loadImageViewer:t,mode:i,clickAction:a,state:o}=this.viewModel,s=null!=e||"default"!==i||o.includes("loading"),{messages:{end:n,next:r,previous:l,start:d}}=this;return ee($,{afterCreate:t,clickAction:a,navigationEnabled:!s&&null!==this.navigationMode,navigationViewModel:this.viewModel,uiStrings:{end:n,next:r,previous:l,start:d},visible:!s})}get _imageViewerTriangular(){const{messages:e,triangularMeasurementActive:t}=this,{displayMessage:i,storeImageMeasurementViewer:a,storePanoramicMeasurementViewer:o,mode:s,state:n,clickAction:r}=this.viewModel,l=null!=i||"none"===s||"video"===s,d=this.classes({[L.viewer]:!l,[L.viewerHidden]:l});return t?ee("calcite-panel",{class:L.viewerContainerMeasurement,heading:e.measurementViewerHeading,loading:n.includes("loading")},ee("calcite-panel",{bind:this,class:d},"default"===s?ee($,{afterCreate:a,clickAction:r,uiStrings:e}):ee(y,{afterCreate:o,clickAction:r,uiStrings:e}))):null}get _videoViewer(){const{mode:e,loadVideoViewer:t,videoViewModel:i}=this.viewModel,{control:a,reset:o}=this.messagesCommon,{mute:s,unmute:n}=this.messages,r="video"!==e,l=this.classes({[L.viewer]:!r,[L.viewerHidden]:r}),d="esri-image-viewer";return ee("calcite-panel",{bind:this,class:l},ee("calcite-panel",{afterCreate:t,class:this.classes(Q.widget,d)}),ee("calcite-slider",{bind:this,labelHandles:!0,labelTicks:!0,max:i?.videoDuration,minLabel:"0",value:i?.currentTime??0,onCalciteSliderChange:this._handleVideoSeek}),ee("calcite-action-bar",{expandDisabled:!0,layout:"horizontal"},ee("calcite-action-group",null,ee("calcite-action",{bind:this,icon:this.activeVideoIcon,onclick:()=>i?.playVideoHandler(),text:"Play",title:i?.videoPaused?a.play:a.pause})),ee("calcite-action-group",null,ee("calcite-action",{bind:this,icon:"refresh",onclick:()=>i?.rewindVideoHandler(),text:"Rewind",title:o})),ee("calcite-action-group",null,ee("calcite-action",{bind:this,icon:this.activeAudioIcon,onclick:()=>i?.toggleAudio(),text:"Audio",title:i?.videoMuted?s:n}))))}get _locationToggle(){const{viewModel:{state:e,groundCoordinates:t,groundCoordinatesAccuracy:i,triangulatedPoint:a},imageLocationToolActive:o,triangularMeasurementActive:s,messages:{groundLocation:n,triangulatedLocationHeading:r}}=this;if("image-loaded"!==e||!t||!o)return;let l=t;if(s){if(!a)return;l=a}return ee("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:s?r:n,id:n,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearImageLocation},ee(G,{accuracy:i,groundCoordinates:l,messages:this.messages}))}_mapImageConversionToggle(){const{mapImageConversionToolState:e,viewModel:{state:t,disabled:i},invalidCameraHeading:a,visibleElements:{mapImageConversionTool:o}}=this;return o?ee("calcite-action",{active:e,bind:this,disabled:"image-loaded"!==t||a||i,icon:"image-pin",onclick:this._toggleMapImageConversionToolState,text:this.messages.mapImageConversionTool,title:this.messages.mapImageConversionTool}):null}_measurementToolsToggle(){const{_activeMeasurementIcon:e,measureType:t,viewModel:i,accuracyParametersMissing:a,messages:o,triangularMeasurementActive:s,visibleElements:{measurementTools:n}}=this,{state:r}=i,{measurementTools:l,groundDistance:d,groundArea:c,heightAboveGround:g,groundLocation:h,triangulatedDistanceHeading:m,triangulatedAreaHeading:u,triangulatedLocationHeading:v}=o;return n?ee("calcite-dropdown",{disabled:a,key:"measurement-tools",maxItems:5,title:l,width:"m"},ee("calcite-action",{bind:this,disabled:"image-loaded"!==r||a,icon:e,slot:"trigger",text:l}),ee("calcite-dropdown-group",null,ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-line",key:"distance-measurement",onclick:e=>this._toggleMeasurementSketch(e,"distance"),selected:"distance"===t&&!s},d),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-area",key:"area-measurement",onclick:e=>this._toggleMeasurementSketch(e,"area"),selected:"area"===t&&!s},c),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-building-height-top-base",key:"height-dropdown",onclick:e=>this._toggleMeasurementSketch(e,"height"),selected:"height"===t},g),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"pin-tear",key:"surface-location",onclick:this._toggleLocationTool,selected:!!this.imageLocationToolActive&&!s},h),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"dual-image-location",key:"triangular-location",selected:!!s&&this.imageLocationToolActive,onCalciteDropdownItemSelect:this._toggleTriangularLocation},v),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"dual-image-distance",key:"triangular-measurement-distance",selected:!!s&&"distance"===this.measureType,onCalciteDropdownItemSelect:this._toggleTriangularDistanceMeasurements},m),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"dual-image-area",key:"triangular-measurement-area",selected:!!s&&"area"===this.measureType,onCalciteDropdownItemSelect:this._toggleTriangularAreaMeasurements},u))):null}get _messageBox(){const{messages:e,viewModel:{displayMessage:i,mode:a}}=this;if(!i||"video"===a)return null;const{data:o,key:s,map:n}=i,r=`${n?t(e[s],n):e[s]}`;return ee("span",{class:L.messageBox},o?`${r} ${o}`:r)}async _loadNavigationSettings(){return this._navigationSettingsLoaderTask||(this._navigationSettingsLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/NavigationSettings.js")).default)),await this._navigationSettingsLoaderTask.promise}_navigationToolToggle(){const{state:e}=this.viewModel,{visibleElements:{navigationTool:t},videoLoaded:i}=this;return t?ee("calcite-action",{active:this.navigationToolActive,bind:this,disabled:"image-loaded"!==e&&!i||this.invalidCameraHeading,icon:"explore",onclick:this._toggleNavigationTool,text:this.messages.navigationTool,title:this.messages.navigationTool}):null}_directionToolToggle(){const{state:e}=this.viewModel,{visibleElements:{directionalNavigation:t,sequentialNavigation:i}}=this,a=new W;t&&a.push(new B({active:"directional"===this.navigationMode,disabled:"image-loaded"!==e||this.invalidCameraHeading,icon:"i2DExplore",onclick:()=>{this._toggleImageNavigation("directional")},text:this.messages.directionalNavigation,title:this.messages.directionalNavigationDescription})),i&&a.push(new B({active:"sequential"===this.navigationMode,disabled:"image-loaded"!==e||this.invalidCameraHeading||!this.canNavigateSequentially,icon:"reorder-stack",onclick:()=>{this._toggleImageNavigation("sequential")},text:this.messages.sequentialNavigation,title:this.messages.sequentialNavigationDescription}));return t||i?ee(U,{actions:a,activeAction:a.items.find(e=>e.active),icon:"absolute-direction",label:this.messages.imageNavigation,scale:"m",title:this.messages.imageNavigation}):null}_openPopupAction(){const{showPopupsAction:e}=this.visibleElements;return e?ee("calcite-action",{bind:this,disabled:!this.popupEnabled,icon:"popup",onclick:this._toggleImageAttributes,text:this.messages.showPopups,title:this.messages.showPopups}):null}get _panoramicVideoViewer(){const{displayMessage:e,loadPanoramicVideoViewer:t,mode:i,clickAction:a,state:o,currentBestFeature:s}=this.viewModel,n=s?.attributes.imagePath,r=null!=e||"panoramic-video"!==i||o.includes("loading")||!n;return ee(p,{afterCreate:t,clickAction:a,oiViewModel:this.viewModel,videoSource:n,visible:!r})}get _panoramicViewer(){const{displayMessage:e,loadPanoramicViewer:t,mode:i,clickAction:a,state:o}=this.viewModel,{messages:{end:s,next:n,previous:r,start:l}}=this,d=null!=e||"panoramic"!==i||o.includes("loading");return ee(y,{afterCreate:t,clickAction:a,navigationEnabled:!d&&null!==this.navigationMode,navigationViewModel:this.viewModel,uiStrings:{end:s,next:n,previous:r,start:l},visible:!d})}_activateTriangulatedImageLocationTool(){this.navigationToolActive=!0,this.imageLocationToolActive=!0}_activateTriangulatedImageLocationWorkflow(e,t){this._closeAllImageTools(),this.imageLocationToolActive=!0,this.triangularMeasurementActive=!e,this.navigationToolActive=!!t||!t}_closeImageToolsAndToggleNavigation(e,t){this._closeAllImageTools(),this.triangularMeasurementActive=!e,this.navigationToolActive=!t}_resetMeasureTypeAndActivateImageLocationTool(){this.measureType=null,this.imageLocationToolActive=!0}_closeAllImageTools(){this.enhancementToolActive=!1,this.navigationToolActive=!1,this.imageOverlaysOpened=!1,this.galleryOpened=!1,this.measureType=null,this.imageLocationToolActive=!1,this.navigationMode=null,this.triangularMeasurementActive=!1,this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))}_handleBrightnessChange(e){this.viewModel.brightness=e.currentTarget.value??0}_handleVideoBrightnessChange(e){this.viewModel.videoViewModel?.handleVideoBrightnessChange(e.target.value)}_handleContrastChange(e){this.viewModel.contrast=e.currentTarget.value??0}_handleVideoContrastChange(e){this.viewModel.videoViewModel?.handleVideoContrastChange(e.target.value)}_handleVideoSeek(e){const t=this.viewModel?.videoElement?.content;t&&(t.currentTime=e.target.value,t.play())}_handleSharpnessChange(e){this.viewModel.sharpness=e.currentTarget.value??0}_lazyLoadImage(e,t){e.forEach(async e=>{if(e.isIntersecting){const a=e.target,o=a.getAttribute("data-src"),s=a.getAttribute("data-rotation"),l=a.getAttribute("data-objectid"),d=s?parseFloat(s)%360:0,{layer:c,_galleryController:{signal:g}}=this;if(!o||!l)return;let h;try{h=P(o)?await F(c,l,{signal:g}):await E(o,{signal:g})}catch(i){r(i)||n.getLogger("esri.widgets.OrientedImageryViewer").error("#lazyLoadImage()",i)}finally{t.unobserve(a)}if(!h)return;x(h,a,d)}})}_loadImageFromGallery(e){const{target:t}=e;if(!t)return;const i=t.getAttribute("data-objectid");i&&this.viewModel.currentBestFeature?.attributes.objectId!==Number(i)&&this.viewModel.selectBestFeature(i)}_loadImageMeasurementResources(){this._imageMeasurementToolsLoaderTask=a(async()=>{const{default:e}=await import("./OrientedImageryViewer/components/ImageMeasurementWidget.js");return e})}_loadSketchResources(){this._sketchLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/SketchTools.js")).default)}_onAdditionalCoverageVisibilityChange(e){this.viewModel.setAdditionalCoverageVisibility(e)}_onAdditionalCameraLocationsVisibility(e){this.viewModel.setAdditionalCameraLocationsVisibility(e)}_onCurrentCoverageVisibilityChange(e){this.viewModel.setCurrentCoverageVisibility(e)}_registerGalleryItem(e){this._galleryObserver.observe(e)}_renderWarning(e,t){const{viewModel:{state:i}}=this;return"image-loaded"===i?ee(D,{icon:"exclamation-mark-triangle-f",kind:"warning",message:t,open:!0,title:e,tooltip:t}):null}get _renderNavigation(){const{viewModel:{sectorData:e,navigatorCurrentBestFeature:t,currentBestFeature:a,state:o}}=this;if(!this.container||!a)return null;let s,n,r,l,d;if(t){const{x:e,y:i,direction:a}=t,[o,c,g,h]=C[a];s=`M ${e} ${i} L ${o} ${c} A ${f[2]} ${f[2]} 0 0 1 ${g} ${h} Z`,n=e,l=i,r=C[a][4],d=C[a][5]}const c=e=>{const t=e.target.dataset?.sector;t&&this.viewModel.handleSectorClick(+t)},g=e=>{const t=e.target.dataset;if(!t)return;const{featureIndexInSector:i,sector:a}=t;i&&a&&this.viewModel.handleFeatureClick({sector:a,featureIndexInSector:+i})},h=e=>{e.removeEventListener("click",g)},m=a.attributes.objectId,u=e?.map(e=>e?.items).filter(Boolean).flatMap(e=>e?.map(({x:e,y:t,objectID:i,featureIndexInSector:a,sector:o})=>ee("circle",{afterRemoved:h,class:this.classes(L.feature,{selected:m===i}),cx:e,cy:t,"data-feature-index-in-sector":a,"data-sector":o,key:`${L.feature}-${i}`,onclick:g,r:A}))),v=e=>{e.removeEventListener("click",c)},p=this.classes({[L.navigationWrapper]:!0,[L.navigationZoomed]:this._navigationToolExpanded});return this.navigationToolActive&&("image-loaded"===o||this.videoLoaded)?ee("div",{bind:this,class:p,key:this.messages.navigationTool},ee("svg",{afterCreate:e=>this._storeNavigationToolReference(e),class:i()?V:L.rotateWithAnimation,focusable:"false",height:I,role:"img",width:I,xmlns:"http://www.w3.org/2000/svg"},ee("defs",null,ee("linearGradient",{gradientUnits:"userSpaceOnUse",id:`${this.id}-coverage-fill`,x1:n,x2:r,y1:l,y2:d},ee("stop",{class:L.navigationPathOffset0,offset:0}),ee("stop",{class:L.navigationPathOffset1,offset:1}))),ee("g",null,ee("circle",{class:this.classes(L.sector,L.outerSector),cx:f[3],cy:f[3],onclick:this._scaleNavigationTool,r:f[3]}),ee("circle",{class:L.sector,cx:f[3],cy:f[3],r:f[2]}),ee("circle",{class:L.sector,cx:f[3],cy:f[3],r:f[1]}),ee("circle",{class:L.sector,cx:f[3],cy:f[3],r:f[0]}),ee("path",{class:L.pointer,d:"M 56.5 6.06217782649107 L 60 0 L 63.5 6.06217782649107 Z",key:`${L.pointer}-west`}),ee("path",{class:this.classes(L.pointer,L.north),d:"M 113.93782217350893 56.5 L 120 60 L 113.93782217350893 63.5 Z",key:`${L.pointer}-north`}),ee("path",{class:L.pointer,d:"M 56.5 113.93782217350893 L 60 120 L 63.5 113.93782217350893 Z",key:`${L.pointer}-east`}),ee("path",{class:L.pointer,d:"M 6.06217782649107 56.5 L 0 60 L 6.06217782649107 63.5 Z",key:`${L.pointer}-south`}),ee("path",{class:this.classes(L.sector,L.sectorSeparator),d:"M 23.937554159486076 23.937554159486076 L 96.06244584051393 96.06244584051393 M 23.937554159486076 96.06244584051393 L 96.06244584051393 23.937554159486076",key:L.sectorSeparator}),_([f[2],f[1],f[0]],f[3],f[3]).map((t,i)=>ee("path",{afterRemoved:v,class:this.classes(L.sector,e?.[i]?.length?L.sectorEnabled:L.sectorDisabled),d:t,"data-sector":`${i}`,key:`${L.sector}-${i}`,onclick:c})),ee("path",{class:this.classes(L.sector,L.sectorCross),d:"M 56.4 56.4 L 63.53 63.53 M 63.53 56.4 L 56.4 63.53",key:L.sectorCross}),u,a.attributes.cameraPitch>=5&&s?ee("path",{class:L.selectedFeaturePath,d:s,fill:`url(#${this.id}-coverage-fill)`,key:L.selectedFeaturePath}):null))):null}_renderSketch(){const{dataCaptureLayer:e,imageOverlaysOpened:t}=this;if(!e||t)return null;if(this._sketchLoaderTask||this._loadSketchResources(),!this._sketchLoaderTask?.value)return null;const{geometryType:i}=e,a="point"===i?"pin":"polyline"===i?"line":"polygon",o=this._sketchLoaderTask.value;return ee("div",{class:L.sketchTools},ee(o,{icon:a,messages:this._imageSketchToolsMessages,type:i,onAction:this._onAction}))}get _renderThumbnails(){const{currentBestFeature:e,thumbnails:t}=this.viewModel;return e?ee("div",{class:L.carouselContent},t?.items.map(({url:t,objectId:i,rotation:a},o)=>ee("div",{class:`${L.carouselItemWrapper}${e.attributes.objectId===i?"--selected":""}`,key:`${L.carouselItemWrapper}-${o}`},ee("canvas",{afterCreate:this._registerGalleryItem,afterRemoved:this._unregisterGalleryItem,alt:`thumbnail-${i}`,class:L.carouselItem,"data-objectid":`${i}`,"data-rotation":`${a}`,"data-src":t,onclick:this._loadImageFromGallery,onmouseenter:this._highlight,onmouseleave:this._removeHighlight})))):null}_resetImageTools(){this.viewModel.sharpness=this.viewModel.brightness=this.viewModel.contrast=0}_resetVideoTools(){this.viewModel.videoViewModel?.resetVideoEnhancementTools()}_storeNavigationToolReference(e){this._navigationTool=e}_toggleAdditionalCameraLocations(){this.isAdditionalPointSourcesVisible=!this.isAdditionalPointSourcesVisible}_toggleAdditionalCoverage(){this.isAdditionalCoverageVisible=!this.isAdditionalCoverageVisible}_toggleCurrentCoverage(){this.currentCoverageVisible=!this.currentCoverageVisible}_toggleEnhancementToolState(e){e.stopPropagation();const t=this.enhancementToolActive;this._closeAllImageTools(),this.enhancementToolActive=!t}_toggleImageOverlays(e){e.stopPropagation();const t=this.imageOverlaysOpened;this._closeAllImageTools(),this.imageOverlaysOpened=!t}_toggleImageGallery(e){e.stopPropagation();const t=this.galleryOpened;this._closeAllImageTools(),this.galleryOpened=!!this.imageGalleryEnabled&&!t}_toggleLocationTool(e){const t=this.imageLocationToolActive,i=this.triangularMeasurementActive&&t;this._closeAllImageTools(),this.imageLocationToolActive=i||!t,e.stopPropagation()}_toggleMeasurementSketch(e,t){e.stopPropagation();const i=this.measureType,a=this.triangularMeasurementActive;this._closeAllImageTools(),this.measureType=i!==t||a?t:null,this.measureType===t&&(this.viewModel.displayNewMeasurementButton=!0)}_toggleNavigationTool(){const e=this.navigationToolActive;this._closeAllImageTools(),this.navigationToolActive=!e}_toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_toggleTriangularAreaMeasurements(){this._toggleTriangularMeasurements("area")}_toggleTriangularDistanceMeasurements(){this._toggleTriangularMeasurements("distance")}_toggleTriangularLocation(){const e=this.triangularMeasurementActive,t=this.navigationToolActive;e?null===this.measureType?this.imageLocationToolActive?this._closeImageToolsAndToggleNavigation(e,t):this._activateTriangulatedImageLocationTool():this._resetMeasureTypeAndActivateImageLocationTool():this._activateTriangulatedImageLocationWorkflow(e,t)}_toggleTriangularMeasurements(e){const t=this.triangularMeasurementActive,i=this.viewModel.measureType,a=this.navigationToolActive;t?e===i?(this._closeAllImageTools(),this.triangularMeasurementActive=!t,this.navigationToolActive=!a):(this.imageLocationToolActive=!1,this.measureType=e):(this._closeAllImageTools(),this.measureType=e,this.triangularMeasurementActive=!t,this.navigationToolActive=!!a||!a)}_unregisterGalleryItem(e){this._galleryObserver.unobserve(e)}_updateNavigationTool(e){const{previousFeatureAngle:t,bestFeatureAngle:i}=this.viewModel,a=(i-t+540)%360-180;e.style.setProperty(k,`${t}deg`),e.style.setProperty(S,`${t+a}deg`)}async loadBestImage(e){return this.viewModel.loadBestImage(e)}loadImageFromSource(e,t){return this.viewModel.loadImageFromSource(e,t)}async overlayMapFeatures(e,t){return this.removeHandles(`${te.overlayed}-${e.id}`),this.addHandles(l(()=>e.visible,()=>{this.viewModel.toggleOverlayMapFeatures(e.id,e.visible,this.showMapFeatures)}),`${te.overlayed}-${e.id}`),this._overlayedLayers.add(e),this.viewModel.overlayMapFeatures(e,t&&this.showMapFeatures)}async plotMapPoint(e){return this.viewModel.plotMapPoint(e)}plotReferencePointOnGround(e){this.viewModel.plotReferencePointOnGround(e)}plotReferencePointOnImage(e){this.viewModel.plotReferencePointOnImage(e)}removeOverlayedGraphicsOnImage(e){this.removeHandles(`${te.overlayed}-${e}`),this._overlayedLayers.remove(this._overlayedLayers.find(t=>t.id===e)),this.viewModel.removeOverlayedGraphicsOnImage(e)}resetImage(){this.viewModel.resetImage()}render(){return ee("div",{class:this.classes(Q.widget,O)},this._renderRoot)}async showImageByObjectId(e,t){return this.viewModel.showImageByObjectId(e,t)}async startDataCapture(e){return this.viewModel.startDataCapture(e)}async stopDataCapture(e){return this.viewModel.stopDataCapture(e)}updateSuitabilities(e){this.viewModel.updateSuitabilities(e)}};e([h({readOnly:!0})],ie.prototype,"accuracyParametersMissing",null),e([h()],ie.prototype,"activeLayer",null),e([h()],ie.prototype,"activeVideoIcon",null),e([h()],ie.prototype,"activeAudioIcon",null),e([h()],ie.prototype,"cameraHeadingThreshold",null),e([h()],ie.prototype,"cameraPitchThreshold",null),e([h()],ie.prototype,"canNavigateSequentially",null),e([h()],ie.prototype,"currentBestFeature",null),e([h()],ie.prototype,"currentCoverageVisible",null),e([h()],ie.prototype,"dataCaptureEnabled",void 0),e([h()],ie.prototype,"dataCaptureLayer",null),e([h()],ie.prototype,"depthImageNotSupported",null),e([h()],ie.prototype,"disabled",null),e([h()],ie.prototype,"enhancementToolActive",null),e([h()],ie.prototype,"features",null),e([h()],ie.prototype,"imagePointsInView",null),e([h()],ie.prototype,"galleryOpened",void 0),e([h()],ie.prototype,"icon",null),e([h()],ie.prototype,"imageEnhancementToolActive",void 0),e([h()],ie.prototype,"videoEnhancementToolActive",void 0),e([h({readOnly:!0})],ie.prototype,"imageGalleryEnabled",null),e([h()],ie.prototype,"imageLocationToolActive",null),e([h()],ie.prototype,"imageOverlaysOpened",void 0),e([h({readOnly:!0})],ie.prototype,"invalidCameraHeading",null),e([h()],ie.prototype,"isAdditionalCoverageVisible",null),e([h()],ie.prototype,"isAdditionalPointSourcesVisible",null),e([h()],ie.prototype,"mapImageConversionToolState",null),e([h()],ie.prototype,"measureType",null),e([h()],ie.prototype,"layer",null),e([h()],ie.prototype,"navigationToolActive",void 0),e([h()],ie.prototype,"navigationMode",null),e([X(M()),h({type:H})],ie.prototype,"viewModel",void 0),e([h(),Y("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],ie.prototype,"messages",void 0),e([h(),Y("esri/core/t9n/Units")],ie.prototype,"measurementUnitMessages",void 0),e([h(),Y("esri/t9n/common")],ie.prototype,"messagesCommon",void 0),e([h(),Y("esri/widgets/Sketch/t9n/Sketch")],ie.prototype,"messagesSketch",void 0),e([h()],ie.prototype,"pixelMeasurementUnit",void 0),e([h()],ie.prototype,"pixelAreaMeasurementUnit",void 0),e([h({readOnly:!0})],ie.prototype,"popupEnabled",null),e([h()],ie.prototype,"referencePoint",null),e([h()],ie.prototype,"showCameraLocations",void 0),e([h()],ie.prototype,"showMapFeatures",void 0),e([X(["create","delete","redo","undo","update"]),h({readOnly:!0})],ie.prototype,"sketchViewModel",null),e([h()],ie.prototype,"triangularMeasurementActive",null),e([h()],ie.prototype,"videoLoaded",null),e([h()],ie.prototype,"view",null),e([h({type:j,nonNullable:!0})],ie.prototype,"visibleElements",void 0),e([h()],ie.prototype,"determineWorkflowForFeature",null),e([h()],ie.prototype,"updateFootprint",null),e([h()],ie.prototype,"_activeMeasurementIcon",null),e([h()],ie.prototype,"_activeMeasurementHeading",null),e([h()],ie.prototype,"_imageOverlaysLoaderTask",void 0),e([h()],ie.prototype,"_imageMeasurementToolsLoaderTask",void 0),e([h()],ie.prototype,"_navigationSettingsLoaderTask",void 0),e([h()],ie.prototype,"_measurementToggle",null),e([h()],ie.prototype,"_renderRoot",null),e([h()],ie.prototype,"_imageEnhancementTools",null),e([h()],ie.prototype,"_videoEnhancementTools",null),e([h()],ie.prototype,"_imageGalleryPanel",null),e([h()],ie.prototype,"_imageGalleryContext",null),e([h()],ie.prototype,"_imageOverlaysComponent",null),e([h()],ie.prototype,"_imageOverlayMessages",null),e([h()],ie.prototype,"_imageSketchToolsMessages",null),e([h()],ie.prototype,"_imageViewer",null),e([h()],ie.prototype,"_imageViewerTriangular",null),e([h()],ie.prototype,"_videoViewer",null),e([h()],ie.prototype,"_locationToggle",null),e([h()],ie.prototype,"_messageBox",null),e([h()],ie.prototype,"_navigationToolExpanded",void 0),e([h()],ie.prototype,"_navigationTool",void 0),e([h()],ie.prototype,"_panoramicVideoViewer",null),e([h()],ie.prototype,"_panoramicViewer",null),e([h()],ie.prototype,"_renderNavigation",null),e([h()],ie.prototype,"_renderThumbnails",null),e([h()],ie.prototype,"_sketchLoaderTask",void 0),ie=e([m("esri.widgets.OrientedImageryViewer")],ie);const ae=ie;export{ae as default};
5
+ import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{prefersReducedMotion as i}from"../core/a11yUtils.js";import{createTask as a}from"../core/asyncUtils.js";import o from"../core/Collection.js";import{deprecatedProperty as s}from"../core/deprecate.js";import n from"../core/Logger.js";import{isAbortError as r}from"../core/promiseUtils.js";import{watch as l,initial as d,syncAndInitial as c,whenOnce as g}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{or as u}from"../layers/orientedImagery/transformations/utils.js";import v from"./Expand.js";import p from"./PanoramicVideoViewer.js";import y from"./PanoramicViewer.js";import w from"./Widget.js";import{getAllArcPath as _}from"./OrientedImageryViewer/arcUtils.js";import{getDelegatedEvents as M,defaultImageGeometryField as T,defaultOIObjectIDField as b,segmentArcs as C,featureCircleRadius as A,navigationToolDimensionLength as I,sectorsRadii as f}from"./OrientedImageryViewer/constants.js";import{css as L,navigation as V,navigationToolRotationFrom as k,navigationToolRotationTo as S,root as O}from"./OrientedImageryViewer/css.js";import{loadImageForAttachment as F,getThumbnailPixelBlock as E,isFeatureAttachment as P,renderImageWithRotation as x}from"./OrientedImageryViewer/galleryUtils.js";import H from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import j from"./OrientedImageryViewer/OrientedImageryViewerVisibleElements.js";import{loadAlertComponents as N,Alert as G}from"./OrientedImageryViewer/components/Alert.js";import D from"./OrientedImageryViewer/components/ImageLocationWidget.js";import $ from"./OrientedImageryViewer/components/ImageViewer.js";import B from"./OrientedImageryViewer/components/NavigationAction.js";import{loadNavigationActionsComponents as R,NavigationActionsCollection as W,NavigationActions as U}from"./OrientedImageryViewer/components/NavigationActions.js";import{loadVideoEnhancementComponents as z,renderEnhancementSlider as q,VideoEnhancementTools as Z}from"./OrientedImageryViewer/components/VideoEnhancementTools.js";import{NoImageLoadedError as J}from"./OrientedImageryViewer/navigation/errors.js";import{loadCalciteComponents as K}from"./support/componentsUtils.js";import{globalCss as Q}from"./support/globalCss.js";import{vmEvent as X,messageBundle as Y,tsx as ee}from"./support/widget.js";const te={overlayed:"overlayed"};let ie=class extends w{constructor(e,t){super(e,t),this.dataCaptureEnabled=!1,this.galleryOpened=!1,this.imageEnhancementToolActive=!1,this.videoEnhancementToolActive=!1,this.imageOverlaysOpened=!1,this.navigationToolActive=!1,this.viewModel=new H,this.messagesCommon=null,this.messagesSketch=null,this.pixelMeasurementUnit="meters",this.pixelAreaMeasurementUnit="square-meters",this.showCameraLocations=!1,this.showMapFeatures=!1,this.visibleElements=new j,this._imageOverlaysLoaderTask=null,this._imageMeasurementToolsLoaderTask=null,this._navigationSettingsLoaderTask=null,this._clearMeasurements=()=>{this.viewModel.measureType=null,this.viewModel.triangularMeasurementActive=!1,this.viewModel.clearPreviousMeasurements()},this._clearImageLocation=()=>{this.imageLocationToolActive=!1,this.triangularMeasurementActive=!1},this._navigationToolExpanded=!1,this._navigationTool=null,this._galleryController=new AbortController,this._galleryObserver=new IntersectionObserver(this._lazyLoadImage.bind(this)),this._overlayedLayers=new o,this._previousAction=null,this._handleDataCaptureLayerChange=async e=>{if(this.dataCaptureLayer&&await this.stopDataCapture(!0),this.dataCaptureLayer=this.dataCaptureLayer===e?null:e,this.dataCaptureLayer)return this.startDataCapture(this.dataCaptureLayer)},this._handleNavigationSettingsInputChange=(e,t)=>{this.set(`${e}Threshold`,t)},this._handleNavigationSettingsToggle=e=>{this.viewModel.preserveAngle=e},this._handleOverlayLayerDeselect=e=>{const t=e.layer;t===this.dataCaptureLayer&&(this.stopDataCapture(),this.dataCaptureLayer=null),this.removeOverlayedGraphicsOnImage(`${t.id}`)},this._handleOverlayLayerSelect=e=>{const t=e.layer;this.viewModel.overlayMapFeatures(t,this.showMapFeatures),this.addHandles(l(()=>t.visible,()=>{this.viewModel.toggleOverlayMapFeatures(t.id,t.visible,this.showMapFeatures)}),`${te.overlayed}-${t.id}`)},this._highlight=e=>{const t=e.target?.dataset.objectid;t&&this.viewModel.highlight(t)},this._onAction=e=>{const{target:t}=e,{dataset:{action:i}}=t,{_previousAction:a}=this,o=a?.dataset.action,s=o?.includes("draw")??!1,n="select-feature"===o,r=o!==i;switch(i){case"draw-point":case"draw-polygon":case"draw-polyline":{a&&u(n,s&&r)&&(a.active=!1),t.active=!t.active;const e=i.replace("draw-","");this.viewModel.digitizeCreate(e),this._previousAction=t.active?t:null;break}case"save":this.viewModel.saveDrawing();break;case"select-feature":s&&(this._previousAction.active=!1),t.active=!t.active,this.viewModel.toggleSelection(t.active),this._previousAction=t.active?t:null;break;case"delete-feature":this.viewModel.digitizeDelete()}},this._onImageOverlayClosed=()=>{this.imageOverlaysOpened=!1},this._onShowCameraLocationsChanged=e=>{this.showCameraLocations=e},this._onShowMapFeaturesChanged=e=>{this.showMapFeatures=e},this._removeHighlight=()=>this.viewModel.removeHighlight(),this._restoreOverlays=async()=>Promise.all(this._overlayedLayers.map(e=>this.viewModel.overlayMapFeatures(e,this.showMapFeatures))),this._scaleNavigationTool=()=>{this._navigationToolExpanded=!this._navigationToolExpanded},this._sketchLoaderTask=null,this._settingsToggle=null,this._toggleImageNavigation=async e=>{const t=this.navigationMode;this._closeAllImageTools(),this.navigationMode=t!==e?e:null;const{activeViewer:i}=this.viewModel;if(!i)return;const{mode:a,preserveAngle:o}=this.viewModel;if("default"===a)if("directional"===this.navigationMode){const e=await this._loadNavigationSettings(),t="heading"===o||"both"===o,i="pitch"===o||"both"===o,{messages:a,messagesCommon:s}=this,n=new e({cameraHeadingThreshold:this.cameraHeadingThreshold,cameraPitchThreshold:this.cameraPitchThreshold,uiStrings:{configureNavigation:a.configureNavigation,preserveHeading:a.preserveHeading,preserveHeadingDescription:a.preserveHeadingDescription,preservePitch:a.preservePitch,preservePitchDescription:a.preservePitchDescription,settings:s.settings,thresholdLabel:a.thresholdLabel},onInputChange:this._handleNavigationSettingsInputChange,onToggle:this._handleNavigationSettingsToggle,preserveHeading:t,preservePitch:i});this._settingsToggle=new v({content:n,expandIcon:"configure"}),this.viewModel.activeViewer?.ui.add(this._settingsToggle,{position:"top-left"})}else this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))},this._toggleImageAttributes=()=>{this.viewModel.toggleImageAttributes()},this.navigate=async e=>{let t=null;try{const{currentNode:i}=this.viewModel;if(!i)throw new J;t=await this.viewModel.navigate(i,e)}catch(i){r(i)||n.getLogger(this).error("Error occurred while navigating",i)}return t},this.reset=()=>{this._closeAllImageTools(),this.viewModel.reset()},this._loadImageFromGallery=this._loadImageFromGallery.bind(this),this._registerGalleryItem=this._registerGalleryItem.bind(this),this._unregisterGalleryItem=this._unregisterGalleryItem.bind(this),this.loadImageFromSource=this.loadImageFromSource.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this._handleVideoBrightnessChange=this._handleVideoBrightnessChange.bind(this),this._handleVideoContrastChange=this._handleVideoContrastChange.bind(this),this._handleBrightnessChange=this._handleBrightnessChange.bind(this),this._handleContrastChange=this._handleContrastChange.bind(this),this._handleSharpnessChange=this._handleSharpnessChange.bind(this),this._resetVideoTools=this._resetVideoTools.bind(this),this._toggleEnhancementToolState=this._toggleEnhancementToolState.bind(this)}initialize(){this.addHandles([l(()=>[this.viewModel?.bestFeatureAngle,this._navigationTool],([e,t])=>{t&&this._updateNavigationTool(t)},d),l(()=>this.currentCoverageVisible,e=>this._onCurrentCoverageVisibilityChange(e)),l(()=>this.isAdditionalCoverageVisible,e=>this._onAdditionalCoverageVisibilityChange(e)),l(()=>this.isAdditionalPointSourcesVisible,e=>this._onAdditionalCameraLocationsVisibility(e)),l(()=>({features:this.currentBestFeature,showCameraLocations:this.showCameraLocations,state:this.viewModel.state}),({showCameraLocations:e,state:t})=>{"image-loaded"===t&&this.viewModel.overlayCameraLocations(e)},c),l(()=>({feature:this.currentBestFeature,showMapFeatures:this.showMapFeatures,state:this.viewModel.state}),async(e,t)=>{if(e.showMapFeatures!==t?.showMapFeatures&&this.viewModel.toggleAllOverlayMapFeatures(e.showMapFeatures),null!=e.feature&&e.feature!==t?.feature){if(this.viewModel.removeAllOverlayMapFeatures(),await g(()=>"image-loaded"===this.viewModel.state),this.dataCaptureLayer&&this.stopDataCapture(),await this._restoreOverlays(),!this.dataCaptureLayer)return;await this.startDataCapture(this.dataCaptureLayer),this._previousAction?.active&&(this._previousAction.active=!1,this._previousAction=null)}},d)])}loadDependencies(){return Promise.all([R(),z(),K({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),shell:()=>import("@esri/calcite-components/dist/components/calcite-shell"),dialog:()=>import("@esri/calcite-components/dist/components/calcite-dialog"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider")}),N()])}destroy(){this._galleryController.abort(),this._galleryObserver.disconnect(),this.currentBestFeature=null}get accuracyParametersMissing(){return this.viewModel.accuracyParametersMissing}get activeLayer(){return s(n.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){s(n.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeVideoIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?t.videoPaused?"play":"pause":"play"}get activeAudioIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?.videoMuted?"sound-off":"sound"}get cameraHeadingThreshold(){return this.viewModel.cameraHeadingThreshold}set cameraHeadingThreshold(e){this.viewModel.cameraHeadingThreshold=e}get cameraPitchThreshold(){return this.viewModel.cameraPitchThreshold}set cameraPitchThreshold(e){this.viewModel.cameraPitchThreshold=e}get canNavigateSequentially(){const{layer:e}=this;if(!e)return!1;const{fields:t,sequenceOrderField:i}=e;return t.some(({name:e})=>e.toLowerCase()===`${i??"sequenceorder"}`.toLowerCase())}get currentBestFeature(){return this.viewModel.currentBestFeature}set currentBestFeature(e){this.viewModel.currentBestFeature=e}get currentCoverageVisible(){return this.viewModel.currentCoverageVisible}set currentCoverageVisible(e){this.viewModel.currentCoverageVisible=e}get dataCaptureLayer(){return this.viewModel.dataCaptureLayer}set dataCaptureLayer(e){this.viewModel.dataCaptureLayer=e}get depthImageNotSupported(){return this.viewModel.depthImageNotSupported}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get displayMessage(){return this.viewModel.displayMessage}get enhancementToolActive(){return"video"===this.viewModel.mode?this.videoEnhancementToolActive:this.imageEnhancementToolActive}set enhancementToolActive(e){"video"===this.viewModel.mode?this.videoEnhancementToolActive=e:this.imageEnhancementToolActive=e}get features(){return this.viewModel.features}get imagePointsInView(){return this.viewModel.imagePointsInView}get icon(){return"oriented-imagery-widget"}set icon(e){this._overrideIfSome("icon",e)}get imageGalleryEnabled(){return this.viewModel.imageGalleryEnabled}get imageLocationToolActive(){return this.viewModel.imageLocationToolState}set imageLocationToolActive(e){this.viewModel.imageLocationToolState=e}get invalidCameraHeading(){return this.viewModel.invalidCameraHeading}get isAdditionalCoverageVisible(){return this.viewModel.isAdditionalCoverageVisible}set isAdditionalCoverageVisible(e){this.viewModel.isAdditionalCoverageVisible=e}get isAdditionalPointSourcesVisible(){return this.viewModel.isAdditionalPointSourcesVisible}set isAdditionalPointSourcesVisible(e){this.viewModel.isAdditionalPointSourcesVisible=e}get mapImageConversionToolState(){return this.viewModel.mapImageConversionToolState}set mapImageConversionToolState(e){this.viewModel.mapImageConversionToolState=e}get measureType(){return this.viewModel.measureType}set measureType(e){this.viewModel.measureType=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get navigationMode(){return this.viewModel.navigationMode}set navigationMode(e){this.viewModel.navigationMode=e}get popupEnabled(){const{popupEnabled:e,state:t}=this.viewModel;return("image-loaded"===t||this.videoLoaded)&&e}get referencePoint(){return this.viewModel.referencePoint??null}get sketchViewModel(){return this.viewModel.sketch}get triangularMeasurementActive(){return this.viewModel.triangularMeasurementActive}set triangularMeasurementActive(e){this.viewModel.triangularMeasurementActive=e}get videoLoaded(){const{mode:e,videoElement:t,panoramicVideoLoaded:i}=this.viewModel;return("video"===e&&!0===t?.loaded||i)??!1}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set determineWorkflowForFeature(e){this.viewModel.determineWorkflowForFeature=e}get determineWorkflowForFeature(){return this.viewModel.determineWorkflowForFeature}set updateFootprint(e){this.viewModel.updateFootprint=e}get updateFootprint(){return this.viewModel.updateFootprint}_renderActionBar(){return ee("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},ee("calcite-action-group",null,this._currentFootprintToggle(),this._additionalFootprintToggle(),this._additionalPointSourcesToggle()),ee("calcite-action-group",null,this._directionToolToggle(),this._mapImageConversionToggle(),this._navigationToolToggle(),this._imageEnhancementsToggle(),this._videoEnhancementsToggle()),ee("calcite-action-group",null,this._measurementToolsToggle(),this._imageGalleryToggle(),this._imageOverlaysToggle(),this._openPopupAction()))}get _activeMeasurementIcon(){const{measureType:e,imageLocationToolActive:t,triangularMeasurementActive:i}=this;if(t)return i?"dual-image-location":"pin-tear";if(i)return"area"===e?"dual-image-area":"dual-image-distance";switch(e){case"area":return"measure-area";case"height":return"measure-building-height-top-base";default:return"measure-line"}}get _activeMeasurementHeading(){const{measureType:e,messages:t,triangularMeasurementActive:i}=this,{groundArea:a,heightAboveGround:o,groundDistance:s,triangulatedAreaHeading:n,triangulatedDistanceHeading:r}=t;if(i)return"area"===e?n:r;switch(e){case"area":return a;case"height":return o;default:return s}}_additionalFootprintToggle(){const{isAdditionalCoverageVisible:e,invalidCameraHeading:t,visibleElements:{additionalFootprintToggle:i}}=this;return i?ee("calcite-action",{active:e,bind:this,class:L.addCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleAdditionalCoverage,text:this.messages.additionalFootprints,title:this.messages.additionalFootprints}):null}_additionalPointSourcesToggle(){const{isAdditionalPointSourcesVisible:e,invalidCameraHeading:t,visibleElements:{additionalCameraLocationsToggle:i}}=this;return i?ee("calcite-action",{active:e,bind:this,class:L.addExpPoints,disabled:t,icon:"circle-area",onclick:this._toggleAdditionalCameraLocations,text:this.messages.additionalCameraLocations,title:this.messages.additionalCameraLocations}):null}get _measurementToggle(){const{viewModel:{state:e,measureType:t,currentBestFeatureMeasurementImage:i},triangularMeasurementActive:a,id:o}=this;if("image-loaded"!==e||!t||a&&!i)return;this._imageMeasurementToolsLoaderTask||this._loadImageMeasurementResources();const s=this._imageMeasurementToolsLoaderTask?.value;return s?ee("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:this._activeMeasurementHeading,id:`${o}-${t}-measurement`,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearMeasurements},ee(s,{measurementType:t,measurementUnitMessages:this.measurementUnitMessages,messages:this.messages,oiViewModel:this.viewModel})):null}get _renderRoot(){const{viewModel:{state:e},triangularMeasurementActive:t}=this;return ee("calcite-panel",{bind:this,class:t?L.viewerContainerMeasurement:L.viewerContainer,heading:this.visibleElements.title?this.messages.title:void 0,loading:e.includes("loading")&&!t},this.visibleElements.menu?this._renderActionBar():null,ee("calcite-shell",null,ee("calcite-panel",null,this._imageViewer,this._panoramicViewer,this._panoramicVideoViewer,this._videoViewer,this._messageBox,this.invalidCameraHeading?null:[this._imageGalleryPanel,this._renderNavigation,this._imageOverlaysPanel()],this._imageEnhancementTools,this._videoEnhancementTools,this._renderSketch()),this._imageViewerTriangular,this._measurementToggle,this._locationToggle,this.invalidCameraHeading?this._renderWarning(this.messages.invalidCameraHeadingWarningTitle,this.messages.invalidCameraHeadingWarningDescription):null,this.depthImageNotSupported?this._renderWarning(this.messages.depthImageNotSupportedTitle,this.messages.depthImageNotSupportedDescription):null))}_currentFootprintToggle(){const{currentCoverageVisible:e,invalidCameraHeading:t}=this,{currentFootprintToggle:i}=this.visibleElements;return i?ee("calcite-action",{active:e,bind:this,class:L.currentCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleCurrentCoverage,text:this.messages.currentFootprint,title:this.messages.currentFootprint}):null}get _imageEnhancementTools(){const{enhancementToolActive:e,viewModel:{brightness:t,contrast:i,sharpness:a,state:o}}=this;return e&&"image-loaded"===o?ee("calcite-panel",{bind:this,class:L.imageEnhancementWrapper,closable:!0,closed:!e,heading:this.messages.imageEnhancement,key:this.messages.imageEnhancement,onCalcitePanelClose:this._toggleEnhancementToolState},ee("div",{class:L.imageEnhancementTools},q({title:this.messages.brightness,value:t,max:10,min:-10,ticks:5,handleChange:this._handleBrightnessChange}),q({title:this.messages.contrast,value:i,max:10,min:-10,ticks:5,handleChange:this._handleContrastChange}),q({title:this.messages.sharpness,value:a,max:1,min:0,ticks:.5,step:.1,handleChange:this._handleSharpnessChange})),ee("calcite-action",{bind:this,icon:"reset",onclick:this._resetImageTools,slot:"header-actions-end",text:this.messagesCommon.reset,title:this.messagesCommon.reset})):null}get _videoEnhancementTools(){const{enhancementToolActive:e,viewModel:{videoViewModel:t,mode:i},messages:{videoEnhancement:a,brightness:o,contrast:s},messagesCommon:{reset:n}}=this;return e&&"video"===i&&t?ee(Z,{brightness:t.videoBrightness,constrast:t.videoContrast,handleBrightnessChange:this._handleVideoBrightnessChange,handleContrastChange:this._handleVideoContrastChange,resetTools:this._resetVideoTools,uiStrings:{videoEnhancement:a,brightness:o,contrast:s,reset:n},videoEnhancementToolActive:e,onClose:this._toggleEnhancementToolState}):null}_imageEnhancementsToggle(){const{state:e,mode:t}=this.viewModel,{imageEnhancement:i}=this.visibleElements;return i&&"video"!==t?ee("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"default"!==t||"image-loaded"!==e,icon:"sliders-horizontal",onclick:this._toggleEnhancementToolState,text:this.messages.imageEnhancement,title:this.messages.imageEnhancement}):null}_videoEnhancementsToggle(){const{mode:e}=this.viewModel,{videoEnhancement:t}=this.messages;return"video"===e?ee("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"video"!==e,icon:"sliders-horizontal",onclick:this._toggleEnhancementToolState,text:t,title:t}):null}get _imageGalleryPanel(){const{container:e,galleryOpened:t,imageGalleryEnabled:i}=this;return i&&t&&e?this._imageGalleryContext:null}get _imageGalleryContext(){const{galleryOpened:e,invalidCameraHeading:t}=this;return ee("calcite-panel",{bind:this,class:L.carousel,closable:!0,closed:!e,disabled:t,heading:this.messages.imageGallery,key:this.messages.imageGallery,onCalcitePanelClose:this._toggleImageGallery},ee("div",{class:L.carouselContainer},this._renderThumbnails))}_imageGalleryToggle(){const{imageGalleryEnabled:e,invalidCameraHeading:t,visibleElements:{imageGallery:i}}=this;return i?ee("calcite-action",{active:this.galleryOpened,bind:this,disabled:!e||t,icon:"images",onclick:this._toggleImageGallery,text:this.messages.imageGallery,title:this.messages.imageGallery}):null}get _imageOverlaysComponent(){const{_imageOverlayMessages:e,_imageOverlaysLoaderTask:t,_overlayedLayers:i,dataCaptureEnabled:o,dataCaptureLayer:s,imageOverlaysOpened:n,showCameraLocations:r,showMapFeatures:l,view:d,layer:c}=this;if(!c)return null;const g=c.imageGeometryField?.length?c.imageGeometryField:T,h=c.imageReferenceField?.length?c.imageReferenceField:b;t||(this._imageOverlaysLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/ImageOverlays.js")).default));const m=this._imageOverlaysLoaderTask?.value;return m?ee(m,{closed:!n,dataCaptureEnabled:o,dataCaptureLayer:s,imageGeometryField:g,imageReferenceField:h,messages:e,overlayedLayers:i,showCameraLocations:r,showMapFeatures:l,view:d,onDataCaptureLayerChanged:this._handleDataCaptureLayerChange,onFilterCapturedFeatures:this.viewModel.filterCapturedFeatures,onImageOverlaysClosed:this._onImageOverlayClosed,onLayerDeselected:this._handleOverlayLayerDeselect,onLayerSelected:this._handleOverlayLayerSelect,onShowCameraLocationsChanged:this._onShowCameraLocationsChanged,onShowMapFeaturesChanged:this._onShowMapFeaturesChanged}):null}get _imageOverlayMessages(){return{...this.messages,...this.messagesSketch}}get _imageSketchToolsMessages(){return{...this.messagesSketch,...this.messagesCommon}}_imageOverlaysPanel(){const{imageOverlaysOpened:e,viewModel:{state:t}}=this,i=this.classes({[L.imageOverlaysContainer]:!0,[Q.hidden]:!e||"image-loaded"!==t});return ee("div",{class:i,key:this.messages.imageOverlays},this._imageOverlaysComponent)}_imageOverlaysToggle(){const{viewModel:{state:e},imageOverlaysOpened:t,invalidCameraHeading:i,visibleElements:{imageOverlays:a}}=this;return a?ee("calcite-action",{active:t,bind:this,disabled:"image-loaded"!==e||i,icon:"layers",onclick:this._toggleImageOverlays,text:this.messages.imageOverlays,title:this.messages.imageOverlays}):null}get _imageViewer(){const{displayMessage:e,loadImageViewer:t,mode:i,clickAction:a,state:o}=this.viewModel,s=null!=e||"default"!==i||o.includes("loading"),{messages:{end:n,next:r,previous:l,start:d}}=this;return ee($,{afterCreate:t,clickAction:a,navigationEnabled:!s&&null!==this.navigationMode,navigationViewModel:this.viewModel,uiStrings:{end:n,next:r,previous:l,start:d},visible:!s})}get _imageViewerTriangular(){const{messages:e,triangularMeasurementActive:t}=this,{displayMessage:i,storeImageMeasurementViewer:a,storePanoramicMeasurementViewer:o,mode:s,state:n,clickAction:r}=this.viewModel,l=null!=i||"none"===s||"video"===s,d=this.classes({[L.viewer]:!l,[L.viewerHidden]:l});return t?ee("calcite-panel",{class:L.viewerContainerMeasurement,heading:e.measurementViewerHeading,loading:n.includes("loading")},ee("calcite-panel",{bind:this,class:d},"default"===s?ee($,{afterCreate:a,clickAction:r,uiStrings:e}):ee(y,{afterCreate:o,clickAction:r,uiStrings:e}))):null}get _videoViewer(){const{mode:e,loadVideoViewer:t,videoViewModel:i}=this.viewModel,{control:a,reset:o}=this.messagesCommon,{mute:s,unmute:n}=this.messages,r="video"!==e,l=this.classes({[L.viewer]:!r,[L.viewerHidden]:r}),d="esri-image-viewer";return ee("calcite-panel",{bind:this,class:l},ee("calcite-panel",{afterCreate:t,class:this.classes(Q.widget,d)}),ee("calcite-slider",{bind:this,labelHandles:!0,labelTicks:!0,max:i?.videoDuration,minLabel:"0",value:i?.currentTime??0,onCalciteSliderChange:this._handleVideoSeek}),ee("calcite-action-bar",{expandDisabled:!0,layout:"horizontal"},ee("calcite-action-group",null,ee("calcite-action",{bind:this,icon:this.activeVideoIcon,onclick:()=>i?.playVideoHandler(),text:"Play",title:i?.videoPaused?a.play:a.pause})),ee("calcite-action-group",null,ee("calcite-action",{bind:this,icon:"refresh",onclick:()=>i?.rewindVideoHandler(),text:"Rewind",title:o})),ee("calcite-action-group",null,ee("calcite-action",{bind:this,icon:this.activeAudioIcon,onclick:()=>i?.toggleAudio(),text:"Audio",title:i?.videoMuted?s:n}))))}get _locationToggle(){const{viewModel:{state:e,groundCoordinates:t,groundCoordinatesAccuracy:i,triangulatedPoint:a},imageLocationToolActive:o,triangularMeasurementActive:s,messages:{groundLocation:n,triangulatedLocationHeading:r}}=this;if("image-loaded"!==e||!t||!o)return;let l=t;if(s){if(!a)return;l=a}return ee("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:s?r:n,id:n,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearImageLocation},ee(D,{accuracy:i,groundCoordinates:l,messages:this.messages}))}_mapImageConversionToggle(){const{mapImageConversionToolState:e,viewModel:{state:t,disabled:i},invalidCameraHeading:a,visibleElements:{mapImageConversionTool:o}}=this;return o?ee("calcite-action",{active:e,bind:this,disabled:"image-loaded"!==t||a||i,icon:"image-pin",onclick:this._toggleMapImageConversionToolState,text:this.messages.mapImageConversionTool,title:this.messages.mapImageConversionTool}):null}_measurementToolsToggle(){const{_activeMeasurementIcon:e,measureType:t,viewModel:i,accuracyParametersMissing:a,messages:o,triangularMeasurementActive:s,visibleElements:{measurementTools:n}}=this,{state:r}=i,{measurementTools:l,groundDistance:d,groundArea:c,heightAboveGround:g,groundLocation:h,triangulatedDistanceHeading:m,triangulatedAreaHeading:u,triangulatedLocationHeading:v}=o;return n?ee("calcite-dropdown",{disabled:a,key:"measurement-tools",maxItems:5,title:l,width:"m"},ee("calcite-action",{bind:this,disabled:"image-loaded"!==r||a,icon:e,slot:"trigger",text:l}),ee("calcite-dropdown-group",null,ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-line",key:"distance-measurement",onclick:e=>this._toggleMeasurementSketch(e,"distance"),selected:"distance"===t&&!s},d),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-area",key:"area-measurement",onclick:e=>this._toggleMeasurementSketch(e,"area"),selected:"area"===t&&!s},c),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-building-height-top-base",key:"height-dropdown",onclick:e=>this._toggleMeasurementSketch(e,"height"),selected:"height"===t},g),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"pin-tear",key:"surface-location",onclick:this._toggleLocationTool,selected:!!this.imageLocationToolActive&&!s},h),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"dual-image-location",key:"triangular-location",selected:!!s&&this.imageLocationToolActive,onCalciteDropdownItemSelect:this._toggleTriangularLocation},v),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"dual-image-distance",key:"triangular-measurement-distance",selected:!!s&&"distance"===this.measureType,onCalciteDropdownItemSelect:this._toggleTriangularDistanceMeasurements},m),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"dual-image-area",key:"triangular-measurement-area",selected:!!s&&"area"===this.measureType,onCalciteDropdownItemSelect:this._toggleTriangularAreaMeasurements},u))):null}get _messageBox(){const{messages:e,viewModel:{displayMessage:i,mode:a}}=this;if(!i||"video"===a)return null;const{data:o,key:s,map:n}=i,r=`${n?t(e[s],n):e[s]}`;return ee("span",{class:L.messageBox},o?`${r} ${o}`:r)}async _loadNavigationSettings(){return this._navigationSettingsLoaderTask||(this._navigationSettingsLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/NavigationSettings.js")).default)),await this._navigationSettingsLoaderTask.promise}_navigationToolToggle(){const{state:e}=this.viewModel,{visibleElements:{navigationTool:t},videoLoaded:i}=this;return t?ee("calcite-action",{active:this.navigationToolActive,bind:this,disabled:"image-loaded"!==e&&!i||this.invalidCameraHeading,icon:"explore",onclick:this._toggleNavigationTool,text:this.messages.navigationTool,title:this.messages.navigationTool}):null}_directionToolToggle(){const{state:e}=this.viewModel,{visibleElements:{directionalNavigation:t,sequentialNavigation:i}}=this,a=new W;t&&a.push(new B({active:"directional"===this.navigationMode,disabled:"image-loaded"!==e||this.invalidCameraHeading,icon:"directional-navigation",onclick:()=>{this._toggleImageNavigation("directional")},text:this.messages.directionalNavigation,title:this.messages.directionalNavigationDescription})),i&&a.push(new B({active:"sequential"===this.navigationMode,disabled:"image-loaded"!==e||this.invalidCameraHeading||!this.canNavigateSequentially,icon:"sequential-navigation",onclick:()=>{this._toggleImageNavigation("sequential")},text:this.messages.sequentialNavigation,title:this.messages.sequentialNavigationDescription}));return t||i?ee(U,{actions:a,activeAction:a.items.find(e=>e.active),icon:"absolute-direction",label:this.messages.imageNavigation,scale:"m",title:this.messages.imageNavigation}):null}_openPopupAction(){const{showPopupsAction:e}=this.visibleElements;return e?ee("calcite-action",{bind:this,disabled:!this.popupEnabled,icon:"popup",onclick:this._toggleImageAttributes,text:this.messages.showPopups,title:this.messages.showPopups}):null}get _panoramicVideoViewer(){const{displayMessage:e,loadPanoramicVideoViewer:t,mode:i,clickAction:a,state:o,currentBestFeature:s}=this.viewModel,n=s?.attributes.imagePath,r=null!=e||"panoramic-video"!==i||o.includes("loading")||!n;return ee(p,{afterCreate:t,clickAction:a,oiViewModel:this.viewModel,videoSource:n,visible:!r})}get _panoramicViewer(){const{displayMessage:e,loadPanoramicViewer:t,mode:i,clickAction:a,state:o}=this.viewModel,{messages:{end:s,next:n,previous:r,start:l}}=this,d=null!=e||"panoramic"!==i||o.includes("loading");return ee(y,{afterCreate:t,clickAction:a,navigationEnabled:!d&&null!==this.navigationMode,navigationViewModel:this.viewModel,uiStrings:{end:s,next:n,previous:r,start:l},visible:!d})}_activateTriangulatedImageLocationTool(){this.navigationToolActive=!0,this.imageLocationToolActive=!0}_activateTriangulatedImageLocationWorkflow(e,t){this._closeAllImageTools(),this.imageLocationToolActive=!0,this.triangularMeasurementActive=!e,this.navigationToolActive=!!t||!t}_closeImageToolsAndToggleNavigation(e,t){this._closeAllImageTools(),this.triangularMeasurementActive=!e,this.navigationToolActive=!t}_resetMeasureTypeAndActivateImageLocationTool(){this.measureType=null,this.imageLocationToolActive=!0}_closeAllImageTools(){this.enhancementToolActive=!1,this.navigationToolActive=!1,this.imageOverlaysOpened=!1,this.galleryOpened=!1,this.measureType=null,this.imageLocationToolActive=!1,this.navigationMode=null,this.triangularMeasurementActive=!1,this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))}_handleBrightnessChange(e){this.viewModel.brightness=e.currentTarget.value??0}_handleVideoBrightnessChange(e){this.viewModel.videoViewModel?.handleVideoBrightnessChange(e.target.value)}_handleContrastChange(e){this.viewModel.contrast=e.currentTarget.value??0}_handleVideoContrastChange(e){this.viewModel.videoViewModel?.handleVideoContrastChange(e.target.value)}_handleVideoSeek(e){const t=this.viewModel?.videoElement?.content;t&&(t.currentTime=e.target.value,t.play())}_handleSharpnessChange(e){this.viewModel.sharpness=e.currentTarget.value??0}_lazyLoadImage(e,t){e.forEach(async e=>{if(e.isIntersecting){const a=e.target,o=a.getAttribute("data-src"),s=a.getAttribute("data-rotation"),l=a.getAttribute("data-objectid"),d=s?parseFloat(s)%360:0,{layer:c,_galleryController:{signal:g}}=this;if(!o||!l)return;let h;try{h=P(o)?await F(c,l,{signal:g}):await E(o,{signal:g})}catch(i){r(i)||n.getLogger("esri.widgets.OrientedImageryViewer").error("#lazyLoadImage()",i)}finally{t.unobserve(a)}if(!h)return;x(h,a,d)}})}_loadImageFromGallery(e){const{target:t}=e;if(!t)return;const i=t.getAttribute("data-objectid");i&&this.viewModel.currentBestFeature?.attributes.objectId!==Number(i)&&this.viewModel.selectBestFeature(i)}_loadImageMeasurementResources(){this._imageMeasurementToolsLoaderTask=a(async()=>{const{default:e}=await import("./OrientedImageryViewer/components/ImageMeasurementWidget.js");return e})}_loadSketchResources(){this._sketchLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/SketchTools.js")).default)}_onAdditionalCoverageVisibilityChange(e){this.viewModel.setAdditionalCoverageVisibility(e)}_onAdditionalCameraLocationsVisibility(e){this.viewModel.setAdditionalCameraLocationsVisibility(e)}_onCurrentCoverageVisibilityChange(e){this.viewModel.setCurrentCoverageVisibility(e)}_registerGalleryItem(e){this._galleryObserver.observe(e)}_renderWarning(e,t){const{viewModel:{state:i}}=this;return"image-loaded"===i?ee(G,{icon:"exclamation-mark-triangle-f",kind:"warning",message:t,open:!0,title:e,tooltip:t}):null}get _renderNavigation(){const{viewModel:{sectorData:e,navigatorCurrentBestFeature:t,currentBestFeature:a,state:o}}=this;if(!this.container||!a)return null;let s,n,r,l,d;if(t){const{x:e,y:i,direction:a}=t,[o,c,g,h]=C[a];s=`M ${e} ${i} L ${o} ${c} A ${f[2]} ${f[2]} 0 0 1 ${g} ${h} Z`,n=e,l=i,r=C[a][4],d=C[a][5]}const c=e=>{const t=e.target.dataset?.sector;t&&this.viewModel.handleSectorClick(+t)},g=e=>{const t=e.target.dataset;if(!t)return;const{featureIndexInSector:i,sector:a}=t;i&&a&&this.viewModel.handleFeatureClick({sector:a,featureIndexInSector:+i})},h=e=>{e.removeEventListener("click",g)},m=a.attributes.objectId,u=e?.map(e=>e?.items).filter(Boolean).flatMap(e=>e?.map(({x:e,y:t,objectID:i,featureIndexInSector:a,sector:o})=>ee("circle",{afterRemoved:h,class:this.classes(L.feature,{selected:m===i}),cx:e,cy:t,"data-feature-index-in-sector":a,"data-sector":o,key:`${L.feature}-${i}`,onclick:g,r:A}))),v=e=>{e.removeEventListener("click",c)},p=this.classes({[L.navigationWrapper]:!0,[L.navigationZoomed]:this._navigationToolExpanded});return this.navigationToolActive&&("image-loaded"===o||this.videoLoaded)?ee("div",{bind:this,class:p,key:this.messages.navigationTool},ee("svg",{afterCreate:e=>this._storeNavigationToolReference(e),class:i()?V:L.rotateWithAnimation,focusable:"false",height:I,role:"img",width:I,xmlns:"http://www.w3.org/2000/svg"},ee("defs",null,ee("linearGradient",{gradientUnits:"userSpaceOnUse",id:`${this.id}-coverage-fill`,x1:n,x2:r,y1:l,y2:d},ee("stop",{class:L.navigationPathOffset0,offset:0}),ee("stop",{class:L.navigationPathOffset1,offset:1}))),ee("g",null,ee("circle",{class:this.classes(L.sector,L.outerSector),cx:f[3],cy:f[3],onclick:this._scaleNavigationTool,r:f[3]}),ee("circle",{class:L.sector,cx:f[3],cy:f[3],r:f[2]}),ee("circle",{class:L.sector,cx:f[3],cy:f[3],r:f[1]}),ee("circle",{class:L.sector,cx:f[3],cy:f[3],r:f[0]}),ee("path",{class:L.pointer,d:"M 56.5 6.06217782649107 L 60 0 L 63.5 6.06217782649107 Z",key:`${L.pointer}-west`}),ee("path",{class:this.classes(L.pointer,L.north),d:"M 113.93782217350893 56.5 L 120 60 L 113.93782217350893 63.5 Z",key:`${L.pointer}-north`}),ee("path",{class:L.pointer,d:"M 56.5 113.93782217350893 L 60 120 L 63.5 113.93782217350893 Z",key:`${L.pointer}-east`}),ee("path",{class:L.pointer,d:"M 6.06217782649107 56.5 L 0 60 L 6.06217782649107 63.5 Z",key:`${L.pointer}-south`}),ee("path",{class:this.classes(L.sector,L.sectorSeparator),d:"M 23.937554159486076 23.937554159486076 L 96.06244584051393 96.06244584051393 M 23.937554159486076 96.06244584051393 L 96.06244584051393 23.937554159486076",key:L.sectorSeparator}),_([f[2],f[1],f[0]],f[3],f[3]).map((t,i)=>ee("path",{afterRemoved:v,class:this.classes(L.sector,e?.[i]?.length?L.sectorEnabled:L.sectorDisabled),d:t,"data-sector":`${i}`,key:`${L.sector}-${i}`,onclick:c})),ee("path",{class:this.classes(L.sector,L.sectorCross),d:"M 56.4 56.4 L 63.53 63.53 M 63.53 56.4 L 56.4 63.53",key:L.sectorCross}),u,a.attributes.cameraPitch>=5&&s?ee("path",{class:L.selectedFeaturePath,d:s,fill:`url(#${this.id}-coverage-fill)`,key:L.selectedFeaturePath}):null))):null}_renderSketch(){const{dataCaptureLayer:e,imageOverlaysOpened:t}=this;if(!e||t)return null;if(this._sketchLoaderTask||this._loadSketchResources(),!this._sketchLoaderTask?.value)return null;const{geometryType:i}=e,a="point"===i?"pin":"polyline"===i?"line":"polygon",o=this._sketchLoaderTask.value;return ee("div",{class:L.sketchTools},ee(o,{icon:a,messages:this._imageSketchToolsMessages,type:i,onAction:this._onAction}))}get _renderThumbnails(){const{currentBestFeature:e,thumbnails:t}=this.viewModel;return e?ee("div",{class:L.carouselContent},t?.items.map(({url:t,objectId:i,rotation:a},o)=>ee("div",{class:`${L.carouselItemWrapper}${e.attributes.objectId===i?"--selected":""}`,key:`${L.carouselItemWrapper}-${o}`},ee("canvas",{afterCreate:this._registerGalleryItem,afterRemoved:this._unregisterGalleryItem,alt:`thumbnail-${i}`,class:L.carouselItem,"data-objectid":`${i}`,"data-rotation":`${a}`,"data-src":t,onclick:this._loadImageFromGallery,onmouseenter:this._highlight,onmouseleave:this._removeHighlight})))):null}_resetImageTools(){this.viewModel.sharpness=this.viewModel.brightness=this.viewModel.contrast=0}_resetVideoTools(){this.viewModel.videoViewModel?.resetVideoEnhancementTools()}_storeNavigationToolReference(e){this._navigationTool=e}_toggleAdditionalCameraLocations(){this.isAdditionalPointSourcesVisible=!this.isAdditionalPointSourcesVisible}_toggleAdditionalCoverage(){this.isAdditionalCoverageVisible=!this.isAdditionalCoverageVisible}_toggleCurrentCoverage(){this.currentCoverageVisible=!this.currentCoverageVisible}_toggleEnhancementToolState(e){e.stopPropagation();const t=this.enhancementToolActive;this._closeAllImageTools(),this.enhancementToolActive=!t}_toggleImageOverlays(e){e.stopPropagation();const t=this.imageOverlaysOpened;this._closeAllImageTools(),this.imageOverlaysOpened=!t}_toggleImageGallery(e){e.stopPropagation();const t=this.galleryOpened;this._closeAllImageTools(),this.galleryOpened=!!this.imageGalleryEnabled&&!t}_toggleLocationTool(e){const t=this.imageLocationToolActive,i=this.triangularMeasurementActive&&t;this._closeAllImageTools(),this.imageLocationToolActive=i||!t,e.stopPropagation()}_toggleMeasurementSketch(e,t){e.stopPropagation();const i=this.measureType,a=this.triangularMeasurementActive;this._closeAllImageTools(),this.measureType=i!==t||a?t:null,this.measureType===t&&(this.viewModel.displayNewMeasurementButton=!0)}_toggleNavigationTool(){const e=this.navigationToolActive;this._closeAllImageTools(),this.navigationToolActive=!e}_toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_toggleTriangularAreaMeasurements(){this._toggleTriangularMeasurements("area")}_toggleTriangularDistanceMeasurements(){this._toggleTriangularMeasurements("distance")}_toggleTriangularLocation(){const e=this.triangularMeasurementActive,t=this.navigationToolActive;e?null===this.measureType?this.imageLocationToolActive?this._closeImageToolsAndToggleNavigation(e,t):this._activateTriangulatedImageLocationTool():this._resetMeasureTypeAndActivateImageLocationTool():this._activateTriangulatedImageLocationWorkflow(e,t)}_toggleTriangularMeasurements(e){const t=this.triangularMeasurementActive,i=this.viewModel.measureType,a=this.navigationToolActive;t?e===i?(this._closeAllImageTools(),this.triangularMeasurementActive=!t,this.navigationToolActive=!a):(this.imageLocationToolActive=!1,this.measureType=e):(this._closeAllImageTools(),this.measureType=e,this.triangularMeasurementActive=!t,this.navigationToolActive=!!a||!a)}_unregisterGalleryItem(e){this._galleryObserver.unobserve(e)}_updateNavigationTool(e){const{previousFeatureAngle:t,bestFeatureAngle:i}=this.viewModel,a=(i-t+540)%360-180;e.style.setProperty(k,`${t}deg`),e.style.setProperty(S,`${t+a}deg`)}async loadBestImage(e){return this.viewModel.loadBestImage(e)}loadImageFromSource(e,t){return this.viewModel.loadImageFromSource(e,t)}async overlayMapFeatures(e,t){return this.removeHandles(`${te.overlayed}-${e.id}`),this.addHandles(l(()=>e.visible,()=>{this.viewModel.toggleOverlayMapFeatures(e.id,e.visible,this.showMapFeatures)}),`${te.overlayed}-${e.id}`),this._overlayedLayers.add(e),this.viewModel.overlayMapFeatures(e,t&&this.showMapFeatures)}async plotMapPoint(e){return this.viewModel.plotMapPoint(e)}plotReferencePointOnGround(e){this.viewModel.plotReferencePointOnGround(e)}plotReferencePointOnImage(e){this.viewModel.plotReferencePointOnImage(e)}removeOverlayedGraphicsOnImage(e){this.removeHandles(`${te.overlayed}-${e}`),this._overlayedLayers.remove(this._overlayedLayers.find(t=>t.id===e)),this.viewModel.removeOverlayedGraphicsOnImage(e)}resetImage(){this.viewModel.resetImage()}render(){return ee("div",{class:this.classes(Q.widget,O)},this._renderRoot)}async showImageByObjectId(e,t){return this.viewModel.showImageByObjectId(e,t)}async startDataCapture(e){return this.viewModel.startDataCapture(e)}async stopDataCapture(e){return this.viewModel.stopDataCapture(e)}updateSuitabilities(e){this.viewModel.updateSuitabilities(e)}};e([h({readOnly:!0})],ie.prototype,"accuracyParametersMissing",null),e([h()],ie.prototype,"activeLayer",null),e([h()],ie.prototype,"activeVideoIcon",null),e([h()],ie.prototype,"activeAudioIcon",null),e([h()],ie.prototype,"cameraHeadingThreshold",null),e([h()],ie.prototype,"cameraPitchThreshold",null),e([h()],ie.prototype,"canNavigateSequentially",null),e([h()],ie.prototype,"currentBestFeature",null),e([h()],ie.prototype,"currentCoverageVisible",null),e([h()],ie.prototype,"dataCaptureEnabled",void 0),e([h()],ie.prototype,"dataCaptureLayer",null),e([h()],ie.prototype,"depthImageNotSupported",null),e([h()],ie.prototype,"disabled",null),e([h()],ie.prototype,"enhancementToolActive",null),e([h()],ie.prototype,"features",null),e([h()],ie.prototype,"imagePointsInView",null),e([h()],ie.prototype,"galleryOpened",void 0),e([h()],ie.prototype,"icon",null),e([h()],ie.prototype,"imageEnhancementToolActive",void 0),e([h()],ie.prototype,"videoEnhancementToolActive",void 0),e([h({readOnly:!0})],ie.prototype,"imageGalleryEnabled",null),e([h()],ie.prototype,"imageLocationToolActive",null),e([h()],ie.prototype,"imageOverlaysOpened",void 0),e([h({readOnly:!0})],ie.prototype,"invalidCameraHeading",null),e([h()],ie.prototype,"isAdditionalCoverageVisible",null),e([h()],ie.prototype,"isAdditionalPointSourcesVisible",null),e([h()],ie.prototype,"mapImageConversionToolState",null),e([h()],ie.prototype,"measureType",null),e([h()],ie.prototype,"layer",null),e([h()],ie.prototype,"navigationToolActive",void 0),e([h()],ie.prototype,"navigationMode",null),e([X(M()),h({type:H})],ie.prototype,"viewModel",void 0),e([h(),Y("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],ie.prototype,"messages",void 0),e([h(),Y("esri/core/t9n/Units")],ie.prototype,"measurementUnitMessages",void 0),e([h(),Y("esri/t9n/common")],ie.prototype,"messagesCommon",void 0),e([h(),Y("esri/widgets/Sketch/t9n/Sketch")],ie.prototype,"messagesSketch",void 0),e([h()],ie.prototype,"pixelMeasurementUnit",void 0),e([h()],ie.prototype,"pixelAreaMeasurementUnit",void 0),e([h({readOnly:!0})],ie.prototype,"popupEnabled",null),e([h()],ie.prototype,"referencePoint",null),e([h()],ie.prototype,"showCameraLocations",void 0),e([h()],ie.prototype,"showMapFeatures",void 0),e([X(["create","delete","redo","undo","update"]),h({readOnly:!0})],ie.prototype,"sketchViewModel",null),e([h()],ie.prototype,"triangularMeasurementActive",null),e([h()],ie.prototype,"videoLoaded",null),e([h()],ie.prototype,"view",null),e([h({type:j,nonNullable:!0})],ie.prototype,"visibleElements",void 0),e([h()],ie.prototype,"determineWorkflowForFeature",null),e([h()],ie.prototype,"updateFootprint",null),e([h()],ie.prototype,"_activeMeasurementIcon",null),e([h()],ie.prototype,"_activeMeasurementHeading",null),e([h()],ie.prototype,"_imageOverlaysLoaderTask",void 0),e([h()],ie.prototype,"_imageMeasurementToolsLoaderTask",void 0),e([h()],ie.prototype,"_navigationSettingsLoaderTask",void 0),e([h()],ie.prototype,"_measurementToggle",null),e([h()],ie.prototype,"_renderRoot",null),e([h()],ie.prototype,"_imageEnhancementTools",null),e([h()],ie.prototype,"_videoEnhancementTools",null),e([h()],ie.prototype,"_imageGalleryPanel",null),e([h()],ie.prototype,"_imageGalleryContext",null),e([h()],ie.prototype,"_imageOverlaysComponent",null),e([h()],ie.prototype,"_imageOverlayMessages",null),e([h()],ie.prototype,"_imageSketchToolsMessages",null),e([h()],ie.prototype,"_imageViewer",null),e([h()],ie.prototype,"_imageViewerTriangular",null),e([h()],ie.prototype,"_videoViewer",null),e([h()],ie.prototype,"_locationToggle",null),e([h()],ie.prototype,"_messageBox",null),e([h()],ie.prototype,"_navigationToolExpanded",void 0),e([h()],ie.prototype,"_navigationTool",void 0),e([h()],ie.prototype,"_panoramicVideoViewer",null),e([h()],ie.prototype,"_panoramicViewer",null),e([h()],ie.prototype,"_renderNavigation",null),e([h()],ie.prototype,"_renderThumbnails",null),e([h()],ie.prototype,"_sketchLoaderTask",void 0),ie=e([m("esri.widgets.OrientedImageryViewer")],ie);const ae=ie;export{ae 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{id as t}from"../../kernel.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import{EventedAccessor as i}from"../../core/Evented.js";import a from"../../core/Logger.js";import{whenOnce as l,once as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{isPoint as h,isMultipoint as u}from"../../geometry/support/jsonUtils.js";import{fetchMessageBundle as p}from"../../intl/messages.js";import d from"../../layers/FeatureLayer.js";import g from"../../layers/GraphicsLayer.js";import y from"../../layers/support/CodedValueDomain.js";import{isFeatureLayer as m,isSubtypeSublayer as f,getOwningPortalUrl as w}from"../../layers/support/layerUtils.js";import _ from"../../networks/UtilityNetwork.js";import{getFeaturesFromLayers as b}from"../../networks/support/utils.js";import A from"../../portal/Portal.js";import{hasUserTypeExtension as v}from"../../portal/support/utils.js";import{trace as k}from"../../rest/networks/trace.js";import I from"../../rest/networks/support/TraceLocation.js";import F from"../../rest/networks/support/TraceParameters.js";import{addUniqueLayer as G}from"../../views/draw/support/layerUtils.js";import{GeometryHandler as R}from"./support/GeometryHandler.js";import{GraphicHandler as L,barrierColor as T,startingPointColor as H}from"./support/GraphicHandler.js";import{ResultAreaHandler as S}from"./support/ResultAreaHandler.js";import{UtilityHelper as N}from"./support/UtilityHelper.js";const P=()=>p("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace"),U=()=>p("esri/core/t9n/Units"),B=`utility-network-trace-flags-${Date.now()}`,C=`utility-network-trace-results-${Date.now()}`,j=`utility-network-trace-sketch-${Date.now()}`;function E(e){return e instanceof y}function V(e){return"feature"===e.layer.type||"subtype-group"===e.layer.type}function D(e){return"layer"in e}function O(e){return void 0!==e.layerViews}function M(e){return"graphics"===e.type}function x(e){return"feature"===e.type||"subtype-group"===e.type||"group"===e.type}async function q(e){const t=new d({url:e.networkSystemLayers.dirtyAreasLayerUrl});await t.load();const r=t.version;if(Number(r)<=11.1){const t=await w(e.layerUrl),r=new A({url:t});await r.load();const s=r?.user?.username;return!!s&&v(r,s,"utilityNetwork")}return!0}let $=class extends i{constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._flagId=0,this._geometryHandler=null,this._highlightHandler=[],this._resultAreaHandler=null,this._sketchViewModel=null,this._traceTimeout=6e5,this._utilityHelper=new N,this._validUNLayers=[],this._watchHandler=null,this.traces=[],this.graphicHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.enableResultArea=!1,this.flags=[],this.messages=null,this.messagesUnits=null,this.defaultResultAreaProperties={type:"convexhull",distance:10,unit:"meters",areaUnit:"square-meters",color:{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},show:!1},this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.traceResults=[],this.utilityNetwork=null}initialize(){this._geometryHandler=new R,this.graphicHandler=new L,this._resultAreaHandler=new S;(async()=>{const[e,t]=await Promise.all([P(),U()]);this.set({messages:e,messagesUnits:t})})()}destroy(){this.view=null}get resultAreaProperties(){return this.defaultResultAreaProperties}set resultAreaProperties(e){this._set("resultAreaProperties",{...this.defaultResultAreaProperties,...e}),this.graphicHandler.addCustomColor(this.resultAreaProperties.color),this.traceResults.forEach(t=>{const r=t.resultArea?.show;t.resultArea={...this.defaultResultAreaProperties,...e},this.removeResultAreaFromMap(t),this.enableResultArea&&this.createResultAreaGraphic(t).then(s=>{if(s){t.resultAreaGraphic=s;const i=e?.show??r;t.resultArea&&(t.resultArea.show=i),i&&this.addResultAreaToMap(t,s)}})})}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&a.getLogger(this).error(new s("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e),this.utilityNetwork&&this.reset(),this.utilityNetwork=null,this.loadUtilityNetwork().then(e=>{e&&this.selectTracesOnLoad()})}addFlagByHit(e,t){const r=!!this.view&&this.view.popupEnabled,s=e=>{this.view?.popup&&(this.view.popupEnabled=e)};return new Promise((i,a)=>{r&&s(!1),this._clickHandler?.remove(),this._clickHandler=this._sketchViewModel.on("create",l=>{if("complete"===l.state){const o=this._getGraphicLayer(j);o&&l.graphic&&o.remove(l.graphic),this.queryFlagByHitTest(l,e,t).then(r=>{this.emit("add-flag-complete",{type:e,symbol:t}),i(r)}).catch(r=>{this.emit("add-flag-error",{type:e,symbol:t}),a(r)}).finally(()=>{r&&s(!0),this._clickHandler?.remove()})}}),this._sketchViewModel.create("point"),this.emit("add-flag",{type:e})})}addNonspatialTraceLocation(e,t){const r=this._getDisplayField(e),s=this.utilityNetwork?.getTerminalConfiguration(e),i={terminalId:null,isFilterBarrier:!1,allTerminals:s,selectedTerminals:[s?s.terminals[0].id||null:1],displayValue:r};e.attributes={...e.attributes,...i};const a=e.attributes.hasOwnProperty("GLOBALID")?e.attributes.GLOBALID:e.attributes.globalid;if(!this._flags.some(e=>e.globalId===a&&e.type===t)){const r=this._createFlagProperty(e,t,null);this._flags.push(r),this.emit("add-flag-complete",{type:t})}this.emit("add-flag",{type:t})}async addFlagsOnLoad(){if(this._flags.length>0)return[];await l(()=>null!=this.view&&!this.view.updating);return(await Promise.all(this.flags.map(async e=>{if(!e.mapPoint)return null;const{type:t}=e,r=e.mapPoint.clone(),s="barrier"===t?T:H,i={graphic:this.graphicHandler.makeGraphic(r,s),state:"complete",tool:"point",toolEventInfo:null,type:"create"};try{return await this.queryFlagByHitTest(i,e.type,null),this.emit("add-flag-complete",{type:t}),null}catch(a){return this.emit("add-flag-error",{type:t}),"barrier"===t?"barrier":"starting-point"}}))).filter(e=>!e)}async addResultAreaToMap(e,t){if(this.view)if(e.resultArea.show=!0,t)this._resultAreaHandler?.addResultAreaToMap(t,this.view.map),this.emit("add-result-area",{graphic:t});else if(e.results){const t=await this.createResultAreaGraphic(e);t&&(e.resultAreaGraphic=t,this._resultAreaHandler?.addResultAreaToMap(t,this.view.map),this.emit("add-result-area",{graphic:t}))}}async addResultGraphicToView(e,t){const{view:r}=this,{results:s}=e;if(r&&s&&this.utilityNetwork)for(const i in s.aggregatedGeometry)if("line,multipoint,polygon".includes(i)){const a=i,l=s.aggregatedGeometry[a];if(null!=l){l.spatialReference=this.utilityNetwork.spatialReference,e.graphicEnabled=!0;const s=await this._geometryHandler.projectGeometry(l,r.spatialReference),i={globalid:e.trace.globalId};if(null!==s){const e=this.graphicHandler.makeGraphic(s,t.color,i,r.spatialReference);this._getGraphicLayer(C)?.add(e)}}}}addTerminal(e,t){const r=[...this._flags];r.forEach(r=>{r.globalId===t.globalId&&(t.selectedTerminals?.includes(parseInt(e,10))||r.selectedTerminals?.push(parseInt(e,10)))}),this._flags=r}async callTrace(){const e=this.traces.filter(e=>e.selected);return!!e.length&&(this.traceResults.length>0&&this.traceResults.forEach(e=>{this.removeResultGraphicFromView(e)}),this.traceResults=[],this.removeSelection(),await Promise.all(e.map(async(e,t)=>{const r=e,s=new F({gdbVersion:this.utilityNetwork?.gdbVersion,moment:this.utilityNetwork?.historicMoment,namedTraceConfigurationGlobalId:r.globalId,outSpatialReference:null,resultTypes:null,traceType:r.traceType,traceLocations:this._flags,traceConfiguration:null});await this.executeTrace(r,this.utilityNetwork?.networkServiceUrl,s).then(async e=>{if(e.hasOwnProperty("results")){const r={...e};if(null!==r.results){r.resultArea={...this.resultAreaProperties};const e=[...r.results.elements];r.results.elements.length=0;const s=new Map;for(const t of e)s.has(t.globalId)||(s.set(t.globalId,!0),r.results.elements.push(t));const i=[...this.traceResults];if(i.splice(t,0,r),this.traceResults=i,null!==r.results&&(this.selectOnComplete&&this.mergeSelection(!0,r.trace),this.showGraphicsOnComplete&&await this.addResultGraphicToView(r,r.graphicColor),this.enableResultArea)){const e=await this.createResultAreaGraphic(r);e&&(r.resultAreaGraphic=e,r.resultArea?.show&&await this.addResultAreaToMap(r,r.resultAreaGraphic))}}else{const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}this._activeProgress=!1}else{this._activeProgress=!1;const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}}).catch(e=>{throw this._activeProgress=!1,e})})),!0)}cancelAddFlagByHit(){this._sketchViewModel.cancel()}changeResultAreaColor(e,t){if(!e.resultArea)return;e.resultArea.color=t;const r=this._resultAreaHandler?.changeResultAreaColor(e.trace.globalId,t,this.view.map);e.resultAreaGraphic&&(e.resultAreaGraphic.symbol=r)}changeResultGraphicColor(e,t){const r=[...this.traceResults];r.length>0&&r.forEach(r=>{r.trace.globalId===t.trace.globalId&&(r.graphicColor=e,r.graphicEnabled=!0)}),this.traceResults=r,this.removeResultGraphicFromView(t),this.addResultGraphicToView(t,e)}changeFlagSymbol(e,t){this._flags.length>0&&this._flags.forEach(r=>{r.type===e&&t&&r.mapGraphic&&(r.mapGraphic.symbol=t)})}checkCanTrace(){const e={status:!0,issues:[]},t=this.traces.filter(e=>e.selected);t.length||(e.status=!1,e.issues.push("noTracesSelected"));this._flags.some(e=>"starting-point"===e.type)||(e.status=!1,e.issues.push("noStartingPoints"));return this._flags.filter(e=>null!==e.allTerminals).some(e=>!e.selectedTerminals.length)&&(e.status=!1,e.issues.push("noTerminalSelected")),e}checkSelectionExist(){return this._highlightHandler.some(e=>e)}clearResult(e){if(!this.view)return;let t=this.traceResults;if(t.length>0){const r=t.filter(t=>t.trace.globalId===e.globalId);r.length>0&&(this.removeResultGraphicFromView(r[0]),this.removeResultAreaFromMap(r[0])),t=t.filter(t=>t.trace.globalId!==e.globalId)}this.traceResults=t,0===t.length?(this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}createResultAreaGeometries(e,t,r){if(!this.view||!this.resultAreaProperties)return;let s;if(s="convexhull"===this.resultAreaProperties?.type?1===t.length&&(h(t[0])||u(t[0])&&1===t[0].points.length)?this._resultAreaHandler?.createBuffer(t,r,e.resultArea?.unit,!0):this._resultAreaHandler?.createConvexHull(t,e.resultArea?.distance,e.resultArea?.unit):this._resultAreaHandler?.createBuffer(t,r,e.resultArea?.unit,!0),!s)return;if(Array.isArray(s)){for(const t of s){const r=this.getResultAreaAttributes(e,t),s=this._resultAreaHandler?.createResultAreaGraphic(t,r,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);if(s)return s}return}const i=this.getResultAreaAttributes(e,s);return this._resultAreaHandler?.createResultAreaGraphic(s,i,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color)}async createResultAreaGraphic(e){if(e.results){const t=await this._createResultAreaInputGeometry(e.results);if(t.length>0){const r=Array(t.length).fill(e.resultArea?.distance),s=this.createResultAreaGeometries(e,t,r);return this.emit("create-result-area",{graphic:s}),s}}}executeTrace(e,t,r){const s=this._processFlags(r.traceLocations);return r.traceLocations=s,k(t,r,{timeout:this._traceTimeout}).then(t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success",date:new Date})).catch(t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message,date:new Date}))}async getNonspatialTraceLocationInitialFeature(){return new Promise((e,t)=>{this._clickHandler?.remove(),this._clickHandler=this._sketchViewModel.on("create",async r=>{if("complete"!==r.state)return;const s=this._getGraphicLayer(j);s&&r.graphic&&s.remove(r.graphic);const i=this.view?.toScreen(r.graphic?.geometry);if(!i)return;const a=await(this.view?.hitTest(i));if(a?.results.length){const r=a.results.find(e=>"graphic"===e.type&&this.utilityNetwork?.isUtilityLayer(e.layer));r?e(r):t(null)}}),this._sketchViewModel.create("point")})}getResultAreaAttributes(e,r){const{messages:s}=this,i=[],a=[];this._flags.forEach(e=>{const t=e.displayValue?.field+":"+e.displayValue?.value+";"+s.attributeStrings.globalid+":"+e.globalId+";"+s.attributeStrings.terminalid+":"+e.terminalId+";"+s.attributeStrings.x+":"+e.mapPoint?.x+";"+s.attributeStrings.y+":"+e.mapPoint?.y;"starting-point"===e.type?i.push(t):a.push(t)});const l=this.utilityNetwork?.gdbVersion;return{traceId:e.trace.globalId,traceName:e.trace.title,traceDescription:e.trace.description??"",startingPoints:i.toString(),barriers:a.toString(),version:l??void 0,username:t.credentials[0].userId,date:e.date,elementCount:e.results?.elements.length,functionResult:JSON.stringify(e.results?.globalFunctionResults),areaStatistic:r?this._geometryHandler.calculateArea(r,e.resultArea?.areaUnit):0}}getValidSources(){let e=[];const t=this.utilityNetwork?.dataElement?.domainNetworks??[];for(const r of t)e=e.concat(r.junctionSources),e=e.concat(r.edgeSources);return e}groupResultsByNetworkSource(e){return 0===e.length?[]:this._groupBy(e,"networkSourceId")}async loadUtilityNetwork(){const{view:e}=this;if(!e)return null;if(await e.when(),this.utilityNetwork){if(this.utilityNetwork.loaded||await this.utilityNetwork.load(),this.utilityNetwork instanceof _){try{const t=e.map;await t.loadAll()}catch(i){if("layer:unsupported-layer-type"!==i.name)throw i}finally{this._loadUNSupportItems()}return this.utilityNetwork}return null}const t=e.map,r=t.utilityNetworks?.at(0);if(r){if(await r.load(),this.utilityNetwork=r,!await q(r))throw new s("utility-network:no-user-type-extension","User type extension not found");try{await t.loadAll()}catch(i){if("layer:unsupported-layer-type"!==i.name)throw i}finally{this._loadUNSupportItems()}return r}return null}manageFilterBarrier(e,t){const r=[...this._flags];r.forEach(r=>{r.globalId===t.globalId&&"barrier"===t.type&&r.id===t.id&&(r.isFilterBarrier=e)}),this._flags=r}mergeSelection(e,t){let r=[];const s=[...this.traceResults],i=t.globalId;s.forEach(t=>{i===t.trace.globalId&&(t.selectionEnabled=e),t.selectionEnabled&&null!==t.results?.elements&&(r=[...r,...t.results?.elements??[]])}),this.selectResults([...new Set(r)])}async queryFeaturesById(e){const{view:t}=this;if(!t||!this.utilityNetwork)return null;const s=this.utilityNetwork.getObjectIdsFromElements(e),i={layerUrl:s[0].layerUrl,objectIds:s[0].objectIds,outFields:["*"]},a=t.map?.allTables.toArray().filter(e=>e?.parsedUrl?.path===s[0].layerUrl).filter(m)??[];this._getUniqueMapLayerViews(t).filter(({layer:e})=>e?.parsedUrl?.path===s[0].layerUrl).forEach(({layer:e})=>{"feature"!==e.type&&"subtype-group"!==e.type||a.push(e)});const l=(await Promise.all(a.map(async e=>{const s={layers:new r([e]),layerInfos:[i],returnGeometry:!0,outSpatialReference:t.spatialReference},[a]=await b(s,!1);return a}))).filter(({featureSet:e})=>e.features.length>0);return l.length>0?l:null}queryFlagByHitTest(e,t,r){return this._lookupFlagByHit(e).then(e=>{const{view:s}=this;if(!s)return!1;if(e.length>0){const s=[...this._flags],i=r;return e.forEach(e=>{const r=e.graphic,a=r.attributes.hasOwnProperty("GLOBALID")?r.attributes.GLOBALID:r.attributes.globalid;if(s.filter(e=>e.globalId===a).length<=0){const e=this.graphicHandler.getFlagGraphic(r.attributes.mapPoint,t,r,i);this._getGraphicLayer(B)?.add(e);const a=this._createFlagProperty(r,t,e);s.push(a)}else if(null!==r.attributes.percentAlong){const e=this.graphicHandler.getFlagGraphic(r.attributes.mapPoint,t,r,i);this._getGraphicLayer(B)?.add(e);const a=this._createFlagProperty(r,t,e);s.push(a)}}),this._flags=s,!0}return!1})}removeResultGraphicFromView(e){const{view:t}=this;if(!t)return;const r=this._getGraphicLayer(C)?.graphics;e.graphicEnabled=!1;const s=r?.filter(t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId);s?.forEach(e=>{this._getGraphicLayer(C)?.remove(e)})}removeFlag(e){const t=this._flags.filter(t=>{if(t.id!==e.id)return t});this._removeGraphic(e),this._flags=t}removeAllResultAreaGraphics(){this._resultAreaHandler?.removeAllResultAreaGraphics(this.view.map)}removeResultAreaFromMap(e){if(e.resultArea){e.resultArea.show=!1;const t=this._resultAreaHandler?.removeResultArea(e.trace.globalId,this.view?.map);t&&this.emit("remove-result-area",{graphic:t})}}removeSelection(){this._highlightHandler.forEach(e=>{e&&e.remove()}),this._highlightHandler=[]}removeTerminal(e,t){const r=[...this._flags];r.forEach(r=>{if(r.globalId===t.globalId&&t.selectedTerminals?.includes(parseInt(e,10))){const s=t.selectedTerminals.indexOf(parseInt(e,10));r.selectedTerminals?.splice(s,1)}}),this._flags=r}removeFlagsOnLoadWatcher(){this._watchHandler&&null!==this._watchHandler&&this._watchHandler.remove()}removeClickHandler(){this._clickHandler&&(this._sketchViewModel.cancel(),this._clickHandler.remove())}reset(){this._flags=[],this.traceResults=[];const e=[...this.traces];e.forEach(e=>{e.selected=!1}),this.traces=e,this.view&&(this._getGraphicLayer(j)?.removeAll(),this._getGraphicLayer(B)?.removeAll(),this._getGraphicLayer(C)?.removeAll(),this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]}),this.emit("reset"))}selectFeaturesById(e){const{view:t}=this;if(!t||!this.utilityNetwork)return;const r=this.utilityNetwork.getObjectIdsFromElements(e);this._getUniqueMapLayerViews(t).forEach(e=>{D(e)&&e.layer?.parsedUrl?.path===r[0].layerUrl&&V(e)&&this._highlightHandler.push(e.highlight(r[0].objectIds))})}selectResults(e){if(e.length>0){this.removeSelection();const t=this.groupResultsByNetworkSource(e),r=[];for(const e in t)this.selectFeaturesById(t[e]),r.push(this.queryFeaturesById(t[e]));Promise.all(r).then(e=>{this.emit("select-features",{resultSet:e})})}else this.removeSelection(),this.emit("clear-selection",{resultSet:[]})}selectTraces(e,t){const r=[...this.traces];r.forEach(r=>{t===r.globalId&&(r.selected=e)}),this.traces=r}selectTracesOnLoad(){this.utilityNetwork?.hasOwnProperty("sharedNamedTraceConfigurations")&&(this.traces=[...this.utilityNetwork.sharedNamedTraceConfigurations],this.traces.forEach(e=>{e.selected=!1,this.selectedTraces.includes(e.globalId)&&(e.selected=!0)}))}zoomToAsset(e){this.view?.goTo(e).catch(e=>console.error(e))}async _createResultAreaInputGeometry(e){if(null!=e.aggregatedGeometry)return this._geometryHandler.mergeAggregatedToGeometries(e.aggregatedGeometry);const t=this.groupResultsByNetworkSource(e.elements),r=[];for(const s in t)r.push(this.queryFeaturesById(t[s]));try{const e=await Promise.all(r),t=[];for(const r of e)if(r)for(const e of r)for(const r of e.featureSet.features)r.geometry&&t.push(r.geometry);return t}catch{return[]}}_loadUNSupportItems(){if(!this.utilityNetwork)return;const{map:e}=this.view,{messages:t}=this;this._populateOutfields(),this._createGraphicLayer(j),this._createGraphicLayer(B),this._createGraphicLayer(C),this._resultAreaHandler?.createGraphicLayer(e,t?.alertsStrings.genericResultHeader),this._validUNLayers=this._utilityHelper.getValidUtilityNetworkLayers(e,this.utilityNetwork),this._sketchViewModel=this.graphicHandler.initializeSketch(this.view,this._getGraphicLayer(j),this._validUNLayers)}_getUniqueMapLayerViews(e){const t=[],r=e.layerViews.filter(({layer:{type:e}})=>"feature"===e||"group"===e||"subtype-group"===e).toArray(),s=e=>{for(const r of e.layerViews)O(r)?s(r):t.push(r)};return r.forEach(e=>{switch(e.layer.type){case"group":O(e)&&s(e);break;case"subtype-group":t.push(e);break;default:t.some(t=>t.layer.id===e.layer.id)||t.push(e)}}),t}_processFlags(e){const t=[];return e.forEach(e=>{if(null!==e.selectedTerminals&&e.selectedTerminals.length>0)e.selectedTerminals.forEach(r=>{const s=new I({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:r,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)});else{const r=new I({globalId:e.globalId,percentAlong:e.percentAlong,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}}),t}_getDisplayField(e){return f(e?.sourceLayer)?this._getDisplayFieldBySublayer(e):this._getDisplayFieldByFeatureLayer(e)}_getDisplayFieldBySublayer(e){let t="",r="";const s=e.sourceLayer;t=this._checkParentForData(s,"displayField");for(const i in e.attributes){const a=i.toLowerCase();a===t?.toLowerCase()?(r=e.attributes[i],"assetgroup"===a||"assettype"===a?r=this._checkSubtype(s,s.subtypeCode):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))}return{field:t,value:r.toString()}}_getDisplayFieldByFeatureLayer(e){const t=e.sourceLayer;let r=t.displayField,s="";for(const i in e.attributes){const a=i.toLowerCase();if(a===r?.toLowerCase())if(s=e.attributes[i],"assetgroup"===a||"assettype"===a){let a=e.attributes[t.typeIdField.toUpperCase()];a||(a=e.attributes[t.typeIdField.toLowerCase()]),r=t.typeIdField,s=this._checkSubtype(t,a),""===r&&(t.templates&&t.templates.length>0?(r=t.templates[0]?.name,s=t.templates[0]?.name):(r=t.displayField,s=e.attributes[i]))}else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t));else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t))}return{field:r,value:s?s.toString():""}}_checkSubtype(e,t){let r=t;if("subtype-sublayer"===e.type){const s=this._checkParentForData(e,"subtypes");s?.length>0&&s.forEach(e=>{e.code===t&&(r=e.name)})}else if(null!=e.types&&e.types.length>0){const s=e.types.filter(e=>e.id===t);s.length>0&&(r=s[0].name)}return r}_checkDomain(e,t,r){let s=r;const i=e.filter(e=>e.name.toLowerCase()===t.toLowerCase());if(i.length>0&&E(i[0].domain)&&i[0].domain?.codedValues){const e=i[0].domain.codedValues.filter(({code:e})=>e===r);e.length>0&&(s=e[0].name)}return s}_checkParentForData(e,t){return e.parent?.[t]??null}_defaultDisplayField(e,t){return e.trim()?e:t.templates&&t.templates?.length>0?t.templates[0].name:t.title}get _uniqueFlagId(){return this._flagId++}_groupBy(e,t){return e.reduce((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e),{})}async _lookupFlagByHit(e){const t=[];let r={};const s=e.graphic?.geometry,i=this.view?.toScreen(s),a=await(this.view?.hitTest(i,{include:this._validUNLayers}));if(!a?.results.length)return[];const l=a?.results.find(e=>null!==e.layer),n=l,c=n.graphic.geometry?.type,h=l?.layer,u=h.globalIdField??"globalid",p=h.objectIdField??"objectid";if(u&&!!n.graphic.attributes[u])r=n.graphic.attributes;else{const e=await(this.view?.whenLayerView(h)),t=e.createQuery();t.outFields=["assetgroup","assettype","globalid","objectid"],t.where=`${p} = ${n.graphic.attributes[p]}`,await o(()=>!e?.updating&&!e?.dataUpdating);const s=await(e?.queryFeatures(t)),i=s?.features[0],a=i?.attributes;r=a}const d=this._getDisplayField(n.graphic),g=n.mapPoint;let y={};if("point"===c||"polygon"===c){if(this.utilityNetwork){const e=this.utilityNetwork.getTerminalConfiguration(n.graphic);y={terminalId:e?e.terminals[0].id||null:1,isFilterBarrier:!1,allTerminals:e??null,selectedTerminals:[e?e.terminals[0].id||null:1],percentAlong:null,displayValue:d,mapPoint:g}}}else if("polyline"===c){const t=n.graphic.geometry;y={terminalId:null,isFilterBarrier:!1,allTerminals:null,selectedTerminals:null,percentAlong:this._geometryHandler.getPercentageAlong(t,e.graphic?.geometry,t.spatialReference),displayValue:d,mapPoint:g}}return n.graphic.attributes={...r,...y},t.push(n),t}_createFlagProperty(e,t,r){const s=new I;s.terminalId=e.attributes.terminalId,s.isFilterBarrier=e.attributes.isFilterBarrier,s.percentAlong=e.attributes.percentAlong,s.globalId=e.attributes.globalid||e.attributes.GLOBALID,s.type=t;const i=s;return i.details=e,i.mapGraphic=r,i.id=this._uniqueFlagId,i.allTerminals=e.attributes.allTerminals,i.selectedTerminals=e.attributes.selectedTerminals,i.displayValue=e.attributes.displayValue,i.mapPoint=e.attributes.mapPoint,i}_populateOutfields(){if(!this.view)return;const{map:e}=this.view,t=this.getValidSources(),r=e=>{"group"===e.type?e.layers.forEach(e=>{x(e)&&r(e)}):t.some(t=>t.layerId===e.layerId)&&e.fields.some(e=>"assetgroup"===e.name.toLowerCase())&&(e.outFields=["assetgroup","assettype","globalid","objectid"])};for(const s of e.layers)x(s)&&r(s)}_removeGraphic(e){this._getGraphicLayer(B)?.remove(e.mapGraphic)}_createGraphicLayer(e){const{map:t}=this.view;if(!t.findLayerById(e)){const t=new g({id:e,internal:!0,listMode:"hide",title:e});G(this.view,t)}}_getGraphicLayer(e){const{map:t}=this.view;if(t){const r=t.findLayerById(e);if(r&&M(r))return r}return null}};e([n()],$.prototype,"_activeProgress",void 0),e([n()],$.prototype,"_flags",void 0),e([n()],$.prototype,"traces",void 0),e([n()],$.prototype,"defaultGraphicColor",void 0),e([n()],$.prototype,"enableResultArea",void 0),e([n()],$.prototype,"flags",void 0),e([n()],$.prototype,"messages",void 0),e([n()],$.prototype,"messagesUnits",void 0),e([n()],$.prototype,"resultAreaProperties",null),e([n()],$.prototype,"selectedTraces",void 0),e([n()],$.prototype,"selectOnComplete",void 0),e([n()],$.prototype,"showGraphicsOnComplete",void 0),e([n()],$.prototype,"showSelectionAttributes",void 0),e([n({readOnly:!0})],$.prototype,"state",null),e([n()],$.prototype,"traceResults",void 0),e([n()],$.prototype,"utilityNetwork",void 0),e([n({value:null})],$.prototype,"view",null),$=e([c("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel")],$);const z=$;export{z as default};
5
+ import{__decorate as e}from"tslib";import{id as t}from"../../kernel.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import{EventedAccessor as i}from"../../core/Evented.js";import a from"../../core/Logger.js";import{whenOnce as l,once as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{isPoint as h,isMultipoint as u}from"../../geometry/support/jsonUtils.js";import{fetchMessageBundle as p}from"../../intl/messages.js";import d from"../../layers/FeatureLayer.js";import g from"../../layers/GraphicsLayer.js";import y from"../../layers/support/CodedValueDomain.js";import{isFeatureLayer as m,isSubtypeSublayer as f,getOwningPortalUrl as w}from"../../layers/support/layerUtils.js";import _ from"../../networks/UtilityNetwork.js";import{getFeaturesFromLayers as b}from"../../networks/support/utils.js";import A from"../../portal/Portal.js";import{hasUserTypeExtension as v}from"../../portal/support/utils.js";import{trace as k}from"../../rest/networks/trace.js";import I from"../../rest/networks/support/TraceLocation.js";import F from"../../rest/networks/support/TraceParameters.js";import{addUniqueLayer as G}from"../../views/draw/support/layerUtils.js";import{GeometryHandler as R}from"./support/GeometryHandler.js";import{GraphicHandler as L,barrierColor as T,startingPointColor as H}from"./support/GraphicHandler.js";import{ResultAreaHandler as S}from"./support/ResultAreaHandler.js";import{UtilityHelper as N}from"./support/UtilityHelper.js";const P=()=>p("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace"),U=()=>p("esri/core/t9n/Units"),B=`utility-network-trace-flags-${Date.now()}`,C=`utility-network-trace-results-${Date.now()}`,j=`utility-network-trace-sketch-${Date.now()}`;function E(e){return e instanceof y}function V(e){return"feature"===e.layer.type||"subtype-group"===e.layer.type}function D(e){return"layer"in e}function O(e){return void 0!==e.layerViews}function M(e){return"graphics"===e.type}function x(e){return"feature"===e.type||"subtype-group"===e.type||"group"===e.type}async function q(e){const t=new d({url:e.networkSystemLayers.dirtyAreasLayerUrl});await t.load();const r=t.version;if(Number(r)<=11.1){const t=await w(e.layerUrl),r=new A({url:t});await r.load();const s=r?.user?.username;return!!s&&v(r,s,"utilityNetwork")}return!0}let $=class extends i{constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._flagId=0,this._geometryHandler=null,this._highlightHandler=[],this._resultAreaHandler=null,this._sketchViewModel=null,this._traceTimeout=6e5,this._utilityHelper=new N,this._validUNLayers=[],this._watchHandler=null,this.traces=[],this.graphicHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.enableResultArea=!1,this.flags=[],this.messages=null,this.messagesUnits=null,this.defaultResultAreaProperties={type:"convexhull",distance:10,unit:"meters",areaUnit:"square-meters",color:{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},show:!1},this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.traceResults=[],this.utilityNetwork=null}initialize(){this._geometryHandler=new R,this.graphicHandler=new L,this._resultAreaHandler=new S;(async()=>{const[e,t]=await Promise.all([P(),U()]);this.set({messages:e,messagesUnits:t})})()}destroy(){this.view=null}get resultAreaProperties(){return this.defaultResultAreaProperties}set resultAreaProperties(e){this._set("resultAreaProperties",{...this.defaultResultAreaProperties,...e}),this.graphicHandler.addCustomColor(this.resultAreaProperties.color),this.traceResults.forEach(t=>{const r=t.resultArea?.show;t.resultArea={...this.defaultResultAreaProperties,...e},this.removeResultAreaFromMap(t),this.enableResultArea&&this.createResultAreaGraphic(t).then(s=>{if(s){t.resultAreaGraphic=s;const i=e?.show??r;t.resultArea&&(t.resultArea.show=i),i&&this.addResultAreaToMap(t,s)}})})}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&a.getLogger(this).error(new s("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e),this.utilityNetwork&&this.reset(),this.utilityNetwork=null,this.loadUtilityNetwork().then(e=>{e&&this.selectTracesOnLoad()})}addFlagByHit(e,t){const r=!!this.view&&this.view.popupEnabled,s=e=>{this.view?.popup&&(this.view.popupEnabled=e)};return new Promise((i,a)=>{r&&s(!1),this._clickHandler?.remove(),this._clickHandler=this._sketchViewModel.on("create",l=>{if("complete"===l.state){const o=this._getGraphicLayer(j);o&&l.graphic&&o.remove(l.graphic),this.queryFlagByHitTest(l,e,t).then(r=>{this.emit("add-flag-complete",{type:e,symbol:t}),i(r)}).catch(r=>{this.emit("add-flag-error",{type:e,symbol:t}),a(r)}).finally(()=>{r&&s(!0),this._clickHandler?.remove()})}}),this._sketchViewModel.create("point"),this.emit("add-flag",{type:e})})}addNonspatialTraceLocation(e,t){const r=this._getDisplayField(e),s=this.utilityNetwork?.getTerminalConfiguration(e),i={terminalId:null,isFilterBarrier:!1,allTerminals:s,selectedTerminals:[s?s.terminals[0].id||null:1],displayValue:r};e.attributes={...e.attributes,...i};const a=e.attributes.hasOwnProperty("GLOBALID")?e.attributes.GLOBALID:e.attributes.globalid;if(!this._flags.some(e=>e.globalId===a&&e.type===t)){const r=this._createFlagProperty(e,t,null);this._flags.push(r),this.emit("add-flag-complete",{type:t})}this.emit("add-flag",{type:t})}async addFlagsOnLoad(){if(this._flags.length>0)return[];await l(()=>null!=this.view&&!this.view.updating);return(await Promise.all(this.flags.map(async e=>{if(!e.mapPoint)return null;const{type:t}=e,r=e.mapPoint.clone(),s="barrier"===t?T:H,i={graphic:this.graphicHandler.makeGraphic(r,s),state:"complete",tool:"point",toolEventInfo:null,type:"create"};try{return await this.queryFlagByHitTest(i,e.type,null),this.emit("add-flag-complete",{type:t}),null}catch(a){return this.emit("add-flag-error",{type:t}),"barrier"===t?"barrier":"starting-point"}}))).filter(e=>!e)}async addResultAreaToMap(e,t){if(this.view)if(e.resultArea.show=!0,t)this._resultAreaHandler?.addResultAreaToMap(t,this.view.map),this.emit("add-result-area",{graphic:t});else if(e.results){const t=await this.createResultAreaGraphic(e);t&&(e.resultAreaGraphic=t,this._resultAreaHandler?.addResultAreaToMap(t,this.view.map),this.emit("add-result-area",{graphic:t}))}}async addResultGraphicToView(e,t){const{view:r}=this,{results:s}=e;if(r&&s&&this.utilityNetwork)for(const i in s.aggregatedGeometry)if("line,multipoint,polygon".includes(i)){const a=i,l=s.aggregatedGeometry[a];if(null!=l){l.spatialReference=this.utilityNetwork.spatialReference,e.graphicEnabled=!0;const s=await this._geometryHandler.projectGeometry(l,r.spatialReference),i={globalid:e.trace.globalId};if(null!==s){const e=this.graphicHandler.makeGraphic(s,t.color,i,r.spatialReference);this._getGraphicLayer(C)?.add(e)}}}}addTerminal(e,t){const r=[...this._flags];r.forEach(r=>{r.globalId===t.globalId&&(t.selectedTerminals?.includes(parseInt(e,10))||r.selectedTerminals?.push(parseInt(e,10)))}),this._flags=r}async callTrace(){const e=this.traces.filter(e=>e.selected);return!!e.length&&(this.traceResults.length>0&&this.traceResults.forEach(e=>{this.removeResultGraphicFromView(e)}),this.traceResults=[],this.removeSelection(),await Promise.all(e.map(async(e,t)=>{const r=e,s=new F({gdbVersion:this.utilityNetwork?.gdbVersion,moment:this.utilityNetwork?.historicMoment,namedTraceConfigurationGlobalId:r.globalId,outSpatialReference:null,resultTypes:null,traceType:r.traceType,traceLocations:this._flags,traceConfiguration:null});await this.executeTrace(r,this.utilityNetwork?.networkServiceUrl,s).then(async e=>{if(e.hasOwnProperty("results")){const r={...e};if(null!==r.results){r.resultArea={...this.resultAreaProperties};const e=[...r.results.elements];r.results.elements.length=0;const s=new Map;for(const t of e)s.has(t.globalId)||(s.set(t.globalId,!0),r.results.elements.push(t));const i=[...this.traceResults];if(i.splice(t,0,r),this.traceResults=i,null!==r.results&&(this.selectOnComplete&&this.mergeSelection(!0,r.trace),this.showGraphicsOnComplete&&await this.addResultGraphicToView(r,r.graphicColor),this.enableResultArea)){const e=await this.createResultAreaGraphic(r);e&&(r.resultAreaGraphic=e,r.resultArea?.show&&await this.addResultAreaToMap(r,r.resultAreaGraphic))}}else{const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}this._activeProgress=!1}else{this._activeProgress=!1;const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}}).catch(e=>{throw this._activeProgress=!1,e})})),!0)}cancelAddFlagByHit(){this._sketchViewModel.cancel()}changeResultAreaColor(e,t){if(!e.resultArea)return;e.resultArea.color=t;const r=this._resultAreaHandler?.changeResultAreaColor(e.trace.globalId,t,this.view.map);e.resultAreaGraphic&&(e.resultAreaGraphic.symbol=r)}changeResultGraphicColor(e,t){const r=[...this.traceResults];r.length>0&&r.forEach(r=>{r.trace.globalId===t.trace.globalId&&(r.graphicColor=e,r.graphicEnabled=!0)}),this.traceResults=r,this.removeResultGraphicFromView(t),this.addResultGraphicToView(t,e)}changeFlagSymbol(e,t){this._flags.length>0&&this._flags.forEach(r=>{r.type===e&&t&&r.mapGraphic&&(r.mapGraphic.symbol=t)})}checkCanTrace(){const e={status:!0,issues:[]},t=this.traces.filter(e=>e.selected);t.length||(e.status=!1,e.issues.push("noTracesSelected"));this._flags.some(e=>"starting-point"===e.type)||(e.status=!1,e.issues.push("noStartingPoints"));return this._flags.filter(e=>null!==e.allTerminals).some(e=>!e.selectedTerminals.length)&&(e.status=!1,e.issues.push("noTerminalSelected")),e}checkSelectionExist(){return this._highlightHandler.some(e=>e)}clearResult(e){if(!this.view)return;let t=this.traceResults;if(t.length>0){const r=t.filter(t=>t.trace.globalId===e.globalId);r.length>0&&(this.removeResultGraphicFromView(r[0]),this.removeResultAreaFromMap(r[0])),t=t.filter(t=>t.trace.globalId!==e.globalId)}this.traceResults=t,0===t.length?(this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}createResultAreaGeometries(e,t,r){if(!this.view||!this.resultAreaProperties)return;let s;if(s="convexhull"===this.resultAreaProperties?.type?1===t.length&&(h(t[0])||u(t[0])&&1===t[0].points.length)?this._resultAreaHandler?.createBuffer(t,r,e.resultArea?.unit,!0):this._resultAreaHandler?.createConvexHull(t,e.resultArea?.distance,e.resultArea?.unit):this._resultAreaHandler?.createBuffer(t,r,e.resultArea?.unit,!0),!s)return;if(Array.isArray(s)){for(const t of s){const r=this.getResultAreaAttributes(e,t),s=this._resultAreaHandler?.createResultAreaGraphic(t,r,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);if(s)return s}return}const i=this.getResultAreaAttributes(e,s);return this._resultAreaHandler?.createResultAreaGraphic(s,i,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color)}async createResultAreaGraphic(e){if(e.results){const t=await this._createResultAreaInputGeometry(e.results);if(t.length>0){const r=Array(t.length).fill(e.resultArea?.distance),s=this.createResultAreaGeometries(e,t,r);return this.emit("create-result-area",{graphic:s}),s}}}executeTrace(e,t,r){const s=this._processFlags(r.traceLocations);return r.traceLocations=s,k(t,r,{timeout:this._traceTimeout}).then(t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success",date:new Date})).catch(t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message,date:new Date}))}async getNonspatialTraceLocationInitialFeature(){return new Promise((e,t)=>{this._clickHandler?.remove(),this._clickHandler=this._sketchViewModel.on("create",async r=>{if("complete"!==r.state)return;const s=this._getGraphicLayer(j);s&&r.graphic&&s.remove(r.graphic);const i=this.view?.toScreen(r.graphic?.geometry);if(!i)return;const a=await(this.view?.hitTest(i));if(a?.results.length){const r=a.results.find(e=>"graphic"===e.type&&this.utilityNetwork?.isUtilityLayer(e.layer));r?e(r):t(null)}}),this._sketchViewModel.create("point")})}getResultAreaAttributes(e,r){const{messages:s}=this,i=[],a=[];this._flags.forEach(e=>{const t=e.displayValue?.field+":"+e.displayValue?.value+";"+s.attributeStrings.globalid+":"+e.globalId+";"+s.attributeStrings.terminalid+":"+e.terminalId+";"+s.attributeStrings.x+":"+e.mapPoint?.x+";"+s.attributeStrings.y+":"+e.mapPoint?.y;"starting-point"===e.type?i.push(t):a.push(t)});const l=this.utilityNetwork?.gdbVersion;return{traceId:e.trace.globalId,traceName:e.trace.title,traceDescription:e.trace.description??"",startingPoints:i.toString(),barriers:a.toString(),version:l??void 0,username:t.credentials[0].userId,date:e.date,elementCount:e.results?.elements.length,functionResult:JSON.stringify(e.results?.globalFunctionResults),areaStatistic:r?this._geometryHandler.calculateArea(r,e.resultArea?.areaUnit):0}}getValidSources(){let e=[];const t=this.utilityNetwork?.dataElement?.domainNetworks??[];for(const r of t)e=e.concat(r.junctionSources),e=e.concat(r.edgeSources);return e}groupResultsByNetworkSource(e){return 0===e.length?[]:this._groupBy(e,"networkSourceId")}async loadUtilityNetwork(){const{view:e}=this;if(!e)return null;if(await e.when(),this.utilityNetwork){if(this.utilityNetwork.loaded||await this.utilityNetwork.load(),this.utilityNetwork instanceof _){try{const t=e.map;await t.loadAll()}catch(i){if("layer:unsupported-layer-type"!==i.name)throw i}finally{this._loadUNSupportItems()}return this.utilityNetwork}return null}const t=e.map,r=t.utilityNetworks?.at(0);if(r){if(await r.load(),this.utilityNetwork=r,!await q(r))throw new s("utility-network:no-user-type-extension","User type extension not found");try{await t.loadAll()}catch(i){if("layer:unsupported-layer-type"!==i.name)throw i}finally{this._loadUNSupportItems()}return r}return null}manageFilterBarrier(e,t){const r=[...this._flags];r.forEach(r=>{r.globalId===t.globalId&&"barrier"===t.type&&r.id===t.id&&(r.isFilterBarrier=e)}),this._flags=r}mergeSelection(e,t){let r=[];const s=[...this.traceResults],i=t.globalId;s.forEach(t=>{i===t.trace.globalId&&(t.selectionEnabled=e),t.selectionEnabled&&null!==t.results?.elements&&(r=[...r,...t.results?.elements??[]])}),this.selectResults([...new Set(r)])}async queryFeaturesById(e){const{view:t}=this;if(!t||!this.utilityNetwork)return null;const s=this.utilityNetwork.getObjectIdsFromElements(e),i={layerUrl:s[0].layerUrl,objectIds:s[0].objectIds,outFields:["*"]},a=t.map?.allTables.toArray().filter(e=>e?.parsedUrl?.path===s[0].layerUrl).filter(m)??[];this._getUniqueMapLayerViews(t).filter(({layer:e})=>e?.parsedUrl?.path===s[0].layerUrl).forEach(({layer:e})=>{"feature"!==e.type&&"subtype-group"!==e.type||a.push(e)});const l=(await Promise.all(a.map(async e=>{const s={layers:new r([e]),layerInfos:[i],returnGeometry:!0,outSpatialReference:t.spatialReference},[a]=await b(s,!1);return a}))).filter(({featureSet:e})=>e.features.length>0);return l.length>0?l:null}queryFlagByHitTest(e,t,r){return this._lookupFlagByHit(e).then(e=>{const{view:s}=this;if(!s)return!1;if(e.length>0){const s=[...this._flags],i=r;return e.forEach(e=>{const r=e.graphic,a=r.attributes.hasOwnProperty("GLOBALID")?r.attributes.GLOBALID:r.attributes.globalid;if(s.filter(e=>e.globalId===a).length<=0){const e=this.graphicHandler.getFlagGraphic(r.attributes.mapPoint,t,r,i);this._getGraphicLayer(B)?.add(e);const a=this._createFlagProperty(r,t,e);s.push(a)}else if(null!==r.attributes.percentAlong){const e=this.graphicHandler.getFlagGraphic(r.attributes.mapPoint,t,r,i);this._getGraphicLayer(B)?.add(e);const a=this._createFlagProperty(r,t,e);s.push(a)}}),this._flags=s,!0}return!1})}removeResultGraphicFromView(e){const{view:t}=this;if(!t)return;const r=this._getGraphicLayer(C)?.graphics;e.graphicEnabled=!1;const s=r?.filter(t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId);s?.forEach(e=>{this._getGraphicLayer(C)?.remove(e)})}removeFlag(e){const t=this._flags.filter(t=>{if(t.id!==e.id)return t});this._removeGraphic(e),this._flags=t}removeAllResultAreaGraphics(){this._resultAreaHandler?.removeAllResultAreaGraphics(this.view.map)}removeResultAreaFromMap(e){if(e.resultArea){e.resultArea.show=!1;const t=this._resultAreaHandler?.removeResultArea(e.trace.globalId,this.view?.map);t&&this.emit("remove-result-area",{graphic:t})}}removeSelection(){this._highlightHandler.forEach(e=>{e&&e.remove()}),this._highlightHandler=[]}removeTerminal(e,t){const r=[...this._flags];r.forEach(r=>{if(r.globalId===t.globalId&&t.selectedTerminals?.includes(parseInt(e,10))){const s=t.selectedTerminals.indexOf(parseInt(e,10));r.selectedTerminals?.splice(s,1)}}),this._flags=r}removeFlagsOnLoadWatcher(){this._watchHandler&&null!==this._watchHandler&&this._watchHandler.remove()}removeClickHandler(){this._clickHandler&&(this._sketchViewModel.cancel(),this._clickHandler.remove())}reset(){this._flags=[],this.traceResults=[];const e=[...this.traces];e.forEach(e=>{e.selected=!1}),this.traces=e,this.view&&(this._getGraphicLayer(j)?.removeAll(),this._getGraphicLayer(B)?.removeAll(),this._getGraphicLayer(C)?.removeAll(),this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]}),this.emit("reset"))}selectFeaturesById(e){const{view:t}=this;if(!t||!this.utilityNetwork)return;const r=this.utilityNetwork.getObjectIdsFromElements(e);this._getUniqueMapLayerViews(t).forEach(e=>{D(e)&&e.layer?.parsedUrl?.path===r[0].layerUrl&&V(e)&&this._highlightHandler.push(e.highlight(r[0].objectIds))})}selectResults(e){if(e.length>0){this.removeSelection();const t=this.groupResultsByNetworkSource(e),r=[];for(const e in t)this.selectFeaturesById(t[e]),r.push(this.queryFeaturesById(t[e]));Promise.all(r).then(e=>{this.emit("select-features",{resultSet:e})})}else this.removeSelection(),this.emit("clear-selection",{resultSet:[]})}selectTraces(e,t){const r=[...this.traces];r.forEach(r=>{t===r.globalId&&(r.selected=e)}),this.traces=r}selectTracesOnLoad(){this.utilityNetwork?.hasOwnProperty("sharedNamedTraceConfigurations")&&(this.traces=[...this.utilityNetwork.sharedNamedTraceConfigurations],this.traces.forEach(e=>{e.selected=!1,this.selectedTraces.includes(e.globalId)&&(e.selected=!0)}))}zoomToAsset(e){this.view?.goTo(e).catch(e=>console.error(e))}async _createResultAreaInputGeometry(e){if(null!=e.aggregatedGeometry)return this._geometryHandler.mergeAggregatedToGeometries(e.aggregatedGeometry);const t=this.groupResultsByNetworkSource(e.elements),r=[];for(const s in t)r.push(this.queryFeaturesById(t[s]));try{const e=await Promise.all(r),t=[];for(const r of e)if(r)for(const e of r)for(const r of e.featureSet.features)r.geometry&&t.push(r.geometry);return t}catch{return[]}}_loadUNSupportItems(){if(!this.utilityNetwork)return;const{map:e}=this.view,{messages:t}=this;this._populateOutfields(),this._createGraphicLayer(j),this._createGraphicLayer(B),this._createGraphicLayer(C),this._resultAreaHandler?.createGraphicLayer(e,t?.alertsStrings.genericResultHeader),this._validUNLayers=this._utilityHelper.getValidUtilityNetworkLayers(e,this.utilityNetwork),this._sketchViewModel=this.graphicHandler.initializeSketch(this.view,this._getGraphicLayer(j),this._validUNLayers)}_getUniqueMapLayerViews(e){const t=[],r=e.layerViews.filter(({layer:{type:e}})=>"feature"===e||"group"===e||"subtype-group"===e).toArray(),s=e=>{for(const r of e.layerViews)O(r)?s(r):t.push(r)};return r.forEach(e=>{switch(e.layer.type){case"group":O(e)&&s(e);break;case"subtype-group":t.push(e);break;default:t.some(t=>t.layer.id===e.layer.id)||t.push(e)}}),t}_processFlags(e){const t=[];return e.forEach(e=>{if(null!==e.selectedTerminals&&e.selectedTerminals.length>0)e.selectedTerminals.forEach(r=>{const s=new I({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:r,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)});else{const r=new I({globalId:e.globalId,percentAlong:e.percentAlong,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}}),t}_getDisplayField(e){return f(e?.sourceLayer)?this._getDisplayFieldBySublayer(e):this._getDisplayFieldByFeatureLayer(e)}_getDisplayFieldBySublayer(e){let t="",r="";const s=e.sourceLayer;t=this._checkParentForData(s,"displayField");for(const i in e.attributes){const a=i.toLowerCase();a===t?.toLowerCase()?(r=e.attributes[i],"assetgroup"===a||"assettype"===a?r=this._checkSubtype(s,s.subtypeCode):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))}return{field:t,value:r?.toString()??s.title}}_getDisplayFieldByFeatureLayer(e){const t=e.sourceLayer;let r=t.displayField,s="";for(const i in e.attributes){const a=i.toLowerCase();if(a===r?.toLowerCase())if(s=e.attributes[i],"assetgroup"===a||"assettype"===a){let a=e.attributes[t.typeIdField.toUpperCase()];a||(a=e.attributes[t.typeIdField.toLowerCase()]),r=t.typeIdField,s=this._checkSubtype(t,a),""===r&&(t.templates&&t.templates.length>0?(r=t.templates[0]?.name,s=t.templates[0]?.name):(r=t.displayField,s=e.attributes[i]))}else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t));else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t))}return{field:r,value:s?s.toString():""}}_checkSubtype(e,t){let r=t;if("subtype-sublayer"===e.type){const s=this._checkParentForData(e,"subtypes");s?.length>0&&s.forEach(e=>{e.code===t&&(r=e.name)})}else if(null!=e.types&&e.types.length>0){const s=e.types.filter(e=>e.id===t);s.length>0&&(r=s[0].name)}return r}_checkDomain(e,t,r){let s=r;const i=e.filter(e=>e.name.toLowerCase()===t.toLowerCase());if(i.length>0&&E(i[0].domain)&&i[0].domain?.codedValues){const e=i[0].domain.codedValues.filter(({code:e})=>e===r);e.length>0&&(s=e[0].name)}return s}_checkParentForData(e,t){return e.parent?.[t]??null}_defaultDisplayField(e,t){return e.trim()?e:t.templates&&t.templates?.length>0?t.templates[0].name:t.title}get _uniqueFlagId(){return this._flagId++}_groupBy(e,t){return e.reduce((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e),{})}async _lookupFlagByHit(e){const t=[];let r={};const s=e.graphic?.geometry,i=this.view?.toScreen(s),a=await(this.view?.hitTest(i,{include:this._validUNLayers}));if(!a?.results.length)return[];const l=a?.results.find(e=>null!==e.layer),n=l,c=n.graphic.geometry?.type,h=l?.layer,u=h.globalIdField??"globalid",p=h.objectIdField??"objectid";if(u&&!!n.graphic.attributes[u])r=n.graphic.attributes;else{const e=await(this.view?.whenLayerView(h)),t=e.createQuery();t.outFields=["assetgroup","assettype","globalid","objectid"],t.where=`${p} = ${n.graphic.attributes[p]}`,await o(()=>!e?.updating&&!e?.dataUpdating);const s=await(e?.queryFeatures(t)),i=s?.features[0],a=i?.attributes;r=a}const d=this._getDisplayField(n.graphic),g=n.mapPoint;let y={};if("point"===c||"polygon"===c){if(this.utilityNetwork){const e=this.utilityNetwork.getTerminalConfiguration(n.graphic);y={terminalId:e?e.terminals[0].id||null:1,isFilterBarrier:!1,allTerminals:e??null,selectedTerminals:[e?e.terminals[0].id||null:1],percentAlong:null,displayValue:d,mapPoint:g}}}else if("polyline"===c){const t=n.graphic.geometry;y={terminalId:null,isFilterBarrier:!1,allTerminals:null,selectedTerminals:null,percentAlong:this._geometryHandler.getPercentageAlong(t,e.graphic?.geometry,t.spatialReference),displayValue:d,mapPoint:g}}return n.graphic.attributes={...r,...y},t.push(n),t}_createFlagProperty(e,t,r){const s=new I;s.terminalId=e.attributes.terminalId,s.isFilterBarrier=e.attributes.isFilterBarrier,s.percentAlong=e.attributes.percentAlong,s.globalId=e.attributes.globalid||e.attributes.GLOBALID,s.type=t;const i=s;return i.details=e,i.mapGraphic=r,i.id=this._uniqueFlagId,i.allTerminals=e.attributes.allTerminals,i.selectedTerminals=e.attributes.selectedTerminals,i.displayValue=e.attributes.displayValue,i.mapPoint=e.attributes.mapPoint,i}_populateOutfields(){if(!this.view)return;const{map:e}=this.view,t=this.getValidSources(),r=e=>{"group"===e.type?e.layers.forEach(e=>{x(e)&&r(e)}):t.some(t=>t.layerId===e.layerId)&&e.fields.some(e=>"assetgroup"===e.name.toLowerCase())&&(e.outFields=["assetgroup","assettype","globalid","objectid"])};for(const s of e.layers)x(s)&&r(s)}_removeGraphic(e){this._getGraphicLayer(B)?.remove(e.mapGraphic)}_createGraphicLayer(e){const{map:t}=this.view;if(!t.findLayerById(e)){const t=new g({id:e,internal:!0,listMode:"hide",title:e});G(this.view,t)}}_getGraphicLayer(e){const{map:t}=this.view;if(t){const r=t.findLayerById(e);if(r&&M(r))return r}return null}};e([n()],$.prototype,"_activeProgress",void 0),e([n()],$.prototype,"_flags",void 0),e([n()],$.prototype,"traces",void 0),e([n()],$.prototype,"defaultGraphicColor",void 0),e([n()],$.prototype,"enableResultArea",void 0),e([n()],$.prototype,"flags",void 0),e([n()],$.prototype,"messages",void 0),e([n()],$.prototype,"messagesUnits",void 0),e([n()],$.prototype,"resultAreaProperties",null),e([n()],$.prototype,"selectedTraces",void 0),e([n()],$.prototype,"selectOnComplete",void 0),e([n()],$.prototype,"showGraphicsOnComplete",void 0),e([n()],$.prototype,"showSelectionAttributes",void 0),e([n({readOnly:!0})],$.prototype,"state",null),e([n()],$.prototype,"traceResults",void 0),e([n()],$.prototype,"utilityNetwork",void 0),e([n({value:null})],$.prototype,"view",null),$=e([c("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel")],$);const z=$;export{z as default};