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

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 (202) hide show
  1. package/analysis/ElevationProfile/ElevationProfileLineInput.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/234b52b2a391631ceff6.js +1 -0
  4. package/assets/esri/core/workers/chunks/{8f3503b2fb6cd38757b9.js → 458e87902abc24b375da.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{57b410198d83bf0ab708.js → 4a89e120be142ab58a27.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{a410dcf80d17a2383337.js → 65a4099bdbe31834d0cc.js} +1 -1
  7. package/assets/esri/core/workers/chunks/71d9e9b0a7f8c0edd32d.js +1 -0
  8. package/assets/esri/core/workers/chunks/722da7a39a0ad9300752.js +1 -0
  9. package/assets/esri/core/workers/chunks/{cdb4664fd59860ddeb5a.js → 888f188541f8bd68e33e.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{319c3f46f2afb8f3e5a9.js → 89c9cf7f799858d14c76.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{e19cd07df8ce87e18832.js → 8b33732e3c2924c1f60d.js} +1 -1
  12. package/assets/esri/core/workers/chunks/98739414c107ad78e4d8.js +1 -0
  13. package/assets/esri/core/workers/chunks/{bc318b6fef192cee2a72.js → a4518f25b9f8fe704286.js} +17 -17
  14. package/assets/esri/core/workers/chunks/{8b73db0f4d6714396eb0.js → a6fa90eab77ac0e1cdfc.js} +1 -1
  15. package/assets/esri/core/workers/chunks/ac366221e8636b60aee5.js +1 -0
  16. package/assets/esri/core/workers/chunks/{23e17b745adf71a5efc7.js → aca72ca7f43f70eb8077.js} +1 -1
  17. package/assets/esri/core/workers/chunks/ad0c7225941437d18408.js +1 -0
  18. package/assets/esri/core/workers/chunks/b30897952494a3e5b9fe.js +1 -0
  19. package/assets/esri/core/workers/chunks/bfd3d81e8e148be99686.js +1 -0
  20. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  21. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  22. package/assets/esri/themes/base/widgets/_Editor.scss +2 -1
  23. package/assets/esri/themes/base/widgets/_FeatureForm.scss +1 -1
  24. package/assets/esri/themes/dark/main.css +1 -1
  25. package/assets/esri/themes/light/main.css +1 -1
  26. package/assets/esri/themes/light/view.css +1 -1
  27. package/chunks/GaussianSplat.glsl.js +2 -2
  28. package/chunks/lyr3DMain.js +1 -1
  29. package/config.js +1 -1
  30. package/core/accessorSupport/ensureType.js +1 -1
  31. package/core/accessorSupport/extensions/serializableProperty/reader.js +1 -1
  32. package/graphic/graphicOriginUtils.js +1 -1
  33. package/interfaces.d.ts +68 -28
  34. package/kernel.js +1 -1
  35. package/layers/BingMapsLayer.js +1 -1
  36. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  37. package/layers/support/attributionUtils.js +5 -0
  38. package/layers/support/fieldConfigUtils.js +1 -1
  39. package/layers/support/fieldFormatUtils.js +1 -1
  40. package/layers/video/VideoController.js +1 -1
  41. package/libs/parquet/parquet.js +1 -1
  42. package/package.json +1 -1
  43. package/support/revision.js +1 -1
  44. package/symbols/cim/SDFHelper.js +1 -1
  45. package/symbols/cim/cimAnalyzer.js +1 -1
  46. package/views/2d/analysis/ElevationProfile/ElevationProfileLineVisualization2D.js +1 -1
  47. package/views/2d/engine/flow/dataUtils.js +1 -1
  48. package/views/2d/engine/webgl/TextureManager.js +1 -1
  49. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AAnimatedPolyShader.js +1 -1
  50. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedFillShader.js +1 -1
  51. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedLineShader.js +1 -1
  52. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedPolyMeshWriters.js +1 -1
  53. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedTechnique.js +1 -1
  54. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
  55. package/views/2d/layers/features/Processor.js +1 -1
  56. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  57. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  58. package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
  59. package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
  60. package/views/3d/analysis/ElevationProfile/ElevationProfileGeometryVisualization3D.js +1 -1
  61. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillComputation.js +1 -1
  62. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementTool.js +1 -1
  63. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  64. package/views/3d/environment/CloudsCompositionTechnique.js +1 -1
  65. package/views/3d/environment/CloudsTechnique.js +1 -1
  66. package/views/3d/environment/FogTechnique.js +1 -1
  67. package/views/3d/environment/NoiseTextureAtlasTechnique.js +1 -1
  68. package/views/3d/environment/PrecipitationTechnique.js +1 -1
  69. package/views/3d/environment/SimpleAtmosphereTechnique.js +1 -1
  70. package/views/3d/layers/FlowSubView3D.js +1 -1
  71. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  72. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  73. package/views/3d/layers/TiledLayerView3D.js +1 -1
  74. package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
  75. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  76. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  77. package/views/3d/support/DisplayQualityProfile.js +1 -1
  78. package/views/3d/support/QualitySettings.js +1 -1
  79. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  80. package/views/3d/support/flow/FlowWorker.js +1 -1
  81. package/views/3d/support/flow/FlowWorkerHandle.js +1 -1
  82. package/views/3d/support/flow/StreamlineResources3D.js +1 -1
  83. package/views/3d/support/flow/StreamlineResources3DOverlay.js +1 -1
  84. package/views/3d/support/flow/StreamlineResources3DShape.js +1 -1
  85. package/views/3d/support/flow/constants.js +1 -1
  86. package/views/3d/support/flow/loadUtils.js +1 -1
  87. package/views/3d/support/popupHitTest.js +1 -1
  88. package/views/3d/terrain/BlendLayersTechnique.js +1 -1
  89. package/views/3d/terrain/RasterColorizerTechnique.js +1 -1
  90. package/views/3d/terrain/TerrainSurface.js +1 -1
  91. package/views/3d/terrain/TileAgent.js +1 -1
  92. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  93. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  94. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  95. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  96. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentData.glsl.js +14 -32
  97. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBuffer.glsl.js +17 -0
  98. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBufferFields.glsl.js +10 -0
  99. package/views/3d/webgl-engine/core/shaderTechnique/{ReloadableShaderModule.js → ReloadableShader.js} +1 -1
  100. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechnique.js +1 -1
  101. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorTechnique.js +1 -1
  102. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskTechnique.js +1 -1
  103. package/views/3d/webgl-engine/effects/glow/GlowBlurTechnique.js +1 -1
  104. package/views/3d/webgl-engine/effects/glow/GlowCompositionTechnique.js +1 -1
  105. package/views/3d/webgl-engine/effects/haze/HazeCompositingTechnique.js +1 -1
  106. package/views/3d/webgl-engine/effects/haze/HazeTechnique.js +1 -1
  107. package/views/3d/webgl-engine/effects/highlight/HighlightApplyTechnique.js +1 -1
  108. package/views/3d/webgl-engine/effects/highlight/HighlightBlurTechnique.js +1 -1
  109. package/views/3d/webgl-engine/effects/highlight/HighlightDownsampleTechnique.js +1 -1
  110. package/views/3d/webgl-engine/effects/highlight/HighlightToSingleTechnique.js +1 -1
  111. package/views/3d/webgl-engine/effects/highlight/ShadowHighlightTechnique.js +1 -1
  112. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathTechnique.js +1 -1
  113. package/views/3d/webgl-engine/effects/laserlines/LaserlineTechnique.js +1 -1
  114. package/views/3d/webgl-engine/effects/magnifier/MagnifierTechnique.js +1 -1
  115. package/views/3d/webgl-engine/effects/smaa/SMAABlendWeightsTechnique.js +1 -1
  116. package/views/3d/webgl-engine/effects/smaa/SMAABlurTechnique.js +1 -1
  117. package/views/3d/webgl-engine/effects/smaa/SMAAEdgeDetectTechnique.js +1 -1
  118. package/views/3d/webgl-engine/effects/ssao/SSAOBlurTechnique.js +1 -1
  119. package/views/3d/webgl-engine/effects/ssao/SSAOTechnique.js +1 -1
  120. package/views/3d/webgl-engine/effects/stars/StarsTechnique.js +1 -1
  121. package/views/3d/webgl-engine/effects/transparency/OITBlendTechnique.js +1 -1
  122. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  123. package/views/3d/webgl-engine/lib/Program.js +1 -1
  124. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  125. package/views/3d/webgl-engine/lib/TextureBackedBuffer/BufferManager.js +1 -1
  126. package/views/3d/webgl-engine/lib/TextureBackedBuffer/ManagedTextureBackedBuffer.js +1 -1
  127. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBuffer.js +1 -1
  128. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferFields.js +5 -0
  129. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js +5 -0
  130. package/views/3d/webgl-engine/lib/TextureTechnique.js +1 -1
  131. package/views/3d/webgl-engine/lib/edgeRendering/EdgeShaderTechnique.js +1 -1
  132. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  133. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  134. package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +1 -1
  135. package/views/3d/webgl-engine/shaders/CheckerBoardTechnique.js +1 -1
  136. package/views/3d/webgl-engine/shaders/ColorMaterialTechnique.js +1 -1
  137. package/views/3d/webgl-engine/shaders/CompositingTechnique.js +1 -1
  138. package/views/3d/webgl-engine/shaders/CutFillCompositionTechnique.js +1 -1
  139. package/views/3d/webgl-engine/shaders/CutFillDepthTechnique.js +1 -1
  140. package/views/3d/webgl-engine/shaders/CutFillMaskTechnique.js +1 -1
  141. package/views/3d/webgl-engine/shaders/CutFillReductionTechnique.js +1 -1
  142. package/views/3d/webgl-engine/shaders/CutFillTargetDepthTechnique.js +1 -1
  143. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  144. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  145. package/views/3d/webgl-engine/shaders/GaussianSplatCompositionTechnique.js +1 -1
  146. package/views/3d/webgl-engine/shaders/GaussianSplatDepthCompositionTechnique.js +1 -1
  147. package/views/3d/webgl-engine/shaders/GaussianSplatDepthTechnique.js +1 -1
  148. package/views/3d/webgl-engine/shaders/GaussianSplatTechnique.js +1 -1
  149. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  150. package/views/3d/webgl-engine/shaders/HUDCompositingTechnique.js +1 -1
  151. package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
  152. package/views/3d/webgl-engine/shaders/HeatmapDensityTechnique.js +1 -1
  153. package/views/3d/webgl-engine/shaders/HeatmapTechnique.js +1 -1
  154. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  155. package/views/3d/webgl-engine/shaders/LineCalloutTechnique.js +1 -1
  156. package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
  157. package/views/3d/webgl-engine/shaders/MeasurementArrowTechnique.js +1 -1
  158. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
  159. package/views/3d/webgl-engine/shaders/OverlayCompositingTechnique.js +1 -1
  160. package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
  161. package/views/3d/webgl-engine/shaders/PointRendererTechnique.js +1 -1
  162. package/views/3d/webgl-engine/shaders/RealisticTreeTechnique.js +1 -1
  163. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  164. package/views/3d/webgl-engine/shaders/ShadedColorMaterialTechnique.js +1 -1
  165. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
  166. package/views/3d/webgl-engine/shaders/ShadowCastClearTechnique.js +1 -1
  167. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +1 -1
  168. package/views/3d/webgl-engine/shaders/SlicePlaneMaterialTechnique.js +1 -1
  169. package/views/3d/webgl-engine/shaders/TerrainTechnique.js +1 -1
  170. package/views/3d/webgl-engine/shaders/ViewshedTechnique.js +1 -1
  171. package/views/SceneView.js +1 -1
  172. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  173. package/views/analysis/ElevationProfile/types.d.ts +5 -0
  174. package/views/analysis/ElevationProfile/types.js +5 -0
  175. package/views/input/gamepad/GamepadInputDevice.js +1 -1
  176. package/views/input/gamepad/GamepadSource.js +1 -1
  177. package/views/navigation/gamepad/GamepadSettings.js +1 -1
  178. package/views/webgl/VertexAttributeLocations.js +1 -1
  179. package/widgets/Attribution/AttributionViewModel.js +1 -1
  180. package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
  181. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  182. package/widgets/Editor/UpdateWorkflow.js +1 -1
  183. package/widgets/Editor/Workflow.js +1 -1
  184. package/widgets/Editor/components/CreateFeaturesPanelContent.js +1 -1
  185. package/widgets/Editor/components/PendingFeatureList.js +1 -1
  186. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  187. package/widgets/Editor.js +1 -1
  188. package/widgets/Feature/support/featureUtils.js +1 -1
  189. package/widgets/FeatureTable/FieldColumn.js +1 -1
  190. package/widgets/FeatureTable/Grid/Column.js +1 -1
  191. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  192. package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
  193. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  194. package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
  195. package/assets/esri/core/workers/chunks/097e5deb51ee7e25e654.js +0 -1
  196. package/assets/esri/core/workers/chunks/38ee69125da60464d5a1.js +0 -1
  197. package/assets/esri/core/workers/chunks/4f0016111fd84c612f41.js +0 -1
  198. package/assets/esri/core/workers/chunks/8208dfa8f7fae7e616b9.js +0 -1
  199. package/assets/esri/core/workers/chunks/847f4fc39100fac1df01.js +0 -1
  200. package/assets/esri/core/workers/chunks/ab005fe84952f0676020.js +0 -1
  201. package/assets/esri/core/workers/chunks/bc19a232076d98825eef.js +0 -1
  202. package/assets/esri/core/workers/chunks/c3dcfe26c2c3c829762d.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import"../../core/has.js";import t from"../../core/Logger.js";import{on as i,sync as n}from"../../core/reactiveUtils.js";import{renderingSanitizer as o}from"../../core/sanitizerUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveFieldAlias as a}from"../../editing/fieldUtils.js";import{convertDateFormatToIntlOptions as s,defaultFormatterOptionsNoTime as u,convertDateTimeFieldFormatToIntlOptions as p,defaultFormatterOptions as d}from"../../intl/date.js";import{formatNumber as m,convertNumberFormatToIntlOptions as c,convertNumberFieldFormatToIntlOptions as f}from"../../intl/number.js";import{isEditableLayer as h}from"../../layers/support/editableLayers.js";import{computeDomainFromTypes as y}from"../../layers/support/featureLayerUtils.js";import g from"../../layers/support/Field.js";import{defaultFieldFormat as v}from"../../layers/support/fieldFormatUtils.js";import{validateFieldValue as F,isDateField as _,isTimeOnlyField as C,isIntegerField as b,isNumericField as D,isStringField as I,isDateOnlyField as x,isTimestampOffsetField as O}from"../../layers/support/fieldUtils.js";import{isAnyDateField as T}from"../../smartMapping/support/utils.js";import{system as w}from"../../time/constants.js";import{getTimeZoneFormattingOptions as V}from"../../time/timeZoneUtils.js";import E from"../FeatureForm/FieldInput.js";import Z from"./Grid/EditorColumn.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as j,isEmptyStringOrWhitespace as L}from"./support/tableUtils.js";import{dateFieldsWithStringFieldValue as R,getLabelForDateFieldValue as S,valueIsInRange as N,dateTimeIsInRange as U,getUnixFieldValueFromDateComponents as A,getISOFieldValueFromDateComponents as q,normalizeTimeOnlyString as k,prepareISOFieldValueForDateComponents as z,prepareUnixFieldValueForDateComponents as B}from"../support/dateUtils.js";import{setFocus as H}from"../support/widgetUtils.js";const P={cancelEdit:"Escape"},M=Symbol(),W="esri-column",G={input:`${W}__cell-input`,inputContainer:`${W}__cell__input-container`};let $=class extends Z{constructor(e){super(e),this._activeFieldInput=null,this.cellValueFormatFunction=({root:e,rowData:t,value:i})=>{const{formatFunction:n}=this;if(n&&t){const{index:r,item:{attachments:l,feature:a,relatedRecords:s}}=t;return n({attachments:l,column:this,feature:a,field:this.field,index:r,relatedRecords:s,value:o.sanitize(i),virtualIndex:this.getVirtualRowIndex(e)})}if(null===i)return"&nbsp;";const{field:r}=this,l=this._getDomainForFeature(t?.item?.feature);if(l){const e=this._getComputedDomain(i,l);return"date"===r.type&&"range"===l.type?this._formatDateValueForDisplay(r,e):this._isNumericField&&"range"===l.type?m(parseFloat(i),this._numberFormatOptions):R.has(r.type)?"range"===l.type?o.sanitize(S(r,e)):o.sanitize(e):e}return"date"===r.type||R.has(r.type)?this._formatDateValueForDisplay(r,i):this._isNumericField?m(parseFloat(i),this._numberFormatOptions):o.sanitize(i)},this.cellValueValidatorFunction=({oldValue:e,value:i})=>{const{_effectiveRange:n,field:o}=this,{max:r,min:l}=n;if(this.effectiveRequired&&(null==i||""===i))return!1;if(this._isNumericField&&(F(o,i)||!N({max:r,min:l,value:i})))return t.getLogger(this).warn("value-exceeds-valid-range","Field value exceeds valid range. Attempted edit was rejected."),!1;if(this._isAnyDateOrTimeField){const e=o.type;if(!U({type:e,range:n,value:i}))return!1}return e!==i},this.field=null,this.formatFunction=null,this.inputRenderFunction=async({root:e,column:i,rowData:n})=>{if(this.editInfo||!this.effectiveEditable)return;const o=this.getCellValue(n),{field:r}=this;if("big-integer"===r.type&&F(r,o))return void t.getLogger(this).warn("value-exceeds-valid-range","Field value is beyond supported limit. Editing is disabled for this field value.");const l=n?.item.feature;if(!l)return;this._activeFieldInput=this._setUpFieldInput(l,o);const a=document.createElement("div");a.classList.add(G.inputContainer);const s=[],u="coded-value"===this._effectiveDomain?.type;if(this._isAnyDateOrTimeField&&!u){const e=document.createElement("div"),t=this._setUpDateComponents(o),i=this._setUpDateActionBar();t.forEach(t=>e.appendChild(t)),a.appendChild(e),a.appendChild(i),s.push(...t)}else{const e=this.createInputElement({value:o});a.appendChild(e),s.push(e)}this._set("editInfo",{column:i,inputs:s,root:e,rowData:n,oldValue:o}),this.removeCellContent(e),e.appendChild(a),this._syncRowEditingState(e,!0),this.grid?.generateCellPartNames();const p=s[0];await H(p),"selectText"in p&&await p.selectText()},this.layer=null,this.parseInputValueFunction=({inputs:e})=>{const{editInfo:t,field:i,includeTime:n}=this;if(!t||!e.length)return null;const o=e[0];if(this._isAnyDateOrTimeField){if("coded-value"===this._effectiveDomain?.type){if(null==o.value||""===o.value)return null;const e=String(o.value);return _(i)?parseFloat(e):e}const{timeZone:r}=this.effectiveTimeZoneOptions,l=t.oldValue??void 0;switch(i.type){case"date-only":{const e=o.value;return""!==e?e:null}case"time-only":{const e=k(o.value);return""!==e?e:null}case"timestamp-offset":{const t=n?e[1]:void 0,i=e.at(-1);return q({oldValue:l,dateComponent:o,timeComponent:t,timeZoneComponent:i,defaultTimeZone:r})}case"date":{const{max:t,min:i}=this._effectiveRange;return A({oldValue:l,dateComponent:o,timeComponent:e[1],timeZone:r,max:t,min:i})}}return null}const r=o.value,{effectiveRequired:l}=this;return l||null!=r&&""!==r?this._isNumericField?parseFloat(r):this._isStringField?r.trim():r:null},this.sortable=!0,this.store=null,this.template=null,this.view=null}get _effectiveDomain(){const e=this._activeFieldInput?.feature;return e?this._getDomainForFeature(e):null}get _effectiveRange(){return this._activeFieldInput?.range??{max:null,min:null}}get _isAnyDateOrTimeField(){const{field:e}=this;return T(e)||C(e)}get _isIntegerField(){return b(this.field)}get _isNumericField(){return D(this.field)}get _isStringField(){return I(this.field)}get _isSubtypeField(){const{layer:e}=this;if(e?.subtypeField){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1}get _layerWithFieldConfigurations(){const{layer:e}=this;return j(e)?e:null}get _dateTimeFormatOptions(){const{layerFieldConfigurationFormat:e,template:t}=this;return t?.format?.dateFormat?s(t.format.dateFormat):t?.input&&"includeTime"in t.input&&!1===t.input.includeTime?u:"date-time"===e?.type?p(e):this._isAnyDateOrTimeField?d:void 0}get _numberFormatOptions(){const{layerFieldConfigurationFormat:e,template:t}=this;return t?.format?c(t.format):"number"===e?.type?f(e):this._isNumericField?{useGrouping:!0,maximumFractionDigits:20}:void 0}get alias(){return a(this.field,this._layerWithFieldConfigurations)}get defaultValue(){return this.field?.defaultValue}get effectiveDescription(){const{description:e,field:t}=this,i=t.description,n=L(e)?L(i)?null:i:e;return null==n?null:o.sanitize(n)}get effectiveEditable(){const{editable:e,field:t,layer:i,tableEditingEnabled:n}=this;if(!t||!i)return!1;const o=h(i),r=i.effectiveCapabilities??i.capabilities,l=r?.operations?.supportsUpdate;return!!(t.editable&&o&&l&&"oid"!==t.type&&n)&&e}get effectiveLabel(){return o.sanitize(this.label||this.alias||this.fieldName)}get effectiveRequired(){return!this.nullable||this._isSubtypeField||this._activeFieldInput?.required||this.required}get effectiveSortable(){return!(!this.layer?.capabilities?.query?.supportsOrderBy||!this.sortable)}get effectiveTimeZoneOptions(){const{layer:e,field:t}=this;if(!e||"date"!==t?.type&&"timestamp-offset"!==t?.type)return{timeZone:void 0,timeZoneName:void 0};const{tableTimeZone:i,timeZone:n,view:o}=this;return V(e.preferredTimeZone||null,!!e.datesInUnknownTimezone,n??i??o?.timeZone??w,s("short-time"),t.type)}get includeTime(){const{field:e,template:t}=this;return"time-only"===e.type||"date-only"!==e.type&&(!t?.input||"includeTime"in t.input&&!1!==t.input.includeTime)}get layerFieldConfigurationFormat(){const{_layerWithFieldConfigurations:e}=this;if(e)return e.getFieldConfiguration(this.fieldName)?.fieldFormat??v(this.field)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,template:t}=this,i=e?.length??-1,n=t?.input&&"maxLength"in t.input?t.input.maxLength:null;return null!=n&&!isNaN(n)&&n>=-1&&(-1===i||n<=i)?n:i}get minLength(){const{template:e,maxLength:t}=this,i=e?.input&&"minLength"in e.input?e.input.minLength:null;return t&&i<=t?i:null}get name(){return this.field?.name}get nullable(){return!1!==this.field.nullable}get shouldShowPrompt(){return this._isSubtypeField}createInputElement({value:e}){const{_effectiveDomain:t,maxLength:o,minLength:r,effectiveRequired:l}=this;let a;if("coded-value"===t?.type)a=this.createCalciteSelect(e,t.codedValues.map(({code:e,name:t})=>({value:e,name:t}))),this.addHandles([i(()=>a,"calciteSelectChange",()=>this.onInputBlur(),n)],M);else if(this._isNumericField){const{_effectiveRange:{max:t,min:i}}=this;a=document.createElement("calcite-input"),a.type="number",this._isIntegerField&&(a.step=1),null!=t&&(a.max=t),null!=i&&(a.min=i),a.status=N({max:t,min:i,value:e})?"idle":"invalid"}else a=document.createElement("calcite-input"),this.addHandles([i(()=>a,"calciteInputChange",()=>this.onInputBlur(),n)],M),o>-1&&(a.maxLength=o),r>0&&(a.minLength=r);return a.classList.add(G.input),a.required=l,a.value=null!=e?e.toString():"",this.addHandles([i(()=>a,"keydown",e=>{e.key===P.cancelEdit&&this.onInputBlur(!0)},n),i(()=>a,"blur",()=>this.onInputBlur(),n)],M),a}onInputBlur(e=!1){this.removeHandles(M),super.onInputBlur(e)}onEditComplete(){const e=this.editInfo?.root;e&&this._syncRowEditingState(e,!1),this._activeFieldInput=null,super.onEditComplete()}get test(){}_clearActiveEditValues(){this.editInfo?.inputs?.forEach(e=>e.value="")}_setUpDateActionBar(){const{messagesCommon:e}=this,t=e?.cancel??"",i=e?.clear??"",n=e?.save??"",o=document.createElement("calcite-action-bar");return o.expandDisabled=!0,o.layout="horizontal",o.appendChild(this.createCalciteAction({text:n,icon:"save",onclick:()=>this.submit()})),this.effectiveRequired||o.appendChild(this.createCalciteAction({text:i,icon:"trash",onclick:()=>{this._clearActiveEditValues(),this.submit()}})),o.appendChild(this.createCalciteAction({text:t,icon:"x",onclick:()=>this.cancel()})),o}_formatDateValueForDisplay(e,t){const{timeZone:i,timeZoneName:n}=this.effectiveTimeZoneOptions;return null!=t?S(e,t,{...this._dateTimeFormatOptions,timeZone:i,timeZoneName:n}):null}_setUpDateComponents(e){const{_effectiveRange:{max:t,min:n,rawMax:o,rawMin:r},field:l,effectiveRequired:a}=this,s=this._getDateFieldValuesForComponents(l,e),u=[];if(T(l)){const e=this.createDateComponent(),p=x(l)||O(l)?o:t,d=x(l)||O(l)?r:n,m=this._getDateFieldValuesForComponents(l,p??null),c=this._getDateFieldValuesForComponents(l,d??null);e.value=s.date??"",e.max=m.date??"",e.min=c.date??"",e.required=a,this.addHandles([i(()=>e,"calciteInputDatePickerOpen",()=>this._onDateComponentOpen(e))],M),u.push(e)}if(this.includeTime){const e=this.createTimeComponent();e.value=s.time??"",e.required=a,this.addHandles([i(()=>e,"calciteInputTimePickerOpen",()=>this._onDateComponentOpen(e))],M),u.push(e)}if("timestamp-offset"===l.type){const e=this.createTimeZoneComponent();e.value=s.timeZoneOffset??"0",this.addHandles([i(()=>e,"calciteInputTimeZoneOpen",()=>this._onDateComponentOpen(e))],M),u.push(e)}return u}_onDateComponentOpen(e){this.editInfo?.inputs.forEach(t=>{t!==e&&"open"in t&&(t.open=!1)})}_syncRowEditingState(e,t=!1){const i=this.grid?.getRowContainingNode(e);i&&(t?i.setAttribute("editing","true"):i.removeAttribute("editing"))}_getDateFieldValuesForComponents(e,t){switch(e.type){case"date":return B(t,this.effectiveTimeZoneOptions.timeZone);case"date-only":return{date:t};case"time-only":return{time:t};case"timestamp-offset":return z(t);default:return{}}}_setUpFieldInput(e,t){const{field:i,layer:n,effectiveTimeZoneOptions:{timeZone:o}}=this,r=new E({feature:e,field:i,initialFeature:e.clone(),layer:n,timeZone:o});return r.set("value",t),r}_isDomainCompatible(e){if(!e)return!1;const{_isNumericField:t,_isStringField:i}=this,{type:n}=e;if("coded-value"===n){const n=typeof e.codedValues[0].code;if("string"===n&&i||"number"===n&&t)return!0}return!("range"!==n||!t)}_getDomainForFeature(e){const{fieldName:t,layer:i,template:n}=this;if(!e||!i?.getFieldDomain)return null;if("wfs"===i.type||"geojson"===i.type||"csv"===i.type||"knowledge-graph-sublayer"===i.type)return null;if(n?.domain&&this._isDomainCompatible(n.domain))return n.domain;if("feature"!==i.type&&"subtype-group"!==i.type&&null==i.getField(t)?.domain){const e=y(i,t);if(e)return e}return i.getFieldDomain(t,{feature:e})}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const i=t.codedValues.filter(t=>t.hasOwnProperty("code")&&t.code===e);return i&&i.length?i[0].name:e}return null}};e([r()],$.prototype,"_effectiveDomain",null),e([r()],$.prototype,"_activeFieldInput",void 0),e([r()],$.prototype,"_effectiveRange",null),e([r()],$.prototype,"_isAnyDateOrTimeField",null),e([r()],$.prototype,"_isIntegerField",null),e([r()],$.prototype,"_isNumericField",null),e([r()],$.prototype,"_isStringField",null),e([r()],$.prototype,"_isSubtypeField",null),e([r()],$.prototype,"_layerWithFieldConfigurations",null),e([r()],$.prototype,"_dateTimeFormatOptions",null),e([r()],$.prototype,"_numberFormatOptions",null),e([r({readOnly:!0})],$.prototype,"alias",null),e([r()],$.prototype,"cellValueFormatFunction",void 0),e([r()],$.prototype,"cellValueValidatorFunction",void 0),e([r({readOnly:!0})],$.prototype,"defaultValue",null),e([r()],$.prototype,"effectiveDescription",null),e([r()],$.prototype,"effectiveEditable",null),e([r()],$.prototype,"effectiveLabel",null),e([r()],$.prototype,"effectiveRequired",null),e([r()],$.prototype,"effectiveSortable",null),e([r()],$.prototype,"effectiveTimeZoneOptions",null),e([r({type:g})],$.prototype,"field",void 0),e([r()],$.prototype,"formatFunction",void 0),e([r()],$.prototype,"includeTime",null),e([r()],$.prototype,"inputRenderFunction",void 0),e([r()],$.prototype,"layer",void 0),e([r()],$.prototype,"layerFieldConfigurationFormat",null),e([r({readOnly:!0})],$.prototype,"loadingMessage",null),e([r()],$.prototype,"maxLength",null),e([r()],$.prototype,"minLength",null),e([r({readOnly:!0})],$.prototype,"name",null),e([r({readOnly:!0})],$.prototype,"nullable",null),e([r()],$.prototype,"parseInputValueFunction",void 0),e([r()],$.prototype,"shouldShowPrompt",null),e([r()],$.prototype,"sortable",void 0),e([r()],$.prototype,"store",void 0),e([r()],$.prototype,"template",void 0),e([r()],$.prototype,"view",void 0),$=e([l("esri.widgets.FeatureTable.FieldColumn")],$);const J=$;export{J as default};
5
+ import{__decorate as e}from"tslib";import"../../core/has.js";import t from"../../core/Logger.js";import{on as i,sync as n}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveFieldAlias as r}from"../../editing/fieldUtils.js";import{convertDateFormatToIntlOptions as a,defaultFormatterOptionsNoTime as s,convertDateTimeFieldFormatToIntlOptions as u,defaultFormatterOptions as p}from"../../intl/date.js";import{formatNumber as d,convertNumberFormatToIntlOptions as m,convertNumberFieldFormatToIntlOptions as c}from"../../intl/number.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import{computeDomainFromTypes as h}from"../../layers/support/featureLayerUtils.js";import y from"../../layers/support/Field.js";import{defaultFieldFormat as g}from"../../layers/support/fieldFormatUtils.js";import{validateFieldValue as v,isDateField as F,isTimeOnlyField as _,isIntegerField as C,isNumericField as b,isStringField as D,isDateOnlyField as I,isTimestampOffsetField as x}from"../../layers/support/fieldUtils.js";import{isAnyDateField as T}from"../../smartMapping/support/utils.js";import{system as O}from"../../time/constants.js";import{getTimeZoneFormattingOptions as w}from"../../time/timeZoneUtils.js";import V from"../FeatureForm/FieldInput.js";import E from"./Grid/EditorColumn.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as Z,isEmptyStringOrWhitespace as L}from"./support/tableUtils.js";import{valueIsInRange as j,dateTimeIsInRange as R,getUnixFieldValueFromDateComponents as S,getISOFieldValueFromDateComponents as N,normalizeTimeOnlyString as A,getLabelForDateFieldValue as U,prepareISOFieldValueForDateComponents as q,prepareUnixFieldValueForDateComponents as k}from"../support/dateUtils.js";import{setFocus as B}from"../support/widgetUtils.js";const z={cancelEdit:"Escape"},H=Symbol(),P="esri-column",M={input:`${P}__cell-input`,inputContainer:`${P}__cell__input-container`};let W=class extends E{constructor(e){super(e),this._activeFieldInput=null,this.cellValueFormatFunction=({root:e,rowData:t,value:i})=>{const{formatFunction:n}=this;if(n&&t){const{index:o,item:{attachments:l,feature:r,relatedRecords:a}}=t,s=n({attachments:l,column:this,feature:r,field:this.field,index:o,relatedRecords:a,value:this.sanitizeContent(i),virtualIndex:this.getVirtualRowIndex(e)});return this.sanitizeContent(s)}if(null===i)return"&nbsp;";const o=this._getDomainForFeature(t?.item?.feature),l=this._getComputedDomain(i,o)||i;return this._isAnyDateOrTimeField&&"coded-value"!==o?.type?this._formatDateValueForDisplay(this.field,l):this._isNumericField&&"coded-value"!==o?.type?d(parseFloat(l),this._numberFormatOptions):this.sanitizeContent(l)},this.cellValueValidatorFunction=({oldValue:e,value:i})=>{const{_effectiveRange:n,field:o}=this,{max:l,min:r}=n;if(this.effectiveRequired&&(null==i||""===i))return!1;if(this._isNumericField&&(v(o,i)||!j({max:l,min:r,value:i})))return t.getLogger(this).warn("value-exceeds-valid-range","Field value exceeds valid range. Attempted edit was rejected."),!1;if(this._isAnyDateOrTimeField){const e=o.type;if(!R({type:e,range:n,value:i}))return!1}return e!==i},this.field=null,this.formatFunction=null,this.inputRenderFunction=async({root:e,column:i,rowData:n})=>{if(this.editInfo||!this.effectiveEditable)return;const o=this.getCellValue(n),{field:l}=this;if("big-integer"===l.type&&v(l,o))return void t.getLogger(this).warn("value-exceeds-valid-range","Field value is beyond supported limit. Editing is disabled for this field value.");const r=n?.item.feature;if(!r)return;this._activeFieldInput=this._setUpFieldInput(r,o);const a=document.createElement("div");a.classList.add(M.inputContainer);const s=[],u="coded-value"===this._effectiveDomain?.type;if(this._isAnyDateOrTimeField&&!u){const e=document.createElement("div"),t=this._setUpDateComponents(o),i=this._setUpDateActionBar();t.forEach(t=>e.appendChild(t)),a.appendChild(e),a.appendChild(i),s.push(...t)}else{const e=this.createInputElement({value:o});a.appendChild(e),s.push(e)}this._set("editInfo",{column:i,inputs:s,root:e,rowData:n,oldValue:o}),this.removeCellContent(e),e.appendChild(a),this._syncRowEditingState(e,!0),this.grid?.generateCellPartNames();const p=s[0];await B(p),"selectText"in p&&await p.selectText()},this.layer=null,this.parseInputValueFunction=({inputs:e})=>{const{editInfo:t,field:i,includeTime:n}=this;if(!t||!e.length)return null;const o=e[0];if(this._isAnyDateOrTimeField){if("coded-value"===this._effectiveDomain?.type){if(null==o.value||""===o.value)return null;const e=String(o.value);return F(i)?parseFloat(e):e}const{timeZone:l}=this.effectiveTimeZoneOptions,r=t.oldValue??void 0;switch(i.type){case"date-only":{const e=o.value;return""!==e?e:null}case"time-only":{const e=A(o.value);return""!==e?e:null}case"timestamp-offset":{const t=n?e[1]:void 0,i=e.at(-1);return N({oldValue:r,dateComponent:o,timeComponent:t,timeZoneComponent:i,defaultTimeZone:l})}case"date":{const{max:t,min:i}=this._effectiveRange;return S({oldValue:r,dateComponent:o,timeComponent:e[1],timeZone:l,max:t,min:i})}}return null}const l=o.value,{effectiveRequired:r}=this;return r||null!=l&&""!==l?this._isNumericField?parseFloat(l):this._isStringField?l.trim():l:null},this.sortable=!0,this.store=null,this.template=null,this.view=null}get _effectiveDomain(){const e=this._activeFieldInput?.feature;return e?this._getDomainForFeature(e):null}get _effectiveRange(){return this._activeFieldInput?.range??{max:null,min:null}}get _isAnyDateOrTimeField(){const{field:e}=this;return T(e)||_(e)}get _isIntegerField(){return C(this.field)}get _isNumericField(){return b(this.field)}get _isStringField(){return D(this.field)}get _isSubtypeField(){const{layer:e}=this;if(e?.subtypeField){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1}get _layerWithFieldConfigurations(){const{layer:e}=this;return Z(e)?e:null}get _dateTimeFormatOptions(){const{layerFieldConfigurationFormat:e,template:t}=this;return t?.format?.dateFormat?a(t.format.dateFormat):t?.input&&"includeTime"in t.input&&!1===t.input.includeTime?s:"date-time"===e?.type?u(e):this._isAnyDateOrTimeField?p:void 0}get _numberFormatOptions(){const{layerFieldConfigurationFormat:e,template:t}=this;return t?.format?m(t.format):"number"===e?.type?c(e):this._isNumericField?{useGrouping:!0,maximumFractionDigits:20}:void 0}get alias(){return r(this.field,this._layerWithFieldConfigurations)}get defaultValue(){return this.field?.defaultValue}get effectiveDescription(){const{description:e,field:t}=this,i=t.description,n=L(e)?L(i)?null:i:e;return null==n?null:this.sanitizeLabel(n)}get effectiveEditable(){const{editable:e,field:t,layer:i,tableEditingEnabled:n}=this;if(!t||!i)return!1;const o=f(i),l=i.effectiveCapabilities??i.capabilities,r=l?.operations?.supportsUpdate;return!!(t.editable&&o&&r&&"oid"!==t.type&&n)&&e}get effectiveLabel(){return this.sanitizeLabel(this.label||this.alias||this.fieldName)}get effectiveRequired(){return!this.nullable||this._isSubtypeField||this._activeFieldInput?.required||this.required}get effectiveSortable(){return!(!this.layer?.capabilities?.query?.supportsOrderBy||!this.sortable)}get effectiveTimeZoneOptions(){const{layer:e,field:t}=this;if(!e||"date"!==t?.type&&"timestamp-offset"!==t?.type)return{timeZone:void 0,timeZoneName:void 0};const{tableTimeZone:i,timeZone:n,view:o}=this;return w(e.preferredTimeZone||null,!!e.datesInUnknownTimezone,n??i??o?.timeZone??O,a("short-time"),t.type)}get includeTime(){const{field:e,template:t}=this;return"time-only"===e.type||"date-only"!==e.type&&(!t?.input||"includeTime"in t.input&&!1!==t.input.includeTime)}get layerFieldConfigurationFormat(){const{_layerWithFieldConfigurations:e}=this;if(e)return e.getFieldConfiguration(this.fieldName)?.fieldFormat??g(this.field)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,template:t}=this,i=e?.length??-1,n=t?.input&&"maxLength"in t.input?t.input.maxLength:null;return null!=n&&!isNaN(n)&&n>=-1&&(-1===i||n<=i)?n:i}get minLength(){const{template:e,maxLength:t}=this,i=e?.input&&"minLength"in e.input?e.input.minLength:null;return t&&i<=t?i:null}get name(){return this.field?.name}get nullable(){return!1!==this.field.nullable}get shouldShowPrompt(){return this._isSubtypeField}createInputElement({value:e}){const{_effectiveDomain:t,maxLength:o,minLength:l,effectiveRequired:r}=this;let a;if("coded-value"===t?.type)a=this.createCalciteSelect(e,t.codedValues.map(({code:e,name:t})=>({value:e,name:t}))),this.addHandles([i(()=>a,"calciteSelectChange",()=>this.onInputBlur(),n)],H);else if(this._isNumericField){const{_effectiveRange:{max:t,min:i}}=this;a=document.createElement("calcite-input"),a.type="number",this._isIntegerField&&(a.step=1),null!=t&&(a.max=t),null!=i&&(a.min=i),a.status=j({max:t,min:i,value:e})?"idle":"invalid"}else a=document.createElement("calcite-input"),this.addHandles([i(()=>a,"calciteInputChange",()=>this.onInputBlur(),n)],H),o>-1&&(a.maxLength=o),l>0&&(a.minLength=l);return a.classList.add(M.input),a.required=r,a.value=null!=e?e.toString():"",this.addHandles([i(()=>a,"keydown",e=>{e.key===z.cancelEdit&&this.onInputBlur(!0)},n),i(()=>a,"blur",()=>this.onInputBlur(),n)],H),a}onInputBlur(e=!1){this.removeHandles(H),super.onInputBlur(e)}onEditComplete(){const e=this.editInfo?.root;e&&this._syncRowEditingState(e,!1),this._activeFieldInput=null,super.onEditComplete()}get test(){}_clearActiveEditValues(){this.editInfo?.inputs?.forEach(e=>e.value="")}_setUpDateActionBar(){const{messagesCommon:e}=this,t=e?.cancel??"",i=e?.clear??"",n=e?.save??"",o=document.createElement("calcite-action-bar");return o.expandDisabled=!0,o.layout="horizontal",o.appendChild(this.createCalciteAction({text:n,icon:"save",onclick:()=>this.submit()})),this.effectiveRequired||o.appendChild(this.createCalciteAction({text:i,icon:"trash",onclick:()=>{this._clearActiveEditValues(),this.submit()}})),o.appendChild(this.createCalciteAction({text:t,icon:"x",onclick:()=>this.cancel()})),o}_formatDateValueForDisplay(e,t){const{timeZone:i,timeZoneName:n}=this.effectiveTimeZoneOptions;return null!=t?U(e,t,{...this._dateTimeFormatOptions,timeZone:i,timeZoneName:n}):null}_setUpDateComponents(e){const{_effectiveRange:{max:t,min:n,rawMax:o,rawMin:l},field:r,effectiveRequired:a}=this,s=this._getDateFieldValuesForComponents(r,e),u=[];if(T(r)){const e=this.createDateComponent(),p=I(r)||x(r)?o:t,d=I(r)||x(r)?l:n,m=this._getDateFieldValuesForComponents(r,p??null),c=this._getDateFieldValuesForComponents(r,d??null);e.value=s.date??"",e.max=m.date??"",e.min=c.date??"",e.required=a,this.addHandles([i(()=>e,"calciteInputDatePickerOpen",()=>this._onDateComponentOpen(e))],H),u.push(e)}if(this.includeTime){const e=this.createTimeComponent();e.value=s.time??"",e.required=a,this.addHandles([i(()=>e,"calciteInputTimePickerOpen",()=>this._onDateComponentOpen(e))],H),u.push(e)}if("timestamp-offset"===r.type){const e=this.createTimeZoneComponent();e.value=s.timeZoneOffset??"0",this.addHandles([i(()=>e,"calciteInputTimeZoneOpen",()=>this._onDateComponentOpen(e))],H),u.push(e)}return u}_onDateComponentOpen(e){this.editInfo?.inputs.forEach(t=>{t!==e&&"open"in t&&(t.open=!1)})}_syncRowEditingState(e,t=!1){const i=this.grid?.getRowContainingNode(e);i&&(t?i.setAttribute("editing","true"):i.removeAttribute("editing"))}_getDateFieldValuesForComponents(e,t){switch(e.type){case"date":return k(t,this.effectiveTimeZoneOptions.timeZone);case"date-only":return{date:t};case"time-only":return{time:t};case"timestamp-offset":return q(t);default:return{}}}_setUpFieldInput(e,t){const{field:i,layer:n,effectiveTimeZoneOptions:{timeZone:o}}=this,l=new V({feature:e,field:i,initialFeature:e.clone(),layer:n,timeZone:o});return l.set("value",t),l}_isDomainCompatible(e){if(!e)return!1;const{_isNumericField:t,_isStringField:i}=this,{type:n}=e;if("coded-value"===n){const n=typeof e.codedValues[0].code;if("string"===n&&i||"number"===n&&t)return!0}return!("range"!==n||!t)}_getDomainForFeature(e){const{fieldName:t,layer:i,template:n}=this;if(!e||!i?.getFieldDomain)return null;if("wfs"===i.type||"geojson"===i.type||"csv"===i.type||"knowledge-graph-sublayer"===i.type)return null;if(n?.domain&&this._isDomainCompatible(n.domain))return n.domain;if("feature"!==i.type&&"subtype-group"!==i.type&&null==i.getField(t)?.domain){const e=h(i,t);if(e)return e}return i.getFieldDomain(t,{feature:e})}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const i=t.codedValues.filter(t=>t.hasOwnProperty("code")&&t.code===e);return i&&i.length?i[0].name:e}return null}};e([o()],W.prototype,"_effectiveDomain",null),e([o()],W.prototype,"_activeFieldInput",void 0),e([o()],W.prototype,"_effectiveRange",null),e([o()],W.prototype,"_isAnyDateOrTimeField",null),e([o()],W.prototype,"_isIntegerField",null),e([o()],W.prototype,"_isNumericField",null),e([o()],W.prototype,"_isStringField",null),e([o()],W.prototype,"_isSubtypeField",null),e([o()],W.prototype,"_layerWithFieldConfigurations",null),e([o()],W.prototype,"_dateTimeFormatOptions",null),e([o()],W.prototype,"_numberFormatOptions",null),e([o({readOnly:!0})],W.prototype,"alias",null),e([o()],W.prototype,"cellValueFormatFunction",void 0),e([o()],W.prototype,"cellValueValidatorFunction",void 0),e([o({readOnly:!0})],W.prototype,"defaultValue",null),e([o()],W.prototype,"effectiveDescription",null),e([o()],W.prototype,"effectiveEditable",null),e([o()],W.prototype,"effectiveLabel",null),e([o()],W.prototype,"effectiveRequired",null),e([o()],W.prototype,"effectiveSortable",null),e([o()],W.prototype,"effectiveTimeZoneOptions",null),e([o({type:y})],W.prototype,"field",void 0),e([o()],W.prototype,"formatFunction",void 0),e([o()],W.prototype,"includeTime",null),e([o()],W.prototype,"inputRenderFunction",void 0),e([o()],W.prototype,"layer",void 0),e([o()],W.prototype,"layerFieldConfigurationFormat",null),e([o({readOnly:!0})],W.prototype,"loadingMessage",null),e([o()],W.prototype,"maxLength",null),e([o()],W.prototype,"minLength",null),e([o({readOnly:!0})],W.prototype,"name",null),e([o({readOnly:!0})],W.prototype,"nullable",null),e([o()],W.prototype,"parseInputValueFunction",void 0),e([o()],W.prototype,"shouldShowPrompt",null),e([o()],W.prototype,"sortable",void 0),e([o()],W.prototype,"store",void 0),e([o()],W.prototype,"template",void 0),e([o()],W.prototype,"view",void 0),W=e([l("esri.widgets.FeatureTable.FieldColumn")],W);const G=W;export{G as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{watch as i,when as n,initial as o}from"../../../core/reactiveUtils.js";import{renderingSanitizer as s}from"../../../core/sanitizerUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{css as a}from"./ColumnCSS.js";import{isEmptyStringOrWhitespace as c}from"../support/tableUtils.js";import{autoLink as d}from"../../support/uriUtils.js";import{setFocus as p}from"../../support/widgetUtils.js";let u=class extends t{constructor(e){super(e),this._menuIsOpen=!1,this.autoWidth=!1,this.cellValueFormatFunction=({root:e,rowData:t,value:i})=>{const{formatFunction:n}=this,o=s.sanitize(i);if(n&&t){const{index:i,item:{attachments:s,feature:r,relatedRecords:l}}=t;return n({attachments:s,column:this,feature:r,index:i,relatedRecords:l,value:o,virtualIndex:this.getVirtualRowIndex(e),field:void 0})}return o},this.description=null,this.direction=null,this.fieldName=null,this.flexGrow=1,this.footerRenderFunction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.grid=null,this.headerRenderFunction=e=>{const{root:t}=e,i=this.createHeaderContent();this.removeCellContent(t),t.appendChild(i)},this.hidden=!1,this.icon=null,this.iconText=null,this.initialSortPriority=null,this.label=null,this.labelTooltipText=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.renderFunction=({root:e,rowData:t})=>{const i=this.getCellValue(t),n=this.cellValueFormatFunction({root:e,rowData:t,value:i});let o=null;if(o=n instanceof HTMLElement?n:d(this.messagesURIUtils,n),this.removeCellContent(e),o instanceof HTMLElement)e.removeAttribute("title"),e.appendChild(o);else if(null!=o){const t=o.toString();e.innerHTML=t,e.title=t}},this.resizable=!0,this.sortable=!1,this.store=null,this.tableTimeZone=null,this.textAlign="start",this.textWrap=!1,this.timeZone=null,this.visibleElements=null,this.width=200}initialize(){const{fieldName:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e),this.addHandles([i(()=>this.direction,e=>{const{sortElement:t}=this;this.effectiveSortable&&t&&(e?this.sortElement.direction!==e&&t.setAttribute("direction",e):t.removeAttribute("direction"))}),n(()=>this.grid?.isReady&&this.sortElement,()=>{const{direction:e,grid:t,hidden:i,sortElement:n}=this;i&&e&&n&&t&&!t.hasSorter(n)&&t.addSorter(n)},o),i(()=>[this.timeZone,this.icon,this.iconText,this.labelTooltipText],()=>this.grid?.requestContentUpdate()),i(()=>this.hidden,()=>this.closeMenu()),i(()=>this.fieldName,e=>{const{sortElement:t}=this;t&&t.path!==e&&t.setAttribute("path",e)}),i(()=>[this.effectiveLabel,this.labelTooltipText],([e,t])=>{const{sortElement:i}=this;i&&(i.setAttribute("title",t||e),i.textContent=e)})])}get _headerRequiresTextContainer(){return!(!this.effectiveSortable&&""===this.effectiveLabel&&null==this.effectiveDescription)}get customMenuItems(){return this.menuConfig?.items?.map(({disabled:e,hidden:t,icon:i,iconClass:n,label:o,selected:s,clickFunction:r})=>this.createCalciteDropdownItem({disabled:e,hidden:t,iconClass:n,iconStart:i,selected:s,textContent:o,onclick:e=>r(e)}))??[]}get defaultMenuItems(){if(!this.effectiveSortable)return[];const e=this.messages,t=[],i=this.visibleElements?.columnMenuItems;if(!1!==i?.sortAscending){const i=this.createCalciteDropdownItem({iconStart:"sort-ascending-arrow",textContent:e?.sortAsc,onclick:()=>this.direction="asc"});t.push(i)}if(!1!==i?.sortDescending){const i=this.createCalciteDropdownItem({iconStart:"sort-descending-arrow",textContent:e?.sortDesc,onclick:()=>this.direction="desc"});t.push(i)}return t}get effectiveDescription(){const{description:e}=this;return c(e)?null:s.sanitize(e)}get effectiveLabel(){return s.sanitize(this.label||this.fieldName)}get effectiveSortable(){return this.sortable}get iconNode(){const{icon:e,iconText:t}=this,i=t?s.sanitize(t):void 0;return e?this.createCalciteIcon({icon:e,textLabel:i}):null}set invalid(e){this._set("invalid",e),this.grid?.generateCellPartNames()}get invalid(){return this._get("invalid")??!1}get menu(){const{customMenuItems:e,defaultMenuItems:t,menuConfig:i}=this,n=!!i?.open,o=this.createCalciteAction({icon:i?.icon??"ellipsis",text:this.messages?.menu??"",slot:"trigger"}),s=document.createElement("calcite-dropdown");if(s.maxItems=i?.maxItems??4,s.placement="top-end",s.scale=i?.scale??"m",n&&(s.open=n,this._menuIsOpen=!0),s.appendChild(o),s.addEventListener("calciteDropdownOpen",()=>this._menuIsOpen=!0),s.addEventListener("calciteDropdownClose",()=>this._menuIsOpen=!1),s.onkeydown=this._stopPropagationOnSelect,s.addEventListener("mousewheel",e=>{e.stopPropagation()}),t.length){const e=s.appendChild(document.createElement("calcite-dropdown-group"));e.selectionMode="none",e.append(...t)}if(e.length){const t=s.appendChild(document.createElement("calcite-dropdown-group"));t.selectionMode=i?.selectionMode??"none",t.append(...e)}return s}get menuItems(){return[...this.defaultMenuItems,...this.customMenuItems]}get menuIsOpen(){return this._menuIsOpen}get menuIsVisible(){return!(!1===this.visibleElements?.columnMenus||!this.menuItems.length)}closeMenu(){this.menu.open=!1}createSortElement(){const{effectiveLabel:e,direction:t,fieldName:i,initialSortPriority:n}=this,o=document.createElement("vaadin-grid-sorter");return o.classList.add(a.sorter),o.setAttribute("path",i),o.setAttribute("title",this.labelTooltipText||e),o.textContent=e,t&&o.setAttribute("direction",t),null!=n&&(o._initialOrder=n),o.addEventListener("direction-changed",()=>{this.direction!==o.direction&&this._set("direction",o.direction)}),o}createCalciteAction(e){const t=document.createElement("calcite-action"),{alignment:i,appearance:n,className:o,disabled:s,icon:r,label:l,scale:a,slot:c,text:d,textEnabled:p,onclick:u}=e;return t.alignment=i??"center",t.appearance=n??"transparent",t.className=o??"",t.disabled=!!s,t.icon=r??"",t.label=l??"",t.scale=a??"s",t.slot=c??"",t.text=t.title=d??"",t.textEnabled=!!p,t.onclick=u??null,t}createCalciteButton(e){const t=document.createElement("calcite-button"),{alignment:i,appearance:n,className:o,disabled:s,iconEnd:r,iconFlipRtl:l,kind:a,loading:c,onclick:d,scale:p,textContent:u,title:m,width:h}=e;return t.alignment=i??"center",t.className=o??"",t.scale=p??"s",t.appearance=n??"transparent",t.disabled=!!s,t.iconEnd=r??"",l&&(t.iconFlipRtl=l),t.kind=a??"brand",t.loading=!!c,t.textContent=u??"",m&&(t.title=m),t.width=h??"auto",t.onclick=d??null,t}createCalciteDropdownItem(e){const t=document.createElement("calcite-dropdown-item"),{disabled:i,hidden:n,iconClass:o,iconStart:s,textContent:r,onclick:l,selected:c}=e,d=r??"";if(o&&!s){const e=document.createElement("span"),i=document.createElement("span");i.classList.add(a.headerMenuIcon,o),e.textContent=e.title=d,e.insertBefore(i,e.firstChild),t.appendChild(e)}else t.iconStart=s??"",t.textContent=t.title=d;return t.disabled=!!i,t.hidden="function"==typeof n?n():!!n,t.selected=!!c,l&&(t.addEventListener("calciteDropdownItemSelect",l),t.onkeydown=this._stopPropagationOnSelect),t}createCalciteIcon(e){const{effectiveLabel:t}=this,{icon:i,scale:n,textLabel:o}=e,s=document.createElement("calcite-icon"),r=o??t;return s.icon=i,s.scale=n??"s",s.textLabel=r,s.title=r,s}createHeaderContent(){const{effectiveDescription:e,effectiveLabel:t,iconNode:i}=this,n=document.createElement("div");if(n.classList.add(a.headerContent),i&&n.appendChild(i),!this._headerRequiresTextContainer)return n;const o=n.appendChild(document.createElement("div"));return this.effectiveSortable?o.appendChild(this.sortElement):""!==t&&o.appendChild(this._createHeaderTextElement({label:t,cssClass:a.headerLabel,title:this.labelTooltipText})),null!=e&&!1!==this.visibleElements?.columnDescriptions&&o.appendChild(this._createHeaderTextElement({label:e,cssClass:a.headerDescription})),this.menuIsVisible&&n.appendChild(this.menu),n}getCellValue(e){return e?.item.feature.attributes?.[this.fieldName]}getVirtualRowIndex(e){const t=this.grid?.getRowContainingNode(e);return t?.parentElement?[...t.parentElement.children].indexOf(t):-1}removeCellContent(e){if(e&&e.firstChild)try{for(;e?.firstChild;)e?.removeChild(e.firstChild)}catch(t){}}openMenu(){this.menuIsVisible&&(this.menu.open=!0,p(this.menuItems[0]))}sort(){this.effectiveSortable&&this.sortElement?.click()}_stopPropagationOnSelect(e){"Enter"!==e.key&&" "!==e.key||e.stopPropagation()}_createHeaderTextElement({cssClass:e,label:t,title:i}){const n=document.createElement("span");n.classList.add(e);const o=n.appendChild(document.createElement("span"));return o.textContent=t,o.setAttribute("title",i||t),n}};e([r()],u.prototype,"_headerRequiresTextContainer",null),e([r()],u.prototype,"_menuIsOpen",void 0),e([r()],u.prototype,"autoWidth",void 0),e([r()],u.prototype,"cellValueFormatFunction",void 0),e([r()],u.prototype,"customMenuItems",null),e([r()],u.prototype,"defaultMenuItems",null),e([r()],u.prototype,"description",void 0),e([r()],u.prototype,"direction",void 0),e([r()],u.prototype,"effectiveDescription",null),e([r()],u.prototype,"effectiveLabel",null),e([r()],u.prototype,"effectiveSortable",null),e([r({constructOnly:!0})],u.prototype,"fieldName",void 0),e([r()],u.prototype,"flexGrow",void 0),e([r()],u.prototype,"footerRenderFunction",void 0),e([r()],u.prototype,"formatFunction",void 0),e([r()],u.prototype,"frozen",void 0),e([r()],u.prototype,"frozenToEnd",void 0),e([r()],u.prototype,"grid",void 0),e([r()],u.prototype,"iconNode",null),e([r()],u.prototype,"invalid",null),e([r()],u.prototype,"headerRenderFunction",void 0),e([r()],u.prototype,"hidden",void 0),e([r()],u.prototype,"icon",void 0),e([r()],u.prototype,"iconText",void 0),e([r({constructOnly:!0})],u.prototype,"initialSortPriority",void 0),e([r()],u.prototype,"label",void 0),e([r()],u.prototype,"labelTooltipText",void 0),e([r()],u.prototype,"menu",null),e([r()],u.prototype,"menuItems",null),e([r()],u.prototype,"menuConfig",void 0),e([r()],u.prototype,"menuIsOpen",null),e([r()],u.prototype,"menuIsVisible",null),e([r()],u.prototype,"messages",void 0),e([r()],u.prototype,"messagesCommon",void 0),e([r()],u.prototype,"messagesURIUtils",void 0),e([r()],u.prototype,"renderFunction",void 0),e([r()],u.prototype,"resizable",void 0),e([r()],u.prototype,"sortable",void 0),e([r({readOnly:!0})],u.prototype,"sortElement",void 0),e([r()],u.prototype,"store",void 0),e([r()],u.prototype,"tableTimeZone",void 0),e([r()],u.prototype,"textAlign",void 0),e([r()],u.prototype,"textWrap",void 0),e([r()],u.prototype,"timeZone",void 0),e([r()],u.prototype,"visibleElements",void 0),e([r()],u.prototype,"width",void 0),u=e([l("esri.widgets.FeatureTable.Grid.Column")],u);const m=u;export{m as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{watch as i,when as n,initial as o}from"../../../core/reactiveUtils.js";import{renderingSanitizer as s,stripHTMLSanitizer as r}from"../../../core/sanitizerUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{css as c}from"./ColumnCSS.js";import{isEmptyStringOrWhitespace as d}from"../support/tableUtils.js";import{autoLink as p}from"../../support/uriUtils.js";import{setFocus as u}from"../../support/widgetUtils.js";const m=/<br\s*\/*>/gi;let h=class extends t{constructor(e){super(e),this._menuIsOpen=!1,this.autoWidth=!1,this.cellValueFormatFunction=({root:e,rowData:t,value:i})=>{const{formatFunction:n}=this,o=this.sanitizeContent(i);if(n&&t){const{index:i,item:{attachments:s,feature:r,relatedRecords:l}}=t,a=n({attachments:s,column:this,feature:r,index:i,relatedRecords:l,value:o,virtualIndex:this.getVirtualRowIndex(e),field:void 0});return this.sanitizeContent(a)}return o},this.description=null,this.direction=null,this.fieldName=null,this.flexGrow=1,this.footerRenderFunction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.grid=null,this.headerRenderFunction=e=>{const{root:t}=e,i=this.createHeaderContent();this.removeCellContent(t),t.appendChild(i)},this.hidden=!1,this.icon=null,this.iconText=null,this.initialSortPriority=null,this.label=null,this.labelTooltipText=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.renderFunction=({root:e,rowData:t})=>{const i=this.getCellValue(t),n=this.cellValueFormatFunction({root:e,rowData:t,value:i});let o=null;if(o=n instanceof HTMLElement?n:p(this.messagesURIUtils,n),this.removeCellContent(e),o instanceof HTMLElement)e.removeAttribute("title"),e.appendChild(o);else if(null!=o){const t=o.toString();e.innerHTML=t,e.title=t}},this.resizable=!0,this.sortable=!1,this.store=null,this.tableTimeZone=null,this.textAlign="start",this.textWrap=!1,this.timeZone=null,this.visibleElements=null,this.width=200}initialize(){const{fieldName:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e),this.addHandles([i(()=>this.direction,e=>{const{sortElement:t}=this;this.effectiveSortable&&t&&(e?this.sortElement.direction!==e&&t.setAttribute("direction",e):t.removeAttribute("direction"))}),n(()=>this.grid?.isReady&&this.sortElement,()=>{const{direction:e,grid:t,hidden:i,sortElement:n}=this;i&&e&&n&&t&&!t.hasSorter(n)&&t.addSorter(n)},o),i(()=>[this.timeZone,this.icon,this.iconText,this.labelTooltipText],()=>this.grid?.requestContentUpdate()),i(()=>this.hidden,()=>this.closeMenu()),i(()=>this.fieldName,e=>{const{sortElement:t}=this;t&&t.path!==e&&t.setAttribute("path",e)}),i(()=>[this.effectiveLabel,this.labelTooltipText],([e,t])=>{const{sortElement:i}=this;i&&(i.setAttribute("title",t||e),i.textContent=e)})])}get _headerRequiresTextContainer(){return!(!this.effectiveSortable&&""===this.effectiveLabel&&null==this.effectiveDescription)}get customMenuItems(){return this.menuConfig?.items?.map(({disabled:e,hidden:t,icon:i,iconClass:n,label:o,selected:s,clickFunction:r})=>this.createCalciteDropdownItem({disabled:e,hidden:t,iconClass:n,iconStart:i,selected:s,textContent:o,onclick:e=>r(e)}))??[]}get defaultMenuItems(){if(!this.effectiveSortable)return[];const e=this.messages,t=[],i=this.visibleElements?.columnMenuItems;if(!1!==i?.sortAscending){const i=this.createCalciteDropdownItem({iconStart:"sort-ascending-arrow",textContent:e?.sortAsc,onclick:()=>this.direction="asc"});t.push(i)}if(!1!==i?.sortDescending){const i=this.createCalciteDropdownItem({iconStart:"sort-descending-arrow",textContent:e?.sortDesc,onclick:()=>this.direction="desc"});t.push(i)}return t}get effectiveDescription(){const{description:e}=this;return d(e)?null:this.sanitizeLabel(e)}get effectiveLabel(){return this.sanitizeLabel(this.label||this.fieldName)}get effectiveSortable(){return this.sortable}get iconNode(){const{icon:e,iconText:t}=this,i=t?this.sanitizeLabel(t):void 0;return e?this.createCalciteIcon({icon:e,textLabel:i}):null}set invalid(e){this._set("invalid",e),this.grid?.generateCellPartNames()}get invalid(){return this._get("invalid")??!1}get menu(){const{customMenuItems:e,defaultMenuItems:t,menuConfig:i}=this,n=!!i?.open,o=this.createCalciteAction({icon:i?.icon??"ellipsis",text:this.messages?.menu??"",slot:"trigger"}),s=document.createElement("calcite-dropdown");if(s.maxItems=i?.maxItems??4,s.placement="top-end",s.scale=i?.scale??"m",n&&(s.open=n,this._menuIsOpen=!0),s.appendChild(o),s.addEventListener("calciteDropdownOpen",()=>this._menuIsOpen=!0),s.addEventListener("calciteDropdownClose",()=>this._menuIsOpen=!1),s.onkeydown=this._stopPropagationOnSelect,s.addEventListener("mousewheel",e=>{e.stopPropagation()}),t.length){const e=s.appendChild(document.createElement("calcite-dropdown-group"));e.selectionMode="none",e.append(...t)}if(e.length){const t=s.appendChild(document.createElement("calcite-dropdown-group"));t.selectionMode=i?.selectionMode??"none",t.append(...e)}return s}get menuItems(){return[...this.defaultMenuItems,...this.customMenuItems]}get menuIsOpen(){return this._menuIsOpen}get menuIsVisible(){return!(!1===this.visibleElements?.columnMenus||!this.menuItems.length)}closeMenu(){this.menu.open=!1}createSortElement(){const{effectiveLabel:e,direction:t,fieldName:i,initialSortPriority:n}=this,o=document.createElement("vaadin-grid-sorter");return o.classList.add(c.sorter),o.setAttribute("path",i),o.setAttribute("title",this.labelTooltipText||e),o.textContent=e,t&&o.setAttribute("direction",t),null!=n&&(o._initialOrder=n),o.addEventListener("direction-changed",()=>{this.direction!==o.direction&&this._set("direction",o.direction)}),o}createCalciteAction(e){const t=document.createElement("calcite-action"),{alignment:i,appearance:n,className:o,disabled:s,icon:r,label:l,scale:a,slot:c,text:d,textEnabled:p,onclick:u}=e;return t.alignment=i??"center",t.appearance=n??"transparent",t.className=o??"",t.disabled=!!s,t.icon=r??"",t.label=l??"",t.scale=a??"s",t.slot=c??"",t.text=t.title=d??"",t.textEnabled=!!p,t.onclick=u??null,t}createCalciteButton(e){const t=document.createElement("calcite-button"),{alignment:i,appearance:n,className:o,disabled:s,iconEnd:r,iconFlipRtl:l,kind:a,loading:c,onclick:d,scale:p,textContent:u,title:m,width:h}=e;return t.alignment=i??"center",t.className=o??"",t.scale=p??"s",t.appearance=n??"transparent",t.disabled=!!s,t.iconEnd=r??"",l&&(t.iconFlipRtl=l),t.kind=a??"brand",t.loading=!!c,t.textContent=u??"",m&&(t.title=m),t.width=h??"auto",t.onclick=d??null,t}createCalciteDropdownItem(e){const t=document.createElement("calcite-dropdown-item"),{disabled:i,hidden:n,iconClass:o,iconStart:s,textContent:r,onclick:l,selected:a}=e,d=r??"";if(o&&!s){const e=document.createElement("span"),i=document.createElement("span");i.classList.add(c.headerMenuIcon,o),e.textContent=e.title=d,e.insertBefore(i,e.firstChild),t.appendChild(e)}else t.iconStart=s??"",t.textContent=t.title=d;return t.disabled=!!i,t.hidden="function"==typeof n?n():!!n,t.selected=!!a,l&&(t.addEventListener("calciteDropdownItemSelect",l),t.onkeydown=this._stopPropagationOnSelect),t}createCalciteIcon(e){const{effectiveLabel:t}=this,{icon:i,scale:n,textLabel:o}=e,s=document.createElement("calcite-icon"),r=o??t;return s.icon=i,s.scale=n??"s",s.textLabel=r,s.title=r,s}createHeaderContent(){const{effectiveDescription:e,effectiveLabel:t,iconNode:i}=this,n=document.createElement("div");if(n.classList.add(c.headerContent),i&&n.appendChild(i),!this._headerRequiresTextContainer)return n;const o=n.appendChild(document.createElement("div"));return this.effectiveSortable?o.appendChild(this.sortElement):""!==t&&o.appendChild(this._createHeaderTextElement({label:t,cssClass:c.headerLabel,title:this.labelTooltipText})),null!=e&&!1!==this.visibleElements?.columnDescriptions&&o.appendChild(this._createHeaderTextElement({label:e,cssClass:c.headerDescription})),this.menuIsVisible&&n.appendChild(this.menu),n}getCellValue(e){return e?.item.feature.attributes?.[this.fieldName]}getVirtualRowIndex(e){const t=this.grid?.getRowContainingNode(e);return t?.parentElement?[...t.parentElement.children].indexOf(t):-1}removeCellContent(e){if(e&&e.firstChild)try{for(;e?.firstChild;)e?.removeChild(e.firstChild)}catch(t){}}openMenu(){this.menuIsVisible&&(this.menu.open=!0,u(this.menuItems[0]))}sanitizeContent(e){return s.sanitize(e)}sanitizeLabel(e){return null==e||""===e?"":r.sanitize(e.toString()).replaceAll(m," ")}sort(){this.effectiveSortable&&this.sortElement?.click()}_stopPropagationOnSelect(e){"Enter"!==e.key&&" "!==e.key||e.stopPropagation()}_createHeaderTextElement({cssClass:e,label:t,title:i}){const n=document.createElement("span");n.classList.add(e);const o=n.appendChild(document.createElement("span"));return o.textContent=t,o.setAttribute("title",i||t),n}};e([l()],h.prototype,"_headerRequiresTextContainer",null),e([l()],h.prototype,"_menuIsOpen",void 0),e([l()],h.prototype,"autoWidth",void 0),e([l()],h.prototype,"cellValueFormatFunction",void 0),e([l()],h.prototype,"customMenuItems",null),e([l()],h.prototype,"defaultMenuItems",null),e([l()],h.prototype,"description",void 0),e([l()],h.prototype,"direction",void 0),e([l()],h.prototype,"effectiveDescription",null),e([l()],h.prototype,"effectiveLabel",null),e([l()],h.prototype,"effectiveSortable",null),e([l({constructOnly:!0})],h.prototype,"fieldName",void 0),e([l()],h.prototype,"flexGrow",void 0),e([l()],h.prototype,"footerRenderFunction",void 0),e([l()],h.prototype,"formatFunction",void 0),e([l()],h.prototype,"frozen",void 0),e([l()],h.prototype,"frozenToEnd",void 0),e([l()],h.prototype,"grid",void 0),e([l()],h.prototype,"iconNode",null),e([l()],h.prototype,"invalid",null),e([l()],h.prototype,"headerRenderFunction",void 0),e([l()],h.prototype,"hidden",void 0),e([l()],h.prototype,"icon",void 0),e([l()],h.prototype,"iconText",void 0),e([l({constructOnly:!0})],h.prototype,"initialSortPriority",void 0),e([l()],h.prototype,"label",void 0),e([l()],h.prototype,"labelTooltipText",void 0),e([l()],h.prototype,"menu",null),e([l()],h.prototype,"menuItems",null),e([l()],h.prototype,"menuConfig",void 0),e([l()],h.prototype,"menuIsOpen",null),e([l()],h.prototype,"menuIsVisible",null),e([l()],h.prototype,"messages",void 0),e([l()],h.prototype,"messagesCommon",void 0),e([l()],h.prototype,"messagesURIUtils",void 0),e([l()],h.prototype,"renderFunction",void 0),e([l()],h.prototype,"resizable",void 0),e([l()],h.prototype,"sortable",void 0),e([l({readOnly:!0})],h.prototype,"sortElement",void 0),e([l()],h.prototype,"store",void 0),e([l()],h.prototype,"tableTimeZone",void 0),e([l()],h.prototype,"textAlign",void 0),e([l()],h.prototype,"textWrap",void 0),e([l()],h.prototype,"timeZone",void 0),e([l()],h.prototype,"visibleElements",void 0),e([l()],h.prototype,"width",void 0),h=e([a("esri.widgets.FeatureTable.Grid.Column")],h);const f=h;export{f as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as a,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import{EventedMixin as c}from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as d}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as p}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as v,waitTick as w}from"../../core/promiseUtils.js";import f from"../../core/ReactiveMap.js";import{whenOnce as F,on as _,watch as b,syncAndInitial as M,initial as I}from"../../core/reactiveUtils.js";import{sqlAnd as P}from"../../core/sql.js";import{getMetersPerUnitForSR as V}from"../../core/unitUtils.js";import{property as S}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{isSerializable as A}from"../../core/support/jsonUtils.js";import{UpdatingHandles as C}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import{union as G}from"../../geometry/geometryEngineAsync.js";import T from"../../geometry/Multipoint.js";import O from"../../geometry/Point.js";import R from"../../geometry/Polygon.js";import j from"../../geometry/Polyline.js";import{projectWithZConversion as B}from"../../geometry/projectionUtils.js";import H from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as x}from"../../geometry/support/centroid.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as D}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as z}from"../../geometry/support/webMercatorUtils.js";import U from"../../layers/GraphicsLayer.js";import N from"../../layers/MediaLayer.js";import{searchImages as W,getSortedLayerFeatures as q}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as $}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as J,computePolygonForInspection as Z,resizePolygon as K,checkIfPolygonContainsSelectedPoint as Q}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as X}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{convertGeographicToWebMercator as Y}from"../../layers/orientedImagery/core/utils.js";import{imageToWorld as ee,imageToWorldPanoramic as te}from"../../layers/orientedImagery/transformations/imageToWorld.js";import ae from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as ie}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as re,getInitialAngle as se,convertPixelToHeadingPitch as oe,convertHeadingPitchToSphereVertex as ne,getImageToWorldProperties as ce,getUpdateElevationProps as le,isElevationSampler as he,getImageToWorldPanoramicProperties as ue,pointToArray as de,transformGraphicCoordinatesToPixel as me,getWorldToImageProperties as pe}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as ge,worldToImagePanoramic as ye}from"../../layers/orientedImagery/transformations/worldToImage.js";import ve from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as we}from"../../layers/support/floorFilterUtils.js";import fe from"../../layers/support/VideoElement.js";import Fe from"../../views/MapView.js";import _e from"../../views/draw/Draw.js";import{scale as be}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as Me}from"../../views/input/InputManager.js";import Ie from"../PanoramicVideoViewer.js";import Pe from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as Ve,videoExtent as Se,invalidCameraHeading as ke,sectorsInOrder as Ae,sampleExtent as Ce,sectorsRadii as Le}from"./constants.js";import{configureSketchTool as Ge,extractFieldsFromDataCaptureLayer as Te,isValidDataCaptureLayer as Oe,constructGraphicFromImageGeometry as Re}from"./dataCaptureUtils.js";import{isFeatureAttachment as je,getImageSourceFromAttachment as Be}from"./galleryUtils.js";import{getModeCorrectedPoint as He,calculateCorrectedPixel as xe,getUnitRateFromSpatialReference as Ee,calculateHeightFromTemporaryDistance as De,getModeCorrectedPoints as ze,computeTriangulatedVector as Ue,computeTriangulatedPoint as Ne}from"./imageMeasurementUtils.js";import{crossSymbol as We,crossSymbol3D as qe,measurementPolygonSymbol as $e,polylineSymbolPanoramic as Je,measurementPolylineSymbol as Ze,cameraOverlaySymbol3D as Ke,cameraOverlaySymbol as Qe,diamondSymbol as Xe,diamondSymbol3D as Ye,locationSymbol as et,locationSymbol3D as tt,activeSourcePointSymbol as at,sourcePointSymbol as it}from"./symbols.js";import{isNoAttachmentError as rt,getContentType as st,isTifOrMrf as ot,filterOILLayerView as nt,assignElevationSampleToFeatures as ct,calculateDirection as lt,calculateSegment as ht,isSceneView as ut,isGraphic as dt}from"./utils.js";import{disableVideoZoomAndPan as mt}from"./videoViewerUtils.js";import pt from"./components/ImageViewer.js";import gt from"./components/NavigationNode.js";import yt from"./components/OrientedImageryVideoViewModel.js";import{NoActiveViewerError as vt,NoFeatureFoundWithObjectIdError as wt}from"./navigation/errors.js";import{queryFeatureByObjectIds as ft}from"./navigation/queries.js";import{ImageMeasurementService as Ft}from"./services/ImageMeasurementService.js";import _t from"../Sketch/SketchViewModel.js";const bt={click:"view-click",imageClick:"image-click",triangularImageClick:"triangular-click",interactionHandles:"interaction-handles",hittestHandles:"hittest-handles",videoPlayerHandles:"video-handles",activeViewerCursorHandles:"active-viewer-cursor-handles",imageViewerCursorHandles:"image-viewer-cursor-handles"},Mt=new Set(["JPG","JPEG","TIFF","TIF","MRF"]),It=new Set(["MRF","TIFF","TIF"]),Pt=/\.(\w+)$/,Vt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let St=class extends(c(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=Ve,this.cameraPitchThreshold=Ve,this.clickAction="hittest",this.videoViewModel=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.depthImage=null,this.directionMode="Relative",this.featureCache=[],this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadDepthImage(a),await this._loadImage(a)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,a)=>{if(this.view?.closePopup(),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(a)}catch(i){y(i)||(this.loadImageError(i),u.getLogger(this).error("#loadIImage()","error occured while loading image",i))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.imageMeasurementViewer=new pt,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.measurementVectors=[],this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new f,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t)=>{"default"===this.mode&&"image-loaded"!==this.state||this.mode.includes("video")&&!this.videoElement?.content||await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new Fe({map:new Map}),this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new pt,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._measurementService=null,this._correctedLocationPointOnImage=null,this._overlays=new U({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._panoramicVideoViewer=new Ie,this._panoramicViewer=new Pe,this._panoramicMeasurementViewer=new Pe,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._featureToSector=null,this._updatingHandles=new C,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.addUpdatingPromise=e=>this._updatingHandles.addPromise(e),this.filterCapturedFeatures=e=>{const t=this.currentBestFeature?.attributes.objectId,a=this.layer?.imageReferenceField;if(!t||!e||!a)return;const i=this.overlayedMapFeatures.get(e);i?.forEach(e=>{const i=e.attributes??{},r=Object.keys(i).find(e=>e.toLowerCase()===a.toLowerCase());(r?i[r]: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:a}=await t;return v(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.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 a=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(a)this.currentBestFeature=a;else{const{layer:a,layerFloorFilterClause:r}=this;if(!a)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const s=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(a,e,r,t));try{await s,await this.selectBestFeature(e,t)}catch(i){y(i)||(u.getLogger(this).error("oriented-imagery-viewer:show-image",i),"NoFeatureFoundWithObjectIdError"===i.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",i.message))}}},this.imageToImageTransform=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await ee(e,r,i);return ge(n,o)},this.imageToImageTransformPanoramic=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await te(e,r,i);return ye(n,o)},this.getSectorFeatureById=e=>this._suitabilities?.find(({feature:{attributes:{objectId:t}}})=>t===e),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{activeViewer:a}=this;if(!a)throw new vt;return await a.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(v(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),F(()=>"image-loaded"===this.state,t)),this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r(async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,c=new t({geometry:n,attributes:o.toJSON(),layer:r,sourceLayer:r});v(e),await s.openPopup({features:[c],location:o.location.clone()})})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const a=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(a,t),this._groupFeaturesBySectors()},this._createViewClickHandle=()=>{if(this.removeHandles(bt.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,Me.WIDGET),bt.click)},this._createImageClickHandle=()=>{this.removeHandles(bt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;const n=a.clickAction;this.clickAction="pixel-location";const c=l(()=>{this.clickAction=n});let h=null;const u=_(()=>a,"pixel-location",e=>{this.plotReferencePointOnImage(e),h?.abort(),h=r(async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then(e=>{const t=this.view?.spatialReference;return re(!t,e.spatialReference.equals(t))?e:B(e,t)});v(a),this.plotReferencePointOnGround(r)})});this.addHandles([u,c],bt.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(bt.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),bt.triangularImageClick)},this._createTriangularImageLocationHandle=()=>{this.removeHandles(bt.triangularImageClick);const{imageLocationToolState:e,mode:t,activeTriangulatedViewer:a}=this,i=a?.imageSize;if(!e||"none"===t||!i)return;this.clickAction="pixel-location";let s=null;const o=_(()=>a,"pixel-location",e=>{1===this.measurementVectors.length&&(this.plotLocationPointOnImage(e,!0),s?.abort(),s=r(async a=>{if(!e||this.triangulatedPoint||2===this.measurementVectors?.length||!this.currentBestFeatureMeasurementImage)return;let r=await this.getMapPoint(e,{feature:this.currentBestFeatureMeasurementImage,imageSize:i,mode:t});v(a);const s=this.currentBestFeatureMeasurementImage.geometry.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await B(r,s),v(a)),await this._calculateTriangulatedPointFromGroundPoint(r,{signal:a}),v(a)}))});this.addHandles(o,bt.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(bt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;this.clickAction="pixel-location";let n=null;const c=_(()=>a,"pixel-location",e=>{const{currentBestFeatureMeasurementImage:a,triangularMeasurementActive:s,activeTriangulatedViewer:c}=this;this.pixelCoordinates=e;const l=null!=a&&!c?.state.includes("loading");re(!s,l)&&this.plotLocationPointOnImage(e),n?.abort(),n=r(async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});v(a);const n=this.view?.spatialReference;n&&!r.spatialReference.equals(n)&&(r=await B(r,n),v(a)),this.groundCoordinates=r,s&&r&&l&&await this.triangulatedLocationWorkflow(r,a);const c=await this.calculateLocationAccuracy(e,r,t,a);v(a),c&&(this.groundCoordinatesAccuracy=c)})});this.addHandles(c,bt.imageClick)},this._handleImageHitTestResponse=async e=>{const{layer:t,overlayedCameraLocations:a}=this;if(!t)return;const i=e.results.find(({graphic:e,graphic:{attributes:i}})=>a.includes(e)&&i&&!i[t.imageReferenceField]&&!i[t.imageGeometryField]);if(!i)return;const r=i.graphic.attributes[t.objectIdField];await this.showImageByObjectId(r)},this._loadDepthImage=async e=>{const{currentBestFeature:t,layer:a,depthImageNotSupported:i}=this;if(this.depthImage?.destroy(),this.depthImage=null,!a||!t||i)return;const{depthImage:r}=t.attributes;if(!r)return;const s=(await import("./services/DepthImageService.js")).default;v(e),this.depthImage=new s({url:r});try{await this.depthImage.load(e)}catch(o){y(o)||(u.getLogger(this).error("error occurred while loading depth image",o),this.depthImage?.destroy(),this.depthImage=null)}},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new O(m);let w=s;if(je(s))try{w=await Be(a,h,e)}catch(f){if(y(f))return;return rt(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(f){y(f)||this.loadImageError(f)}},this._loadVideo=async e=>{const{currentBestFeature:t,layer:a,mode:i,selectedPoint:r}=this,s=t?.attributes.imagePath;if(!a||!t||"panoramic-video"!==i||!s)return;const{attributes:o}=t,{cameraHeading:n,cameraPitch:c,cameraOrientation:l,location:h}=o,u=h.spatialReference.isWGS84&&4!==l?.type?z(h):new O(h);try{this._panoramicVideoViewer.viewModel.video&&this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.videoSource=s;let t=n??0;u&&r&&(t=await se(u,r)-t),this._panoramicVideoViewer.pitch=c??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),v(e)}catch(d){y(d)||this.loadImageError(d)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:c}=new URL(o);let l=s?n.match(Pt)?.[1]:e.datasetFormat;if(!l)try{l=await st(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(l??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,l,o,c,i,r):await this._setImageSource(this._imageViewer,l,o,c,i,r);break;case"panoramic":if(Mt.has(l.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t,c=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;let h=i??0;"number"==typeof n?h=n-h:s&&e&&(h=await se(s,e)-h),c.imageSource=o,c.pitch=a??0,c.yaw=h,It.has(l.toUpperCase())?await c.loadImageTiled(o,r):await c.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:l});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:i}=this;if(this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new O(m);let w=s;if(je(s))try{w=await Be(a,h,e)}catch(f){if(y(f))return;return rt(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e)}catch(f){y(f)||this.loadImageError(f)}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");v(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");v(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{if(e.stopPropagation(),e.preventDefault(),e.mapPoint){const t=e.mapPoint;t.x=D(t.x,t.spatialReference),this.plotMapPoint(e.mapPoint)}},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:i,triangulatedMeasurementGraphic:r}=this;t&&a&&i&&r&&"active"!==t.state&&(t.update([r],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r(async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))})},this.plotSelectedPointOnImage=async(e,a)=>{if(await w(a),!e)return;const i=new O({...A(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:We}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._crossSymbol=new t({geometry:new O(n,H.WebMercator),symbol:qe}),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)},I),b(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},I),b(()=>[this.state,this.mapImageConversionToolState,this.view],()=>{this._createViewClickHandle(),this._createImageClickHandle()},M),b(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},M),b(()=>[this.state,this.imageLocationToolState,this.view],(e,t)=>{if(this._initializeMeasurementService(),this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();e[1]!==t?.[1]&&this._setMeasurementCursor()},M),b(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},M),b(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},M),b(()=>this.currentBestFeature,async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r(async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}])),await this._featureChangedTask.promise},{sync:!0}),b(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{m(this._featureChangedTask),t&&e!==t&&(this.measurementVectors=[],this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll()),this._featureChangedTask=r(async a=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:a}),v(a),this._reorderTriangularSketchLayer()})},M),b(()=>this.triangularMeasurementActive,(e,t)=>{t&&!e&&(this.measurementVectors=[],this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearImage(),this._panoramicMeasurementViewer.clearGraphics())}),b(()=>this.mode,e=>{switch(this.removeHandles(bt.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=r(async t=>{await this.updateFootprint(e,{signal:t})}))},{...M,equals:(e,t)=>a(e,t,h)}),bt.interactionHandles);break;case"video":this.addHandles(b(()=>{const{footprintExtent:e}=this;if(e)return Se},e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e,{signal:t})}))},{...M,equals:(e,t)=>a(e,t,h)}),bt.interactionHandles);break;case"panoramic":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n}=a;return e&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o]:null},e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;this.currentNode&&(this.currentNode.currentHeading=i+(this.currentNode.heading??0),this.currentNode.currentPitch=s+(this.currentNode.pitch??0)),m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),bt.interactionHandles);break;case"panoramic-video":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n,viewModel:c}=a,l=c.closestFeature??e;return l&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o,l]:null},e=>{if(!e)return;const[t,a,i,s,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s,feature:o},{signal:e}),v(e),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),bt.interactionHandles)}},M),b(()=>[this.brightness,this.contrast,this.sharpness],()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)},M),b(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),b(()=>this.activeViewer,e=>{this.removeHandles(bt.hittestHandles),e&&this.addHandles(_(()=>e,"hittest-response",this._handleImageHitTestResponse),bt.hittestHandles)})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){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._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this._referencePointOnImage=p(this._referencePointOnImage),this._locationPointOnImage=p(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy(),this._panoramicMeasurementViewer.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:a}=this;switch(a){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!ot(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 ot(t)||je(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===ke}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(nt(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?we(e):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:a,isSpherical:i}=e;return 360===a||i?"panoramic":"default"}get panoramicVideoLoaded(){const{mode:e,_panoramicVideoViewer:t}=this,{videoLoaded:a}=t.viewModel;return("panoramic-video"===e&&!0===a)??!1}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Ae.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",d(e,0,1))}get sketchGraphicsLayer(){const{sketch:e}=this;return"graphics"===e?.layer?.type?e.layer:void 0}get state(){const{mode:e,_updatingHandles:{updating:t},_featureChangedTask:a}=this;if(!this.isFulfilled()||t||!1===a?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map(({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:i}})=>{const r=e?.trim();return ot(r)||je(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null}).filter(i)):null}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new U({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new U({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}beforeLoad(e=!0){this.view?.closePopup(),e&&(this.displayMessage=null),this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._overlays?.removeAll()}async computeHeight(e,t,a=!0){return this._measurementService?.computeHeight(e,t,a)}async calculateAreaMeasurement(e,t,a){return this._measurementService?.calculateAreaMeasurement(e,t,a)}async calculateDistanceMeasurement(e,t,a){return this._measurementService?.calculateDistanceMeasurement(e,t,a)}async calculateAccuracy(e,t,a){return this._measurementService?.calculateAccuracy(e,t,a)}async calculateLocationAccuracy(e,t,a="default",i){return this._measurementService?.calculateLocationAccuracy(e,t,a,i)}async calculateAccuracyPanoramic(e,t,a){return this._measurementService?.calculateAccuracyPanoramic(e,t,a)}async calculateHeightMeasurementInfo(e,t,a){return this._measurementService?.calculateHeightMeasurementInfo(e,t,a)}async calculateTriangulatedMeasurements(e){await(this._measurementService?.calculateTriangulatedMeasurements(e))}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:a,dataCaptureLayer:i}=this;if(!a)throw Vt();Ge(i,e,a),await a.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw Vt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw Vt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw Vt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw Vt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw Vt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw Vt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t,a=!1){const i=[],r=[],s=[];return e.forEach(e=>{const{layer:{coveragePercent:o},attributes:n}=e;let c;const{polygon:l,frustum:h}=J(n);if(c=l.clone(),n.isInspection&&(c=Z(n)),o&&(c=K(c,o)),a||!t||Q(c,t)){s.push(e);const{geometry:t,objectId:a,cameraHeight:o,cameraHeading:c}=n,u=t.clone();u.z=o,u.imageID=a,this.pointSources.push(u),c!==ke&&(i.push(l),h&&r.push(h))}}),{features:s,polygons:i,frustums:r}}getMeasurementProperties(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ce(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?B(n,H.WebMercator):Promise.resolve(n)).then(e=>(n=e,le(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}getMeasurementPropertiesPanoramic(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ue(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?B(n,H.WebMercator):Promise.resolve(n)).then(e=>(n=e,le(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}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?.[Ae[e]],a=t?.at(0);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t],r=i?.at(a);r&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(r):this._updateCurrentBestFeature(r))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s,currentBestFeature:o}=this,n=s?.imageSize;if(!e.vertices||!n||!o)return;const c=He(e.vertices.at(-1),r,n);if(i.length<1||!c||!a||!t||"none"===r)return;const l=xe(i[0],c,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const h=Ee(o.attributes.location.spatialReference),u=De(this.heightMeasurementPixels,a,h);u&&(this.heightMeasurementResult=u)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=He(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!y(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=Y(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:a}=await t;v(e),this.sketch=new a({layer:this._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:a}=await t;if(v(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async loadTriangulatedMeasurementAdapter(e){if(!this.triangulatedMeasurementAdapter){const t=import("./adapters/sketch/TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(v(e),this.triangulatedMeasurementAdapter=new a({viewModel:this}),!this.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.triangulatedMeasurementAdapter}async processFeatureResponse(e,t,a){const{features:i}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(i))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t,a?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,a);v(a),await this._updateElevationOfSelectedPointAndLocations(r,t,n),v(a),ct(r,n);const c=this._processSuitableFeatures(r,t);this.updateSuitabilities(c,a?.loadBestImage)}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=$e(o),this.sketch.polylineSymbol="panoramic"===s?Je:Ze(o,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new _e({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],e=>this.handleDrawEvents(e))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[e],spatialReference:a});else{const i=new j({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:Ze(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=oe(i,a[0],a[1]),{heading:n,pitch:c}=oe(r,a[0],a[1]),l=[[...ne(s,o)],[...ne(n,c)]];if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[l],spatialReference:e});else{const a=new j({paths:[l],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:Je}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async editOverlayedGraphics(e){this.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.sketchTriangularGraphicsLayer.add(e),this.sketchTriangular||(this._initializeSketchTriangular(),await this.loadTriangulatedMeasurementAdapter()),this.updateOverlayedGeometry(e)}updateOverlayedGeometry(e){this.sketchTriangular?.update([e],{tool:"reshape"})}async processMeasurementVectors(e){this.triangularMeasurementActive&&this.currentBestFeature&&(this.measurementVectors?.length<2&&await this.updateMeasurementVectorsArray(e),2===this.measurementVectors.length&&await this.calculateTriangulatedMeasurements(e))}async updateMeasurementVectorsArray(e){const t=this.measurementVectors.length?this.currentBestFeatureMeasurementImage:this.currentBestFeature;if(t){const a=await this.computeMeasurementVector(e,t);a&&this.measurementVectors.push(a)}}async computeMeasurementVector(e,t){const{activeViewer:a,mode:i}=this,r=a?.imageSize;if(!e||!t||!r)return;const s=ze(e,i,r),o=this.view?.spatialReference,n=[];for(let c=0;c<s.length;c++){const e={x:s[c][0],y:s[c][1]};let a=await this.getMapPoint(e,{feature:t,imageSize:r,mode:i});o&&!a.spatialReference.equals(o)&&(a=await B(a,o)),n.push(a)}return Ue(n,t)}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":await this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n,layerFloorFilterClause:c}=this,l=a?.imageSize;if(!l||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:h}=J(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:P(`${s.objectIdField} <> ${i.attributes.objectId}`,P(s.definitionExpression,c)),geometry:h,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map(async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:l,mode:o}),n="panoramic"===o?Ke():Qe();return new t({attributes:a,symbol:n,geometry:s})}));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:c,layer:l}=this,h=r?.imageSize;if(!h||!o||"none"===n||"video"===n||"panoramic-video"===n||c.includes("loading")||!l)return;const{polygon:d}=J(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Te(e,l.imageGeometryField,l.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:d,returnGeometry:!0,outFields:["*"]}),p=new s((await Promise.all(m.map(async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:c}=i,l=c,{imageGeometryField:d,oiObjectIdField:m}=this;if(d&&m&&Oe(e,d,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Re(s,d,e,a,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(l?.type){case"point":{const i=await this.getPixels(l,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:c}=l,u=i.map(e=>e.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de))));return new t({attributes:s,layer:e,symbol:r,geometry:new R({rings:d,spatialReference:H.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:c}=l,u=i.map(e=>e.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({paths:d,spatialReference:H.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:c}=l,u=i.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c})),d=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de));return new t({attributes:s,layer:e,symbol:r,geometry:new T({points:d,spatialReference:H.WebMercator}),visible:e.visible&&a})}}return null}))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,p)}getDepthAt(e){const{activeViewer:t,currentBestFeature:a,mode:i,state:r,depthImage:s}=this,o=t?.imageSize;if(!o||!a||"none"===i||r.includes("loading"))return u.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!s?.loaded)return u.getLogger(this).error("oriented-imagery-viewer:get-depth-at","Depth image is not loaded"),this.emit("depth-image-service:not-loaded"),null;const n=(Array.isArray(e)?e:[e]).map(e=>s.depthAt(e,{width:o[0],height:o[1]})??null);return Array.isArray(e)?n:n[0]}async getPixels(e,t){const{imageSize:a,mode:i,feature:r}=t,s=(await this.worldToImage(Array.isArray(e)?e:[e],r)).map(e=>{if("default"===i)return new O({x:e.x-.5,y:.5-e.y,spatialReference:H.WebMercator});const[t,r]=a,{heading:s,pitch:o}=oe(e,t,r),n=ne(s,o);return new O(n,H.WebMercator)});return Array.isArray(e)?s:s[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:c,cameraHeight:l}=o;let h=c.clone();h.spatialReference.isGeographic&&(h=await B(h,H.WebMercator));const u=await le(c.spatialReference,c.z??0,l,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;"elevationSample"in u&&he(u.elevationSample)&&(a.elevationSample=u.elevationSample);const m=Array.isArray(e)?e:[e];if(this.depthImage?.loaded)for(const p of m){const e=this.getDepthAt(p);null!=e&&(p.depth=e)}if("default"===i){const e=ce(o,r[0],r[1]);d=await ee(m,{...e,cameraLocation:h},u)}else{const e=ue(o,r[0],r[1]);d=await te(m,{...e,cameraLocation:h},u)}return Array.isArray(e)?d:d[0]}getActiveSectors(){return Ae.filter(e=>this._sectorData?.[e]?.length)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new O({...e.toJSON()}),symbol:Xe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=A(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new O({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:Xe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new O(n,H.WebMercator),symbol:Ye}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e,t=!1){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(t),this.mode){case"default":this._plotLocationPointOnDefaultImage(e,t);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e,t)}}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.heightMeasurementPixels=[],this.measurementVectors=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:c}=n;return r?t.error.push(n):(a&&(c[e.objectIdField]=a),i&&e.globalIdField&&(c[e.globalIdField]=i),t.success.push(n)),t},{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s||"video"===s||"panoramic-video"===s)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const c=await Promise.all(e.map(async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,c=r.hasZ,l=r.geometryType,h=n!==l,u=h?await import("./transformers.js"):null,d=u?.default[l],m=h?d?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(me(s,m,o),{feature:a,imageSize:o,mode:s}),c||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map(async e=>this.getMapPoint(e.map(([e,t,a])=>me(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new R({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,rings:e.map(e=>e.map(de))}),t}case"polyline":{const e=await Promise.all(m.paths.map(async e=>this.getMapPoint(e.map(([e,t,a])=>me(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new j({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,paths:e.map(e=>e.map(de))}),t}}})),l=c.filter(i);return r.applyEdits({addFeatures:l}).then(e=>{const{addFeatureResults:t}=e;let a=0;const i=c.map(e=>{const i=t[a++];return e?i:{error:new n("orientedimageryviewer:save-unsucccessful","Error in saving data capture features"),objectId:null,globalId:null}});return{...e,addFeatureResults:i}})}async searchBestImage(e,t){try{const a=await W(e,t);a&&await this.processFeatureResponse(a,e.point,t)}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),u.getLogger(this).error("error occurred while finding best image",a))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find(({attributes:t})=>t.objectId===Number(e))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach(t=>{t.visible=e})}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach(t=>{t.visible=e})}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],c=[],l=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?c.push(s):l.push(s);this.overlayGraphicsOnImage(e.id,new s(l)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);v(t),h.addGraphics(c),u.savedGraphics.addMany(c);a.ui.find("zoom").visible=!1,a.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach(t=>{this._toggleVisiblity(t,e)})}toggleOverlayMapFeatures(e,t,a){const i=this.overlayedMapFeatures.get(e);i&&a&&this._toggleVisiblity(i,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{feature:t,selectedLocation:a,options:i}=e;let r=!1,s=!1;const o=this.bestFeatureFootprint?.geometry;switch(o?.type){case"polygon":{const e=a.spatialReference.equals(o.spatialReference)?a:await B(a,o.spatialReference);r=o.contains(e);break}case"mesh":{const e=a.spatialReference.equals(o.spatialReference)?a:await B(a,o.spatialReference);s=o.extent.contains(e);break}}if(!r&&!s)return void this.clearReferencePointOnImage();const n=await this.worldToImage(a,t,i);if(n)return v(i),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}async triangulatedLocationWorkflow(e,t){if(this.currentBestFeature&&e){const{currentBestFeature:a}=this;this.triangulatedPoint&&(this.measurementVectors=[],this.triangulatedPoint=null,this.clearLocationPointOnImage(!0));const i=Ue(e,a);if(!i)return;this.measurementVectors.push(i),await this.plotReferenceLocationPoint(e,t),v(t),this._createTriangularImageLocationHandle()}}async _calculateTriangulatedPointFromGroundPoint(e,t){if(this.currentBestFeatureMeasurementImage&&e){const{currentBestFeatureMeasurementImage:a}=this,i=Ue(e,a);i&&this.measurementVectors.push(i);const r=await Ne(this.measurementVectors);v(t),this.triangulatedPoint=r??this.triangulatedPoint}}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:a,invalidCameraHeading:i}=this,r=a.at(0);if(!e||!t||!r||!a||i)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const h of Ae)this._sectorData[h]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const c=n.map(({distance:e})=>e),l=Math.max(...c);n.forEach(e=>{const{distance:t,angle:i,featureIndex:s}=e,n=t/l*Le[2],c=ht(t,l),h=lt(i);if(!this._sectorData)return;const u=Le[3]+n*Math.sin(i*Math.PI/180),d=Le[3]+n*Math.cos(i*Math.PI/180);let m;const p=a.at(s),g=p===r,{cameraPitch:y}=p.attributes,v=y<5;if(g&&v)m=-90;else{const e=u-Le[3],t=d-Le[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),m=i}const w=""===c?h:`${c}_${h}`;g&&(m===this.bestFeatureAngle?this.previousFeatureAngle=m:this.bestFeatureAngle=m,this.navigatorCurrentBestFeature=v?null:{x:u,y:d,direction:h}),o[`${p.attributes.objectId}`]=w;const f=this._sectorData[w];f.add({angle:i,featureIndex:s,x:u,y:d,objectID:p.attributes.objectId,sector:w,featureIndexInSector:f.length})})}_handleDestroyedTriangularSketchLayer(){this.sketchTriangularGraphicsLayer&&this.activeTriangulatedViewer&&(this.activeTriangulatedViewer.imageRenderer.map.layers.remove(this.sketchTriangularGraphicsLayer),this.sketchTriangularGraphicsLayer=new U,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer),this.sketchTriangular&&(this.sketchTriangular.layer=this.sketchTriangularGraphicsLayer,this.sketchTriangular.view=this.activeTriangulatedViewer.imageRenderer))}_initializeMeasurementService(){this._measurementService||(this._measurementService=new Ft(this))}_initializeSketchTriangular(){if(!this.activeTriangulatedViewer)return;const e="panoramic"===this.mode;this.sketchTriangular=new _t({view:this.activeTriangulatedViewer.imageRenderer,layer:this.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1,enableZ:!e}}),e&&(this.sketchTriangular.defaultUpdateOptions.reshapeOptions={edgeOperation:"offset",shapeOperation:"move-xy",vertexOperation:"move-xy"})}_initializeSketchTriangularGraphicsLayer(){this.activeTriangulatedViewer&&(this.sketchTriangularGraphicsLayer=new U,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(bt.videoPlayerHandles),this.videoElement=new fe({video:this.currentBestFeature.attributes.imagePath,georeference:new ve({extent:new L(Ce)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new N({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.addHandles(mt(this.videoMapView),bt.videoPlayerHandles),this.videoViewModel=new yt({oiViewModel:this})}_plotLocationPointOnDefaultImage(e,a=!1){const i=A(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,a?(this._correctedLocationPointOnImage=new t({geometry:new O({spatialReference:H.WebMercator,...i}),symbol:et}),this.imageMeasurementViewer.addGraphic(this._correctedLocationPointOnImage,0)):(this._locationPointOnImage=new t({geometry:new O({spatialReference:H.WebMercator,...i}),symbol:et}),this._imageViewer.addGraphic(this._locationPointOnImage,0))}_plotLocationPointOnPanoramicImage(e,a=!1){const i=a?this._panoramicMeasurementViewer:this._panoramicViewer,{imageSize:r}=i;if(!r)return;const[s,o]=r,{heading:n,pitch:c}=oe(e,s,o),l=ne(n,c),h=new t({geometry:new O(l,H.WebMercator),symbol:tt});a?this._correctedLocationPointOnImage=h:this._locationPointOnImage=h,i.addGraphic(h,0)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.setMessage("noImageError","error"),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,a){if(!e[0])return;const i=await G(e);if(this._updateFootprintWithFeatures(t,i),"3d"===this.view?.type)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(r){y(r)||u.getLogger(this).error(r)}}async processElevationSample(e,t,a){const{elevationSource:i}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,a);return r||(i&&this.footprintExtent&&X(i)?await ie({extent:this.footprintExtent,lod:i.lod,url:i.url,rasterFunction:i.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return $({features:e,selectedPoint:t,camera:ut(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;o.x=D(o.x,o.spatialReference);const{layerFloorFilterClause:n}=this,c=e.spatialReference.equals(o.spatialReference)?o:await B(o,e.spatialReference),l=c.spatialReference.isGeographic?z(c):c,h=P("1=1",P(e.definitionExpression,n)),u=l.spatialReference.isGeographic?1:V(l.spatialReference),d={layerInstanceOrURL:e,point:l,queryParams:{where:h,maximumDistance:e.maximumDistance?e.maximumDistance/u:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(d,a)}async _queryAndLoadByObjectId(e,t,a,i){this.displayMessage=null;const{response:r}=await ft(e,t,a,i);if(v(i),!r?.features?.length)throw new wt(t);const s=J(r.features[0].attributes).polygon,o=O.fromJSON(x(s)),n=Y(o),c=V(n.spatialReference);this.selectedPoint=n;const l={layerInstanceOrURL:e,point:n,queryParams:{where:P(P("1=1",P(e.definitionExpression,a)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0}},h=await W(l,i);v(i);const{features:u}=h;return u.push(r.features[0]),await this.processFeatureResponse(h,n,{...i,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}_resetCursor(){const{activeViewer:e,imageMeasurementViewer:t}=this;e&&this.removeHandles(bt.activeViewerCursorHandles),t&&this.removeHandles(bt.imageViewerCursorHandles)}async _setImageSource(e,t,a,i,r,s){e.imageSource={datasetFormat:t.toUpperCase(),url:a.split("?")[0]},e.customParameters=Object.fromEntries(i),e.imageRotation=r??0,await e.loadImage(s)}_setMeasurementCursor(){const{activeViewer:e,imageMeasurementViewer:t,triangularMeasurementActive:a}=this;e&&this.addHandles(e.imageRenderer.acquireCursor("crosshair","high"),bt.activeViewerCursorHandles),t&&a&&this.addHandles(t.imageRenderer.acquireCursor("crosshair","high"),bt.activeViewerCursorHandles)}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,a,i){const r=he(a),{location:s,cameraHeight:o}=e[0].attributes,n=await le(s.spatialReference,s.z,o,{elevationSample:r?a:void 0,elevationSource:r?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},i);v(i);const[c,...l]=await ae([t,...e.map(e=>e.attributes.geometry.clone())],n);v(i),t.elevation=c.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:a}=e,{isSpherical:i,cameraHeading:r,cameraPitch:s}=a;return new gt({geometry:t,attributes:a,currentHeading:i?0:r,currentPitch:i?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 a=[];for(const{attributes:{geometry:i}}of e)t.contains(i)||a.push([i.x,i.y]);a.sort((e,t)=>+E([e,t])),t.addRing(a),this.footprintExtent=be(t.extent,2,2)}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),v(e);for(const e of a)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:at,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:it,visible:s}));if(("video"===o||"panoramic-video"===o)&&n&&!this.featureCache.length){const e=await q(n,i.geometry.spatialReference);e.features?.length&&(this.featureCache=e.features)}}}_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 a;if(t)a=-90;else{const t=e.x-Le[3],i=e.y-Le[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage))}clearLocationPointOnImage(e=!1){this._locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=p(this._locationPointOnImage)),this._correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this._correctedLocationPointOnImage),this._panoramicMeasurementViewer.removeGraphic(this._correctedLocationPointOnImage),this._correctedLocationPointOnImage=p(this._correctedLocationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}async plotReferenceLocationPoint(e,t){if(this.currentBestFeatureMeasurementImage){const a=await this.worldToImage(e,this.currentBestFeatureMeasurementImage,{signal:t});v(t),a&&this.plotLocationPointOnImage(a,!0)}}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,t,e),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t,a){const{footprintExtent:i}=this,{imageSize:r}=this.activeViewer;if("none"===this.mode||!t||!r||!i)return;const{attributes:{location:s,elevationSource:o,cameraHeading:n,cameraHeight:c},elevationSample:l}=t;let h=s.clone();const u=await le(s.spatialReference,s.z??0,c,{elevationSample:l,elevationSource:o});t.elevationSample=u.elevationSample;const d=Array.isArray(e)?e:[e];let m,p=await Promise.all(d.map(e=>new Promise(t=>{if(!e.hasZ)return t(ae(e,u));t(e)})));if(s.spatialReference.isGeographic&&(h=await B(h,H.WebMercator,a)),p=await Promise.all(p.map(async e=>h.spatialReference.equals(e.spatialReference)?e:await B(e,h.spatialReference,a))),v(a),"panoramic"===this.mode)m=ye(p,{imageHeight:r[1],imageWidth:r[0],cameraHeading:n,cameraLocation:h});else{const e=pe(t.attributes,r[0],r[1]);m=ge(p,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:c,_adapter:l,mode:h}=this;if(!r)return;const{attributes:{objectId:u},elevationSample:d}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),c){const e=[...a,...i,s].filter(dt);"3d"===c?.type&&d&&l?.updateGroundElevation&&(this._updateGroundElevation&&l.updateGroundElevation(e,d),"panoramic"===h&&l.updateGroundElevation([this.bestFeatureCurrentFootprint],d)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:We.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(c){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,"3d"===c?.type&&d&&l?.updateGroundElevation&&"panoramic"===h&&l.updateGroundElevation([e],d),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],St.prototype,"activeLayer",null),e([S({readOnly:!0})],St.prototype,"activeViewer",null),e([S()],St.prototype,"activeTriangulatedViewer",null),e([S()],St.prototype,"accuracyParametersMissing",null),e([S()],St.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],St.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],St.prototype,"additionalFootprints",void 0),e([S()],St.prototype,"areaMeasurementResult",void 0),e([S()],St.prototype,"areaMeasurementAccuracy",void 0),e([S()],St.prototype,"bestFeatureAngle",void 0),e([S()],St.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],St.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],St.prototype,"brightness",null),e([S()],St.prototype,"cameraHeadingThreshold",void 0),e([S()],St.prototype,"cameraPitchThreshold",void 0),e([S()],St.prototype,"clickAction",void 0),e([S()],St.prototype,"videoViewModel",void 0),e([S()],St.prototype,"collectionId",void 0),e([S({type:Number})],St.prototype,"contrast",null),e([S()],St.prototype,"conversionProps",void 0),e([S()],St.prototype,"coverageFrustums",void 0),e([S()],St.prototype,"coveragePolygons",void 0),e([S()],St.prototype,"currentBestFeature",void 0),e([S()],St.prototype,"currentBestFeatureMeasurementImage",void 0),e([S()],St.prototype,"currentBestFeatureLocation",void 0),e([S()],St.prototype,"currentCoverageVisible",void 0),e([S()],St.prototype,"currentNode",null),e([S()],St.prototype,"depthImage",void 0),e([S()],St.prototype,"depthImageNotSupported",null),e([S()],St.prototype,"directionMode",void 0),e([S()],St.prototype,"featureCache",void 0),e([S()],St.prototype,"navigationNodes",void 0),e([S({json:{write:!1}})],St.prototype,"determineWorkflowForFeature",void 0),e([S({json:{write:!1}})],St.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([S()],St.prototype,"disabled",void 0),e([S()],St.prototype,"displayMessage",void 0),e([S()],St.prototype,"displayNewMeasurementButton",void 0),e([S()],St.prototype,"distanceMeasurementResult",void 0),e([S()],St.prototype,"distanceAccuracyArray",void 0),e([S()],St.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],St.prototype,"featureCount",null),e([S()],St.prototype,"features",void 0),e([S()],St.prototype,"groundCoordinates",void 0),e([S()],St.prototype,"groundCoordinatesAccuracy",void 0),e([S()],St.prototype,"heightMeasurementPixels",void 0),e([S()],St.prototype,"heightGraphic",void 0),e([S()],St.prototype,"heightMeasurementResult",void 0),e([S()],St.prototype,"heightMeasurementAccuracy",void 0),e([S()],St.prototype,"measurementAngle",void 0),e([S()],St.prototype,"tempDistance",void 0),e([S({readOnly:!0})],St.prototype,"imageGalleryEnabled",null),e([S()],St.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],St.prototype,"imageLoaded",null),e([S()],St.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],St.prototype,"invalidCameraHeading",null),e([S()],St.prototype,"imagePointsInView",null),e([S()],St.prototype,"imageMeasurementViewer",void 0),e([S()],St.prototype,"isAdditionalCoverageVisible",void 0),e([S()],St.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],St.prototype,"measurementVectors",void 0),e([S()],St.prototype,"layer",void 0),e([S()],St.prototype,"layerView",null),e([S({readOnly:!0})],St.prototype,"layerFloorFilterClause",null),e([S({type:Number})],St.prototype,"localPort",void 0),e([S()],St.prototype,"mapImageConversionToolState",void 0),e([S()],St.prototype,"measureType",void 0),e([S()],St.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],St.prototype,"mode",null),e([S()],St.prototype,"navigationMode",void 0),e([S()],St.prototype,"navigatorCurrentBestFeature",void 0),e([S()],St.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],St.prototype,"overlayedCameraLocations",void 0),e([S()],St.prototype,"overlayedMapFeatures",void 0),e([S()],St.prototype,"panoramicVideoLoaded",null),e([S()],St.prototype,"pixelCoordinates",void 0),e([S()],St.prototype,"preserveAngle",void 0),e([S()],St.prototype,"pointSources",void 0),e([S({readOnly:!0})],St.prototype,"popupEnabled",null),e([S()],St.prototype,"previousFeatureAngle",void 0),e([S()],St.prototype,"referencePoint",null),e([S({readOnly:!0})],St.prototype,"sectorData",null),e([S()],St.prototype,"selectedPoint",void 0),e([S({type:Number})],St.prototype,"sharpness",null),e([S()],St.prototype,"shouldShowSelectedImage",void 0),e([S()],St.prototype,"sketch",void 0),e([S()],St.prototype,"sketchTriangular",void 0),e([S()],St.prototype,"sketchTriangularGraphicsLayer",void 0),e([S()],St.prototype,"draw",void 0),e([S()],St.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],St.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],St.prototype,"state",null),e([S({readOnly:!0})],St.prototype,"thumbnails",null),e([S()],St.prototype,"triangularMeasurementActive",void 0),e([S()],St.prototype,"triangulatedDistanceMeasurement",void 0),e([S()],St.prototype,"triangulatedDistanceAccuracy",void 0),e([S()],St.prototype,"triangulatedAreaMeasurement",void 0),e([S()],St.prototype,"triangulatedAreaAccuracy",void 0),e([S()],St.prototype,"triangulatedMeasurementGraphic",void 0),e([S()],St.prototype,"triangulatedPoint",void 0),e([S()],St.prototype,"triangulatedMeasurementAdapter",void 0),e([S()],St.prototype,"updateFootprint",void 0),e([S()],St.prototype,"updateFootprintPanorama",void 0),e([S()],St.prototype,"updatingTriangularMeasurementState",void 0),e([S({value:null})],St.prototype,"view",null),e([S()],St.prototype,"videoElement",void 0),e([S()],St.prototype,"videoLayer",void 0),e([S()],St.prototype,"videoMapView",void 0),e([S()],St.prototype,"_adapter",void 0),e([S()],St.prototype,"_defaultGraphicsLayer",null),e([S()],St.prototype,"_highlightedFeatureHandle",void 0),e([S()],St.prototype,"_imageViewer",void 0),e([S()],St.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],St.prototype,"_locationPointOnImage",void 0),e([S()],St.prototype,"_measurementService",void 0),e([S()],St.prototype,"_correctedLocationPointOnImage",void 0),e([S()],St.prototype,"_overlays",void 0),e([S({readOnly:!0})],St.prototype,"_overlaysView",null),e([S()],St.prototype,"_panoramicVideoViewer",void 0),e([S()],St.prototype,"_panoramicViewer",void 0),e([S()],St.prototype,"_panoramicMeasurementViewer",void 0),e([S()],St.prototype,"_referencePointOnGround",void 0),e([S()],St.prototype,"_referencePointOnImage",void 0),e([S()],St.prototype,"_sectorData",void 0),e([S()],St.prototype,"_featureToSector",void 0),e([S({readOnly:!0})],St.prototype,"_updatingHandles",void 0),e([S()],St.prototype,"footprintExtent",void 0),e([S()],St.prototype,"_featureChangedTask",void 0),St=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],St);const kt=St;export{kt as default};
5
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as a,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import{EventedMixin as c}from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as d}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as p}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as v,waitTick as w}from"../../core/promiseUtils.js";import f from"../../core/ReactiveMap.js";import{whenOnce as F,on as _,watch as b,syncAndInitial as M,initial as I}from"../../core/reactiveUtils.js";import{sqlAnd as P}from"../../core/sql.js";import{getMetersPerUnitForSR as V}from"../../core/unitUtils.js";import{property as S}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{isSerializable as A}from"../../core/support/jsonUtils.js";import{UpdatingHandles as C}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import{union as G}from"../../geometry/geometryEngineAsync.js";import T from"../../geometry/Multipoint.js";import O from"../../geometry/Point.js";import R from"../../geometry/Polygon.js";import j from"../../geometry/Polyline.js";import{projectWithZConversion as B}from"../../geometry/projectionUtils.js";import x from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as H}from"../../geometry/support/centroid.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as D}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as z}from"../../geometry/support/webMercatorUtils.js";import U from"../../layers/GraphicsLayer.js";import N from"../../layers/MediaLayer.js";import{searchImages as W,getSortedLayerFeatures as q}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as $}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as J,computePolygonForInspection as Z,resizePolygon as K,checkIfPolygonContainsSelectedPoint as Q}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as X}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{convertGeographicToWebMercator as Y}from"../../layers/orientedImagery/core/utils.js";import{imageToWorld as ee,imageToWorldPanoramic as te}from"../../layers/orientedImagery/transformations/imageToWorld.js";import ae from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as ie}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as re,getInitialAngle as se,convertPixelToHeadingPitch as oe,convertHeadingPitchToSphereVertex as ne,getImageToWorldProperties as ce,getUpdateElevationProps as le,isElevationSampler as he,getImageToWorldPanoramicProperties as ue,pointToArray as de,transformGraphicCoordinatesToPixel as me,getWorldToImageProperties as pe}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as ge,worldToImagePanoramic as ye}from"../../layers/orientedImagery/transformations/worldToImage.js";import ve from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as we}from"../../layers/support/floorFilterUtils.js";import fe from"../../layers/support/VideoElement.js";import Fe from"../../views/MapView.js";import _e from"../../views/draw/Draw.js";import{scale as be}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as Me}from"../../views/input/InputManager.js";import Ie from"../PanoramicVideoViewer.js";import Pe from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as Ve,videoExtent as Se,invalidCameraHeading as ke,sectorsInOrder as Ae,sampleExtent as Ce,sectorsRadii as Le}from"./constants.js";import{configureSketchTool as Ge,extractFieldsFromDataCaptureLayer as Te,isValidDataCaptureLayer as Oe,constructGraphicFromImageGeometry as Re}from"./dataCaptureUtils.js";import{isFeatureAttachment as je,getImageSourceFromAttachment as Be}from"./galleryUtils.js";import{getModeCorrectedPoint as xe,calculateCorrectedPixel as He,getUnitRateFromSpatialReference as Ee,calculateHeightFromTemporaryDistance as De,getModeCorrectedPoints as ze,computeTriangulatedVector as Ue,computeTriangulatedPoint as Ne}from"./imageMeasurementUtils.js";import{crossSymbol as We,crossSymbol3D as qe,measurementPolygonSymbol as $e,polylineSymbolPanoramic as Je,measurementPolylineSymbol as Ze,cameraOverlaySymbol3D as Ke,cameraOverlaySymbol as Qe,diamondSymbol as Xe,diamondSymbol3D as Ye,locationSymbol as et,locationSymbol3D as tt,activeSourcePointSymbol as at,sourcePointSymbol as it}from"./symbols.js";import{isNoAttachmentError as rt,getContentType as st,isTifOrMrf as ot,filterOILLayerView as nt,assignElevationSampleToFeatures as ct,calculateDirection as lt,calculateSegment as ht,isSceneView as ut,isGraphic as dt}from"./utils.js";import{disableVideoZoomAndPan as mt}from"./videoViewerUtils.js";import pt from"./components/ImageViewer.js";import gt from"./components/NavigationNode.js";import yt from"./components/OrientedImageryVideoViewModel.js";import{NoActiveViewerError as vt,NoFeatureFoundWithObjectIdError as wt}from"./navigation/errors.js";import{queryFeatureByObjectIds as ft}from"./navigation/queries.js";import{ImageMeasurementService as Ft}from"./services/ImageMeasurementService.js";import _t from"../Sketch/SketchViewModel.js";const bt={click:"view-click",imageClick:"image-click",triangularImageClick:"triangular-click",interactionHandles:"interaction-handles",hittestHandles:"hittest-handles",videoPlayerHandles:"video-handles",activeViewerCursorHandles:"active-viewer-cursor-handles",imageViewerCursorHandles:"image-viewer-cursor-handles"},Mt=new Set(["JPG","JPEG","TIFF","TIF","MRF"]),It=new Set(["MRF","TIFF","TIF"]),Pt=/\.(\w+)$/,Vt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let St=class extends(c(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=Ve,this.cameraPitchThreshold=Ve,this.clickAction="hittest",this.videoViewModel=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.depthImage=null,this.directionMode="Relative",this.featureCache=[],this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadDepthImage(a),await this._loadImage(a)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,a)=>{if(this.view?.closePopup(),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(a)}catch(i){y(i)||(this.loadImageError(i),u.getLogger(this).error("#loadIImage()","error occured while loading image",i))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.imageMeasurementViewer=new pt,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.measurementVectors=[],this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new f,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t,a)=>{"default"===this.mode&&"image-loaded"!==this.state||this.mode.includes("video")&&!this.videoElement?.content||await(this._adapter?.updateFootprint(e,t,a))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new Fe({map:new Map}),this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new pt,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._measurementService=null,this._correctedLocationPointOnImage=null,this._overlays=new U({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._panoramicVideoViewer=new Ie,this._panoramicViewer=new Pe,this._panoramicMeasurementViewer=new Pe,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._featureToSector=null,this._updatingHandles=new C,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.addUpdatingPromise=e=>this._updatingHandles.addPromise(e),this.filterCapturedFeatures=e=>{const t=this.currentBestFeature?.attributes.objectId,a=this.layer?.imageReferenceField;if(!t||!e||!a)return;const i=this.overlayedMapFeatures.get(e);i?.forEach(e=>{const i=e.attributes??{},r=Object.keys(i).find(e=>e.toLowerCase()===a.toLowerCase());(r?i[r]: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:a}=await t;return v(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.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 a=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(a)this.currentBestFeature=a;else{const{layer:a,layerFloorFilterClause:r}=this;if(!a)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const s=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(a,e,r,t));try{await s,await this.selectBestFeature(e,t)}catch(i){y(i)||(u.getLogger(this).error("oriented-imagery-viewer:show-image",i),"NoFeatureFoundWithObjectIdError"===i.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",i.message))}}},this.imageToImageTransform=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await ee(e,r,i);return ge(n,o)},this.imageToImageTransformPanoramic=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await te(e,r,i);return ye(n,o)},this.getSectorFeatureById=e=>this._suitabilities?.find(({feature:{attributes:{objectId:t}}})=>t===e),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{activeViewer:a}=this;if(!a)throw new vt;return await a.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(v(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),F(()=>"image-loaded"===this.state,t)),this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r(async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,c=new t({geometry:n,attributes:o.toJSON(),layer:r,sourceLayer:r});v(e),await s.openPopup({features:[c],location:o.location.clone()})})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const a=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(a,t),this._groupFeaturesBySectors()},this._createViewClickHandle=()=>{if(this.removeHandles(bt.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,Me.WIDGET),bt.click)},this._createImageClickHandle=()=>{this.removeHandles(bt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;const n=a.clickAction;this.clickAction="pixel-location";const c=l(()=>{this.clickAction=n});let h=null;const u=_(()=>a,"pixel-location",e=>{this.plotReferencePointOnImage(e),h?.abort(),h=r(async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then(e=>{const t=this.view?.spatialReference;return re(!t,e.spatialReference.equals(t))?e:B(e,t)});v(a),this.plotReferencePointOnGround(r)})});this.addHandles([u,c],bt.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(bt.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),bt.triangularImageClick)},this._createTriangularImageLocationHandle=()=>{this.removeHandles(bt.triangularImageClick);const{imageLocationToolState:e,mode:t,activeTriangulatedViewer:a}=this,i=a?.imageSize;if(!e||"none"===t||!i)return;this.clickAction="pixel-location";let s=null;const o=_(()=>a,"pixel-location",e=>{1===this.measurementVectors.length&&(this.plotLocationPointOnImage(e,!0),s?.abort(),s=r(async a=>{if(!e||this.triangulatedPoint||2===this.measurementVectors?.length||!this.currentBestFeatureMeasurementImage)return;let r=await this.getMapPoint(e,{feature:this.currentBestFeatureMeasurementImage,imageSize:i,mode:t});v(a);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await B(r,s),v(a)),await this._calculateTriangulatedPointFromGroundPoint(r,{signal:a}),v(a)}))});this.addHandles(o,bt.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(bt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;this.clickAction="pixel-location";let n=null;const c=_(()=>a,"pixel-location",e=>{const{currentBestFeatureMeasurementImage:a,triangularMeasurementActive:s,activeTriangulatedViewer:c}=this;this.pixelCoordinates=e;const l=null!=a&&!c?.state.includes("loading");re(!s,l)&&this.plotLocationPointOnImage(e),n?.abort(),n=r(async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});v(a);const n=this.view?.spatialReference;n&&!r.spatialReference.equals(n)&&(r=await B(r,n),v(a)),this.groundCoordinates=r,s&&r&&l&&await this.triangulatedLocationWorkflow(r,a);const c=await this.calculateLocationAccuracy(e,r,t,a);v(a),c&&(this.groundCoordinatesAccuracy=c)})});this.addHandles(c,bt.imageClick)},this._handleImageHitTestResponse=async e=>{const{layer:t,overlayedCameraLocations:a}=this;if(!t)return;const i=e.results.find(({graphic:e,graphic:{attributes:i}})=>a.includes(e)&&i&&!i[t.imageReferenceField]&&!i[t.imageGeometryField]);if(!i)return;const r=i.graphic.attributes[t.objectIdField];await this.showImageByObjectId(r)},this._loadDepthImage=async e=>{const{currentBestFeature:t,layer:a,depthImageNotSupported:i}=this;if(this.depthImage?.destroy(),this.depthImage=null,!a||!t||i)return;const{depthImage:r}=t.attributes;if(!r)return;const s=(await import("./services/DepthImageService.js")).default;v(e),this.depthImage=new s({url:r});try{await this.depthImage.load(e)}catch(o){y(o)||(u.getLogger(this).error("error occurred while loading depth image",o),this.depthImage?.destroy(),this.depthImage=null)}},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new O(m);let w=s;if(je(s))try{w=await Be(a,h,e)}catch(f){if(y(f))return;return rt(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(f){y(f)||this.loadImageError(f)}},this._loadVideo=async e=>{const{currentBestFeature:t,layer:a,mode:i,selectedPoint:r}=this,s=t?.attributes.imagePath;if(!a||!t||"panoramic-video"!==i||!s)return;const{attributes:o}=t,{cameraHeading:n,cameraPitch:c,cameraOrientation:l,location:h}=o,u=h.spatialReference.isWGS84&&4!==l?.type?z(h):new O(h);try{this._panoramicVideoViewer.viewModel.video&&this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.videoSource=s;let t=n??0;u&&r&&(t=await se(u,r)-t),this._panoramicVideoViewer.pitch=c??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),v(e)}catch(d){y(d)||this.loadImageError(d)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:c}=new URL(o);let l=s?n.match(Pt)?.[1]:e.datasetFormat;if(!l)try{l=await st(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(l??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,l,o,c,i,r):await this._setImageSource(this._imageViewer,l,o,c,i,r);break;case"panoramic":if(Mt.has(l.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t,c=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;let h=i??0;"number"==typeof n?h=n-h:s&&e&&(h=await se(s,e)-h),c.imageSource=o,c.pitch=a??0,c.yaw=h,It.has(l.toUpperCase())?await c.loadImageTiled(o,r):await c.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:l});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:i}=this;if(this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new O(m);let w=s;if(je(s))try{w=await Be(a,h,e)}catch(f){if(y(f))return;return rt(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e)}catch(f){y(f)||this.loadImageError(f)}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");v(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");v(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{if(e.stopPropagation(),e.preventDefault(),e.mapPoint){const t=e.mapPoint;t.x=D(t.x,t.spatialReference),this.plotMapPoint(e.mapPoint)}},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:i,triangulatedMeasurementGraphic:r}=this;t&&a&&i&&r&&"active"!==t.state&&(t.update([r],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r(async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))})},this.plotSelectedPointOnImage=async(e,a)=>{if(await w(a),!e)return;const i=new O({...A(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:We}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._crossSymbol=new t({geometry:new O(n,x.WebMercator),symbol:qe}),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)},I),b(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},I),b(()=>[this.state,this.mapImageConversionToolState,this.view],()=>{this._createViewClickHandle(),this._createImageClickHandle()},M),b(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},M),b(()=>[this.state,this.imageLocationToolState,this.view],(e,t)=>{if(this._initializeMeasurementService(),this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();e[1]!==t?.[1]&&this._setMeasurementCursor()},M),b(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},M),b(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},M),b(()=>this.currentBestFeature,async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r(async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}])),await this._featureChangedTask.promise},{sync:!0}),b(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{m(this._featureChangedTask),t&&e!==t&&(this.measurementVectors=[],this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll()),this._featureChangedTask=r(async a=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:a}),v(a),this._reorderTriangularSketchLayer()})},M),b(()=>this.triangularMeasurementActive,(e,t)=>{t&&!e&&(this.measurementVectors=[],this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearImage(),this._panoramicMeasurementViewer.clearGraphics())}),b(()=>this.mode,e=>{switch(this.removeHandles(bt.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=r(async t=>{await this.updateFootprint(e,void 0,{signal:t})}))},{...M,equals:(e,t)=>a(e,t,h)}),bt.interactionHandles);break;case"video":this.addHandles(b(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:a}=this;if(e&&t?.loaded&&a)return{videoExtent:Se,bestFeatureFootprint:a}},e=>{e?.videoExtent&&e?.bestFeatureFootprint&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e.videoExtent,void 0,{signal:t})}))},{...M,equals:(e,t)=>a(e?.videoExtent,t?.videoExtent,h)&&e?.bestFeatureFootprint===t?.bestFeatureFootprint}),bt.interactionHandles);break;case"panoramic":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n}=a;return e&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o]:null},e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;this.currentNode&&(this.currentNode.currentHeading=i+(this.currentNode.heading??0),this.currentNode.currentPitch=s+(this.currentNode.pitch??0)),m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),bt.interactionHandles);break;case"panoramic-video":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n,viewModel:c}=a,l=c.closestFeature??e;return l&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o,l]:null},e=>{if(!e)return;const[t,a,i,s,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s,feature:o},{signal:e}),v(e),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),bt.interactionHandles)}},M),b(()=>[this.brightness,this.contrast,this.sharpness],()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)},M),b(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),b(()=>this.activeViewer,e=>{this.removeHandles(bt.hittestHandles),e&&this.addHandles(_(()=>e,"hittest-response",this._handleImageHitTestResponse),bt.hittestHandles)})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){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._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this._referencePointOnImage=p(this._referencePointOnImage),this._locationPointOnImage=p(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy(),this._panoramicMeasurementViewer.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:a}=this;switch(a){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!ot(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 ot(t)||je(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===ke}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(nt(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?we(e):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:a,isSpherical:i}=e;return 360===a||i?"panoramic":"default"}get panoramicVideoLoaded(){const{mode:e,_panoramicVideoViewer:t}=this,{videoLoaded:a}=t.viewModel;return("panoramic-video"===e&&!0===a)??!1}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Ae.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",d(e,0,1))}get sketchGraphicsLayer(){const{sketch:e}=this;return"graphics"===e?.layer?.type?e.layer:void 0}get state(){const{mode:e,_updatingHandles:{updating:t},_featureChangedTask:a}=this;if(!this.isFulfilled()||t||!1===a?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map(({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:i}})=>{const r=e?.trim();return ot(r)||je(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null}).filter(i)):null}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new U({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new U({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}beforeLoad(e=!0){this.view?.closePopup(),e&&(this.displayMessage=null),this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._overlays?.removeAll()}async computeHeight(e,t,a=!0){return this._measurementService?.computeHeight(e,t,a)}async calculateAreaMeasurement(e,t,a){return this._measurementService?.calculateAreaMeasurement(e,t,a)}async calculateDistanceMeasurement(e,t,a){return this._measurementService?.calculateDistanceMeasurement(e,t,a)}async calculateAccuracy(e,t,a){return this._measurementService?.calculateAccuracy(e,t,a)}async calculateLocationAccuracy(e,t,a="default",i){return this._measurementService?.calculateLocationAccuracy(e,t,a,i)}async calculateAccuracyPanoramic(e,t,a){return this._measurementService?.calculateAccuracyPanoramic(e,t,a)}async calculateHeightMeasurementInfo(e,t,a){return this._measurementService?.calculateHeightMeasurementInfo(e,t,a)}async calculateTriangulatedMeasurements(e){await(this._measurementService?.calculateTriangulatedMeasurements(e))}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:a,dataCaptureLayer:i}=this;if(!a)throw Vt();Ge(i,e,a),await a.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw Vt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw Vt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw Vt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw Vt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw Vt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw Vt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t,a=!1){const i=[],r=[],s=[];return e.forEach(e=>{const{layer:{coveragePercent:o},attributes:n}=e;let c;const{polygon:l,frustum:h}=J(n);if(c=l.clone(),n.isInspection&&(c=Z(n)),o&&(c=K(c,o)),a||!t||Q(c,t)){s.push(e);const{geometry:t,objectId:a,cameraHeight:o,cameraHeading:c}=n,u=t.clone();u.z=o,u.imageID=a,this.pointSources.push(u),c!==ke&&(i.push(l),h&&r.push(h))}}),{features:s,polygons:i,frustums:r}}getMeasurementProperties(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ce(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?B(n,x.WebMercator):Promise.resolve(n)).then(e=>(n=e,le(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}getMeasurementPropertiesPanoramic(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ue(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?B(n,x.WebMercator):Promise.resolve(n)).then(e=>(n=e,le(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}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?.[Ae[e]],a=t?.at(0);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t],r=i?.at(a);r&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(r):this._updateCurrentBestFeature(r))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s,currentBestFeature:o}=this,n=s?.imageSize;if(!e.vertices||!n||!o)return;const c=xe(e.vertices.at(-1),r,n);if(i.length<1||!c||!a||!t||"none"===r)return;const l=He(i[0],c,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const h=Ee(o.attributes.location.spatialReference),u=De(this.heightMeasurementPixels,a,h);u&&(this.heightMeasurementResult=u)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=xe(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!y(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=Y(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:a}=await t;v(e),this.sketch=new a({layer:this._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:a}=await t;if(v(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async loadTriangulatedMeasurementAdapter(e){if(!this.triangulatedMeasurementAdapter){const t=import("./adapters/sketch/TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(v(e),this.triangulatedMeasurementAdapter=new a({viewModel:this}),!this.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.triangulatedMeasurementAdapter}async processFeatureResponse(e,t,a){const{features:i}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(i))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t,a?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,a);v(a),await this._updateElevationOfSelectedPointAndLocations(r,t,n),v(a),ct(r,n);const c=this._processSuitableFeatures(r,t);this.updateSuitabilities(c,a?.loadBestImage)}async processFeatureElevation(e,t,a){if(!t)return;const{features:i,polygons:r}=this.filterByFootprints(e,t,!0);if(!i?.length)return;const s=await this.processElevationSample(r,i,a);return v(a),s}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=$e(o),this.sketch.polylineSymbol="panoramic"===s?Je:Ze(o,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new _e({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],e=>this.handleDrawEvents(e))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[e],spatialReference:a});else{const i=new j({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:Ze(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=oe(i,a[0],a[1]),{heading:n,pitch:c}=oe(r,a[0],a[1]),l=[[...ne(s,o)],[...ne(n,c)]];if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[l],spatialReference:e});else{const a=new j({paths:[l],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:Je}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async editOverlayedGraphics(e){this.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.sketchTriangularGraphicsLayer.add(e),this.sketchTriangular||(this._initializeSketchTriangular(),await this.loadTriangulatedMeasurementAdapter()),this.updateOverlayedGeometry(e)}updateOverlayedGeometry(e){this.sketchTriangular?.update([e],{tool:"reshape"})}async processMeasurementVectors(e){this.triangularMeasurementActive&&this.currentBestFeature&&(this.measurementVectors?.length<2&&await this.updateMeasurementVectorsArray(e),2===this.measurementVectors.length&&await this.calculateTriangulatedMeasurements(e))}async updateMeasurementVectorsArray(e){const t=this.measurementVectors.length?this.currentBestFeatureMeasurementImage:this.currentBestFeature;if(t){const a=await this.computeMeasurementVector(e,t);a&&this.measurementVectors.push(a)}}async computeMeasurementVector(e,t){const{activeViewer:a,mode:i}=this,r=a?.imageSize;if(!e||!t||!r)return;const s=ze(e,i,r),o=this.view?.spatialReference,n=[];for(let c=0;c<s.length;c++){const e={x:s[c][0],y:s[c][1]};let a=await this.getMapPoint(e,{feature:t,imageSize:r,mode:i});o&&!a.spatialReference.equals(o)&&(a=await B(a,o)),n.push(a)}return Ue(n,t)}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":await this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n,layerFloorFilterClause:c}=this,l=a?.imageSize;if(!l||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:h}=J(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:P(`${s.objectIdField} <> ${i.attributes.objectId}`,P(s.definitionExpression,c)),geometry:h,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map(async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:l,mode:o}),n="panoramic"===o?Ke():Qe();return new t({attributes:a,symbol:n,geometry:s})}));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:c,layer:l}=this,h=r?.imageSize;if(!h||!o||"none"===n||"video"===n||"panoramic-video"===n||c.includes("loading")||!l)return;const{polygon:d}=J(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Te(e,l.imageGeometryField,l.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:d,returnGeometry:!0,outFields:["*"]}),p=new s((await Promise.all(m.map(async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:c}=i,l=c,{imageGeometryField:d,oiObjectIdField:m}=this;if(d&&m&&Oe(e,d,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Re(s,d,e,a,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(l?.type){case"point":{const i=await this.getPixels(l,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:c}=l,u=i.map(e=>e.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de))));return new t({attributes:s,layer:e,symbol:r,geometry:new R({rings:d,spatialReference:x.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:c}=l,u=i.map(e=>e.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({paths:d,spatialReference:x.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:c}=l,u=i.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c})),d=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de));return new t({attributes:s,layer:e,symbol:r,geometry:new T({points:d,spatialReference:x.WebMercator}),visible:e.visible&&a})}}return null}))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,p)}getDepthAt(e){const{activeViewer:t,currentBestFeature:a,mode:i,state:r,depthImage:s}=this,o=t?.imageSize;if(!o||!a||"none"===i||r.includes("loading"))return u.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!s?.loaded)return u.getLogger(this).error("oriented-imagery-viewer:get-depth-at","Depth image is not loaded"),this.emit("depth-image-service:not-loaded"),null;const n=(Array.isArray(e)?e:[e]).map(e=>s.depthAt(e,{width:o[0],height:o[1]})??null);return Array.isArray(e)?n:n[0]}async getPixels(e,t){const{imageSize:a,mode:i,feature:r}=t,s=(await this.worldToImage(Array.isArray(e)?e:[e],r)).map(e=>{if("default"===i)return new O({x:e.x-.5,y:.5-e.y,spatialReference:x.WebMercator});const[t,r]=a,{heading:s,pitch:o}=oe(e,t,r),n=ne(s,o);return new O(n,x.WebMercator)});return Array.isArray(e)?s:s[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:c,cameraHeight:l}=o;let h=c.clone();h.spatialReference.isGeographic&&(h=await B(h,x.WebMercator));const u=await le(c.spatialReference,c.z??0,l,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;"elevationSample"in u&&he(u.elevationSample)&&(a.elevationSample=u.elevationSample);const m=Array.isArray(e)?e:[e];if(this.depthImage?.loaded)for(const p of m){const e=this.getDepthAt(p);null!=e&&(p.depth=e)}if("default"===i){const e=ce(o,r[0],r[1]);d=await ee(m,{...e,cameraLocation:h},u)}else{const e=ue(o,r[0],r[1]);d=await te(m,{...e,cameraLocation:h},u)}return Array.isArray(e)?d:d[0]}getActiveSectors(){return Ae.filter(e=>this._sectorData?.[e]?.length)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new O({...e.toJSON()}),symbol:Xe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=A(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new O({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:Xe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new O(n,x.WebMercator),symbol:Ye}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e,t=!1){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(t),this.mode){case"default":this._plotLocationPointOnDefaultImage(e,t);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e,t)}}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.heightMeasurementPixels=[],this.measurementVectors=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:c}=n;return r?t.error.push(n):(a&&(c[e.objectIdField]=a),i&&e.globalIdField&&(c[e.globalIdField]=i),t.success.push(n)),t},{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s||"video"===s||"panoramic-video"===s)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const c=await Promise.all(e.map(async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,c=r.hasZ,l=r.geometryType,h=n!==l,u=h?await import("./transformers.js"):null,d=u?.default[l],m=h?d?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(me(s,m,o),{feature:a,imageSize:o,mode:s}),c||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map(async e=>this.getMapPoint(e.map(([e,t,a])=>me(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new R({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,rings:e.map(e=>e.map(de))}),t}case"polyline":{const e=await Promise.all(m.paths.map(async e=>this.getMapPoint(e.map(([e,t,a])=>me(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new j({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,paths:e.map(e=>e.map(de))}),t}}})),l=c.filter(i);return r.applyEdits({addFeatures:l}).then(e=>{const{addFeatureResults:t}=e;let a=0;const i=c.map(e=>{const i=t[a++];return e?i:{error:new n("orientedimageryviewer:save-unsucccessful","Error in saving data capture features"),objectId:null,globalId:null}});return{...e,addFeatureResults:i}})}async searchBestImage(e,t){try{const a=await W(e,t);a&&await this.processFeatureResponse(a,e.point,t)}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),u.getLogger(this).error("error occurred while finding best image",a))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find(({attributes:t})=>t.objectId===Number(e))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach(t=>{t.visible=e})}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach(t=>{t.visible=e})}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],c=[],l=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?c.push(s):l.push(s);this.overlayGraphicsOnImage(e.id,new s(l)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);v(t),h.addGraphics(c),u.savedGraphics.addMany(c);a.ui.find("zoom").visible=!1,a.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach(t=>{this._toggleVisiblity(t,e)})}toggleOverlayMapFeatures(e,t,a){const i=this.overlayedMapFeatures.get(e);i&&a&&this._toggleVisiblity(i,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{feature:t,selectedLocation:a,options:i}=e;let r=!1,s=!1;const o=this.bestFeatureFootprint?.geometry;switch(o?.type){case"polygon":{const e=a.spatialReference.equals(o.spatialReference)?a:await B(a,o.spatialReference);r=o.contains(e);break}case"mesh":{const e=a.spatialReference.equals(o.spatialReference)?a:await B(a,o.spatialReference);s=o.extent.contains(e);break}}if(!r&&!s)return void this.clearReferencePointOnImage();const n=await this.worldToImage(a,t,i);if(n)return v(i),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}async triangulatedLocationWorkflow(e,t){if(this.currentBestFeature&&e){const{currentBestFeature:a}=this;this.triangulatedPoint&&(this.measurementVectors=[],this.triangulatedPoint=null,this.clearLocationPointOnImage(!0));const i=Ue(e,a);if(!i)return;this.measurementVectors.push(i),await this.plotReferenceLocationPoint(e,t),v(t),this._createTriangularImageLocationHandle()}}async updateFeatureCache(e,t){const a=await q(e,t);a.features?.length&&(this.featureCache=a.features)}async _calculateTriangulatedPointFromGroundPoint(e,t){if(this.currentBestFeatureMeasurementImage&&e){const{currentBestFeatureMeasurementImage:a}=this,i=Ue(e,a);i&&this.measurementVectors.push(i);const r=await Ne(this.measurementVectors);v(t),this.triangulatedPoint=r??this.triangulatedPoint}}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:a,invalidCameraHeading:i}=this,r=a.at(0);if(!e||!t||!r||!a||i)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const h of Ae)this._sectorData[h]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const c=n.map(({distance:e})=>e),l=Math.max(...c);n.forEach(e=>{const{distance:t,angle:i,featureIndex:s}=e,n=t/l*Le[2],c=ht(t,l),h=lt(i);if(!this._sectorData)return;const u=Le[3]+n*Math.sin(i*Math.PI/180),d=Le[3]+n*Math.cos(i*Math.PI/180);let m;const p=a.at(s),g=p===r,{cameraPitch:y}=p.attributes,v=y<5;if(g&&v)m=-90;else{const e=u-Le[3],t=d-Le[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),m=i}const w=""===c?h:`${c}_${h}`;g&&(m===this.bestFeatureAngle?this.previousFeatureAngle=m:this.bestFeatureAngle=m,this.navigatorCurrentBestFeature=v?null:{x:u,y:d,direction:h}),o[`${p.attributes.objectId}`]=w;const f=this._sectorData[w];f.add({angle:i,featureIndex:s,x:u,y:d,objectID:p.attributes.objectId,sector:w,featureIndexInSector:f.length})})}_handleDestroyedTriangularSketchLayer(){this.sketchTriangularGraphicsLayer&&this.activeTriangulatedViewer&&(this.activeTriangulatedViewer.imageRenderer.map.layers.remove(this.sketchTriangularGraphicsLayer),this.sketchTriangularGraphicsLayer=new U,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer),this.sketchTriangular&&(this.sketchTriangular.layer=this.sketchTriangularGraphicsLayer,this.sketchTriangular.view=this.activeTriangulatedViewer.imageRenderer))}_initializeMeasurementService(){this._measurementService||(this._measurementService=new Ft(this))}_initializeSketchTriangular(){if(!this.activeTriangulatedViewer)return;const e="panoramic"===this.mode;this.sketchTriangular=new _t({view:this.activeTriangulatedViewer.imageRenderer,layer:this.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1,enableZ:!e}}),e&&(this.sketchTriangular.defaultUpdateOptions.reshapeOptions={edgeOperation:"offset",shapeOperation:"move-xy",vertexOperation:"move-xy"})}_initializeSketchTriangularGraphicsLayer(){this.activeTriangulatedViewer&&(this.sketchTriangularGraphicsLayer=new U,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(bt.videoPlayerHandles),this.videoElement=new fe({video:this.currentBestFeature.attributes.imagePath,georeference:new ve({extent:new L(Ce)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new N({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.addHandles(mt(this.videoMapView),bt.videoPlayerHandles),this.videoViewModel=new yt({oiViewModel:this})}_plotLocationPointOnDefaultImage(e,a=!1){const i=A(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,a?(this._correctedLocationPointOnImage=new t({geometry:new O({spatialReference:x.WebMercator,...i}),symbol:et}),this.imageMeasurementViewer.addGraphic(this._correctedLocationPointOnImage,0)):(this._locationPointOnImage=new t({geometry:new O({spatialReference:x.WebMercator,...i}),symbol:et}),this._imageViewer.addGraphic(this._locationPointOnImage,0))}_plotLocationPointOnPanoramicImage(e,a=!1){const i=a?this._panoramicMeasurementViewer:this._panoramicViewer,{imageSize:r}=i;if(!r)return;const[s,o]=r,{heading:n,pitch:c}=oe(e,s,o),l=ne(n,c),h=new t({geometry:new O(l,x.WebMercator),symbol:tt});a?this._correctedLocationPointOnImage=h:this._locationPointOnImage=h,i.addGraphic(h,0)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.setMessage("noImageError","error"),this.videoElement?.content?.pause(),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,a){if(!e[0])return;const i=await G(e);if(this._updateFootprintWithFeatures(t,i),"3d"===this.view?.type)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(r){y(r)||u.getLogger(this).error(r)}}async processElevationSample(e,t,a){const{elevationSource:i}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,a);return r||(i&&this.footprintExtent&&X(i)?await ie({extent:this.footprintExtent,lod:i.lod,url:i.url,rasterFunction:i.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return $({features:e,selectedPoint:t,camera:ut(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;o.x=D(o.x,o.spatialReference);const{layerFloorFilterClause:n}=this,c=e.spatialReference.equals(o.spatialReference)?o:await B(o,e.spatialReference),l=c.spatialReference.isGeographic?z(c):c,h=P("1=1",P(e.definitionExpression,n)),u=l.spatialReference.isGeographic?1:V(l.spatialReference),d={layerInstanceOrURL:e,point:l,queryParams:{where:h,maximumDistance:e.maximumDistance?e.maximumDistance/u:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(d,a)}async _queryAndLoadByObjectId(e,t,a,i){this.displayMessage=null;const{response:r}=await ft(e,t,a,i);if(v(i),!r?.features?.length)throw new wt(t);const s=J(r.features[0].attributes).polygon,o=O.fromJSON(H(s)),n=Y(o),c=V(n.spatialReference);this.selectedPoint=n;const l={layerInstanceOrURL:e,point:n,queryParams:{where:P(P("1=1",P(e.definitionExpression,a)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0}},h=await W(l,i);v(i);const{features:u}=h;return u.push(r.features[0]),await this.processFeatureResponse(h,n,{...i,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}_resetCursor(){const{activeViewer:e,imageMeasurementViewer:t}=this;e&&this.removeHandles(bt.activeViewerCursorHandles),t&&this.removeHandles(bt.imageViewerCursorHandles)}async _setImageSource(e,t,a,i,r,s){e.imageSource={datasetFormat:t.toUpperCase(),url:a.split("?")[0]},e.customParameters=Object.fromEntries(i),e.imageRotation=r??0,await e.loadImage(s)}_setMeasurementCursor(){const{activeViewer:e,imageMeasurementViewer:t,triangularMeasurementActive:a}=this;e&&this.addHandles(e.imageRenderer.acquireCursor("crosshair","high"),bt.activeViewerCursorHandles),t&&a&&this.addHandles(t.imageRenderer.acquireCursor("crosshair","high"),bt.activeViewerCursorHandles)}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,a,i){const r=he(a),{location:s,cameraHeight:o}=e[0].attributes,n=await le(s.spatialReference,s.z,o,{elevationSample:r?a:void 0,elevationSource:r?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},i);v(i);const[c,...l]=await ae([t,...e.map(e=>e.attributes.geometry.clone())],n);v(i),t.elevation=c.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:a}=e,{isSpherical:i,cameraHeading:r,cameraPitch:s}=a;return new gt({geometry:t,attributes:a,currentHeading:i?0:r,currentPitch:i?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 a=[];for(const{attributes:{geometry:i}}of e)t.contains(i)||a.push([i.x,i.y]);a.sort((e,t)=>+E([e,t])),t.addRing(a),this.footprintExtent=be(t.extent,2,2)}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),v(e);for(const e of a)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:at,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:it,visible:s}));"video"!==o&&"panoramic-video"!==o||!n||this.featureCache.length||await this.updateFeatureCache(n,i.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 a;if(t)a=-90;else{const t=e.x-Le[3],i=e.y-Le[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage))}clearLocationPointOnImage(e=!1){this._locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=p(this._locationPointOnImage)),this._correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this._correctedLocationPointOnImage),this._panoramicMeasurementViewer.removeGraphic(this._correctedLocationPointOnImage),this._correctedLocationPointOnImage=p(this._correctedLocationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}async plotReferenceLocationPoint(e,t){if(this.currentBestFeatureMeasurementImage){const a=await this.worldToImage(e,this.currentBestFeatureMeasurementImage,{signal:t});v(t),a&&this.plotLocationPointOnImage(a,!0)}}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,t,e),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t,a){const{footprintExtent:i}=this,{imageSize:r}=this.activeViewer;if("none"===this.mode||!t||!r||!i)return;const{attributes:{location:s,elevationSource:o,cameraHeading:n,cameraHeight:c},elevationSample:l}=t;let h=s.clone();const u=await le(s.spatialReference,s.z??0,c,{elevationSample:l,elevationSource:o});t.elevationSample=u.elevationSample;const d=Array.isArray(e)?e:[e];let m,p=await Promise.all(d.map(e=>new Promise(t=>{if(!e.hasZ)return t(ae(e,u));t(e)})));if(s.spatialReference.isGeographic&&(h=await B(h,x.WebMercator,a)),p=await Promise.all(p.map(async e=>h.spatialReference.equals(e.spatialReference)?e:await B(e,h.spatialReference,a))),v(a),"panoramic"===this.mode)m=ye(p,{imageHeight:r[1],imageWidth:r[0],cameraHeading:n,cameraLocation:h});else{const e=pe(t.attributes,r[0],r[1]);m=ge(p,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:c,_adapter:l,mode:h}=this;if(!r)return;const{attributes:{objectId:u},elevationSample:d}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),c){const e=[...a,...i,s].filter(dt);"3d"===c?.type&&d&&l?.updateGroundElevation&&(this._updateGroundElevation&&l.updateGroundElevation(e,d),"panoramic"===h&&l.updateGroundElevation([this.bestFeatureCurrentFootprint],d)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:We.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(c){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,"3d"===c?.type&&d&&l?.updateGroundElevation&&"panoramic"===h&&l.updateGroundElevation([e],d),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],St.prototype,"activeLayer",null),e([S({readOnly:!0})],St.prototype,"activeViewer",null),e([S()],St.prototype,"activeTriangulatedViewer",null),e([S()],St.prototype,"accuracyParametersMissing",null),e([S()],St.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],St.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],St.prototype,"additionalFootprints",void 0),e([S()],St.prototype,"areaMeasurementResult",void 0),e([S()],St.prototype,"areaMeasurementAccuracy",void 0),e([S()],St.prototype,"bestFeatureAngle",void 0),e([S()],St.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],St.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],St.prototype,"brightness",null),e([S()],St.prototype,"cameraHeadingThreshold",void 0),e([S()],St.prototype,"cameraPitchThreshold",void 0),e([S()],St.prototype,"clickAction",void 0),e([S()],St.prototype,"videoViewModel",void 0),e([S()],St.prototype,"collectionId",void 0),e([S({type:Number})],St.prototype,"contrast",null),e([S()],St.prototype,"conversionProps",void 0),e([S()],St.prototype,"coverageFrustums",void 0),e([S()],St.prototype,"coveragePolygons",void 0),e([S()],St.prototype,"currentBestFeature",void 0),e([S()],St.prototype,"currentBestFeatureMeasurementImage",void 0),e([S()],St.prototype,"currentBestFeatureLocation",void 0),e([S()],St.prototype,"currentCoverageVisible",void 0),e([S()],St.prototype,"currentNode",null),e([S()],St.prototype,"depthImage",void 0),e([S()],St.prototype,"depthImageNotSupported",null),e([S()],St.prototype,"directionMode",void 0),e([S()],St.prototype,"featureCache",void 0),e([S()],St.prototype,"navigationNodes",void 0),e([S({json:{write:!1}})],St.prototype,"determineWorkflowForFeature",void 0),e([S({json:{write:!1}})],St.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([S()],St.prototype,"disabled",void 0),e([S()],St.prototype,"displayMessage",void 0),e([S()],St.prototype,"displayNewMeasurementButton",void 0),e([S()],St.prototype,"distanceMeasurementResult",void 0),e([S()],St.prototype,"distanceAccuracyArray",void 0),e([S()],St.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],St.prototype,"featureCount",null),e([S()],St.prototype,"features",void 0),e([S()],St.prototype,"groundCoordinates",void 0),e([S()],St.prototype,"groundCoordinatesAccuracy",void 0),e([S()],St.prototype,"heightMeasurementPixels",void 0),e([S()],St.prototype,"heightGraphic",void 0),e([S()],St.prototype,"heightMeasurementResult",void 0),e([S()],St.prototype,"heightMeasurementAccuracy",void 0),e([S()],St.prototype,"measurementAngle",void 0),e([S()],St.prototype,"tempDistance",void 0),e([S({readOnly:!0})],St.prototype,"imageGalleryEnabled",null),e([S()],St.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],St.prototype,"imageLoaded",null),e([S()],St.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],St.prototype,"invalidCameraHeading",null),e([S()],St.prototype,"imagePointsInView",null),e([S()],St.prototype,"imageMeasurementViewer",void 0),e([S()],St.prototype,"isAdditionalCoverageVisible",void 0),e([S()],St.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],St.prototype,"measurementVectors",void 0),e([S()],St.prototype,"layer",void 0),e([S()],St.prototype,"layerView",null),e([S({readOnly:!0})],St.prototype,"layerFloorFilterClause",null),e([S({type:Number})],St.prototype,"localPort",void 0),e([S()],St.prototype,"mapImageConversionToolState",void 0),e([S()],St.prototype,"measureType",void 0),e([S()],St.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],St.prototype,"mode",null),e([S()],St.prototype,"navigationMode",void 0),e([S()],St.prototype,"navigatorCurrentBestFeature",void 0),e([S()],St.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],St.prototype,"overlayedCameraLocations",void 0),e([S()],St.prototype,"overlayedMapFeatures",void 0),e([S()],St.prototype,"panoramicVideoLoaded",null),e([S()],St.prototype,"pixelCoordinates",void 0),e([S()],St.prototype,"preserveAngle",void 0),e([S()],St.prototype,"pointSources",void 0),e([S({readOnly:!0})],St.prototype,"popupEnabled",null),e([S()],St.prototype,"previousFeatureAngle",void 0),e([S()],St.prototype,"referencePoint",null),e([S({readOnly:!0})],St.prototype,"sectorData",null),e([S()],St.prototype,"selectedPoint",void 0),e([S({type:Number})],St.prototype,"sharpness",null),e([S()],St.prototype,"shouldShowSelectedImage",void 0),e([S()],St.prototype,"sketch",void 0),e([S()],St.prototype,"sketchTriangular",void 0),e([S()],St.prototype,"sketchTriangularGraphicsLayer",void 0),e([S()],St.prototype,"draw",void 0),e([S()],St.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],St.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],St.prototype,"state",null),e([S({readOnly:!0})],St.prototype,"thumbnails",null),e([S()],St.prototype,"triangularMeasurementActive",void 0),e([S()],St.prototype,"triangulatedDistanceMeasurement",void 0),e([S()],St.prototype,"triangulatedDistanceAccuracy",void 0),e([S()],St.prototype,"triangulatedAreaMeasurement",void 0),e([S()],St.prototype,"triangulatedAreaAccuracy",void 0),e([S()],St.prototype,"triangulatedMeasurementGraphic",void 0),e([S()],St.prototype,"triangulatedPoint",void 0),e([S()],St.prototype,"triangulatedMeasurementAdapter",void 0),e([S()],St.prototype,"updateFootprint",void 0),e([S()],St.prototype,"updateFootprintPanorama",void 0),e([S()],St.prototype,"updatingTriangularMeasurementState",void 0),e([S({value:null})],St.prototype,"view",null),e([S()],St.prototype,"videoElement",void 0),e([S()],St.prototype,"videoLayer",void 0),e([S()],St.prototype,"videoMapView",void 0),e([S()],St.prototype,"_adapter",void 0),e([S()],St.prototype,"_defaultGraphicsLayer",null),e([S()],St.prototype,"_highlightedFeatureHandle",void 0),e([S()],St.prototype,"_imageViewer",void 0),e([S()],St.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],St.prototype,"_locationPointOnImage",void 0),e([S()],St.prototype,"_measurementService",void 0),e([S()],St.prototype,"_correctedLocationPointOnImage",void 0),e([S()],St.prototype,"_overlays",void 0),e([S({readOnly:!0})],St.prototype,"_overlaysView",null),e([S()],St.prototype,"_panoramicVideoViewer",void 0),e([S()],St.prototype,"_panoramicViewer",void 0),e([S()],St.prototype,"_panoramicMeasurementViewer",void 0),e([S()],St.prototype,"_referencePointOnGround",void 0),e([S()],St.prototype,"_referencePointOnImage",void 0),e([S()],St.prototype,"_sectorData",void 0),e([S()],St.prototype,"_featureToSector",void 0),e([S({readOnly:!0})],St.prototype,"_updatingHandles",void 0),e([S()],St.prototype,"footprintExtent",void 0),e([S()],St.prototype,"_featureChangedTask",void 0),St=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],St);const kt=St;export{kt as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Graphic.js";import{isSome as t}from"../../../../core/arrayUtils.js";import o from"../../../../core/Logger.js";import{waitTick as i,throwIfAborted as r,isAbortError as s}from"../../../../core/promiseUtils.js";import a from"../../../../geometry/Polygon.js";import{convertOrientationToPixelLocation as n}from"../../../../layers/orientedImagery/transformations/utils.js";import{fixedImageSize as l}from"../../constants.js";import{activePolygonSymbol as u,polygonSymbol as c}from"../../symbols.js";class m{constructor(m){this.viewModel=m,this.createFootprints=async t=>{await i(t);const{coveragePolygons:o,currentBestFeature:r,isAdditionalCoverageVisible:s}=this.viewModel;for(const i of o)i?.imageID===r.attributes.objectId?this.viewModel.bestFeatureFootprint=new e({attributes:{imageID:i?.imageID},geometry:i,symbol:u,visible:!1}):this.viewModel.additionalFootprints.push(new e({attributes:{imageID:i?.imageID},geometry:i,symbol:c.clone(),visible:s}))},this.updateFootprint=async(i,n)=>{const{activeViewer:c,mode:m,currentBestFeature:p,currentCoverageVisible:d,footprintExtent:g}=this.viewModel,v="video"===m?l:c?.imageSize;if(p&&v&&g)try{const o=await this.viewModel.getMapPoint(i,{feature:p,mode:"default",imageSize:v});r(n);const s=o.filter(t);if(!s.length)return;const l=[s.map(({x:e,y:t})=>[e,t,1])];l[0].push(l[0][0]);const c=new a({rings:l,spatialReference:s[0].spatialReference});this.viewModel.updateCurrentCoveragePolygon(new e({geometry:c,attributes:{imageID:p.attributes.objectId},symbol:u,visible:d}))}catch(f){s(f)||o.getLogger(this.viewModel).error("update-footprint",f)}else this.viewModel.updateCurrentCoveragePolygon(null)},this.updateFootprintPanorama=async(t,o)=>{const{horizontalFieldOfView:i,pitch:s,verticalFieldOfView:c,yaw:m,feature:p}=t,{activeViewer:d,currentBestFeature:g,currentCoverageVisible:v,footprintExtent:f,mode:h}=this.viewModel,w="video"===h||"panoramic-video"===h?l:d?.imageSize,y=p??g;if(!y||!w||!f)return void this.viewModel.updateCurrentCoveragePolygon(null);const{cameraPitch:b,objectId:M}=y.attributes;if(s+b-c/2>180)return void this.viewModel.updateCurrentCoveragePolygon(null);const C=[],P=c/2,j=i/2,F=s-P,I=b+F,D=b+(s+P);if(I>180)return void this.viewModel.updateCurrentCoveragePolygon(null);const V=F<0,x=[-j,P],z=[j,P],R=[j,-P],S=[-j,-P];if(I<180&&D>180){C.push(V?R:S);const e=Math.floor(i/5),t=i/e;for(let o=0;o<=e;o++)C.push([o*t-j,90-s]);C.push(V?S:R)}D<180&&(C.push(x,z),V?C.push(S,R):C.push(R,S));const B=C.map(([e,t])=>n(m+e,s+t,w[0],w[1])),E=await this.viewModel.getMapPoint(B,{feature:y,mode:"panorama",imageSize:w});r(o);const L=[E.map(({x:e,y:t})=>[e,t,1])];L[0].push(L[0][0]);const O=new a({rings:L,spatialReference:E[0].spatialReference});this.viewModel.updateCurrentCoveragePolygon(new e({geometry:O,attributes:{imageID:M},symbol:u.clone(),visible:v}))}}}export{m as default};
5
+ import e from"../../../../Graphic.js";import{isSome as t}from"../../../../core/arrayUtils.js";import o from"../../../../core/Logger.js";import{waitTick as i,throwIfAborted as r,isAbortError as s}from"../../../../core/promiseUtils.js";import a from"../../../../geometry/Polygon.js";import{convertOrientationToPixelLocation as n}from"../../../../layers/orientedImagery/transformations/utils.js";import{fixedImageSize as l}from"../../constants.js";import{activePolygonSymbol as u,polygonSymbol as c}from"../../symbols.js";class m{constructor(m){this.viewModel=m,this.createFootprints=async t=>{await i(t);const{coveragePolygons:o,currentBestFeature:r,isAdditionalCoverageVisible:s}=this.viewModel;for(const i of o)i?.imageID===r.attributes.objectId?this.viewModel.bestFeatureFootprint=new e({attributes:{imageID:i?.imageID},geometry:i,symbol:u,visible:!1}):this.viewModel.additionalFootprints.push(new e({attributes:{imageID:i?.imageID},geometry:i,symbol:c.clone(),visible:s}))},this.updateFootprint=async(i,n,c)=>{const{activeViewer:m,mode:p,currentBestFeature:d,currentCoverageVisible:g,footprintExtent:v}=this.viewModel,f="video"===p?l:m?.imageSize,h=n??d;if(d&&f&&v&&h)try{const o=await this.viewModel.getMapPoint(i,{feature:h,mode:"default",imageSize:f});r(c);const s=o.filter(t);if(!s.length)return;const n=[s.map(({x:e,y:t})=>[e,t,1])];n[0].push(n[0][0]);const l=new a({rings:n,spatialReference:s[0].spatialReference});this.viewModel.updateCurrentCoveragePolygon(new e({geometry:l,attributes:{imageID:h.attributes.objectId},symbol:u,visible:g}))}catch(w){s(w)||o.getLogger(this.viewModel).error("update-footprint",w)}else this.viewModel.updateCurrentCoveragePolygon(null)},this.updateFootprintPanorama=async(t,o)=>{const{horizontalFieldOfView:i,pitch:s,verticalFieldOfView:c,yaw:m,feature:p}=t,{activeViewer:d,currentBestFeature:g,currentCoverageVisible:v,footprintExtent:f,mode:h}=this.viewModel,w="video"===h||"panoramic-video"===h?l:d?.imageSize,y=p??g;if(!y||!w||!f)return void this.viewModel.updateCurrentCoveragePolygon(null);const{cameraPitch:b,objectId:M}=y.attributes;if(s+b-c/2>180)return void this.viewModel.updateCurrentCoveragePolygon(null);const C=[],P=c/2,j=i/2,F=s-P,I=b+F,D=b+(s+P);if(I>180)return void this.viewModel.updateCurrentCoveragePolygon(null);const V=F<0,x=[-j,P],z=[j,P],R=[j,-P],S=[-j,-P];if(I<180&&D>180){C.push(V?R:S);const e=Math.floor(i/5),t=i/e;for(let o=0;o<=e;o++)C.push([o*t-j,90-s]);C.push(V?S:R)}D<180&&(C.push(x,z),V?C.push(S,R):C.push(R,S));const B=C.map(([e,t])=>n(m+e,s+t,w[0],w[1])),E=await this.viewModel.getMapPoint(B,{feature:y,mode:"panorama",imageSize:w});r(o);const L=[E.map(({x:e,y:t})=>[e,t,1])];L[0].push(L[0][0]);const O=new a({rings:L,spatialReference:E[0].spatialReference});this.viewModel.updateCurrentCoveragePolygon(new e({geometry:O,attributes:{imageID:M},symbol:u.clone(),visible:v}))}}}export{m as default};