@arcgis/core 4.33.0-next.20250218 → 4.33.0-next.20250220

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 (216) hide show
  1. package/applications/ExperienceBuilder/sketchUtils.d.ts +1 -0
  2. package/applications/ExperienceBuilder/sketchUtils.js +1 -1
  3. package/arcade/treeAnalysis.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/{f5ce6af342c02a4b0d15.js → 030384851fa745908a6e.js} +13 -12
  6. package/assets/esri/core/workers/chunks/0c3930e40fc9f8a84599.js +2 -0
  7. package/assets/esri/core/workers/chunks/{ccee343fb8c415b59ce3.js.LICENSE.txt → 0c3930e40fc9f8a84599.js.LICENSE.txt} +1 -1
  8. package/assets/esri/core/workers/chunks/0e6762d69b7449f8a997.js +1 -0
  9. package/assets/esri/core/workers/chunks/{5ad51a68d20b0d0d404f.js → 1661ac4e1b6c6af6ee0f.js} +1 -1
  10. package/assets/esri/core/workers/chunks/186db99d05ca1183d4e9.js +1 -0
  11. package/assets/esri/core/workers/chunks/{a42ae5d5e5f66d120b4d.js → 21c7265f1f2a718de7c6.js} +1 -1
  12. package/assets/esri/core/workers/chunks/2a88909a03600349dff9.js +1 -0
  13. package/assets/esri/core/workers/chunks/333bb93a28209c997d8b.js +314 -0
  14. package/assets/esri/core/workers/chunks/469c50c49447f0d602c0.js +1 -0
  15. package/assets/esri/core/workers/chunks/486df1e042204b90b0dd.js.LICENSE.txt +1 -1
  16. package/assets/esri/core/workers/chunks/{c2d539359f321bba3432.js → 52c13b3c074c9f6dadde.js} +2 -2
  17. package/assets/esri/core/workers/chunks/{c2d539359f321bba3432.js.LICENSE.txt → 52c13b3c074c9f6dadde.js.LICENSE.txt} +1 -1
  18. package/assets/esri/core/workers/chunks/5352b374454bc4f73d55.js +1 -0
  19. package/assets/esri/core/workers/chunks/5693d9ce4472a4c5959f.js.LICENSE.txt +1 -1
  20. package/assets/esri/core/workers/chunks/5984ab09ea8010f8a874.js +1 -0
  21. package/assets/esri/core/workers/chunks/5b56b271afb0fadf48b4.js.LICENSE.txt +1 -1
  22. package/assets/esri/core/workers/chunks/6518954889df2e781c47.js.LICENSE.txt +1 -1
  23. package/assets/esri/core/workers/chunks/68322a63ec92d33701ea.js +1 -0
  24. package/assets/esri/core/workers/chunks/{ec62fffe07c4382e8796.js → 6c64ccf5f64b5025b239.js} +1 -1
  25. package/assets/esri/core/workers/chunks/717d7e9912d948e44d8d.js +1 -0
  26. package/assets/esri/core/workers/chunks/aacebda644be06ad1a61.js +1 -0
  27. package/assets/esri/core/workers/chunks/ac11b2168feee63d2f09.js +1 -0
  28. package/assets/esri/core/workers/chunks/b0952b81d5be214262dd.js.LICENSE.txt +1 -1
  29. package/assets/esri/core/workers/chunks/b9292cd91005137a2094.js +1 -0
  30. package/assets/esri/core/workers/chunks/b9d2f60b2d587a2b6cd7.js +1 -0
  31. package/assets/esri/core/workers/chunks/cf285e45c18cd4399dde.js +1 -0
  32. package/assets/esri/core/workers/chunks/{42f21349f488a14198e4.js → d4a08800c75051a5131d.js} +1 -1
  33. package/assets/esri/core/workers/chunks/e2df18662cc4d6e47715.js +1 -0
  34. package/assets/esri/core/workers/chunks/e96f4c76c8bc78a7f80f.js +1 -0
  35. package/assets/esri/core/workers/chunks/f24aef061e60d2c2f597.js +1 -0
  36. package/assets/esri/core/workers/chunks/f664cc15238c8e9856a0.js +1 -0
  37. package/assets/esri/themes/base/widgets/_Editor.scss +3 -0
  38. package/assets/esri/themes/base/widgets/_Print.scss +1 -0
  39. package/assets/esri/themes/base/widgets/_ResponsiveToolbar.scss +23 -3
  40. package/assets/esri/themes/base/widgets/_Sketch.scss +32 -24
  41. package/assets/esri/themes/dark/main.css +1 -1
  42. package/assets/esri/themes/light/main.css +1 -1
  43. package/assets/esri/themes/light/view.css +1 -1
  44. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm.json +1 -1
  45. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ar.json +1 -1
  46. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bg.json +1 -1
  47. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bs.json +1 -1
  48. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ca.json +1 -1
  49. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_cs.json +1 -1
  50. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_da.json +1 -1
  51. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_de.json +1 -1
  52. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_el.json +1 -1
  53. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_en.json +1 -1
  54. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_es.json +1 -1
  55. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_et.json +1 -1
  56. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fi.json +1 -1
  57. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fr.json +1 -1
  58. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_he.json +1 -1
  59. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hr.json +1 -1
  60. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hu.json +1 -1
  61. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_id.json +1 -1
  62. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_it.json +1 -1
  63. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ja.json +1 -1
  64. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ko.json +1 -1
  65. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lt.json +1 -1
  66. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lv.json +1 -1
  67. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_nl.json +1 -1
  68. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_no.json +1 -1
  69. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pl.json +1 -1
  70. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-BR.json +1 -1
  71. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-PT.json +1 -1
  72. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ro.json +1 -1
  73. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ru.json +1 -1
  74. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sk.json +1 -1
  75. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sl.json +1 -1
  76. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sr.json +1 -1
  77. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sv.json +1 -1
  78. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_th.json +1 -1
  79. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_tr.json +1 -1
  80. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_uk.json +1 -1
  81. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_vi.json +1 -1
  82. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-CN.json +1 -1
  83. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-HK.json +1 -1
  84. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-TW.json +1 -1
  85. package/chunks/RealisticTree.glsl.js +18 -17
  86. package/copyright.txt +91 -0
  87. package/geometry/support/meshUtils/elevation.js +1 -1
  88. package/interfaces.d.ts +493 -131
  89. package/layers/BuildingSceneLayer.js +1 -1
  90. package/layers/FeatureLayer.js +1 -1
  91. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  92. package/layers/IntegratedMeshLayer.js +1 -1
  93. package/layers/OrientedImageryLayer.js +1 -1
  94. package/layers/PointCloudLayer.js +1 -1
  95. package/layers/RouteLayer.js +1 -1
  96. package/layers/SceneLayer.js +1 -1
  97. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  98. package/layers/graphics/OptimizedGeometry.js +1 -1
  99. package/layers/graphics/featureConversionUtils.js +1 -1
  100. package/layers/support/featureLayerUtils.js +1 -1
  101. package/layers/support/rasterFunctionUtils.d.ts +11 -0
  102. package/networks/UtilityNetwork.js +1 -1
  103. package/package.json +2 -2
  104. package/portal/Portal.js +1 -1
  105. package/rest/route.js +1 -1
  106. package/rest/support/AttributeBinsGrouping.js +1 -1
  107. package/rest/support/AttributeBinsQuery.js +1 -1
  108. package/rest/support/RouteParameters.js +1 -1
  109. package/rest/support/RouteSolveResult.js +1 -1
  110. package/support/revision.js +1 -1
  111. package/symbols/cim/CIMEffects.js +1 -1
  112. package/symbols/cim/cimAnalyzer.js +1 -1
  113. package/symbols/cim/effects/EffectAddControlPoints.js +1 -1
  114. package/symbols/cim/effects/EffectBuffer.js +1 -1
  115. package/symbols/cim/effects/EffectDonut.js +1 -1
  116. package/symbols/cim/effects/EffectOffset.js +1 -1
  117. package/views/2d/FrameTask.js +1 -1
  118. package/views/2d/engine/webgl/TextureManager.js +1 -1
  119. package/views/2d/engine/webgl/Utils.js +1 -1
  120. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelTechnique.js +1 -1
  121. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  122. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  123. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  124. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  125. package/views/2d/layers/features/sources/FeatureCache.js +1 -1
  126. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  127. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  128. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  129. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  130. package/views/2d/viewpointUtils.js +1 -1
  131. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  132. package/views/3d/layers/I3SMeshView3D.js +1 -1
  133. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  134. package/views/3d/layers/graphics/pipeline/Tile.js +1 -1
  135. package/views/3d/layers/graphics/pipeline/Tile3DManager.js +1 -1
  136. package/views/3d/layers/graphics/pipeline/featureData/FeatureData.js +1 -1
  137. package/views/3d/layers/graphics/pipeline/featureData/FeatureDataSubset.js +5 -0
  138. package/views/3d/layers/graphics/pipeline/featureData/processingUtils.js +1 -1
  139. package/views/3d/layers/graphics/pipeline/featureSet/PBFPointFeatureSetView.js +1 -1
  140. package/views/3d/layers/graphics/pipeline/featureSet/TiledFeatureStore.js +1 -1
  141. package/views/3d/layers/graphics/pipeline/fetching/Tile3DFetcher.js +1 -1
  142. package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
  143. package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
  144. package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
  145. package/views/3d/layers/support/FeatureTile.js +1 -1
  146. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  147. package/views/3d/terrain/TileRenderer.js +1 -1
  148. package/views/3d/webgl-engine/collections/Component/ComponentData.js +1 -1
  149. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  150. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticComponentBVH.js +1 -1
  151. package/views/3d/webgl-engine/collections/Component/IndexRange/ComponentRange.js +5 -0
  152. package/views/3d/webgl-engine/lib/ComponentUtils.js +1 -1
  153. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  154. package/views/3d/webgl-engine/materials/renderers/BufferRange.js +1 -1
  155. package/views/VideoView.js +1 -1
  156. package/views/View2D.js +1 -1
  157. package/views/Viewport2DMixin.js +5 -0
  158. package/views/webgl/Texture.js +1 -1
  159. package/webmap/utils.js +1 -1
  160. package/widgets/BasemapLayerList.js +1 -1
  161. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  162. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  163. package/widgets/BatchAttributeForm/templates/support/contingentValuesUtils.js +5 -0
  164. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  165. package/widgets/BatchAttributeForm.js +1 -1
  166. package/widgets/CatalogLayerList.js +1 -1
  167. package/widgets/DirectionalPad/DirectionalPadViewModel.js +1 -1
  168. package/widgets/Directions/DirectionsViewModel.js +1 -1
  169. package/widgets/Directions.js +1 -1
  170. package/widgets/ElevationProfile/components/LegendItem.js +1 -1
  171. package/widgets/ElevationProfile/components/SettingsButton.js +1 -1
  172. package/widgets/Feature/FeatureUtilityNetworkAssociations.js +1 -1
  173. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  174. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  175. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  176. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  177. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  178. package/widgets/LayerList.js +1 -1
  179. package/widgets/Legend/styles/support/utils.js +1 -1
  180. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  181. package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
  182. package/widgets/OrientedImageryViewer/digitizationUtils.js +1 -1
  183. package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
  184. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  185. package/widgets/OrientedImageryViewer.js +1 -1
  186. package/widgets/Print.js +1 -1
  187. package/widgets/ShadowCast.js +1 -1
  188. package/widgets/Sketch/SketchViewModel.js +1 -1
  189. package/widgets/Sketch/support/ResponsiveToolbar/OverflowGroup.js +1 -1
  190. package/widgets/Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js +1 -1
  191. package/widgets/Sketch/support/ResponsiveToolbar/SplitButton.js +1 -1
  192. package/widgets/Sketch/support/sketchUtils.js +1 -1
  193. package/widgets/Sketch.js +1 -1
  194. package/widgets/VideoPlayer.js +1 -1
  195. package/widgets/support/UtilityNetworkAssociations/utilityNetworkUtils.js +1 -1
  196. package/assets/esri/core/workers/chunks/1cbea0c0b20a2963a86d.js +0 -1
  197. package/assets/esri/core/workers/chunks/238bcf6514a1f214cc8a.js +0 -1
  198. package/assets/esri/core/workers/chunks/26b5397f63dc602612f2.js +0 -1
  199. package/assets/esri/core/workers/chunks/290f613ef70590de9f15.js +0 -314
  200. package/assets/esri/core/workers/chunks/33c6fd524711efd8ef13.js +0 -1
  201. package/assets/esri/core/workers/chunks/3f077176c03a360e1edd.js +0 -1
  202. package/assets/esri/core/workers/chunks/544ad8fa4777ba8ec177.js +0 -1
  203. package/assets/esri/core/workers/chunks/6039da57a2adedd3b83f.js +0 -1
  204. package/assets/esri/core/workers/chunks/842db06ce62758fab1e7.js +0 -1
  205. package/assets/esri/core/workers/chunks/916f0ca8e3aaed5a9508.js +0 -1
  206. package/assets/esri/core/workers/chunks/bdc9dec6a359d2e3705c.js +0 -1
  207. package/assets/esri/core/workers/chunks/bf127fe767174e2715b5.js +0 -1
  208. package/assets/esri/core/workers/chunks/cb3148cf11a420d6e9ab.js +0 -1
  209. package/assets/esri/core/workers/chunks/ccee343fb8c415b59ce3.js +0 -2
  210. package/assets/esri/core/workers/chunks/d342c56558f164e9e786.js +0 -1
  211. package/assets/esri/core/workers/chunks/d3f7ff03ab5b40062d89.js +0 -1
  212. package/assets/esri/core/workers/chunks/ed89a108b032b982b12f.js +0 -1
  213. package/assets/esri/core/workers/chunks/ef6279f5c63ab1e88c71.js +0 -1
  214. package/assets/esri/core/workers/chunks/f088e7db4e7ac85aaff1.js +0 -1
  215. package/views/3d/layers/graphics/pipeline/featureData/FeatureDataStore.js +0 -5
  216. package/views/3d/webgl-engine/collections/Component/IndexRange/ComponentRangeRunLengthEncoded.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import i from"../core/Identifiable.js";import o from"../core/ReactiveMap.js";import{on as s,watch as l,initial as r}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import{css as p}from"./LayerList/css.js";import c from"./LayerList/LayerListItem.js";import m from"./LayerList/LayerListViewModel.js";import h from"./LayerList/LayerListVisibleElements.js";import y from"./LayerList/ListItem.js";import{minDragEnabledItems as u,minFilterItems as g,getItem as _,getLayerType as L,sortLayersToIds as f,sortChildLayersToIds as I,removeDestroyedListItems as v,setFilterPredicate as b}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as w}from"./support/componentsUtils.js";import{globalCss as C}from"./support/globalCss.js";import{calciteListFilterProps as E}from"./support/listUtils.js";import{setFocus as F}from"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as O}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";const P=t.ofType(y),A="nested";let j=class extends(i.IdentifiableMixin(d)){constructor(e,i){super(e,i),this._rootListEl=null,this._activeItem=null,this._tooltipReferenceMap=new o,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusLayerFlowItem=null,this._layerListMap=new o,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`operational-${this.uid}`,this._openedLayersController=null,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterPredicate=null,this.filterText="",this.headingLevel=2,this.knowledgeGraphOptions=null,this.layerTablesEnabled=new t(["knowledge-graph"]),this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.mapImageOptions=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=u,this.minFilterItems=g,this.openedLayers=new t,this.openedLayerLists=new t,this.selectedItems=new P,this.selectionMode="none",this.tableList=null,this.tileOptions=null,this.viewModel=new m,this.visibilityAppearance="default",this.visibleElements=new h,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const s="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,l=_(e);if(!l?.sortable)return!1;const r=_(t),a=L(t),n=_(i),d=L(i),p=!!a&&!!d&&a===d,c={selected:l,from:r,to:n},m=t.group,h=i.group,y=r?.layer?.type??"",u=n?.layer?.type??"",g=new Set(["map-image","catalog","knowledge-graph"]),f="sublayer";return m&&h&&"function"==typeof s?s.call(null,c):p&&!g.has(y)&&!g.has(u)&&l?.layer?.type!==f},this._onCatalogOpen=e=>{this.openedLayers.push(e.layer?.parent),this._focusLayerFlowItem=e.layer?.uid},this._onTablesOpen=e=>{this.openedLayers.push(e.layer),this._focusLayerFlowItem=e.layer?.uid},this._onPanelOpen=()=>{this._focusPanelFlowItem=!0},this._onTooltipReferenceChange=(e,t)=>{t?this._tooltipReferenceMap.set(e,t):this._tooltipReferenceMap.delete(e)},this._onSelectedDragItemLayerUidChange=e=>{this._selectedDragItemLayerUid=e},this._onTriggerAction=(e,t)=>{this.triggerAction(e,t)},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(p.item)));this._activeItem=_(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:s,newIndex:l}=e;if(o&&i&&!(t?.newIndex===l&&t?.dragEl===s&&t?.toEl===i&&t?.fromEl===o))if(this._lastDragDetail=e,this._selectedDragItemLayerUid=s.value,o!==i)this._moveLayerFromChildList({toEl:i,fromEl:o,dragEl:s,newIndex:l});else{const e=Array.from(o.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(o,e)}}}initialize(){this.addHandles([s((()=>this.openedLayers),"change",(()=>this._handleOpenedLayersChange()),r),s((()=>this.viewModel.operationalItems),"change",(()=>v(this.selectedItems)),r),l((()=>[this.filterPredicate,this._rootListEl]),(()=>b(this._rootListEl,this.filterPredicate)))])}loadDependencies(){return w({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this._destroyOpenedLayerLists(),this._tooltipReferenceMap.clear()}get _totalItems(){return this.viewModel.operationalItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer?.type)))).length}get _visibleItems(){return this.operationalItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}get _openedPanelItems(){return this._visibleItems.flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled))}get _dragEnabled(){return this._totalItems>=this.minDragEnabledItems&&this.dragEnabled}get _filterEnabled(){return this._totalItems>=this.minFilterItems&&this.visibleElements.filter}get _renderedOpenLayerFlowItems(){const{openedLayers:e}=this;return e.toArray().map(((t,i)=>this._renderLayerFlowItem(t,i===e.length-1)))}get icon(){return"layers"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get operationalItems(){return this.viewModel.operationalItems}set operationalItems(e){this.viewModel.operationalItems=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,{_visibleItems:t}=this,i={[C.hidden]:"loading"===e,[C.disabled]:"disabled"===e};return T("div",{class:this.classes(p.base,C.widget,C.panel,i)},t?.length?[this._renderItemTooltips(),this._renderItems()]:this._renderNoItems())}async _createFlowList(e,t){const{_layerListMap:i}=this,o=i.get(e);if(o)return o;const s="catalog"===e.type?await this._createCatalogLayerList(e):await this._createTableList(e);return t.aborted||i.set(e,s),s}async _handleOpenedLayersChange(){const{_layerListMap:e,openedLayers:t,openedLayerLists:i}=this;this._openedLayersController?.abort();const o=new AbortController,{signal:s}=o;this._openedLayersController=o,e.forEach(((i,o)=>{t.includes(o)||(i.destroy(),e.delete(o))}));const l=await Promise.all(t.map((e=>this._createFlowList(e,s))));if(s.aborted)return;i.removeAll(),i.addMany(l);const r=i.at(-1);r?"catalogLayer"in r?(this._set("catalogLayerList",r),this._set("tableList",null)):(this._set("catalogLayerList",null),this._set("tableList",r)):(this._set("catalogLayerList",null),this._set("tableList",null))}_destroyOpenedLayerLists(){this.openedLayerLists.destroyAll(),this.openedLayers.removeAll(),this._layerListMap.clear()}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?T("calcite-tooltip",{key:`tooltip-${e.layer?.uid}`,referenceElement:t.get(e.layer?.uid)},i.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(){return this._visibleItems?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderNoItemsMessage(){return T("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return T("div",{class:p.itemMessage,key:"esri-layer-list__no-items"},T("calcite-notice",{icon:"information",kind:"info",open:!0,width:"full"},this._renderNoItemsMessage()))}async _createCatalogLayerList(e){const{default:t}=await import("./CatalogLayerList.js"),{headingLevel:i,catalogOptions:o,view:s,filterPlaceholder:l,listItemCreatedFunction:r,minFilterItems:a,selectionMode:n,visibilityAppearance:d,_onCatalogOpen:p,_onTablesOpen:c,layerTablesEnabled:m}=this;return new t({headingLevel:i,view:s,filterPlaceholder:l,listItemCreatedFunction:r,minFilterItems:a,selectionMode:n,visibilityAppearance:d,...o,catalogLayer:e,layerTablesEnabled:m,onCatalogOpen:p,onTablesOpen:c})}_getTableListParams(e){switch(e.type){case"knowledge-graph":return{...this.knowledgeGraphOptions,tables:e.tables};case"map-image":return{...this.mapImageOptions,tables:e.subtables};case"tile":return{...this.tileOptions,tables:e.subtables};default:return null}}async _createTableList(e){const{default:t}=await import("./TableList.js"),{headingLevel:i,selectionMode:o,dragEnabled:s}=this;return new t({headingLevel:i,selectionMode:o,dragEnabled:s,...this._getTableListParams(e)})}_renderLayerFlowItem(e,t){const{messages:i,openedLayers:o}=this,s=e.title||this.messages.untitledLayer;return T("calcite-flow-item",{afterCreate:this._focusLayerFlowItemNode,afterUpdate:this._focusLayerFlowItemNode,bind:this,"data-layer-uid":e.uid,description:s,heading:i["catalog"===e.type?"catalogLayers":"tables"],headingLevel:this.headingLevel,key:`flow-layer-list-${e.uid}`,selected:t,onCalciteFlowItemBack:e=>{e.preventDefault(),o.pop();const t=o.at(-1);t?this._focusLayerFlowItem=t.uid:this._focusRootFlowItem=!0}},this._layerListMap.get(e)?.render())}_renderPanelFlowItems(){const{_openedPanelItems:e,openedLayers:t}=this;return e.toArray().map((({title:i,panel:o},s)=>{const l=()=>this._handlePanelFlowItemBack(o);return T("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:i,heading:o.title,headingLevel:this.headingLevel,key:`flow-panel-${o.uid}`,selected:!t.length&&s===e.length-1,onCalciteFlowItemBack:e=>{e.preventDefault(),l()}},o.render(),T("calcite-button",{appearance:"transparent",onclick:l,slot:"footer-actions",width:"full"},this.messagesCommon.back))}))}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,F(e))}_focusLayerFlowItemNode(e){this._focusLayerFlowItem===e.dataset.layerUid&&(this._focusLayerFlowItem=null,F(e))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,F(e))}_renderItems(){const{visible:e,collapsed:t,_visibleItems:i,_openedPanelItems:o,_filterEnabled:s,_rootGroupUid:l,visibleElements:{closeButton:r,collapseButton:a,heading:n,flow:d},_dragEnabled:c,selectionMode:m,filterText:h,openedLayers:y,filterPlaceholder:u,messages:g}=this,_=[T("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:r,closed:!e,collapsed:t,collapsible:a,heading:n?g.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",selected:!y.length&&!o.length,onCalciteFlowItemClose:()=>this.visible=!1},T("calcite-list",{afterCreate:e=>{this._rootListEl=e,e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{this._rootListEl=null,e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":l,displayMode:A,dragEnabled:c,filterEnabled:s,filterPlaceholder:u,filterProps:E,filterText:s?h:"",group:l,key:"root-list",label:g.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:m,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.currentTarget?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},i?.toArray().map((e=>this._renderItem(e))),i?.length&&s?T("div",{class:p.filterNoResults,slot:"filter-no-results"},T("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(),this._renderedOpenLayerFlowItems];return e?d?T("calcite-flow",{key:"root-flow"},_):_:null}_renderItem(e,t,i){return T(c,{activeItem:this._activeItem,canMove:this._canMove,css:p,displayMode:A,dragEnabled:this.dragEnabled,item:e,key:`layerListItem-${e.layer?.uid}`,layerTablesEnabled:this.layerTablesEnabled,listModeDisabled:this.viewModel.listModeDisabled,messages:this.messages,messagesCommon:this.messagesCommon,parent:t,parentTitles:i,rootGroupUid:this._rootGroupUid,selectedDragItemLayerUid:this._selectedDragItemLayerUid,selectedItems:this.selectedItems,selectionMode:this.selectionMode,visibilityAppearance:this.visibilityAppearance,visibleElements:this.visibleElements,onAction:this._onTriggerAction,onCatalogOpen:this._onCatalogOpen,onPanelOpen:this._onPanelOpen,onSelectedDragItemLayerUidChange:this._onSelectedDragItemLayerUidChange,onTablesOpen:this._onTablesOpen,onTooltipReferenceChange:this._onTooltipReferenceChange})}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:o}){const s=_(i),l=_(e),r=_(t);this.viewModel.moveListItem(s,r,l,o)}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:o}=e;t.insertBefore(i,t.children[o])}_sortLayers(e,t){if(e)if(e===this._rootListEl)f(this.view?.map?.layers,t);else{const i=_(e);if(!i)return;I(i,t)}}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>_(e))).filter(Boolean);i.removeAll(),i.addMany(o)}};e([a()],j.prototype,"_rootListEl",void 0),e([a()],j.prototype,"_activeItem",void 0),e([a()],j.prototype,"_tooltipReferenceMap",void 0),e([a()],j.prototype,"_focusRootFlowItem",void 0),e([a()],j.prototype,"_focusPanelFlowItem",void 0),e([a()],j.prototype,"_focusLayerFlowItem",void 0),e([a()],j.prototype,"_layerListMap",void 0),e([a()],j.prototype,"_totalItems",null),e([a()],j.prototype,"_visibleItems",null),e([a()],j.prototype,"_openedPanelItems",null),e([a()],j.prototype,"_dragEnabled",null),e([a()],j.prototype,"_filterEnabled",null),e([a()],j.prototype,"_renderedOpenLayerFlowItems",null),e([a({readOnly:!0})],j.prototype,"catalogLayerList",void 0),e([a()],j.prototype,"catalogOptions",void 0),e([a()],j.prototype,"collapsed",void 0),e([a()],j.prototype,"dragEnabled",void 0),e([a()],j.prototype,"filterPlaceholder",void 0),e([a()],j.prototype,"filterPredicate",void 0),e([a()],j.prototype,"filterText",void 0),e([a()],j.prototype,"headingLevel",void 0),e([a()],j.prototype,"icon",null),e([a()],j.prototype,"knowledgeGraphOptions",void 0),e([a()],j.prototype,"label",null),e([a()],j.prototype,"layerTablesEnabled",void 0),e([a()],j.prototype,"listItemCanGiveFunction",void 0),e([a()],j.prototype,"listItemCanReceiveFunction",void 0),e([a()],j.prototype,"listItemCreatedFunction",null),e([a()],j.prototype,"mapImageOptions",void 0),e([a(),M("esri/widgets/LayerList/t9n/LayerList")],j.prototype,"messages",void 0),e([a(),M("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([a()],j.prototype,"minDragEnabledItems",void 0),e([a()],j.prototype,"minFilterItems",void 0),e([a({readOnly:!0})],j.prototype,"openedLayers",void 0),e([a({readOnly:!0})],j.prototype,"openedLayerLists",void 0),e([a()],j.prototype,"operationalItems",null),e([a()],j.prototype,"selectedItems",void 0),e([a()],j.prototype,"selectionMode",void 0),e([a({readOnly:!0})],j.prototype,"tableList",void 0),e([a()],j.prototype,"tileOptions",void 0),e([a()],j.prototype,"view",null),e([O("trigger-action"),a({type:m})],j.prototype,"viewModel",void 0),e([a()],j.prototype,"visibilityAppearance",void 0),e([a({type:h,nonNullable:!0})],j.prototype,"visibleElements",void 0),j=e([n("esri.widgets.LayerList")],j);const D=j;export{D as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import i from"../core/Identifiable.js";import o from"../core/ReactiveMap.js";import{on as s,watch as l,initial as r}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import{css as p}from"./LayerList/css.js";import c from"./LayerList/LayerListItem.js";import m from"./LayerList/LayerListViewModel.js";import h from"./LayerList/LayerListVisibleElements.js";import y from"./LayerList/ListItem.js";import{minDragEnabledItems as u,minFilterItems as g,getItem as _,getLayerType as L,sortLayersToIds as f,sortChildLayersToIds as v,removeDestroyedListItems as I,setFilterPredicate as b}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as w}from"./support/componentsUtils.js";import{globalCss as C}from"./support/globalCss.js";import{calciteListFilterProps as E}from"./support/listUtils.js";import{setFocus as F}from"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as O}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";const P=t.ofType(y),A="nested";let j=class extends(i.IdentifiableMixin(d)){constructor(e,i){super(e,i),this._rootListEl=null,this._activeItem=null,this._tooltipReferenceMap=new o,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusLayerFlowItem=null,this._layerListMap=new o,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`operational-${this.uid}`,this._openedLayersController=null,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterPredicate=null,this.filterText="",this.headingLevel=2,this.knowledgeGraphOptions=null,this.layerTablesEnabled=new t(["knowledge-graph"]),this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.mapImageOptions=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=u,this.minFilterItems=g,this.openedLayers=new t,this.openedLayerLists=new t,this.selectedItems=new P,this.selectionMode="none",this.tableList=null,this.tileOptions=null,this.viewModel=new m,this.visibilityAppearance="default",this.visibleElements=new h,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const s="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,l=_(e);if(!l?.sortable)return!1;const r=_(t),a=L(t),n=_(i),d=L(i),p=!!a&&!!d&&a===d,c={selected:l,from:r,to:n},m=t.group,h=i.group,y=r?.layer?.type??"",u=n?.layer?.type??"",g=new Set(["map-image","catalog","knowledge-graph"]),f="sublayer";return m&&h&&"function"==typeof s?s.call(null,c):p&&!g.has(y)&&!g.has(u)&&l?.layer?.type!==f},this._onCatalogOpen=e=>{this.openedLayers.push(e.layer?.parent),this._focusLayerFlowItem=e.layer?.uid},this._onTablesOpen=e=>{this.openedLayers.push(e.layer),this._focusLayerFlowItem=e.layer?.uid},this._onPanelOpen=()=>{this._focusPanelFlowItem=!0},this._onTooltipReferenceChange=(e,t)=>{t?this._tooltipReferenceMap.set(e,t):this._tooltipReferenceMap.delete(e)},this._onSelectedDragItemLayerUidChange=e=>{this._selectedDragItemLayerUid=e},this._onTriggerAction=(e,t)=>{this.triggerAction(e,t)},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(p.item)));this._activeItem=_(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:s,newIndex:l}=e;if(o&&i&&!(t?.newIndex===l&&t?.dragEl===s&&t?.toEl===i&&t?.fromEl===o))if(this._lastDragDetail=e,this._selectedDragItemLayerUid=s.value,o!==i)this._moveLayerFromChildList({toEl:i,fromEl:o,dragEl:s,newIndex:l});else{const e=Array.from(o.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(o,e)}}}initialize(){this.addHandles([s((()=>this.openedLayers),"change",(()=>this._handleOpenedLayersChange()),r),s((()=>this.viewModel.operationalItems),"change",(()=>I(this.selectedItems)),r),l((()=>[this.filterPredicate,this._rootListEl]),(()=>b(this._rootListEl,this.filterPredicate)))])}loadDependencies(){return w({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this._destroyOpenedLayerLists(),this._tooltipReferenceMap.clear()}get _totalItems(){return this.viewModel.operationalItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer?.type)))).length}get _visibleItems(){return this.operationalItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}get _openedPanelItems(){return this._visibleItems.flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled))}get _dragEnabled(){return this._totalItems>=this.minDragEnabledItems&&this.dragEnabled}get _filterEnabled(){return this._totalItems>=this.minFilterItems&&this.visibleElements.filter}get _renderedOpenLayerFlowItems(){const{openedLayers:e}=this;return e.toArray().map(((t,i)=>this._renderLayerFlowItem(t,i===e.length-1)))}get icon(){return"layers"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get operationalItems(){return this.viewModel.operationalItems}set operationalItems(e){this.viewModel.operationalItems=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,{_visibleItems:t}=this,i={[C.hidden]:"loading"===e,[C.disabled]:"disabled"===e};return T("div",{class:this.classes(p.base,C.widget,C.panel,i)},t?.length?[this._renderItemTooltips(),this._renderItems()]:this._renderNoItems())}async _createFlowList(e,t){const{_layerListMap:i}=this,o=i.get(e);if(o)return o;const s="catalog"===e.type?await this._createCatalogLayerList(e):await this._createTableList(e);return t.aborted||i.set(e,s),s}async _handleOpenedLayersChange(){const{_layerListMap:e,openedLayers:t,openedLayerLists:i}=this;this._openedLayersController?.abort();const o=new AbortController,{signal:s}=o;this._openedLayersController=o,e.forEach(((i,o)=>{t.includes(o)||(i.destroy(),e.delete(o))}));const l=await Promise.all(t.map((e=>this._createFlowList(e,s))));if(s.aborted)return;i.removeAll(),i.addMany(l);const r=i.at(-1);r?"catalogLayer"in r?(this._set("catalogLayerList",r),this._set("tableList",null)):(this._set("catalogLayerList",null),this._set("tableList",r)):(this._set("catalogLayerList",null),this._set("tableList",null))}_destroyOpenedLayerLists(){this.openedLayerLists.destroyAll(),this.openedLayers.removeAll(),this._layerListMap.clear()}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?T("calcite-tooltip",{key:`tooltip-${e.layer?.uid}`,overlayPositioning:"fixed",referenceElement:t.get(e.layer?.uid)},i.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(){return this._visibleItems?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderNoItemsMessage(){return T("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return T("div",{class:p.itemMessage,key:"esri-layer-list__no-items"},T("calcite-notice",{icon:"information",kind:"info",open:!0,width:"full"},this._renderNoItemsMessage()))}async _createCatalogLayerList(e){const{default:t}=await import("./CatalogLayerList.js"),{headingLevel:i,catalogOptions:o,view:s,filterPlaceholder:l,listItemCreatedFunction:r,minFilterItems:a,selectionMode:n,visibilityAppearance:d,_onCatalogOpen:p,_onTablesOpen:c,layerTablesEnabled:m}=this;return new t({headingLevel:i,view:s,filterPlaceholder:l,listItemCreatedFunction:r,minFilterItems:a,selectionMode:n,visibilityAppearance:d,...o,catalogLayer:e,layerTablesEnabled:m,onCatalogOpen:p,onTablesOpen:c})}_getTableListParams(e){switch(e.type){case"knowledge-graph":return{...this.knowledgeGraphOptions,tables:e.tables};case"map-image":return{...this.mapImageOptions,tables:e.subtables};case"tile":return{...this.tileOptions,tables:e.subtables};default:return null}}async _createTableList(e){const{default:t}=await import("./TableList.js"),{headingLevel:i,selectionMode:o,dragEnabled:s}=this;return new t({headingLevel:i,selectionMode:o,dragEnabled:s,...this._getTableListParams(e)})}_renderLayerFlowItem(e,t){const{messages:i,openedLayers:o}=this,s=e.title||this.messages.untitledLayer;return T("calcite-flow-item",{afterCreate:this._focusLayerFlowItemNode,afterUpdate:this._focusLayerFlowItemNode,bind:this,"data-layer-uid":e.uid,description:s,heading:i["catalog"===e.type?"catalogLayers":"tables"],headingLevel:this.headingLevel,key:`flow-layer-list-${e.uid}`,selected:t,onCalciteFlowItemBack:e=>{e.preventDefault(),o.pop();const t=o.at(-1);t?this._focusLayerFlowItem=t.uid:this._focusRootFlowItem=!0}},this._layerListMap.get(e)?.render())}_renderPanelFlowItems(){const{_openedPanelItems:e,openedLayers:t}=this;return e.toArray().map((({title:i,panel:o},s)=>{const l=()=>this._handlePanelFlowItemBack(o);return T("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:i,heading:o.title,headingLevel:this.headingLevel,key:`flow-panel-${o.uid}`,selected:!t.length&&s===e.length-1,onCalciteFlowItemBack:e=>{e.preventDefault(),l()}},o.render(),T("calcite-button",{appearance:"transparent",onclick:l,slot:"footer-actions",width:"full"},this.messagesCommon.back))}))}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,F(e))}_focusLayerFlowItemNode(e){this._focusLayerFlowItem===e.dataset.layerUid&&(this._focusLayerFlowItem=null,F(e))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,F(e))}_renderItems(){const{visible:e,collapsed:t,_visibleItems:i,_openedPanelItems:o,_filterEnabled:s,_rootGroupUid:l,visibleElements:{closeButton:r,collapseButton:a,heading:n,flow:d},_dragEnabled:c,selectionMode:m,filterText:h,openedLayers:y,filterPlaceholder:u,messages:g}=this,_=[T("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:r,closed:!e,collapsed:t,collapsible:a,heading:n?g.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",selected:!y.length&&!o.length,onCalciteFlowItemClose:()=>this.visible=!1},T("calcite-list",{afterCreate:e=>{this._rootListEl=e,e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{this._rootListEl=null,e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":l,displayMode:A,dragEnabled:c,filterEnabled:s,filterPlaceholder:u,filterProps:E,filterText:s?h:"",group:l,key:"root-list",label:g.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:m,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.currentTarget?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},i?.toArray().map((e=>this._renderItem(e))),i?.length&&s?T("div",{class:p.filterNoResults,slot:"filter-no-results"},T("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(),this._renderedOpenLayerFlowItems];return e?d?T("calcite-flow",{key:"root-flow"},_):_:null}_renderItem(e,t,i){return T(c,{activeItem:this._activeItem,canMove:this._canMove,css:p,displayMode:A,dragEnabled:this.dragEnabled,item:e,key:`layerListItem-${e.layer?.uid}`,layerTablesEnabled:this.layerTablesEnabled,listModeDisabled:this.viewModel.listModeDisabled,messages:this.messages,messagesCommon:this.messagesCommon,parent:t,parentTitles:i,rootGroupUid:this._rootGroupUid,selectedDragItemLayerUid:this._selectedDragItemLayerUid,selectedItems:this.selectedItems,selectionMode:this.selectionMode,visibilityAppearance:this.visibilityAppearance,visibleElements:this.visibleElements,onAction:this._onTriggerAction,onCatalogOpen:this._onCatalogOpen,onPanelOpen:this._onPanelOpen,onSelectedDragItemLayerUidChange:this._onSelectedDragItemLayerUidChange,onTablesOpen:this._onTablesOpen,onTooltipReferenceChange:this._onTooltipReferenceChange})}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:o}){const s=_(i),l=_(e),r=_(t);this.viewModel.moveListItem(s,r,l,o)}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:o}=e;t.insertBefore(i,t.children[o])}_sortLayers(e,t){if(e)if(e===this._rootListEl)f(this.view?.map?.layers,t);else{const i=_(e);if(!i)return;v(i,t)}}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>_(e))).filter(Boolean);i.removeAll(),i.addMany(o)}};e([a()],j.prototype,"_rootListEl",void 0),e([a()],j.prototype,"_activeItem",void 0),e([a()],j.prototype,"_tooltipReferenceMap",void 0),e([a()],j.prototype,"_focusRootFlowItem",void 0),e([a()],j.prototype,"_focusPanelFlowItem",void 0),e([a()],j.prototype,"_focusLayerFlowItem",void 0),e([a()],j.prototype,"_layerListMap",void 0),e([a()],j.prototype,"_totalItems",null),e([a()],j.prototype,"_visibleItems",null),e([a()],j.prototype,"_openedPanelItems",null),e([a()],j.prototype,"_dragEnabled",null),e([a()],j.prototype,"_filterEnabled",null),e([a()],j.prototype,"_renderedOpenLayerFlowItems",null),e([a({readOnly:!0})],j.prototype,"catalogLayerList",void 0),e([a()],j.prototype,"catalogOptions",void 0),e([a()],j.prototype,"collapsed",void 0),e([a()],j.prototype,"dragEnabled",void 0),e([a()],j.prototype,"filterPlaceholder",void 0),e([a()],j.prototype,"filterPredicate",void 0),e([a()],j.prototype,"filterText",void 0),e([a()],j.prototype,"headingLevel",void 0),e([a()],j.prototype,"icon",null),e([a()],j.prototype,"knowledgeGraphOptions",void 0),e([a()],j.prototype,"label",null),e([a()],j.prototype,"layerTablesEnabled",void 0),e([a()],j.prototype,"listItemCanGiveFunction",void 0),e([a()],j.prototype,"listItemCanReceiveFunction",void 0),e([a()],j.prototype,"listItemCreatedFunction",null),e([a()],j.prototype,"mapImageOptions",void 0),e([a(),M("esri/widgets/LayerList/t9n/LayerList")],j.prototype,"messages",void 0),e([a(),M("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([a()],j.prototype,"minDragEnabledItems",void 0),e([a()],j.prototype,"minFilterItems",void 0),e([a({readOnly:!0})],j.prototype,"openedLayers",void 0),e([a({readOnly:!0})],j.prototype,"openedLayerLists",void 0),e([a()],j.prototype,"operationalItems",null),e([a()],j.prototype,"selectedItems",void 0),e([a()],j.prototype,"selectionMode",void 0),e([a({readOnly:!0})],j.prototype,"tableList",void 0),e([a()],j.prototype,"tileOptions",void 0),e([a()],j.prototype,"view",null),e([O("trigger-action"),a({type:m})],j.prototype,"viewModel",void 0),e([a()],j.prototype,"visibilityAppearance",void 0),e([a({type:h,nonNullable:!0})],j.prototype,"visibleElements",void 0),j=e([n("esri.widgets.LayerList")],j);const D=j;export{D as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{getStretchStopLabel as t,getTitle as e,isRendererTitle as r}from"../../support/styleUtils.js";function i(e,r,i){switch(r){case"heatmap-ramp":return i[e.label];case"stretch-ramp":return t(e,i);default:return e.label}}function l(t,i){if(!t.title||"string"==typeof t.title)return t.title;const l="color-ramp"===t.type||"opacity-ramp"===t.type,p=t.title,a=e(i,p,l);return r(p,l)&&p.title?`${p.title} (${a})`:a}export{l as getLegendElementTitle,i as getRampStopLabel};
5
+ import{getStretchStopLabel as t,getTitle as e,isRendererTitle as r}from"../../support/styleUtils.js";function l(e,r,l){switch(r){case"heatmap-ramp":return l[e.label]||e.label;case"stretch-ramp":return t(e,l);default:return e.label}}function i(t,l){if(!t.title||"string"==typeof t.title)return t.title;const i="color-ramp"===t.type||"opacity-ramp"===t.type,a=t.title,p=e(l,a,i);return r(a,i)&&a.title?`${a.title} (${p})`:p}export{i as getLegendElementTitle,l as getRampStopLabel};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{isSome as i,equals as a}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import c from"../../core/JSONSupport.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as d}from"../../core/maybe.js";import g from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as f,waitTick as v}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{on as b,watch as F,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as S}from"../../core/sql.js";import{getMetersPerUnitForSR as M}from"../../core/unitUtils.js";import{property as I}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{distance as C}from"../../core/libs/gl-matrix-2/math/vec2.js";import{UpdatingHandles as A}from"../../core/support/UpdatingHandles.js";import{union as V}from"../../geometry/geometryEngineAsync.js";import R from"../../geometry/Multipoint.js";import G from"../../geometry/Point.js";import O from"../../geometry/Polygon.js";import j from"../../geometry/Polyline.js";import{projectWithZConversion as L}from"../../geometry/projection.js";import z from"../../geometry/SpatialReference.js";import{isClockwise as x}from"../../geometry/support/coordsUtils.js";import{fromJSON as B}from"../../geometry/support/jsonUtils.js";import{geographicToWebMercator as E}from"../../geometry/support/webMercatorUtils.js";import H from"../../layers/GraphicsLayer.js";import{searchImages as T}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as D}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as U,computePolygonForInspection as N,resizePolygon as W,checkIfPolygonContainsSelectedPoint as q}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as $,isElevationSource as J}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as Z,imageToWorldPanoramic as K}from"../../layers/orientedImagery/transformations/imageToWorld.js";import Q from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as X}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as Y,convertPixelToHeadingPitch as ee,getImageToWorldProperties as te,getUpdateElevationProps as ie,isElevationSampler as ae,getImageToWorldPanoramicProperties as re,pointToArray as se,transformGraphicCoordinatesToPixel as oe,getWorldToImageProperties as ne,convertHeadingPitchToSphereVertex as le,or as ce}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as he,worldToImage as ue}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as pe}from"../../layers/support/floorFilterUtils.js";import me from"../../symbols/SimpleLineSymbol.js";import de from"../../views/draw/Draw.js";import{scale as ge}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ye}from"../../views/input/InputManager.js";import fe from"../PanoramicViewer.js";import{invalidCameraHeading as ve,sectorsInOrder as we,sectorsRadii as be}from"./constants.js";import{configureSketchTool as Fe,isValidDigitizationLayer as _e,extractFieldsFromDigitizationLayer as Pe}from"./digitizationUtils.js";import{isFeatureAttachment as Se,getImageSourceFromAttachment as Me}from"./galleryUtils.js";import{formatPixels as Ie,heightMeasurement2D as ke,calculateHeightAccuracy as Ce,pixelAreaMeasurement2D as Ae,pixelAreaMeasurementPanoramic as Ve,pixelDistanceMeasurement2D as Re,pixelDistanceMeasurementPanoramic as Ge,generateCombinations as Oe,getRootOfSumOfSquaredErrors as je,generateCombinationsPanoramic as Le,calculateTempImagePoint as ze,calculateAngle as xe,calculateCorrectedPixel as Be,calculateHeightFromTemporaryDistance as Ee}from"./imageMeasurementUtils.js";import{crossSymbol as He,crossSymbol3D as Te,measurementPolygonSymbol as De,polylineSymbolPanoramic as Ue,measurementPolylineSymbol as Ne,sourcePointSymbol as We,digitizationSymbol as qe,diamondSymbol as $e,diamondSymbol3D as Je,activeSourcePointSymbol as Ze}from"./symbols.js";import{isNoAttachmentError as Ke,getContentType as Qe,isTifOrMrf as Xe,filterOILLayerView as Ye,isSceneView as et,isGraphic as tt,calculateSegment as it,calculateDirection as at}from"./utils.js";import rt from"./components/ImageViewer.js";const st={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles",sketchHandles:"sketch-handles"},ot=new Set(["JPG","JPEG"]),nt=/\.(\w+)$/,lt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let ct=class extends(l.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:a,selectedPoint:r,view:s}=this;if(s?.closePopup(),a&&r){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons(i),await this._loadImage(i)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.digitizationLayer=null,this.features=new s,this.groundCoordinates=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.draw=null,this.sketchAdapter=null,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new rt,this._initialCurrentCoverageUpdate=!0,this._overlays=new H({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new fe,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new A,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.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.loadDigitizationAdapter=async e=>{const{sketchAdapter:t}=this;if(await this.loadSketch(e),"digitization"===t?.type)return t;const i=import("./adapters/sketch/DigitizationAdapter.js"),{default:a}=await i;return f(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r((async e=>{const{currentBestFeature:i,popupEnabled:a,layer:r,view:s}=this;if(s?.closePopup(),!(s&&i&&a&&r))return;const{attributes:o,geometry:n}=i,l=new t({geometry:n,attributes:o.toJSON(),layer:r});f(e),await s.openPopup({features:[l],location:o.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(st.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,ye.WIDGET),st.click)},this._createImageClickHandle=()=>{this.removeHandles(st.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:i,currentBestFeature:a,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&a))return;i.clickAction="pixel-location";let n=null;const l=b((()=>i),"pixel-location",(e=>{this.plotReferencePointOnImage(e),n?.abort(),n=r((async i=>{if(!e)return;const r=await this.getMapPoint(e,{feature:a,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return ce(!t,e.spatialReference.equals(t))?e:L(e,t)}));f(i),this.plotReferencePointOnGround(r)}))}));this.addHandles(l,st.imageClick)},this._createImageLocationHandle=()=>{this.removeHandles(st.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:i,currentBestFeature:a,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&a))return;i.clickAction="pixel-location";let n=null;const l=b((()=>i),"pixel-location",(e=>{this.pixelCoordinates=e,n?.abort(),n=r((async i=>{if(!e)return;let r=await this.getMapPoint(e,{feature:a,imageSize:o,mode:t});f(i);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await L(r,s),f(i)),this.groundCoordinates=r}))}));this.addHandles(l,st.imageClick)},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:a}=this;if(this.clearGraphics(),!i||!t||"none"===a)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:p,location:m}=r,d=(l??0)+(o??0),g=m.spatialReference.isWGS84&&4!==p?.type?E(m):new G(m);let v=s;if(Se(s))try{v=await Me(i,h,e)}catch(w){if(y(w))return;return Ke(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${i.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[i.objectIdField]:h,layer:i}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${i.objectIdField} ${h}`))}try{await this.loadImageFromSource(v,{imageRotation:d,options:e,pitch:c,yaw:n,mode:a,cameraLocation:g}),f(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:i,imageRotation:a,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(nt)?.[1]:e.datasetFormat;if(!c)try{c=await Qe(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(c??="UNKNOWN FORMAT",i){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:o.split("?")[0]},this._imageViewer.customParameters=Object.fromEntries(l),this._imageViewer.imageRotation=a??0,await this._imageViewer.loadImage(r);break;case"panoramic":if(ot.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:i,yaw:a,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=a??0;"number"==typeof n?l=n-l:s&&e&&(l=await Y(s,e)-l),this._panoramicViewer.pitch=i??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");f(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");f(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r((async t=>{const{pointerType:i,button:a,mapPoint:r}=e;if(("mouse"!==i||0===a)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,i)=>{if(await v(i),!e)return;const a=new G({...c.isSerializable(e)?e.toJSON():e});if("default"===this.mode)a.x-=.5,a.y=.5-a.y,a.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:a,symbol:He}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=ee(e,a,r),n=le(s,o);this._crossSymbol=new t({geometry:new G(n,z.WebMercator),symbol:Te}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this)}initialize(){this.addHandles([F((()=>this.view),(()=>{this.load()}),_),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),P),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),F((()=>[this.state,this.imageLocationToolState,this.view]),(()=>{this.imageLocationToolState||this.clearPreviousGroundLocation(),this._createImageLocationHandle()}),_),F((()=>this.measureType),(()=>{this.clearPreviousMeasurements()}),_),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),F((()=>this.currentBestFeature),(async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r((async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}]))),await this._featureChangedTask.promise}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(st.interactionHandles),e){case"default":this.addHandles(F((()=>this._imageViewer.imagePointsInView),(e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>a(e,t,h)}),st.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:i,vfov:a,hfov:r,pitch:s,yaw:o}=this._panoramicViewer;return e&&i&&"image-loading"!==t?[a,r,o,s]:null}),(e=>{if(!e||"image-loading"===this.state)return;const[t,i,a,s]=e;m(this._updateFootprintTask),this._updateFootprintTask=r((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:a,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>a(e,t,h)}),st.interactionHandles)}}),_),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:a,sharpness:r}=this;"default"===a&&(e.brightness=t,e.contrast=i,e.sharpness=r)}),_),F((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}))]),this.when().finally((()=>{this.notifyChange("state")}))}destroy(){this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=d(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._crossSymbol=d(this._crossSymbol),this._referencePointOnGround=d(this._referencePointOnGround),this._referencePointOnImage=d(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every((e=>0===e))??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",p(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return Xe(t)||Se(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===ve}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(Ye(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?pe(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:i}=e;return 360===t||i?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?we.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t}=this;if(t)return"disabled";if(!this.isFulfilled())return"loading";if(this.isRejected())return"error";if(null!=this._featureChangedTask&&!this._featureChangedTask.finished||this._updatingHandles.updating)return"image-loading";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:a}})=>{const r=e?.trim();return Xe(r)||Se(r)?{url:r,objectId:t,rotation:(i??0)+(a??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new H({elevationInfo:{mode:"absolute-height"}});case"default":return new H;case"none":return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}async computeHeight(e,t=!0){const{currentBestFeature:i,activeViewer:a,layer:r}=this,s=a?.imageSize,o=i?.attributes,n=r?.orientationAccuracy;if(!o||!s||!e||e.length<2||!n)return;const l=te(o,s[0],s[1]),c=e.at(0),h=e.at(-1);if(!c||!h||!n)return;const u=[h,c],p=Ie(u,!1),m=await ke(u,l,n,!0,t);if(!m)return;const d=await Ce(n,p,l,m,!0);return d?{value:m,accuracy:d}:{value:m}}async calculateAreaMeasurement(e,t,i){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const a="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(i),a?"default"===t?await Ae(e,a,!0):await Ve(e,a,!0,i):null}async calculateDistanceMeasurement(e,t,i){const{currentBestFeature:a,activeViewer:r}=this;if(e.length<2||!a||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(i),s?"default"===t?await Re([e.at(0),e.at(-1)],s,!0):await Ge([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,i){const{layer:a,currentBestFeature:r,activeViewer:s}=this,o=a?.orientationAccuracy,n=o?.every((e=>0===e))||!o?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||n)return null;const l=await this.getMeasurementProperties();if(f(i),!l)return null;const c="area"===t?await Ae(e,l,!0):await Re([e.at(0),e.at(-1)],l,!0);f(i);const{updateElevationProps:h,...u}=l,p=Oe(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async a=>{const r="area"===t?await Ae(e,a,!0):await Re([e.at(0),e.at(-1)],a,!0);if(f(i),r&&c){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-c.area):null}return Math.abs(r-c)}return null})),d=await Promise.all(m);f(i);const g=d.filter((e=>null!==e));return 0===g.length?null:je(g)}async calculateAccuracyPanoramic(e,t,i){const{layer:a,currentBestFeature:r,activeViewer:s,mode:o}=this,n=a?.orientationAccuracy,l=n?.every((e=>0===e))||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||l||"panoramic"!==o)return null;const c=await this.getMeasurementPropertiesPanoramic();if(f(i),!c)return null;const h="area"===t?await Ve(e,c,!0):await Ge([e.at(0),e.at(-1)],c,!0);f(i);const{updateElevationProps:u,...p}=c,m=Le(p,n);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async a=>{const r="area"===t?await Ve(e,a,!0):await Ge([e.at(0),e.at(-1)],a,!0);if(f(i),r&&h){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-h.area):null}return Math.abs(r-h)}return null})),g=await Promise.all(d);f(i);const y=g.filter((e=>null!==e));return 0===y.length?null:je(y)}async calculateHeightMeasurementInfo(e,t){const{currentBestFeature:i,activeViewer:a}=this,r=a?.imageSize;if(!i||!a||!r?.length)return;const{attributes:s}=i,[o]=Ie([e],!0),n=te(s,r[0],r[1]),l=await ze(o,n,t);if(!l)return;const c=xe(o,l),h=C([o.x,o.y],[l.x,l.y]);return c&&h?{measurementAngle:c,tempDistance:h}:void 0}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.pixelCoordinates=null}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null)}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:i,digitizationLayer:a}=this;if(!i)throw lt();Fe(a,e,i),await i.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw lt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw lt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw lt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw lt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw lt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw lt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:i}=this,a=t?.imageSize,r=e?.attributes;if(!r||!a)return;const s=await this.computeHeight(i);s?.value&&s?.accuracy&&(this.heightMeasurementResult=s.value,this.heightMeasurementAccuracy=s.accuracy)}filterByFootprints(e,t){const i=[],a=[],r=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:o}=e;let n;const l=M(e.geometry.spatialReference);o.cameraHeight/=l,o.farDistance/=l,o.nearDistance/=l,$(o.elevationSource)&&(o.elevationSource.constantElevation/=l);const{polygon:c,frustum:h}=U(o);if(n=c.clone(),o.isInspection&&(n=N(o)),s&&(n=W(n,s)),q(n,t)){r.push(e);const{geometry:t,objectId:s,cameraHeight:n,cameraHeading:l}=o,u=t.clone();u.z=n,u.imageID=s,this.pointSources.push(u),l!==ve&&(i.push(c),h&&a.push(h))}})),{features:r,polygons:i,frustums:a}}getMeasurementProperties(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:i,attributes:a}=e,{elevationSource:r,cameraHeight:s}=a,o=te(a,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?L(n,z.WebMercator):Promise.resolve(n)).then((e=>(n=e,ie((n.z??0)-s,{elevationSample:i,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ae(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:i,attributes:a}=e,{elevationSource:r,cameraHeight:s}=a,o=re(a,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?L(n,z.WebMercator):Promise.resolve(n)).then((e=>(n=e,ie((n.z??0)-s,{elevationSample:i,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ae(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDigitizedFeatures(e){const{digitizationLayer:t}=this;if(!t)throw new n("Digitization 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?.[we[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const a=this._sectorData?.[t];a?.length&&this._updateCurrentBestFeature(a.at(i))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:i,heightMeasurementPixels:a}=this;if(!e.vertices)return;const r=e.vertices.at(-1);if(a.length<1||!r||!i||!t)return;const s=Be(a[0],r,t);if(!s?.length)return;this.heightMeasurementPixels.push(s),this.createPolylineGraphic();const o=Ee(this.heightMeasurementPixels,i);o&&(this.heightMeasurementResult=o)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:i,activeViewer:a,heightMeasurementPixels:r}=this;if(!i||!a||!e.vertices?.length)return;const s=a?.imageSize;if(!r.length&&s){const i=e.vertices.at(-1);this.heightMeasurementPixels.push(i);const a=await this.calculateHeightMeasurementInfo(i,t);if(!a?.measurementAngle||!a?.tempDistance)return;this.measurementAngle=a.measurementAngle,this.tempDistance=a.tempDistance}}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.imageLocationToolState=!1,this.selectedPoint=e.spatialReference.isGeographic?E(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:i}=await t;f(e),this.sketch=new i({layer:this._sketchGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:i}=await t;if(f(e),this.sketchAdapter=new i({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async startMeasurement(e,t){await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:i,sketchAdapter:a,activeViewer:r,mode:s}=this;if(!i||!a||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(i.defaultCreateOptions.defaultZ=0),await i.create(e),"panoramic"===s){const{drawOperation:e}=i.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=De(o),this.sketch.polylineSymbol="panoramic"===s?Ue:Ne(o))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new de({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],(e=>this.handleDrawEvents(e)))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],i=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[e],spatialReference:i});else{const a=new j({paths:[e],spatialReference:i}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:a,symbol:Ne(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:i,currentBestFeature:a,overlayedCameraLocations:r,layer:s,mode:o,state:n}=this,l=i?.imageSize;if(!l||!a||!s||"none"===o||n.includes("loading"))return;const{polygon:c}=U(a.attributes);if(i.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:`${s.objectIdField} <> ${a.attributes.objectId}`,geometry:c,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:i,geometry:r}=e,s=await this.getPixels(r,{feature:a,imageSize:l,mode:o}),n=We.clone();return n.outline=new me({color:[0,0,0],width:1}),new t({attributes:i,symbol:n,geometry:s})})));r.addMany(n),i.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:l}=this,c=r?.imageSize;if(!c||!o||"none"===n||l.includes("loading"))return;const{polygon:h}=U(o.attributes),p=_e(e);try{const{imageGeometryField:t,oiObjectIdField:i}=Pe(e);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:h,returnGeometry:!0,outFields:["*"]}),d=new s((await Promise.all(m.map((async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:l}=i;let h=l;if(p&&this.imageGeometryField&&this.oiObjectIdField){if(s[this.oiObjectIdField]===`${o.attributes.objectId}`)return h=B(JSON.parse(atob(s[this.imageGeometryField]))),new t({attributes:s,layer:e,symbol:h.type===e.geometryType?r:qe(h.type)?.()??null,geometry:h,visible:e.visible&&a})}switch(h?.type){case"point":{const i=await this.getPixels(h,{feature:o,imageSize:c,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:l}=h,u=i.map((e=>e.map((([e,t,i])=>new G({x:e,y:t,z:i,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:c,mode:n}).then((e=>e.map(se))))));return new t({attributes:s,layer:e,symbol:r,geometry:new O({rings:p,spatialReference:z.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:l}=h,u=i.map((e=>e.map((([e,t,i])=>new G({x:e,y:t,z:i,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:c,mode:n}).then((e=>e.map(se))))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({paths:p,spatialReference:z.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:l}=h,u=i.map((([e,t,i])=>new G({x:e,y:t,z:i,spatialReference:l}))),p=await this.getPixels(u,{feature:o,imageSize:c,mode:n}).then((e=>e.map(se)));return new t({attributes:s,layer:e,symbol:r,geometry:new R({points:p,spatialReference:z.WebMercator}),visible:e.visible&&a})}}return null})))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,d)}async getPixels(e,t){const{imageSize:i,mode:a}=t,r=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===a)return new G({x:e.x-.5,y:.5-e.y,spatialReference:z.WebMercator});const[t,r]=i,{heading:s,pitch:o}=ee(e,t,r),n=le(s,o);return new G(n,z.WebMercator)}));return Array.isArray(e)?r:r[0]}async getMapPoint(e,t){const{feature:i,mode:a,imageSize:r}=t,{elevationSample:s,attributes:o}=i,{elevationSource:n,location:l,elevation:c,cameraHeight:h}=o;let u=l.clone();u.spatialReference.isGeographic&&(u=await L(u,z.WebMercator));const p=await ie(c??(l.z??0)-h,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let m;if("elevationSample"in p&&ae(p.elevationSample)&&(i.elevationSample=p.elevationSample),"default"===a){const t=te(o,r[0],r[1]);m=await Z(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}else{const t=re(o,r[0],r[1]);m=await K(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}return Array.isArray(e)?m:m[0]}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new G({...e.toJSON()}),symbol:$e}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const i=c.isSerializable(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._referencePointOnImage=new t({geometry:new G({spatialReference:this._imageViewer.imageRenderer.spatialReference.clone(),...i}),symbol:$e}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=ee(e,a,r),n=le(s,o);this._referencePointOnImage=new t({geometry:new G(n,z.WebMercator),symbol:Je}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null}async saveDrawing(){const{digitizationLayer:e,sketchAdapter:t}=this;if(!e||"digitization"!==t?.type)return;const{pendingGraphics:i,savedGraphics:a}=t,r=i.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDigitizedFeatures(s),n=o.reduce(((t,{objectId:i,globalId:a,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(i&&(l[e.objectIdField]=i),a&&e.globalIdField&&(l[e.globalIdField]=a),t.success.push(n)),t}),{success:[],error:[]});a.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDigitizedFeatures(e){const{activeViewer:t,currentBestFeature:a,digitizationLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s)throw new n("Image size, current best feature and mode are required to save digitized features");if(!r)throw new n("Digitization layer is not available");const l=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,l=r.hasZ,c=r.geometryType,h=n!==c,u=h?await import("./transformers.js"):null,p=u?.default[c],m=h?p?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(oe(s,m,o),{feature:a,imageSize:o,mode:s}),l||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map((async e=>this.getMapPoint(e.map((([e,t,i])=>oe(s,{x:e,y:t,z:i},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new O({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,rings:e.map((e=>e.map(se)))}),t}case"polyline":{const e=await Promise.all(m.paths.map((async e=>this.getMapPoint(e.map((([e,t,i])=>oe(s,{x:e,y:t,z:i},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new j({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,paths:e.map((e=>e.map(se)))}),t}}}))),c=l.filter(i);return r.applyEdits({addFeatures:c}).then((e=>{const{addFeatureResults:t}=e;let i=0;const a=l.map((e=>{const a=t[i++];return e?a:{error:new n("Error in saving digitized features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:a}}))}async searchBestImage(e,t){try{const i=await T(e,t);i&&await this._processFeatureResponse(i,e.point,{signal:t?.signal})}catch(i){y(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async startDigitization(e,t){const i=this.activeViewer?.imageRenderer;if(!i)return;const a=this.overlayedMapFeatures.get(e.id)?.toArray()??[];this.removeOverlayedGraphicsOnImage(e.id),this.collectionId=e.id,await this.loadSketch(t),await this.loadDigitizationAdapter(t),f(t),this.sketchGraphicsLayer?.addMany(a),this.sketchAdapter?.savedGraphics.addMany(a);i.ui.find("zoom").visible=!1,i.map.layers.add(this.sketchGraphicsLayer)}stopDigitization(e){this.sketch?.cancel();const t=this.sketchAdapter?.savedGraphics;this.sketchGraphicsLayer?.removeAll();const i=this.activeViewer?.imageRenderer;if(!t||!i)return;if(this.overlayGraphicsOnImage(e,t),i.destroyed)return;i.map.layers.remove(this.sketchGraphicsLayer);const a=i.ui.find("zoom");a&&(a.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const i=this.overlayedMapFeatures.get(e);i&&this._toggleVisiblity(i,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e;let a=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await L(t,s.spatialReference);a=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await L(t,s.spatialReference);r=s.extent.contains(e);break}}if(!a&&!r)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,i);if(o)return f(i),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}updateSuitabilities(e){e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const t=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(t),this._groupFeaturesBySectors()}async _fetchFeatures(e,t){if(!this.view)return;const i=this.layer;if(i){const a={include:i},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,a);return this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(y(i))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:i,features:a,invalidCameraHeading:r}=this;if(!e||!t||!i||!a||r)return void(this._sectorData=null);this._sectorData={};for(const c of we)this._sectorData[c]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const n=o.map((({distance:e})=>e)),l=Math.max(...n);o.forEach((e=>{const{distance:t,angle:i,featureIndex:r}=e,s=t/l*be[2],o=it(t,l),n=at(i);if(!this._sectorData)return;const c=be[3]+s*Math.sin(i*Math.PI/180),h=be[3]+s*Math.cos(i*Math.PI/180);let u;const p=a.at(r),m=p===this.currentBestFeature,d=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(m&&d)u=-90;else{const e=c-be[3],t=h-be[3],i=t/Math.sqrt(e**2+t**2);let a=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(a*=-1),u=a}const g=""===o?n:`${o}_${n}`;m&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=d?null:{x:c,y:h,direction:n});const y=this._sectorData[g];y.add({angle:i,featureIndex:r,x:c,y:h,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t,i){const{features:a}=e;if(!a?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:r,polygons:s,frustums:o}=this.filterByFootprints(a,t);if(!r.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);let n;if(this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o),s[0]){let e=new O({spatialReference:s[0].spatialReference});for(const i of s)e=await V(e,i);const t=[];for(const{geometry:i}of r)e.contains(i)||t.push([i.x,i.y]);if(t.sort(((e,t)=>+x([e,t]))),e.addRing(t),this.footprintExtent=ge(e.extent,2,2),this.view?.supportsGround)try{n=await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(l){y(l)||u.getLogger(this).error(l)}}if((n||r[0].attributes.elevationSource)&&this.footprintExtent){const e=r[0].attributes.elevationSource;J(e)&&!n&&(n=await X({extent:this.footprintExtent,lod:e.lod,url:e.url,rasterFunction:e.rasterFunction}));const i=await ie((r[0].attributes.location.z??0)-r[0].attributes.cameraHeight,{elevationSample:n,elevationSource:e,extent:this.footprintExtent}),[a,...s]=await Q([t,...r.map((e=>e.attributes.geometry.clone()))],i);r[0].elevationSample=n??i.elevationSample,t.elevation=a.z,r.forEach(((e,t)=>{e.attributes.elevation=s[t].z}))}r[0].elevationSample&&r.forEach((e=>{e.elevationSample=r[0].elevationSample})),this._suitabilities=D({features:r,selectedPoint:t,camera:et(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,i){const{screenPoint:a,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(a);if(!o)return;const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await L(o,e.spatialReference),c=S("1=1",S(e.definitionExpression,n)),h=l.spatialReference.isGeographic?1:M(l.spatialReference),u={layerInstanceOrURL:e,point:l,queryParams:{where:c,maximumDistance:e.maximumDistance?e.maximumDistance/h:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(u,i)}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this.currentBestFeature=e[0]}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:a,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s}=this;if(a&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),f(e);for(const e of i)e.imageID===a.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e,symbol:Ze,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:We,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-be[3],a=e.y-be[3],r=a/Math.sqrt(t**2+a**2);let s=180*Math.acos(r)/Math.PI;(t<0&&a<0||t<0&&a>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=d(this._referencePointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,a){this.displayMessage={key:e,type:t,data:i,map:a}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:i,selectedPoint:a,state:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=d(this._crossSymbol)),!a||!t||"image-loaded"!==r||i)return;let s;try{s=await this.worldToImage(a,e),f(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:a,feature:t})}}async worldToImage(e,t){const{footprintExtent:i}=this,{imageSize:a}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!a||!i)return;const{attributes:{location:r,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:l},elevationSample:c}=this.currentBestFeature;let h=r.clone();const u=await ie(n??(r.z??0)-l,{elevationSample:c,elevationSource:s});this.currentBestFeature.elevationSample=u.elevationSample;const p=Array.isArray(e)?e:[e];let m,d=await Promise.all(p.map((e=>new Promise((t=>{if(!e.hasZ)return t(Q(e,u));t(e)})))));if(r.spatialReference.isGeographic&&(h=await L(h,z.WebMercator,t)),d=await Promise.all(d.map((async e=>h.spatialReference.equals(e.spatialReference)?e:await L(e,h.spatialReference,t)))),f(t),"panoramic"===this.mode)m=he(d,{imageHeight:a[1],imageWidth:a[0],cameraHeading:o,cameraLocation:h});else{const e=ne(this.currentBestFeature.attributes,a[0],a[1]);m=ue(d,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:a,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c}=this,{attributes:{objectId:h},elevationSample:u}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...a,this.bestFeatureCurrentFootprint,s].filter(tt);l.supportsGround&&u&&c?.updateGroundElevation&&c.updateGroundElevation(e,u),n&&e.push(new t({geometry:n.clone(),symbol:He.clone(),attributes:{imageID:h}})),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&u&&c?.updateGroundElevation&&c.updateGroundElevation([e],u),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([I()],ct.prototype,"activeLayer",null),e([I({readOnly:!0})],ct.prototype,"activeViewer",null),e([I()],ct.prototype,"accuracyParametersMissing",null),e([I()],ct.prototype,"additionalFeatures",void 0),e([I({type:s.ofType(t)})],ct.prototype,"additionalCameraLocations",void 0),e([I({type:s.ofType(t)})],ct.prototype,"additionalFootprints",void 0),e([I()],ct.prototype,"areaMeasurementResult",void 0),e([I()],ct.prototype,"areaMeasurementAccuracy",void 0),e([I()],ct.prototype,"bestFeatureAngle",void 0),e([I()],ct.prototype,"bestFeatureCurrentFootprint",void 0),e([I({type:t})],ct.prototype,"bestFeatureFootprint",void 0),e([I({type:Number})],ct.prototype,"brightness",null),e([I()],ct.prototype,"collectionId",void 0),e([I({type:Number})],ct.prototype,"contrast",null),e([I()],ct.prototype,"conversionProps",void 0),e([I()],ct.prototype,"coverageFrustums",void 0),e([I()],ct.prototype,"coveragePolygons",void 0),e([I()],ct.prototype,"currentBestFeature",void 0),e([I()],ct.prototype,"currentBestFeatureLocation",void 0),e([I()],ct.prototype,"currentCoverageVisible",void 0),e([I({json:{write:!1}})],ct.prototype,"determineWorkflowForFeature",void 0),e([I()],ct.prototype,"disabled",void 0),e([I()],ct.prototype,"displayMessage",void 0),e([I()],ct.prototype,"displayNewMeasurementButton",void 0),e([I()],ct.prototype,"distanceMeasurementResult",void 0),e([I()],ct.prototype,"distanceAccuracyArray",void 0),e([I()],ct.prototype,"digitizationLayer",void 0),e([I({readOnly:!0})],ct.prototype,"featureCount",null),e([I()],ct.prototype,"features",void 0),e([I()],ct.prototype,"groundCoordinates",void 0),e([I()],ct.prototype,"heightMeasurementPixels",void 0),e([I()],ct.prototype,"heightGraphic",void 0),e([I()],ct.prototype,"heightMeasurementResult",void 0),e([I()],ct.prototype,"heightMeasurementAccuracy",void 0),e([I()],ct.prototype,"measurementAngle",void 0),e([I()],ct.prototype,"tempDistance",void 0),e([I({readOnly:!0})],ct.prototype,"imageGalleryEnabled",null),e([I()],ct.prototype,"imageGeometryField",void 0),e([I({readOnly:!0})],ct.prototype,"imageLoaded",null),e([I()],ct.prototype,"imageLocationToolState",void 0),e([I({readOnly:!0})],ct.prototype,"invalidCameraHeading",null),e([I()],ct.prototype,"imagePointsInView",null),e([I()],ct.prototype,"isAdditionalCoverageVisible",void 0),e([I()],ct.prototype,"isAdditionalPointSourcesVisible",void 0),e([I()],ct.prototype,"layer",void 0),e([I()],ct.prototype,"layerView",null),e([I({readOnly:!0})],ct.prototype,"layerFloorFilterClause",null),e([I({type:Number})],ct.prototype,"localPort",void 0),e([I()],ct.prototype,"mapImageConversionToolState",void 0),e([I()],ct.prototype,"measureType",void 0),e([I()],ct.prototype,"measurementGraphic",void 0),e([I({readOnly:!0,value:"none"})],ct.prototype,"mode",null),e([I()],ct.prototype,"navigatorCurrentBestFeature",void 0),e([I()],ct.prototype,"oiObjectIdField",void 0),e([I({type:s.ofType(t)})],ct.prototype,"overlayedCameraLocations",void 0),e([I()],ct.prototype,"overlayedMapFeatures",void 0),e([I()],ct.prototype,"pixelCoordinates",void 0),e([I()],ct.prototype,"pointSources",void 0),e([I({readOnly:!0})],ct.prototype,"popupEnabled",null),e([I()],ct.prototype,"previousFeatureAngle",void 0),e([I()],ct.prototype,"referencePoint",null),e([I({readOnly:!0})],ct.prototype,"sectorData",null),e([I()],ct.prototype,"selectedPoint",void 0),e([I({type:Number})],ct.prototype,"sharpness",null),e([I()],ct.prototype,"shouldShowSelectedImage",void 0),e([I()],ct.prototype,"sketch",void 0),e([I()],ct.prototype,"draw",void 0),e([I()],ct.prototype,"sketchAdapter",void 0),e([I({readOnly:!0})],ct.prototype,"sketchGraphicsLayer",null),e([I({readOnly:!0})],ct.prototype,"state",null),e([I({readOnly:!0})],ct.prototype,"thumbnails",null),e([I()],ct.prototype,"updateFootprint",void 0),e([I()],ct.prototype,"updateFootprintPanorama",void 0),e([I({value:null})],ct.prototype,"view",null),e([I()],ct.prototype,"_adapter",void 0),e([I()],ct.prototype,"_sketchGraphicsLayer",null),e([I()],ct.prototype,"_highlightedFeatureHandle",void 0),e([I()],ct.prototype,"_imageViewer",void 0),e([I()],ct.prototype,"_initialCurrentCoverageUpdate",void 0),e([I()],ct.prototype,"_overlays",void 0),e([I({readOnly:!0})],ct.prototype,"_overlaysView",null),e([I()],ct.prototype,"_panoramicViewer",void 0),e([I()],ct.prototype,"_referencePointOnGround",void 0),e([I()],ct.prototype,"_referencePointOnImage",void 0),e([I()],ct.prototype,"_sectorData",void 0),e([I({readOnly:!0})],ct.prototype,"_updatingHandles",void 0),e([I()],ct.prototype,"footprintExtent",void 0),e([I()],ct.prototype,"_featureChangedTask",void 0),ct=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],ct);const ht=ct;export{ht as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{isSome as i,equals as a}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import c from"../../core/JSONSupport.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as d}from"../../core/maybe.js";import g from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as f,waitTick as v}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{on as b,watch as F,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as S}from"../../core/sql.js";import{getMetersPerUnitForSR as M}from"../../core/unitUtils.js";import{property as I}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{distance as C}from"../../core/libs/gl-matrix-2/math/vec2.js";import{UpdatingHandles as A}from"../../core/support/UpdatingHandles.js";import{union as V}from"../../geometry/geometryEngineAsync.js";import G from"../../geometry/Multipoint.js";import R from"../../geometry/Point.js";import O from"../../geometry/Polygon.js";import x from"../../geometry/Polyline.js";import{projectWithZConversion as j}from"../../geometry/projection.js";import z from"../../geometry/SpatialReference.js";import{isClockwise as L}from"../../geometry/support/coordsUtils.js";import{fromJSON as B}from"../../geometry/support/jsonUtils.js";import{geographicToWebMercator as E}from"../../geometry/support/webMercatorUtils.js";import H from"../../layers/GraphicsLayer.js";import{searchImages as D}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as T}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as U,computePolygonForInspection as N,resizePolygon as W,checkIfPolygonContainsSelectedPoint as q}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as $,isElevationSource as J}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as Z,imageToWorldPanoramic as K}from"../../layers/orientedImagery/transformations/imageToWorld.js";import Q from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as X}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as Y,convertPixelToHeadingPitch as ee,getImageToWorldProperties as te,getUpdateElevationProps as ie,isElevationSampler as ae,getImageToWorldPanoramicProperties as re,pointToArray as se,transformGraphicCoordinatesToPixel as oe,getWorldToImageProperties as ne,convertHeadingPitchToSphereVertex as le,or as ce}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as he,worldToImage as ue}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as pe}from"../../layers/support/floorFilterUtils.js";import me from"../../symbols/SimpleLineSymbol.js";import de from"../../views/draw/Draw.js";import{scale as ge}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ye}from"../../views/input/InputManager.js";import fe from"../PanoramicViewer.js";import{invalidCameraHeading as ve,sectorsInOrder as we,sectorsRadii as be}from"./constants.js";import{configureSketchTool as Fe,isValidDigitizationLayer as _e,extractFieldsFromDigitizationLayer as Pe}from"./digitizationUtils.js";import{isFeatureAttachment as Se,getImageSourceFromAttachment as Me}from"./galleryUtils.js";import{formatPixels as Ie,heightMeasurementPanoramic as ke,heightMeasurement2D as Ce,calculateHeightAccuracyPanoramic as Ae,calculateHeightAccuracy as Ve,pixelAreaMeasurement2D as Ge,pixelAreaMeasurementPanoramic as Re,pixelDistanceMeasurement2D as Oe,pixelDistanceMeasurementPanoramic as xe,generateCombinations as je,getRootOfSumOfSquaredErrors as ze,generateCombinationsPanoramic as Le,calculateReferenceImagePointPanoramic as Be,calculateAnglePano as Ee,calculateTempImagePoint as He,calculateAngle as De,getModeCorrectedPoint as Te,calculateCorrectedPixel as Ue,calculateHeightFromTemporaryDistance as Ne}from"./imageMeasurementUtils.js";import{crossSymbol as We,crossSymbol3D as qe,measurementPolygonSymbol as $e,polylineSymbolPanoramic as Je,measurementPolylineSymbol as Ze,sourcePointSymbol as Ke,digitizationSymbol as Qe,diamondSymbol as Xe,diamondSymbol3D as Ye,activeSourcePointSymbol as et}from"./symbols.js";import{isNoAttachmentError as tt,getContentType as it,isTifOrMrf as at,filterOILLayerView as rt,isSceneView as st,isGraphic as ot,calculateSegment as nt,calculateDirection as lt}from"./utils.js";import ct from"./components/ImageViewer.js";const ht={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles",sketchHandles:"sketch-handles"},ut=new Set(["JPG","JPEG"]),pt=/\.(\w+)$/,mt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let dt=class extends(l.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:a,selectedPoint:r,view:s}=this;if(s?.closePopup(),a&&r){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons(i),await this._loadImage(i)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.digitizationLayer=null,this.features=new s,this.groundCoordinates=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.draw=null,this.sketchAdapter=null,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new ct,this._initialCurrentCoverageUpdate=!0,this._overlays=new H({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new fe,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new A,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.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.loadDigitizationAdapter=async e=>{const{sketchAdapter:t}=this;if(await this.loadSketch(e),"digitization"===t?.type)return t;const i=import("./adapters/sketch/DigitizationAdapter.js"),{default:a}=await i;return f(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r((async e=>{const{currentBestFeature:i,popupEnabled:a,layer:r,view:s}=this;if(s?.closePopup(),!(s&&i&&a&&r))return;const{attributes:o,geometry:n}=i,l=new t({geometry:n,attributes:o.toJSON(),layer:r});f(e),await s.openPopup({features:[l],location:o.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(ht.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,ye.WIDGET),ht.click)},this._createImageClickHandle=()=>{this.removeHandles(ht.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:i,currentBestFeature:a,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&a))return;i.clickAction="pixel-location";let n=null;const l=b((()=>i),"pixel-location",(e=>{this.plotReferencePointOnImage(e),n?.abort(),n=r((async i=>{if(!e)return;const r=await this.getMapPoint(e,{feature:a,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return ce(!t,e.spatialReference.equals(t))?e:j(e,t)}));f(i),this.plotReferencePointOnGround(r)}))}));this.addHandles(l,ht.imageClick)},this._createImageLocationHandle=()=>{this.removeHandles(ht.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:i,currentBestFeature:a,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&a))return;i.clickAction="pixel-location";let n=null;const l=b((()=>i),"pixel-location",(e=>{this.pixelCoordinates=e,n?.abort(),n=r((async i=>{if(!e)return;let r=await this.getMapPoint(e,{feature:a,imageSize:o,mode:t});f(i);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await j(r,s),f(i)),this.groundCoordinates=r}))}));this.addHandles(l,ht.imageClick)},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:a}=this;if(this.clearGraphics(),!i||!t||"none"===a)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:p,location:m}=r,d=(l??0)+(o??0),g=m.spatialReference.isWGS84&&4!==p?.type?E(m):new R(m);let v=s;if(Se(s))try{v=await Me(i,h,e)}catch(w){if(y(w))return;return tt(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${i.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[i.objectIdField]:h,layer:i}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${i.objectIdField} ${h}`))}try{await this.loadImageFromSource(v,{imageRotation:d,options:e,pitch:c,yaw:n,mode:a,cameraLocation:g}),f(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:i,imageRotation:a,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(pt)?.[1]:e.datasetFormat;if(!c)try{c=await it(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(c??="UNKNOWN FORMAT",i){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:o.split("?")[0]},this._imageViewer.customParameters=Object.fromEntries(l),this._imageViewer.imageRotation=a??0,await this._imageViewer.loadImage(r);break;case"panoramic":if(ut.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:i,yaw:a,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=a??0;"number"==typeof n?l=n-l:s&&e&&(l=await Y(s,e)-l),this._panoramicViewer.pitch=i??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");f(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");f(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r((async t=>{const{pointerType:i,button:a,mapPoint:r}=e;if(("mouse"!==i||0===a)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,i)=>{if(await v(i),!e)return;const a=new R({...c.isSerializable(e)?e.toJSON():e});if("default"===this.mode)a.x-=.5,a.y=.5-a.y,a.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:a,symbol:We}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=ee(e,a,r),n=le(s,o);this._crossSymbol=new t({geometry:new R(n,z.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),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this)}initialize(){this.addHandles([F((()=>this.view),(()=>{this.load()}),_),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),P),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),F((()=>[this.state,this.imageLocationToolState,this.view]),(()=>{this.imageLocationToolState||this.clearPreviousGroundLocation(),this._createImageLocationHandle()}),_),F((()=>this.measureType),(()=>{this.clearPreviousMeasurements()}),_),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),F((()=>this.currentBestFeature),(async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r((async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}]))),await this._featureChangedTask.promise}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(ht.interactionHandles),e){case"default":this.addHandles(F((()=>this._imageViewer.imagePointsInView),(e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>a(e,t,h)}),ht.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:i,vfov:a,hfov:r,pitch:s,yaw:o}=this._panoramicViewer;return e&&i&&"image-loading"!==t?[a,r,o,s]:null}),(e=>{if(!e||"image-loading"===this.state)return;const[t,i,a,s]=e;m(this._updateFootprintTask),this._updateFootprintTask=r((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:a,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>a(e,t,h)}),ht.interactionHandles)}}),_),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:a,sharpness:r}=this;"default"===a&&(e.brightness=t,e.contrast=i,e.sharpness=r)}),_),F((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}))]),this.when().finally((()=>{this.notifyChange("state")}))}destroy(){this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=d(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._crossSymbol=d(this._crossSymbol),this._referencePointOnGround=d(this._referencePointOnGround),this._referencePointOnImage=d(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every((e=>0===e))??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",p(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return at(t)||Se(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===ve}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(rt(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?pe(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:i}=e;return 360===t||i?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?we.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:i},_featureChangedTask:a}=this;if(t)return"disabled";if(!this.isFulfilled()||i||!1===a?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:a}})=>{const r=e?.trim();return at(r)||Se(r)?{url:r,objectId:t,rotation:(i??0)+(a??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new H({elevationInfo:{mode:"absolute-height"}});case"default":return new H;case"none":return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}async computeHeight(e,t,i=!0){const{currentBestFeature:a,activeViewer:r,layer:s,footprintExtent:o}=this,n=r?.imageSize,l=a?.attributes,c=s?.orientationAccuracy;if(!l||!n||!e||e.length<2||!c)return;const h="panoramic"===t?await this.getMeasurementPropertiesPanoramic():te(l,n[0],n[1]),u=e.at(0),p=e.at(-1);if(!(h&&u&&p&&c&&o))return;const m=[p,u],d=Ie(m,!1),g="panoramic"===t?await ke(m,h,c,a,!0,!1):await Ce(m,h,c,!0,i);if(!g)return;const y="panoramic"===t?await Ae(c,d,h,g,a,!0):await Ve(c,d,h,g,!0);return y?{value:g,accuracy:y}:{value:g}}async calculateAreaMeasurement(e,t,i){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const a="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(i),a?"default"===t?await Ge(e,a,!0):await Re(e,a,!0,i):null}async calculateDistanceMeasurement(e,t,i){const{currentBestFeature:a,activeViewer:r}=this;if(e.length<2||!a||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(i),s?"default"===t?await Oe([e.at(0),e.at(-1)],s,!0):await xe([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,i){const{layer:a,currentBestFeature:r,activeViewer:s}=this,o=a?.orientationAccuracy,n=o?.every((e=>0===e))||!o?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||n)return null;const l=await this.getMeasurementProperties();if(f(i),!l)return null;const c="area"===t?await Ge(e,l,!0):await Oe([e.at(0),e.at(-1)],l,!0);f(i);const{updateElevationProps:h,...u}=l,p=je(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async a=>{const r="area"===t?await Ge(e,a,!0):await Oe([e.at(0),e.at(-1)],a,!0);if(f(i),r&&c){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-c.area):null}return Math.abs(r-c)}return null})),d=await Promise.all(m);f(i);const g=d.filter((e=>null!==e));return 0===g.length?null:ze(g)}async calculateAccuracyPanoramic(e,t,i){const{layer:a,currentBestFeature:r,activeViewer:s,mode:o}=this,n=a?.orientationAccuracy,l=n?.every((e=>0===e))||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||l||"panoramic"!==o)return null;const c=await this.getMeasurementPropertiesPanoramic();if(f(i),!c)return null;const h="area"===t?await Re(e,c,!0):await xe([e.at(0),e.at(-1)],c,!0);f(i);const{updateElevationProps:u,...p}=c,m=Le(p,n);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async a=>{const r="area"===t?await Re(e,a,!0):await xe([e.at(0),e.at(-1)],a,!0);if(f(i),r&&h){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-h.area):null}return Math.abs(r-h)}return null})),g=await Promise.all(d);f(i);const y=g.filter((e=>null!==e));return 0===y.length?null:ze(y)}async calculateHeightMeasurementInfo(e,t,i){const{currentBestFeature:a,activeViewer:r}=this,s=r?.imageSize;if(!a||!r||!s?.length||"none"===t)return;const{attributes:o}=a,[n]=Ie([e],"panoramic"!==t),l="panoramic"===t?await this.getMeasurementPropertiesPanoramic():te(o,s[0],s[1]);if("panoramic"===t){if(!l)return;const e=await Be(n,l,a,i);if(!e)return;e?.heading>180&&(e.heading-=360);const t=Ee(n,e),r=C([n.x,n.y],[e.x,e.y]);if(!t||!r)return;return{measurementAngle:t,tempDistance:r}}const c=await He(n,l,i);if(!c)return;const h=De(n,c),u=C([n.x,n.y],[c.x,c.y]);return h&&u?{measurementAngle:h,tempDistance:u}:void 0}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.pixelCoordinates=null}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null)}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:i,digitizationLayer:a}=this;if(!i)throw mt();Fe(a,e,i),await i.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw mt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw mt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw mt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw mt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw mt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw mt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:i,mode:a}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(i,a);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t){const i=[],a=[],r=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:o}=e;let n;const l=M(e.geometry.spatialReference);o.cameraHeight/=l,o.farDistance/=l,o.nearDistance/=l,$(o.elevationSource)&&(o.elevationSource.constantElevation/=l);const{polygon:c,frustum:h}=U(o);if(n=c.clone(),o.isInspection&&(n=N(o)),s&&(n=W(n,s)),q(n,t)){r.push(e);const{geometry:t,objectId:s,cameraHeight:n,cameraHeading:l}=o,u=t.clone();u.z=n,u.imageID=s,this.pointSources.push(u),l!==ve&&(i.push(c),h&&a.push(h))}})),{features:r,polygons:i,frustums:a}}getMeasurementProperties(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:i,attributes:a}=e,{elevationSource:r,cameraHeight:s}=a,o=te(a,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?j(n,z.WebMercator):Promise.resolve(n)).then((e=>(n=e,ie((n.z??0)-s,{elevationSample:i,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ae(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:i,attributes:a}=e,{elevationSource:r,cameraHeight:s}=a,o=re(a,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?j(n,z.WebMercator):Promise.resolve(n)).then((e=>(n=e,ie((n.z??0)-s,{elevationSample:i,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ae(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDigitizedFeatures(e){const{digitizationLayer:t}=this;if(!t)throw new n("Digitization 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?.[we[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const a=this._sectorData?.[t];a?.length&&this._updateCurrentBestFeature(a.at(i))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:i,heightMeasurementPixels:a,mode:r,activeViewer:s}=this,o=s?.imageSize;if(!e.vertices||!o)return;const n=Te(e.vertices.at(-1),r,o);if(a.length<1||!n||!i||!t||"none"===r)return;const l=Ue(a[0],n,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const c=Ne(this.heightMeasurementPixels,i);c&&(this.heightMeasurementResult=c)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:i,activeViewer:a,heightMeasurementPixels:r,mode:s}=this;if(!i||!a||!e.vertices?.length||"none"===s)return;const o=a?.imageSize;if(!r.length&&o){const i=Te(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(i);const a=await this.calculateHeightMeasurementInfo(i,s,t);if(!a?.measurementAngle||!a?.tempDistance)return;this.measurementAngle=a.measurementAngle,this.tempDistance=a.tempDistance}}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.imageLocationToolState=!1,this.selectedPoint=e.spatialReference.isGeographic?E(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:i}=await t;f(e),this.sketch=new i({layer:this._sketchGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:i}=await t;if(f(e),this.sketchAdapter=new i({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async startMeasurement(e,t){await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:i,sketchAdapter:a,activeViewer:r,mode:s}=this;if(!i||!a||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(i.defaultCreateOptions.defaultZ=0),await i.create(e),"panoramic"===s){const{drawOperation:e}=i.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=$e(o),this.sketch.polylineSymbol="panoramic"===s?Je:Ze(o))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new de({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],(e=>this.handleDrawEvents(e)))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],i=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new x({paths:[e],spatialReference:i});else{const a=new x({paths:[e],spatialReference:i}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:a,symbol:Ze(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,i=this.activeViewer?.imageSize;if(!i)return;const a={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=ee(a,i[0],i[1]),{heading:n,pitch:l}=ee(r,i[0],i[1]),c=[[...le(s,o)],[...le(n,l)]];if(this.heightGraphic)this.heightGraphic.geometry=new x({paths:[c],spatialReference:e});else{const i=new x({paths:[c],spatialReference:e});this.heightGraphic=new t({geometry:i,symbol:Je}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:i,currentBestFeature:a,overlayedCameraLocations:r,layer:s,mode:o,state:n}=this,l=i?.imageSize;if(!l||!a||!s||"none"===o||n.includes("loading"))return;const{polygon:c}=U(a.attributes);if(i.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:`${s.objectIdField} <> ${a.attributes.objectId}`,geometry:c,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:i,geometry:r}=e,s=await this.getPixels(r,{feature:a,imageSize:l,mode:o}),n=Ke.clone();return n.outline=new me({color:[0,0,0],width:1}),new t({attributes:i,symbol:n,geometry:s})})));r.addMany(n),i.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:l,layer:c}=this,h=r?.imageSize;if(!h||!o||"none"===n||l.includes("loading")||!c)return;const{polygon:p}=U(o.attributes),m=_e(e,c.imageGeometryField,c.imageReferenceField);try{const{imageGeometryField:t,oiObjectIdField:i}=Pe(e,c.imageGeometryField,c.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(y){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",y)}const{features:d}=await e.queryFeatures({geometry:p,returnGeometry:!0,outFields:["*"]}),g=new s((await Promise.all(d.map((async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:l}=i;let c=l;if(m&&this.imageGeometryField&&this.oiObjectIdField){if(s[this.oiObjectIdField]===`${o.attributes.objectId}`)return c=B(JSON.parse(atob(s[this.imageGeometryField]))),new t({attributes:s,layer:e,symbol:c.type===e.geometryType?r:Qe(c.type)?.()??null,geometry:c,visible:e.visible&&a})}switch(c?.type){case"point":{const i=await this.getPixels(c,{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:l}=c,u=i.map((e=>e.map((([e,t,i])=>new R({x:e,y:t,z:i,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(se))))));return new t({attributes:s,layer:e,symbol:r,geometry:new O({rings:p,spatialReference:z.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:l}=c,u=i.map((e=>e.map((([e,t,i])=>new R({x:e,y:t,z:i,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(se))))));return new t({attributes:s,layer:e,symbol:r,geometry:new x({paths:p,spatialReference:z.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:l}=c,u=i.map((([e,t,i])=>new R({x:e,y:t,z:i,spatialReference:l}))),p=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then((e=>e.map(se)));return new t({attributes:s,layer:e,symbol:r,geometry:new G({points:p,spatialReference:z.WebMercator}),visible:e.visible&&a})}}return null})))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,g)}async getPixels(e,t){const{imageSize:i,mode:a}=t,r=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===a)return new R({x:e.x-.5,y:.5-e.y,spatialReference:z.WebMercator});const[t,r]=i,{heading:s,pitch:o}=ee(e,t,r),n=le(s,o);return new R(n,z.WebMercator)}));return Array.isArray(e)?r:r[0]}async getMapPoint(e,t){const{feature:i,mode:a,imageSize:r}=t,{elevationSample:s,attributes:o}=i,{elevationSource:n,location:l,elevation:c,cameraHeight:h}=o;let u=l.clone();u.spatialReference.isGeographic&&(u=await j(u,z.WebMercator));const p=await ie(c??(l.z??0)-h,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let m;if("elevationSample"in p&&ae(p.elevationSample)&&(i.elevationSample=p.elevationSample),"default"===a){const t=te(o,r[0],r[1]);m=await Z(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}else{const t=re(o,r[0],r[1]);m=await K(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}return Array.isArray(e)?m:m[0]}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new R({...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 i=c.isSerializable(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._referencePointOnImage=new t({geometry:new R({spatialReference:this._imageViewer.imageRenderer.spatialReference.clone(),...i}),symbol:Xe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=ee(e,a,r),n=le(s,o);this._referencePointOnImage=new t({geometry:new R(n,z.WebMercator),symbol:Ye}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null}async saveDrawing(){const{digitizationLayer:e,sketchAdapter:t}=this;if(!e||"digitization"!==t?.type)return;const{pendingGraphics:i,savedGraphics:a}=t,r=i.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDigitizedFeatures(s),n=o.reduce(((t,{objectId:i,globalId:a,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(i&&(l[e.objectIdField]=i),a&&e.globalIdField&&(l[e.globalIdField]=a),t.success.push(n)),t}),{success:[],error:[]});a.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDigitizedFeatures(e){const{activeViewer:t,currentBestFeature:a,digitizationLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s)throw new n("Image size, current best feature and mode are required to save digitized features");if(!r)throw new n("Digitization layer is not available");const l=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,l=r.hasZ,c=r.geometryType,h=n!==c,u=h?await import("./transformers.js"):null,p=u?.default[c],m=h?p?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(oe(s,m,o),{feature:a,imageSize:o,mode:s}),l||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map((async e=>this.getMapPoint(e.map((([e,t,i])=>oe(s,{x:e,y:t,z:i},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new O({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,rings:e.map((e=>e.map(se)))}),t}case"polyline":{const e=await Promise.all(m.paths.map((async e=>this.getMapPoint(e.map((([e,t,i])=>oe(s,{x:e,y:t,z:i},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new x({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,paths:e.map((e=>e.map(se)))}),t}}}))),c=l.filter(i);return r.applyEdits({addFeatures:c}).then((e=>{const{addFeatureResults:t}=e;let i=0;const a=l.map((e=>{const a=t[i++];return e?a:{error:new n("Error in saving digitized features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:a}}))}async searchBestImage(e,t){try{const i=await D(e,t);i&&await this._processFeatureResponse(i,e.point,{signal:t?.signal})}catch(i){y(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async startDigitization(e,t){const i=this.activeViewer?.imageRenderer;if(!i)return;const a=this.overlayedMapFeatures.get(e.id)?.toArray()??[];this.removeOverlayedGraphicsOnImage(e.id),this.collectionId=e.id,await this.loadSketch(t),await this.loadDigitizationAdapter(t),f(t),this.sketchGraphicsLayer?.addMany(a),this.sketchAdapter?.savedGraphics.addMany(a);i.ui.find("zoom").visible=!1,i.map.layers.add(this.sketchGraphicsLayer)}stopDigitization(e){this.sketch?.cancel();const t=this.sketchAdapter?.savedGraphics;this.sketchGraphicsLayer?.removeAll();const i=this.activeViewer?.imageRenderer;if(!t||!i)return;if(this.overlayGraphicsOnImage(e,t),i.destroyed)return;i.map.layers.remove(this.sketchGraphicsLayer);const a=i.ui.find("zoom");a&&(a.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const i=this.overlayedMapFeatures.get(e);i&&this._toggleVisiblity(i,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e;let a=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await j(t,s.spatialReference);a=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await j(t,s.spatialReference);r=s.extent.contains(e);break}}if(!a&&!r)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,i);if(o)return f(i),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}updateSuitabilities(e){e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const t=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(t),this._groupFeaturesBySectors()}async _fetchFeatures(e,t){if(!this.view)return;const i=this.layer;if(i){const a={include:i},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,a);return this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(y(i))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:i,features:a,invalidCameraHeading:r}=this;if(!e||!t||!i||!a||r)return void(this._sectorData=null);this._sectorData={};for(const c of we)this._sectorData[c]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const n=o.map((({distance:e})=>e)),l=Math.max(...n);o.forEach((e=>{const{distance:t,angle:i,featureIndex:r}=e,s=t/l*be[2],o=nt(t,l),n=lt(i);if(!this._sectorData)return;const c=be[3]+s*Math.sin(i*Math.PI/180),h=be[3]+s*Math.cos(i*Math.PI/180);let u;const p=a.at(r),m=p===this.currentBestFeature,d=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(m&&d)u=-90;else{const e=c-be[3],t=h-be[3],i=t/Math.sqrt(e**2+t**2);let a=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(a*=-1),u=a}const g=""===o?n:`${o}_${n}`;m&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=d?null:{x:c,y:h,direction:n});const y=this._sectorData[g];y.add({angle:i,featureIndex:r,x:c,y:h,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t,i){const{features:a}=e;if(!a?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:r,polygons:s,frustums:o}=this.filterByFootprints(a,t);if(!r.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);let n;if(this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o),s[0]){let e=new O({spatialReference:s[0].spatialReference});for(const i of s)e=await V(e,i);const t=[];for(const{geometry:i}of r)e.contains(i)||t.push([i.x,i.y]);if(t.sort(((e,t)=>+L([e,t]))),e.addRing(t),this.footprintExtent=ge(e.extent,2,2),this.view?.supportsGround)try{n=await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(l){y(l)||u.getLogger(this).error(l)}}if((n||r[0].attributes.elevationSource)&&this.footprintExtent){const e=r[0].attributes.elevationSource;J(e)&&!n&&(n=await X({extent:this.footprintExtent,lod:e.lod,url:e.url,rasterFunction:e.rasterFunction}));const i=await ie((r[0].attributes.location.z??0)-r[0].attributes.cameraHeight,{elevationSample:n,elevationSource:e,extent:this.footprintExtent}),[a,...s]=await Q([t,...r.map((e=>e.attributes.geometry.clone()))],i);r[0].elevationSample=n??i.elevationSample,t.elevation=a.z,r.forEach(((e,t)=>{e.attributes.elevation=s[t].z}))}r[0].elevationSample&&r.forEach((e=>{e.elevationSample=r[0].elevationSample})),this._suitabilities=T({features:r,selectedPoint:t,camera:st(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,i){const{screenPoint:a,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(a);if(!o)return;const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await j(o,e.spatialReference),c=S("1=1",S(e.definitionExpression,n)),h=l.spatialReference.isGeographic?1:M(l.spatialReference),u={layerInstanceOrURL:e,point:l,queryParams:{where:c,maximumDistance:e.maximumDistance?e.maximumDistance/h:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(u,i)}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this.currentBestFeature=e[0]}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:a,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s}=this;if(a&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),f(e);for(const e of i)e.imageID===a.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e,symbol:et,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:Ke,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-be[3],a=e.y-be[3],r=a/Math.sqrt(t**2+a**2);let s=180*Math.acos(r)/Math.PI;(t<0&&a<0||t<0&&a>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=d(this._referencePointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,a){this.displayMessage={key:e,type:t,data:i,map:a}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:i,selectedPoint:a,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=d(this._crossSymbol)),!a||!t||"image-loaded"!==r?.state||i)return;let s;try{s=await this.worldToImage(a,e),f(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:a,feature:t})}}async worldToImage(e,t){const{footprintExtent:i}=this,{imageSize:a}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!a||!i)return;const{attributes:{location:r,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:l},elevationSample:c}=this.currentBestFeature;let h=r.clone();const u=await ie(n??(r.z??0)-l,{elevationSample:c,elevationSource:s});this.currentBestFeature.elevationSample=u.elevationSample;const p=Array.isArray(e)?e:[e];let m,d=await Promise.all(p.map((e=>new Promise((t=>{if(!e.hasZ)return t(Q(e,u));t(e)})))));if(r.spatialReference.isGeographic&&(h=await j(h,z.WebMercator,t)),d=await Promise.all(d.map((async e=>h.spatialReference.equals(e.spatialReference)?e:await j(e,h.spatialReference,t)))),f(t),"panoramic"===this.mode)m=he(d,{imageHeight:a[1],imageWidth:a[0],cameraHeading:o,cameraLocation:h});else{const e=ne(this.currentBestFeature.attributes,a[0],a[1]);m=ue(d,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:a,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c}=this,{attributes:{objectId:h},elevationSample:u}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...a,this.bestFeatureCurrentFootprint,s].filter(ot);l.supportsGround&&u&&c?.updateGroundElevation&&c.updateGroundElevation(e,u),n&&e.push(new t({geometry:n.clone(),symbol:We.clone(),attributes:{imageID:h}})),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&u&&c?.updateGroundElevation&&c.updateGroundElevation([e],u),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([I()],dt.prototype,"activeLayer",null),e([I({readOnly:!0})],dt.prototype,"activeViewer",null),e([I()],dt.prototype,"accuracyParametersMissing",null),e([I()],dt.prototype,"additionalFeatures",void 0),e([I({type:s.ofType(t)})],dt.prototype,"additionalCameraLocations",void 0),e([I({type:s.ofType(t)})],dt.prototype,"additionalFootprints",void 0),e([I()],dt.prototype,"areaMeasurementResult",void 0),e([I()],dt.prototype,"areaMeasurementAccuracy",void 0),e([I()],dt.prototype,"bestFeatureAngle",void 0),e([I()],dt.prototype,"bestFeatureCurrentFootprint",void 0),e([I({type:t})],dt.prototype,"bestFeatureFootprint",void 0),e([I({type:Number})],dt.prototype,"brightness",null),e([I()],dt.prototype,"collectionId",void 0),e([I({type:Number})],dt.prototype,"contrast",null),e([I()],dt.prototype,"conversionProps",void 0),e([I()],dt.prototype,"coverageFrustums",void 0),e([I()],dt.prototype,"coveragePolygons",void 0),e([I()],dt.prototype,"currentBestFeature",void 0),e([I()],dt.prototype,"currentBestFeatureLocation",void 0),e([I()],dt.prototype,"currentCoverageVisible",void 0),e([I({json:{write:!1}})],dt.prototype,"determineWorkflowForFeature",void 0),e([I()],dt.prototype,"disabled",void 0),e([I()],dt.prototype,"displayMessage",void 0),e([I()],dt.prototype,"displayNewMeasurementButton",void 0),e([I()],dt.prototype,"distanceMeasurementResult",void 0),e([I()],dt.prototype,"distanceAccuracyArray",void 0),e([I()],dt.prototype,"digitizationLayer",void 0),e([I({readOnly:!0})],dt.prototype,"featureCount",null),e([I()],dt.prototype,"features",void 0),e([I()],dt.prototype,"groundCoordinates",void 0),e([I()],dt.prototype,"heightMeasurementPixels",void 0),e([I()],dt.prototype,"heightGraphic",void 0),e([I()],dt.prototype,"heightMeasurementResult",void 0),e([I()],dt.prototype,"heightMeasurementAccuracy",void 0),e([I()],dt.prototype,"measurementAngle",void 0),e([I()],dt.prototype,"tempDistance",void 0),e([I({readOnly:!0})],dt.prototype,"imageGalleryEnabled",null),e([I()],dt.prototype,"imageGeometryField",void 0),e([I({readOnly:!0})],dt.prototype,"imageLoaded",null),e([I()],dt.prototype,"imageLocationToolState",void 0),e([I({readOnly:!0})],dt.prototype,"invalidCameraHeading",null),e([I()],dt.prototype,"imagePointsInView",null),e([I()],dt.prototype,"isAdditionalCoverageVisible",void 0),e([I()],dt.prototype,"isAdditionalPointSourcesVisible",void 0),e([I()],dt.prototype,"layer",void 0),e([I()],dt.prototype,"layerView",null),e([I({readOnly:!0})],dt.prototype,"layerFloorFilterClause",null),e([I({type:Number})],dt.prototype,"localPort",void 0),e([I()],dt.prototype,"mapImageConversionToolState",void 0),e([I()],dt.prototype,"measureType",void 0),e([I()],dt.prototype,"measurementGraphic",void 0),e([I({readOnly:!0,value:"none"})],dt.prototype,"mode",null),e([I()],dt.prototype,"navigatorCurrentBestFeature",void 0),e([I()],dt.prototype,"oiObjectIdField",void 0),e([I({type:s.ofType(t)})],dt.prototype,"overlayedCameraLocations",void 0),e([I()],dt.prototype,"overlayedMapFeatures",void 0),e([I()],dt.prototype,"pixelCoordinates",void 0),e([I()],dt.prototype,"pointSources",void 0),e([I({readOnly:!0})],dt.prototype,"popupEnabled",null),e([I()],dt.prototype,"previousFeatureAngle",void 0),e([I()],dt.prototype,"referencePoint",null),e([I({readOnly:!0})],dt.prototype,"sectorData",null),e([I()],dt.prototype,"selectedPoint",void 0),e([I({type:Number})],dt.prototype,"sharpness",null),e([I()],dt.prototype,"shouldShowSelectedImage",void 0),e([I()],dt.prototype,"sketch",void 0),e([I()],dt.prototype,"draw",void 0),e([I()],dt.prototype,"sketchAdapter",void 0),e([I({readOnly:!0})],dt.prototype,"sketchGraphicsLayer",null),e([I({readOnly:!0})],dt.prototype,"state",null),e([I({readOnly:!0})],dt.prototype,"thumbnails",null),e([I()],dt.prototype,"updateFootprint",void 0),e([I()],dt.prototype,"updateFootprintPanorama",void 0),e([I({value:null})],dt.prototype,"view",null),e([I()],dt.prototype,"_adapter",void 0),e([I()],dt.prototype,"_sketchGraphicsLayer",null),e([I()],dt.prototype,"_highlightedFeatureHandle",void 0),e([I()],dt.prototype,"_imageViewer",void 0),e([I()],dt.prototype,"_initialCurrentCoverageUpdate",void 0),e([I()],dt.prototype,"_overlays",void 0),e([I({readOnly:!0})],dt.prototype,"_overlaysView",null),e([I()],dt.prototype,"_panoramicViewer",void 0),e([I()],dt.prototype,"_referencePointOnGround",void 0),e([I()],dt.prototype,"_referencePointOnImage",void 0),e([I()],dt.prototype,"_sectorData",void 0),e([I({readOnly:!0})],dt.prototype,"_updatingHandles",void 0),e([I()],dt.prototype,"footprintExtent",void 0),e([I()],dt.prototype,"_featureChangedTask",void 0),dt=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],dt);const gt=dt;export{gt as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Collection.js";import i from"../../../core/Identifiable.js";import{on as s,watch as o,syncAndInitial as a}from"../../../core/reactiveUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../../../support/actions/ActionToggle.js";import c from"../../Widget.js";import{css as h}from"../css.js";import{isValidDigitizationLayer as d}from"../digitizationUtils.js";import p from"./OverlayLayersList.js";import{loadCalciteComponents as m}from"../../support/componentsUtils.js";import{globalCss as y}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{tsx as g}from"../../support/jsxFactory.js";let u=class extends(i.IdentifiableMixin(c)){constructor(e){super(e),this._previousAction=null,this.closed=!1,this.digitizationEnabled=!1,this.digitizationLayer=null,this.layerList=new p({selectionMode:"multiple"}),this.messages=null,this.overlayedLayers=new t,this.showCameraLocations=!1,this.showMapFeatures=!1,this._createSelectedItemsHandle=()=>{this.removeHandles("selected-items"),this.addHandles(this._trackLayerSelectionChanges(),"selected-items")},this._handleSelectedItemsChange=({added:e,removed:t})=>{e.forEach((e=>{this.overlayedLayers.includes(e.layer)||this.onLayerSelected?.(e)})),t.forEach((e=>{this.overlayedLayers.includes(e.layer)&&this.onLayerDeselected?.(e)})),this.overlayedLayers.removeAll(),this.overlayedLayers.addMany(this.layerList.selectedItems.items.map((e=>e.layer)))},this._layerListTriggerActionHandle=()=>s((()=>this.layerList),"trigger-action",(e=>{const{action:t,item:{layer:i}}=e;if(this._resetPreviousAction(t),"create-features"===t.id)this._toggleDigitizationLayer(t,i)})),this._resetPreviousAction=e=>{"toggle"===this._previousAction?.type&&this._previousAction!==e&&(this._previousAction.value=!1,this._previousAction=null)},this._toggleDigitizationLayer=(e,t)=>{this._previousAction=e;const i=e.value;this.digitizationLayer=i?t:null,this.onDigitizationLayerChanged?.(this.digitizationLayer)},this._trackLayerSelectionChanges=()=>s((()=>this.layerList.selectedItems),"change",this._handleSelectedItemsChange),this._watchLayerListForListItemCreatedFunction=()=>o((()=>({layerList:this.layerList,listItemCreatedFunction:this._listItemCreatedFunction})),(()=>{this.layerList.listItemCreatedFunction=this._listItemCreatedFunction}),a),this._watchSelectedItems=()=>o((()=>this.layerList.selectedItems),this._createSelectedItemsHandle,a)}initialize(){this.addHandles([this._watchSelectedItems(),this._layerListTriggerActionHandle(),this._watchLayerListForListItemCreatedFunction()])}loadDependencies(){return m({list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}get _listItemCreatedFunction(){const{digitizationEnabled:e}=this;return e?async e=>{const{item:t}=e,i=t.layer,{digitizationLayer:s,overlayedLayers:o,messages:{createFeaturesFromImage:a},layerList:r}=this,n=o.includes(i),{selectedItems:l}=r;if(v(n,l,t),await(i?.load()),!i||!d(i))return;const c=s===i,h=_(a,t,l,c);c&&(this._previousAction=h)}:null}get view(){return this.layerList?.view}set view(e){this.layerList.view=e}_renderCameraLocationsSwitch(e){return g("calcite-list-item",{bind:this,label:this.messages.overlayCameraLocations,onclick:this._toggleShowCameraLocations},g("calcite-switch",{bind:this,checked:e,class:h.overlaysSwitch,onchange:this._toggleShowCameraLocations,scale:"s",slot:"actions-end"}))}_renderOverlayMapFeatures(e){return g("calcite-list-item",{bind:this,label:this.messages?.overlayMapFeatures,onclick:this._toggleShowMapFeatures},g("calcite-switch",{bind:this,checked:e,class:h.overlaysSwitch,onchange:this._toggleShowMapFeatures,scale:"s",slot:"actions-end"}))}_renderList(e){return e?g("div",{class:h.imageOverlaysLayerList},this.layerList.render()):null}_renderPanel(){const{closed:e,messages:t,showCameraLocations:i,showMapFeatures:s}=this;return g("calcite-panel",{bind:this,closable:!0,closed:e,heading:t.imageOverlays,onCalcitePanelClose:this.onImageOverlaysClosed},g("calcite-list",{label:t.imageOverlays},this._renderCameraLocationsSwitch(i),this._renderOverlayMapFeatures(s)),this._renderList(s))}_toggleShowCameraLocations(e){e.stopPropagation(),this.showCameraLocations=!this.showCameraLocations,this.onShowCameraLocationsChanged?.(this.showCameraLocations)}_toggleShowMapFeatures(e){e.stopPropagation(),this.showMapFeatures=!this.showMapFeatures,this.onShowMapFeaturesChanged?.(this.showMapFeatures)}render(){const e=this.layerList.operationalItems.items.length,t=this.showMapFeatures&&0===e,i=this.showMapFeatures&&e>0,s={[y.widget]:!0,[h.imageOverlaysNoResult]:t,[h.imageOverlaysIncreasedHeight]:i,[h.imageOverlays]:!t&&!i};return g("div",{class:this.classes(s)},this._renderPanel())}};e([r()],u.prototype,"_previousAction",void 0),e([r()],u.prototype,"_listItemCreatedFunction",null),e([r()],u.prototype,"closed",void 0),e([r()],u.prototype,"digitizationEnabled",void 0),e([r()],u.prototype,"digitizationLayer",void 0),e([r()],u.prototype,"layerList",void 0),e([r()],u.prototype,"messages",void 0),e([r()],u.prototype,"onDigitizationLayerChanged",void 0),e([r()],u.prototype,"onImageOverlaysClosed",void 0),e([r()],u.prototype,"onLayerDeselected",void 0),e([r()],u.prototype,"onLayerSelected",void 0),e([r()],u.prototype,"onShowCameraLocationsChanged",void 0),e([r()],u.prototype,"onShowMapFeaturesChanged",void 0),e([r()],u.prototype,"overlayedLayers",void 0),e([r()],u.prototype,"showCameraLocations",void 0),e([r()],u.prototype,"showMapFeatures",void 0),e([r()],u.prototype,"view",null),u=e([n("esri.widgets.OrientedImageryViewer.components.ImageOverlays")],u);const L=u;function v(e,t,i){e&&t.items.push(i)}function w(e,i){const s=new t;s.add(e),i.actionsSections=new t([s])}function _(e,t,i,s=!1){const r=new l({icon:"pencil",id:"create-features",title:e,value:s});return t.addHandles(o((()=>i.includes(t)),(e=>{r.visible=e}),a)),w(r,t),r}export{L as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Collection.js";import i from"../../../core/Identifiable.js";import{on as s,watch as o,syncAndInitial as a}from"../../../core/reactiveUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../../../support/actions/ActionToggle.js";import c from"../../Widget.js";import{css as d}from"../css.js";import{isValidDigitizationLayer as h}from"../digitizationUtils.js";import p from"./OverlayLayersList.js";import{loadCalciteComponents as m}from"../../support/componentsUtils.js";import{globalCss as y}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{tsx as g}from"../../support/jsxFactory.js";let u=class extends(i.IdentifiableMixin(c)){constructor(e){super(e),this._previousAction=null,this.closed=!1,this.digitizationEnabled=!1,this.digitizationLayer=null,this.imageGeometryField=null,this.imageReferenceField=null,this.layerList=new p({selectionMode:"multiple"}),this.messages=null,this.overlayedLayers=new t,this.showCameraLocations=!1,this.showMapFeatures=!1,this._createSelectedItemsHandle=()=>{this.removeHandles("selected-items"),this.addHandles(this._trackLayerSelectionChanges(),"selected-items")},this._handleSelectedItemsChange=({added:e,removed:t})=>{e.forEach((e=>{this.overlayedLayers.includes(e.layer)||this.onLayerSelected?.(e)})),t.forEach((e=>{this.overlayedLayers.includes(e.layer)&&this.onLayerDeselected?.(e)})),this.overlayedLayers.removeAll(),this.overlayedLayers.addMany(this.layerList.selectedItems.items.map((e=>e.layer)))},this._layerListTriggerActionHandle=()=>s((()=>this.layerList),"trigger-action",(e=>{const{action:t,item:{layer:i}}=e;if(this._resetPreviousAction(t),"create-features"===t.id)this._toggleDigitizationLayer(t,i)})),this._resetPreviousAction=e=>{"toggle"===this._previousAction?.type&&this._previousAction!==e&&(this._previousAction.value=!1,this._previousAction=null)},this._toggleDigitizationLayer=(e,t)=>{this._previousAction=e;const i=e.value;this.digitizationLayer=i?t:null,this.onDigitizationLayerChanged?.(this.digitizationLayer)},this._trackLayerSelectionChanges=()=>s((()=>this.layerList.selectedItems),"change",this._handleSelectedItemsChange),this._watchLayerListForListItemCreatedFunction=()=>o((()=>({layerList:this.layerList,listItemCreatedFunction:this._listItemCreatedFunction})),(()=>{this.layerList.listItemCreatedFunction=this._listItemCreatedFunction}),a),this._watchSelectedItems=()=>o((()=>this.layerList.selectedItems),this._createSelectedItemsHandle,a)}initialize(){this.addHandles([this._watchSelectedItems(),this._layerListTriggerActionHandle(),this._watchLayerListForListItemCreatedFunction()])}loadDependencies(){return m({list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}get _listItemCreatedFunction(){const{digitizationEnabled:e,imageGeometryField:t,imageReferenceField:i}=this;return e&&t&&i?async e=>{const{item:s}=e,o=s.layer,{digitizationLayer:a,overlayedLayers:r,messages:{createFeaturesFromImage:n},layerList:l}=this,c=r.includes(o),{selectedItems:d}=l;if(v(c,d,s),await(o?.load()),!o||!h(o,t,i))return;const p=a===o,m=_(n,s,d,p);p&&(this._previousAction=m)}:null}get view(){return this.layerList?.view}set view(e){this.layerList.view=e}_renderCameraLocationsSwitch(e){return g("calcite-list-item",{bind:this,label:this.messages.overlayCameraLocations,onclick:this._toggleShowCameraLocations},g("calcite-switch",{bind:this,checked:e,class:d.overlaysSwitch,onchange:this._toggleShowCameraLocations,scale:"s",slot:"actions-end"}))}_renderOverlayMapFeatures(e){return g("calcite-list-item",{bind:this,label:this.messages?.overlayMapFeatures,onclick:this._toggleShowMapFeatures},g("calcite-switch",{bind:this,checked:e,class:d.overlaysSwitch,onchange:this._toggleShowMapFeatures,scale:"s",slot:"actions-end"}))}_renderList(e){return e?g("div",{class:d.imageOverlaysLayerList},this.layerList.render()):null}_renderPanel(){const{closed:e,messages:t,showCameraLocations:i,showMapFeatures:s}=this;return g("calcite-panel",{bind:this,closable:!0,closed:e,heading:t.imageOverlays,onCalcitePanelClose:this.onImageOverlaysClosed},g("calcite-list",{label:t.imageOverlays},this._renderCameraLocationsSwitch(i),this._renderOverlayMapFeatures(s)),this._renderList(s))}_toggleShowCameraLocations(e){e.stopPropagation(),this.showCameraLocations=!this.showCameraLocations,this.onShowCameraLocationsChanged?.(this.showCameraLocations)}_toggleShowMapFeatures(e){e.stopPropagation(),this.showMapFeatures=!this.showMapFeatures,this.onShowMapFeaturesChanged?.(this.showMapFeatures)}render(){const e=this.layerList.operationalItems.items.length,t=this.showMapFeatures&&0===e,i=this.showMapFeatures&&e>0,s={[y.widget]:!0,[d.imageOverlaysNoResult]:t,[d.imageOverlaysIncreasedHeight]:i,[d.imageOverlays]:!t&&!i};return g("div",{class:this.classes(s)},this._renderPanel())}};e([r()],u.prototype,"_previousAction",void 0),e([r()],u.prototype,"_listItemCreatedFunction",null),e([r()],u.prototype,"closed",void 0),e([r()],u.prototype,"digitizationEnabled",void 0),e([r()],u.prototype,"digitizationLayer",void 0),e([r()],u.prototype,"imageGeometryField",void 0),e([r()],u.prototype,"imageReferenceField",void 0),e([r()],u.prototype,"layerList",void 0),e([r()],u.prototype,"messages",void 0),e([r()],u.prototype,"onDigitizationLayerChanged",void 0),e([r()],u.prototype,"onImageOverlaysClosed",void 0),e([r()],u.prototype,"onLayerDeselected",void 0),e([r()],u.prototype,"onLayerSelected",void 0),e([r()],u.prototype,"onShowCameraLocationsChanged",void 0),e([r()],u.prototype,"onShowMapFeaturesChanged",void 0),e([r()],u.prototype,"overlayedLayers",void 0),e([r()],u.prototype,"showCameraLocations",void 0),e([r()],u.prototype,"showMapFeatures",void 0),e([r()],u.prototype,"view",null),u=e([n("esri.widgets.OrientedImageryViewer.components.ImageOverlays")],u);const L=u;function v(e,t,i){e&&t.items.push(i)}function w(e,i){const s=new t;s.add(e),i.actionsSections=new t([s])}function _(e,t,i,s=!1){const r=new l({icon:"pencil",id:"create-features",title:e,value:s});return t.addHandles(o((()=>i.includes(t)),(e=>{r.visible=e}),a)),w(r,t),r}export{L as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import{or as o}from"../../layers/orientedImagery/transformations/utils.js";import{isEditableLayer as r}from"../../layers/support/editableLayers.js";import{digitizationSymbol as t}from"./symbols.js";const i="oiobjectid",n="imagegeometry";function l(e,o){return m(i,e,o)}function y(e,o,r){return m(n,e,o)&&"blob"===r}function m(e,r,t){return o(r.toLowerCase()===e,t?.toLowerCase()===e)}function a(e){return"point"===e||"polygon"===e||"polyline"===e}function s(e){return r(e)&&a(e.geometryType)&&2===e.fields.filter((({name:e,type:o,alias:r})=>y(e,r,o)||l(e,r))).length}function f(e){return"feature"===e.type&&u(e)}function u(e){return"point"===e.geometryType||"polygon"===e.geometryType||"polyline"===e.geometryType}function d(e,o,r){if(e?.geometryType!==o||!e?.renderer)return;const{renderer:i}=e,n=t(o)?.(),l=("symbol"in i?i.symbol:"defaultSymbol"in i?i.defaultSymbol:i.getSymbol())??n;l&&(r[`${o}Symbol`]=l)}function p(o){const r=o.fields.find((({name:e,alias:o,type:r})=>y(e,o,r))),t=o.fields.find((({name:e,alias:o})=>l(e,o)));if(!r||!t)throw new e("invalid-digitization-layer","Digitization layer is not configured correctly.",{layer:o,imageGeometryField:r,oiObjectIdField:t});return{imageGeometryField:r,oiObjectIdField:t}}export{y as checkImageGeometryField,l as checkOiObjectIdField,d as configureSketchTool,p as extractFieldsFromDigitizationLayer,s as isValidDigitizationLayer,f as isValidOverlayLayer,u as supportedDigitigedGeometryType};
5
+ import e from"../../core/Error.js";import{or as o}from"../../layers/orientedImagery/transformations/utils.js";import{isEditableLayer as r}from"../../layers/support/editableLayers.js";import{digitizationSymbol as t}from"./symbols.js";function i(e,r,t){const i=e.toLowerCase(),n=r.toLowerCase()===i,l=t?.toLowerCase()===i;return o(n,l)}function n(e){return"point"===e||"polygon"===e||"polyline"===e}function l(e,o,t){return r(e)&&n(e.geometryType)&&2===e.fields.filter((({name:e,type:r,alias:n})=>i(t,e,n)||i(o,e,n)&&"blob"===r)).length}function y(e){return"feature"===e.type&&a(e)}function a(e){return"point"===e.geometryType||"polygon"===e.geometryType||"polyline"===e.geometryType}function m(e,o,r){if(e?.geometryType!==o||!e?.renderer)return;const{renderer:i}=e,n=t(o)?.(),l=("symbol"in i?i.symbol:"defaultSymbol"in i?i.defaultSymbol:i.getSymbol())??n;l&&(r[`${o}Symbol`]=l)}function s(o,r,t){const n=o.fields.find((({name:e,alias:o,type:t})=>i(r,e,o)&&"blob"===t)),l=o.fields.find((({name:e,alias:o})=>i(t,e,o)));if(!n||!l)throw new e("invalid-digitization-layer","Digitization layer is not configured correctly.",{layer:o,imageGeometryField:n,oiObjectIdField:l});return{imageGeometryField:n,oiObjectIdField:l}}export{m as configureSketchTool,s as extractFieldsFromDigitizationLayer,l as isValidDigitizationLayer,y as isValidOverlayLayer,a as supportedDigitigedGeometryType};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../request.js";import e from"../../core/Error.js";import{deg2rad as a}from"../../core/mathUtils.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{rotatePixel as o}from"../../layers/orientedImagery/transformations/utils.js";import{imageGalleryThumbnailSize as s}from"./constants.js";import{getContentType as n,validateTifOrMrfExtension as i}from"./utils.js";const m=t=>"FA"===t,c=async(t,a,r)=>{const o=new(await import("../../rest/support/AttachmentQuery.js").then((t=>t.default)))({objectIds:[a]}),s=await t.queryAttachments(o,r),n=s[`${a}`]?.[0],i=n?.url;if(!i)throw new e("NoAttachmentError","no attachments found",{[t.objectIdField]:a,layer:t});return{datasetFormat:n.contentType.split("/")[1].toUpperCase(),url:i}};async function h(t,e){const a="string"==typeof t?t:t.url,{origin:r,pathname:o,searchParams:s}=new URL(a);let i="string"==typeof t?void 0:t.datasetFormat;i||(i=await n(a));const m=await import("../../layers/support/rasterDatasets/RasterFactory.js").then((t=>t.default)),c=await m.open({ioConfig:{customFetchParameters:Object.fromEntries(s),skipMapInfo:!0},datasetFormat:i,url:`${r}${o}`,signal:e?.signal});return c?l(c,{signal:e?.signal}):null}async function l(t,e){const{level:a,offset:o,size:s}=u(t),{pixelBlock:n}=await t.fetchRawPixels(a,o,s,e);return r(e),n}function u(t){const{storageInfo:e,width:a,height:r}=t.rasterInfo,{maximumPyramidLevel:o,pyramidScalingFactor:s}=e,n=s??2;return{level:o,offset:{x:0,y:0},size:{width:Math.ceil(a/n**o),height:Math.ceil(r/n**o)}}}async function f(e,a,r){const{datasetFormat:o,url:n}=await c(e,+a,r);return i(o)?await h({datasetFormat:o,url:n},r):(await t(n,{...r,useRequestQueue:!0,responseType:"image",query:{w:s}})).data}function p(t,e,a=0){const{height:r,width:o}=t;e.width=o,e.height=r;const s=e.getContext("2d");if(!s)return;const n=d(t,e,s);n.getContext("2d")&&(a>0?g(s,n,o,r,a):s.drawImage(n,0,0))}function d(t,e,a){const r=document.createElement("canvas"),o=r.getContext("2d");if(t instanceof HTMLImageElement)r.width=t.width,r.height=t.height,o?.drawImage(t,0,0);else{const s=a.createImageData(e.width,e.height);s&&(s.data.set(t.getAsRGBA()),r.width=s.width,r.height=s.height,o?.putImageData(s,0,0))}return r}function g(t,e,r,s,n){const i=a(n),m=[o(0,0,i),o(r,0,i),o(r,s,i),o(0,s,i)],c=Math.max(...m.map((t=>t[0])))-Math.min(...m.map((t=>t[0]))),h=Math.max(...m.map((t=>t[1])))-Math.min(...m.map((t=>t[1]))),l=Math.min(r/c,s/h);t.save(),t.clearRect(0,0,r,s),t.translate(r/2,s/2),t.rotate(i),t.scale(l,l),t.drawImage(e,-r/2,-s/2,r,s),t.restore()}export{c as getImageSourceFromAttachment,h as getThumbnailPixelBlock,m as isFeatureAttachment,f as loadImageForAttachment,p as renderImageWithRotation};
5
+ import t from"../../request.js";import e from"../../core/Error.js";import{deg2rad as a}from"../../core/mathUtils.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{getPathExtension as o}from"../../core/urlUtils.js";import{rotatePixel as s}from"../../layers/orientedImagery/transformations/utils.js";import{imageGalleryThumbnailSize as n}from"./constants.js";import{getContentType as i,validateTifOrMrfExtension as m}from"./utils.js";const c=t=>"FA"===t,h=async(t,a,r)=>{const o=new(await import("../../rest/support/AttachmentQuery.js").then((t=>t.default)))({objectIds:[a]}),s=await t.queryAttachments(o,r),n=s[`${a}`]?.[0],i=n?.url;if(!i)throw new e("NoAttachmentError","no attachments found",{[t.objectIdField]:a,layer:t});return{datasetFormat:n.contentType.split("/")[1].toUpperCase(),url:i}};async function l(t,e){const a="string"==typeof t,r=a?t:t.url,{pathname:s,searchParams:n,origin:m}=new URL(r);let c=a?o(s):t.datasetFormat;c||(c=await i(r));const h=await import("../../layers/support/rasterDatasets/RasterFactory.js").then((t=>t.default)),l=await h.open({ioConfig:{customFetchParameters:Object.fromEntries(n),skipMapInfo:!0},datasetFormat:c?.toUpperCase(),url:`${m}${s}`,signal:e?.signal});return l?u(l,{signal:e?.signal}):null}async function u(t,e){const{level:a,offset:o,size:s}=p(t),{pixelBlock:n}=await t.fetchRawPixels(a,o,s,e);return r(e),n}function p(t){const{storageInfo:e,width:a,height:r}=t.rasterInfo,{maximumPyramidLevel:o,pyramidScalingFactor:s}=e,n=s??2;return{level:o,offset:{x:0,y:0},size:{width:Math.ceil(a/n**o),height:Math.ceil(r/n**o)}}}async function f(e,a,r){const{datasetFormat:o,url:s}=await h(e,+a,r);return m(o)?await l({datasetFormat:o,url:s},r):(await t(s,{...r,useRequestQueue:!0,responseType:"image",query:{w:n}})).data}function d(t,e,a=0){const{height:r,width:o}=t;e.width=o,e.height=r;const s=e.getContext("2d");if(!s)return;const n=g(t,e,s);n.getContext("2d")&&(a>0?w(s,n,o,r,a):s.drawImage(n,0,0))}function g(t,e,a){const r=document.createElement("canvas"),o=r.getContext("2d");if(t instanceof HTMLImageElement)r.width=t.width,r.height=t.height,o?.drawImage(t,0,0);else{const s=a.createImageData(e.width,e.height);s&&(s.data.set(t.getAsRGBA()),r.width=s.width,r.height=s.height,o?.putImageData(s,0,0))}return r}function w(t,e,r,o,n){const i=a(n),m=[s(0,0,i),s(r,0,i),s(r,o,i),s(0,o,i)],c=Math.max(...m.map((t=>t[0])))-Math.min(...m.map((t=>t[0]))),h=Math.max(...m.map((t=>t[1])))-Math.min(...m.map((t=>t[1]))),l=Math.min(r/c,o/h);t.save(),t.clearRect(0,0,r,o),t.translate(r/2,o/2),t.rotate(i),t.scale(l,l),t.drawImage(e,-r/2,-o/2,r,o),t.restore()}export{h as getImageSourceFromAttachment,l as getThumbnailPixelBlock,c as isFeatureAttachment,f as loadImageForAttachment,d as renderImageWithRotation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{throwIfAborted as e}from"../../core/promiseUtils.js";import{formatLength as t,formatArea as n}from"../../core/quantityFormatUtils.js";import{createLength as r,createArea as o}from"../../core/quantityUtils.js";import{distance as a}from"../../core/libs/gl-matrix-2/math/vec2.js";import{geodesicDensify as s,simplify as c,geodesicLength as i,planarLength as u,planarArea as f,geodesicArea as l}from"../../geometry/geometryEngine.js";import m from"../../geometry/Point.js";import p from"../../geometry/Polygon.js";import y from"../../geometry/Polyline.js";import{project as h}from"../../geometry/projection.js";import g from"../../geometry/SpatialReference.js";import{isSupported as x,geodesicLengths as w,geodesicAreas as R}from"../../geometry/support/geodesicUtils.js";import{imageToWorld as d,imageToWorldPanoramic as j}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{worldToImage as v}from"../../layers/orientedImagery/transformations/worldToImage.js";const z=1e5;function P(e,t){let n=180*Math.atan2(-e.y+t.y,e.x-t.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function M(e,t,n){if(!e?.length||!t?.length||!n)return;const[r,o]=e,[,a]=t,s=a-o;return[r+s*Math.cos(n),o+s*Math.sin(n)]}function q(e,t,n){if(x(e)){const e=w([t],"meters")[0];return{area:R([n],"square-meters")[0],perimeter:e}}const r=g.WGS84,o=h(t,r),a=h(n,r);let i=s(a,z);if(i=c(i),!i)return null;const u=w([o],"meters")[0];return{area:R([i],"square-meters")[0],perimeter:u}}async function b(t,n,r,o,a=!1,s){if(n.length<2||!o||!r||!t)return null;const c=A(r,t);if(!c)return null;const i=n.map((e=>[e.x,e.y])),u=i.at(0),f=i.at(-1);if(!u||!f)return null;const l=c.map((e=>N([u,f],e,t,a,!1))),m=await Promise.all(l);e(s);let p=0;for(const e of m){if(!e)return null;const t=Math.abs(e-o);p=Math.max(t,p)}return p}function E(e,t){const n=H(e,!1);if(!n?.length)return;return 20*a([n[0].x,n[0].y],[n.at(-1).x,n.at(-1).y])/t}function W(e){const t=e.spatialReference;if(t.isGeographic){if(x(t))return w([e],"meters")[0];const n=h(e,g.WGS84);return w([n],"meters")[0]}return t.isWebMercator?i(e,"meters"):u(e,"meters")}function G(e,t){const n=c(t);if(!n)return null;const r=u(e,"meters");return{area:f(n,"square-meters"),perimeter:r}}function I(e,t){let n=s(t,z,"meters");if(n=c(n),!n)return null;const r=i(e,"meters");return{area:l(n,"square-meters"),perimeter:r}}async function L(t,n,r){const o=await d(t,n);e(r);const a=o.clone();a.z?a.z+=20:a.z=20;const{averageElevation:s,cameraPitch:c,cameraRoll:i,farDistance:u,...f}=n;return v(a,f)||null}function k(e,t,n,r,o=0,s=1,c){const{averageElevation:i,cameraPitch:u,cameraRoll:f,farDistance:l,...p}=r;if(o>=5||s<=.1)return{value:e};const y=new m({x:t.x,y:t.y,z:t.z?t.z+e:e,spatialReference:r.cameraLocation.spatialReference}),h=v(y,p),g=a([n[0].x,n[0].y],[h.x,h.y]),x=n.at(0),w=n.at(-1);if(!x||!w)return null;const R=a([x.x,x.y],[w.x,w.y])*e/g;return k(R,t,n,r,o+1,Math.abs(e-R))}async function U(e,t){const{updateElevationProps:n,...r}=t;return await d(e,r,n)}async function D(e,t){const{updateElevationProps:n,...r}=t;return j(e,r,n)}function S(e){navigator.clipboard.writeText(e).catch((e=>{throw e}))}function T(e){const t=e.map((e=>[e.x,e.y])),n=e[0].spatialReference;return new y({paths:[t],spatialReference:n})}function H(e,t){return e.map((e=>({x:t?.5+e[0]:e[0],y:t?.5-e[1]:e[1]})))}function F(e,n,o,a,s){const c="measurement"===e?n:o;if(s&&c)return t(a,r(c,"meters"),s,3)||null}function A(e,t){const{cameraPitch:n,cameraRoll:r,cameraLocation:o}=e,{x:a,y:s,z:c,spatialReference:i}=o;if(t.every((e=>0===e))||!t||!t.length)return null;const[u,f,,l,p]=t,y=[-l,0,l],h=[-p,0,p],g=[-u,0,u],x=[-f,0,f],w=[];for(const R of y)for(const t of h)for(const o of g)for(const u of g)for(const f of x){const l={...e};l.cameraPitch=n+R,l.cameraRoll=r+t,l.cameraLocation=new m({x:a+o,y:s+u,z:c?c+f:0,spatialReference:{wkid:i.wkid}}),w.push(l)}return w}function B(e,t){const{cameraHeading:n,cameraLocation:r}=e,{x:o,y:a,z:s,spatialReference:c}=r;if(t.every((e=>0===e))||!t||!t.length)return null;const[i,u,f]=t,l=f>0?[-f,0,f]:[],p=i>0?[-i,0,i]:[],y=u>0?[-u,0,u]:[],h=[];for(const g of l)for(const t of p)for(const r of p)for(const i of y){const u={...e};u.cameraHeading=n+g,u.cameraLocation=new m({x:o+t,y:a+r,z:s?s+i:0,spatialReference:{wkid:c.wkid}}),h.push(u)}return h}function C(e,n,o,a,s){const c="measurement"===e?n:K(o);if(s&&c)return t(a,r(c,"meters"),s,3)||null}function J(e,t,r,a,s){const c="measurement"===e?t:r;if(s&&c)return n(a,o(c,"square-meters"),s,3)||null}function K(e){return Math.sqrt(e.reduce(((e,t)=>e+t**2),0))}async function N(t,n,r,o=!1,s=!1,c){if(!t||!n||t.length<2)return null;const i=H(t,o);if(!i||i.length<2)return null;const[u,f]=[i[0],i.at(-1)];if(!f)return null;const l=[u],m=await d(u,n);e(c);const p=m.clone();p.z?p.z+=20:p.z=20;const{averageElevation:y,cameraPitch:h,cameraRoll:g,farDistance:x,...w}=n,R=v(p,w),j=a([u.x,u.y],[R.x,R.y]),z=P(u,R);if(!z)return;const q=M([u.x,u.y],[f.x,f.y],z);if(!q?.length)return;l.push({x:q[0],y:q[1]});const b=20*a([l[0].x,l[0].y],[l[1].x,l[1].y])/j;if(!s)return b;const E=k(b,m,l,n,0,1);return E?.value}async function O(e,t,n=!1){if(e.length<3)return null;const r=H(e,n),o=await U(r,t),a=o.map((({x:e,y:t})=>[e,t]));e.push(e[0]),a.push(a[0]);const s=o[0].spatialReference,c=new y({paths:[a],spatialReference:s}),i=new p({rings:[a],spatialReference:s});return s.isGeographic?q(s,c,i):s.isWebMercator?I(c,i):G(c,i)}async function Q(t,n,r=!1,o){if(t.length<3)return null;const a=H(t,r),s=await D(a,n);e(o);const c=s.map((({x:e,y:t})=>[e,t]));t.push(t[0]),c.push(c[0]);const i=s[0].spatialReference,u=new y({paths:[c],spatialReference:i}),f=new p({rings:[c],spatialReference:i});return i.isGeographic?q(i,u,f):i.isWebMercator?I(u,f):G(u,f)}async function V(e,t,n=!1){const r=H(e,n);return W(T(await U(r,t)))}async function X(t,n,r=!1,o){const a=H(t,r),s=await D(a,n);e(o);return W(T(s))}export{P as calculateAngle,M as calculateCorrectedPixel,b as calculateHeightAccuracy,E as calculateHeightFromTemporaryDistance,L as calculateTempImagePoint,k as computeHeightIteratively,S as copyToClipboard,H as formatPixels,A as generateCombinations,B as generateCombinationsPanoramic,J as getConvertedArea,C as getConvertedDistance,F as getConvertedHeight,K as getRootOfSumOfSquaredErrors,N as heightMeasurement2D,O as pixelAreaMeasurement2D,Q as pixelAreaMeasurementPanoramic,V as pixelDistanceMeasurement2D,X as pixelDistanceMeasurementPanoramic};
5
+ import{throwIfAborted as t}from"../../core/promiseUtils.js";import{formatLength as e,formatArea as r}from"../../core/quantityFormatUtils.js";import{createLength as n,createArea as a}from"../../core/quantityUtils.js";import{distance as o}from"../../core/libs/gl-matrix-2/math/vec2.js";import{geodesicDensify as i,simplify as s,geodesicLength as c,planarLength as u,planarArea as f,geodesicArea as l}from"../../geometry/geometryEngine.js";import m from"../../geometry/Point.js";import p from"../../geometry/Polygon.js";import y from"../../geometry/Polyline.js";import{projectWithZConversion as h,project as x}from"../../geometry/projection.js";import g from"../../geometry/SpatialReference.js";import{isSupported as w,geodesicLengths as R,geodesicAreas as d}from"../../geometry/support/geodesicUtils.js";import{imageToWorld as z,imageToWorldPanoramic as v}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as M}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as P,worldToImagePanoramic as j}from"../../layers/orientedImagery/transformations/worldToImage.js";const E=1e5;function b(t,e){let r=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return r<0&&(r+=180),r*Math.PI/180}function I(t,e){let r=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return r<0&&(r+=180),r*Math.PI/180}function q(t,e,r){if(!t?.length||!e?.length||!r)return;const[n,a]=t,[,o]=e,i=o-a;return[n+i*Math.cos(r),a+i*Math.sin(r)]}function L(t,e,r){if(w(t)){const t=R([e],"meters")[0];return{area:d([r],"square-meters")[0],perimeter:t}}const n=g.WGS84,a=x(e,n),o=x(r,n);let c=i(o,E);if(c=s(c),!c)return null;const u=R([a],"meters")[0];return{area:d([c],"square-meters")[0],perimeter:u}}async function W(e,r,n,a,o=!1,i){if(r.length<2||!a||!n||!e)return null;const s=N(n,e);if(!s)return null;const c=r.map((t=>[t.x,t.y])),u=c.at(0),f=c.at(-1);if(!u||!f)return null;const l=s.map((t=>_([u,f],t,e,o,!1))),m=await Promise.all(l);t(i);let p=0;for(const t of m){if(!t)return null;const e=Math.abs(t-a);p=Math.max(e,p)}return p}async function G(e,r,n,a,o,i=!1,s){if(r.length<2||!a||!n||!e)throw new Error("Missing parameters");const c=Q(n,e),u=r.map((t=>[t.x,t.y])),f=u.at(0),l=u.at(-1),m=c.map((t=>tt([f,l],t,e,o,i,!1))),p=await Promise.all(m);t(s);let y=0;for(const t of p){if(!t)return 0;const e=Math.abs(t-a);y=Math.max(e,y)}return y}function k(t,e){const r=J(t,!1);if(!r?.length)return;return 20*o([r[0].x,r[0].y],[r.at(-1).x,r.at(-1).y])/e}function D(t){const e=t.spatialReference;if(e.isGeographic){if(w(e))return R([t],"meters")[0];const r=x(t,g.WGS84);return R([r],"meters")[0]}return e.isWebMercator?c(t,"meters"):u(t,"meters")}function U(t,e){const r=s(e);if(!r)return null;const n=u(t,"meters");return{area:f(r,"square-meters"),perimeter:n}}function F(t,e){let r=i(e,E,"meters");if(r=s(r),!r)return null;const n=c(t,"meters");return{area:l(r,"square-meters"),perimeter:n}}async function S(e,r,n){if(!r||!e)throw new Error("Missing required parameters");const a=await z(e,r);t(n);const o=a.clone();o.z?o.z+=20:o.z=20;const{averageElevation:i,cameraPitch:s,cameraRoll:c,farDistance:u,...f}=r;return P(o,f)}async function T(e,r,n,a){const{attributes:o}=n,{location:i}=o,{updateElevationProps:s,...c}=r;if(!e||!r)throw new Error("Missing parameters");let u=i.clone();u.spatialReference.isGeographic&&(u=await h(u,g.WebMercator));const f=await v(e,{...c,cameraLocation:u},s);t(a);const l=f.clone();return l.z?l.z+=20:l.z=20,j(l,c)}function H(t,e,r,n,a=0,i=1,s){const{averageElevation:c,cameraPitch:u,cameraRoll:f,farDistance:l,...p}=n;if(a>=5||i<=.1)return{value:t};const y=new m({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:n.cameraLocation.spatialReference}),h=P(y,p),x=o([r[0].x,r[0].y],[h.x,h.y]),g=r.at(0),w=r.at(-1);if(!g||!w)return null;const R=o([g.x,g.y],[w.x,w.y])*t/x;return H(R,e,r,n,a+1,Math.abs(t-R))}function O(t,e,r,n,a=0,i=1,s){const{averageElevation:c,horizontalFieldOfView:u,verticalFieldOfView:f,farDistance:l,...p}=n;if(a>=5||i<=.1)return{value:t};const y=new m({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:n.cameraLocation.spatialReference}),h=j(y,p),x=o([r[0].x,r[0].y],[h.x,h.y]),g=r.at(0),w=r.at(-1);if(!g||!w)return null;const R=o([g.x,g.y],[w.x,w.y])*t/x;return O(R,e,r,n,a+1,Math.abs(t-R))}async function V(t,e){const{updateElevationProps:r,...n}=e;return await z(t,n,r)}async function A(t,e){const{updateElevationProps:r,...n}=e;return v(t,n,r)}function B(t){navigator.clipboard.writeText(t).catch((t=>{throw t}))}function C(t){const e=t.map((t=>[t.x,t.y])),r=t[0].spatialReference;return new y({paths:[e],spatialReference:r})}function J(t,e){return t.map((t=>({x:e?.5+t[0]:t[0],y:e?.5-t[1]:t[1]})))}function K(t,r,a,o,i){const s="measurement"===t?r:a;if(i&&s)return e(o,n(s,"meters"),i,3)||null}function N(t,e){const{cameraPitch:r,cameraRoll:n,cameraLocation:a}=t,{x:o,y:i,z:s,spatialReference:c}=a;if(e.every((t=>0===t))||!e||!e.length)return null;const[u,f,,l,p]=e,y=[-l,0,l],h=[-p,0,p],x=[-u,0,u],g=[-f,0,f],w=[];for(const R of y)for(const e of h)for(const a of x)for(const u of x)for(const f of g){const l={...t};l.cameraPitch=r+R,l.cameraRoll=n+e,l.cameraLocation=new m({x:o+a,y:i+u,z:s?s+f:0,spatialReference:{wkid:c.wkid}}),w.push(l)}return w}function Q(t,e){const{cameraHeading:r,cameraLocation:n}=t,{x:a,y:o,z:i,spatialReference:s}=n;if(e.every((t=>0===t))||!e||!e.length)throw new Error("Invalid parameters");const[c,u,f]=e,l=f>0?[-f,0,f]:[],p=c>0?[-c,0,c]:[],y=u>0?[-u,0,u]:[],h=[];for(const x of l)for(const e of p)for(const n of p)for(const c of y){const u={...t};u.cameraHeading=r+x,u.cameraLocation=new m({x:a+e,y:o+n,z:i?i+c:0,spatialReference:{wkid:s.wkid}}),h.push(u)}return h}function X(t,r,a,o,i){const s="measurement"===t?r:Z(a);if(i&&s)return e(o,n(s,"meters"),i,3)||null}function Y(t,e,n,o,i){const s="measurement"===t?e:n;if(i&&s)return r(o,a(s,"square-meters"),i,3)||null}function Z(t){return Math.sqrt(t.reduce(((t,e)=>t+e**2),0))}function $(t,e,r){if("default"===e)return t;const n={x:t[0],y:t[1],z:t[2]},a=M(n,r[0],r[1]);return[a.x,a.y]}async function _(e,r,n,a=!1,i=!1,s){if(!e||!r||e.length<2)return null;const c=J(e,a);if(!c||c.length<2)return null;const[u,f]=[c[0],c.at(-1)];if(!f)return null;const l=[u],m=await z(u,r);t(s);const p=m.clone();p.z?p.z+=20:p.z=20;const{averageElevation:y,cameraPitch:h,cameraRoll:x,farDistance:g,...w}=r,R=P(p,w),d=o([u.x,u.y],[R.x,R.y]),v=b(u,R);if(!v)return;const M=q([u.x,u.y],[f.x,f.y],v);if(!M?.length)return;l.push({x:M[0],y:M[1]});const j=20*o([l[0].x,l[0].y],[l[1].x,l[1].y])/d;if(!i)return j;const E=H(j,m,l,r,0,1);return E?.value}async function tt(e,r,n,a,i=!1,s=!1,c){const{attributes:u}=a,{location:f}=u,{updateElevationProps:l,...m}=r;if(!e||!r||e.length<2)throw new Error("Invalid parameters");const p=J(e,i),[y,x]=[p[0],p.at(-1)],w=[y];let R=f.clone();R.spatialReference.isGeographic&&(R=await h(R,g.WebMercator));const d=await v(y,{...m,cameraLocation:R},l);t(c);const z=d.clone();z.z?z.z+=20:z.z=20;const M=j(z,m),P=o([y.x,y.y],[M.x,M.y]),E=b(y,M);if(!E)return;const I=q([y.x,y.y],[x.x,x.y],E);if(!I?.length)return;w.push({x:I[0],y:I[1]});const L=20*o([w[0].x,w[0].y],[w[1].x,w[1].y])/P;if(!s)return L;const W=O(L,d,w,r,0,1);return W?.value}async function et(t,e,r=!1){if(t.length<3)return null;const n=J(t,r),a=await V(n,e),o=a.map((({x:t,y:e})=>[t,e]));t.push(t[0]),o.push(o[0]);const i=a[0].spatialReference,s=new y({paths:[o],spatialReference:i}),c=new p({rings:[o],spatialReference:i});return i.isGeographic?L(i,s,c):i.isWebMercator?F(s,c):U(s,c)}async function rt(e,r,n=!1,a){if(e.length<3)return null;const o=J(e,n),i=await A(o,r);t(a);const s=i.map((({x:t,y:e})=>[t,e]));e.push(e[0]),s.push(s[0]);const c=i[0].spatialReference,u=new y({paths:[s],spatialReference:c}),f=new p({rings:[s],spatialReference:c});return c.isGeographic?L(c,u,f):c.isWebMercator?F(u,f):U(u,f)}async function nt(t,e,r=!1){const n=J(t,r);return D(C(await V(n,e)))}async function at(e,r,n=!1,a){const o=J(e,n),i=await A(o,r);t(a);return D(C(i))}export{b as calculateAngle,I as calculateAnglePano,q as calculateCorrectedPixel,W as calculateHeightAccuracy,G as calculateHeightAccuracyPanoramic,k as calculateHeightFromTemporaryDistance,T as calculateReferenceImagePointPanoramic,S as calculateTempImagePoint,H as computeHeightIteratively,O as computeHeightIterativelyPanoramic,B as copyToClipboard,J as formatPixels,N as generateCombinations,Q as generateCombinationsPanoramic,Y as getConvertedArea,X as getConvertedDistance,K as getConvertedHeight,$ as getModeCorrectedPoint,Z as getRootOfSumOfSquaredErrors,_ as heightMeasurement2D,tt as heightMeasurementPanoramic,et as pixelAreaMeasurement2D,rt as pixelAreaMeasurementPanoramic,nt as pixelDistanceMeasurement2D,at as pixelDistanceMeasurementPanoramic};