@arcgis/core 5.2.0-next.27 → 5.2.0-next.28

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 (266) hide show
  1. package/WebLinkChart.js +1 -1
  2. package/arcade/Dictionary.js +1 -1
  3. package/arcade/Feature.js +1 -1
  4. package/arcade/Pixel.js +1 -1
  5. package/arcade/deepClone.js +1 -1
  6. package/arcade/featureset/support/FeatureSet.js +1 -1
  7. package/arcade/functions/geometry.js +1 -1
  8. package/arcade/languageUtils.js +1 -1
  9. package/assets/esri/core/libs/libtess/libtess-f32.wasm +0 -0
  10. package/assets/esri/core/libs/libtess/libtess-f64.wasm +0 -0
  11. package/assets/esri/core/workers/RemoteClient.js +1 -1
  12. package/assets/esri/core/workers/chunks/{5ee887fc6e1e0e70e02f.js → 1664434dc7a67c8ce453.js} +1 -1
  13. package/assets/esri/core/workers/chunks/1837f97f720d255a1694.js +1 -0
  14. package/assets/esri/core/workers/chunks/1893a4b344aa9b57aa8d.js +1 -0
  15. package/assets/esri/core/workers/chunks/209460f8aae3f9f8c9b8.js +1 -0
  16. package/assets/esri/core/workers/chunks/{316a3d5c7842b445e29e.js → 24704e70d1ce01ca4081.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{bf9eca7dd107bdb06614.js → 2665337e1b665e7e2b70.js} +1 -1
  18. package/assets/esri/core/workers/chunks/29a7321fd069253c2521.js +1 -0
  19. package/assets/esri/core/workers/chunks/{31c4128b23968575feca.js → 31d92ba9089617aa59ab.js} +1 -1
  20. package/assets/esri/core/workers/chunks/390f2beee8e3f2a302e4.js +1 -0
  21. package/assets/esri/core/workers/chunks/3eee32db0e9a5086b9a8.js +1 -0
  22. package/assets/esri/core/workers/chunks/{511b9c12a7479d39dac0.js → 409bc7d69b95f7a1634c.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{4e16d7fa2e6f11d082b5.js → 4ba4fd8fa31169760fee.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{268ee59800e64baa9682.js → 4be0c64bbf2449d57ea5.js} +1 -1
  25. package/assets/esri/core/workers/chunks/4fc32e60e63a9c8429b9.js +1 -0
  26. package/assets/esri/core/workers/chunks/{e8e7cd26c43f231cdea2.js → 5189413a83faf3480e29.js} +1 -1
  27. package/assets/esri/core/workers/chunks/5363c622a0571134cadd.js +1 -0
  28. package/assets/esri/core/workers/chunks/{88b08b386926ec889573.js → 548842f8ba9224b15ee4.js} +1 -1
  29. package/assets/esri/core/workers/chunks/5c63b38160c7d063b8af.js +1 -0
  30. package/assets/esri/core/workers/chunks/6183a26837dc087663ad.js +1 -0
  31. package/assets/esri/core/workers/chunks/{a9d477f90e5046400dd5.js → 654a6dc13ff5be88c8b9.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{1f03e34520746e432719.js → 67f44cab103d4411dcc5.js} +1 -1
  33. package/assets/esri/core/workers/chunks/697e0ce10d77b90d4fee.js +1 -0
  34. package/assets/esri/core/workers/chunks/{8f93e6fc11a158d4f1ee.js → 7335a762412bc8c15a2f.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{b2b342b06d502fc61ea5.js → 76789f46b2c65d219cf9.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{fae147d03ed723ab234d.js → 78f68f7534716956f5bc.js} +1 -1
  37. package/assets/esri/core/workers/chunks/7b290ac2e8a567ecae4a.js +1 -0
  38. package/assets/esri/core/workers/chunks/7c344c339743295d11d7.js +1 -0
  39. package/assets/esri/core/workers/chunks/{0098544169e429dd98d2.js → 7f1babbb7ead78201ab3.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{dadf85890961bcc205eb.js → 7fcf4f3b9131c7516524.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{292498a9c7d462d215c6.js → 86e61841df12dbe20a19.js} +1 -1
  42. package/assets/esri/core/workers/chunks/8aba35305368234c94f8.js +1 -0
  43. package/assets/esri/core/workers/chunks/{d670e134348954ce465d.js → 8b452383ba972b638a0c.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{a3ecde3794a7db3cf283.js → 8d90bef1091204fba0f1.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{a18cb809dd56c5537b3b.js → 8dbf9b1d8bb6817b19c1.js} +1 -1
  46. package/assets/esri/core/workers/chunks/8f16a358ed83d2264415.js +1 -0
  47. package/assets/esri/core/workers/chunks/{a454df829a72ab02c860.js → 8fd63cb38036f331a803.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{bbcad2fde838819ffc7b.js → 906f4c0fa8135e6c2f03.js} +1 -1
  49. package/assets/esri/core/workers/chunks/989937c120bdd676ec1e.js +1 -0
  50. package/assets/esri/core/workers/chunks/9ba705a6ddabca0f77b1.js +1 -0
  51. package/assets/esri/core/workers/chunks/a2357aae79bfbb91f125.js +1 -0
  52. package/assets/esri/core/workers/chunks/a3ca0649edb646da0918.js +1 -0
  53. package/assets/esri/core/workers/chunks/a9db775210ebeee41738.js +1 -0
  54. package/assets/esri/core/workers/chunks/acbc14395c31f6da509e.js +1 -0
  55. package/assets/esri/core/workers/chunks/{8bd4c43c34aacf3b07da.js → b10f36658aa77bc3a6cf.js} +1 -1
  56. package/assets/esri/core/workers/chunks/b18b6bb85e52b03b85e3.js +680 -0
  57. package/assets/esri/core/workers/chunks/b7458bd3a2f590f32111.js +1 -0
  58. package/assets/esri/core/workers/chunks/{d374cb2d17a2d11c500f.js → c46500cc95a84e2a5f7a.js} +1 -1
  59. package/assets/esri/core/workers/chunks/cc46261e01a985df5aab.js +1 -0
  60. package/assets/esri/core/workers/chunks/{de0c94defb90e1805081.js → d07261f3fb67b9a99369.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{04070767356c12026369.js → d61294dcc3ba41060d44.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{f3d331da3c61af5c5a2f.js → d8ae5b61b5ae71f4796c.js} +1 -1
  63. package/assets/esri/core/workers/chunks/e181d0f5562878b3dc01.js +1 -0
  64. package/assets/esri/core/workers/chunks/{d07068c44d560e4ce02e.js → e5d2fab228d54b18a8a8.js} +1 -1
  65. package/assets/esri/core/workers/chunks/f1d211904d5a1de93cb3.js +1 -0
  66. package/assets/esri/core/workers/chunks/{928b18e13e015330d44b.js → f68b84df093f2894210b.js} +1 -1
  67. package/assets/esri/core/workers/chunks/{3a35779cae6a11cde51b.js → f74b6952c888d92e479e.js} +1 -1
  68. package/assets/esri/core/workers/chunks/f847a4846c427f671455.js +1 -0
  69. package/assets/esri/core/workers/chunks/{66392ff750c28064040a.js → fe20683f442294eb111b.js} +1 -1
  70. package/assets/esri/images/portal/gaussiansplatlayer16.png +0 -0
  71. package/assets/esri/images/portal/knowledgegraphlayer16.png +0 -0
  72. package/assets/esri/images/portal/propresentation16.png +0 -0
  73. package/assets/esri/images/portal/urbanproject16.png +0 -0
  74. package/assets/esri/images/support/loading-throb.gif +0 -0
  75. package/assets/esri/layers/raster/formats/lerc-wasm.wasm +0 -0
  76. package/assets/esri/libs/basisu/basis_encoder.wasm +0 -0
  77. package/assets/esri/libs/dxtEncoder/dxt_encoder.wasm +0 -0
  78. package/assets/esri/themes/base/icons/style.scss +0 -0
  79. package/assets/esri/themes/base/icons/variables.scss +0 -0
  80. package/assets/esri/themes/base/images/files/archive-32.svg +0 -0
  81. package/assets/esri/themes/base/images/files/cad-32.svg +0 -0
  82. package/assets/esri/themes/base/images/files/code-32.svg +0 -0
  83. package/assets/esri/themes/base/images/files/csv-32.svg +0 -0
  84. package/assets/esri/themes/base/images/files/excel-32.svg +0 -0
  85. package/assets/esri/themes/base/images/files/generic-32.svg +0 -0
  86. package/assets/esri/themes/base/images/files/gpx-32.svg +0 -0
  87. package/assets/esri/themes/base/images/files/image-32.svg +0 -0
  88. package/assets/esri/themes/base/images/files/pdf-32.svg +0 -0
  89. package/assets/esri/themes/base/images/files/report-32.svg +0 -0
  90. package/assets/esri/themes/base/images/files/sound-32.svg +0 -0
  91. package/assets/esri/themes/base/images/files/text-32.svg +0 -0
  92. package/assets/esri/themes/base/images/files/video-32.svg +0 -0
  93. package/assets/esri/themes/base/images/files/word-32.svg +0 -0
  94. package/assets/esri/themes/base/images/files/zip-32.svg +0 -0
  95. package/assets/esri/themes/base/images/loading-throb.gif +0 -0
  96. package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +24 -0
  97. package/assets/esri/themes/base/widgets/_Bookmarks.scss +0 -0
  98. package/assets/esri/themes/dark/main.css +1 -1
  99. package/assets/esri/themes/light/main.css +1 -1
  100. package/assets/esri/themes/light/view.css +1 -1
  101. package/chunks/OITBlend.glsl.js +1 -1
  102. package/chunks/languageUtils.js +1 -1
  103. package/config.js +1 -1
  104. package/core/Loadable.js +1 -1
  105. package/core/colorUtils.js +1 -1
  106. package/core/has.js +1 -1
  107. package/core/workers/WorkerHandle.js +1 -1
  108. package/editing/sharedTemplates/SharedTemplateProvider.js +1 -1
  109. package/geometry/Mesh.js +1 -1
  110. package/geometry/support/meshUtils/loadExternal.js +1 -1
  111. package/identity/OAuthCredential.js +1 -1
  112. package/kernel.js +1 -1
  113. package/layers/AnnotationFeatureLayer.d.ts +2 -2
  114. package/layers/AnnotationFeatureLayer.js +1 -1
  115. package/layers/LinkChartLayer.js +1 -1
  116. package/layers/ParquetLayer.js +1 -1
  117. package/layers/PointCloudLayer.js +1 -1
  118. package/layers/SceneLayer.js +1 -1
  119. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  120. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  121. package/layers/graphics/editingSupport.js +1 -1
  122. package/layers/graphics/sources/MemorySource.js +1 -1
  123. package/layers/graphics/sources/ParquetSource.js +1 -1
  124. package/layers/mixins/EditBusLayer.js +1 -1
  125. package/layers/mixins/SceneService.js +1 -1
  126. package/layers/support/KMLSublayer.js +1 -1
  127. package/layers/support/ParquetFilesData.js +1 -1
  128. package/layers/support/TitleCreator.js +1 -1
  129. package/package.json +3 -3
  130. package/rest/knowledgeGraph/ReplicaDefinition.d.ts +62 -6
  131. package/smartMapping/support/adapters/FeatureLayerBinningAdapter.js +1 -1
  132. package/support/ArcadeExpression.js +1 -1
  133. package/support/basemapUtils.js +1 -1
  134. package/support/revision.js +1 -1
  135. package/versionManagement/VersionManagementService.js +1 -1
  136. package/versionManagement/VersionManager.js +1 -1
  137. package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
  138. package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementTool.js +1 -1
  139. package/views/2d/engine/ParentChildStage.js +1 -1
  140. package/views/2d/engine/Stage.js +1 -1
  141. package/views/2d/engine/ThrottledCanvas.js +2 -0
  142. package/views/2d/engine/webgl/Profiler.js +1 -1
  143. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  144. package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
  145. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  146. package/views/2d/layers/LayerView2D.js +1 -1
  147. package/views/2d/layers/MediaLayerView2D.js +1 -1
  148. package/views/2d/layers/TileLayerView2D.js +1 -1
  149. package/views/2d/layers/features/layerAdapters/AnnotationLayerAdapter.js +1 -1
  150. package/views/2d/layers/features/layerAdapters/DimensionLayerAdapter.js +1 -1
  151. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  152. package/views/2d/layers/features/layerAdapters/featureLayerAdapterUtils.js +2 -0
  153. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  154. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  155. package/views/3d/camera/constraintUtils/surfaceCollision.js +1 -1
  156. package/views/3d/camera/constraintUtils.js +1 -1
  157. package/views/3d/glTF/internal/Resource.js +1 -1
  158. package/views/3d/glTF/loader.js +1 -1
  159. package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
  160. package/views/3d/layers/I3SMeshView3D.js +1 -1
  161. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  162. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  163. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  164. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  165. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  166. package/views/3d/layers/graphics/tessellationUtils.js +1 -1
  167. package/views/3d/state/GoToOperation.js +1 -1
  168. package/views/3d/state/SurfaceCollisionConstraint.js +1 -1
  169. package/views/3d/state/ViewState.js +1 -1
  170. package/views/3d/state/ViewStateManager.js +1 -1
  171. package/views/3d/state/controllers/PointToPointAnimationController.js +1 -1
  172. package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
  173. package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
  174. package/views/3d/support/renderInfoUtils/polygon.js +1 -1
  175. package/views/3d/webgl/ManagedFBO.js +1 -1
  176. package/views/3d/webgl/RenderCamera.js +1 -1
  177. package/views/3d/webgl/RenderNode.js +1 -1
  178. package/views/3d/webgl-engine/effects/RenderNodes.js +1 -1
  179. package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphere.js +1 -1
  180. package/views/3d/webgl-engine/effects/clouds/CloudsComposition.js +1 -1
  181. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  182. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
  183. package/views/3d/webgl-engine/effects/fog/Fog.js +1 -1
  184. package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
  185. package/views/3d/webgl-engine/effects/glow/Glow.js +1 -1
  186. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  187. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  188. package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
  189. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  190. package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
  191. package/views/3d/webgl-engine/effects/transparency/OITBlendTechniqueConfiguration.js +1 -1
  192. package/views/3d/webgl-engine/lib/CutFillComputationRenderNode.js +1 -1
  193. package/views/3d/webgl-engine/lib/CutFillVisualizationRenderNode.js +1 -1
  194. package/views/3d/webgl-engine/lib/GPUPointOcclusionQuery.js +1 -1
  195. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  196. package/views/3d/webgl.js +1 -1
  197. package/views/VideoView.js +1 -1
  198. package/views/View2D.js +1 -1
  199. package/views/Viewport2DBaseMixin.js +1 -1
  200. package/views/analysis/ElevationProfile/ElevationProfileLineGroundComputation.js +1 -1
  201. package/views/draw/support/editingSessionUtils.js +1 -1
  202. package/views/popupAdapter.js +1 -1
  203. package/views/webgl/BufferObject.js +1 -1
  204. package/widgets/BasemapGallery/support/PortalBasemapsSource.js +1 -1
  205. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  206. package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
  207. package/widgets/BatchAttributeForm/css.js +1 -1
  208. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  209. package/widgets/BatchAttributeForm/interfaceUtils.js +1 -1
  210. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  211. package/widgets/BatchAttributeForm.js +1 -1
  212. package/widgets/Directions/DirectionsViewModel.js +1 -1
  213. package/widgets/Directions.js +1 -1
  214. package/widgets/Editor/EditorViewModel.d.ts +1 -1
  215. package/widgets/Editor.d.ts +11 -1
  216. package/widgets/Editor.js +1 -1
  217. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  218. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  219. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  220. package/widgets/FeatureTable.js +1 -1
  221. package/widgets/Features/FeaturesViewModel.js +1 -1
  222. package/widgets/LinkChartLayoutSwitcher/LinkChartLayoutSwitcherViewModel.js +1 -1
  223. package/widgets/Locate/LocateViewModel.js +1 -1
  224. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  225. package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
  226. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  227. package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
  228. package/widgets/OrientedImageryViewer/services/SuperimposeService.js +1 -1
  229. package/widgets/OrientedImageryViewer/support/MediaPrefetcher.js +1 -1
  230. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  231. package/widgets/Print/PrintViewModel.js +1 -1
  232. package/widgets/Print.js +1 -1
  233. package/widgets/TableList/ListItem.js +1 -1
  234. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  235. package/widgets/VersionManagement/VersionManagementViewModel.js +1 -1
  236. package/widgets/Widget.js +1 -1
  237. package/widgets/support/geolocationUtils.js +1 -1
  238. package/widgets/support/tests.js +1 -1
  239. package/assets/esri/core/workers/chunks/045f178fecc23839bfa8.js +0 -680
  240. package/assets/esri/core/workers/chunks/073ee52705ea326fecfb.js +0 -1
  241. package/assets/esri/core/workers/chunks/0e81b6aa64d5491870b2.js +0 -1
  242. package/assets/esri/core/workers/chunks/126a8c26618425790804.js +0 -1
  243. package/assets/esri/core/workers/chunks/1cb1f125dccbf8c8cac9.js +0 -1
  244. package/assets/esri/core/workers/chunks/2ed81f1e490cb7e73405.js +0 -1
  245. package/assets/esri/core/workers/chunks/32f26757e36704923286.js +0 -1
  246. package/assets/esri/core/workers/chunks/33e86dd1a54e447fa0e3.js +0 -1
  247. package/assets/esri/core/workers/chunks/35c87b0a4d4ee7ce302d.js +0 -1
  248. package/assets/esri/core/workers/chunks/36b904912cea1744d1c6.js +0 -1
  249. package/assets/esri/core/workers/chunks/3df5394b17e9659ecb8f.js +0 -1
  250. package/assets/esri/core/workers/chunks/4adfe7f8a8efe2cd8e80.js +0 -1
  251. package/assets/esri/core/workers/chunks/5396a894e6f8030ca088.js +0 -1
  252. package/assets/esri/core/workers/chunks/6849282c4a5cd733779d.js +0 -1
  253. package/assets/esri/core/workers/chunks/6adc17e6e287a365ad8d.js +0 -1
  254. package/assets/esri/core/workers/chunks/76ed8e455f6bd79e561c.js +0 -1
  255. package/assets/esri/core/workers/chunks/831455798b177678720c.js +0 -1
  256. package/assets/esri/core/workers/chunks/8ca88cfc0b9f84dc5832.js +0 -1
  257. package/assets/esri/core/workers/chunks/93b40245378ced43ca08.js +0 -1
  258. package/assets/esri/core/workers/chunks/98dfe31e8ed9b522eaff.js +0 -1
  259. package/assets/esri/core/workers/chunks/a40ede4d3375184f21fe.js +0 -1
  260. package/assets/esri/core/workers/chunks/af96cbc4fb7bef726635.js +0 -1
  261. package/assets/esri/core/workers/chunks/e73bb7c8de7412d9975c.js +0 -1
  262. package/assets/esri/core/workers/chunks/f23351a04643c464be84.js +0 -1
  263. package/assets/esri/core/workers/chunks/f912c173c58ae4299cbe.js +0 -1
  264. package/assets/esri/core/workers/chunks/f93facf47aba9b128fcc.js +0 -1
  265. package/views/2d/engine/ManagedCanvas.js +0 -2
  266. package/views/3d/state/controllers/SurfaceCollisionCorrectionController.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as i,isSome as r}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import{EventedMixin as l}from"../../core/Evented.js";import{makeHandle as c}from"../../core/handleUtils.js";import{equalsShallow as d}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as h}from"../../core/mathUtils.js";import{destroyMaybe as p,abortMaybe as m}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as v,throwIfAborted as y,waitTick as f}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{whenOnce as _,on as F,watch as b,syncAndInitial as M,initial as V,when as S}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as P}from"../../core/units.js";import{property as C,subclass as A}from"../../core/accessorSupport/decorators.js";import{isSerializable as k}from"../../core/support/jsonUtils.js";import{UpdatingHandles as T}from"../../core/support/UpdatingHandles.js";import O from"../../geometry/Extent.js";import L from"../../geometry/Point.js";import{projectAsync as G}from"../../geometry/projectionUtils.js";import E from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as j}from"../../geometry/support/centroid.js";import{isClockwise as R}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as x}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as B}from"../../geometry/support/webMercatorUtils.js";import D from"../../layers/GraphicsLayer.js";import H from"../../layers/MediaLayer.js";import{searchImages as z,getSortedLayerFeatures as N}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as U}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as q,computePolygonForInspection as W,resizePolygon as $,checkIfPolygonContainsSelectedPoint as Z}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as J}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{getMetersPerUnitOfSR as K,convertGeographicToWebMercator as Q}from"../../layers/orientedImagery/core/utils.js";import X from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Y}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as ee,getInitialAngle as te,convertPixelLocationToSphereVertex as ie,getUpdateElevationProps as re,getImageToWorldProperties as ae,getImageToWorldPanoramicProperties as se}from"../../layers/orientedImagery/transformations/utils.js";import oe from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as ne}from"../../layers/support/floorFilterUtils.js";import le from"../../layers/support/VideoElement.js";import ce from"../../views/MapView.js";import de from"../../views/draw/Draw.js";import{scale as ue}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as he}from"../../views/input/InputManager.js";import pe from"../PanoramicVideoViewer.js";import me from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as ge,videoMapViewConstraint as ve,fixedImageSize as ye,clockwiseDirections as fe,videoFitScaleTolerance as we,videoExtent as _e,invalidCameraHeading as Fe,sectorsInOrder as be,sampleExtent as Me,sectorsRadii as Ve}from"./constants.js";import{isFeatureAttachment as Se}from"./galleryUtils.js";import{crossSymbol as Ie,crossSymbol3D as Pe,measurementPolygonSymbol as Ce,polylineSymbolPanoramic as Ae,measurementPolylineSymbol as ke,cameraOverlaySymbol3D as Te,cameraOverlaySymbol as Oe,diamondSymbol as Le,diamondSymbol3D as Ge,activeSourcePointSymbol as Ee,sourcePointSymbol as je}from"./symbols.js";import{registryKeys as Re}from"./types.js";import{isNoAttachmentError as xe,extractHorizonAnglesFromMedia as Be,isTifOrMrf as De,filterOILLayerView as He,assignElevationSampleToFeatures as ze,filterByZ as Ne,createPanoramicMedia as Ue,createNonPanoramicMedia as qe,isSceneView as We,isGraphic as $e,calculateSegment as Ze,calculateDirection as Je}from"./utils.js";import{disableVideoZoomAndPan as Ke,getUpdatedConstraints as Qe,getUpdatedExtentPoints as Xe}from"./videoViewerUtils.js";import Ye from"./components/ImageViewer.js";import et from"./components/NavigationNode.js";import tt from"./components/OrientedImageryVideoViewModel.js";import{NoFeatureFoundWithObjectIdError as it}from"./navigation/errors.js";import{queryFeatureByObjectIds as rt}from"./navigation/queries.js";import{ImageMeasurementService as at}from"./services/ImageMeasurementService.js";import st from"./services/SuperimposeService.js";import{configureSketchTool as ot,extractFieldsFromDataCaptureLayer as nt,constructGraphicFromImageGeometry as lt}from"./support/dataCaptureUtils.js";import{removeZFromGeometry as ct,imageSpaceToPoint as dt}from"./support/geometryUtils.js";import ut from"./support/resolveMediaProps.js";import{isValidDataCaptureLayer as ht}from"./support/typeUtils.js";const pt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let mt=class extends(l(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=ge,this.cameraPitchThreshold=ge,this.clickAction="hittest",this.correctedLocationPointOnImage=null,this.videoViewModel=null,this.collectionId=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.depthImage=null,this.featureCache=[],this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:r,selectedPoint:a}=this;if(this.emit("popup-close"),r&&a){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(i),await this._loadDepthImage(i),await this._loadCurrentFeatureMedia(r,i)}catch(s){v(s)||(this.loadImageError(s),u.getLogger(this).error("#loadIImage()","error occured while loading image",s))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,i)=>{if(this.emit("popup-close"),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(i)}catch(r){v(r)||(this.loadImageError(r),u.getLogger(this).error("#loadIImage()","error occured while loading image",r))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.imageGeometryField=null,this.imageLocationToolState=!1,this.initialVideoMapViewExtent=null,this.imageMeasurementViewer=new Ye,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.locationPointOnImage=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new s,this.preloadMedia=!1,this.preloadMediaSize=5,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.superimposeViewEnabled=!1,this.defaultSuperimposeCameraLockEnabled=!0,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.drawAdapter=null,this.polylineDrawAction=null,this.scheduledFrameId=null,this.superimposeScheduledFrameId=null,this.superimposeDebounceTimeoutId=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t,i)=>{"default"===this.mode&&"image-loaded"!==this.state||await(this._adapter?.updateFootprint(e,t,i))},this.updateVideoFootprint=async e=>{this.mode.includes("video")&&this.videoElement?.content&&await(this._adapter?.updateVideoFootprint(e))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new ce({map:new Map,constraints:ve}),this.verticalFilterEnabled=!1,this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new Ye,this._initialCurrentCoverageUpdate=!0,this._locationViewModel=null,this._measurementService=null,this._mediaPrefetcher=null,this._navigationManager=null,this._overlays=new D({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._superimposePreviousCurrentCoverageVisible=null,this._superimposeService=new st({getMapPoint:(e,t)=>this.getMapPoint(e,t),pointToPixel:(e,t)=>this._transformationService.pointToPixel(e,t),overlays:this._overlays}),this._panoramicVideoViewer=new pe,this._panoramicViewer=new me,this._panoramicMeasurementViewer=new me,this._referencePointOnGround=null,this._referencePointOnImage=null,this._referenceTransformationService=null,this._sectorData=null,this._transformationService=null,this._featureToSector=null,this._updatingHandles=new T,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._mediaPrefetchTask=null,this._restoreSuperimposeMediaTask=null,this._superimposeScheduleController=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.addUpdatingPromise=e=>this._updatingHandles.addPromise(e),this.filterCapturedFeatures=e=>{const t=this.currentBestFeature?.attributes.objectId,i=this.layer?.imageReferenceField;if(!t||!e||!i)return;const r=this.overlayedMapFeatures.get(e);r?.forEach(e=>{const r=e.attributes??{},a=Object.keys(r).find(e=>e.toLowerCase()===i.toLowerCase());(a?r[a]:null)!==t&&(e.visible=!e.visible)})},this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find(({attributes:{imageID:t}})=>t===Number(e));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:i}=await t;return y(e),this.sketchAdapter=new i({viewModel:this}),this.sketchAdapter},this.loadImageFromFeature=(e,t,i)=>this._updatingHandles.addPromise(this._loadImageFromFeature(e,t,i)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.storePanoramicMeasurementViewer=e=>{this._panoramicMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadPanoramicVideoViewer=e=>{this._panoramicVideoViewer?.destroy(),this._panoramicVideoViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const i=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(i)this.currentBestFeature=i;else{const{layer:i,layerFloorFilterClause:a,layerTimeExtent:s}=this;if(!i)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const o=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(i,e,a,s,t));try{await o,await this.selectBestFeature(e,t)}catch(r){v(r)||(u.getLogger(this).error("oriented-imagery-viewer:show-image",r),"NoFeatureFoundWithObjectIdError"===r.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",r.message))}}},this.getSectorFeatureById=e=>this._suitabilities?.find(({feature:{attributes:{objectId:t}}})=>t===e),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{mode:i}=this;if("default"!==i&&"panoramic"!==i)throw new n("NavigationError","Navigation is only supported in 'default' and 'panoramic' modes.");const r=e=>"default"===i&&e.declaredClass.endsWith("NavigationManager")||"panoramic"===i&&e.declaredClass.endsWith("NavigationManagerPanoramic");if(null==this._navigationManager||!r(this._navigationManager)){p(this._navigationManager);const e="default"===i?import("./navigation/NavigationManager.js"):import("./navigation/NavigationManagerPanoramic.js");this._navigationManager=new(await e).default({viewModel:this})}return this._navigationManager.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(y(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),_(()=>{switch(this.mode){case"video":return"video-loaded"===this.state;case"panoramic-video":return this.panoramicVideoLoaded;default:return"image-loaded"===this.state}},t)),this.toggleImageAttributes=()=>{const{currentBestFeature:e,popupEnabled:i,layer:r,view:a}=this;if(this.emit("popup-close"),!(a&&e&&i&&r))return;const{attributes:s,geometry:o}=e,n=new t({geometry:o,attributes:s.toJSON(),origin:r.graphicOrigin,sourceLayer:r});this.emit("popup-open",{features:[n],location:s.location.clone()})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const i=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(i,t),this._groupFeaturesBySectors()},this._computeOverlayImageSize=()=>{const{mode:e}=this;return"video"===e?ye:"panoramic-video"===e?this._panoramicVideoViewer.imageSize:this.activeViewer?.imageSize},this._geometryToOverlayImageGeometry=async(e,t,i)=>{const{mode:r,videoViewModel:a,_panoramicVideoViewer:s}=this;if("video"===r)return await(a?.geometryToOverlayGeometry(e,t))??null;if("panoramic-video"===r){const a={feature:t,mode:r,imageSize:i,footprintExtent:this.footprintExtent};return await this._transformationService.geometryToImageGeometryForFeature(e,a,s.horizonAngles)}return await this._transformationService.geometryToImageGeometry(e)},this._createViewClickHandle=()=>{if(this.removeHandles(Re.click),this.disabled||null==this.view)return;const e=this.mapImageConversionToolState&&("image-loaded"===this.state||"video-loaded"===this.state&&"video"===this.mode&&!!this.videoViewModel?.videoPaused||this.panoramicVideoLoaded&&"panoramic-video"===this.mode&&this.panoramicVideoPaused)?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,he.DEFAULT),Re.click)},this._createImageClickHandle=()=>{this.removeHandles(Re.imageClick),this.videoViewModel?.syncMapImageConversionHandle();const{mapImageConversionToolState:e,mode:t,footprintExtent:i,panoramicVideoLoaded:r}=this,s="panoramic-video"===t?this._panoramicVideoViewer:this.activeViewer,o=s?.imageSize;if(!e||"none"===t||"video"===t||!o||!i)return;const n="panoramic-video"===t,l=this._getActiveFeatureForCurrentMode(),d=!n||r&&this.panoramicVideoPaused;if(!l||!d)return;const u=s.clickAction;this.clickAction="pixel-location";const h=c(()=>{this.clickAction=u});let p=null;const m=F(()=>s,"pixel-location",e=>{this.plotReferencePointOnImage(e),p?.abort(),p=a(async r=>{if(!e)return;const a=this._getActiveFeatureForCurrentMode();if(!a)return;const s={feature:a,mode:t,imageSize:o,footprintExtent:i};let l=n?await this.getMapPointForFeature(e,s,{signal:r}):await this._transformationService.pixelToMapPoint(e);const c=this.view?.spatialReference;l&&!ee(!c,l.spatialReference.equals(c))&&(l=await G(l,c,{signal:r})),y(r),this.plotReferencePointOnGround(l)})});this.addHandles([m,h],Re.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(Re.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),Re.triangularImageClick)},this._enablePan=()=>{this.removeHandles(Re.videoPanHandles)},this._disablePan=()=>{this.removeHandles(Re.videoPanHandles),this.addHandles(Ke(this.videoMapView),Re.videoPanHandles)},this._handleImageHitTestResponse=async e=>{const{layer:t,overlayedCameraLocations:i}=this;if(!t)return;const r=e.results.find(({graphic:e,graphic:{attributes:r}})=>i.includes(e)&&r&&!r[t.imageReferenceField]&&!r[t.imageGeometryField]);if(!r)return;const a=r.graphic.attributes[t.objectIdField];await this.showImageByObjectId(a)},this._loadCurrentFeatureMedia=async(e,t)=>{if("video"===this.mode)return this._initializeVideo(),void this.videoViewModel?.playVideoFromSelectedLocation(e);"panoramic-video"!==this.mode?await this._loadImage(t):await this._loadVideo(t)},this._loadDepthImage=async e=>{const{currentBestFeature:t,layer:i,depthImageNotSupported:r}=this;if(this.depthImage?.destroy(),this.depthImage=null,!i||!t||r)return;const{depthImage:a}=t.attributes;if(!a)return;const s=(await import("./services/DepthImageService.js")).default;y(e),this.depthImage=new s({url:a});try{await this.depthImage.load(e)}catch(o){v(o)||(u.getLogger(this).error("error occurred while loading depth image",o),this.depthImage?.destroy(),this.depthImage=null)}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:r}=this;if(this.clearGraphics(),i&&t&&"none"!==r&&"video"!==r&&"panoramic-video"!==r)try{await this.loadImageFromFeature(i,t,e),y(e),await this.transformAndPlotSelectedLocation(e)}catch(a){v(a)||this.loadImageError(a)}},this._loadVideo=async e=>{const{currentBestFeature:t,mode:i,selectedPoint:r}=this,a=t?.attributes.imagePath;if(!t||"panoramic-video"!==i||!a)return;const{attributes:s}=t,{cameraPitch:o,cameraOrientation:n,location:l}=s,c=l.spatialReference.isWGS84&&4!==n?.type?B(l):new L(l);try{this._panoramicVideoViewer.viewModel.video&&(this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.viewModel.videoPaused=!0),this._panoramicVideoViewer.videoSource=a;let t=0;c&&r&&(t=await te(c,r)-t),this._panoramicVideoViewer.pitch=o??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),y(e)}catch(d){v(d)||this.loadImageError(d)}},this._loadImageFromFeature=async(e,t,i)=>{const{mode:r}=this;if("default"!==r&&"panoramic"!==r)return;let a;try{a=await ut(t.attributes,e,i),y(i)}catch(f){if(v(f))return;return xe(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${e.objectIdField}: ${t.attributes.objectId}`)):(u.getLogger(this).error(f,{[e.objectIdField]:t.attributes.objectId,layer:e}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${e.objectIdField} ${t.attributes.objectId}`))}if(!a)return;const{mediaUrl:s,datasetFormat:o,rotation:n,searchParams:l,location:c,cameraHeading:d,matrix:h,cameraPitch:p,getDataSetFormatError:m}=a,g=`${t.attributes.objectId}`;try{let a=this._mediaPrefetcher?.getCachedMedia(g);if(!a){const i=this.navigationNodes.find(e=>e.id===t.attributes.objectId);if(i){try{await(this._mediaPrefetcher?.startPrefetchForNode(i,e))}catch(w){}a=this._mediaPrefetcher?.getCachedMedia(g)}}if(a){if("panoramic"===r){const e=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;let r=0;return c&&this.selectedPoint&&(r=await te(c,this.selectedPoint)-r),await e.loadMedia(a,i),this.selectedPoint?e.set({yaw:r,pitch:p}):"viewAngle"in t.attributes&&Number.isFinite(t.attributes.viewAngle)&&e.set({yaw:t.attributes.viewAngle,pitch:p}),void(this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i))}return await this._setImageSource(this.triangularMeasurementActive?this.imageMeasurementViewer:this._imageViewer,a,i),void(this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i))}}catch(w){}m&&u.getLogger(this).warn("error occurred while getting dataset format",m),"panoramic"===r?await this.loadPanoramicMediaSource({lookAt:{yaw:this.selectedPoint?await te(c,this.selectedPoint):"viewAngle"in t.attributes&&Number.isFinite(t.attributes.viewAngle)?t.attributes.viewAngle:0,pitch:p},extension:o?.toUpperCase(),url:s,cameraHeading:d,matrix:h},i):await this.loadMediaSource({datasetFormat:o?.toUpperCase(),url:s,customParameters:l,rotation:n},i),this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i)},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:i,mode:r}=this;if(this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics(),i&&t&&"none"!==r&&"video"!==r&&"panoramic-video"!==r)try{await this.loadImageFromFeature(i,t,e),y(e)}catch(a){v(a)||this.loadImageError(a)}},this._loadMediaPrefetcher=async e=>{if(!this._mediaPrefetcher){const{default:t}=await import("./support/MediaPrefetcher.js");y(e),this._mediaPrefetcher=new t({maxEntries:this.preloadMediaSize*fe.length})}return this._mediaPrefetcher},this._loadViewAdapter=async e=>{const{view:t}=this;if(this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");y(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");y(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{if(e.stopPropagation(),e.preventDefault(),e.mapPoint){const t=e.mapPoint;t.x=x(t.x,t.spatialReference),this.plotMapPoint(e.mapPoint)}},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:i,currentBestFeatureMeasurementImage:r,triangulatedMeasurementGraphic:a}=this;t&&i&&r&&a&&"active"!==t.state&&(t.update([a],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._updateInteraction=()=>{const e=this.videoMapView.extent;if(!e)return;const{minScale:t}=this.videoMapView.constraints,i=this.videoMapView.scale<t-we,r=Qe(e);i&&!!r?(this._enablePan(),this.videoMapView.constraints.geometry=r):i?(this._disablePan(),this.videoMapView.constraints.geometry=null):(this.initialVideoMapViewExtent&&!this.videoMapView.extent.equals(this.initialVideoMapViewExtent)&&(this.videoMapView.extent=this.initialVideoMapViewExtent),this._disablePan(),this.videoMapView.constraints.geometry=null)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=a(async t=>{const{pointerType:i,button:r,mapPoint:a}=e;if("mouse"===i&&0!==r||!a)return;e.stopPropagation(),e.preventDefault();const{view:s,layer:o}=this;if(s){if(o){if(this.shouldShowSelectedImage){const i=s.hitTest(e,{include:[o]});this._updatingHandles.addPromise(i);const r=await i;return y(t),await this._processHitTestResults(o,r,{signal:t})}return this._updatingHandles.addPromise(this.loadBestImage(a,{signal:t}))}this.setMessage("noLayerSelected","info")}})},this.plotSelectedPointOnImage=async(e,i)=>{if(await f(i),!e)return;const r=new L({...k(e)?e.toJSON():e});if("default"===this.mode)r.x-=.5,r.y=.5-r.y,r.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:r,symbol:Ie}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i,media:r}=this._panoramicViewer;if(!i||!r)return;const a=Be(r),s=ie(e,...i,a);this._crossSymbol=new t({geometry:new L(s,E.WebMercator),symbol:Pe}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([b(()=>this.view,()=>this.load(),M),b(()=>this.view?.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},V),b(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},V),b(()=>[this.state,this.panoramicVideoLoaded,this.mapImageConversionToolState,this.view,this.disabled,this.panoramicVideoPaused,this.videoViewModel?.videoPaused],(e,t)=>{const i=e[2],r=t?.[2];r&&!i&&(this.plotReferencePointOnGround(null),this.clearReferencePointOnImage()),this._createViewClickHandle(),this._createImageClickHandle()},M),b(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},M),b(()=>[this.state,this.imageLocationToolState,this.view],()=>{this._initializeMeasurementService(),this._initializeLocationViewModel()},M),b(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},M),b(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},M),b(()=>[this.superimposeViewEnabled,this.defaultSuperimposeCameraLockEnabled,this.superimposeViewSupported,this.currentBestFeature,this.mode,this.state,this.view?.type],()=>{this._shouldDisableUnsupportedSuperimposeView()?this.superimposeViewEnabled=!1:this._hasActiveSuperimposeCameraContext()?this._updateSuperimposedImage():this._resetInactiveSuperimposeState()},M),b(()=>this._getSuperimposeCameraWatchState(),()=>this._handleSuperimposeCameraChange(),M),b(()=>this.currentBestFeature,async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=a(async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}])),await this._featureChangedTask.promise},{sync:!0}),b(()=>[this.currentNode,this.preloadMedia,this.navigationMode],()=>{this._mediaPrefetchTask?.abort(),this._mediaPrefetchTask=a(async e=>{this.preloadMedia&&null!=this.navigationMode?(this._mediaPrefetcher??=await this._loadMediaPrefetcher({signal:e}),y(e),"directional"===this.navigationMode?this._mediaPrefetcher.enqueueDirectionalPrefetch(this.layer,this.currentNode,this.preloadMediaSize):this._mediaPrefetcher.enqueueSequentialPrefetch(this.layer,this.currentNode,this.preloadMediaSize)):this._mediaPrefetcher?.clear()})},M),b(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{m(this._featureChangedTask),t&&e!==t&&(this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this._measurementService?.resetMeasurementVectors()),this._featureChangedTask=a(async i=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:i}),y(i),this._reorderTriangularSketchLayer()})},M),b(()=>this.triangularMeasurementActive,(e,t)=>{t&&!e&&(this._measurementService?.resetMeasurementVectors(),this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearImage(),this._panoramicMeasurementViewer.clearGraphics())}),b(()=>this.mode,e=>{switch(this.removeHandles(Re.interactionHandles),e){case"default":this.addHandles(b(()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null},e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=a(async t=>{await this.updateFootprint(e,void 0,{signal:t})}))},{...M,equals:(e,t)=>i(e,t,d)}),Re.interactionHandles);break;case"video":this.addHandles(b(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:i}=this;if(e&&t?.loaded&&i)return{videoExtent:_e,bestFeatureFootprint:i}},e=>{e?.videoExtent&&e?.bestFeatureFootprint&&(m(this._updateFootprintTask),this._updateFootprintTask=a(async t=>{const i={points:e.videoExtent,feature:void 0,scale:void 0,options:{signal:t}};await this.updateVideoFootprint(i)}))},{...M,equals:(e,t)=>i(e?.videoExtent,t?.videoExtent,d)&&e?.bestFeatureFootprint===t?.bestFeatureFootprint}),Re.interactionHandles);break;case"panoramic":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:i}=this,{imageSize:r,vfov:a,hfov:s,pitch:o,yaw:n}=i;return e&&r&&!t.includes("loading")&&null!=a&&null!=s&&null!=o&&null!=n?[a,s,n,o]:null},e=>{if(!e||this.state.includes("loading"))return;const[t,i,r,s]=e;this.currentNode&&(this.currentNode.currentHeading=r,this.currentNode.currentPitch=s),m(this._updateFootprintTask),this._updateFootprintTask=a(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,d)}),Re.interactionHandles);break;case"panoramic-video":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:i}=this,{imageSize:r,vfov:a,hfov:s,pitch:o,yaw:n,viewModel:l}=i,c=l.closestFeature??e;return c&&r&&!t.includes("loading")&&null!=a&&null!=s&&null!=o&&null!=n?[a,s,n,o,c]:null},e=>{if(!e)return;const[t,i,r,s,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=a(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s,feature:o,horizonAngles:this._panoramicVideoViewer.horizonAngles},{signal:e}),y(e),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,d)}),Re.interactionHandles)}},M),b(()=>[this.brightness,this.contrast,this.sharpness],()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:r,sharpness:a}=this;"default"===r&&(e.brightness=t,e.contrast=i,e.sharpness=a)},M),b(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),b(()=>this.activeViewer,e=>{this.removeHandles(Re.hittestHandles),e&&this.addHandles(F(()=>e,"hittest-response",this._handleImageHitTestResponse),Re.hittestHandles)}),b(()=>this.videoMapView.extent,async()=>{this._scheduleVideoInteractionUpdate();const e=this.videoViewModel?.closestFeature;e&&(m(this._updateFootprintTask),this._updateFootprintTask=a(async t=>{const i={points:this.videoExtentPoints,feature:e,options:{signal:t}};await this.updateVideoFootprint(i)}))}),b(()=>[this.videoMapView.interacting,this.videoMapView.navigating,this.videoMapView.scale],()=>{this._scheduleVideoInteractionUpdate()},{initial:!0}),S(()=>null!=this.videoMapView.extent,()=>{this.initialVideoMapViewExtent=this.videoMapView.extent},{once:!0})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this._abortSuperimposeSchedule(),this.currentBestFeature=null,this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this._restoreSuperimposeMediaTask=m(this._restoreSuperimposeMediaTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=p(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this.videoViewModel=p(this.videoViewModel),this._locationViewModel=p(this._locationViewModel),this._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this.clearReferencePointOnImage(),this._superimposeService.destroy(),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy(),this._panoramicMeasurementViewer.destroy(),this._mediaPrefetcher?.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get activeTriangulatedViewer(){switch(this.mode){case"default":return this.imageMeasurementViewer;case"panoramic":return this._panoramicMeasurementViewer;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every(e=>0===e)??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",h(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",h(e,-10,10))}get currentNode(){const{currentBestFeature:e,navigationNodes:t}=this;return t.find(t=>t.id===e?.attributes.objectId)}get depthImageNotSupported(){if(this.currentBestFeature?.attributes.depthImage)return!De(this.currentBestFeature.attributes.depthImage)}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return De(t)||Se(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===Fe}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(He(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ne(e):null}get layerTimeExtent(){return this.layerView?.timeExtent??null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const t=e.orientedImageryType;if(t?.includes("video"))return t.includes("360")?"panoramic-video":"video";const{horizontalFieldOfView:i,isSpherical:r}=e;return 360===i||r?"panoramic":"default"}get panoramicVideoLoaded(){const{mode:e,_panoramicVideoViewer:t}=this,{videoLoaded:i}=t.viewModel;return("panoramic-video"===e&&!0===i)??!1}get overlayGraphicsEnabled(){const{mode:e,state:t,panoramicVideoLoaded:i,videoViewModel:r,panoramicVideoPaused:a}=this;return"image-loaded"===t||"video"===e&&"video-loaded"===t&&!0===r?.videoPaused||"panoramic-video"===e&&i&&a}get panoramicVideoPaused(){return!!this._panoramicVideoViewer.viewModel.videoPaused}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?be.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",h(e,0,1))}get superimposeViewSupported(){return"default"===this.mode||"panoramic"===this.mode}get sketchGraphicsLayer(){const{sketch:e}=this;return"graphics"===e?.layer?.type?e.layer:void 0}get state(){const{mode:e,_updatingHandles:{updating:t},_featureChangedTask:i}=this;if(!this.isFulfilled()||t||!1===i?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map(({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:r}})=>{const a=e?.trim();return De(a)||Se(a)?{url:a,objectId:t,rotation:(i??0)+(r??0)}:null}).filter(r)):null}get videoExtentPoints(){const e=Xe(this.videoMapView.extent);return e.length?e:_e}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new D({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new D({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}updateSuperimposeZOffset(e){this._superimposeService.updateZOffset(e)}setDefaultSuperimposeZOffsetPercentage(e){this._superimposeService.setDefaultZOffsetPercentage(e)}setPanoramicSuperimposeRadiusPercentage(e){this._superimposeService.setPanoramicRadiusPercentage(e)}updateDefaultSuperimposeCameraLock(e){this.defaultSuperimposeCameraLockEnabled=e,this.superimposeViewEnabled&&"default"===this.mode&&(e?this._adapter?.enableDefaultSuperimposeNavigation?.():this._adapter?.disableDefaultSuperimposeNavigation?.())}beforeLoad(e=!0){this.emit("popup-close"),e&&(this.displayMessage=null),this._abortSuperimposeSchedule(),this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._restoreSuperimposeMediaTask=m(this._restoreSuperimposeMediaTask),this._superimposeService.clear(),this._overlays?.removeAll()}async calculateLocationAccuracy(e){return this._measurementService?.calculateLocationAccuracy(e)}clearLocationPointOnImage(e=!1){this.locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this.locationPointOnImage),this._panoramicViewer.removeGraphic(this.locationPointOnImage),this.locationPointOnImage=p(this.locationPointOnImage)),this.correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this._panoramicMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this.correctedLocationPointOnImage=p(this.correctedLocationPointOnImage))}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:i,dataCaptureLayer:r}=this;if(!i)throw pt();ot(r,e,i),await i.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw pt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw pt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw pt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw pt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw pt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw pt();return this.sketch.update(e,t)}filterByFootprints(e,t,i=!1){const r=[],a=[],s=[];return e.forEach(e=>{const{layer:{coveragePercent:o},attributes:n}=e;let l;const{polygon:c,frustum:d}=q(n);if(l=c.clone(),n.isInspection&&(l=W(n)),o&&(l=$(l,o)),i||!t||Z(l,t)){s.push(e);const{geometry:t,objectId:i,cameraHeight:o,cameraHeading:l}=n,u=t.clone();u.z=o/K(t.spatialReference),u.imageID=i,this.pointSources.push(u),l!==Fe&&(r.push(c),d&&a.push(d))}}),{features:s,polygons:r,frustums:a}}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then(({features:e})=>t.applyEdits({deleteFeatures:e}))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[be[e]],i=t?.at(0);i&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(i):this._updateCurrentBestFeature(i))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const r=this._sectorData?.[t],a=r?.at(i);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!v(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=Q(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}async loadHeightMeasurementAdapter(e){if(!this.drawAdapter){const t=import("./adapters/draw/HeightMeasurementAdapter.js"),{default:i}=await t;if(y(e),this.drawAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.drawAdapter.viewModel.isResolved())return}return this.drawAdapter}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:i}=await t;y(e),this.sketch=new i({layer:this._defaultGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:i}=await t;if(y(e),this.sketchAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async processFeatureResponse(e,t,i){const{features:r}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(r))return;const{features:a,polygons:s,frustums:o}=this.filterByFootprints(r,t,i?.skipFilter);if(!this._checkFeatures(a))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,a,i);y(i),await this._updateElevationOfSelectedPointAndLocations(a,t,n),y(i),ze(a,n);let l=a;if(this.layer?.verticalSearchRange&&this.layer.hasZ&&this.verticalFilterEnabled&&(l=Ne(a,t,this.layer.verticalSearchRange),!l.length))return void this.setMessage("noImageAtElevation","info");const c=this._processSuitableFeatures(l,t);this.updateSuitabilities(c,i?.loadBestImage)}async processFeatureElevation(e,t,i){if(!t)return;const{features:r,polygons:a}=this.filterByFootprints(e,t,!0);if(!r?.length)return;const s=await this.processElevationSample(a,r,i);return y(i),s}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:i,sketchAdapter:r,activeViewer:a,mode:s}=this;if(!i||!r||!a||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(i.defaultCreateOptions.defaultZ=0),await i.create(e),"panoramic"===s){const{drawOperation:e}=i.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=Ce(o),this.sketch.polylineSymbol="panoramic"===s?Ae:ke(o,2.5))}async startHeightMeasurement(){this.displayNewMeasurementButton=!1,this.draw??=new de({view:this.activeViewer?.imageRenderer}),this.polylineDrawAction=this.draw.create("polyline"),await this.loadHeightMeasurementAdapter()}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:i,overlayedCameraLocations:a,layer:s,mode:o,layerFloorFilterClause:n,layerTimeExtent:l,videoViewModel:c,_panoramicVideoViewer:d}=this,u="video"===o,h="panoramic-video"===o,p=this._getActiveFeatureForCurrentMode(),m=this._computeOverlayImageSize();if(!(m&&p&&s&&"none"!==o&&this.overlayGraphicsEnabled))return;const{polygon:g}=q(p.attributes);if(u?c?.removeOverlayGraphics(a.toArray()):h?d.removeManyGraphics(a.toArray()):i?.removeManyGraphics(a.toArray()),a.removeAll(),e){const{features:e}=await s.queryFeatures({where:I(`${s.objectIdField} <> ${p.attributes.objectId}`,I(s.definitionExpression,n)),geometry:g,returnGeometry:!0,outFields:[s.objectIdField],timeExtent:l}),v=await Promise.all(e.map(async e=>{const{attributes:i,geometry:r}=e;if("point"!==r?.type)return null;const a=await this._geometryToOverlayImageGeometry(r,p,m);if(!a)return null;const s="panoramic"===o||"panoramic-video"===o?Te():Oe();return new t({attributes:i,symbol:s,geometry:a})}));a.addMany(v.filter(r)),u?c?.addOverlayGraphics(a.toArray()):h?d.addManyGraphics(a.toArray()):i?.addManyGraphics(a.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),"video"!==this.mode?"panoramic-video"!==this.mode?this.activeViewer?.addManyGraphics(t.toArray()):this._panoramicVideoViewer.addManyGraphics(t.toArray()):this.videoViewModel?.addOverlayGraphics(t.toArray())}async overlayMapFeatures(e,i=!1){const{activeViewer:a,mode:o,layer:n,videoViewModel:l,_panoramicVideoViewer:c}=this,d="video"===o,h="panoramic-video"===o,p=this._getActiveFeatureForCurrentMode(),m=this._computeOverlayImageSize();if(!(m&&p&&"none"!==o&&this.overlayGraphicsEnabled&&n))return;const{polygon:g}=q(p.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=nt(e,n.imageGeometryField,n.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(w){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",w)}const{features:v}=await e.queryFeatures({geometry:g,returnGeometry:!0,outFields:["*"]}),y=await Promise.all(v.map(async r=>{const s=r.symbol?.clone()??e.renderer?.getSymbol(r)?.clone(),{attributes:n,geometry:g}=r,{imageGeometryField:v,oiObjectIdField:y}=this;if(v&&y&&ht(e,v,y)&&`${n[y]}`==`${p.attributes.objectId}`)try{const r=h?c.horizonAngles:Be(a?.media),u=lt(n,v,e,i,m,d?"default":o,s,r);if(!d)return u;const p=u.geometry;if(!p)return null;const g=l?.imageGeometryToOverlayGeometry(p);return g?new t({attributes:n,layer:e,symbol:u.symbol,geometry:g,visible:u.visible}):null}catch(w){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:w,feature:r,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}if(!g)return null;const f={feature:p,imageSize:m,footprintExtent:this.footprintExtent},_=await this._geometryToOverlayImageGeometry(g,f.feature,f.imageSize);return _?new t({attributes:n,layer:e,symbol:s,geometry:_,visible:e.visible&&i}):null})),f=new s(y.filter(r));("video"!==o&&"panoramic-video"!==o||this.overlayGraphicsEnabled)&&this.overlayGraphicsOnImage(`${e.id}`,f)}getDepthAt(e){const{activeViewer:t,currentBestFeature:i,mode:r,state:a,depthImage:s}=this,o=t?.imageSize;if(!o||!i||"none"===r||a.includes("loading"))return u.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!s?.loaded)return u.getLogger(this).error("oriented-imagery-viewer:get-depth-at","Depth image is not loaded"),this.emit("depth-image-service:not-loaded"),null;const n=(Array.isArray(e)?e:[e]).map(e=>s.depthAt(e,{width:o[0],height:o[1]})??null);return Array.isArray(e)?n:n[0]}getActiveSectors(){return be.filter(e=>this._sectorData?.[e]?.length)}async getPixelLocationForFeature(e,t,i){return(await this._transformationService.pointToPixelForFeature([e],t,i))[0]}async getPixelLocationsForFeature(e,t,i){return await this._transformationService.pointToPixelForFeature(e,t,i)}async plotMapPoint(e){this.plotReferencePoint(e);const t=this._getActiveFeatureForCurrentMode();if(t)return this.transformAndPlotReferencePointOnImage({feature:t,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new L({...e.toJSON()}),symbol:Le}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){switch(this.mode){case"video":return void this._plotReferencePointOnVideo(e);case"panoramic-video":return void this._plotReferencePointOnPanoramicVideo(e);case"default":return void this._plotReferencePointOnDefaultImage(e);case"panoramic":return void this._plotReferencePointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){const{mode:e}=this;this.overlayedMapFeatures.forEach(t=>{const i=t.toArray();switch(e){case"video":this.videoViewModel?.removeOverlayGraphics(i);break;case"panoramic-video":this._panoramicVideoViewer.removeManyGraphics(i);break;default:this.activeViewer?.removeManyGraphics(i)}}),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e),{mode:i}=this;if(!t?.length)return;const r=t.toArray();switch(i){case"video":this.videoViewModel?.removeOverlayGraphics(r);break;case"panoramic-video":this._panoramicVideoViewer.removeManyGraphics(r);break;default:this.activeViewer?.removeManyGraphics(r)}this.overlayedMapFeatures.delete(e)}reset(){const{mode:e}=this;"default"===e||"panoramic"===e?this.resetImage():"video"===e?this.resetVideo():"panoramic-video"===e&&this.resetVideoPanoramic(),this.beforeLoad(!1)}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}resetVideo(){this.setMessage("onLoadMessage","info"),this.videoViewModel?.resetVideoHandler(),this._overlays?.removeAll(),this.videoViewModel=null,this.featureCache=[],this.currentBestFeature=null}resetVideoPanoramic(){this.setMessage("onLoadMessage","info"),this._overlays?.removeAll(),this.currentBestFeature=null}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0,this._measurementService?.resetMeasurementVectors()}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:i,savedGraphics:r}=t,a=i.get(e.id),s=a?.toArray();if(!a||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce((t,{objectId:i,globalId:r,error:a},o)=>{const n=s[o],{attributes:l}=n;return a?t.error.push(n):(i&&(l[e.objectIdField]=i),r&&e.globalIdField&&(l[e.globalIdField]=r),t.success.push(n)),t},{success:[],error:[]});r.addMany(n.success),a.removeAll(),a.addMany(n.error)}async saveDataCaptureFeatures(e,t){const{activeViewer:i,currentBestFeature:a,dataCaptureLayer:s,mode:o}=this,l=i?.imageSize;if(!l||!a||"none"===o||"video"===o||"panoramic-video"===o)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!s)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const c=await Promise.all(e.map(async e=>{const i=e.clone(),{geometry:r}=i;if(!r)return;const a=r.type,o=s.hasZ,n=s.geometryType,l=a!==n,c=l?await import("./transformers.js"):null,d=c?.default[n],u=l?d?.(r):r;return u&&(i.geometry=await this._transformationService.imageGeometryToMapGeometry(u,t),i.geometry)?(o||ct(i.geometry),i):void 0})),d=c.filter(r);return s.applyEdits({addFeatures:d}).then(e=>{const{addFeatureResults:t}=e;let i=0;const r=c.map(e=>{const r=t[i++];return e?r:{error:new n("orientedimageryviewer:save-unsucccessful","Error in saving data capture features"),objectId:null,globalId:null}});return{...e,addFeatureResults:r}})}async searchBestImage(e,t){try{const i=await z(e,t);i&&await this.processFeatureResponse(i,e.point,t)}catch(i){v(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find(({attributes:t})=>t.objectId===Number(e))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach(t=>{t.visible=e})}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach(t=>{t.visible=e})}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const i=this.activeViewer?.imageRenderer,{oiObjectIdField:r,currentBestFeature:a}=this;if(!i||!a||!r)return;const{attributes:{objectId:o}}=a,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(r)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const d=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);y(t),d.addGraphics(l),u.savedGraphics.addMany(l);i.ui.find("zoom").visible=!1,i.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,i=this.activeViewer?.imageRenderer;if(!i||i.destroyed)return;i.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const r=i.ui.find("zoom");r&&(r.visible=!0)}stopMeasurement(){this.draw?.reset(),this.sketch?.cancel()}async toggleAllOverlayMapFeatures(e){!e&&this.dataCaptureLayer&&(await this.stopDataCapture(!0),this.dataCaptureLayer=null),this.overlayedMapFeatures.forEach(t=>{this._toggleVisiblity(t,e)})}toggleOverlayMapFeatures(e,t,i){const r=this.overlayedMapFeatures.get(e);r&&i&&this._toggleVisiblity(r,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{feature:t,selectedLocation:i,options:r}=e;let a=!1,s=!1;const o="video"===this.mode?this.bestFeatureCurrentFootprint?.geometry:this.bestFeatureFootprint?.geometry;switch(o?.type){case"polygon":{const e=i.spatialReference.equals(o.spatialReference)?i:await G(i,o.spatialReference);a=o.contains(e);break}case"mesh":{const e=i.spatialReference.equals(o.spatialReference)?i:await G(i,o.spatialReference);s=o.extent.contains(e);break}}if(!a&&!s)return void this.clearReferencePointOnImage();const n="video"===this.mode||"panoramic-video"===this.mode?await this.getPixelLocationForFeature(i,{feature:t,mode:this.mode,imageSize:ye,footprintExtent:this.footprintExtent},r):await this._transformationService.pointToPixel(i,r);if(n)return y(r),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}async updateFeatureCache(e,t){const i=await N(e,t);i.features?.length&&(this.featureCache=i.features)}_plotReferencePointOnVideo(e){"video-loaded"===this.state&&this.videoViewModel?.videoPaused&&(this.clearReferencePointOnImage(),this.videoViewModel.plotReferencePointOnVideo(e))}_plotReferencePointOnPanoramicVideo(e){const i=this._panoramicVideoViewer,{imageSize:r,media:a}=i.viewModel;if(!this.panoramicVideoLoaded||!this.panoramicVideoPaused||!r)return;this.clearReferencePointOnImage();const s=Be(a),o=dt(e,"panoramic",r,s);this._referencePointOnImage=new t({geometry:o,symbol:Ge.clone()}),i.addGraphic(this._referencePointOnImage,0)}_getActiveFeatureForCurrentMode(){switch(this.mode){case"video":return this.videoViewModel?.closestFeature??this.currentBestFeature;case"panoramic-video":return this._panoramicVideoViewer.viewModel.closestFeature??this.currentBestFeature;default:return this.currentBestFeature}}_plotReferencePointOnDefaultImage(e){const i=this._imageViewer,{imageSize:r}=i;if("image-loaded"!==this.state||!r)return;this.clearReferencePointOnImage();const a=dt(e,"default",r);this._referencePointOnImage=new t({geometry:a,symbol:Le.clone()}),i.addGraphic(this._referencePointOnImage,0)}_plotReferencePointOnPanoramicImage(e){const i=this._panoramicViewer,{imageSize:r,media:a}=i;if("image-loaded"!==this.state||!r)return;this.clearReferencePointOnImage();const s=Be(a),o=dt(e,"panoramic",r,s);this._referencePointOnImage=new t({geometry:o,symbol:Ge.clone()}),i.addGraphic(this._referencePointOnImage,0)}async _fetchFeatures(e,t){const{layer:i,layerFloorFilterClause:r,layerTimeExtent:a,view:s}=this;if(!s)return;if(!i)return void this.setMessage("noLayerSelected","info");e.x=x(e.x,e.spatialReference);const o=i.spatialReference.equals(e.spatialReference)?e:await G(e,i.spatialReference),n=o.spatialReference.isGeographic?B(o):o,l=I("1=1",I(i.definitionExpression,r)),c=n.spatialReference.isGeographic?1:P(n.spatialReference),d={layerInstanceOrURL:i,point:n,queryParams:{where:l,maximumDistance:i.maximumDistance?i.maximumDistance/c:void 0,timeExtent:a}};return await this.searchBestImage(d,t)}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(v(i))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:i,invalidCameraHeading:r}=this,a=i.at(0);if(!e||!t||!a||!i||r)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const d of be)this._sectorData[d]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const l=n.map(({distance:e})=>e),c=Math.max(...l);n.forEach(e=>{const{distance:t,angle:r,featureIndex:s}=e,n=t/c*Ve[2],l=Ze(t,c),d=Je(r);if(!this._sectorData)return;const u=Ve[3]+n*Math.sin(r*Math.PI/180),h=Ve[3]+n*Math.cos(r*Math.PI/180);let p;const m=i.at(s),g=m===a,{cameraPitch:v}=m.attributes,y=v<5;if(g&&y)p=-90;else{const e=u-Ve[3],t=h-Ve[3],i=t/Math.sqrt(e**2+t**2);let r=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(r*=-1),p=r}const f=""===l?d:`${l}_${d}`;g&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=y?null:{x:u,y:h,direction:d}),o[`${m.attributes.objectId}`]=f;const w=this._sectorData[f];w.add({angle:r,featureIndex:s,x:u,y:h,objectID:m.attributes.objectId,sector:f,featureIndexInSector:w.length})})}async _initializeLocationViewModel(e){if(!this._locationViewModel){const t=import("./components/ImageLocationViewModel.js"),{default:i}=await t;y(e),this._locationViewModel=new i({oiViewModel:this,referenceTransformationService:this._referenceTransformationService})}}_initializeMeasurementService(){this._measurementService||(this._measurementService=new at({transformationService:this._transformationService,referenceTransformationService:this._referenceTransformationService}))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(Re.videoPlayerHandles),this.videoElement=new le({video:this.currentBestFeature.attributes.imagePath,georeference:new oe({extent:new O(Me)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new H({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.videoViewModel=new tt({oiViewModel:this})}async getMapPoint(e,t){const i=await this._transformationService.pixelToMapPoint(Array.isArray(e)?e:[e],t);return Array.isArray(e)?i:i[0]}async getMapPointForFeature(e,t,i){const r=await this._transformationService.pixelToMapPointForFeature(Array.isArray(e)?e:[e],t,i);return Array.isArray(e)?r:r[0]}async loadPanoramicMediaSource(e,t){const{lookAt:i,...r}=e,a=Ue(r);try{await a.load(t)}catch(o){if(v(o))return;if("unsupported-format"===o.name)return void this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:a?.extension??"UNKNOWN FORMAT"})}const s=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;await s.loadMedia(a,t),i&&s.set(i)}async loadMediaSource(e,t){const i=qe(e);await this._setImageSource(this.triangularMeasurementActive?this.imageMeasurementViewer:this._imageViewer,i,t)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.emit("no-image-found"),this.setMessage("noImageError","error"),this.videoElement?.content?.pause(),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,i){if(!e[0])return;const r=(await import("../../geometry/operators/unionOperator.js")).executeMany(e);if(this._updateFootprintWithFeatures(t,r),"3d"===this.view?.type)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(a){v(a)||u.getLogger(this).error(a)}}async processElevationSample(e,t,i){const{elevationSource:r}=t[0].attributes,a=await this._getElevationSampleFromGround(e,t,i);return a||(r&&this.footprintExtent&&J(r)?await Y({extent:this.footprintExtent,lod:r.lod,url:r.url,rasterFunction:r.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return U({features:e,selectedPoint:t,camera:We(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,i){const{results:[r]}=t;if("graphic"!==r?.type)return this.emit("no-image-found"),void this.setMessage("noImageError","error");const a=r.graphic.getAttribute(e.objectIdField);return await this.showImageByObjectId(a,i)}async _queryAndLoadByObjectId(e,t,i,r,a){this.displayMessage=null;const{response:s}=await rt(e,t,i,r,a);if(y(a),!s?.features?.length)throw new it(t);const o=q(s.features[0].attributes).polygon,n=L.fromJSON(j(o)),l=Q(n),c=P(l.spatialReference);this.selectedPoint=l;const d={layerInstanceOrURL:e,point:l,queryParams:{where:I(I("1=1",I(e.definitionExpression,i)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0,timeExtent:r}},u=await z(d,a);y(a);const{features:h}=u;return h.push(s.features[0]),await this.processFeatureResponse(u,l,{...a,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}async _setImageSource(e,t,i){e.media=t,await e.loadMedia(t,i)}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,i,r){const{location:a,cameraHeight:s}=e[0].attributes,o=await re(a.spatialReference,a.z,s,{elevationSample:i,elevationSource:i?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},r);y(r);const[n,...l]=await X([t,...e.map(e=>e.attributes.geometry.clone())],o);y(r),t.elevation=n.z,e.forEach((e,t)=>{e.attributes.elevation=l[t].z})}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.navigationNodes.removeAll(),this.navigationNodes.addMany(e.map(e=>{const{geometry:t,attributes:i}=e,{isSpherical:r,cameraHeading:a,cameraPitch:s}=i;return new et({geometry:t,attributes:i,currentHeading:r?0:a,currentPitch:r?0:s})})),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0])}_updateFootprintWithFeatures(e,t){const i=[];for(const{attributes:{geometry:r}}of e)t.contains(r)||i.push([r.x,r.y]);i.sort((e,t)=>+R([e,t])),t.addRing(i),this.footprintExtent=ue(t.extent,2,2)}_scheduleVideoInteractionUpdate(){this.scheduledFrameId||(this.scheduledFrameId=requestAnimationFrame(()=>{this.scheduledFrameId=null,this._updateInteraction()}))}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:r,currentCoverageVisible:a,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(r&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),y(e);for(const o of i){const i=this.view&&!this.view.spatialReference?.equals(o.spatialReference)?await G(o.clone(),this.view?.spatialReference,e):o.clone();o.imageID===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:o.imageID},geometry:i,symbol:Ee,visible:a}):this.additionalCameraLocations.push(new t({attributes:{imageID:o.imageID},geometry:i,symbol:je,visible:s}))}"video"!==o&&"panoramic-video"!==o||(await this.initializeTransformationService(e),n&&!this.featureCache.length&&await this.updateFeatureCache(n,r.geometry.spatialReference))}}_updateCurrentBestFeature(e){if(!e)return;if(this.currentBestFeature=this.features?.at(e.featureIndex),"video"===this.mode)return void(this.currentBestFeature&&this.videoViewModel?.playVideoFromSelectedLocation(this.currentBestFeature));if("panoramic-video"===this.mode)return void(this.currentBestFeature&&this._panoramicVideoViewer.viewModel.playPanoramicVideoFromSelectedLocation(this.currentBestFeature));const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-Ve[3],r=e.y-Ve[3],a=r/Math.sqrt(t**2+r**2);let s=180*Math.acos(a)/Math.PI;(t<0&&r<0||t<0&&r>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._panoramicVideoViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage)),this.videoViewModel?.clearReferencePointOnVideo()}async initializeReferenceTransformationService(e){const{currentBestFeatureMeasurementImage:t,activeTriangulatedViewer:i,mode:r}=this;if(!t||!i||!i.imageSize||"panoramic"!==r&&"default"!==r)return;const{imageSize:a}=i,{attributes:s,elevationSample:o}=t,{location:{spatialReference:n,z:l},cameraHeight:c,elevationSource:d}=s;let u=s.location;u.spatialReference.isGeographic&&(u=Q(u));const h="default"===r?ae(s,a[0],a[1]):se(s,a[0],a[1]),p=await re(n,l??0,c,{elevationSample:o,elevationSource:d,extent:this.footprintExtent},e),m=(await import("./services/TransformationService.js")).default,g={imageToWorldProperties:h,updateElevationProps:p,mode:r,imageSize:a,depthImageService:this.depthImage};this._referenceTransformationService=new m(g),this._locationViewModel&&(this._locationViewModel.referenceTransformationService=this._referenceTransformationService),this._measurementService&&(this._measurementService.referenceTransformationService=this._referenceTransformationService)}async initializeTransformationService(e){const{currentBestFeature:t,activeViewer:i,mode:r}=this,a="video"===r||"panoramic-video"===r?ye:i?.imageSize;if(!t||!a||"none"===r)return;const{attributes:s,elevationSample:o}=t,{location:{spatialReference:n,z:l},cameraHeight:c,elevationSource:d}=s;let u=s.location;u.spatialReference.isGeographic&&(u=Q(u));const h="default"===r||"video"===r?"default":"panoramic",p={..."default"===h?ae(s,a[0],a[1]):se(s,a[0],a[1]),cameraLocation:u},m=await re(n,l??0,c,{elevationSample:o,elevationSource:d,extent:this.footprintExtent},e),g=(await import("./services/TransformationService.js")).default,v={imageToWorldProperties:p,updateElevationProps:m,mode:h,imageSize:a,depthImageService:this.depthImage};this._transformationService=new g(v),this._measurementService&&(this._measurementService.transformationService=this._transformationService)}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,r){this.displayMessage={key:e,type:t,data:i,map:r}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:i,selectedPoint:r,activeViewer:a}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!r||!t||"image-loaded"!==a?.state||i)return;let s;try{s=await this._transformationService.pointToPixel(r,{signal:e?.signal}),y(e),await this.plotSelectedPointOnImage(s,e)}catch(o){v(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:r,feature:t})}}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:r,currentBestFeature:a,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:d}=this;if(!a)return;const{attributes:{objectId:u},elevationSample:h}=a;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...r,s].filter($e);"3d"===l?.type&&h&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e),"panoramic"===d&&c.updateGroundElevation([this.bestFeatureCurrentFootprint])),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:Ie.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return void this._superimposeService.clear();this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,"3d"===l?.type&&h&&c?.updateGroundElevation&&"panoramic"===d&&c.updateGroundElevation([e]),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}_updateSuperimposedImage(){if(!this._hasActiveSuperimposeCameraContext())return;const e="panoramic"===this.mode?this._panoramicViewer:null,{currentBestFeature:t,defaultSuperimposeCameraLockEnabled:i,layer:r,mode:a,view:s,state:o,superimposeViewEnabled:n,superimposeViewSupported:l,activeViewer:c,depthImage:d}=this,u=this.coverageFrustums.find(({imageID:e})=>e===t?.attributes.objectId);this._superimposeService.update({activeImageSize:c?.imageSize||void 0,adapter:this._adapter,currentBestFeature:t,currentBestFeatureFrustum:u,defaultSuperimposeCameraLockEnabled:i,depthImageLoaded:d?.loaded??!1,layer:r,mode:a,panoramicCamera:e?.camera,panoramicHorizonAngles:Be(e?.media),state:o,superimposeViewEnabled:n&&l,view:s}),this.setMessage("superimposeImageDescription","info"),this._superimposePreviousCurrentCoverageVisible??=this.currentCoverageVisible,this.currentCoverageVisible=!1}_getSuperimposeCameraWatchState(){const e="3d"===this.view?.type?this.view:null,t=e?.camera;return[this.superimposeViewEnabled,this.superimposeViewSupported,this.mode,this.state,this.view?.type,this.view?.interacting,this.view?.navigating,t?.heading,t?.tilt,t?.fov,t?.position.x,t?.position.y,t?.position.z]}_handleSuperimposeCameraChange(){const e=this.view,t="3d"===e?.type?e:null;this._hasActiveSuperimposeCameraContext()?"panoramic"!==this.mode?!t||t.interacting||t.navigating?this._abortSuperimposeSchedule():this._scheduleDefaultSuperimposeUpdate():this._schedulePanoramicSuperimposeUpdate():this._abortSuperimposeSchedule()}_shouldDisableUnsupportedSuperimposeView(){return this.superimposeViewEnabled&&"panoramic"===this.mode&&!this.superimposeViewSupported}_hasActiveSuperimposeCameraContext(){return("default"===this.mode||"panoramic"===this.mode)&&this.superimposeViewEnabled&&this.superimposeViewSupported&&"image-loaded"===this.state&&"3d"===this.view?.type&&!!this.view.camera}_abortSuperimposeSchedule(){this._superimposeScheduleController?.abort(),this._superimposeScheduleController=null,this._clearSuperimposeDebounceTimeout(),this._clearSuperimposeScheduledFrame()}_resetInactiveSuperimposeState(){const e=null!=this._superimposePreviousCurrentCoverageVisible;this._abortSuperimposeSchedule(),this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this._superimposeService.clear(),this._restoreCurrentCoverageVisibilityAfterSuperimpose(),this._restoreDefaultMessageAfterSuperimpose(),e&&this._restoreViewerMediaAfterSuperimpose()}_restoreCurrentCoverageVisibilityAfterSuperimpose(){null!=this._superimposePreviousCurrentCoverageVisible&&(this.currentCoverageVisible=this._superimposePreviousCurrentCoverageVisible,this._superimposePreviousCurrentCoverageVisible=null)}_restoreViewerMediaAfterSuperimpose(){const{currentBestFeature:e,mode:t}=this;if(!e||"default"!==t&&"panoramic"!==t)return;this._restoreSuperimposeMediaTask?.abort();const i=a(async t=>{await this._loadCurrentFeatureMedia(e,{signal:t})});this._restoreSuperimposeMediaTask=i,i.promise.finally(()=>{this._restoreSuperimposeMediaTask===i&&(this._restoreSuperimposeMediaTask=null)})}_restoreDefaultMessageAfterSuperimpose(){if("superimposeImageDescription"===this.displayMessage?.key){!!this.currentBestFeature&&("default"===this.mode||"panoramic"===this.mode)?this.displayMessage=null:this.setMessage("onLoadMessage","info")}}_clearSuperimposeDebounceTimeout(){null!=this.superimposeDebounceTimeoutId&&(clearTimeout(this.superimposeDebounceTimeoutId),this.superimposeDebounceTimeoutId=null)}_clearSuperimposeScheduledFrame(){null!=this.superimposeScheduledFrameId&&(cancelAnimationFrame(this.superimposeScheduledFrameId),this.superimposeScheduledFrameId=null)}_schedulePanoramicSuperimposeUpdate(){this._abortSuperimposeSchedule(),this.superimposeDebounceTimeoutId=window.setTimeout(()=>{this.superimposeDebounceTimeoutId=null,this._hasActiveSuperimposeCameraContext()&&"panoramic"===this.mode&&this._updateSuperimposedImage()},150)}_scheduleDefaultSuperimposeUpdate(){const e=this.view;if(!("3d"===e?.type?e:null))return;if(this.superimposeScheduledFrameId)return;this._superimposeScheduleController?.abort();const t=new AbortController,{signal:i}=t,r=()=>{this._clearSuperimposeDebounceTimeout(),this._clearSuperimposeScheduledFrame(),this._superimposeScheduleController===t&&(this._superimposeScheduleController=null),i.removeEventListener("abort",r)};this._superimposeScheduleController=t,i.addEventListener("abort",r),this.superimposeScheduledFrameId=requestAnimationFrame(()=>{if(i.removeEventListener("abort",r),this.superimposeScheduledFrameId=null,this._superimposeScheduleController===t&&(this._superimposeScheduleController=null),i.aborted)return;const e=this.view,a="3d"===e?.type?e:null;!this._hasActiveSuperimposeCameraContext()||null==a||a.interacting||a.navigating||this._updateSuperimposedImage()})}};e([C()],mt.prototype,"activeLayer",null),e([C({readOnly:!0})],mt.prototype,"activeViewer",null),e([C()],mt.prototype,"activeTriangulatedViewer",null),e([C()],mt.prototype,"accuracyParametersMissing",null),e([C()],mt.prototype,"additionalFeatures",void 0),e([C({type:s.ofType(t)})],mt.prototype,"additionalCameraLocations",void 0),e([C({type:s.ofType(t)})],mt.prototype,"additionalFootprints",void 0),e([C()],mt.prototype,"areaMeasurementResult",void 0),e([C()],mt.prototype,"areaMeasurementAccuracy",void 0),e([C()],mt.prototype,"bestFeatureAngle",void 0),e([C()],mt.prototype,"bestFeatureCurrentFootprint",void 0),e([C({type:t})],mt.prototype,"bestFeatureFootprint",void 0),e([C({type:Number})],mt.prototype,"brightness",null),e([C()],mt.prototype,"cameraHeadingThreshold",void 0),e([C()],mt.prototype,"cameraPitchThreshold",void 0),e([C()],mt.prototype,"clickAction",void 0),e([C()],mt.prototype,"correctedLocationPointOnImage",void 0),e([C()],mt.prototype,"videoViewModel",void 0),e([C()],mt.prototype,"collectionId",void 0),e([C({type:Number})],mt.prototype,"contrast",null),e([C()],mt.prototype,"coverageFrustums",void 0),e([C()],mt.prototype,"coveragePolygons",void 0),e([C()],mt.prototype,"currentBestFeature",void 0),e([C()],mt.prototype,"currentBestFeatureMeasurementImage",void 0),e([C()],mt.prototype,"currentBestFeatureLocation",void 0),e([C()],mt.prototype,"currentCoverageVisible",void 0),e([C()],mt.prototype,"currentNode",null),e([C()],mt.prototype,"depthImage",void 0),e([C()],mt.prototype,"depthImageNotSupported",null),e([C()],mt.prototype,"featureCache",void 0),e([C()],mt.prototype,"navigationNodes",void 0),e([C({json:{write:!1}})],mt.prototype,"determineWorkflowForFeature",void 0),e([C({json:{write:!1}})],mt.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([C()],mt.prototype,"disabled",void 0),e([C()],mt.prototype,"displayMessage",void 0),e([C()],mt.prototype,"displayNewMeasurementButton",void 0),e([C()],mt.prototype,"distanceMeasurementResult",void 0),e([C()],mt.prototype,"distanceAccuracyArray",void 0),e([C()],mt.prototype,"dataCaptureLayer",void 0),e([C({readOnly:!0})],mt.prototype,"featureCount",null),e([C()],mt.prototype,"features",void 0),e([C()],mt.prototype,"groundCoordinates",void 0),e([C()],mt.prototype,"groundCoordinatesAccuracy",void 0),e([C()],mt.prototype,"heightGraphic",void 0),e([C()],mt.prototype,"heightMeasurementResult",void 0),e([C()],mt.prototype,"heightMeasurementAccuracy",void 0),e([C({readOnly:!0})],mt.prototype,"imageGalleryEnabled",null),e([C()],mt.prototype,"imageGeometryField",void 0),e([C({readOnly:!0})],mt.prototype,"imageLoaded",null),e([C()],mt.prototype,"imageLocationToolState",void 0),e([C()],mt.prototype,"initialVideoMapViewExtent",void 0),e([C({readOnly:!0})],mt.prototype,"invalidCameraHeading",null),e([C()],mt.prototype,"imagePointsInView",null),e([C()],mt.prototype,"imageMeasurementViewer",void 0),e([C()],mt.prototype,"isAdditionalCoverageVisible",void 0),e([C()],mt.prototype,"isAdditionalPointSourcesVisible",void 0),e([C()],mt.prototype,"layer",void 0),e([C()],mt.prototype,"layerView",null),e([C({readOnly:!0})],mt.prototype,"layerFloorFilterClause",null),e([C({readOnly:!0})],mt.prototype,"layerTimeExtent",null),e([C({type:Number})],mt.prototype,"localPort",void 0),e([C()],mt.prototype,"locationPointOnImage",void 0),e([C()],mt.prototype,"mapImageConversionToolState",void 0),e([C()],mt.prototype,"measureType",void 0),e([C()],mt.prototype,"measurementGraphic",void 0),e([C({readOnly:!0,value:"none"})],mt.prototype,"mode",null),e([C()],mt.prototype,"navigationMode",void 0),e([C()],mt.prototype,"navigatorCurrentBestFeature",void 0),e([C()],mt.prototype,"oiObjectIdField",void 0),e([C({type:s.ofType(t)})],mt.prototype,"overlayedCameraLocations",void 0),e([C()],mt.prototype,"overlayedMapFeatures",void 0),e([C()],mt.prototype,"panoramicVideoLoaded",null),e([C()],mt.prototype,"panoramicVideoPaused",null),e([C()],mt.prototype,"pixelCoordinates",void 0),e([C()],mt.prototype,"preserveAngle",void 0),e([C()],mt.prototype,"pointSources",void 0),e([C({readOnly:!0})],mt.prototype,"popupEnabled",null),e([C()],mt.prototype,"preloadMedia",void 0),e([C()],mt.prototype,"preloadMediaSize",void 0),e([C()],mt.prototype,"previousFeatureAngle",void 0),e([C()],mt.prototype,"referencePoint",null),e([C({readOnly:!0})],mt.prototype,"sectorData",null),e([C()],mt.prototype,"selectedPoint",void 0),e([C({type:Number})],mt.prototype,"sharpness",null),e([C()],mt.prototype,"shouldShowSelectedImage",void 0),e([C()],mt.prototype,"superimposeViewEnabled",void 0),e([C()],mt.prototype,"defaultSuperimposeCameraLockEnabled",void 0),e([C()],mt.prototype,"superimposeViewSupported",null),e([C()],mt.prototype,"sketch",void 0),e([C()],mt.prototype,"sketchTriangular",void 0),e([C()],mt.prototype,"sketchTriangularGraphicsLayer",void 0),e([C()],mt.prototype,"draw",void 0),e([C()],mt.prototype,"drawAdapter",void 0),e([C()],mt.prototype,"polylineDrawAction",void 0),e([C()],mt.prototype,"scheduledFrameId",void 0),e([C()],mt.prototype,"superimposeScheduledFrameId",void 0),e([C()],mt.prototype,"superimposeDebounceTimeoutId",void 0),e([C()],mt.prototype,"sketchAdapter",void 0),e([C({readOnly:!0})],mt.prototype,"sketchGraphicsLayer",null),e([C({readOnly:!0})],mt.prototype,"state",null),e([C({readOnly:!0})],mt.prototype,"thumbnails",null),e([C()],mt.prototype,"videoExtentPoints",null),e([C()],mt.prototype,"triangularMeasurementActive",void 0),e([C()],mt.prototype,"triangulatedDistanceMeasurement",void 0),e([C()],mt.prototype,"triangulatedDistanceAccuracy",void 0),e([C()],mt.prototype,"triangulatedAreaMeasurement",void 0),e([C()],mt.prototype,"triangulatedAreaAccuracy",void 0),e([C()],mt.prototype,"triangulatedMeasurementGraphic",void 0),e([C()],mt.prototype,"triangulatedPoint",void 0),e([C()],mt.prototype,"triangulatedMeasurementAdapter",void 0),e([C()],mt.prototype,"updateFootprint",void 0),e([C()],mt.prototype,"updateVideoFootprint",void 0),e([C()],mt.prototype,"updateFootprintPanorama",void 0),e([C()],mt.prototype,"updatingTriangularMeasurementState",void 0),e([C({value:null})],mt.prototype,"view",null),e([C()],mt.prototype,"videoElement",void 0),e([C()],mt.prototype,"videoLayer",void 0),e([C()],mt.prototype,"videoMapView",void 0),e([C()],mt.prototype,"verticalFilterEnabled",void 0),e([C()],mt.prototype,"_adapter",void 0),e([C()],mt.prototype,"_defaultGraphicsLayer",null),e([C()],mt.prototype,"_highlightedFeatureHandle",void 0),e([C()],mt.prototype,"_imageViewer",void 0),e([C()],mt.prototype,"_initialCurrentCoverageUpdate",void 0),e([C()],mt.prototype,"_locationViewModel",void 0),e([C()],mt.prototype,"_measurementService",void 0),e([C()],mt.prototype,"_mediaPrefetcher",void 0),e([C()],mt.prototype,"_navigationManager",void 0),e([C()],mt.prototype,"_overlays",void 0),e([C()],mt.prototype,"_superimposePreviousCurrentCoverageVisible",void 0),e([C()],mt.prototype,"_superimposeService",void 0),e([C({readOnly:!0})],mt.prototype,"_overlaysView",null),e([C()],mt.prototype,"_panoramicVideoViewer",void 0),e([C()],mt.prototype,"_panoramicViewer",void 0),e([C()],mt.prototype,"_panoramicMeasurementViewer",void 0),e([C()],mt.prototype,"_referencePointOnGround",void 0),e([C()],mt.prototype,"_referencePointOnImage",void 0),e([C()],mt.prototype,"_referenceTransformationService",void 0),e([C()],mt.prototype,"_sectorData",void 0),e([C()],mt.prototype,"_transformationService",void 0),e([C()],mt.prototype,"_featureToSector",void 0),e([C({readOnly:!0})],mt.prototype,"_updatingHandles",void 0),e([C()],mt.prototype,"footprintExtent",void 0),e([C()],mt.prototype,"_featureChangedTask",void 0),mt=e([A("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],mt);const gt=mt;export{gt as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as i,isSome as r}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import{EventedMixin as l}from"../../core/Evented.js";import{makeHandle as c}from"../../core/handleUtils.js";import{equalsShallow as d}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as h}from"../../core/mathUtils.js";import{destroyMaybe as p,abortMaybe as m}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as v,throwIfAborted as y,waitTick as f}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{whenOnce as _,on as F,watch as b,syncAndInitial as M,initial as V,when as S}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as P}from"../../core/units.js";import{property as C,subclass as A}from"../../core/accessorSupport/decorators.js";import{isSerializable as k}from"../../core/support/jsonUtils.js";import{UpdatingHandles as T}from"../../core/support/UpdatingHandles.js";import O from"../../geometry/Extent.js";import L from"../../geometry/Point.js";import{projectAsync as G}from"../../geometry/projectionUtils.js";import E from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as j}from"../../geometry/support/centroid.js";import{isClockwise as R}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as x}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as B}from"../../geometry/support/webMercatorUtils.js";import D from"../../layers/GraphicsLayer.js";import H from"../../layers/MediaLayer.js";import{searchImages as z,getSortedLayerFeatures as N}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as U}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as q,computePolygonForInspection as W,resizePolygon as $,checkIfPolygonContainsSelectedPoint as Z}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as J}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{getMetersPerUnitOfSR as K,convertGeographicToWebMercator as Q}from"../../layers/orientedImagery/core/utils.js";import X from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Y}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as ee,getInitialAngle as te,convertPixelLocationToSphereVertex as ie,getUpdateElevationProps as re,getImageToWorldProperties as ae,getImageToWorldPanoramicProperties as se}from"../../layers/orientedImagery/transformations/utils.js";import oe from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as ne}from"../../layers/support/floorFilterUtils.js";import le from"../../layers/support/VideoElement.js";import ce from"../../views/MapView.js";import de from"../../views/draw/Draw.js";import{scale as ue}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as he}from"../../views/input/InputManager.js";import pe from"../PanoramicVideoViewer.js";import me from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as ge,videoMapViewConstraint as ve,fixedImageSize as ye,clockwiseDirections as fe,videoFitScaleTolerance as we,videoExtent as _e,invalidCameraHeading as Fe,sectorsInOrder as be,sampleExtent as Me,sectorsRadii as Ve}from"./constants.js";import{isFeatureAttachment as Se}from"./galleryUtils.js";import{crossSymbol as Ie,crossSymbol3D as Pe,measurementPolygonSymbol as Ce,polylineSymbolPanoramic as Ae,measurementPolylineSymbol as ke,cameraOverlaySymbol3D as Te,cameraOverlaySymbol as Oe,diamondSymbol as Le,diamondSymbol3D as Ge,activeSourcePointSymbol as Ee,sourcePointSymbol as je}from"./symbols.js";import{registryKeys as Re}from"./types.js";import{isNoAttachmentError as xe,extractHorizonAnglesFromMedia as Be,isTifOrMrf as De,filterOILLayerView as He,assignElevationSampleToFeatures as ze,filterByZ as Ne,createPanoramicMedia as Ue,createNonPanoramicMedia as qe,isSceneView as We,isGraphic as $e,calculateSegment as Ze,calculateDirection as Je}from"./utils.js";import{disableVideoZoomAndPan as Ke,getUpdatedConstraints as Qe,getUpdatedExtentPoints as Xe}from"./videoViewerUtils.js";import Ye from"./components/ImageViewer.js";import et from"./components/NavigationNode.js";import tt from"./components/OrientedImageryVideoViewModel.js";import{NoFeatureFoundWithObjectIdError as it}from"./navigation/errors.js";import{queryFeatureByObjectIds as rt}from"./navigation/queries.js";import{ImageMeasurementService as at}from"./services/ImageMeasurementService.js";import st from"./services/SuperimposeService.js";import{configureSketchTool as ot,extractFieldsFromDataCaptureLayer as nt,constructGraphicFromImageGeometry as lt}from"./support/dataCaptureUtils.js";import{removeZFromGeometry as ct,imageSpaceToPoint as dt}from"./support/geometryUtils.js";import ut from"./support/resolveMediaProps.js";import{isValidDataCaptureLayer as ht}from"./support/typeUtils.js";const pt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let mt=class extends(l(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=ge,this.cameraPitchThreshold=ge,this.clickAction="hittest",this.correctedLocationPointOnImage=null,this.videoViewModel=null,this.collectionId=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.depthImage=null,this.featureCache=[],this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:r,selectedPoint:a}=this;if(this.emit("popup-close"),r&&a){this.displayMessage=null,this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(i),await this._loadDepthImage(i),await this._loadCurrentFeatureMedia(r,i)}catch(s){v(s)||(this.loadImageError(s),u.getLogger(this).error("#loadIImage()","error occured while loading image",s))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,i)=>{if(this.emit("popup-close"),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(i)}catch(r){v(r)||(this.loadImageError(r),u.getLogger(this).error("#loadIImage()","error occured while loading image",r))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.imageGeometryField=null,this.imageLocationToolState=!1,this.initialVideoMapViewExtent=null,this.imageMeasurementViewer=new Ye,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.locationPointOnImage=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new s,this.preloadMedia=!1,this.preloadMediaSize=5,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.superimposeViewEnabled=!1,this.defaultSuperimposeCameraLockEnabled=!0,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.drawAdapter=null,this.polylineDrawAction=null,this.scheduledFrameId=null,this.superimposeScheduledFrameId=null,this.superimposeDebounceTimeoutId=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t,i)=>{"default"===this.mode&&"image-loaded"!==this.state||await(this._adapter?.updateFootprint(e,t,i))},this.updateVideoFootprint=async e=>{this.mode.includes("video")&&this.videoElement?.content&&await(this._adapter?.updateVideoFootprint(e))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new ce({map:new Map,constraints:ve}),this.verticalFilterEnabled=!1,this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new Ye,this._initialCurrentCoverageUpdate=!0,this._locationViewModel=null,this._measurementService=null,this._mediaPrefetcher=null,this._navigationManager=null,this._overlays=new D({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._superimposePreviousCurrentCoverageVisible=null,this._superimposeService=new st({getMapPoint:(e,t)=>this.getMapPoint(e,t),pointToPixel:(e,t)=>this._transformationService.pointToPixel(e,t),overlays:this._overlays}),this._panoramicVideoViewer=new pe,this._panoramicViewer=new me,this._panoramicMeasurementViewer=new me,this._referencePointOnGround=null,this._referencePointOnImage=null,this._referenceTransformationService=null,this._sectorData=null,this._transformationService=null,this._featureToSector=null,this._updatingHandles=new T,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._mediaPrefetchTask=null,this._restoreSuperimposeMediaTask=null,this._superimposeScheduleController=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.addUpdatingPromise=e=>this._updatingHandles.addPromise(e),this.filterCapturedFeatures=e=>{const t=this.currentBestFeature?.attributes.objectId,i=this.layer?.imageReferenceField;if(!t||!e||!i)return;const r=this.overlayedMapFeatures.get(e);r?.forEach(e=>{const r=e.attributes??{},a=Object.keys(r).find(e=>e.toLowerCase()===i.toLowerCase());(a?r[a]:null)!==t&&(e.visible=!e.visible)})},this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find(({attributes:{imageID:t}})=>t===Number(e));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:i}=await t;return y(e),this.sketchAdapter=new i({viewModel:this}),this.sketchAdapter},this.loadImageFromFeature=(e,t,i)=>this._updatingHandles.addPromise(this._loadImageFromFeature(e,t,i)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.storePanoramicMeasurementViewer=e=>{this._panoramicMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadPanoramicVideoViewer=e=>{this._panoramicVideoViewer?.destroy(),this._panoramicVideoViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const i=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(i)this.currentBestFeature=i;else{const{layer:i,layerFloorFilterClause:a,layerTimeExtent:s}=this;if(!i)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const o=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(i,e,a,s,t));try{await o,await this.selectBestFeature(e,t)}catch(r){v(r)||(u.getLogger(this).error("oriented-imagery-viewer:show-image",r),"NoFeatureFoundWithObjectIdError"===r.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",r.message))}}},this.getSectorFeatureById=e=>this._suitabilities?.find(({feature:{attributes:{objectId:t}}})=>t===e),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{mode:i}=this;if("default"!==i&&"panoramic"!==i)throw new n("NavigationError","Navigation is only supported in 'default' and 'panoramic' modes.");const r=e=>"default"===i&&e.declaredClass.endsWith("NavigationManager")||"panoramic"===i&&e.declaredClass.endsWith("NavigationManagerPanoramic");if(null==this._navigationManager||!r(this._navigationManager)){p(this._navigationManager);const e="default"===i?import("./navigation/NavigationManager.js"):import("./navigation/NavigationManagerPanoramic.js");this._navigationManager=new(await e).default({viewModel:this})}return this._navigationManager.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(y(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),_(()=>{switch(this.mode){case"video":return"video-loaded"===this.state;case"panoramic-video":return this.panoramicVideoLoaded;default:return"image-loaded"===this.state}},t)),this.toggleImageAttributes=()=>{const{currentBestFeature:e,popupEnabled:i,layer:r,view:a}=this;if(this.emit("popup-close"),!(a&&e&&i&&r))return;const{attributes:s,geometry:o}=e,n=new t({geometry:o,attributes:s.toJSON(),origin:r.graphicOrigin,sourceLayer:r});this.emit("popup-open",{features:[n],location:s.location.clone()})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const i=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(i,t),this._groupFeaturesBySectors()},this._computeOverlayImageSize=()=>{const{mode:e}=this;return"video"===e?ye:"panoramic-video"===e?this._panoramicVideoViewer.imageSize:this.activeViewer?.imageSize},this._geometryToOverlayImageGeometry=async(e,t,i)=>{const{mode:r,videoViewModel:a,_panoramicVideoViewer:s}=this;if("video"===r)return await(a?.geometryToOverlayGeometry(e,t))??null;if("panoramic-video"===r){const a={feature:t,mode:r,imageSize:i,footprintExtent:this.footprintExtent};return await this._transformationService.geometryToImageGeometryForFeature(e,a,s.horizonAngles)}return await this._transformationService.geometryToImageGeometry(e)},this._createViewClickHandle=()=>{if(this.removeHandles(Re.click),this.disabled||null==this.view)return;const e=this.mapImageConversionToolState&&("image-loaded"===this.state||"video-loaded"===this.state&&"video"===this.mode&&!!this.videoViewModel?.videoPaused||this.panoramicVideoLoaded&&"panoramic-video"===this.mode&&this.panoramicVideoPaused)?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,he.DEFAULT),Re.click)},this._createImageClickHandle=()=>{this.removeHandles(Re.imageClick),this.videoViewModel?.syncMapImageConversionHandle();const{mapImageConversionToolState:e,mode:t,footprintExtent:i,panoramicVideoLoaded:r}=this,s="panoramic-video"===t?this._panoramicVideoViewer:this.activeViewer,o=s?.imageSize;if(!e||"none"===t||"video"===t||!o||!i)return;const n="panoramic-video"===t,l=this._getActiveFeatureForCurrentMode(),d=!n||r&&this.panoramicVideoPaused;if(!l||!d)return;const u=s.clickAction;this.clickAction="pixel-location";const h=c(()=>{this.clickAction=u});let p=null;const m=F(()=>s,"pixel-location",e=>{this.plotReferencePointOnImage(e),p?.abort(),p=a(async r=>{if(!e)return;const a=this._getActiveFeatureForCurrentMode();if(!a)return;const s={feature:a,mode:t,imageSize:o,footprintExtent:i};let l=n?await this.getMapPointForFeature(e,s,{signal:r}):await this._transformationService.pixelToMapPoint(e);const c=this.view?.spatialReference;l&&!ee(!c,l.spatialReference.equals(c))&&(l=await G(l,c,{signal:r})),y(r),this.plotReferencePointOnGround(l)})});this.addHandles([m,h],Re.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(Re.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),Re.triangularImageClick)},this._enablePan=()=>{this.removeHandles(Re.videoPanHandles)},this._disablePan=()=>{this.removeHandles(Re.videoPanHandles),this.addHandles(Ke(this.videoMapView),Re.videoPanHandles)},this._handleImageHitTestResponse=async e=>{const{layer:t,overlayedCameraLocations:i}=this;if(!t)return;const r=e.results.find(({graphic:e,graphic:{attributes:r}})=>i.includes(e)&&r&&!r[t.imageReferenceField]&&!r[t.imageGeometryField]);if(!r)return;const a=r.graphic.attributes[t.objectIdField];await this.showImageByObjectId(a)},this._loadCurrentFeatureMedia=async(e,t)=>{if("video"===this.mode)return this._initializeVideo(),void this.videoViewModel?.playVideoFromSelectedLocation(e);"panoramic-video"!==this.mode?await this._loadImage(t):await this._loadVideo(t)},this._loadDepthImage=async e=>{const{currentBestFeature:t,layer:i,depthImageNotSupported:r}=this;if(this.depthImage?.destroy(),this.depthImage=null,!i||!t||r)return;const{depthImage:a}=t.attributes;if(!a)return;const s=(await import("./services/DepthImageService.js")).default;y(e),this.depthImage=new s({url:a});try{await this.depthImage.load(e)}catch(o){v(o)||(u.getLogger(this).error("error occurred while loading depth image",o),this.depthImage?.destroy(),this.depthImage=null)}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:r}=this;if(this.clearGraphics(),i&&t&&"none"!==r&&"video"!==r&&"panoramic-video"!==r)try{await this.loadImageFromFeature(i,t,e),y(e),await this.transformAndPlotSelectedLocation(e)}catch(a){v(a)||this.loadImageError(a)}},this._loadVideo=async e=>{const{currentBestFeature:t,mode:i,selectedPoint:r}=this,a=t?.attributes.imagePath;if(!t||"panoramic-video"!==i||!a)return;const{attributes:s}=t,{cameraPitch:o,cameraOrientation:n,location:l}=s,c=l.spatialReference.isWGS84&&4!==n?.type?B(l):new L(l);try{this._panoramicVideoViewer.viewModel.video&&(this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.viewModel.videoPaused=!0),this._panoramicVideoViewer.videoSource=a;let t=0;c&&r&&(t=await te(c,r)-t),this._panoramicVideoViewer.pitch=o??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),y(e)}catch(d){v(d)||this.loadImageError(d)}},this._loadImageFromFeature=async(e,t,i)=>{const{mode:r}=this;if("default"!==r&&"panoramic"!==r)return;let a;try{a=await ut(t.attributes,e,i),y(i)}catch(f){if(v(f))return;return xe(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${e.objectIdField}: ${t.attributes.objectId}`)):(u.getLogger(this).error(f,{[e.objectIdField]:t.attributes.objectId,layer:e}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${e.objectIdField} ${t.attributes.objectId}`))}if(!a)return;const{mediaUrl:s,datasetFormat:o,rotation:n,searchParams:l,location:c,cameraHeading:d,matrix:h,cameraPitch:p,getDataSetFormatError:m}=a,g=`${t.attributes.objectId}`;try{let a=this._mediaPrefetcher?.getCachedMedia(g);if(!a){const i=this.navigationNodes.find(e=>e.id===t.attributes.objectId);if(i){try{await(this._mediaPrefetcher?.startPrefetchForNode(i,e))}catch(w){}a=this._mediaPrefetcher?.getCachedMedia(g)}}if(a){if("panoramic"===r){const e=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;let r=0;return c&&this.selectedPoint&&(r=await te(c,this.selectedPoint)-r),await e.loadMedia(a,i),this.selectedPoint?e.set({yaw:r,pitch:p}):"viewAngle"in t.attributes&&Number.isFinite(t.attributes.viewAngle)&&e.set({yaw:t.attributes.viewAngle,pitch:p}),void(this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i))}return await this._setImageSource(this.triangularMeasurementActive?this.imageMeasurementViewer:this._imageViewer,a,i),void(this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i))}}catch(w){}m&&u.getLogger(this).warn("error occurred while getting dataset format",m),"panoramic"===r?await this.loadPanoramicMediaSource({lookAt:{yaw:this.selectedPoint?await te(c,this.selectedPoint):"viewAngle"in t.attributes&&Number.isFinite(t.attributes.viewAngle)?t.attributes.viewAngle:0,pitch:p},extension:o?.toUpperCase(),url:s,cameraHeading:d,matrix:h},i):await this.loadMediaSource({datasetFormat:o?.toUpperCase(),url:s,customParameters:l,rotation:n},i),this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i)},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:i,mode:r}=this;if(this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics(),i&&t&&"none"!==r&&"video"!==r&&"panoramic-video"!==r)try{await this.loadImageFromFeature(i,t,e),y(e)}catch(a){v(a)||this.loadImageError(a)}},this._loadMediaPrefetcher=async e=>{if(!this._mediaPrefetcher){const{default:t}=await import("./support/MediaPrefetcher.js");y(e),this._mediaPrefetcher=new t({maxEntries:this.preloadMediaSize*fe.length})}return this._mediaPrefetcher},this._loadViewAdapter=async e=>{const{view:t}=this;if(this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");y(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");y(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{if(e.stopPropagation(),e.preventDefault(),e.mapPoint){const t=e.mapPoint;t.x=x(t.x,t.spatialReference),this.plotMapPoint(e.mapPoint)}},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:i,currentBestFeatureMeasurementImage:r,triangulatedMeasurementGraphic:a}=this;t&&i&&r&&a&&"active"!==t.state&&(t.update([a],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._updateInteraction=()=>{const e=this.videoMapView.extent;if(!e)return;const{minScale:t}=this.videoMapView.constraints,i=this.videoMapView.scale<t-we,r=Qe(e);i&&!!r?(this._enablePan(),this.videoMapView.constraints.geometry=r):i?(this._disablePan(),this.videoMapView.constraints.geometry=null):(this.initialVideoMapViewExtent&&!this.videoMapView.extent.equals(this.initialVideoMapViewExtent)&&(this.videoMapView.extent=this.initialVideoMapViewExtent),this._disablePan(),this.videoMapView.constraints.geometry=null)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=a(async t=>{const{pointerType:i,button:r,mapPoint:a}=e;if("mouse"===i&&0!==r||!a)return;e.stopPropagation(),e.preventDefault();const{view:s,layer:o}=this;if(s){if(o){if(this.shouldShowSelectedImage){const i=s.hitTest(e,{include:[o]});this._updatingHandles.addPromise(i);const r=await i;return y(t),await this._processHitTestResults(o,r,{signal:t})}return this._updatingHandles.addPromise(this.loadBestImage(a,{signal:t}))}this.setMessage("noLayerSelected","info")}})},this.plotSelectedPointOnImage=async(e,i)=>{if(await f(i),!e)return;const r=new L({...k(e)?e.toJSON():e});if("default"===this.mode)r.x-=.5,r.y=.5-r.y,r.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:r,symbol:Ie}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i,media:r}=this._panoramicViewer;if(!i||!r)return;const a=Be(r),s=ie(e,...i,a);this._crossSymbol=new t({geometry:new L(s,E.WebMercator),symbol:Pe}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([b(()=>this.view,()=>this.load(),M),b(()=>this.view?.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},V),b(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},V),b(()=>[this.state,this.panoramicVideoLoaded,this.mapImageConversionToolState,this.view,this.disabled,this.panoramicVideoPaused,this.videoViewModel?.videoPaused],(e,t)=>{const i=e[2],r=t?.[2];r&&!i&&(this.plotReferencePointOnGround(null),this.clearReferencePointOnImage()),this._createViewClickHandle(),this._createImageClickHandle()},M),b(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},M),b(()=>[this.state,this.imageLocationToolState,this.view],()=>{this._initializeMeasurementService(),this._initializeLocationViewModel()},M),b(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},M),b(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},M),b(()=>[this.superimposeViewEnabled,this.defaultSuperimposeCameraLockEnabled,this.superimposeViewSupported,this.currentBestFeature,this.mode,this.state,this.view?.type],()=>{this._shouldDisableUnsupportedSuperimposeView()?this.superimposeViewEnabled=!1:this._hasActiveSuperimposeCameraContext()?this._updateSuperimposedImage():this._resetInactiveSuperimposeState()},M),b(()=>this._getSuperimposeCameraWatchState(),()=>this._handleSuperimposeCameraChange(),M),b(()=>this.currentBestFeature,async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=a(async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}])),await this._featureChangedTask.promise},{sync:!0}),b(()=>[this.currentNode,this.preloadMedia,this.navigationMode],()=>{this._mediaPrefetchTask?.abort(),this._mediaPrefetchTask=a(async e=>{this.preloadMedia&&null!=this.navigationMode?(this._mediaPrefetcher??=await this._loadMediaPrefetcher({signal:e}),y(e),"directional"===this.navigationMode?this._mediaPrefetcher.enqueueDirectionalPrefetch(this.layer,this.currentNode,this.preloadMediaSize):this._mediaPrefetcher.enqueueSequentialPrefetch(this.layer,this.currentNode,this.preloadMediaSize)):this._mediaPrefetcher?.clear()})},M),b(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{m(this._featureChangedTask),t&&e!==t&&(this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this._measurementService?.resetMeasurementVectors()),this._featureChangedTask=a(async i=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:i}),y(i),this._reorderTriangularSketchLayer()})},M),b(()=>this.triangularMeasurementActive,(e,t)=>{t&&!e&&(this._measurementService?.resetMeasurementVectors(),this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearImage(),this._panoramicMeasurementViewer.clearGraphics())}),b(()=>this.mode,e=>{switch(this.removeHandles(Re.interactionHandles),e){case"default":this.addHandles(b(()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null},e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=a(async t=>{await this.updateFootprint(e,void 0,{signal:t})}))},{...M,equals:(e,t)=>i(e,t,d)}),Re.interactionHandles);break;case"video":this.addHandles(b(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:i}=this;if(e&&t?.loaded&&i)return{videoExtent:_e,bestFeatureFootprint:i}},e=>{e?.videoExtent&&e?.bestFeatureFootprint&&(m(this._updateFootprintTask),this._updateFootprintTask=a(async t=>{const i={points:e.videoExtent,feature:void 0,scale:void 0,options:{signal:t}};await this.updateVideoFootprint(i)}))},{...M,equals:(e,t)=>i(e?.videoExtent,t?.videoExtent,d)&&e?.bestFeatureFootprint===t?.bestFeatureFootprint}),Re.interactionHandles);break;case"panoramic":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:i}=this,{imageSize:r,vfov:a,hfov:s,pitch:o,yaw:n}=i;return e&&r&&!t.includes("loading")&&null!=a&&null!=s&&null!=o&&null!=n?[a,s,n,o]:null},e=>{if(!e||this.state.includes("loading"))return;const[t,i,r,s]=e;this.currentNode&&(this.currentNode.currentHeading=r,this.currentNode.currentPitch=s),m(this._updateFootprintTask),this._updateFootprintTask=a(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,d)}),Re.interactionHandles);break;case"panoramic-video":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:i}=this,{imageSize:r,vfov:a,hfov:s,pitch:o,yaw:n,viewModel:l}=i,c=l.closestFeature??e;return c&&r&&!t.includes("loading")&&null!=a&&null!=s&&null!=o&&null!=n?[a,s,n,o,c]:null},e=>{if(!e)return;const[t,i,r,s,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=a(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s,feature:o,horizonAngles:this._panoramicVideoViewer.horizonAngles},{signal:e}),y(e),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,d)}),Re.interactionHandles)}},M),b(()=>[this.brightness,this.contrast,this.sharpness],()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:r,sharpness:a}=this;"default"===r&&(e.brightness=t,e.contrast=i,e.sharpness=a)},M),b(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),b(()=>this.activeViewer,e=>{this.removeHandles(Re.hittestHandles),e&&this.addHandles(F(()=>e,"hittest-response",this._handleImageHitTestResponse),Re.hittestHandles)}),b(()=>this.videoMapView.extent,async()=>{this._scheduleVideoInteractionUpdate();const e=this.videoViewModel?.closestFeature;e&&(m(this._updateFootprintTask),this._updateFootprintTask=a(async t=>{const i={points:this.videoExtentPoints,feature:e,options:{signal:t}};await this.updateVideoFootprint(i)}))}),b(()=>[this.videoMapView.interacting,this.videoMapView.navigating,this.videoMapView.scale],()=>{this._scheduleVideoInteractionUpdate()},{initial:!0}),S(()=>null!=this.videoMapView.extent,()=>{this.initialVideoMapViewExtent=this.videoMapView.extent},{once:!0})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this._abortSuperimposeSchedule(),this.currentBestFeature=null,this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this._restoreSuperimposeMediaTask=m(this._restoreSuperimposeMediaTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=p(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this.videoViewModel=p(this.videoViewModel),this._locationViewModel=p(this._locationViewModel),this._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this.clearReferencePointOnImage(),this._superimposeService.destroy(),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy(),this._panoramicMeasurementViewer.destroy(),this._mediaPrefetcher?.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get activeTriangulatedViewer(){switch(this.mode){case"default":return this.imageMeasurementViewer;case"panoramic":return this._panoramicMeasurementViewer;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every(e=>0===e)??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",h(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",h(e,-10,10))}get currentNode(){const{currentBestFeature:e,navigationNodes:t}=this;return t.find(t=>t.id===e?.attributes.objectId)}get depthImageNotSupported(){if(this.currentBestFeature?.attributes.depthImage)return!De(this.currentBestFeature.attributes.depthImage)}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return De(t)||Se(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===Fe}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(He(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ne(e):null}get layerTimeExtent(){return this.layerView?.timeExtent??null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const t=e.orientedImageryType;if(t?.includes("video"))return t.includes("360")?"panoramic-video":"video";const{horizontalFieldOfView:i,isSpherical:r}=e;return 360===i||r?"panoramic":"default"}get panoramicVideoLoaded(){const{mode:e,_panoramicVideoViewer:t}=this,{videoLoaded:i}=t.viewModel;return("panoramic-video"===e&&!0===i)??!1}get overlayGraphicsEnabled(){const{mode:e,state:t,panoramicVideoLoaded:i,videoViewModel:r,panoramicVideoPaused:a}=this;return"image-loaded"===t||"video"===e&&"video-loaded"===t&&!0===r?.videoPaused||"panoramic-video"===e&&i&&a}get panoramicVideoPaused(){return!!this._panoramicVideoViewer.viewModel.videoPaused}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?be.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",h(e,0,1))}get superimposeViewSupported(){return"default"===this.mode||"panoramic"===this.mode}get sketchGraphicsLayer(){const{sketch:e}=this;return"graphics"===e?.layer?.type?e.layer:void 0}get state(){const{mode:e,_updatingHandles:{updating:t},_featureChangedTask:i}=this;if(!this.isFulfilled()||t||!1===i?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map(({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:r}})=>{const a=e?.trim();return De(a)||Se(a)?{url:a,objectId:t,rotation:(i??0)+(r??0)}:null}).filter(r)):null}get videoExtentPoints(){const e=Xe(this.videoMapView.extent);return e.length?e:_e}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new D({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new D({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}updateSuperimposeZOffset(e){this._superimposeService.updateZOffset(e)}setDefaultSuperimposeZOffsetPercentage(e){this._superimposeService.setDefaultZOffsetPercentage(e)}setPanoramicSuperimposeRadiusPercentage(e){this._superimposeService.setPanoramicRadiusPercentage(e)}updateDefaultSuperimposeCameraLock(e){this.defaultSuperimposeCameraLockEnabled=e,this.superimposeViewEnabled&&"default"===this.mode&&(e?this._adapter?.enableDefaultSuperimposeNavigation?.():this._adapter?.disableDefaultSuperimposeNavigation?.())}beforeLoad(e=!0){this.emit("popup-close"),e&&(this.displayMessage=null),this._abortSuperimposeSchedule(),this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._restoreSuperimposeMediaTask=m(this._restoreSuperimposeMediaTask),this._superimposeService.clear(),this._overlays?.removeAll()}async calculateLocationAccuracy(e){return this._measurementService?.calculateLocationAccuracy(e)}clearLocationPointOnImage(e=!1){this.locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this.locationPointOnImage),this._panoramicViewer.removeGraphic(this.locationPointOnImage),this.locationPointOnImage=p(this.locationPointOnImage)),this.correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this._panoramicMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this.correctedLocationPointOnImage=p(this.correctedLocationPointOnImage))}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:i,dataCaptureLayer:r}=this;if(!i)throw pt();ot(r,e,i),await i.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw pt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw pt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw pt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw pt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw pt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw pt();return this.sketch.update(e,t)}filterByFootprints(e,t,i=!1){const r=[],a=[],s=[];return e.forEach(e=>{const{layer:{coveragePercent:o},attributes:n}=e;let l;const{polygon:c,frustum:d}=q(n);if(l=c.clone(),n.isInspection&&(l=W(n)),o&&(l=$(l,o)),i||!t||Z(l,t)){s.push(e);const{geometry:t,objectId:i,cameraHeight:o,cameraHeading:l}=n,u=t.clone();u.z=o/K(t.spatialReference),u.imageID=i,this.pointSources.push(u),l!==Fe&&(r.push(c),d&&a.push(d))}}),{features:s,polygons:r,frustums:a}}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then(({features:e})=>t.applyEdits({deleteFeatures:e}))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[be[e]],i=t?.at(0);i&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(i):this._updateCurrentBestFeature(i))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const r=this._sectorData?.[t],a=r?.at(i);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!v(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=Q(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}async loadHeightMeasurementAdapter(e){if(!this.drawAdapter){const t=import("./adapters/draw/HeightMeasurementAdapter.js"),{default:i}=await t;if(y(e),this.drawAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.drawAdapter.viewModel.isResolved())return}return this.drawAdapter}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:i}=await t;y(e),this.sketch=new i({layer:this._defaultGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:i}=await t;if(y(e),this.sketchAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async processFeatureResponse(e,t,i){const{features:r}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(r))return;const{features:a,polygons:s,frustums:o}=this.filterByFootprints(r,t,i?.skipFilter);if(!this._checkFeatures(a))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,a,i);y(i),await this._updateElevationOfSelectedPointAndLocations(a,t,n),y(i),ze(a,n);let l=a;if(this.layer?.verticalSearchRange&&this.layer.hasZ&&this.verticalFilterEnabled&&(l=Ne(a,t,this.layer.verticalSearchRange),!l.length))return void this.setMessage("noImageAtElevation","info");const c=this._processSuitableFeatures(l,t);this.updateSuitabilities(c,i?.loadBestImage)}async processFeatureElevation(e,t,i){if(!t)return;const{features:r,polygons:a}=this.filterByFootprints(e,t,!0);if(!r?.length)return;const s=await this.processElevationSample(a,r,i);return y(i),s}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:i,sketchAdapter:r,activeViewer:a,mode:s}=this;if(!i||!r||!a||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(i.defaultCreateOptions.defaultZ=0),await i.create(e),"panoramic"===s){const{drawOperation:e}=i.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=Ce(o),this.sketch.polylineSymbol="panoramic"===s?Ae:ke(o,2.5))}async startHeightMeasurement(){this.displayNewMeasurementButton=!1,this.draw??=new de({view:this.activeViewer?.imageRenderer}),this.polylineDrawAction=this.draw.create("polyline"),await this.loadHeightMeasurementAdapter()}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:i,overlayedCameraLocations:a,layer:s,mode:o,layerFloorFilterClause:n,layerTimeExtent:l,videoViewModel:c,_panoramicVideoViewer:d}=this,u="video"===o,h="panoramic-video"===o,p=this._getActiveFeatureForCurrentMode(),m=this._computeOverlayImageSize();if(!(m&&p&&s&&"none"!==o&&this.overlayGraphicsEnabled))return;const{polygon:g}=q(p.attributes);if(u?c?.removeOverlayGraphics(a.toArray()):h?d.removeManyGraphics(a.toArray()):i?.removeManyGraphics(a.toArray()),a.removeAll(),e){const{features:e}=await s.queryFeatures({where:I(`${s.objectIdField} <> ${p.attributes.objectId}`,I(s.definitionExpression,n)),geometry:g,returnGeometry:!0,outFields:[s.objectIdField],timeExtent:l}),v=await Promise.all(e.map(async e=>{const{attributes:i,geometry:r}=e;if("point"!==r?.type)return null;const a=await this._geometryToOverlayImageGeometry(r,p,m);if(!a)return null;const s="panoramic"===o||"panoramic-video"===o?Te():Oe();return new t({attributes:i,symbol:s,geometry:a})}));a.addMany(v.filter(r)),u?c?.addOverlayGraphics(a.toArray()):h?d.addManyGraphics(a.toArray()):i?.addManyGraphics(a.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),"video"!==this.mode?"panoramic-video"!==this.mode?this.activeViewer?.addManyGraphics(t.toArray()):this._panoramicVideoViewer.addManyGraphics(t.toArray()):this.videoViewModel?.addOverlayGraphics(t.toArray())}async overlayMapFeatures(e,i=!1){const{activeViewer:a,mode:o,layer:n,videoViewModel:l,_panoramicVideoViewer:c}=this,d="video"===o,h="panoramic-video"===o,p=this._getActiveFeatureForCurrentMode(),m=this._computeOverlayImageSize();if(!(m&&p&&"none"!==o&&this.overlayGraphicsEnabled&&n))return;const{polygon:g}=q(p.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=nt(e,n.imageGeometryField,n.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(w){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",w)}const{features:v}=await e.queryFeatures({geometry:g,returnGeometry:!0,outFields:["*"]}),y=await Promise.all(v.map(async r=>{const s=r.symbol?.clone()??e.renderer?.getSymbol(r)?.clone(),{attributes:n,geometry:g}=r,{imageGeometryField:v,oiObjectIdField:y}=this;if(v&&y&&ht(e,v,y)&&`${n[y]}`==`${p.attributes.objectId}`)try{const r=h?c.horizonAngles:Be(a?.media),u=lt(n,v,e,i,m,d?"default":o,s,r);if(!d)return u;const p=u.geometry;if(!p)return null;const g=l?.imageGeometryToOverlayGeometry(p);return g?new t({attributes:n,layer:e,symbol:u.symbol,geometry:g,visible:u.visible}):null}catch(w){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:w,feature:r,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}if(!g)return null;const f={feature:p,imageSize:m,footprintExtent:this.footprintExtent},_=await this._geometryToOverlayImageGeometry(g,f.feature,f.imageSize);return _?new t({attributes:n,layer:e,symbol:s,geometry:_,visible:e.visible&&i}):null})),f=new s(y.filter(r));("video"!==o&&"panoramic-video"!==o||this.overlayGraphicsEnabled)&&this.overlayGraphicsOnImage(`${e.id}`,f)}getDepthAt(e){const{activeViewer:t,currentBestFeature:i,mode:r,state:a,depthImage:s}=this,o=t?.imageSize;if(!o||!i||"none"===r||a.includes("loading"))return u.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!s?.loaded)return u.getLogger(this).error("oriented-imagery-viewer:get-depth-at","Depth image is not loaded"),this.emit("depth-image-service:not-loaded"),null;const n=(Array.isArray(e)?e:[e]).map(e=>s.depthAt(e,{width:o[0],height:o[1]})??null);return Array.isArray(e)?n:n[0]}getActiveSectors(){return be.filter(e=>this._sectorData?.[e]?.length)}async getPixelLocationForFeature(e,t,i){return(await this._transformationService.pointToPixelForFeature([e],t,i))[0]}async getPixelLocationsForFeature(e,t,i){return await this._transformationService.pointToPixelForFeature(e,t,i)}async plotMapPoint(e){this.plotReferencePoint(e);const t=this._getActiveFeatureForCurrentMode();if(t)return this.transformAndPlotReferencePointOnImage({feature:t,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new L({...e.toJSON()}),symbol:Le}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){switch(this.mode){case"video":return void this._plotReferencePointOnVideo(e);case"panoramic-video":return void this._plotReferencePointOnPanoramicVideo(e);case"default":return void this._plotReferencePointOnDefaultImage(e);case"panoramic":return void this._plotReferencePointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){const{mode:e}=this;this.overlayedMapFeatures.forEach(t=>{const i=t.toArray();switch(e){case"video":this.videoViewModel?.removeOverlayGraphics(i);break;case"panoramic-video":this._panoramicVideoViewer.removeManyGraphics(i);break;default:this.activeViewer?.removeManyGraphics(i)}}),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e),{mode:i}=this;if(!t?.length)return;const r=t.toArray();switch(i){case"video":this.videoViewModel?.removeOverlayGraphics(r);break;case"panoramic-video":this._panoramicVideoViewer.removeManyGraphics(r);break;default:this.activeViewer?.removeManyGraphics(r)}this.overlayedMapFeatures.delete(e)}reset(){const{mode:e}=this;"default"===e||"panoramic"===e?this.resetImage():"video"===e?this.resetVideo():"panoramic-video"===e&&this.resetVideoPanoramic(),this.beforeLoad(!1)}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}resetVideo(){this.setMessage("onLoadMessage","info"),this.videoViewModel?.resetVideoHandler(),this._overlays?.removeAll(),this.videoViewModel=null,this.featureCache=[],this.currentBestFeature=null}resetVideoPanoramic(){this.setMessage("onLoadMessage","info"),this._overlays?.removeAll(),this.currentBestFeature=null}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0,this._measurementService?.resetMeasurementVectors()}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:i,savedGraphics:r}=t,a=i.get(e.id),s=a?.toArray();if(!a||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce((t,{objectId:i,globalId:r,error:a},o)=>{const n=s[o],{attributes:l}=n;return a?t.error.push(n):(i&&(l[e.objectIdField]=i),r&&e.globalIdField&&(l[e.globalIdField]=r),t.success.push(n)),t},{success:[],error:[]});r.addMany(n.success),a.removeAll(),a.addMany(n.error)}async saveDataCaptureFeatures(e,t){const{activeViewer:i,currentBestFeature:a,dataCaptureLayer:s,mode:o}=this,l=i?.imageSize;if(!l||!a||"none"===o||"video"===o||"panoramic-video"===o)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!s)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const c=await Promise.all(e.map(async e=>{const i=e.clone(),{geometry:r}=i;if(!r)return;const a=r.type,o=s.hasZ,n=s.geometryType,l=a!==n,c=l?await import("./transformers.js"):null,d=c?.default[n],u=l?d?.(r):r;return u&&(i.geometry=await this._transformationService.imageGeometryToMapGeometry(u,t),i.geometry)?(o||ct(i.geometry),i):void 0})),d=c.filter(r);return s.applyEdits({addFeatures:d}).then(e=>{const{addFeatureResults:t}=e;let i=0;const r=c.map(e=>{const r=t[i++];return e?r:{error:new n("orientedimageryviewer:save-unsucccessful","Error in saving data capture features"),objectId:null,globalId:null}});return{...e,addFeatureResults:r}})}async searchBestImage(e,t){try{const i=await z(e,t);i&&await this.processFeatureResponse(i,e.point,t)}catch(i){v(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find(({attributes:t})=>t.objectId===Number(e))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach(t=>{t.visible=e})}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach(t=>{t.visible=e})}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const i=this.activeViewer?.imageRenderer,{oiObjectIdField:r,currentBestFeature:a}=this;if(!i||!a||!r)return;const{attributes:{objectId:o}}=a,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(r)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const d=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);y(t),d.addGraphics(l),u.savedGraphics.addMany(l);i.ui.find("zoom").visible=!1,i.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,i=this.activeViewer?.imageRenderer;if(!i||i.destroyed)return;i.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const r=i.ui.find("zoom");r&&(r.visible=!0)}stopMeasurement(){this.draw?.reset(),this.sketch?.cancel()}async toggleAllOverlayMapFeatures(e){!e&&this.dataCaptureLayer&&(await this.stopDataCapture(!0),this.dataCaptureLayer=null),this.overlayedMapFeatures.forEach(t=>{this._toggleVisiblity(t,e)})}toggleOverlayMapFeatures(e,t,i){const r=this.overlayedMapFeatures.get(e);r&&i&&this._toggleVisiblity(r,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{feature:t,selectedLocation:i,options:r}=e;let a=!1,s=!1;const o="video"===this.mode?this.bestFeatureCurrentFootprint?.geometry:this.bestFeatureFootprint?.geometry;switch(o?.type){case"polygon":{const e=i.spatialReference.equals(o.spatialReference)?i:await G(i,o.spatialReference);a=o.contains(e);break}case"mesh":{const e=i.spatialReference.equals(o.spatialReference)?i:await G(i,o.spatialReference);s=o.extent.contains(e);break}}if(!a&&!s)return void this.clearReferencePointOnImage();const n="video"===this.mode||"panoramic-video"===this.mode?await this.getPixelLocationForFeature(i,{feature:t,mode:this.mode,imageSize:ye,footprintExtent:this.footprintExtent},r):await this._transformationService.pointToPixel(i,r);if(n)return y(r),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}async updateFeatureCache(e,t){const i=await N(e,t);i.features?.length&&(this.featureCache=i.features)}_plotReferencePointOnVideo(e){"video-loaded"===this.state&&this.videoViewModel?.videoPaused&&(this.clearReferencePointOnImage(),this.videoViewModel.plotReferencePointOnVideo(e))}_plotReferencePointOnPanoramicVideo(e){const i=this._panoramicVideoViewer,{imageSize:r,media:a}=i.viewModel;if(!this.panoramicVideoLoaded||!this.panoramicVideoPaused||!r)return;this.clearReferencePointOnImage();const s=Be(a),o=dt(e,"panoramic",r,s);this._referencePointOnImage=new t({geometry:o,symbol:Ge.clone()}),i.addGraphic(this._referencePointOnImage,0)}_getActiveFeatureForCurrentMode(){switch(this.mode){case"video":return this.videoViewModel?.closestFeature??this.currentBestFeature;case"panoramic-video":return this._panoramicVideoViewer.viewModel.closestFeature??this.currentBestFeature;default:return this.currentBestFeature}}_plotReferencePointOnDefaultImage(e){const i=this._imageViewer,{imageSize:r}=i;if("image-loaded"!==this.state||!r)return;this.clearReferencePointOnImage();const a=dt(e,"default",r);this._referencePointOnImage=new t({geometry:a,symbol:Le.clone()}),i.addGraphic(this._referencePointOnImage,0)}_plotReferencePointOnPanoramicImage(e){const i=this._panoramicViewer,{imageSize:r,media:a}=i;if("image-loaded"!==this.state||!r)return;this.clearReferencePointOnImage();const s=Be(a),o=dt(e,"panoramic",r,s);this._referencePointOnImage=new t({geometry:o,symbol:Ge.clone()}),i.addGraphic(this._referencePointOnImage,0)}async _fetchFeatures(e,t){const{layer:i,layerFloorFilterClause:r,layerTimeExtent:a,view:s}=this;if(!s)return;if(!i)return void this.setMessage("noLayerSelected","info");e.x=x(e.x,e.spatialReference);const o=i.spatialReference.equals(e.spatialReference)?e:await G(e,i.spatialReference),n=o.spatialReference.isGeographic?B(o):o,l=I("1=1",I(i.definitionExpression,r)),c=n.spatialReference.isGeographic?1:P(n.spatialReference),d={layerInstanceOrURL:i,point:n,queryParams:{where:l,maximumDistance:i.maximumDistance?i.maximumDistance/c:void 0,timeExtent:a}};return await this.searchBestImage(d,t)}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(v(i))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:i,invalidCameraHeading:r}=this,a=i.at(0);if(!e||!t||!a||!i||r)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const d of be)this._sectorData[d]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const l=n.map(({distance:e})=>e),c=Math.max(...l);n.forEach(e=>{const{distance:t,angle:r,featureIndex:s}=e,n=t/c*Ve[2],l=Ze(t,c),d=Je(r);if(!this._sectorData)return;const u=Ve[3]+n*Math.sin(r*Math.PI/180),h=Ve[3]+n*Math.cos(r*Math.PI/180);let p;const m=i.at(s),g=m===a,{cameraPitch:v}=m.attributes,y=v<5;if(g&&y)p=-90;else{const e=u-Ve[3],t=h-Ve[3],i=t/Math.sqrt(e**2+t**2);let r=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(r*=-1),p=r}const f=""===l?d:`${l}_${d}`;g&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=y?null:{x:u,y:h,direction:d}),o[`${m.attributes.objectId}`]=f;const w=this._sectorData[f];w.add({angle:r,featureIndex:s,x:u,y:h,objectID:m.attributes.objectId,sector:f,featureIndexInSector:w.length})})}async _initializeLocationViewModel(e){if(!this._locationViewModel){const t=import("./components/ImageLocationViewModel.js"),{default:i}=await t;y(e),this._locationViewModel=new i({oiViewModel:this,referenceTransformationService:this._referenceTransformationService})}}_initializeMeasurementService(){this._measurementService||(this._measurementService=new at({transformationService:this._transformationService,referenceTransformationService:this._referenceTransformationService}))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(Re.videoPlayerHandles),this.videoElement=new le({video:this.currentBestFeature.attributes.imagePath,georeference:new oe({extent:new O(Me)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new H({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.videoViewModel=new tt({oiViewModel:this})}async getMapPoint(e,t){const i=await this._transformationService.pixelToMapPoint(Array.isArray(e)?e:[e],t);return Array.isArray(e)?i:i[0]}async getMapPointForFeature(e,t,i){const r=await this._transformationService.pixelToMapPointForFeature(Array.isArray(e)?e:[e],t,i);return Array.isArray(e)?r:r[0]}async loadPanoramicMediaSource(e,t){const{lookAt:i,...r}=e,a=Ue(r);try{await a.load(t)}catch(o){if(v(o))return;if("unsupported-format"===o.name)return void this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:a?.extension??"UNKNOWN FORMAT"})}const s=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;await s.loadMedia(a,t),i&&s.set(i)}async loadMediaSource(e,t){const i=qe(e);await this._setImageSource(this.triangularMeasurementActive?this.imageMeasurementViewer:this._imageViewer,i,t)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.emit("no-image-found"),this.setMessage("noImageError","error"),this.videoElement?.content?.pause(),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,i){if(!e[0])return;const r=(await import("../../geometry/operators/unionOperator.js")).executeMany(e);if(this._updateFootprintWithFeatures(t,r),"3d"===this.view?.type)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(a){v(a)||u.getLogger(this).error(a)}}async processElevationSample(e,t,i){const{elevationSource:r}=t[0].attributes,a=await this._getElevationSampleFromGround(e,t,i);return a||(r&&this.footprintExtent&&J(r)?await Y({extent:this.footprintExtent,lod:r.lod,url:r.url,rasterFunction:r.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return U({features:e,selectedPoint:t,camera:We(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,i){const{results:[r]}=t;if("graphic"!==r?.type)return this.beforeLoad(!1),this.emit("no-image-found"),void this.setMessage("noImageError","error");const a=r.graphic.getAttribute(e.objectIdField);return await this.showImageByObjectId(a,i)}async _queryAndLoadByObjectId(e,t,i,r,a){this.displayMessage=null;const{response:s}=await rt(e,t,i,r,a);if(y(a),!s?.features?.length)throw new it(t);const o=q(s.features[0].attributes).polygon,n=L.fromJSON(j(o)),l=Q(n),c=P(l.spatialReference);this.selectedPoint=l;const d={layerInstanceOrURL:e,point:l,queryParams:{where:I(I("1=1",I(e.definitionExpression,i)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0,timeExtent:r}},u=await z(d,a);y(a);const{features:h}=u;return h.push(s.features[0]),await this.processFeatureResponse(u,l,{...a,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}async _setImageSource(e,t,i){e.media=t,await e.loadMedia(t,i)}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,i,r){const{location:a,cameraHeight:s}=e[0].attributes,o=await re(a.spatialReference,a.z,s,{elevationSample:i,elevationSource:i?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},r);y(r);const[n,...l]=await X([t,...e.map(e=>e.attributes.geometry.clone())],o);y(r),t.elevation=n.z,e.forEach((e,t)=>{e.attributes.elevation=l[t].z})}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.navigationNodes.removeAll(),this.navigationNodes.addMany(e.map(e=>{const{geometry:t,attributes:i}=e,{isSpherical:r,cameraHeading:a,cameraPitch:s}=i;return new et({geometry:t,attributes:i,currentHeading:r?0:a,currentPitch:r?0:s})})),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0])}_updateFootprintWithFeatures(e,t){const i=[];for(const{attributes:{geometry:r}}of e)t.contains(r)||i.push([r.x,r.y]);i.sort((e,t)=>+R([e,t])),t.addRing(i),this.footprintExtent=ue(t.extent,2,2)}_scheduleVideoInteractionUpdate(){this.scheduledFrameId||(this.scheduledFrameId=requestAnimationFrame(()=>{this.scheduledFrameId=null,this._updateInteraction()}))}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:r,currentCoverageVisible:a,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(r&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),y(e);for(const o of i){const i=this.view&&!this.view.spatialReference?.equals(o.spatialReference)?await G(o.clone(),this.view?.spatialReference,e):o.clone();o.imageID===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:o.imageID},geometry:i,symbol:Ee,visible:a}):this.additionalCameraLocations.push(new t({attributes:{imageID:o.imageID},geometry:i,symbol:je,visible:s}))}"video"!==o&&"panoramic-video"!==o||(await this.initializeTransformationService(e),n&&!this.featureCache.length&&await this.updateFeatureCache(n,r.geometry.spatialReference))}}_updateCurrentBestFeature(e){if(!e)return;if(this.currentBestFeature=this.features?.at(e.featureIndex),"video"===this.mode)return void(this.currentBestFeature&&this.videoViewModel?.playVideoFromSelectedLocation(this.currentBestFeature));if("panoramic-video"===this.mode)return void(this.currentBestFeature&&this._panoramicVideoViewer.viewModel.playPanoramicVideoFromSelectedLocation(this.currentBestFeature));const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-Ve[3],r=e.y-Ve[3],a=r/Math.sqrt(t**2+r**2);let s=180*Math.acos(a)/Math.PI;(t<0&&r<0||t<0&&r>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._panoramicVideoViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage)),this.videoViewModel?.clearReferencePointOnVideo()}async initializeReferenceTransformationService(e){const{currentBestFeatureMeasurementImage:t,activeTriangulatedViewer:i,mode:r}=this;if(!t||!i||!i.imageSize||"panoramic"!==r&&"default"!==r)return;const{imageSize:a}=i,{attributes:s,elevationSample:o}=t,{location:{spatialReference:n,z:l},cameraHeight:c,elevationSource:d}=s;let u=s.location;u.spatialReference.isGeographic&&(u=Q(u));const h="default"===r?ae(s,a[0],a[1]):se(s,a[0],a[1]),p=await re(n,l??0,c,{elevationSample:o,elevationSource:d,extent:this.footprintExtent},e),m=(await import("./services/TransformationService.js")).default,g={imageToWorldProperties:h,updateElevationProps:p,mode:r,imageSize:a,depthImageService:this.depthImage};this._referenceTransformationService=new m(g),this._locationViewModel&&(this._locationViewModel.referenceTransformationService=this._referenceTransformationService),this._measurementService&&(this._measurementService.referenceTransformationService=this._referenceTransformationService)}async initializeTransformationService(e){const{currentBestFeature:t,activeViewer:i,mode:r}=this,a="video"===r||"panoramic-video"===r?ye:i?.imageSize;if(!t||!a||"none"===r)return;const{attributes:s,elevationSample:o}=t,{location:{spatialReference:n,z:l},cameraHeight:c,elevationSource:d}=s;let u=s.location;u.spatialReference.isGeographic&&(u=Q(u));const h="default"===r||"video"===r?"default":"panoramic",p={..."default"===h?ae(s,a[0],a[1]):se(s,a[0],a[1]),cameraLocation:u},m=await re(n,l??0,c,{elevationSample:o,elevationSource:d,extent:this.footprintExtent},e),g=(await import("./services/TransformationService.js")).default,v={imageToWorldProperties:p,updateElevationProps:m,mode:h,imageSize:a,depthImageService:this.depthImage};this._transformationService=new g(v),this._measurementService&&(this._measurementService.transformationService=this._transformationService)}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,r){this.displayMessage={key:e,type:t,data:i,map:r}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:i,selectedPoint:r,activeViewer:a}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!r||!t||"image-loaded"!==a?.state||i)return;let s;try{s=await this._transformationService.pointToPixel(r,{signal:e?.signal}),y(e),await this.plotSelectedPointOnImage(s,e)}catch(o){v(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:r,feature:t})}}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:r,currentBestFeature:a,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:d}=this;if(!a)return;const{attributes:{objectId:u},elevationSample:h}=a;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...r,s].filter($e);"3d"===l?.type&&h&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e),"panoramic"===d&&c.updateGroundElevation([this.bestFeatureCurrentFootprint])),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:Ie.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return void this._superimposeService.clear();this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,"3d"===l?.type&&h&&c?.updateGroundElevation&&"panoramic"===d&&c.updateGroundElevation([e]),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}_updateSuperimposedImage(){if(!this._hasActiveSuperimposeCameraContext())return;const e="panoramic"===this.mode?this._panoramicViewer:null,{currentBestFeature:t,defaultSuperimposeCameraLockEnabled:i,layer:r,mode:a,view:s,state:o,superimposeViewEnabled:n,superimposeViewSupported:l,activeViewer:c,depthImage:d}=this,u=this.coverageFrustums.find(({imageID:e})=>e===t?.attributes.objectId);this._superimposeService.update({activeImageSize:c?.imageSize||void 0,adapter:this._adapter,currentBestFeature:t,currentBestFeatureFrustum:u,defaultSuperimposeCameraLockEnabled:i,depthImageLoaded:d?.loaded??!1,layer:r,mode:a,panoramicCamera:e?.camera,panoramicHorizonAngles:Be(e?.media),state:o,superimposeViewEnabled:n&&l,view:s}),this.setMessage("superimposeImageDescription","info"),this._superimposePreviousCurrentCoverageVisible??=this.currentCoverageVisible,this.currentCoverageVisible=!1}_getSuperimposeCameraWatchState(){const e="3d"===this.view?.type?this.view:null,t=e?.camera;return[this.superimposeViewEnabled,this.superimposeViewSupported,this.mode,this.state,this.view?.type,this.view?.interacting,this.view?.navigating,t?.heading,t?.tilt,t?.fov,t?.position.x,t?.position.y,t?.position.z]}_handleSuperimposeCameraChange(){const e=this.view,t="3d"===e?.type?e:null;this._hasActiveSuperimposeCameraContext()?"panoramic"!==this.mode?!t||t.interacting||t.navigating?this._abortSuperimposeSchedule():this._scheduleDefaultSuperimposeUpdate():this._schedulePanoramicSuperimposeUpdate():this._abortSuperimposeSchedule()}_shouldDisableUnsupportedSuperimposeView(){return this.superimposeViewEnabled&&"panoramic"===this.mode&&!this.superimposeViewSupported}_hasActiveSuperimposeCameraContext(){return("default"===this.mode||"panoramic"===this.mode)&&this.superimposeViewEnabled&&this.superimposeViewSupported&&"image-loaded"===this.state&&"3d"===this.view?.type&&!!this.view.camera}_abortSuperimposeSchedule(){this._superimposeScheduleController?.abort(),this._superimposeScheduleController=null,this._clearSuperimposeDebounceTimeout(),this._clearSuperimposeScheduledFrame()}_resetInactiveSuperimposeState(){const e=null!=this._superimposePreviousCurrentCoverageVisible;this._abortSuperimposeSchedule(),this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this._superimposeService.clear(),this._restoreCurrentCoverageVisibilityAfterSuperimpose(),this._restoreDefaultMessageAfterSuperimpose(),e&&this._restoreViewerMediaAfterSuperimpose()}_restoreCurrentCoverageVisibilityAfterSuperimpose(){null!=this._superimposePreviousCurrentCoverageVisible&&(this.currentCoverageVisible=this._superimposePreviousCurrentCoverageVisible,this._superimposePreviousCurrentCoverageVisible=null)}_restoreViewerMediaAfterSuperimpose(){const{currentBestFeature:e,mode:t}=this;if(!e||"default"!==t&&"panoramic"!==t)return;this._restoreSuperimposeMediaTask?.abort();const i=a(async t=>{await this._loadCurrentFeatureMedia(e,{signal:t})});this._restoreSuperimposeMediaTask=i,i.promise.finally(()=>{this._restoreSuperimposeMediaTask===i&&(this._restoreSuperimposeMediaTask=null)})}_restoreDefaultMessageAfterSuperimpose(){if("superimposeImageDescription"===this.displayMessage?.key){!!this.currentBestFeature&&("default"===this.mode||"panoramic"===this.mode)?this.displayMessage=null:this.setMessage("onLoadMessage","info")}}_clearSuperimposeDebounceTimeout(){null!=this.superimposeDebounceTimeoutId&&(clearTimeout(this.superimposeDebounceTimeoutId),this.superimposeDebounceTimeoutId=null)}_clearSuperimposeScheduledFrame(){null!=this.superimposeScheduledFrameId&&(cancelAnimationFrame(this.superimposeScheduledFrameId),this.superimposeScheduledFrameId=null)}_schedulePanoramicSuperimposeUpdate(){this._abortSuperimposeSchedule(),this.superimposeDebounceTimeoutId=window.setTimeout(()=>{this.superimposeDebounceTimeoutId=null,this._hasActiveSuperimposeCameraContext()&&"panoramic"===this.mode&&this._updateSuperimposedImage()},150)}_scheduleDefaultSuperimposeUpdate(){const e=this.view;if(!("3d"===e?.type?e:null))return;if(this.superimposeScheduledFrameId)return;this._superimposeScheduleController?.abort();const t=new AbortController,{signal:i}=t,r=()=>{this._clearSuperimposeDebounceTimeout(),this._clearSuperimposeScheduledFrame(),this._superimposeScheduleController===t&&(this._superimposeScheduleController=null),i.removeEventListener("abort",r)};this._superimposeScheduleController=t,i.addEventListener("abort",r),this.superimposeScheduledFrameId=requestAnimationFrame(()=>{if(i.removeEventListener("abort",r),this.superimposeScheduledFrameId=null,this._superimposeScheduleController===t&&(this._superimposeScheduleController=null),i.aborted)return;const e=this.view,a="3d"===e?.type?e:null;!this._hasActiveSuperimposeCameraContext()||null==a||a.interacting||a.navigating||this._updateSuperimposedImage()})}};e([C()],mt.prototype,"activeLayer",null),e([C({readOnly:!0})],mt.prototype,"activeViewer",null),e([C()],mt.prototype,"activeTriangulatedViewer",null),e([C()],mt.prototype,"accuracyParametersMissing",null),e([C()],mt.prototype,"additionalFeatures",void 0),e([C({type:s.ofType(t)})],mt.prototype,"additionalCameraLocations",void 0),e([C({type:s.ofType(t)})],mt.prototype,"additionalFootprints",void 0),e([C()],mt.prototype,"areaMeasurementResult",void 0),e([C()],mt.prototype,"areaMeasurementAccuracy",void 0),e([C()],mt.prototype,"bestFeatureAngle",void 0),e([C()],mt.prototype,"bestFeatureCurrentFootprint",void 0),e([C({type:t})],mt.prototype,"bestFeatureFootprint",void 0),e([C({type:Number})],mt.prototype,"brightness",null),e([C()],mt.prototype,"cameraHeadingThreshold",void 0),e([C()],mt.prototype,"cameraPitchThreshold",void 0),e([C()],mt.prototype,"clickAction",void 0),e([C()],mt.prototype,"correctedLocationPointOnImage",void 0),e([C()],mt.prototype,"videoViewModel",void 0),e([C()],mt.prototype,"collectionId",void 0),e([C({type:Number})],mt.prototype,"contrast",null),e([C()],mt.prototype,"coverageFrustums",void 0),e([C()],mt.prototype,"coveragePolygons",void 0),e([C()],mt.prototype,"currentBestFeature",void 0),e([C()],mt.prototype,"currentBestFeatureMeasurementImage",void 0),e([C()],mt.prototype,"currentBestFeatureLocation",void 0),e([C()],mt.prototype,"currentCoverageVisible",void 0),e([C()],mt.prototype,"currentNode",null),e([C()],mt.prototype,"depthImage",void 0),e([C()],mt.prototype,"depthImageNotSupported",null),e([C()],mt.prototype,"featureCache",void 0),e([C()],mt.prototype,"navigationNodes",void 0),e([C({json:{write:!1}})],mt.prototype,"determineWorkflowForFeature",void 0),e([C({json:{write:!1}})],mt.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([C()],mt.prototype,"disabled",void 0),e([C()],mt.prototype,"displayMessage",void 0),e([C()],mt.prototype,"displayNewMeasurementButton",void 0),e([C()],mt.prototype,"distanceMeasurementResult",void 0),e([C()],mt.prototype,"distanceAccuracyArray",void 0),e([C()],mt.prototype,"dataCaptureLayer",void 0),e([C({readOnly:!0})],mt.prototype,"featureCount",null),e([C()],mt.prototype,"features",void 0),e([C()],mt.prototype,"groundCoordinates",void 0),e([C()],mt.prototype,"groundCoordinatesAccuracy",void 0),e([C()],mt.prototype,"heightGraphic",void 0),e([C()],mt.prototype,"heightMeasurementResult",void 0),e([C()],mt.prototype,"heightMeasurementAccuracy",void 0),e([C({readOnly:!0})],mt.prototype,"imageGalleryEnabled",null),e([C()],mt.prototype,"imageGeometryField",void 0),e([C({readOnly:!0})],mt.prototype,"imageLoaded",null),e([C()],mt.prototype,"imageLocationToolState",void 0),e([C()],mt.prototype,"initialVideoMapViewExtent",void 0),e([C({readOnly:!0})],mt.prototype,"invalidCameraHeading",null),e([C()],mt.prototype,"imagePointsInView",null),e([C()],mt.prototype,"imageMeasurementViewer",void 0),e([C()],mt.prototype,"isAdditionalCoverageVisible",void 0),e([C()],mt.prototype,"isAdditionalPointSourcesVisible",void 0),e([C()],mt.prototype,"layer",void 0),e([C()],mt.prototype,"layerView",null),e([C({readOnly:!0})],mt.prototype,"layerFloorFilterClause",null),e([C({readOnly:!0})],mt.prototype,"layerTimeExtent",null),e([C({type:Number})],mt.prototype,"localPort",void 0),e([C()],mt.prototype,"locationPointOnImage",void 0),e([C()],mt.prototype,"mapImageConversionToolState",void 0),e([C()],mt.prototype,"measureType",void 0),e([C()],mt.prototype,"measurementGraphic",void 0),e([C({readOnly:!0,value:"none"})],mt.prototype,"mode",null),e([C()],mt.prototype,"navigationMode",void 0),e([C()],mt.prototype,"navigatorCurrentBestFeature",void 0),e([C()],mt.prototype,"oiObjectIdField",void 0),e([C({type:s.ofType(t)})],mt.prototype,"overlayedCameraLocations",void 0),e([C()],mt.prototype,"overlayedMapFeatures",void 0),e([C()],mt.prototype,"panoramicVideoLoaded",null),e([C()],mt.prototype,"panoramicVideoPaused",null),e([C()],mt.prototype,"pixelCoordinates",void 0),e([C()],mt.prototype,"preserveAngle",void 0),e([C()],mt.prototype,"pointSources",void 0),e([C({readOnly:!0})],mt.prototype,"popupEnabled",null),e([C()],mt.prototype,"preloadMedia",void 0),e([C()],mt.prototype,"preloadMediaSize",void 0),e([C()],mt.prototype,"previousFeatureAngle",void 0),e([C()],mt.prototype,"referencePoint",null),e([C({readOnly:!0})],mt.prototype,"sectorData",null),e([C()],mt.prototype,"selectedPoint",void 0),e([C({type:Number})],mt.prototype,"sharpness",null),e([C()],mt.prototype,"shouldShowSelectedImage",void 0),e([C()],mt.prototype,"superimposeViewEnabled",void 0),e([C()],mt.prototype,"defaultSuperimposeCameraLockEnabled",void 0),e([C()],mt.prototype,"superimposeViewSupported",null),e([C()],mt.prototype,"sketch",void 0),e([C()],mt.prototype,"sketchTriangular",void 0),e([C()],mt.prototype,"sketchTriangularGraphicsLayer",void 0),e([C()],mt.prototype,"draw",void 0),e([C()],mt.prototype,"drawAdapter",void 0),e([C()],mt.prototype,"polylineDrawAction",void 0),e([C()],mt.prototype,"scheduledFrameId",void 0),e([C()],mt.prototype,"superimposeScheduledFrameId",void 0),e([C()],mt.prototype,"superimposeDebounceTimeoutId",void 0),e([C()],mt.prototype,"sketchAdapter",void 0),e([C({readOnly:!0})],mt.prototype,"sketchGraphicsLayer",null),e([C({readOnly:!0})],mt.prototype,"state",null),e([C({readOnly:!0})],mt.prototype,"thumbnails",null),e([C()],mt.prototype,"videoExtentPoints",null),e([C()],mt.prototype,"triangularMeasurementActive",void 0),e([C()],mt.prototype,"triangulatedDistanceMeasurement",void 0),e([C()],mt.prototype,"triangulatedDistanceAccuracy",void 0),e([C()],mt.prototype,"triangulatedAreaMeasurement",void 0),e([C()],mt.prototype,"triangulatedAreaAccuracy",void 0),e([C()],mt.prototype,"triangulatedMeasurementGraphic",void 0),e([C()],mt.prototype,"triangulatedPoint",void 0),e([C()],mt.prototype,"triangulatedMeasurementAdapter",void 0),e([C()],mt.prototype,"updateFootprint",void 0),e([C()],mt.prototype,"updateVideoFootprint",void 0),e([C()],mt.prototype,"updateFootprintPanorama",void 0),e([C()],mt.prototype,"updatingTriangularMeasurementState",void 0),e([C({value:null})],mt.prototype,"view",null),e([C()],mt.prototype,"videoElement",void 0),e([C()],mt.prototype,"videoLayer",void 0),e([C()],mt.prototype,"videoMapView",void 0),e([C()],mt.prototype,"verticalFilterEnabled",void 0),e([C()],mt.prototype,"_adapter",void 0),e([C()],mt.prototype,"_defaultGraphicsLayer",null),e([C()],mt.prototype,"_highlightedFeatureHandle",void 0),e([C()],mt.prototype,"_imageViewer",void 0),e([C()],mt.prototype,"_initialCurrentCoverageUpdate",void 0),e([C()],mt.prototype,"_locationViewModel",void 0),e([C()],mt.prototype,"_measurementService",void 0),e([C()],mt.prototype,"_mediaPrefetcher",void 0),e([C()],mt.prototype,"_navigationManager",void 0),e([C()],mt.prototype,"_overlays",void 0),e([C()],mt.prototype,"_superimposePreviousCurrentCoverageVisible",void 0),e([C()],mt.prototype,"_superimposeService",void 0),e([C({readOnly:!0})],mt.prototype,"_overlaysView",null),e([C()],mt.prototype,"_panoramicVideoViewer",void 0),e([C()],mt.prototype,"_panoramicViewer",void 0),e([C()],mt.prototype,"_panoramicMeasurementViewer",void 0),e([C()],mt.prototype,"_referencePointOnGround",void 0),e([C()],mt.prototype,"_referencePointOnImage",void 0),e([C()],mt.prototype,"_referenceTransformationService",void 0),e([C()],mt.prototype,"_sectorData",void 0),e([C()],mt.prototype,"_transformationService",void 0),e([C()],mt.prototype,"_featureToSector",void 0),e([C({readOnly:!0})],mt.prototype,"_updatingHandles",void 0),e([C()],mt.prototype,"footprintExtent",void 0),e([C()],mt.prototype,"_featureChangedTask",void 0),mt=e([A("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],mt);const gt=mt;export{gt as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import i from"../../../../core/Collection.js";import r from"../../../../core/ReactiveMap.js";import{property as a,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{extractHorizonAnglesFromMedia as s}from"../../utils.js";import{SketchHandlerMixin as c}from"../../mixins/SketchHandlerMixin.js";import{mapSpaceToImageSpace as p}from"../../support/dataCaptureUtils.js";let d=class extends(c(t)){constructor(e){super(e),this.savedGraphics=new i,this.type="data-capture",this.pendingGraphics=new r}get collectionId(){return this.viewModel.collectionId}handleCreate(e){const{state:t,graphic:i,tool:r}=e,a=i?.geometry;if("complete"!==t||!i||!a)return;const{collectionId:o,viewModel:{dataCaptureLayer:c,currentBestFeature:p,imageGeometryField:d,oiObjectIdField:l,activeViewer:h,mode:u},pendingGraphics:m}=this,g=h?.imageSize,v=h?.media;if(!(p&&d&&o&&l&&c&&g&&("default"===u||"panoramic"===u)))return;n(i,a,d,l,p,m,o,g,u,c,s(v)),this.viewModel.emit("after-data-capture-complete",{pendingGraphics:m.get(o)?.toArray()??null}),this.viewModel.sketch?.create(r)}handleDelete(e){const{dataCaptureLayer:t}=this.viewModel;if(!t)return;const{graphics:i}=e;this.pendingGraphics.get(t.id)?.removeMany(i),this.savedGraphics.removeMany(i),this.viewModel.deleteDataCaptureFeatures(l(i,t.objectIdField))}handleDestroy(){const{dataCaptureLayer:e}=this.viewModel;e&&(this.viewModel.stopDataCapture(),this.savedGraphics.removeAll(),this.pendingGraphics=null)}handleUpdate(e){const{toolEventInfo:t,state:i,graphics:r}=e;if(t)this.viewModel.sketch?.undo();else switch(i){case"complete":this.viewModel.emit("deselect-data-capture-features",{graphics:r});break;case"start":this.viewModel.emit("select-data-capture-features",{graphics:r})}}};function n(e,t,r,a,o,s,c,d,n,l,h){e.origin=l?.graphicOrigin??l,e.attributes=e.attributes??{},e.attributes[r]=btoa(JSON.stringify({geometry:p(t.clone(),n,d,h).toJSON()})),e.attributes[a]=o.attributes.objectId,s.has(c)||s.set(c,new i);s.get(c).add(e)}function l(e,t){return e.map(({attributes:e})=>t?e[t]:null).filter(Boolean)}e([a()],d.prototype,"collectionId",null),e([a()],d.prototype,"savedGraphics",void 0),e([a()],d.prototype,"type",void 0),e([a()],d.prototype,"pendingGraphics",void 0),d=e([o("esri.widgets.OrientedImageryViewer.adapters.sketch.DataCaptureAdapter")],d);const h=d;export{h as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import i from"../../../../core/Collection.js";import r from"../../../../core/ReactiveMap.js";import{property as a,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{extractHorizonAnglesFromMedia as s}from"../../utils.js";import{SketchHandlerMixin as c}from"../../mixins/SketchHandlerMixin.js";import{mapSpaceToImageSpace as p}from"../../support/dataCaptureUtils.js";let d=class extends(c(t)){constructor(e){super(e),this.savedGraphics=new i,this.type="data-capture",this.pendingGraphics=new r}get collectionId(){return this.viewModel.collectionId}handleCreate(e){const{state:t,graphic:i,tool:r}=e,a=i?.geometry;if("complete"!==t||!i||!a)return;const{collectionId:o,viewModel:{dataCaptureLayer:c,currentBestFeature:p,imageGeometryField:d,oiObjectIdField:l,activeViewer:h,mode:u},pendingGraphics:m}=this,g=h?.imageSize,v=h?.media;if(!(p&&d&&o&&l&&c&&g&&("default"===u||"panoramic"===u)))return;n(i,a,d,l,p,m,o,g,u,c,s(v)),this.viewModel.emit("after-data-capture-complete",{pendingGraphics:m.get(o)?.toArray()??null}),this.viewModel.sketch?.create(r).catch(()=>{})}handleDelete(e){const{dataCaptureLayer:t}=this.viewModel;if(!t)return;const{graphics:i}=e;this.pendingGraphics.get(t.id)?.removeMany(i),this.savedGraphics.removeMany(i),this.viewModel.deleteDataCaptureFeatures(l(i,t.objectIdField))}handleDestroy(){const{dataCaptureLayer:e}=this.viewModel;e&&(this.viewModel.stopDataCapture(),this.savedGraphics.removeAll(),this.pendingGraphics=null)}handleUpdate(e){const{toolEventInfo:t,state:i,graphics:r}=e;if(t)this.viewModel.sketch?.undo();else switch(i){case"complete":this.viewModel.emit("deselect-data-capture-features",{graphics:r});break;case"start":this.viewModel.emit("select-data-capture-features",{graphics:r})}}};function n(e,t,r,a,o,s,c,d,n,l,h){e.origin=l?.graphicOrigin??l,e.attributes=e.attributes??{},e.attributes[r]=btoa(JSON.stringify({geometry:p(t.clone(),n,d,h).toJSON()})),e.attributes[a]=o.attributes.objectId,s.has(c)||s.set(c,new i);s.get(c).add(e)}function l(e,t){return e.map(({attributes:e})=>t?e[t]:null).filter(Boolean)}e([a()],d.prototype,"collectionId",null),e([a()],d.prototype,"savedGraphics",void 0),e([a()],d.prototype,"type",void 0),e([a()],d.prototype,"pendingGraphics",void 0),d=e([o("esri.widgets.OrientedImageryViewer.adapters.sketch.DataCaptureAdapter")],d);const h=d;export{h as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- 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 r}from"../../../../core/promiseUtils.js";import{property as s,subclass as n}from"../../../../core/accessorSupport/decorators.js";import o from"../../../../geometry/Polygon.js";import l from"../../../../geometry/Polyline.js";import{load as c}from"../../../../geometry/projectionUtils.js";import u from"../../../../geometry/SpatialReference.js";import h from"../../../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as m,convertPixelToHeadingPitch as d,convertHeadingPitchToSphereVertex as w}from"../../../../layers/orientedImagery/transformations/utils.js";import{getMeasurementProperties as p,getMeasurementPropertiesPanoramic as g,pixelAreaMeasurement2D as y,pixelAreaMeasurementPanoramic as v,pixelDistanceMeasurement2D as M,pixelDistanceMeasurementPanoramic as f,getPixelLocationFromSphereVertices as T,formatPixels as A,imageToImageTransform as V,imageToImageTransformPanoramic as k}from"../../imageMeasurementUtils.js";import{extractHorizonAnglesFromMedia as S}from"../../utils.js";import{SketchHandlerMixin as _}from"../../mixins/SketchHandlerMixin.js";import x from"../../../Sketch/SketchViewModel.js";let F=[],z=[],G=0,B=class extends(_(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(c())}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()}async calculateAreaMeasurement(e,t,a){if(e.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize||"none"===this.viewModel.mode)return null;const i="default"===t?await p(this.viewModel.currentBestFeature,this.viewModel.activeViewer?.imageSize,this.viewModel.footprintExtent):await g(this.viewModel.currentBestFeature,this.viewModel.activeViewer?.imageSize,this.viewModel.footprintExtent);return r(a),i?"default"===t?await y(e,i,!0):await v(e,i,!0,a):null}async calculateDistanceMeasurement(e,t,a){const{currentBestFeature:i,activeViewer:s}=this.viewModel;if(e.length<2||!i||!s?.imageSize||"none"===t)return null;const n="default"===t?await p(i,s?.imageSize,this.viewModel.footprintExtent):await g(i,s?.imageSize,this.viewModel.footprintExtent);return r(a),n?"default"===t?await M([e.at(0),e.at(-1)],n,!0):await f([e.at(0),e.at(-1)],n,!0):null}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=m(t,a.imageSize[0],a.imageSize[1]);this.measurementArray.push([i.x,i.y])}const i=z.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(F=[...this.polygonVertices],"default"===t)F.push(i);else{const e={x:i[0],y:i[1],z:i[2]},t=m(e,a?.imageSize[0],a?.imageSize[1]);F.push([t.x,t.y])}if(F.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const r=F[0];F=F.filter((e,t)=>0===t||t===F.length-1||JSON.stringify(e)!==JSON.stringify(r));const s=await this._getAreaFromTask(F);s?.area&&s?.perimeter&&(G=s.area)}async handlePolylineEvents(e,t){const{currentBestFeature:a,activeViewer:i,mode:r,view:s}=this.viewModel,n=!this.viewModel.accuracyParametersMissing;if("cancel"===e.state)return this.resetDistanceMeasurements(),this.viewModel.distanceMeasurementResult=0,void(this.viewModel.distanceAccuracyArray=[]);if("complete"===e.state&&e.graphic){if(this.viewModel.activeViewer?.addGraphic(e.graphic),this.viewModel.triangularMeasurementActive&&a){const t={pixels:e.graphic.geometry.paths[0],activeFeature:a,activeViewer:i,mode:r,spatialReference:s?.spatialReference};await(this.measurementService?.updateMeasurementVectorsArray(t)),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&&n){const e=await this._getAccuracyFromTask();e&&this.viewModel.distanceAccuracyArray.push(e)}this.vertexUpdatePolylineHandler()}const o=await this._getDistanceFromTask();this.pixelMeasurement=o??this.pixelMeasurement}async handlePolygonEvents(e,t){const{currentBestFeature:a,activeViewer:i,mode:r,view:s,accuracyParametersMissing:n}=this.viewModel;if("cancel"===e.state)return this.resetAreaMeasurements(),this.viewModel.areaMeasurementResult=0,void(this.viewModel.areaMeasurementAccuracy=0);if("complete"===e.state&&e.graphic){this.viewModel.activeViewer?.addGraphic(e.graphic);if(!n&&!this.viewModel.triangularMeasurementActive){const e=await this._getAreaAccuracyFromTask(this.polygonVertices);this.viewModel.areaMeasurementAccuracy=e||this.viewModel.areaMeasurementAccuracy}if(this.viewModel.triangularMeasurementActive&&a){const t={pixels:e.graphic.geometry.rings[0],activeFeature:a,activeViewer:i,mode:r,spatialReference:s?.spatialReference};await(this.measurementService?.updateMeasurementVectorsArray(t)),await this._overlayFirstMeasurement(e.graphic,e.tool)}return this.viewModel.measurementGraphic=e.graphic,void this.resetAreaMeasurements()}switch(t?.type){case"vertex-add":await this.vertexAddPolygonHandler(t);break;case"cursor-update":await this.cursorUpdatePolygonHandler(t)}this.viewModel.areaMeasurementResult=G>0?G:this.pixelAreaMeasurement}async vertexAddPolygonHandler(e){const{mode:t,activeViewer:a}=this.viewModel,i=e.added,r=i[i.length-1];if(!Array.isArray(r)||"none"===t||!a?.imageSize)return;if("default"===t)this.polygonVertices.push(r);else{const e={x:r[0],y:r[1],z:r[2]},t=m(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 s=this.polygonVertices[0];this.polygonVertices=this.polygonVertices.filter((e,t)=>0===t||t===this.polygonVertices.length-1||JSON.stringify(e)!==JSON.stringify(s));const n=await this._getAreaFromTask(this.polygonVertices);if(!n?.area||!n?.perimeter)return;const{area:o}=n;this.pixelAreaMeasurement=o}vertexUpdatePolylineHandler(){this.measurementArray=this.measurementArray.slice(-1);const e=z.reduce((e,t)=>e+t,0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=e,this.pixelMeasurement>0&&z.push(this.pixelMeasurement)}resetDistanceMeasurements(){this.measurementArray=[],this.pixelMeasurement=0,z=[]}resetAreaMeasurements(){this.polygonVertices=[],this.pixelAreaMeasurement=0,G=0}async _editOverlayedGraphics(e){this.viewModel.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.viewModel.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.viewModel.sketchTriangularGraphicsLayer.add(e),this.viewModel.sketchTriangular||(this._initializeSketchTriangular(),await this._loadTriangulatedMeasurementAdapter()),this._updateOverlayedGeometry(e)}_handleDestroyedTriangularSketchLayer(){this.viewModel.sketchTriangularGraphicsLayer&&this.viewModel.activeTriangulatedViewer&&(this.viewModel.activeTriangulatedViewer.imageRenderer.map.layers.remove(this.viewModel.sketchTriangularGraphicsLayer),this.viewModel.sketchTriangularGraphicsLayer=new h,this.viewModel.activeTriangulatedViewer.imageRenderer.map.layers.add(this.viewModel.sketchTriangularGraphicsLayer),this.viewModel.sketchTriangular&&(this.viewModel.sketchTriangular.layer=this.viewModel.sketchTriangularGraphicsLayer,this.viewModel.sketchTriangular.view=this.viewModel.activeTriangulatedViewer.imageRenderer))}_initializeSketchTriangular(){if(!this.viewModel.activeTriangulatedViewer)return;const e="panoramic"===this.viewModel.mode;this.viewModel.sketchTriangular=new x({view:this.viewModel.activeTriangulatedViewer.imageRenderer,layer:this.viewModel.sketchTriangularGraphicsLayer,updateOnGraphicClick:!0,defaultUpdateOptions:{toggleToolOnClick:!1,enableZ:!e}}),e&&(this.viewModel.sketchTriangular.defaultUpdateOptions.reshapeOptions={edgeOperation:"offset",shapeOperation:"move-xy",vertexOperation:"move-xy"})}_initializeSketchTriangularGraphicsLayer(){this.viewModel.activeTriangulatedViewer&&(this.viewModel.sketchTriangularGraphicsLayer=new h,this.viewModel.activeTriangulatedViewer.imageRenderer.map.layers.add(this.viewModel.sketchTriangularGraphicsLayer))}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,currentBestFeature:r,activeViewer:s,footprintExtent:n,currentBestFeatureMeasurementImage:o}=this.viewModel,c=e.geometry?.clone(),h=e.symbol?.clone(),m=i?.imageSize,d=[...c.paths[0]],w=S(i?.media),y="default"===a;if(!("none"!==a&&"video"!==a&&m&&r&&s?.imageSize&&o))return;const v=y?d:T(d,m,w),M=y?A(v,!0):v,f=y?await p(r,s?.imageSize,n):await g(r,s?.imageSize,n),_=y?await p(o,this.viewModel.imageMeasurementViewer?.imageSize,n):await g(o,this.viewModel.activeTriangulatedViewer?.imageSize,n);if(M?.length&&f&&_){const e=y?await V(M,f,_):await k(M,f,_),a=e.map(e=>[e.x-.5,-.5-e.y]),i=e.slice(0,2).map(e=>R(e,m,w)),r=new l({paths:y?[a]:[i],spatialReference:u.WebMercator}),s=new t({geometry:r,symbol:h});await this._editOverlayedGraphics(s)}}async _overlayFirstAreaGeometry(e){const{mode:a,activeTriangulatedViewer:i,currentBestFeature:r,currentBestFeatureMeasurementImage:s,activeViewer:n,footprintExtent:l}=this.viewModel,c=e.geometry?.clone(),h=e.symbol?.clone(),m=i?.imageSize,d=S(i?.media),w=[...c.rings[0]],y="default"===a;if(!("none"!==a&&"video"!==a&&m&&r&&n?.imageSize&&s))return;const v=y?w:T(w,m,d),M=y?A(v,!0):v,f=y?await p(r,n?.imageSize,l):await g(r,n?.imageSize,l),_=y?await p(s,this.viewModel.imageMeasurementViewer?.imageSize,l):await g(s,this.viewModel.activeTriangulatedViewer?.imageSize,l);if(M?.length&&f&&_){const e=y?await V(M,f,_):await k(M,f,_),a=e.map(e=>[e.x-.5,-.5-e.y]),i=e.slice(0,y?2:e.length).map(e=>R(e,m,d)),r=new o({rings:y?[a]:[i],spatialReference:u.WebMercator}),s=new t({geometry:r,symbol:h});await this._editOverlayedGraphics(s)}}async _loadTriangulatedMeasurementAdapter(e){if(!this.viewModel.triangulatedMeasurementAdapter){const t=import("./TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(r(e),this.viewModel.triangulatedMeasurementAdapter=new a({viewModel:this.viewModel,measurementService:this.measurementService}),!this.viewModel.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.viewModel.triangulatedMeasurementAdapter}async _getAreaFromTask(e){const{mode:t}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=a(async a=>{this._areaCalculation=null;const i=await this.calculateAreaMeasurement(e,t,a);r(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.calculateDistanceMeasurement(this.measurementArray,e,t);r(t),this._distanceCalculation=a}),await this._calculationTask.promise,this._distanceCalculation}async _getAccuracyFromTask(){const{mode:e,currentBestFeature:t,currentBestFeatureMeasurementImage:i,activeViewer:s,activeTriangulatedViewer:n,layer:o,footprintExtent:l}=this.viewModel,c=s?.imageSize;return"none"!==e&&c?(this._calculationTask?.abort(),this._calculationTask=a(async a=>{this._distanceCalculation=0;const u={measurementArray:this.measurementArray,measurementType:"distance",currentBestFeature:t,currentBestFeatureMeasurementImage:i,activeViewer:s,imageSize:c,layer:o,triangularMeasurementActive:!1,footprintExtent:l,signal:a},h={measurementArray:this.measurementArray,measurementType:"distance",secondaryViewer:!1,currentBestFeature:t,currentBestFeatureMeasurementImage:i,activeViewer:s,activeTriangulatedViewer:n,layer:o,footprintExtent:l,signal:a},m="default"===e?await(this.measurementService?.calculateAccuracy(u)):await(this.measurementService?.calculateAccuracyPanoramic(h));r(a),this._distanceCalculation=m}),await this._calculationTask.promise,this._distanceCalculation):null}async _getAreaAccuracyFromTask(e){const{mode:t,currentBestFeature:i,currentBestFeatureMeasurementImage:s,activeViewer:n,activeTriangulatedViewer:o,layer:l,footprintExtent:c}=this.viewModel,u=n?.imageSize;return"none"!==t&&u?(this._calculationTask?.abort(),this._calculationTask=a(async a=>{this._distanceCalculation=0;const h={measurementArray:e,measurementType:"area",currentBestFeature:i,currentBestFeatureMeasurementImage:s,activeViewer:n,imageSize:u,layer:l,triangularMeasurementActive:!1,footprintExtent:c,signal:a},m={measurementArray:e,measurementType:"area",secondaryViewer:!1,currentBestFeature:i,currentBestFeatureMeasurementImage:s,activeViewer:n,activeTriangulatedViewer:o,layer:l,footprintExtent:c,signal:a},d="default"===t?await(this.measurementService?.calculateAccuracy(h)):await(this.measurementService?.calculateAccuracyPanoramic(m));r(a),this._distanceCalculation=d}),await this._calculationTask.promise,this._distanceCalculation):null}_updateOverlayedGeometry(e){this.viewModel.sketchTriangular?.update([e],{tool:"reshape"})}};e([s()],B.prototype,"type",void 0),e([s()],B.prototype,"measurementArray",void 0),e([s()],B.prototype,"pixelMeasurement",void 0),e([s()],B.prototype,"pixelAreaMeasurement",void 0),e([s()],B.prototype,"polygonVertices",void 0),B=e([n("esri.widgets.OrientedImageryViewer.adapters.sketch.MeasurementAdapter")],B);const P=B,R=(e,t,a)=>{const{heading:i,pitch:r}=d(e,t[0],t[1]);return w(i,r,a)};export{P as default};
2
+ 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 r}from"../../../../core/promiseUtils.js";import{property as s,subclass as n}from"../../../../core/accessorSupport/decorators.js";import o from"../../../../geometry/Polygon.js";import c from"../../../../geometry/Polyline.js";import{load as l}from"../../../../geometry/projectionUtils.js";import u from"../../../../geometry/SpatialReference.js";import h from"../../../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as m,convertPixelToHeadingPitch as d,convertHeadingPitchToSphereVertex as w}from"../../../../layers/orientedImagery/transformations/utils.js";import{getMeasurementProperties as p,getMeasurementPropertiesPanoramic as g,pixelAreaMeasurement2D as y,pixelAreaMeasurementPanoramic as v,pixelDistanceMeasurement2D as M,pixelDistanceMeasurementPanoramic as f,getPixelLocationFromSphereVertices as T,formatPixels as A,imageToImageTransform as V,imageToImageTransformPanoramic as k}from"../../imageMeasurementUtils.js";import{extractHorizonAnglesFromMedia as S}from"../../utils.js";import{SketchHandlerMixin as _}from"../../mixins/SketchHandlerMixin.js";import x from"../../../Sketch/SketchViewModel.js";let F=[],z=[],G=0,B=class extends(_(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()}async calculateAreaMeasurement(e,t,a){if(e.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize||"none"===this.viewModel.mode)return null;const i="default"===t?await p(this.viewModel.currentBestFeature,this.viewModel.activeViewer?.imageSize,this.viewModel.footprintExtent):await g(this.viewModel.currentBestFeature,this.viewModel.activeViewer?.imageSize,this.viewModel.footprintExtent);return r(a),i?"default"===t?await y(e,i,!0):await v(e,i,!0,a):null}async calculateDistanceMeasurement(e,t,a){const{currentBestFeature:i,activeViewer:s}=this.viewModel;if(e.length<2||!i||!s?.imageSize||"none"===t)return null;const n="default"===t?await p(i,s?.imageSize,this.viewModel.footprintExtent):await g(i,s?.imageSize,this.viewModel.footprintExtent);return r(a),n?"default"===t?await M([e.at(0),e.at(-1)],n,!0):await f([e.at(0),e.at(-1)],n,!0):null}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=m(t,a.imageSize[0],a.imageSize[1]);this.measurementArray.push([i.x,i.y])}const i=z.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(F=[...this.polygonVertices],"default"===t)F.push(i);else{const e={x:i[0],y:i[1],z:i[2]},t=m(e,a?.imageSize[0],a?.imageSize[1]);F.push([t.x,t.y])}if(F.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const r=F[0];F=F.filter((e,t)=>0===t||t===F.length-1||JSON.stringify(e)!==JSON.stringify(r));const s=await this._getAreaFromTask(F);s?.area&&s?.perimeter&&(G=s.area)}async handlePolylineEvents(e,t){const{currentBestFeature:a,activeViewer:i,mode:r,view:s}=this.viewModel,n=!this.viewModel.accuracyParametersMissing;if("cancel"===e.state)return this.resetDistanceMeasurements(),this.viewModel.distanceMeasurementResult=0,void(this.viewModel.distanceAccuracyArray=[]);if("complete"===e.state&&e.graphic){if(this.viewModel.activeViewer?.addGraphic(e.graphic),this.viewModel.triangularMeasurementActive&&a){const t={pixels:e.graphic.geometry.paths[0],activeFeature:a,activeViewer:i,mode:r,spatialReference:s?.spatialReference};await(this.measurementService?.updateMeasurementVectorsArray(t)),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&&n){const e=await this._getAccuracyFromTask();e&&this.viewModel.distanceAccuracyArray.push(e)}this.vertexUpdatePolylineHandler()}const o=await this._getDistanceFromTask();this.pixelMeasurement=o??this.pixelMeasurement}async handlePolygonEvents(e,t){const{currentBestFeature:a,activeViewer:i,mode:r,view:s,accuracyParametersMissing:n}=this.viewModel;if("cancel"===e.state)return this.resetAreaMeasurements(),this.viewModel.areaMeasurementResult=0,void(this.viewModel.areaMeasurementAccuracy=0);if("complete"===e.state&&e.graphic){this.viewModel.activeViewer?.addGraphic(e.graphic);if(!n&&!this.viewModel.triangularMeasurementActive){const e=await this._getAreaAccuracyFromTask(this.polygonVertices);this.viewModel.areaMeasurementAccuracy=e||this.viewModel.areaMeasurementAccuracy}if(this.viewModel.triangularMeasurementActive&&a){const t={pixels:e.graphic.geometry.rings[0],activeFeature:a,activeViewer:i,mode:r,spatialReference:s?.spatialReference};await(this.measurementService?.updateMeasurementVectorsArray(t)),await this._overlayFirstMeasurement(e.graphic,e.tool)}return this.viewModel.measurementGraphic=e.graphic,void this.resetAreaMeasurements()}switch(t?.type){case"vertex-add":await this.vertexAddPolygonHandler(t);break;case"cursor-update":await this.cursorUpdatePolygonHandler(t)}this.viewModel.areaMeasurementResult=G>0?G:this.pixelAreaMeasurement}async vertexAddPolygonHandler(e){const{mode:t,activeViewer:a}=this.viewModel,i=e.added,r=i[i.length-1];if(!Array.isArray(r)||"none"===t||!a?.imageSize)return;if("default"===t)this.polygonVertices.push(r);else{const e={x:r[0],y:r[1],z:r[2]},t=m(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 s=this.polygonVertices[0];this.polygonVertices=this.polygonVertices.filter((e,t)=>0===t||t===this.polygonVertices.length-1||JSON.stringify(e)!==JSON.stringify(s));const n=await this._getAreaFromTask(this.polygonVertices);if(!n?.area||!n?.perimeter)return;const{area:o}=n;this.pixelAreaMeasurement=o}vertexUpdatePolylineHandler(){this.measurementArray=this.measurementArray.slice(-1);const e=z.reduce((e,t)=>e+t,0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=e,this.pixelMeasurement>0&&z.push(this.pixelMeasurement)}resetDistanceMeasurements(){this.measurementArray=[],this.pixelMeasurement=0,z=[]}resetAreaMeasurements(){this.polygonVertices=[],this.pixelAreaMeasurement=0,G=0}async _editOverlayedGraphics(e){this.viewModel.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.viewModel.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.viewModel.sketchTriangularGraphicsLayer.add(e),this.viewModel.sketchTriangular||(this._initializeSketchTriangular(),await this._loadTriangulatedMeasurementAdapter()),this._updateOverlayedGeometry(e)}_handleDestroyedTriangularSketchLayer(){this.viewModel.sketchTriangularGraphicsLayer&&this.viewModel.activeTriangulatedViewer&&(this.viewModel.activeTriangulatedViewer.imageRenderer.map.layers.remove(this.viewModel.sketchTriangularGraphicsLayer),this.viewModel.sketchTriangularGraphicsLayer=new h,this.viewModel.activeTriangulatedViewer.imageRenderer.map.layers.add(this.viewModel.sketchTriangularGraphicsLayer),this.viewModel.sketchTriangular&&(this.viewModel.sketchTriangular.layer=this.viewModel.sketchTriangularGraphicsLayer,this.viewModel.sketchTriangular.view=this.viewModel.activeTriangulatedViewer.imageRenderer))}_initializeSketchTriangular(){if(!this.viewModel.activeTriangulatedViewer)return;const e="panoramic"===this.viewModel.mode;this.viewModel.sketchTriangular=new x({view:this.viewModel.activeTriangulatedViewer.imageRenderer,layer:this.viewModel.sketchTriangularGraphicsLayer,updateOnGraphicClick:!0,defaultUpdateOptions:{toggleToolOnClick:!1,enableZ:!e}}),e&&(this.viewModel.sketchTriangular.defaultUpdateOptions.reshapeOptions={edgeOperation:"offset",shapeOperation:"move-xy",vertexOperation:"move-xy"})}_initializeSketchTriangularGraphicsLayer(){this.viewModel.activeTriangulatedViewer&&(this.viewModel.sketchTriangularGraphicsLayer=new h,this.viewModel.activeTriangulatedViewer.imageRenderer.map.layers.add(this.viewModel.sketchTriangularGraphicsLayer))}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,currentBestFeature:r,activeViewer:s,footprintExtent:n,currentBestFeatureMeasurementImage:o}=this.viewModel,l=e.geometry?.clone(),h=e.symbol?.clone(),m=i?.imageSize,d=[...l.paths[0]],w=S(i?.media),y="default"===a;if(!("none"!==a&&"video"!==a&&m&&r&&s?.imageSize&&o))return;const v=y?d:T(d,m,w),M=y?A(v,!0):v,f=y?await p(r,s?.imageSize,n):await g(r,s?.imageSize,n),_=y?await p(o,this.viewModel.imageMeasurementViewer?.imageSize,n):await g(o,this.viewModel.activeTriangulatedViewer?.imageSize,n);if(M?.length&&f&&_){const e=y?await V(M,f,_):await k(M,f,_),a=e.map(e=>[e.x-.5,-.5-e.y]),i=e.slice(0,2).map(e=>R(e,m,w)),r=new c({paths:y?[a]:[i],spatialReference:u.WebMercator}),s=new t({geometry:r,symbol:h});await this._editOverlayedGraphics(s)}}async _overlayFirstAreaGeometry(e){const{mode:a,activeTriangulatedViewer:i,currentBestFeature:r,currentBestFeatureMeasurementImage:s,activeViewer:n,footprintExtent:c}=this.viewModel,l=e.geometry?.clone(),h=e.symbol?.clone(),m=i?.imageSize,d=S(i?.media),w=[...l.rings[0]],y="default"===a;if(!("none"!==a&&"video"!==a&&m&&r&&n?.imageSize&&s))return;const v=y?w:T(w,m,d),M=y?A(v,!0):v,f=y?await p(r,n?.imageSize,c):await g(r,n?.imageSize,c),_=y?await p(s,this.viewModel.imageMeasurementViewer?.imageSize,c):await g(s,this.viewModel.activeTriangulatedViewer?.imageSize,c);if(M?.length&&f&&_){const e=y?await V(M,f,_):await k(M,f,_),a=e.map(e=>[e.x-.5,-.5-e.y]),i=e.slice(0,y?2:e.length).map(e=>R(e,m,d)),r=new o({rings:y?[a]:[i],spatialReference:u.WebMercator}),s=new t({geometry:r,symbol:h});await this._editOverlayedGraphics(s)}}async _loadTriangulatedMeasurementAdapter(e){if(!this.viewModel.triangulatedMeasurementAdapter){const t=import("./TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(r(e),this.viewModel.triangulatedMeasurementAdapter=new a({viewModel:this.viewModel,measurementService:this.measurementService}),!this.viewModel.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.viewModel.triangulatedMeasurementAdapter}async _getAreaFromTask(e){const{mode:t}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=a(async a=>{this._areaCalculation=null;const i=await this.calculateAreaMeasurement(e,t,a);r(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.calculateDistanceMeasurement(this.measurementArray,e,t);r(t),this._distanceCalculation=a}),await this._calculationTask.promise,this._distanceCalculation}async _getAccuracyFromTask(){const{mode:e,currentBestFeature:t,currentBestFeatureMeasurementImage:i,activeViewer:s,activeTriangulatedViewer:n,layer:o,footprintExtent:c}=this.viewModel,l=s?.imageSize;return"none"!==e&&l?(this._calculationTask?.abort(),this._calculationTask=a(async a=>{this._distanceCalculation=0;const u={measurementArray:this.measurementArray,measurementType:"distance",currentBestFeature:t,currentBestFeatureMeasurementImage:i,activeViewer:s,imageSize:l,layer:o,triangularMeasurementActive:!1,footprintExtent:c,signal:a},h={measurementArray:this.measurementArray,measurementType:"distance",secondaryViewer:!1,currentBestFeature:t,currentBestFeatureMeasurementImage:i,activeViewer:s,activeTriangulatedViewer:n,layer:o,footprintExtent:c,signal:a},m="default"===e?await(this.measurementService?.calculateAccuracy(u)):await(this.measurementService?.calculateAccuracyPanoramic(h));r(a),this._distanceCalculation=m}),await this._calculationTask.promise,this._distanceCalculation):null}async _getAreaAccuracyFromTask(e){const{mode:t,currentBestFeature:i,currentBestFeatureMeasurementImage:s,activeViewer:n,activeTriangulatedViewer:o,layer:c,footprintExtent:l}=this.viewModel,u=n?.imageSize;return"none"!==t&&u?(this._calculationTask?.abort(),this._calculationTask=a(async a=>{this._distanceCalculation=0;const h={measurementArray:e,measurementType:"area",currentBestFeature:i,currentBestFeatureMeasurementImage:s,activeViewer:n,imageSize:u,layer:c,triangularMeasurementActive:!1,footprintExtent:l,signal:a},m={measurementArray:e,measurementType:"area",secondaryViewer:!1,currentBestFeature:i,currentBestFeatureMeasurementImage:s,activeViewer:n,activeTriangulatedViewer:o,layer:c,footprintExtent:l,signal:a},d="default"===t?await(this.measurementService?.calculateAccuracy(h)):await(this.measurementService?.calculateAccuracyPanoramic(m));r(a),this._distanceCalculation=d}),await this._calculationTask.promise,this._distanceCalculation):null}_updateOverlayedGeometry(e){this.viewModel.sketchTriangular?.update([e],{tool:"reshape"}).catch(()=>{})}};e([s()],B.prototype,"type",void 0),e([s()],B.prototype,"measurementArray",void 0),e([s()],B.prototype,"pixelMeasurement",void 0),e([s()],B.prototype,"pixelAreaMeasurement",void 0),e([s()],B.prototype,"polygonVertices",void 0),B=e([n("esri.widgets.OrientedImageryViewer.adapters.sketch.MeasurementAdapter")],B);const P=B,R=(e,t,a)=>{const{heading:i,pitch:r}=d(e,t[0],t[1]);return w(i,r,a)};export{P as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../Graphic.js";import{isSome as t}from"../../../../core/arrayUtils.js";import i from"../../../../core/Logger.js";import{waitTick as o,throwIfAborted as r,isAbortError as a}from"../../../../core/promiseUtils.js";import s from"../../../../geometry/Polygon.js";import{projectAsync as n}from"../../../../geometry/projectionUtils.js";import{e as l}from"../../../../chunks/centroidOperator.js";import{adjustHorizonAngles as p,convertOrientationToPixelLocation as c}from"../../../../layers/orientedImagery/transformations/utils.js";import{fixedImageSize as u}from"../../constants.js";import{activePolygonSymbol as d,polygonSymbol as m}from"../../symbols.js";import{extractHorizonAnglesFromMedia as g}from"../../utils.js";class v{constructor(v){this.viewModel=v,this.createFootprints=async t=>{await o(t);const{coveragePolygons:i,currentBestFeature:r,isAdditionalCoverageVisible:a}=this.viewModel;for(const o of i)o?.imageID===r.attributes.objectId?this.viewModel.bestFeatureFootprint=new e({attributes:{imageID:o?.imageID},geometry:o,symbol:d,visible:!1}):this.viewModel.additionalFootprints.push(new e({attributes:{imageID:o?.imageID},geometry:o,symbol:m.clone(),visible:a}))},this.updateFootprint=async(o,l,p)=>{const{activeViewer:c,mode:m,currentBestFeature:g,currentCoverageVisible:v,footprintExtent:f}=this.viewModel,w=l??g;if(g&&("video"===m?u:c?.imageSize)&&f&&w)try{const i=await this.viewModel.getMapPoint(o);r(p);const a=i.filter(t);if(!a.length)return;const l=[a.map(({x:e,y:t})=>[e,t,1])];l[0].push(l[0][0]);const c=new s({rings:l,spatialReference:a[0].spatialReference}),u=this.viewModel.view?.spatialReference.equals(c.spatialReference)?c:await n(c,this.viewModel.view.spatialReference,p);this.viewModel.updateCurrentCoveragePolygon(new e({geometry:u,attributes:{imageID:w.attributes.objectId},symbol:d,visible:v}))}catch(h){a(h)||i.getLogger(this.viewModel).error("update-footprint",h)}else this.viewModel.updateCurrentCoveragePolygon(null)},this.updateVideoFootprint=async o=>{const{points:p,feature:c,scale:m,options:g}=o,{activeViewer:v,mode:f,currentBestFeature:w,currentCoverageVisible:h,footprintExtent:y}=this.viewModel,M="video"===f?u:v?.imageSize,b=c??w;if(w&&M&&y&&b&&"none"!==f)try{const i={feature:b,mode:f,imageSize:M,footprintExtent:y},o=await this.viewModel.getMapPointForFeature(p,i,g);r(g);const a=o.filter(t);if(!a.length)return;const c=[a.map(({x:e,y:t})=>[e,t,1])];c[0].push(c[0][0]);let u=new s({rings:c,spatialReference:a[0].spatialReference});if(m){const e=u.spatialReference,t=l(u),i=u.rings.map(e=>e.map(([e,i])=>[t.x+(e-t.x)*m,t.y+(i-t.y)*m]));u=new s({rings:i,spatialReference:e})}const v=this.viewModel.view?.spatialReference.equals(u.spatialReference)?u:await n(u,this.viewModel.view.spatialReference,g);this.viewModel.updateCurrentCoveragePolygon(new e({geometry:v,attributes:{imageID:b.attributes.objectId},symbol:d,visible:h}))}catch(C){a(C)||i.getLogger(this.viewModel).error("update-footprint",C)}else this.viewModel.updateCurrentCoveragePolygon(null)},this.updateFootprintPanorama=async(t,i)=>{const{horizontalFieldOfView:o,pitch:a,verticalFieldOfView:l,yaw:m,feature:v,horizonAngles:f}=t,{activeViewer:w,currentBestFeature:h,currentCoverageVisible:y,footprintExtent:M,mode:b}=this.viewModel,C="video"===b||"panoramic-video"===b?u:w?.imageSize,F=v??h;if(!F||!C||!M||"none"===b)return void this.viewModel.updateCurrentCoveragePolygon(null);const{cameraPitch:R,objectId:j}=F.attributes;if(a+R-l/2>180)return void this.viewModel.updateCurrentCoveragePolygon(null);const P=[],I=l/2,x=o/2,V=a-I,D=a+I;if(V>90)return void this.viewModel.updateCurrentCoveragePolygon(null);const z=V<0,E=[-x,I],S=[x,I],B=[x,-I],q=[-x,-I];if(V<90&&D>90){P.push(z?B:q);const e=Math.floor(o/5),t=o/e;for(let i=0;i<=e;i++)P.push([i*t-x,90-a]);P.push(z?q:B)}D<90&&(P.push(E,S),z?P.push(q,B):P.push(B,q));const L=f??g(w?.media),O=P.map(([e,t])=>{const i=a+t,o=m+e,r=L?p(o,i,L):[o,i];return{...c(r[0],r[1],C[0],C[1]),heading:o,pitch:i}}),U={feature:F,mode:b,imageSize:C,footprintExtent:M},A=v?await this.viewModel.getMapPointForFeature(O,U):await this.viewModel.getMapPoint(O);r(i);const k=[A.map(({x:e,y:t})=>[e,t,1])];k[0].push(k[0][0]);const G=new s({rings:k,spatialReference:A[0].spatialReference}),H=this.viewModel.view?.spatialReference.equals(G.spatialReference)?G:await n(G,this.viewModel.view.spatialReference,i);this.viewModel.updateCurrentCoveragePolygon(new e({geometry:H,attributes:{imageID:j},symbol:d.clone(),visible:y}))}}}export{v as default};
2
+ import e from"../../../../Graphic.js";import{isSome as t}from"../../../../core/arrayUtils.js";import i from"../../../../core/Logger.js";import{waitTick as o,throwIfAborted as r,isAbortError as a}from"../../../../core/promiseUtils.js";import s from"../../../../geometry/Polygon.js";import{projectAsync as n}from"../../../../geometry/projectionUtils.js";import{e as l}from"../../../../chunks/centroidOperator.js";import{adjustHorizonAngles as c,convertOrientationToPixelLocation as p}from"../../../../layers/orientedImagery/transformations/utils.js";import{fixedImageSize as u}from"../../constants.js";import{activePolygonSymbol as d,polygonSymbol as m}from"../../symbols.js";import{extractHorizonAnglesFromMedia as g}from"../../utils.js";class v{constructor(v){this.viewModel=v,this.createFootprints=async t=>{await o(t);const{coveragePolygons:i,currentBestFeature:r,isAdditionalCoverageVisible:a}=this.viewModel;for(const o of i)o?.imageID===r.attributes.objectId?this.viewModel.bestFeatureFootprint=new e({attributes:{imageID:o?.imageID},geometry:o,symbol:d,visible:!1}):this.viewModel.additionalFootprints.push(new e({attributes:{imageID:o?.imageID},geometry:o,symbol:m.clone(),visible:a}))},this.updateFootprint=async(o,l,c)=>{const{activeViewer:p,mode:m,currentBestFeature:g,currentCoverageVisible:v,footprintExtent:f}=this.viewModel,w=l??g;if(g&&("video"===m?u:p?.imageSize)&&f&&w)try{const i=await this.viewModel.getMapPoint(o);r(c);const a=i.filter(t);if(!a.length)return;const l=[a.map(({x:e,y:t})=>[e,t,1])];l[0].push(l[0][0]);const p=new s({rings:l,spatialReference:a[0].spatialReference}),u=this.viewModel.view?.spatialReference.equals(p.spatialReference)?p:await n(p,this.viewModel.view.spatialReference,c);this.viewModel.updateCurrentCoveragePolygon(new e({geometry:u,attributes:{imageID:w.attributes.objectId},symbol:d,visible:v}))}catch(h){a(h)||i.getLogger(this.viewModel).error("update-footprint",h)}else this.viewModel.updateCurrentCoveragePolygon(null)},this.updateVideoFootprint=async o=>{const{points:c,feature:p,scale:m,options:g}=o,{activeViewer:v,mode:f,currentBestFeature:w,currentCoverageVisible:h,footprintExtent:y}=this.viewModel,M="video"===f?u:v?.imageSize,b=p??w;if(w&&M&&y&&b&&"none"!==f)try{const i={feature:b,mode:f,imageSize:M,footprintExtent:y},o=await this.viewModel.getMapPointForFeature(c,i,g);r(g);const a=o.filter(t);if(!a.length)return;const p=[a.map(({x:e,y:t})=>[e,t,1])];p[0].push(p[0][0]);let u=new s({rings:p,spatialReference:a[0].spatialReference});if(m){const e=u.spatialReference,t=l(u),i=u.rings.map(e=>e.map(([e,i])=>[t.x+(e-t.x)*m,t.y+(i-t.y)*m]));u=new s({rings:i,spatialReference:e})}const v=this.viewModel.view?.spatialReference.equals(u.spatialReference)?u:await n(u,this.viewModel.view.spatialReference,g);this.viewModel.updateCurrentCoveragePolygon(new e({geometry:v,attributes:{imageID:b.attributes.objectId},symbol:d,visible:h}))}catch(C){a(C)||i.getLogger(this.viewModel).error("update-footprint",C)}else this.viewModel.updateCurrentCoveragePolygon(null)},this.updateFootprintPanorama=async(t,i)=>{const{horizontalFieldOfView:o,pitch:a,verticalFieldOfView:l,yaw:m,feature:v,horizonAngles:f}=t,{activeViewer:w,currentBestFeature:h,currentCoverageVisible:y,footprintExtent:M,mode:b}=this.viewModel,C="video"===b||"panoramic-video"===b?u:w?.imageSize,F=v??h;if(!F||!C||!M||"none"===b)return void this.viewModel.updateCurrentCoveragePolygon(null);const{cameraPitch:j,objectId:P}=F.attributes;if(a+j-l/2>180)return void this.viewModel.updateCurrentCoveragePolygon(null);const R=[],I=l/2,x=o/2,V=a-I,D=a+I;if(V>90)return void this.viewModel.updateCurrentCoveragePolygon(null);const z=V<0,E=[-x,I],S=[x,I],B=[x,-I],q=[-x,-I];if(V<90&&D>90){R.push(z?B:q);const e=Math.floor(o/5),t=o/e;for(let i=0;i<=e;i++)R.push([i*t-x,90-a]);R.push(z?q:B)}D<90&&(R.push(E,S),z?R.push(q,B):R.push(B,q));const L=f??g(w?.media),O=R.map(([e,t])=>{const i=a+t,o=m+e,r=L?c(o,i,L):[o,i];return{...p(r[0],r[1],C[0],C[1]),heading:o,pitch:i}}),U={feature:F,mode:b,imageSize:C,footprintExtent:M},A=v?await this.viewModel.getMapPointForFeature(O,U,i):await this.viewModel.getMapPoint(O,i);r(i);const k=[A.map(({x:e,y:t})=>[e,t,1])];k[0].push(k[0][0]);const G=new s({rings:k,spatialReference:A[0].spatialReference}),H=this.viewModel.view?.spatialReference;if(!H)return;const J=H.equals(G.spatialReference)?G:await n(G,H,i);this.viewModel.updateCurrentCoveragePolygon(new e({geometry:J,attributes:{imageID:P},symbol:d.clone(),visible:y}))}}}export{v as default};