@arcgis/core 5.1.0-next.81 → 5.1.0-next.82

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 (171) hide show
  1. package/analysis/ShadowCast/DiscreteOptions.d.ts +12 -0
  2. package/analysis/ShadowCast/TotalDurationOptions.d.ts +12 -0
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/040884cec4b84dd1bb17.js +1 -0
  5. package/assets/esri/core/workers/chunks/05c5f68e117fc58ae801.js +1 -0
  6. package/assets/esri/core/workers/chunks/074f5e6aaeafca13bf72.js +1 -0
  7. package/assets/esri/core/workers/chunks/{7bd1d624f4f4a11a31e8.js → 086d7cdfa92a649c9f7b.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{0eed2b1b06355ab89013.js → 0c074c46d106ca4d3bad.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{c758e16b57c96ce88294.js → 1768f1a7e3caa6074d91.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{85d3475667c503ec4fc6.js → 186bfde8c552e3b42302.js} +1 -1
  11. package/assets/esri/core/workers/chunks/1a35121a0c2595a41fdb.js +1 -0
  12. package/assets/esri/core/workers/chunks/1ab66600579fa4232d7b.js +1 -0
  13. package/assets/esri/core/workers/chunks/1e3fe89970c57a883fe5.js +1 -0
  14. package/assets/esri/core/workers/chunks/{824051af00e7a1f05ed0.js → 230e0e43f8e771950397.js} +1 -1
  15. package/assets/esri/core/workers/chunks/26f804c92077c11c626d.js +1 -0
  16. package/assets/esri/core/workers/chunks/28a45bd26eb5c9b3ec7c.js +1 -0
  17. package/assets/esri/core/workers/chunks/38f1a86b8dd9ee684ee5.js +596 -0
  18. package/assets/esri/core/workers/chunks/{71fe127734f33d020a44.js → 475394218caaa4cd3e86.js} +1 -1
  19. package/assets/esri/core/workers/chunks/475409026288f0981ce2.js +1 -0
  20. package/assets/esri/core/workers/chunks/4e206957b28253ddc1a3.js +1 -0
  21. package/assets/esri/core/workers/chunks/5cc38ac051d3d0557920.js +1 -0
  22. package/assets/esri/core/workers/chunks/{992cd87ba0ab6346f692.js → 64e268ebac0b62076f81.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{003fd7745966fe03510c.js → 65ac73de5bb133c6bf89.js} +1 -1
  24. package/assets/esri/core/workers/chunks/6675d56f49d07a97dc40.js +1 -0
  25. package/assets/esri/core/workers/chunks/{484d6c1b0fe1633515b7.js → 72f8f4cfa0842d325fb0.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{283d39dfb1625b5a74db.js → 747e258f57f0543c836e.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{dd4f431511edd975a53b.js → 7acf82763aeba44049d0.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{5d8e944b192aad4cf986.js → 7b505112c7e6d9b7a239.js} +1 -1
  29. package/assets/esri/core/workers/chunks/7b8466f892a38a53c600.js +1 -0
  30. package/assets/esri/core/workers/chunks/{77dd719516138afb1a2a.js → 8af9a78cf316581ea482.js} +1 -1
  31. package/assets/esri/core/workers/chunks/988e91cc6cf88c34c2de.js +1 -0
  32. package/assets/esri/core/workers/chunks/9c402657f63a4d5668d0.js +1 -0
  33. package/assets/esri/core/workers/chunks/9ea23cd4b2664c08b670.js +1 -0
  34. package/assets/esri/core/workers/chunks/9f51a69b8f1937a8794a.js +1 -0
  35. package/assets/esri/core/workers/chunks/a28124bba6b43efd74cc.js +1 -0
  36. package/assets/esri/core/workers/chunks/af762422a65c551dcd54.js +1 -0
  37. package/assets/esri/core/workers/chunks/{056fd7847caaff2c9514.js → af8bc56cf1404afc3028.js} +1 -1
  38. package/assets/esri/core/workers/chunks/b9e163f4a898e50cc854.js +1 -0
  39. package/assets/esri/core/workers/chunks/{444f0f51b3ee0b9845a5.js → bb2f6b0fcdfb8b158e26.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{4af39fa53bc0b79101ed.js → bc8a74da48b08309875f.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{026d3fa331caec1ea3d2.js → bf4dd8e50704e4040966.js} +1 -1
  42. package/assets/esri/core/workers/chunks/c19e3f6027b6526de359.js +1 -0
  43. package/assets/esri/core/workers/chunks/ce4dfc3a470230ddc9e4.js +1 -0
  44. package/assets/esri/core/workers/chunks/{8ea4584e07ccc85caabd.js → d11de13537b623739e14.js} +1 -1
  45. package/assets/esri/core/workers/chunks/d897412b99b9fba44bb4.js +1 -0
  46. package/assets/esri/core/workers/chunks/{035dbb0217f83108fa89.js → db86a1119e4e58ecfbda.js} +1 -1
  47. package/assets/esri/core/workers/chunks/dcb7a3ff59677b1cf0f1.js +1 -0
  48. package/assets/esri/core/workers/chunks/{5fe97253f80c797fad7f.js → df8a3d3cac454d42e14d.js} +1 -1
  49. package/assets/esri/core/workers/chunks/dfe1139124fda0d6c059.js +1 -0
  50. package/assets/esri/core/workers/chunks/{8b8f391f27774aec6db9.js → e0b27bceb397482bd0e8.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{84821dff3bcc51161802.js → e89dc473f46a5584d2ef.js} +32 -32
  52. package/assets/esri/core/workers/chunks/{01ee18782a50279f907e.js → f4220b6eab0865318033.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{42336e0d1ef88737b078.js → f468c6ea2818a1f97e19.js} +1 -1
  54. package/assets/esri/core/workers/chunks/fce2306a1b31c6680f90.js +1 -0
  55. package/assets/esri/core/workers/chunks/fcf51697c361e0075cc2.js +1 -0
  56. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
  57. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
  58. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +15 -0
  59. package/assets/esri/themes/dark/main.css +1 -1
  60. package/assets/esri/themes/light/main.css +1 -1
  61. package/assets/esri/themes/light/view.css +1 -1
  62. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
  63. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
  64. package/chunks/ShadowCastVisualize.glsl.js +33 -15
  65. package/chunks/arcgis-knowledge-client-core-simd.js +1 -1
  66. package/chunks/arcgis-knowledge-client-core.js +1 -1
  67. package/config.js +1 -1
  68. package/core/workers/registry.js +1 -1
  69. package/form/elements/inputs/MultipleChoiceInput.d.ts +6 -6
  70. package/form/elements/inputs/MultipleChoiceInput.js +1 -1
  71. package/kernel.js +1 -1
  72. package/layers/BaseDynamicLayer.js +1 -1
  73. package/layers/BaseTileLayer.js +1 -1
  74. package/layers/ElevationLayer.js +1 -1
  75. package/layers/MapImageLayer.js +1 -1
  76. package/layers/TileLayer.js +1 -1
  77. package/layers/WMSLayer.js +1 -1
  78. package/layers/WMTSLayer.js +1 -1
  79. package/layers/WebTileLayer.js +1 -1
  80. package/layers/mixins/ArcGISImageService.js +1 -1
  81. package/layers/mixins/TiledImagery.js +1 -1
  82. package/layers/support/imageBitmapUtils.js +1 -1
  83. package/package.json +1 -1
  84. package/request/process.js +1 -1
  85. package/rest/knowledgeGraph/CreateReplicaResponse.d.ts +37 -0
  86. package/rest/knowledgeGraph/CreateReplicaResponse.js +2 -0
  87. package/rest/knowledgeGraph/ReplicaDefinition.d.ts +91 -0
  88. package/rest/knowledgeGraph/ReplicaDefinition.js +2 -0
  89. package/rest/knowledgeGraph/ReplicasInformationResponse.d.ts +24 -0
  90. package/rest/knowledgeGraph/ReplicasInformationResponse.js +2 -0
  91. package/rest/knowledgeGraph/UnregisterReplicaResponse.d.ts +44 -0
  92. package/rest/knowledgeGraph/UnregisterReplicaResponse.js +2 -0
  93. package/rest/knowledgeGraph/wasmInterface/replicaToWasmEncodedFactories.js +2 -0
  94. package/rest/knowledgeGraph/wasmInterface/wasmToReplicaFactories.js +2 -0
  95. package/rest/knowledgeGraphService.d.ts +50 -1
  96. package/rest/knowledgeGraphService.js +1 -1
  97. package/support/revision.js +1 -1
  98. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerShader.js +1 -1
  99. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/AFeatureShader.js +1 -1
  100. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/FillShader.js +1 -1
  101. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
  102. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/OutlineFillShader.js +1 -1
  103. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
  104. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  105. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  106. package/views/2d/layers/BaseDynamicLayerView2D.js +1 -1
  107. package/views/2d/layers/MapImageLayerView2D.js +1 -1
  108. package/views/2d/layers/TileLayerView2D.js +1 -1
  109. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  110. package/views/2d/layers/WMSLayerView2D.js +1 -1
  111. package/views/2d/layers/WMTSLayerView2D.js +1 -1
  112. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  113. package/views/3d/layers/ElevationLayerView3D.js +1 -1
  114. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  115. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  116. package/views/3d/layers/IntegratedMesh3DTilesLayerWorker.js +2 -0
  117. package/views/3d/layers/IntegratedMesh3DTilesLayerWorkerHandle.js +2 -0
  118. package/views/3d/layers/TileLayerView3D.js +1 -1
  119. package/views/3d/layers/WMTSLayerView3D.js +1 -1
  120. package/views/3d/layers/graphics/tessellationUtils.js +1 -1
  121. package/views/3d/layers/support/IntegratedMesh3DTilesVertexProcessing.js +2 -0
  122. package/views/3d/layers/support/makeScheduleFunction.js +1 -1
  123. package/views/3d/support/renderInfoUtils/polygon.js +1 -1
  124. package/views/3d/terrain/TerrainData.js +1 -1
  125. package/views/3d/terrain/TerrainSurface.js +1 -1
  126. package/views/3d/terrain/Tile.js +1 -1
  127. package/views/3d/terrain/TileRenderer.js +1 -1
  128. package/views/3d/terrain/terrainUtils.js +1 -1
  129. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  130. package/views/3d/webgl-engine/materials/VisualVariablePassParameters.js +1 -1
  131. package/views/3d/webgl-engine/shaders/ShadowCastVisualize.glsl.js +1 -1
  132. package/views/3d/webgl-engine/shaders/colorRampParameters.js +2 -0
  133. package/views/support/TextureCompressionWorker.js +1 -1
  134. package/views/support/TextureCompressionWorkerHandle.js +1 -1
  135. package/views/webgl/Texture.js +1 -1
  136. package/widgets/BatchAttributeForm/templates/support/hashElementTemplate.js +1 -1
  137. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  138. package/widgets/OrientedImageryViewer/css.js +1 -1
  139. package/widgets/OrientedImageryViewer.js +1 -1
  140. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  141. package/assets/esri/core/workers/chunks/05c3146d87d917606193.js +0 -1
  142. package/assets/esri/core/workers/chunks/0b77c124b743067e4155.js +0 -1
  143. package/assets/esri/core/workers/chunks/11241781baaed346af52.js +0 -1
  144. package/assets/esri/core/workers/chunks/1d9560eb8b21b9e76616.js +0 -1
  145. package/assets/esri/core/workers/chunks/2bd69a7734d170e190ed.js +0 -1
  146. package/assets/esri/core/workers/chunks/2c87c3112a43db8624f6.js +0 -1
  147. package/assets/esri/core/workers/chunks/3a58708217a9c11836ab.js +0 -1
  148. package/assets/esri/core/workers/chunks/3bbf684ee2484eb44c9f.js +0 -1
  149. package/assets/esri/core/workers/chunks/49fb9c47070641bce9a9.js +0 -1
  150. package/assets/esri/core/workers/chunks/5417308eba30e668b1ee.js +0 -1
  151. package/assets/esri/core/workers/chunks/62b3e933f548ce354b99.js +0 -1
  152. package/assets/esri/core/workers/chunks/6e70e922331704b92a08.js +0 -1
  153. package/assets/esri/core/workers/chunks/7c7c11c0fde8b63e330b.js +0 -1
  154. package/assets/esri/core/workers/chunks/7cee7ffaf941a4fe23b0.js +0 -596
  155. package/assets/esri/core/workers/chunks/7f55eef696e9ed717bfc.js +0 -1
  156. package/assets/esri/core/workers/chunks/89dbea6f436d45a3b185.js +0 -1
  157. package/assets/esri/core/workers/chunks/9d216e30d04ea21fc8a2.js +0 -1
  158. package/assets/esri/core/workers/chunks/a5d8d6f3c0c8de474efd.js +0 -1
  159. package/assets/esri/core/workers/chunks/a809b811121099a87a98.js +0 -1
  160. package/assets/esri/core/workers/chunks/c02ba921c0a32d2021e3.js +0 -1
  161. package/assets/esri/core/workers/chunks/c3c19b62d948d53118a8.js +0 -1
  162. package/assets/esri/core/workers/chunks/c46a4adea39636a96d03.js +0 -1
  163. package/assets/esri/core/workers/chunks/c5507480344176fad241.js +0 -1
  164. package/assets/esri/core/workers/chunks/c6030271bd6d39b6e1db.js +0 -1
  165. package/assets/esri/core/workers/chunks/d1a7d13e1d48abcd7bf1.js +0 -1
  166. package/assets/esri/core/workers/chunks/dcbc4072c18278c2b67d.js +0 -1
  167. package/assets/esri/core/workers/chunks/e610d24539a675fb054b.js +0 -1
  168. package/assets/esri/core/workers/chunks/ecb7ede6a8e6c05e4c6c.js +0 -1
  169. package/assets/esri/core/workers/chunks/f227b34cce6843df0fb6.js +0 -1
  170. package/request/ImageWithType.js +0 -2
  171. package/views/3d/layers/support/fetchTile.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import t from"../../core/Error.js";import has from"../../core/has.js";import e from"../../core/Logger.js";import{abortMaybe as i}from"../../core/maybe.js";import{hasValue as r}from"../../core/object.js";import{throwIfAborted as s,isAbortError as o}from"../../core/promiseUtils.js";import{checkWebGLError as a}from"./checkWebGLError.js";import{ResourceType as n,CompressedTextureFormat as p}from"./enums.js";import{estimateMemory as l}from"./TextureDescriptor.js";import{isCompressedData as m,deriveInternalFormat as h,isTexImageSource as d,is3DTarget as c,validateTexture as _,isCompressedFormat as u,getDimensions as g,isSizedPixelFormat as x,isSizedDepthFormat as T,isSizedDepthStencilFormat as M,calcMipmapLevels as b}from"./textureUtils.js";import{ValidatedTextureDescriptor as f}from"./ValidatedTextureDescriptor.js";const w=!!has("esri-tests-disable-gpu-memory-measurements"),D=()=>e.getLogger("esri/views/webgl/Texture");class E{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(e,i=null,r=null){if(this.type=1,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._shadowFilterDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,r=i;else{const r=f.validate(e,i);if(!r)throw new t("texture:invalid-descriptor","Texture descriptor invalid");this._descriptor=r}34067===this._descriptor.target?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return w?0:l(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty||this._shadowFilterDirty}get hasWebGLTextureObject(){return!!this._glName}dispose(){this.abortCompression(),this.hasWebGLTextureObject&&this._descriptor.context?.gl&&(this._descriptor.context.instanceCounter.decrement(n.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}[Symbol.dispose](){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("texture:immutable-resize","Immutable textures can't be resized!");r.width=e,r.height=i,34067===this._descriptor.target?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t){this._descriptor.compress=t}disableCompression(){this._descriptor.compress=void 0}setData(t){this.abortCompression(),!m(t)&&this._descriptor.internalFormat&&r(p,this._descriptor.internalFormat)&&(this._descriptor.internalFormat=void 0),this._setData(t),!m(t)&&this._descriptor.compress&&this._compressOnWorker(t)}updateData(e,i,r,s,o,a,n=0){a||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update uninitialized texture!");const p=this._descriptor;p.internalFormat=h(p);const{context:l,pixelFormat:c,dataType:_,target:u,isImmutable:g}=p;if(g&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");const x=l.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES,!0);(i<0||r<0||i+s>p.width||r+o>p.height)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:T}=l;n&&(s&&o||D().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),T.pixelStorei(T.UNPACK_SKIP_ROWS,n)),d(a)?T.texSubImage2D(u,e,i,r,s,o,c,_,a):m(a)?T.compressedTexSubImage2D(u,e,i,r,s,o,p.internalFormat,a.levels[e]):T.texSubImage2D(u,e,i,r,s,o,c,_,a),n&&T.pixelStorei(T.UNPACK_SKIP_ROWS,0),l.bindTexture(x,E.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(e,i,r,s,o,a,n,p){p||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update an uninitialized texture!");const l=this._descriptor;l.internalFormat=h(l);const{context:d,pixelFormat:_,dataType:u,isImmutable:g,target:x}=l;if(g&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");c(x)||D().warn("Attempting to set 3D texture data on a non-3D texture");const T=d.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES);d.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES),(i<0||r<0||s<0||i+o>l.width||r+a>l.height||s+n>l.depth)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=d;if(m(p))p=p.levels[e],M.compressedTexSubImage3D(x,e,i,r,s,o,a,n,l.internalFormat,p);else{const t=p;M.texSubImage3D(x,e,i,r,s,o,a,n,_,u,t)}d.bindTexture(T,E.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const e=this._descriptor;if(0===e.width||0===e.height)return;if(!e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot add mipmaps to immutable texture after allocation");e.hasMipmap=!0,this._samplingModeDirty=!0,_(e)}9729===e.samplingMode?(this._samplingModeDirty=!0,e.samplingMode=9985):9728===e.samplingMode&&(this._samplingModeDirty=!0,e.samplingMode=9984);const i=this._descriptor.context.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(e.target),this._descriptor.context.bindTexture(i,E.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,_(e)}9985===e.samplingMode?(this._samplingModeDirty=!0,e.samplingMode=9729):9984===e.samplingMode&&(this._samplingModeDirty=!0,e.samplingMode=9728)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,_(this._descriptor),this._wrapModeDirty=!0)}setShadowFiltering(t){t!==this._descriptor.linearFilterDepth&&(this._descriptor.linearFilterDepth=this._descriptor.compareEnabled=t,this.setSamplingMode(t?9729:9728),_(this._descriptor),this._shadowFilterDirty=!0)}applyChanges(){this._samplingModeDirty&&(this._applySamplingMode(),this._samplingModeDirty=!1),this._wrapModeDirty&&(this._applyWrapMode(),this._wrapModeDirty=!1),this._shadowFilterDirty&&(this._applyShadowMode(),this._shadowFilterDirty=!1)}abortCompression(){this._compressionAbortController=i(this._compressionAbortController)}_setData(e,i){const r=this._descriptor,s=r.context?.gl;if(!s)return;a(s),this.hasWebGLTextureObject||(this._glName=s.createTexture(),r.context.instanceCounter.increment(n.Texture,this)),_(r);const o=r.context.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES);r.context.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),a(s);const p=i??r.target,l=c(p);if(d(e))this._setDataFromTexImageSource(e,p);else{const{width:i,height:o,depth:n}=r;if(null==i||null==o)throw new t("texture:missing-size","Width and height must be specified!");if(l&&null==n)throw new t("texture:missing-depth","Depth must be specified!");if(r.internalFormat=h(r),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(p,r.internalFormat,r.hasMipmap,i,o,n),m(e)){if(!u(r.internalFormat))throw new t("texture:format-mismatch","Attempting to use compressed data with an uncompressed format!");this._setDataFromCompressedSource(e,r.internalFormat,p)}else this._texImage(p,0,r.internalFormat,i,o,n,e),a(s),r.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),this._applyShadowMode(),a(s),r.context.bindTexture(o,E.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(t=null){for(let e=34069;e<=34074;e++)this._setData(t,e)}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_setDataFromTexImageSource(t,e){const{gl:i}=this._descriptor.context,r=this._descriptor;r.internalFormat=h(r);const s=c(e),{width:o,height:n,depth:p}=g(t);r.width&&r.height,r.width||(r.width=o),r.height||(r.height=n),s&&r.depth,s&&(r.depth=p),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(e,r.internalFormat,r.hasMipmap,o,n,p),this._texImage(e,0,r.internalFormat,o,n,p,t),a(i),r.hasMipmap&&(this.generateMipmap(),a(i))}_setDataFromCompressedSource(t,e,i){const r=this._descriptor,{width:s,height:o,depth:a}=r,n=t.levels,p=b(i,s,o,a),l=Math.min(p,n.length)-1;this._descriptor.context.gl.texParameteri(r.target,33085,l),this._forEachMipmapLevel((t,r,s,o)=>{const a=n[Math.min(t,n.length-1)];this._compressedTexImage(i,t,e,r,s,o,a)},l)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!x(i)&&!T(i)&&!M(i))throw new t("texture:missing-format","Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const p=r?b(e,s,o,a):1;if(c(e)){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");n.texStorage3D(e,p,i,s,o,a)}else n.texStorage2D(e,p,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=c(e),{isImmutable:m,pixelFormat:h,dataType:d}=this._descriptor;if(m){if(null!=n){const r=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texSubImage3D(e,i,0,0,0,s,o,a,h,d,r)}else p.texSubImage2D(e,i,0,0,s,o,h,d,r)}}else{const m=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texImage3D(e,i,r,s,o,a,0,h,d,m)}else p.texImage2D(e,i,r,s,o,0,h,d,m)}}_compressedTexImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=c(e);if(this._descriptor.isImmutable){if(null!=n)if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else p.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexImage3D(e,i,r,s,o,a,0,n)}else p.compressedTexImage2D(e,i,r,s,o,0,n)}async _compressOnWorker(t){const{width:e,height:i,context:r,flipped:a,preMultiplyAlpha:n,hasMipmap:p}=this._descriptor,l=this._descriptor.compress?.compressionTracker,m=this._descriptor.compress?.compressionCallback,{compressedTextureETC:h,compressedTextureS3TC:d}=r.capabilities;if(!E.compressionWorkerHandle?.isCompressible(t,this._descriptor)||!h&&!d)return;this.abortCompression();const c=new AbortController;let _;this._compressionAbortController=c,l?.increment();try{t instanceof Uint8Array?_=t.buffer:(_=await createImageBitmap(t,{imageOrientation:a?"flipY":"none"}),s(c));const r={data:_,width:e,height:i,needsFlip:t instanceof Uint8Array&&this.descriptor.flipped,components:6408===this._descriptor.pixelFormat?4:3,preMultiplyAlpha:n,hasMipmap:p,hasETC:!!h,hasS3TC:!!d},o=await E.compressionWorkerHandle.invoke(r,c.signal,1);if(s(c),o.compressedTexture&&this.hasWebGLTextureObject){const t=this.usedMemory;this._descriptor.internalFormat=o.internalFormat,this._setData(o.compressedTexture),m?.(t-this.usedMemory)}}catch(u){o(u)||D().error("Texture compression failed!")}finally{l?.decrement(),this._compressionAbortController?.signal.aborted&&(this._compressionAbortController=null),_ instanceof ImageBitmap&&_.close()}}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:o,hasMipmap:a,target:n}=this._descriptor;const p=32879===n;if(null==r||null==s||p&&null==o)throw new t("texture:missing-size","Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,o),a&&(1!==r||1!==s||p&&1!==o)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),p&&(o=Math.max(1,o>>1))}_applySamplingMode(){const t=this._descriptor,e=t.context?.gl;let i=t.samplingMode,r=t.samplingMode;9985===i||9987===i?(i=9729,t.hasMipmap||(r=9729)):9984!==i&&9986!==i||(i=9728,t.hasMipmap||(r=9728)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,i),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){const t=this._descriptor,e=t.context?.gl;"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}_applyShadowMode(){const t=this._descriptor,e=t.context?.gl,i=t.compareEnabled?e.COMPARE_REF_TO_TEXTURE:e.NONE;e.texParameteri(t.target,e.TEXTURE_COMPARE_MODE,i),t.compareEnabled&&e.texParameteri(t.target,e.TEXTURE_COMPARE_FUNC,e.GREATER),a(e)}_applyAnisotropicFilteringParameters(){const t=this._descriptor,e=t.context.capabilities.textureFilterAnisotropic;if(!e)return;t.context.gl.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}}export{E as default};
2
+ import t from"../../core/Error.js";import has from"../../core/has.js";import e from"../../core/Logger.js";import{abortMaybe as i}from"../../core/maybe.js";import{hasValue as r}from"../../core/object.js";import{throwIfAborted as s,isAbortError as o}from"../../core/promiseUtils.js";import{checkWebGLError as a}from"./checkWebGLError.js";import{ResourceType as n,CompressedTextureFormat as p}from"./enums.js";import{estimateMemory as l}from"./TextureDescriptor.js";import{isCompressedData as m,deriveInternalFormat as h,isTexImageSource as d,is3DTarget as c,validateTexture as _,isCompressedFormat as u,getDimensions as g,isSizedPixelFormat as x,isSizedDepthFormat as T,isSizedDepthStencilFormat as M,calcMipmapLevels as b}from"./textureUtils.js";import{ValidatedTextureDescriptor as f}from"./ValidatedTextureDescriptor.js";const w=!!has("esri-tests-disable-gpu-memory-measurements"),D=()=>e.getLogger("esri/views/webgl/Texture");class E{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(e,i=null,r=null){if(this.type=1,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._shadowFilterDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,r=i;else{const r=f.validate(e,i);if(!r)throw new t("texture:invalid-descriptor","Texture descriptor invalid");this._descriptor=r}34067===this._descriptor.target?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return w?0:l(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty||this._shadowFilterDirty}get hasWebGLTextureObject(){return!!this._glName}dispose(){this.abortCompression(),this.hasWebGLTextureObject&&this._descriptor.context?.gl&&(this._descriptor.context.instanceCounter.decrement(n.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}[Symbol.dispose](){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("texture:immutable-resize","Immutable textures can't be resized!");r.width=e,r.height=i,34067===this._descriptor.target?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t){this._descriptor.compress=t}disableCompression(){this._descriptor.compress=void 0}setData(t){this.abortCompression(),!m(t)&&this._descriptor.internalFormat&&r(p,this._descriptor.internalFormat)&&(this._descriptor.internalFormat=void 0),this._setData(t),!m(t)&&this._descriptor.compress&&this._compressOnWorker(t)}updateData(e,i,r,s,o,a,n=0){a||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update uninitialized texture!");const p=this._descriptor;p.internalFormat=h(p);const{context:l,pixelFormat:c,dataType:_,target:u,isImmutable:g}=p;if(g&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");const x=l.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES,!0);(i<0||r<0||i+s>p.width||r+o>p.height)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:T}=l;n&&(s&&o||D().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),T.pixelStorei(T.UNPACK_SKIP_ROWS,n)),d(a)?T.texSubImage2D(u,e,i,r,s,o,c,_,a):m(a)?T.compressedTexSubImage2D(u,e,i,r,s,o,p.internalFormat,a.levels[e]):T.texSubImage2D(u,e,i,r,s,o,c,_,a),n&&T.pixelStorei(T.UNPACK_SKIP_ROWS,0),l.bindTexture(x,E.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(e,i,r,s,o,a,n,p){p||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update an uninitialized texture!");const l=this._descriptor;l.internalFormat=h(l);const{context:d,pixelFormat:_,dataType:u,isImmutable:g,target:x}=l;if(g&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");c(x)||D().warn("Attempting to set 3D texture data on a non-3D texture");const T=d.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES);d.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES),(i<0||r<0||s<0||i+o>l.width||r+a>l.height||s+n>l.depth)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=d;if(m(p))p=p.levels[e],M.compressedTexSubImage3D(x,e,i,r,s,o,a,n,l.internalFormat,p);else{const t=p;M.texSubImage3D(x,e,i,r,s,o,a,n,_,u,t)}d.bindTexture(T,E.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const e=this._descriptor;if(0===e.width||0===e.height)return;if(!e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot add mipmaps to immutable texture after allocation");e.hasMipmap=!0,this._samplingModeDirty=!0,_(e)}9729===e.samplingMode?(this._samplingModeDirty=!0,e.samplingMode=9985):9728===e.samplingMode&&(this._samplingModeDirty=!0,e.samplingMode=9984);const i=this._descriptor.context.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(e.target),this._descriptor.context.bindTexture(i,E.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,_(e)}9985===e.samplingMode?(this._samplingModeDirty=!0,e.samplingMode=9729):9984===e.samplingMode&&(this._samplingModeDirty=!0,e.samplingMode=9728)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,_(this._descriptor),this._wrapModeDirty=!0)}setShadowFiltering(t){t!==this._descriptor.linearFilterDepth&&(this._descriptor.linearFilterDepth=this._descriptor.compareEnabled=t,this.setSamplingMode(t?9729:9728),_(this._descriptor),this._shadowFilterDirty=!0)}applyChanges(){this._samplingModeDirty&&(this._applySamplingMode(),this._samplingModeDirty=!1),this._wrapModeDirty&&(this._applyWrapMode(),this._wrapModeDirty=!1),this._shadowFilterDirty&&(this._applyShadowMode(),this._shadowFilterDirty=!1)}abortCompression(){this._compressionAbortController=i(this._compressionAbortController)}_setData(e,i){const r=this._descriptor,s=r.context?.gl;if(!s)return;a(s),this.hasWebGLTextureObject||(this._glName=s.createTexture(),r.context.instanceCounter.increment(n.Texture,this)),_(r);const o=r.context.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES);r.context.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),a(s);const p=i??r.target,l=c(p);if(d(e))this._setDataFromTexImageSource(e,p);else{const{width:i,height:o,depth:n}=r;if(null==i||null==o)throw new t("texture:missing-size","Width and height must be specified!");if(l&&null==n)throw new t("texture:missing-depth","Depth must be specified!");if(r.internalFormat=h(r),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(p,r.internalFormat,r.hasMipmap,i,o,n),m(e)){if(!u(r.internalFormat))throw new t("texture:format-mismatch","Attempting to use compressed data with an uncompressed format!");this._setDataFromCompressedSource(e,r.internalFormat,p)}else this._texImage(p,0,r.internalFormat,i,o,n,e),a(s),r.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),this._applyShadowMode(),a(s),r.context.bindTexture(o,E.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(t=null){for(let e=34069;e<=34074;e++)this._setData(t,e)}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_setDataFromTexImageSource(t,e){const{gl:i}=this._descriptor.context,r=this._descriptor;r.internalFormat=h(r);const s=c(e),{width:o,height:n,depth:p}=g(t);r.width&&r.height,r.width||(r.width=o),r.height||(r.height=n),s&&r.depth,s&&(r.depth=p),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(e,r.internalFormat,r.hasMipmap,o,n,p),this._texImage(e,0,r.internalFormat,o,n,p,t),a(i),r.hasMipmap&&(this.generateMipmap(),a(i))}_setDataFromCompressedSource(t,e,i){const r=this._descriptor,{width:s,height:o,depth:a}=r,n=t.levels,p=b(i,s,o,a),l=Math.min(p,n.length)-1;this._descriptor.context.gl.texParameteri(r.target,33085,l),this._forEachMipmapLevel((t,r,s,o)=>{const a=n[Math.min(t,n.length-1)];this._compressedTexImage(i,t,e,r,s,o,a)},l)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!x(i)&&!T(i)&&!M(i))throw new t("texture:missing-format","Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const p=r?b(e,s,o,a):1;if(c(e)){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");n.texStorage3D(e,p,i,s,o,a)}else n.texStorage2D(e,p,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=c(e),{isImmutable:m,pixelFormat:h,dataType:d}=this._descriptor;if(m){if(null!=n){const r=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texSubImage3D(e,i,0,0,0,s,o,a,h,d,r)}else p.texSubImage2D(e,i,0,0,s,o,h,d,r)}}else{const m=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texImage3D(e,i,r,s,o,a,0,h,d,m)}else p.texImage2D(e,i,r,s,o,0,h,d,m)}}_compressedTexImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=c(e);if(this._descriptor.isImmutable){if(null!=n)if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else p.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexImage3D(e,i,r,s,o,a,0,n)}else p.compressedTexImage2D(e,i,r,s,o,0,n)}async _compressOnWorker(t){const{width:e,height:i,context:r,flipped:a,preMultiplyAlpha:n,hasMipmap:p}=this._descriptor,l=this._descriptor.compress?.compressionTracker,m=this._descriptor.compress?.compressionCallback,{compressedTextureETC:h,compressedTextureS3TC:d}=r.capabilities;if(!E.compressionWorkerHandle?.isCompressible(t,this._descriptor)||!h&&!d)return;this.abortCompression();const c=new AbortController;let _;this._compressionAbortController=c,l?.increment();let u=!1,g=!1;try{t instanceof ImageBitmap?_=t:t instanceof Uint8Array?(_=t.buffer,u=this.descriptor.flipped):(_=await createImageBitmap(t,{imageOrientation:a?"flipY":"none"}),s(c),g=!0);const r={data:_,width:e,height:i,needsFlip:u,components:6408===this._descriptor.pixelFormat?4:3,preMultiplyAlpha:n,hasMipmap:p,hasETC:!!h,hasS3TC:!!d},o=await E.compressionWorkerHandle.invoke(r,c.signal,1);if(s(c),o.compressedTexture&&this.hasWebGLTextureObject){const t=this.usedMemory;this._descriptor.internalFormat=o.internalFormat,this._setData(o.compressedTexture),m?.(t-this.usedMemory)}}catch(x){o(x)||D().error("Texture compression failed!")}finally{l?.decrement(),this._compressionAbortController?.signal.aborted&&(this._compressionAbortController=null),g&&_ instanceof ImageBitmap&&_.close()}}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:o,hasMipmap:a,target:n}=this._descriptor;const p=32879===n;if(null==r||null==s||p&&null==o)throw new t("texture:missing-size","Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,o),a&&(1!==r||1!==s||p&&1!==o)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),p&&(o=Math.max(1,o>>1))}_applySamplingMode(){const t=this._descriptor,e=t.context?.gl;let i=t.samplingMode,r=t.samplingMode;9985===i||9987===i?(i=9729,t.hasMipmap||(r=9729)):9984!==i&&9986!==i||(i=9728,t.hasMipmap||(r=9728)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,i),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){const t=this._descriptor,e=t.context?.gl;"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}_applyShadowMode(){const t=this._descriptor,e=t.context?.gl,i=t.compareEnabled?e.COMPARE_REF_TO_TEXTURE:e.NONE;e.texParameteri(t.target,e.TEXTURE_COMPARE_MODE,i),t.compareEnabled&&e.texParameteri(t.target,e.TEXTURE_COMPARE_FUNC,e.GREATER),a(e)}_applyAnisotropicFilteringParameters(){const t=this._descriptor,e=t.context.capabilities.textureFilterAnisotropic;if(!e)return;t.context.gl.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}}export{E as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{numericHash as t}from"../../../../core/string.js";import{isBarcodeScannerInput as n,isComboBoxInput as e,isRadioButtonsInput as i,isDatePickerInput as r,isDateTimePickerInput as o,isDateTimeOffsetPickerInput as $,isSwitchInput as u,isTextAreaInput as c,isTextBoxInput as l,isTimePickerInput as a,isMultipleChoiceInput as m}from"../../../../form/elements/inputs/inputUtils.js";import{isFieldElementTemplate as f,isGroupElementTemplate as s,isRelationshipElementTemplate as p,isTextElementTemplate as g,isAttachmentElementTemplate as h,isExcludedFromSharedForm as d}from"./templateUtils.js";const S="",y="num:";function O(n){return f(n)?t(x(n)).toString():s(n)?t(b(n)).toString():p(n)?t(C(n)).toString():g(n)?t(V(n)).toString():h(n)?t(N(n)).toString():t(JSON.stringify(n)).toString()}function x(t){return`${T(t)}.${L(t.field)}.${R(t.domain)}.${t.hint??S}.${j(t.input)}.${t.layerTimeZone??""}`}function b(t){const n=T(t)+`.${t.initialState}`;let e=S;for(const i of t.elements)d(i)||(e+="."+O(i).toString());return`${n}${e}`}function C(t){return`${T(t)}`}function V(t){const n=T(t),{compiledText:e}=t;return`${n}.${e??S}`}function N(t){return`${T(t)}.${t.allowUserRename}.${t.attachmentKeyword??S}.${t.displayFilename}.${J(t.input)}.${t.maxAttachmentCount??S}.${t.minAttachmentCount??S}.${t.useOriginalFilename}`}function T(t){return`${t.label??S}.${t.description??S}`}function j(t){if(!t)return S;const{type:f}=t;if(n(t))return f??S;if(e(t)||i(t)){const{showNoValueOption:n}=t;return`${f}.${n}.${t.noValueOptionLabel??S}`}if(r(t))return`${f}.${v(t)}`;if(o(t)){const n=t.min?.getTime(),e=t.max?.getTime(),{includeTime:i}=t;return`${f}.${n}.${e}.${i}`}if($(t)){const n=v(t),{includeTimeOffset:e,timeResolution:i}=t;return`${f}.${n}.${e}.${i}`}if(u(t)){const{offValue:n,onValue:e}=t;return`${f}.${A(n)}.${A(e)}`}if(c(t)||l(t)){return`${f}.${t.minLength?.toString()??S}.${t.maxLength?.toString()??S}`}if(a(t)){const n=v(t),{timeResolution:e}=t;return`${f}.${n}.${e}`}if(m(t)){return`${f}.${v({min:t.minSelectedChoices?.toString(),max:t.maxSelectedChoices?.toString()})}.${t.choiceDelimiter??S}.${t.includeOtherChoice}.${t.otherChoice?.fieldName??S}.${t.otherChoice?.label??S}.${t.otherChoice?.hint??S}.${w(t)}`}return JSON.stringify(t)}function J(t){return t?JSON.stringify(t.toJSON()):S}function v(t){return`${t.min??S}.${t.max??S}`}function w(t){return(t.choices??[]).map(({label:t,value:n})=>`${t}.${n}`).sort().join(".")}function L(t){const n=t.name,e=t.alias??S;return`${n}.${e===n?S:e}.${t.nullable}.${t.type}.${t.length??S}.${t.defaultValue??S}.${t.description??S}.${t.editable}.${t.visible}`}function R(t){return t?"coded-value"===t.type?U(t):"range"===t.type?F(t):JSON.stringify(t):S}function U(t){const{type:n}=t;return`${n}.${t.codedValues.map(({code:t,name:n})=>`${A(t)}.${n}`).sort().join(".")}`}function A(t){return"number"==typeof t?`${y}${t}`:t}function F(t){const{maxValue:n,minValue:e,type:i}=t;return`${i}.${e}.${n}`}export{O as hashElementTemplate};
2
+ import{numericHash as t}from"../../../../core/string.js";import{isBarcodeScannerInput as n,isComboBoxInput as e,isRadioButtonsInput as i,isDatePickerInput as r,isDateTimePickerInput as o,isDateTimeOffsetPickerInput as $,isSwitchInput as u,isTextAreaInput as c,isTextBoxInput as l,isTimePickerInput as a,isMultipleChoiceInput as m}from"../../../../form/elements/inputs/inputUtils.js";import{isFieldElementTemplate as f,isGroupElementTemplate as s,isRelationshipElementTemplate as p,isTextElementTemplate as g,isAttachmentElementTemplate as d,isExcludedFromSharedForm as h}from"./templateUtils.js";const S="",y="num:";function x(n){return f(n)?t(O(n)).toString():s(n)?t(b(n)).toString():p(n)?t(C(n)).toString():g(n)?t(V(n)).toString():d(n)?t(N(n)).toString():t(JSON.stringify(n)).toString()}function O(t){return`${T(t)}.${A(t.field)}.${L(t.domain)}.${t.hint??S}.${j(t.input)}.${t.layerTimeZone??""}`}function b(t){const n=T(t)+`.${t.initialState}`;let e=S;for(const i of t.elements)h(i)||(e+="."+x(i).toString());return`${n}${e}`}function C(t){return`${T(t)}`}function V(t){const n=T(t),{compiledText:e}=t;return`${n}.${e??S}`}function N(t){return`${T(t)}.${t.allowUserRename}.${t.attachmentKeyword??S}.${t.displayFilename}.${J(t.input)}.${t.maxAttachmentCount??S}.${t.minAttachmentCount??S}.${t.useOriginalFilename}`}function T(t){return`${t.label??S}.${t.description??S}`}function j(t){if(!t)return S;const{type:f}=t;if(n(t))return f??S;if(e(t)||i(t)){const{showNoValueOption:n}=t;return`${f}.${n}.${t.noValueOptionLabel??S}`}if(r(t))return`${f}.${v(t)}`;if(o(t)){const n=t.min?.getTime(),e=t.max?.getTime(),{includeTime:i}=t;return`${f}.${n}.${e}.${i}`}if($(t)){const n=v(t),{includeTimeOffset:e,timeResolution:i}=t;return`${f}.${n}.${e}.${i}`}if(u(t)){const{offValue:n,onValue:e}=t;return`${f}.${U(n)}.${U(e)}`}if(c(t)||l(t)){return`${f}.${t.minLength?.toString()??S}.${t.maxLength?.toString()??S}`}if(a(t)){const n=v(t),{timeResolution:e}=t;return`${f}.${n}.${e}`}if(m(t)){return`${f}.${v({min:t.minSelectedChoices?.toString(),max:t.maxSelectedChoices?.toString()})}.${t.choiceDelimiter??S}.${t.includeSelectAllChoices}.${t.otherChoice?.fieldName??S}.${t.otherChoice?.label??S}.${t.otherChoice?.hint??S}.${w(t)}`}return JSON.stringify(t)}function J(t){return t?JSON.stringify(t.toJSON()):S}function v(t){return`${t.min??S}.${t.max??S}`}function w(t){return(t.choices??[]).map(({label:t,value:n})=>`${t}.${n}`).sort().join(".")}function A(t){const n=t.name,e=t.alias??S;return`${n}.${e===n?S:e}.${t.nullable}.${t.type}.${t.length??S}.${t.defaultValue??S}.${t.description??S}.${t.editable}.${t.visible}`}function L(t){return t?"coded-value"===t.type?R(t):"range"===t.type?F(t):JSON.stringify(t):S}function R(t){const{type:n}=t;return`${n}.${t.codedValues.map(({code:t,name:n})=>`${U(t)}.${n}`).sort().join(".")}`}function U(t){return"number"==typeof t?`${y}${t}`:t}function F(t){const{maxValue:n,minValue:e,type:i}=t;return`${i}.${e}.${n}`}export{x as hashElementTemplate};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/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 h from"../../core/Logger.js";import{clamp as u}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 y,throwIfAborted as v,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 S,when as I}from"../../core/reactiveUtils.js";import{sqlAnd as V}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 L from"../../geometry/Extent.js";import E from"../../geometry/Point.js";import{projectAsync as j}from"../../geometry/projectionUtils.js";import G from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as O}from"../../geometry/support/centroid.js";import{isClockwise as x}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as B}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as R}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 he}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ue}from"../../views/input/InputManager.js";import pe from"../PanoramicVideoViewer.js";import me from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as ge,videoMapViewConstraint as ye,clockwiseDirections as ve,sampleExtent as fe,videoExtent as we,invalidCameraHeading as _e,sectorsInOrder as Fe,sectorsRadii as be,fixedImageSize as Me}from"./constants.js";import{isFeatureAttachment as Se}from"./galleryUtils.js";import{crossSymbol as Ie,crossSymbol3D as Ve,measurementPolygonSymbol as Pe,polylineSymbolPanoramic as Ce,measurementPolylineSymbol as Ae,cameraOverlaySymbol3D as ke,cameraOverlaySymbol as Te,diamondSymbol as Le,diamondSymbol3D as Ee,activeSourcePointSymbol as je,sourcePointSymbol as Ge}from"./symbols.js";import{registryKeys as Oe}from"./types.js";import{isNoAttachmentError as xe,extractHorizonAnglesFromMedia as Be,isTifOrMrf as Re,filterOILLayerView as De,assignElevationSampleToFeatures as He,filterByZ as ze,createPanoramicMedia as Ne,createNonPanoramicMedia as Ue,isSceneView as qe,isGraphic as We,calculateSegment as $e,calculateDirection as Ze}from"./utils.js";import{disableVideoZoomAndPan as Je,getUpdatedConstraints as Ke,getUpdatedExtentPoints as Qe}from"./videoViewerUtils.js";import Xe from"./components/ImageViewer.js";import Ye from"./components/NavigationNode.js";import et from"./components/OrientedImageryVideoViewModel.js";import{NoFeatureFoundWithObjectIdError as tt}from"./navigation/errors.js";import{queryFeatureByObjectIds as it}from"./navigation/queries.js";import{ImageMeasurementService as rt}from"./services/ImageMeasurementService.js";import at from"./services/SuperimposeService.js";import{configureSketchTool as st,extractFieldsFromDataCaptureLayer as ot,constructGraphicFromImageGeometry as nt}from"./support/dataCaptureUtils.js";import{imageSpaceToPoint as lt,removeZFromGeometry as ct}from"./support/geometryUtils.js";import dt from"./support/resolveMediaProps.js";import{isValidDataCaptureLayer as ht}from"./support/typeUtils.js";const ut=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let pt=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._loadImage(i)}catch(s){y(s)||(this.loadImageError(s),h.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){y(r)||(this.loadImageError(r),h.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 Xe,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:ye}),this.verticalFilterEnabled=!1,this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new Xe,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._superimposeService=new at({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._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 v(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){y(r)||(h.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)=>(v(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),_(()=>"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._createViewClickHandle=()=>{if(this.removeHandles(Oe.click),this.disabled||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,ue.DEFAULT),Oe.click)},this._createImageClickHandle=()=>{this.removeHandles(Oe.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:i,currentBestFeature:r,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&r))return;const n=i.clickAction;this.clickAction="pixel-location";const l=c(()=>{this.clickAction=n});let d=null;const h=F(()=>i,"pixel-location",e=>{this.plotReferencePointOnImage(e),d?.abort(),d=a(async t=>{if(!e)return;const i=await this._transformationService.pixelToMapPoint(e).then(e=>{const t=this.view?.spatialReference;return ee(!t,e.spatialReference.equals(t))?e:j(e,t)});v(t),this.plotReferencePointOnGround(i)})});this.addHandles([h,l],Oe.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(Oe.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),Oe.triangularImageClick)},this._enablePan=()=>{this.removeHandles(Oe.videoPanHandles)},this._disablePan=()=>{this.removeHandles(Oe.videoPanHandles),this.addHandles(Je(this.videoMapView),Oe.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._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;v(e),this.depthImage=new s({url:a});try{await this.depthImage.load(e)}catch(o){y(o)||(h.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),v(e),await this.transformAndPlotSelectedLocation(e)}catch(a){y(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?R(l):new E(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),v(e)}catch(d){y(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 dt(t.attributes,e,i),v(i)}catch(f){if(y(f))return;return xe(f)?(h.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${e.objectIdField}: ${t.attributes.objectId}`)):(h.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:u,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&&h.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:u},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),v(e)}catch(a){y(a)||this.loadImageError(a)}},this._loadMediaPrefetcher=async e=>{if(!this._mediaPrefetcher){const{default:t}=await import("./support/MediaPrefetcher.js");v(e),this._mediaPrefetcher=new t({maxEntries:this.preloadMediaSize*ve.length})}return this._mediaPrefetcher},this._loadViewAdapter=async e=>{const{view:t}=this;if(this._adapter?.disableDefaultSuperimposeNavigation?.(),t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");v(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");v(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{if(e.stopPropagation(),e.preventDefault(),e.mapPoint){const t=e.mapPoint;t.x=B(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;if(e.width<fe.xmax-fe.xmin&&e.height<fe.ymax-fe.ymin){this._enablePan();const t=Ke(e);t&&(this.videoMapView.constraints.geometry=t)}else 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&&o){if(this.shouldShowSelectedImage){const i=s.hitTest(e,{include:[o]});this._updatingHandles.addPromise(i);const r=await i;return v(t),await this._processHitTestResults(o,r,{signal:t})}return this._updatingHandles.addPromise(this.loadBestImage(a,{signal:t}))}})},this.plotSelectedPointOnImage=async(e,i)=>{if(await f(i),!e)return;const r=new E({...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 E(s,G.WebMercator),symbol:Ve}),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)},S),b(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},S),b(()=>[this.state,this.mapImageConversionToolState,this.view,this.disabled],()=>{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._updateSuperimposedImage()},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}),v(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}),v(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(Oe.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)}),Oe.interactionHandles);break;case"video":this.addHandles(b(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:i}=this;if(e&&t?.loaded&&i)return{videoExtent:we,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}),Oe.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)}),Oe.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}),v(e),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,d)}),Oe.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(Oe.hittestHandles),e&&this.addHandles(F(()=>e,"hittest-response",this._handleImageHitTestResponse),Oe.hittestHandles)}),b(()=>this.videoMapView.extent,async()=>{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.scheduledFrameId||(this.scheduledFrameId=requestAnimationFrame(()=>{this.scheduledFrameId=null,this._updateInteraction()}))},{initial:!0}),I(()=>null!=this.videoMapView.extent,()=>{this.initialVideoMapViewExtent=this.videoMapView.extent},{once:!0})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){this._adapter?.disableDefaultSuperimposeNavigation?.(),this._abortSuperimposeSchedule(),this.currentBestFeature=null,this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=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._referencePointOnImage=p(this._referencePointOnImage),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(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get 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",u(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",u(e,-10,10))}get currentNode(){const{currentBestFeature:e,navigationNodes:t}=this;return t.find(t=>t.id===e?.attributes.objectId)}get depthImageNotSupported(){if(this.currentBestFeature?.attributes.depthImage)return!Re(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 Re(t)||Se(t)}get imageLoaded(){return o(h.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===_e}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(De(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 popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Fe.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",u(e,0,1))}get superimposeViewSupported(){return"default"===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 Re(a)||Se(a)?{url:a,objectId:t,rotation:(i??0)+(r??0)}:null}).filter(r)):null}get videoExtentPoints(){const e=Qe(this.videoMapView.extent);return e.length?e:we}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(this.mode,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.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._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 ut();st(r,e,i),await i.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw ut();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw ut();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw ut();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw ut();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw ut();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw ut();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,h=t.clone();h.z=o/K(t.spatialReference),h.imageID=i,this.pointSources.push(h),l!==_e&&(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?.[Fe[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(!y(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(v(e),this.drawAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.drawAdapter.viewModel.isResolved())return}return this.drawAdapter}loadImageError(e){h.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:i}=await t;v(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(v(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);v(i),await this._updateElevationOfSelectedPointAndLocations(a,t,n),v(i),He(a,n);let l=a;if(this.layer?.verticalSearchRange&&this.layer.hasZ&&this.verticalFilterEnabled&&(l=ze(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 v(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=Pe(o),this.sketch.polylineSymbol="panoramic"===s?Ce:Ae(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,currentBestFeature:r,overlayedCameraLocations:a,layer:s,mode:o,state:n,layerFloorFilterClause:l,layerTimeExtent:c}=this,d=i?.imageSize;if(!d||!r||!s||"default"!==o&&"panoramic"!==o||n.includes("loading"))return;const{polygon:h}=q(r.attributes);if(i.removeManyGraphics(a.toArray()),a.removeAll(),e){const{features:e}=await s.queryFeatures({where:V(`${s.objectIdField} <> ${r.attributes.objectId}`,V(s.definitionExpression,l)),geometry:h,returnGeometry:!0,outFields:[s.objectIdField],timeExtent:c}),n=await Promise.all(e.map(async e=>{const{attributes:i,geometry:r}=e,a=await this._transformationService.pointToImageGeometry(r),s="panoramic"===o?ke():Te();return new t({attributes:i,symbol:s,geometry:a})}));a.addMany(n),i.addManyGraphics(a.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,i=!1){const{activeViewer:r,currentBestFeature:a,mode:o,state:n,layer:l}=this,c=r?.imageSize;if(!c||!a||"none"===o||"video"===o||"panoramic-video"===o||n.includes("loading")||!l)return;const{polygon:d}=q(a.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=ot(e,l.imageGeometryField,l.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(m){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",m)}const{features:u}=await e.queryFeatures({geometry:d,returnGeometry:!0,outFields:["*"]}),p=new s(await Promise.all(u.map(async s=>{const n=s.symbol?.clone()??e.renderer?.getSymbol(s)?.clone(),{attributes:l,geometry:d}=s,{imageGeometryField:u,oiObjectIdField:p}=this;if(u&&p&&ht(e,u,p)&&`${l[p]}`==`${a.attributes.objectId}`)try{const t=Be(r?.media);return nt(l,u,e,i,c,o,n,t)}catch(m){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:m,feature:s,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}const g=await this._transformationService.geometryToImageGeometry(d);return new t({attributes:l,layer:e,symbol:n,geometry:g,visible:e.visible&&i})})));this.overlayGraphicsOnImage(`${e.id}`,p)}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 h.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!s?.loaded)return h.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 Fe.filter(e=>this._sectorData?.[e]?.length)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new E({...e.toJSON()}),symbol:Le}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){const{state:i,mode:r,activeViewer:a}=this;if("image-loaded"!==i||!a?.imageSize||"default"!==r&&"panoramic"!==r)return;this.clearReferencePointOnImage();const s=Be(a.media),o=lt(e,r,a.imageSize,s);this._referencePointOnImage=new t({geometry:o,symbol:"panoramic"===r?Ee.clone():Le.clone()}),a.addGraphic(this._referencePointOnImage,0)}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach(e=>{this._imageViewer.removeManyGraphics(e.toArray())}),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}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],h=l?d?.(r):r;return h&&(i.geometry=await this._transformationService.imageGeometryToMapGeometry(h,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){y(i)||(this.setMessage("imageLoadError","error",i.message),h.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),h=await this.loadDataCaptureAdapter(t);v(t),d.addGraphics(l),h.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{selectedLocation:t,options:i}=e;let r=!1,a=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await j(t,s.spatialReference);r=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await j(t,s.spatialReference);a=s.extent.contains(e);break}}if(!r&&!a)return void this.clearReferencePointOnImage();const o=await this._transformationService.pointToPixel(t,i);if(o)return v(i),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}async updateFeatureCache(e,t){const i=await N(e,t);i.features?.length&&(this.featureCache=i.features)}async _fetchFeatures(e,t){const{layer:i,layerFloorFilterClause:r,layerTimeExtent:a,view:s}=this;if(!s||!i)return;e.x=B(e.x,e.spatialReference);const o=i.spatialReference.equals(e.spatialReference)?e:await j(e,i.spatialReference),n=o.spatialReference.isGeographic?R(o):o,l=V("1=1",V(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(y(i))return;this.setMessage("imageLoadError","error"),h.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 Fe)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*be[2],l=$e(t,c),d=Ze(r);if(!this._sectorData)return;const h=be[3]+n*Math.sin(r*Math.PI/180),u=be[3]+n*Math.cos(r*Math.PI/180);let p;const m=i.at(s),g=m===a,{cameraPitch:y}=m.attributes,v=y<5;if(g&&v)p=-90;else{const e=h-be[3],t=u-be[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=v?null:{x:h,y:u,direction:d}),o[`${m.attributes.objectId}`]=f;const w=this._sectorData[f];w.add({angle:r,featureIndex:s,x:h,y:u,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;v(e),this._locationViewModel=new i({oiViewModel:this,referenceTransformationService:this._referenceTransformationService})}}_initializeMeasurementService(){this._measurementService||(this._measurementService=new rt({transformationService:this._transformationService,referenceTransformationService:this._referenceTransformationService}))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(Oe.videoPlayerHandles),this.videoElement=new le({video:this.currentBestFeature.attributes.imagePath,georeference:new oe({extent:new L(fe)}),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 et({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=Ne(r);try{await a.load(t)}catch(o){if(y(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=Ue(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){y(a)||h.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:qe(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 it(e,t,i,r,a);if(v(a),!s?.features?.length)throw new tt(t);const o=q(s.features[0].attributes).polygon,n=E.fromJSON(O(o)),l=Q(n),c=P(l.spatialReference);this.selectedPoint=l;const d={layerInstanceOrURL:e,point:l,queryParams:{where:V(V("1=1",V(e.definitionExpression,i)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0,timeExtent:r}},h=await z(d,a);v(a);const{features:u}=h;return u.push(s.features[0]),await this.processFeatureResponse(h,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);v(r);const[n,...l]=await X([t,...e.map(e=>e.attributes.geometry.clone())],o);v(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 Ye({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]),"video"===this.mode&&(this._initializeVideo(),this.videoElement?.loaded&&this.videoViewModel?.playVideoFromSelectedLocation(e[0])),"panoramic-video"===this.mode&&this._loadVideo()}_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)=>+x([e,t])),t.addRing(i),this.footprintExtent=he(t.extent,2,2)}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)),v(e);for(const o of i){const i=this.view&&!this.view.spatialReference?.equals(o.spatialReference)?await j(o.clone(),this.view?.spatialReference,e):o.clone();o.imageID===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:o.imageID},geometry:i,symbol:je,visible:a}):this.additionalCameraLocations.push(new t({attributes:{imageID:o.imageID},geometry:i,symbol:Ge,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-be[3],r=e.y-be[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._referencePointOnImage=p(this._referencePointOnImage))}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 h=s.location;h.spatialReference.isGeographic&&(h=Q(h));const u="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:u,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?Me: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 h=s.location;h.spatialReference.isGeographic&&(h=Q(h));const u="default"===r||"video"===r?"default":"panoramic",p={..."default"===u?ae(s,a[0],a[1]):se(s,a[0],a[1]),cameraLocation:h},m=await re(n,l??0,c,{elevationSample:o,elevationSource:d,extent:this.footprintExtent},e),g=(await import("./services/TransformationService.js")).default,y={imageToWorldProperties:p,updateElevationProps:m,mode:u,imageSize:a,depthImageService:this.depthImage};this._transformationService=new g(y),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}),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||h.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint: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:h},elevationSample:u}=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(We);"3d"===l?.type&&u&&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:h}}))),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&&u&&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(){const{currentBestFeature:e,defaultSuperimposeCameraLockEnabled:t,layer:i,mode:r,view:a,state:s,superimposeViewEnabled:o,superimposeViewSupported:n,activeViewer:l,depthImage:c}=this;this._superimposeService.update({activeImageSize:l?.imageSize||void 0,adapter:this._adapter,currentBestFeature:e,defaultSuperimposeCameraLockEnabled:t,depthImageLoaded:c?.loaded??!1,layer:i,mode:r,state:s,superimposeViewEnabled:o&&n,view:a}),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()?!t||t.interacting||t.navigating?this._abortSuperimposeSchedule():this._scheduleDefaultSuperimposeUpdate():this._abortSuperimposeSchedule()}_shouldDisableUnsupportedSuperimposeView(){return this.superimposeViewEnabled&&"panoramic"===this.mode&&!this.superimposeViewSupported}_hasActiveSuperimposeCameraContext(){return"default"===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()}_clearSuperimposeDebounceTimeout(){null!=this.superimposeDebounceTimeoutId&&(clearTimeout(this.superimposeDebounceTimeoutId),this.superimposeDebounceTimeoutId=null)}_clearSuperimposeScheduledFrame(){null!=this.superimposeScheduledFrameId&&(cancelAnimationFrame(this.superimposeScheduledFrameId),this.superimposeScheduledFrameId=null)}_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()],pt.prototype,"activeLayer",null),e([C({readOnly:!0})],pt.prototype,"activeViewer",null),e([C()],pt.prototype,"activeTriangulatedViewer",null),e([C()],pt.prototype,"accuracyParametersMissing",null),e([C()],pt.prototype,"additionalFeatures",void 0),e([C({type:s.ofType(t)})],pt.prototype,"additionalCameraLocations",void 0),e([C({type:s.ofType(t)})],pt.prototype,"additionalFootprints",void 0),e([C()],pt.prototype,"areaMeasurementResult",void 0),e([C()],pt.prototype,"areaMeasurementAccuracy",void 0),e([C()],pt.prototype,"bestFeatureAngle",void 0),e([C()],pt.prototype,"bestFeatureCurrentFootprint",void 0),e([C({type:t})],pt.prototype,"bestFeatureFootprint",void 0),e([C({type:Number})],pt.prototype,"brightness",null),e([C()],pt.prototype,"cameraHeadingThreshold",void 0),e([C()],pt.prototype,"cameraPitchThreshold",void 0),e([C()],pt.prototype,"clickAction",void 0),e([C()],pt.prototype,"correctedLocationPointOnImage",void 0),e([C()],pt.prototype,"videoViewModel",void 0),e([C()],pt.prototype,"collectionId",void 0),e([C({type:Number})],pt.prototype,"contrast",null),e([C()],pt.prototype,"coverageFrustums",void 0),e([C()],pt.prototype,"coveragePolygons",void 0),e([C()],pt.prototype,"currentBestFeature",void 0),e([C()],pt.prototype,"currentBestFeatureMeasurementImage",void 0),e([C()],pt.prototype,"currentBestFeatureLocation",void 0),e([C()],pt.prototype,"currentCoverageVisible",void 0),e([C()],pt.prototype,"currentNode",null),e([C()],pt.prototype,"depthImage",void 0),e([C()],pt.prototype,"depthImageNotSupported",null),e([C()],pt.prototype,"featureCache",void 0),e([C()],pt.prototype,"navigationNodes",void 0),e([C({json:{write:!1}})],pt.prototype,"determineWorkflowForFeature",void 0),e([C({json:{write:!1}})],pt.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([C()],pt.prototype,"disabled",void 0),e([C()],pt.prototype,"displayMessage",void 0),e([C()],pt.prototype,"displayNewMeasurementButton",void 0),e([C()],pt.prototype,"distanceMeasurementResult",void 0),e([C()],pt.prototype,"distanceAccuracyArray",void 0),e([C()],pt.prototype,"dataCaptureLayer",void 0),e([C({readOnly:!0})],pt.prototype,"featureCount",null),e([C()],pt.prototype,"features",void 0),e([C()],pt.prototype,"groundCoordinates",void 0),e([C()],pt.prototype,"groundCoordinatesAccuracy",void 0),e([C()],pt.prototype,"heightGraphic",void 0),e([C()],pt.prototype,"heightMeasurementResult",void 0),e([C()],pt.prototype,"heightMeasurementAccuracy",void 0),e([C({readOnly:!0})],pt.prototype,"imageGalleryEnabled",null),e([C()],pt.prototype,"imageGeometryField",void 0),e([C({readOnly:!0})],pt.prototype,"imageLoaded",null),e([C()],pt.prototype,"imageLocationToolState",void 0),e([C()],pt.prototype,"initialVideoMapViewExtent",void 0),e([C({readOnly:!0})],pt.prototype,"invalidCameraHeading",null),e([C()],pt.prototype,"imagePointsInView",null),e([C()],pt.prototype,"imageMeasurementViewer",void 0),e([C()],pt.prototype,"isAdditionalCoverageVisible",void 0),e([C()],pt.prototype,"isAdditionalPointSourcesVisible",void 0),e([C()],pt.prototype,"layer",void 0),e([C()],pt.prototype,"layerView",null),e([C({readOnly:!0})],pt.prototype,"layerFloorFilterClause",null),e([C({readOnly:!0})],pt.prototype,"layerTimeExtent",null),e([C({type:Number})],pt.prototype,"localPort",void 0),e([C()],pt.prototype,"locationPointOnImage",void 0),e([C()],pt.prototype,"mapImageConversionToolState",void 0),e([C()],pt.prototype,"measureType",void 0),e([C()],pt.prototype,"measurementGraphic",void 0),e([C({readOnly:!0,value:"none"})],pt.prototype,"mode",null),e([C()],pt.prototype,"navigationMode",void 0),e([C()],pt.prototype,"navigatorCurrentBestFeature",void 0),e([C()],pt.prototype,"oiObjectIdField",void 0),e([C({type:s.ofType(t)})],pt.prototype,"overlayedCameraLocations",void 0),e([C()],pt.prototype,"overlayedMapFeatures",void 0),e([C()],pt.prototype,"panoramicVideoLoaded",null),e([C()],pt.prototype,"pixelCoordinates",void 0),e([C()],pt.prototype,"preserveAngle",void 0),e([C()],pt.prototype,"pointSources",void 0),e([C({readOnly:!0})],pt.prototype,"popupEnabled",null),e([C()],pt.prototype,"preloadMedia",void 0),e([C()],pt.prototype,"preloadMediaSize",void 0),e([C()],pt.prototype,"previousFeatureAngle",void 0),e([C()],pt.prototype,"referencePoint",null),e([C({readOnly:!0})],pt.prototype,"sectorData",null),e([C()],pt.prototype,"selectedPoint",void 0),e([C({type:Number})],pt.prototype,"sharpness",null),e([C()],pt.prototype,"shouldShowSelectedImage",void 0),e([C()],pt.prototype,"superimposeViewEnabled",void 0),e([C()],pt.prototype,"defaultSuperimposeCameraLockEnabled",void 0),e([C()],pt.prototype,"superimposeViewSupported",null),e([C()],pt.prototype,"sketch",void 0),e([C()],pt.prototype,"sketchTriangular",void 0),e([C()],pt.prototype,"sketchTriangularGraphicsLayer",void 0),e([C()],pt.prototype,"draw",void 0),e([C()],pt.prototype,"drawAdapter",void 0),e([C()],pt.prototype,"polylineDrawAction",void 0),e([C()],pt.prototype,"scheduledFrameId",void 0),e([C()],pt.prototype,"superimposeScheduledFrameId",void 0),e([C()],pt.prototype,"superimposeDebounceTimeoutId",void 0),e([C()],pt.prototype,"sketchAdapter",void 0),e([C({readOnly:!0})],pt.prototype,"sketchGraphicsLayer",null),e([C({readOnly:!0})],pt.prototype,"state",null),e([C({readOnly:!0})],pt.prototype,"thumbnails",null),e([C()],pt.prototype,"videoExtentPoints",null),e([C()],pt.prototype,"triangularMeasurementActive",void 0),e([C()],pt.prototype,"triangulatedDistanceMeasurement",void 0),e([C()],pt.prototype,"triangulatedDistanceAccuracy",void 0),e([C()],pt.prototype,"triangulatedAreaMeasurement",void 0),e([C()],pt.prototype,"triangulatedAreaAccuracy",void 0),e([C()],pt.prototype,"triangulatedMeasurementGraphic",void 0),e([C()],pt.prototype,"triangulatedPoint",void 0),e([C()],pt.prototype,"triangulatedMeasurementAdapter",void 0),e([C()],pt.prototype,"updateFootprint",void 0),e([C()],pt.prototype,"updateVideoFootprint",void 0),e([C()],pt.prototype,"updateFootprintPanorama",void 0),e([C()],pt.prototype,"updatingTriangularMeasurementState",void 0),e([C({value:null})],pt.prototype,"view",null),e([C()],pt.prototype,"videoElement",void 0),e([C()],pt.prototype,"videoLayer",void 0),e([C()],pt.prototype,"videoMapView",void 0),e([C()],pt.prototype,"verticalFilterEnabled",void 0),e([C()],pt.prototype,"_adapter",void 0),e([C()],pt.prototype,"_defaultGraphicsLayer",null),e([C()],pt.prototype,"_highlightedFeatureHandle",void 0),e([C()],pt.prototype,"_imageViewer",void 0),e([C()],pt.prototype,"_initialCurrentCoverageUpdate",void 0),e([C()],pt.prototype,"_locationViewModel",void 0),e([C()],pt.prototype,"_measurementService",void 0),e([C()],pt.prototype,"_mediaPrefetcher",void 0),e([C()],pt.prototype,"_navigationManager",void 0),e([C()],pt.prototype,"_overlays",void 0),e([C()],pt.prototype,"_superimposeService",void 0),e([C({readOnly:!0})],pt.prototype,"_overlaysView",null),e([C()],pt.prototype,"_panoramicVideoViewer",void 0),e([C()],pt.prototype,"_panoramicViewer",void 0),e([C()],pt.prototype,"_panoramicMeasurementViewer",void 0),e([C()],pt.prototype,"_referencePointOnGround",void 0),e([C()],pt.prototype,"_referencePointOnImage",void 0),e([C()],pt.prototype,"_referenceTransformationService",void 0),e([C()],pt.prototype,"_sectorData",void 0),e([C()],pt.prototype,"_transformationService",void 0),e([C()],pt.prototype,"_featureToSector",void 0),e([C({readOnly:!0})],pt.prototype,"_updatingHandles",void 0),e([C()],pt.prototype,"footprintExtent",void 0),e([C()],pt.prototype,"_featureChangedTask",void 0),pt=e([A("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],pt);const mt=pt;export{mt 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 u}from"../../core/lang.js";import h from"../../core/Logger.js";import{clamp as d}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 y,throwIfAborted as v,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 S,when as I}from"../../core/reactiveUtils.js";import{sqlAnd as V}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 L from"../../geometry/Extent.js";import E from"../../geometry/Point.js";import{projectAsync as j}from"../../geometry/projectionUtils.js";import G from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as O}from"../../geometry/support/centroid.js";import{isClockwise as x}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as B}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as R}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 ue from"../../views/draw/Draw.js";import{scale as he}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as de}from"../../views/input/InputManager.js";import pe from"../PanoramicVideoViewer.js";import me from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as ge,videoMapViewConstraint as ye,clockwiseDirections as ve,sampleExtent as fe,videoExtent as we,invalidCameraHeading as _e,sectorsInOrder as Fe,sectorsRadii as be,fixedImageSize as Me}from"./constants.js";import{isFeatureAttachment as Se}from"./galleryUtils.js";import{crossSymbol as Ie,crossSymbol3D as Ve,measurementPolygonSymbol as Pe,polylineSymbolPanoramic as Ce,measurementPolylineSymbol as Ae,cameraOverlaySymbol3D as ke,cameraOverlaySymbol as Te,diamondSymbol as Le,diamondSymbol3D as Ee,activeSourcePointSymbol as je,sourcePointSymbol as Ge}from"./symbols.js";import{registryKeys as Oe}from"./types.js";import{isNoAttachmentError as xe,extractHorizonAnglesFromMedia as Be,isTifOrMrf as Re,filterOILLayerView as De,assignElevationSampleToFeatures as He,filterByZ as ze,createPanoramicMedia as Ne,createNonPanoramicMedia as Ue,isSceneView as qe,isGraphic as We,calculateSegment as $e,calculateDirection as Ze}from"./utils.js";import{disableVideoZoomAndPan as Je,getUpdatedConstraints as Ke,getUpdatedExtentPoints as Qe}from"./videoViewerUtils.js";import Xe from"./components/ImageViewer.js";import Ye from"./components/NavigationNode.js";import et from"./components/OrientedImageryVideoViewModel.js";import{NoFeatureFoundWithObjectIdError as tt}from"./navigation/errors.js";import{queryFeatureByObjectIds as it}from"./navigation/queries.js";import{ImageMeasurementService as rt}from"./services/ImageMeasurementService.js";import at from"./services/SuperimposeService.js";import{configureSketchTool as st,extractFieldsFromDataCaptureLayer as ot,constructGraphicFromImageGeometry as nt}from"./support/dataCaptureUtils.js";import{imageSpaceToPoint as lt,removeZFromGeometry as ct}from"./support/geometryUtils.js";import ut from"./support/resolveMediaProps.js";import{isValidDataCaptureLayer as ht}from"./support/typeUtils.js";const dt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let pt=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._loadImage(i)}catch(s){y(s)||(this.loadImageError(s),h.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){y(r)||(this.loadImageError(r),h.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 Xe,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:ye}),this.verticalFilterEnabled=!1,this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new Xe,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._superimposeService=new at({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._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 v(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){y(r)||(h.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)=>(v(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),_(()=>"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._createViewClickHandle=()=>{if(this.removeHandles(Oe.click),this.disabled||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,de.DEFAULT),Oe.click)},this._createImageClickHandle=()=>{this.removeHandles(Oe.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:i,currentBestFeature:r,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&r))return;const n=i.clickAction;this.clickAction="pixel-location";const l=c(()=>{this.clickAction=n});let u=null;const h=F(()=>i,"pixel-location",e=>{this.plotReferencePointOnImage(e),u?.abort(),u=a(async t=>{if(!e)return;const i=await this._transformationService.pixelToMapPoint(e).then(e=>{const t=this.view?.spatialReference;return ee(!t,e.spatialReference.equals(t))?e:j(e,t)});v(t),this.plotReferencePointOnGround(i)})});this.addHandles([h,l],Oe.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(Oe.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),Oe.triangularImageClick)},this._enablePan=()=>{this.removeHandles(Oe.videoPanHandles)},this._disablePan=()=>{this.removeHandles(Oe.videoPanHandles),this.addHandles(Je(this.videoMapView),Oe.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._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;v(e),this.depthImage=new s({url:a});try{await this.depthImage.load(e)}catch(o){y(o)||(h.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),v(e),await this.transformAndPlotSelectedLocation(e)}catch(a){y(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?R(l):new E(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),v(e)}catch(u){y(u)||this.loadImageError(u)}},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),v(i)}catch(f){if(y(f))return;return xe(f)?(h.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${e.objectIdField}: ${t.attributes.objectId}`)):(h.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:u,matrix:d,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&&h.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:u,matrix:d},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),v(e)}catch(a){y(a)||this.loadImageError(a)}},this._loadMediaPrefetcher=async e=>{if(!this._mediaPrefetcher){const{default:t}=await import("./support/MediaPrefetcher.js");v(e),this._mediaPrefetcher=new t({maxEntries:this.preloadMediaSize*ve.length})}return this._mediaPrefetcher},this._loadViewAdapter=async e=>{const{view:t}=this;if(this._adapter?.disableDefaultSuperimposeNavigation?.(),t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");v(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");v(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{if(e.stopPropagation(),e.preventDefault(),e.mapPoint){const t=e.mapPoint;t.x=B(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;if(e.width<fe.xmax-fe.xmin&&e.height<fe.ymax-fe.ymin){this._enablePan();const t=Ke(e);t&&(this.videoMapView.constraints.geometry=t)}else 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&&o){if(this.shouldShowSelectedImage){const i=s.hitTest(e,{include:[o]});this._updatingHandles.addPromise(i);const r=await i;return v(t),await this._processHitTestResults(o,r,{signal:t})}return this._updatingHandles.addPromise(this.loadBestImage(a,{signal:t}))}})},this.plotSelectedPointOnImage=async(e,i)=>{if(await f(i),!e)return;const r=new E({...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 E(s,G.WebMercator),symbol:Ve}),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)},S),b(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},S),b(()=>[this.state,this.mapImageConversionToolState,this.view,this.disabled],()=>{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}),v(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}),v(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(Oe.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,u)}),Oe.interactionHandles);break;case"video":this.addHandles(b(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:i}=this;if(e&&t?.loaded&&i)return{videoExtent:we,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,u)&&e?.bestFeatureFootprint===t?.bestFeatureFootprint}),Oe.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,u)}),Oe.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}),v(e),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,u)}),Oe.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(Oe.hittestHandles),e&&this.addHandles(F(()=>e,"hittest-response",this._handleImageHitTestResponse),Oe.hittestHandles)}),b(()=>this.videoMapView.extent,async()=>{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.scheduledFrameId||(this.scheduledFrameId=requestAnimationFrame(()=>{this.scheduledFrameId=null,this._updateInteraction()}))},{initial:!0}),I(()=>null!=this.videoMapView.extent,()=>{this.initialVideoMapViewExtent=this.videoMapView.extent},{once:!0})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){this._adapter?.disableDefaultSuperimposeNavigation?.(),this._abortSuperimposeSchedule(),this.currentBestFeature=null,this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=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._referencePointOnImage=p(this._referencePointOnImage),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(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get 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",d(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",d(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!Re(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 Re(t)||Se(t)}get imageLoaded(){return o(h.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===_e}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(De(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 popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Fe.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",d(e,0,1))}get superimposeViewSupported(){return"default"===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 Re(a)||Se(a)?{url:a,objectId:t,rotation:(i??0)+(r??0)}:null}).filter(r)):null}get videoExtentPoints(){const e=Qe(this.videoMapView.extent);return e.length?e:we}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(this.mode,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.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._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 dt();st(r,e,i),await i.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw dt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw dt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw dt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw dt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw dt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw dt();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:u}=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,h=t.clone();h.z=o/K(t.spatialReference),h.imageID=i,this.pointSources.push(h),l!==_e&&(r.push(c),u&&a.push(u))}}),{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?.[Fe[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(!y(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(v(e),this.drawAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.drawAdapter.viewModel.isResolved())return}return this.drawAdapter}loadImageError(e){h.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:i}=await t;v(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(v(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);v(i),await this._updateElevationOfSelectedPointAndLocations(a,t,n),v(i),He(a,n);let l=a;if(this.layer?.verticalSearchRange&&this.layer.hasZ&&this.verticalFilterEnabled&&(l=ze(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 v(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=Pe(o),this.sketch.polylineSymbol="panoramic"===s?Ce:Ae(o,2.5))}async startHeightMeasurement(){this.displayNewMeasurementButton=!1,this.draw??=new ue({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,currentBestFeature:r,overlayedCameraLocations:a,layer:s,mode:o,state:n,layerFloorFilterClause:l,layerTimeExtent:c}=this,u=i?.imageSize;if(!u||!r||!s||"default"!==o&&"panoramic"!==o||n.includes("loading"))return;const{polygon:h}=q(r.attributes);if(i.removeManyGraphics(a.toArray()),a.removeAll(),e){const{features:e}=await s.queryFeatures({where:V(`${s.objectIdField} <> ${r.attributes.objectId}`,V(s.definitionExpression,l)),geometry:h,returnGeometry:!0,outFields:[s.objectIdField],timeExtent:c}),n=await Promise.all(e.map(async e=>{const{attributes:i,geometry:r}=e,a=await this._transformationService.pointToImageGeometry(r),s="panoramic"===o?ke():Te();return new t({attributes:i,symbol:s,geometry:a})}));a.addMany(n),i.addManyGraphics(a.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,i=!1){const{activeViewer:r,currentBestFeature:a,mode:o,state:n,layer:l}=this,c=r?.imageSize;if(!c||!a||"none"===o||"video"===o||"panoramic-video"===o||n.includes("loading")||!l)return;const{polygon:u}=q(a.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=ot(e,l.imageGeometryField,l.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(m){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",m)}const{features:d}=await e.queryFeatures({geometry:u,returnGeometry:!0,outFields:["*"]}),p=new s(await Promise.all(d.map(async s=>{const n=s.symbol?.clone()??e.renderer?.getSymbol(s)?.clone(),{attributes:l,geometry:u}=s,{imageGeometryField:d,oiObjectIdField:p}=this;if(d&&p&&ht(e,d,p)&&`${l[p]}`==`${a.attributes.objectId}`)try{const t=Be(r?.media);return nt(l,d,e,i,c,o,n,t)}catch(m){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:m,feature:s,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}const g=await this._transformationService.geometryToImageGeometry(u);return new t({attributes:l,layer:e,symbol:n,geometry:g,visible:e.visible&&i})})));this.overlayGraphicsOnImage(`${e.id}`,p)}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 h.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!s?.loaded)return h.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 Fe.filter(e=>this._sectorData?.[e]?.length)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new E({...e.toJSON()}),symbol:Le}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){const{state:i,mode:r,activeViewer:a}=this;if("image-loaded"!==i||!a?.imageSize||"default"!==r&&"panoramic"!==r)return;this.clearReferencePointOnImage();const s=Be(a.media),o=lt(e,r,a.imageSize,s);this._referencePointOnImage=new t({geometry:o,symbol:"panoramic"===r?Ee.clone():Le.clone()}),a.addGraphic(this._referencePointOnImage,0)}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach(e=>{this._imageViewer.removeManyGraphics(e.toArray())}),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}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,u=c?.default[n],h=l?u?.(r):r;return h&&(i.geometry=await this._transformationService.imageGeometryToMapGeometry(h,t),i.geometry)?(o||ct(i.geometry),i):void 0})),u=c.filter(r);return s.applyEdits({addFeatures:u}).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){y(i)||(this.setMessage("imageLoadError","error",i.message),h.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 u=await this.loadSketch(t),h=await this.loadDataCaptureAdapter(t);v(t),u.addGraphics(l),h.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{selectedLocation:t,options:i}=e;let r=!1,a=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await j(t,s.spatialReference);r=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await j(t,s.spatialReference);a=s.extent.contains(e);break}}if(!r&&!a)return void this.clearReferencePointOnImage();const o=await this._transformationService.pointToPixel(t,i);if(o)return v(i),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}async updateFeatureCache(e,t){const i=await N(e,t);i.features?.length&&(this.featureCache=i.features)}async _fetchFeatures(e,t){const{layer:i,layerFloorFilterClause:r,layerTimeExtent:a,view:s}=this;if(!s||!i)return;e.x=B(e.x,e.spatialReference);const o=i.spatialReference.equals(e.spatialReference)?e:await j(e,i.spatialReference),n=o.spatialReference.isGeographic?R(o):o,l=V("1=1",V(i.definitionExpression,r)),c=n.spatialReference.isGeographic?1:P(n.spatialReference),u={layerInstanceOrURL:i,point:n,queryParams:{where:l,maximumDistance:i.maximumDistance?i.maximumDistance/c:void 0,timeExtent:a}};return await this.searchBestImage(u,t)}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(y(i))return;this.setMessage("imageLoadError","error"),h.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,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 u of Fe)this._sectorData[u]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const l=n.map(({distance:e})=>e),c=Math.max(...l);n.forEach(e=>{const{distance:t,angle:r,featureIndex:s}=e,n=t/c*be[2],l=$e(t,c),u=Ze(r);if(!this._sectorData)return;const h=be[3]+n*Math.sin(r*Math.PI/180),d=be[3]+n*Math.cos(r*Math.PI/180);let p;const m=i.at(s),g=m===a,{cameraPitch:y}=m.attributes,v=y<5;if(g&&v)p=-90;else{const e=h-be[3],t=d-be[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?u:`${l}_${u}`;g&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=v?null:{x:h,y:d,direction:u}),o[`${m.attributes.objectId}`]=f;const w=this._sectorData[f];w.add({angle:r,featureIndex:s,x:h,y:d,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;v(e),this._locationViewModel=new i({oiViewModel:this,referenceTransformationService:this._referenceTransformationService})}}_initializeMeasurementService(){this._measurementService||(this._measurementService=new rt({transformationService:this._transformationService,referenceTransformationService:this._referenceTransformationService}))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(Oe.videoPlayerHandles),this.videoElement=new le({video:this.currentBestFeature.attributes.imagePath,georeference:new oe({extent:new L(fe)}),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 et({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=Ne(r);try{await a.load(t)}catch(o){if(y(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=Ue(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){y(a)||h.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:qe(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 it(e,t,i,r,a);if(v(a),!s?.features?.length)throw new tt(t);const o=q(s.features[0].attributes).polygon,n=E.fromJSON(O(o)),l=Q(n),c=P(l.spatialReference);this.selectedPoint=l;const u={layerInstanceOrURL:e,point:l,queryParams:{where:V(V("1=1",V(e.definitionExpression,i)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0,timeExtent:r}},h=await z(u,a);v(a);const{features:d}=h;return d.push(s.features[0]),await this.processFeatureResponse(h,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);v(r);const[n,...l]=await X([t,...e.map(e=>e.attributes.geometry.clone())],o);v(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 Ye({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]),"video"===this.mode&&(this._initializeVideo(),this.videoElement?.loaded&&this.videoViewModel?.playVideoFromSelectedLocation(e[0])),"panoramic-video"===this.mode&&this._loadVideo()}_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)=>+x([e,t])),t.addRing(i),this.footprintExtent=he(t.extent,2,2)}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)),v(e);for(const o of i){const i=this.view&&!this.view.spatialReference?.equals(o.spatialReference)?await j(o.clone(),this.view?.spatialReference,e):o.clone();o.imageID===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:o.imageID},geometry:i,symbol:je,visible:a}):this.additionalCameraLocations.push(new t({attributes:{imageID:o.imageID},geometry:i,symbol:Ge,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-be[3],r=e.y-be[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._referencePointOnImage=p(this._referencePointOnImage))}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:u}=s;let h=s.location;h.spatialReference.isGeographic&&(h=Q(h));const d="default"===r?ae(s,a[0],a[1]):se(s,a[0],a[1]),p=await re(n,l??0,c,{elevationSample:o,elevationSource:u,extent:this.footprintExtent},e),m=(await import("./services/TransformationService.js")).default,g={imageToWorldProperties:d,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?Me:i?.imageSize;if(!t||!a||"none"===r)return;const{attributes:s,elevationSample:o}=t,{location:{spatialReference:n,z:l},cameraHeight:c,elevationSource:u}=s;let h=s.location;h.spatialReference.isGeographic&&(h=Q(h));const d="default"===r||"video"===r?"default":"panoramic",p={..."default"===d?ae(s,a[0],a[1]):se(s,a[0],a[1]),cameraLocation:h},m=await re(n,l??0,c,{elevationSample:o,elevationSource:u,extent:this.footprintExtent},e),g=(await import("./services/TransformationService.js")).default,y={imageToWorldProperties:p,updateElevationProps:m,mode:d,imageSize:a,depthImageService:this.depthImage};this._transformationService=new g(y),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}),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||h.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:r,feature:t})}}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:r,currentBestFeature:a,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:u}=this;if(!a)return;const{attributes:{objectId:h},elevationSample:d}=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(We);"3d"===l?.type&&d&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e),"panoramic"===u&&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:h}}))),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&&d&&c?.updateGroundElevation&&"panoramic"===u&&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{currentBestFeature:e,defaultSuperimposeCameraLockEnabled:t,layer:i,mode:r,view:a,state:s,superimposeViewEnabled:o,superimposeViewSupported:n,activeViewer:l,depthImage:c}=this;this._superimposeService.update({activeImageSize:l?.imageSize||void 0,adapter:this._adapter,currentBestFeature:e,defaultSuperimposeCameraLockEnabled:t,depthImageLoaded:c?.loaded??!1,layer:i,mode:r,state:s,superimposeViewEnabled:o&&n,view:a}),this.setMessage("superimposeImageDescription","info"),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()?!t||t.interacting||t.navigating?this._abortSuperimposeSchedule():this._scheduleDefaultSuperimposeUpdate():this._abortSuperimposeSchedule()}_shouldDisableUnsupportedSuperimposeView(){return this.superimposeViewEnabled&&"panoramic"===this.mode&&!this.superimposeViewSupported}_hasActiveSuperimposeCameraContext(){return"default"===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(){this._abortSuperimposeSchedule(),this._adapter?.disableDefaultSuperimposeNavigation?.(),this._superimposeService.clear(),this._restoreDefaultMessageAfterSuperimpose()}_restoreDefaultMessageAfterSuperimpose(){"superimposeImageDescription"===this.displayMessage?.key&&this.setMessage("onLoadMessage","info")}_clearSuperimposeDebounceTimeout(){null!=this.superimposeDebounceTimeoutId&&(clearTimeout(this.superimposeDebounceTimeoutId),this.superimposeDebounceTimeoutId=null)}_clearSuperimposeScheduledFrame(){null!=this.superimposeScheduledFrameId&&(cancelAnimationFrame(this.superimposeScheduledFrameId),this.superimposeScheduledFrameId=null)}_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()],pt.prototype,"activeLayer",null),e([C({readOnly:!0})],pt.prototype,"activeViewer",null),e([C()],pt.prototype,"activeTriangulatedViewer",null),e([C()],pt.prototype,"accuracyParametersMissing",null),e([C()],pt.prototype,"additionalFeatures",void 0),e([C({type:s.ofType(t)})],pt.prototype,"additionalCameraLocations",void 0),e([C({type:s.ofType(t)})],pt.prototype,"additionalFootprints",void 0),e([C()],pt.prototype,"areaMeasurementResult",void 0),e([C()],pt.prototype,"areaMeasurementAccuracy",void 0),e([C()],pt.prototype,"bestFeatureAngle",void 0),e([C()],pt.prototype,"bestFeatureCurrentFootprint",void 0),e([C({type:t})],pt.prototype,"bestFeatureFootprint",void 0),e([C({type:Number})],pt.prototype,"brightness",null),e([C()],pt.prototype,"cameraHeadingThreshold",void 0),e([C()],pt.prototype,"cameraPitchThreshold",void 0),e([C()],pt.prototype,"clickAction",void 0),e([C()],pt.prototype,"correctedLocationPointOnImage",void 0),e([C()],pt.prototype,"videoViewModel",void 0),e([C()],pt.prototype,"collectionId",void 0),e([C({type:Number})],pt.prototype,"contrast",null),e([C()],pt.prototype,"coverageFrustums",void 0),e([C()],pt.prototype,"coveragePolygons",void 0),e([C()],pt.prototype,"currentBestFeature",void 0),e([C()],pt.prototype,"currentBestFeatureMeasurementImage",void 0),e([C()],pt.prototype,"currentBestFeatureLocation",void 0),e([C()],pt.prototype,"currentCoverageVisible",void 0),e([C()],pt.prototype,"currentNode",null),e([C()],pt.prototype,"depthImage",void 0),e([C()],pt.prototype,"depthImageNotSupported",null),e([C()],pt.prototype,"featureCache",void 0),e([C()],pt.prototype,"navigationNodes",void 0),e([C({json:{write:!1}})],pt.prototype,"determineWorkflowForFeature",void 0),e([C({json:{write:!1}})],pt.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([C()],pt.prototype,"disabled",void 0),e([C()],pt.prototype,"displayMessage",void 0),e([C()],pt.prototype,"displayNewMeasurementButton",void 0),e([C()],pt.prototype,"distanceMeasurementResult",void 0),e([C()],pt.prototype,"distanceAccuracyArray",void 0),e([C()],pt.prototype,"dataCaptureLayer",void 0),e([C({readOnly:!0})],pt.prototype,"featureCount",null),e([C()],pt.prototype,"features",void 0),e([C()],pt.prototype,"groundCoordinates",void 0),e([C()],pt.prototype,"groundCoordinatesAccuracy",void 0),e([C()],pt.prototype,"heightGraphic",void 0),e([C()],pt.prototype,"heightMeasurementResult",void 0),e([C()],pt.prototype,"heightMeasurementAccuracy",void 0),e([C({readOnly:!0})],pt.prototype,"imageGalleryEnabled",null),e([C()],pt.prototype,"imageGeometryField",void 0),e([C({readOnly:!0})],pt.prototype,"imageLoaded",null),e([C()],pt.prototype,"imageLocationToolState",void 0),e([C()],pt.prototype,"initialVideoMapViewExtent",void 0),e([C({readOnly:!0})],pt.prototype,"invalidCameraHeading",null),e([C()],pt.prototype,"imagePointsInView",null),e([C()],pt.prototype,"imageMeasurementViewer",void 0),e([C()],pt.prototype,"isAdditionalCoverageVisible",void 0),e([C()],pt.prototype,"isAdditionalPointSourcesVisible",void 0),e([C()],pt.prototype,"layer",void 0),e([C()],pt.prototype,"layerView",null),e([C({readOnly:!0})],pt.prototype,"layerFloorFilterClause",null),e([C({readOnly:!0})],pt.prototype,"layerTimeExtent",null),e([C({type:Number})],pt.prototype,"localPort",void 0),e([C()],pt.prototype,"locationPointOnImage",void 0),e([C()],pt.prototype,"mapImageConversionToolState",void 0),e([C()],pt.prototype,"measureType",void 0),e([C()],pt.prototype,"measurementGraphic",void 0),e([C({readOnly:!0,value:"none"})],pt.prototype,"mode",null),e([C()],pt.prototype,"navigationMode",void 0),e([C()],pt.prototype,"navigatorCurrentBestFeature",void 0),e([C()],pt.prototype,"oiObjectIdField",void 0),e([C({type:s.ofType(t)})],pt.prototype,"overlayedCameraLocations",void 0),e([C()],pt.prototype,"overlayedMapFeatures",void 0),e([C()],pt.prototype,"panoramicVideoLoaded",null),e([C()],pt.prototype,"pixelCoordinates",void 0),e([C()],pt.prototype,"preserveAngle",void 0),e([C()],pt.prototype,"pointSources",void 0),e([C({readOnly:!0})],pt.prototype,"popupEnabled",null),e([C()],pt.prototype,"preloadMedia",void 0),e([C()],pt.prototype,"preloadMediaSize",void 0),e([C()],pt.prototype,"previousFeatureAngle",void 0),e([C()],pt.prototype,"referencePoint",null),e([C({readOnly:!0})],pt.prototype,"sectorData",null),e([C()],pt.prototype,"selectedPoint",void 0),e([C({type:Number})],pt.prototype,"sharpness",null),e([C()],pt.prototype,"shouldShowSelectedImage",void 0),e([C()],pt.prototype,"superimposeViewEnabled",void 0),e([C()],pt.prototype,"defaultSuperimposeCameraLockEnabled",void 0),e([C()],pt.prototype,"superimposeViewSupported",null),e([C()],pt.prototype,"sketch",void 0),e([C()],pt.prototype,"sketchTriangular",void 0),e([C()],pt.prototype,"sketchTriangularGraphicsLayer",void 0),e([C()],pt.prototype,"draw",void 0),e([C()],pt.prototype,"drawAdapter",void 0),e([C()],pt.prototype,"polylineDrawAction",void 0),e([C()],pt.prototype,"scheduledFrameId",void 0),e([C()],pt.prototype,"superimposeScheduledFrameId",void 0),e([C()],pt.prototype,"superimposeDebounceTimeoutId",void 0),e([C()],pt.prototype,"sketchAdapter",void 0),e([C({readOnly:!0})],pt.prototype,"sketchGraphicsLayer",null),e([C({readOnly:!0})],pt.prototype,"state",null),e([C({readOnly:!0})],pt.prototype,"thumbnails",null),e([C()],pt.prototype,"videoExtentPoints",null),e([C()],pt.prototype,"triangularMeasurementActive",void 0),e([C()],pt.prototype,"triangulatedDistanceMeasurement",void 0),e([C()],pt.prototype,"triangulatedDistanceAccuracy",void 0),e([C()],pt.prototype,"triangulatedAreaMeasurement",void 0),e([C()],pt.prototype,"triangulatedAreaAccuracy",void 0),e([C()],pt.prototype,"triangulatedMeasurementGraphic",void 0),e([C()],pt.prototype,"triangulatedPoint",void 0),e([C()],pt.prototype,"triangulatedMeasurementAdapter",void 0),e([C()],pt.prototype,"updateFootprint",void 0),e([C()],pt.prototype,"updateVideoFootprint",void 0),e([C()],pt.prototype,"updateFootprintPanorama",void 0),e([C()],pt.prototype,"updatingTriangularMeasurementState",void 0),e([C({value:null})],pt.prototype,"view",null),e([C()],pt.prototype,"videoElement",void 0),e([C()],pt.prototype,"videoLayer",void 0),e([C()],pt.prototype,"videoMapView",void 0),e([C()],pt.prototype,"verticalFilterEnabled",void 0),e([C()],pt.prototype,"_adapter",void 0),e([C()],pt.prototype,"_defaultGraphicsLayer",null),e([C()],pt.prototype,"_highlightedFeatureHandle",void 0),e([C()],pt.prototype,"_imageViewer",void 0),e([C()],pt.prototype,"_initialCurrentCoverageUpdate",void 0),e([C()],pt.prototype,"_locationViewModel",void 0),e([C()],pt.prototype,"_measurementService",void 0),e([C()],pt.prototype,"_mediaPrefetcher",void 0),e([C()],pt.prototype,"_navigationManager",void 0),e([C()],pt.prototype,"_overlays",void 0),e([C()],pt.prototype,"_superimposeService",void 0),e([C({readOnly:!0})],pt.prototype,"_overlaysView",null),e([C()],pt.prototype,"_panoramicVideoViewer",void 0),e([C()],pt.prototype,"_panoramicViewer",void 0),e([C()],pt.prototype,"_panoramicMeasurementViewer",void 0),e([C()],pt.prototype,"_referencePointOnGround",void 0),e([C()],pt.prototype,"_referencePointOnImage",void 0),e([C()],pt.prototype,"_referenceTransformationService",void 0),e([C()],pt.prototype,"_sectorData",void 0),e([C()],pt.prototype,"_transformationService",void 0),e([C()],pt.prototype,"_featureToSector",void 0),e([C({readOnly:!0})],pt.prototype,"_updatingHandles",void 0),e([C()],pt.prototype,"footprintExtent",void 0),e([C()],pt.prototype,"_featureChangedTask",void 0),pt=e([A("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],pt);const mt=pt;export{mt as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- const e="esri-oriented-imagery-viewer",t=`${e}__carousel`,a=`${e}__image-enhancement`,o=`${e}__navigation`,r="--oi-navigation-tool-rotation-from",n="--oi-navigation-tool-rotation-to",i=`${o}-ui`,s=`${i}__direction`,$=`${e}__image-overlays`,m={alert:`${e}__alert`,addCoverage:`${e}__body-additional-coverage`,addExpPoints:`${e}__body-additional-camera-locations`,body:`${e}__body`,carousel:`${e}__carousel`,carouselContainer:`${t}-container`,carouselContent:`${t}-content`,carouselItem:`${t}-item`,carouselItemWrapper:`${t}-item-wrapper`,close:`${e}__close`,currentCoverage:`${e}__body-current-coverage`,feature:`${o}-feature`,footprint:`${e}__body-footprint`,imageEnhancementToolContainer:`${a}-tool-container`,imageEnhancementTools:`${a}-tools`,imageEnhancementWrapper:`${a}-wrapper`,imageOverlays:$,imageOverlaysContainer:`${$}-container`,imageOverlaysNoResult:`${$}-no-result`,imageOverlaysIncreasedHeight:`${$}-increased-height`,imageOverlaysLayerList:`${$}-layer-list`,measurementResults:`${e}__measurement-results`,measurementsBar:`${e}__measurements-bar`,measurementsButton:`${e}__measurements-button`,measurementsTable:`${e}__measurements-table`,measurementDisplay:`${e}__measurement-display`,messageBox:`${e}__message-box`,navigationPathOffset0:`${o}-feature-path-stop-offset-0`,navigationPathOffset1:`${o}-feature-path-stop-offset-1`,navigationWrapper:`${o}-wrapper`,navigationZoomed:`${o}-wrapper--zoomed`,north:`${o}-pointer-north`,outerSector:`${o}-sector-outer`,overlaysSwitch:`${$}-switch`,pointer:`${o}-pointer`,rotateWithAnimation:`${o}-animate`,sector:`${o}-sector`,sectorCross:`${o}-sector-cross`,sectorDisabled:`${o}-sector-disabled`,sectorEnabled:`${o}-sector-enabled`,sectorSeparator:`${o}-sector-separator`,selectedFeaturePath:`${o}-feature-path`,sketchTools:`${e}__sketch-tools`,submenu:`${e}__submenu`,viewer:`${e}__viewer`,viewerHidden:`${e}__viewer--hidden`,viewerContainer:`${e}__viewer-container`,viewerContainerMeasurement:`${e}__viewer-container-measurement`,navigationUI:i,navigationDirection:s,navigationDirectionPad:`${s}-pad`,navigationSettingsUI:`${o}-settings-ui`};export{t as carousel,m as css,a as imageEnhancement,o as navigation,r as navigationToolRotationFrom,n as navigationToolRotationTo,e as root};
2
+ const e="esri-oriented-imagery-viewer",t=`${e}__carousel`,a=`${e}__image-enhancement`,o=`${e}__navigation`,r="--oi-navigation-tool-rotation-from",n="--oi-navigation-tool-rotation-to",i=`${o}-ui`,s=`${i}__direction`,$=`${e}__image-overlays`,m={alert:`${e}__alert`,addCoverage:`${e}__body-additional-coverage`,addExpPoints:`${e}__body-additional-camera-locations`,body:`${e}__body`,carousel:`${e}__carousel`,carouselContainer:`${t}-container`,carouselContent:`${t}-content`,carouselItem:`${t}-item`,carouselItemWrapper:`${t}-item-wrapper`,close:`${e}__close`,currentCoverage:`${e}__body-current-coverage`,feature:`${o}-feature`,footprint:`${e}__body-footprint`,imageEnhancementToolContainer:`${a}-tool-container`,imageEnhancementTools:`${a}-tools`,imageEnhancementWrapper:`${a}-wrapper`,imageOverlays:$,imageOverlaysContainer:`${$}-container`,imageOverlaysNoResult:`${$}-no-result`,imageOverlaysIncreasedHeight:`${$}-increased-height`,imageOverlaysLayerList:`${$}-layer-list`,measurementResults:`${e}__measurement-results`,measurementsBar:`${e}__measurements-bar`,measurementsButton:`${e}__measurements-button`,measurementsTable:`${e}__measurements-table`,measurementDisplay:`${e}__measurement-display`,messageBox:`${e}__message-box`,navigationPathOffset0:`${o}-feature-path-stop-offset-0`,navigationPathOffset1:`${o}-feature-path-stop-offset-1`,navigationWrapper:`${o}-wrapper`,navigationZoomed:`${o}-wrapper--zoomed`,north:`${o}-pointer-north`,outerSector:`${o}-sector-outer`,overlaysSwitch:`${$}-switch`,pointer:`${o}-pointer`,rotateWithAnimation:`${o}-animate`,sector:`${o}-sector`,sectorCross:`${o}-sector-cross`,sectorDisabled:`${o}-sector-disabled`,sectorEnabled:`${o}-sector-enabled`,sectorSeparator:`${o}-sector-separator`,selectedFeaturePath:`${o}-feature-path`,sketchTools:`${e}__sketch-tools`,superimposeTools:`${e}__superimpose-tools`,submenu:`${e}__submenu`,viewer:`${e}__viewer`,viewerHidden:`${e}__viewer--hidden`,viewerContainer:`${e}__viewer-container`,viewerContainerMeasurement:`${e}__viewer-container-measurement`,navigationUI:i,navigationDirection:s,navigationDirectionPad:`${s}-pad`,navigationSettingsUI:`${o}-settings-ui`};export{t as carousel,m as css,a as imageEnhancement,o as navigation,r as navigationToolRotationFrom,n as navigationToolRotationTo,e as root};