@arcgis/core 4.33.0-next.20250417 → 4.33.0-next.20250419

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 (119) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{afcb12bf54a5656f641e.js → 02176f84d6d57f1bc1c8.js} +2 -2
  3. package/assets/esri/core/workers/chunks/{afcb12bf54a5656f641e.js.LICENSE.txt → 02176f84d6d57f1bc1c8.js.LICENSE.txt} +1 -1
  4. package/assets/esri/core/workers/chunks/{2db5dd5638c93b0af102.js → 0a7cba60a5286ba621d4.js} +1 -1
  5. package/assets/esri/core/workers/chunks/0c6f2808c57ff820bfdd.js.LICENSE.txt +1 -1
  6. package/assets/esri/core/workers/chunks/244d2196bac5ef279436.js +1 -0
  7. package/assets/esri/core/workers/chunks/32f2e0c88046b39916cc.js +1 -0
  8. package/assets/esri/core/workers/chunks/38f9ede26098eb03ca2d.js.LICENSE.txt +1 -1
  9. package/assets/esri/core/workers/chunks/{c616139a160eab9cd717.js → 4867a515ddbdab97cc61.js} +1 -1
  10. package/assets/esri/core/workers/chunks/48a1bb1e171dd06a7c6e.js +1 -0
  11. package/assets/esri/core/workers/chunks/5db336767959507c07e5.js.LICENSE.txt +1 -1
  12. package/assets/esri/core/workers/chunks/814d72abbfdd4552e4ec.js.LICENSE.txt +1 -1
  13. package/assets/esri/core/workers/chunks/93f792f5b94f3745b57d.js.LICENSE.txt +1 -1
  14. package/assets/esri/core/workers/chunks/ae13bd77a25ce8b54631.js +1 -0
  15. package/assets/esri/core/workers/chunks/c5d786166a5609b85276.js.LICENSE.txt +1 -1
  16. package/assets/esri/core/workers/chunks/d28e2c9bdf514236b011.js +1 -0
  17. package/assets/esri/core/workers/chunks/dbaa4b8d37aab40d7bd1.js.LICENSE.txt +1 -1
  18. package/assets/esri/themes/base/widgets/_FeatureTable.scss +1 -1
  19. package/assets/esri/themes/dark/main.css +1 -1
  20. package/assets/esri/themes/light/main.css +1 -1
  21. package/assets/esri/themes/light/view.css +1 -1
  22. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
  23. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ar.json +1 -1
  24. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bg.json +1 -1
  25. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bs.json +1 -1
  26. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ca.json +1 -1
  27. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_cs.json +1 -1
  28. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_da.json +1 -1
  29. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_de.json +1 -1
  30. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_el.json +1 -1
  31. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
  32. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_es.json +1 -1
  33. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_et.json +1 -1
  34. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fi.json +1 -1
  35. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fr.json +1 -1
  36. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_he.json +1 -1
  37. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hr.json +1 -1
  38. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hu.json +1 -1
  39. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_id.json +1 -1
  40. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_it.json +1 -1
  41. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ja.json +1 -1
  42. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ko.json +1 -1
  43. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lt.json +1 -1
  44. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lv.json +1 -1
  45. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nl.json +1 -1
  46. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_no.json +1 -1
  47. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pl.json +1 -1
  48. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-BR.json +1 -1
  49. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-PT.json +1 -1
  50. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ro.json +1 -1
  51. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ru.json +1 -1
  52. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sk.json +1 -1
  53. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sl.json +1 -1
  54. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sr.json +1 -1
  55. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sv.json +1 -1
  56. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_th.json +1 -1
  57. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_tr.json +1 -1
  58. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_uk.json +1 -1
  59. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_vi.json +1 -1
  60. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-CN.json +1 -1
  61. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-HK.json +1 -1
  62. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-TW.json +1 -1
  63. package/chunks/BloomComposition.glsl.js +25 -19
  64. package/chunks/ChapmanAtmosphere.glsl.js +1 -1
  65. package/chunks/Fog.glsl.js +3 -3
  66. package/chunks/Haze.glsl.js +1 -1
  67. package/interfaces.d.ts +94 -2
  68. package/layers/VideoLayer.js +1 -1
  69. package/layers/support/domainUtils.js +1 -1
  70. package/layers/support/fieldUtils.js +1 -1
  71. package/layers/support/labelingInfo.js +1 -1
  72. package/layers/support/serviceCapabilitiesUtils.js +1 -1
  73. package/layers/video/VideoController.js +1 -1
  74. package/layers/video/videoUtils.js +1 -1
  75. package/networks/UtilityNetwork.js +1 -1
  76. package/package.json +2 -2
  77. package/renderers/support/AuthoringInfoVisualVariable.js +1 -1
  78. package/rest/featureService/FeatureService.js +1 -1
  79. package/rest/networks/support/NetworkElement.js +1 -1
  80. package/rest/networks/support/TelecomNetworkElement.js +5 -0
  81. package/rest/print.js +1 -1
  82. package/smartMapping/renderers/size.js +1 -1
  83. package/smartMapping/renderers/support/spikeUtils.js +5 -0
  84. package/support/revision.js +1 -1
  85. package/views/2d/engine/webgl/FeatureTile.js +1 -1
  86. package/views/2d/engine/webgl/collisions/LabelMetric.js +1 -1
  87. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  88. package/views/2d/layers/VideoLayerView2D.js +1 -1
  89. package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
  90. package/views/3d/environment/ChapmanAtmosphereTechniqueConfiguration.js +1 -1
  91. package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +8 -8
  92. package/views/3d/webgl-engine/effects/bloom/BloomComposition.glsl.js +1 -1
  93. package/views/3d/webgl-engine/effects/bloom/BloomCompositionTechniqueConfiguration.js +5 -0
  94. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
  95. package/views/3d/webgl-engine/effects/haze/HazeTechniqueConfiguration.js +1 -1
  96. package/views/3d/webgl-engine/shaders/ToneMapping.glsl.js +20 -2
  97. package/views/draw/DrawScreenTool.js +1 -1
  98. package/widgets/Editor.js +1 -1
  99. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  100. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  101. package/widgets/Legend/support/sizeRampUtils.js +1 -1
  102. package/widgets/Legend/support/utils.js +1 -1
  103. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  104. package/widgets/OrientedImageryViewer/components/ImageLocationWidget.js +1 -1
  105. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  106. package/widgets/OrientedImageryViewer.js +1 -1
  107. package/widgets/Print/PrintViewModel.js +1 -1
  108. package/widgets/Print/utils.js +1 -1
  109. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
  110. package/widgets/Slider/SliderViewModel.js +1 -1
  111. package/widgets/Slider.js +1 -1
  112. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
  113. package/widgets/support/Selector2D/SelectionOperation.js +1 -1
  114. package/widgets/support/Selector2D/selectorUtils.js +1 -1
  115. package/assets/esri/core/workers/chunks/3b8eee013d7ca156ef2d.js +0 -1
  116. package/assets/esri/core/workers/chunks/3ee505f9ddb671dcfa52.js +0 -1
  117. package/assets/esri/core/workers/chunks/7f36cffc6ed984b7e467.js +0 -1
  118. package/assets/esri/core/workers/chunks/efb0f3ec2344adcb24f3.js +0 -1
  119. package/assets/esri/core/workers/chunks/f34ce3c37a385b341631.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/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 I}from"../../core/sql.js";import{getMetersPerUnitForSR as S}from"../../core/unitUtils.js";import{property as M}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as C}from"../../core/accessorSupport/decorators/subclass.js";import{distance as k}from"../../core/libs/gl-matrix-2/math/vec2.js";import{UpdatingHandles as V}from"../../core/support/UpdatingHandles.js";import{union as A}from"../../geometry/geometryEngineAsync.js";import G from"../../geometry/Multipoint.js";import R from"../../geometry/Point.js";import O from"../../geometry/Polygon.js";import L from"../../geometry/Polyline.js";import{projectWithZConversion as x}from"../../geometry/projection.js";import j from"../../geometry/SpatialReference.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as B}from"../../geometry/support/webMercatorUtils.js";import z from"../../layers/GraphicsLayer.js";import{searchImages as H}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as D}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as T,computePolygonForInspection as U,resizePolygon as N,checkIfPolygonContainsSelectedPoint as W}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as q,isElevationSource as $}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as J,imageToWorldPanoramic as Z}from"../../layers/orientedImagery/transformations/imageToWorld.js";import K from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Q}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as X,convertPixelToHeadingPitch as Y,getImageToWorldProperties as ee,getUpdateElevationProps as te,isElevationSampler as ie,getImageToWorldPanoramicProperties as ae,pointToArray as re,transformGraphicCoordinatesToPixel as se,getWorldToImageProperties as oe,convertHeadingPitchToSphereVertex as ne,or as le}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as ce,worldToImage as he}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as ue}from"../../layers/support/floorFilterUtils.js";import pe from"../../symbols/SimpleLineSymbol.js";import me from"../../views/draw/Draw.js";import{scale as de}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ge}from"../../views/input/InputManager.js";import ye from"../PanoramicViewer.js";import{invalidCameraHeading as fe,sectorsInOrder as ve,sectorsRadii as we}from"./constants.js";import{configureSketchTool as be,extractFieldsFromDataCaptureLayer as Fe,isValidDataCaptureLayer as _e,constructGraphicFromImageGeometry as Pe}from"./dataCaptureUtils.js";import{isFeatureAttachment as Ie,getImageSourceFromAttachment as Se}from"./galleryUtils.js";import{formatPixels as Me,heightMeasurementPanoramic as Ce,heightMeasurement2D as ke,calculateHeightAccuracyPanoramic as Ve,calculateHeightAccuracy as Ae,pixelAreaMeasurement2D as Ge,pixelAreaMeasurementPanoramic as Re,pixelDistanceMeasurement2D as Oe,pixelDistanceMeasurementPanoramic as Le,generateCombinations as xe,getRootOfSumOfSquaredErrors as je,generateCombinationsPanoramic as Ee,calculateReferenceImagePointPanoramic as Be,calculateAnglePano as ze,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,diamondSymbol as Qe,diamondSymbol3D as Xe,locationSymbol as Ye,locationSymbol3D as et,activeSourcePointSymbol as tt}from"./symbols.js";import{isNoAttachmentError as it,getContentType as at,isTifOrMrf as rt,filterOILLayerView as st,isSceneView as ot,isGraphic as nt,calculateSegment as lt,calculateDirection as ct}from"./utils.js";import ht from"./components/ImageViewer.js";const ut={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles",sketchHandles:"sketch-handles"},pt=new Set(["JPG","JPEG"]),mt=/\.(\w+)$/,dt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let gt=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,this._updateGroundElevation=!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.dataCaptureLayer=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 ht,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._overlays=new z({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new ye,this._previousCursor=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new V,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:i}=await t;return f(e),this.sketchAdapter=new i({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(ut.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,ge.WIDGET),ut.click)},this._createImageClickHandle=()=>{this.removeHandles(ut.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 le(!t,e.spatialReference.equals(t))?e:x(e,t)}));f(i),this.plotReferencePointOnGround(r)}))}));this.addHandles(l,ut.imageClick)},this._createImageLocationHandle=()=>{this.removeHandles(ut.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,this.plotLocationPointOnImage(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 x(r,s),f(i)),this.groundCoordinates=r}))}));this.addHandles(l,ut.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?B(m):new R(m);let v=s;if(Ie(s))try{v=await Se(i,h,e)}catch(w){if(y(w))return;return it(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(mt)?.[1]:e.datasetFormat;if(!c)try{c=await at(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(pt.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 X(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}=Y(e,a,r),n=ne(s,o);this._crossSymbol=new t({geometry:new R(n,j.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]),(()=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();this._setMeasurementCursor()}),_),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(ut.interactionHandles),e){case"default":this.addHandles(F((()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null}),(e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>a(e,t,h)}),ut.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&&!t.includes("loading")?[a,r,o,s]:null}),(e=>{if(!e||this.state.includes("loading"))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)}),ut.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._locationPointOnImage=d(this._locationPointOnImage),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 rt(t)||Ie(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===fe}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(st(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ue(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?ve.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 rt(r)||Ie(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 z({elevationInfo:{mode:"absolute-height"}});case"default":return new z;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():ee(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=Me(m,!1),g="panoramic"===t?await Ce(m,h,c,a,!0,!1):await ke(m,h,c,!0,i);if(!g)return;const y="panoramic"===t?await Ve(c,d,h,g,a,!0):await Ae(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 Le([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=xe(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: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 Re(e,c,!0):await Le([e.at(0),e.at(-1)],c,!0);f(i);const{updateElevationProps:u,...p}=c,m=Ee(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 Le([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,i){const{currentBestFeature:a,activeViewer:r}=this,s=r?.imageSize;if(!a||!r||!s?.length||"none"===t)return;const{attributes:o}=a,[n]=Me([e],"panoramic"!==t),l="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(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=ze(n,e),r=k([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=k([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,this.clearLocationPointOnImage()}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,dataCaptureLayer:a}=this;if(!i)throw dt();be(a,e,i),await i.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw dt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw dt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw dt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw dt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw dt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw dt();return this.sketch.update(e,t)}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=S(e.geometry.spatialReference);o.cameraHeight/=l,o.farDistance/=l,o.nearDistance/=l,q(o.elevationSource)&&(o.elevationSource.constantElevation/=l);const{polygon:c,frustum:h}=T(o);if(n=c.clone(),o.isInspection&&(n=U(o)),s&&(n=N(n,s)),W(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!==fe&&(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=ee(a,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:i,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ie(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=ae(a,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:i,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ie(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimagery","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then((({features:e})=>t.applyEdits({deleteFeatures:e})))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[ve[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?B(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 me({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 L({paths:[e],spatialReference:i});else{const a=new L({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}=Y(a,i[0],i[1]),{heading:n,pitch:l}=Y(r,i[0],i[1]),c=[[...ne(s,o)],[...ne(n,l)]];if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[c],spatialReference:e});else{const i=new L({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}=T(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 pe({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}=T(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=Fe(e,c.imageGeometryField,c.imageReferenceField);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:p,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,c=l,{imageGeometryField:p,oiObjectIdField:m}=this;if(p&&m&&_e(e,p,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Pe(s,p,e,a,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(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(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new O({rings:p,spatialReference:j.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(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new L({paths:p,spatialReference:j.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(re)));return new t({attributes:s,layer:e,symbol:r,geometry:new G({points:p,spatialReference:j.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 R({x:e.x-.5,y:.5-e.y,spatialReference:j.WebMercator});const[t,r]=i,{heading:s,pitch:o}=Y(e,t,r),n=ne(s,o);return new R(n,j.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 x(u,j.WebMercator));const p=await te(c??(l.z??0)-h,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let m;if("elevationSample"in p&&ie(p.elevationSample)&&(i.elevationSample=p.elevationSample),"default"===a){const t=ee(o,r[0],r[1]);m=await J(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}else{const t=ae(o,r[0],r[1]);m=await Z(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:Qe}),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,...i}),symbol:Qe}),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}=Y(e,a,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new R(n,j.WebMercator),symbol:Xe}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(),this.mode){case"default":this._plotLocationPointOnDefaultImage(e);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e)}}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{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==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.saveDataCaptureFeatures(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 saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s)throw new n("orientedimagery","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimagery","Data capture 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(se(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])=>se(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(re)))}),t}case"polyline":{const e=await Promise.all(m.paths.map((async e=>this.getMapPoint(e.map((([e,t,i])=>se(s,{x:e,y:t,z:i},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new L({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,paths:e.map((e=>e.map(re)))}),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("orientedimagery","Error in saving data capture features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:a}}))}async searchBestImage(e,t){try{const i=await H(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 startDataCapture(e,t){const i=this.activeViewer?.imageRenderer,{oiObjectIdField:a,currentBestFeature:r}=this;if(!i||!r||!a)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(a)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);f(t),h.layer.addMany(l),h.layer.blendMode="source-atop",u.savedGraphics.addMany(l);i.ui.find("zoom").visible=!1,i.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=d(this.sketchAdapter),this.sketch=d(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,i=this.activeViewer?.imageRenderer;if(!i||i.destroyed)return;i.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const 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 x(t,s.spatialReference);a=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(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 ve)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*we[2],o=lt(t,l),n=ct(i);if(!this._sectorData)return;const c=we[3]+s*Math.sin(i*Math.PI/180),h=we[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-we[3],t=h-we[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})}))}_plotLocationPointOnDefaultImage(e){const i=c.isSerializable(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._locationPointOnImage=new t({geometry:new R({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:Ye}),this._imageViewer.addGraphic(this._locationPointOnImage,0)}_plotLocationPointOnPanoramicImage(e){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=Y(e,a,r),n=ne(s,o);this._locationPointOnImage=new t({geometry:new R(n,j.WebMercator),symbol:et}),this._panoramicViewer.addGraphic(this._locationPointOnImage,0)}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 A(e,i);const t=[];for(const{geometry:i}of r)e.contains(i)||t.push([i.x,i.y]);if(t.sort(((e,t)=>+E([e,t]))),e.addRing(t),this.footprintExtent=de(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;$(e)&&!n&&(n=await Q({extent:this.footprintExtent,lod:e.lod,url:e.url,rasterFunction:e.rasterFunction}));const i=await te((r[0].attributes.location.z??0)-r[0].attributes.cameraHeight,{elevationSample:n,elevationSource:e,extent:this.footprintExtent}),[a,...s]=await K([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:ot(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 x(o,e.spatialReference),c=I("1=1",I(e.definitionExpression,n)),h=l.spatialReference.isGeographic?1:S(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)}_resetCursor(){const{activeViewer:e}=this;e&&(e.imageRenderer.cursor=this._previousCursor)}_setMeasurementCursor(){const{activeViewer:e}=this;e&&(this._previousCursor=e.imageRenderer.cursor,e.imageRenderer.cursor="crosshair")}_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._updateGroundElevation=!0,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.clone(),symbol:tt,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),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-we[3],a=e.y-we[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))}clearLocationPointOnImage(){this._locationPointOnImage&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=d(this._locationPointOnImage))}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 te(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(K(e,u));t(e)})))));if(r.spatialReference.isGeographic&&(h=await x(h,j.WebMercator,t)),d=await Promise.all(d.map((async e=>h.spatialReference.equals(e.spatialReference)?e:await x(e,h.spatialReference,t)))),f(t),"panoramic"===this.mode)m=ce(d,{imageHeight:a[1],imageWidth:a[0],cameraHeading:o,cameraLocation:h});else{const e=oe(this.currentBestFeature.attributes,a[0],a[1]);m=he(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,mode:h}=this,{attributes:{objectId:u},elevationSample:p}=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,s].filter(nt);l.supportsGround&&p&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e,p),"panoramic"===h&&c.updateGroundElevation([this.bestFeatureCurrentFootprint],p)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:We.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(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&&p&&c?.updateGroundElevation&&"panoramic"===h&&c.updateGroundElevation([e],p),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([M()],gt.prototype,"activeLayer",null),e([M({readOnly:!0})],gt.prototype,"activeViewer",null),e([M()],gt.prototype,"accuracyParametersMissing",null),e([M()],gt.prototype,"additionalFeatures",void 0),e([M({type:s.ofType(t)})],gt.prototype,"additionalCameraLocations",void 0),e([M({type:s.ofType(t)})],gt.prototype,"additionalFootprints",void 0),e([M()],gt.prototype,"areaMeasurementResult",void 0),e([M()],gt.prototype,"areaMeasurementAccuracy",void 0),e([M()],gt.prototype,"bestFeatureAngle",void 0),e([M()],gt.prototype,"bestFeatureCurrentFootprint",void 0),e([M({type:t})],gt.prototype,"bestFeatureFootprint",void 0),e([M({type:Number})],gt.prototype,"brightness",null),e([M()],gt.prototype,"collectionId",void 0),e([M({type:Number})],gt.prototype,"contrast",null),e([M()],gt.prototype,"conversionProps",void 0),e([M()],gt.prototype,"coverageFrustums",void 0),e([M()],gt.prototype,"coveragePolygons",void 0),e([M()],gt.prototype,"currentBestFeature",void 0),e([M()],gt.prototype,"currentBestFeatureLocation",void 0),e([M()],gt.prototype,"currentCoverageVisible",void 0),e([M({json:{write:!1}})],gt.prototype,"determineWorkflowForFeature",void 0),e([M()],gt.prototype,"disabled",void 0),e([M()],gt.prototype,"displayMessage",void 0),e([M()],gt.prototype,"displayNewMeasurementButton",void 0),e([M()],gt.prototype,"distanceMeasurementResult",void 0),e([M()],gt.prototype,"distanceAccuracyArray",void 0),e([M()],gt.prototype,"dataCaptureLayer",void 0),e([M({readOnly:!0})],gt.prototype,"featureCount",null),e([M()],gt.prototype,"features",void 0),e([M()],gt.prototype,"groundCoordinates",void 0),e([M()],gt.prototype,"heightMeasurementPixels",void 0),e([M()],gt.prototype,"heightGraphic",void 0),e([M()],gt.prototype,"heightMeasurementResult",void 0),e([M()],gt.prototype,"heightMeasurementAccuracy",void 0),e([M()],gt.prototype,"measurementAngle",void 0),e([M()],gt.prototype,"tempDistance",void 0),e([M({readOnly:!0})],gt.prototype,"imageGalleryEnabled",null),e([M()],gt.prototype,"imageGeometryField",void 0),e([M({readOnly:!0})],gt.prototype,"imageLoaded",null),e([M()],gt.prototype,"imageLocationToolState",void 0),e([M({readOnly:!0})],gt.prototype,"invalidCameraHeading",null),e([M()],gt.prototype,"imagePointsInView",null),e([M()],gt.prototype,"isAdditionalCoverageVisible",void 0),e([M()],gt.prototype,"isAdditionalPointSourcesVisible",void 0),e([M()],gt.prototype,"layer",void 0),e([M()],gt.prototype,"layerView",null),e([M({readOnly:!0})],gt.prototype,"layerFloorFilterClause",null),e([M({type:Number})],gt.prototype,"localPort",void 0),e([M()],gt.prototype,"mapImageConversionToolState",void 0),e([M()],gt.prototype,"measureType",void 0),e([M()],gt.prototype,"measurementGraphic",void 0),e([M({readOnly:!0,value:"none"})],gt.prototype,"mode",null),e([M()],gt.prototype,"navigatorCurrentBestFeature",void 0),e([M()],gt.prototype,"oiObjectIdField",void 0),e([M({type:s.ofType(t)})],gt.prototype,"overlayedCameraLocations",void 0),e([M()],gt.prototype,"overlayedMapFeatures",void 0),e([M()],gt.prototype,"pixelCoordinates",void 0),e([M()],gt.prototype,"pointSources",void 0),e([M({readOnly:!0})],gt.prototype,"popupEnabled",null),e([M()],gt.prototype,"previousFeatureAngle",void 0),e([M()],gt.prototype,"referencePoint",null),e([M({readOnly:!0})],gt.prototype,"sectorData",null),e([M()],gt.prototype,"selectedPoint",void 0),e([M({type:Number})],gt.prototype,"sharpness",null),e([M()],gt.prototype,"shouldShowSelectedImage",void 0),e([M()],gt.prototype,"sketch",void 0),e([M()],gt.prototype,"draw",void 0),e([M()],gt.prototype,"sketchAdapter",void 0),e([M({readOnly:!0})],gt.prototype,"sketchGraphicsLayer",null),e([M({readOnly:!0})],gt.prototype,"state",null),e([M({readOnly:!0})],gt.prototype,"thumbnails",null),e([M()],gt.prototype,"updateFootprint",void 0),e([M()],gt.prototype,"updateFootprintPanorama",void 0),e([M({value:null})],gt.prototype,"view",null),e([M()],gt.prototype,"_adapter",void 0),e([M()],gt.prototype,"_sketchGraphicsLayer",null),e([M()],gt.prototype,"_highlightedFeatureHandle",void 0),e([M()],gt.prototype,"_imageViewer",void 0),e([M()],gt.prototype,"_initialCurrentCoverageUpdate",void 0),e([M()],gt.prototype,"_locationPointOnImage",void 0),e([M()],gt.prototype,"_overlays",void 0),e([M({readOnly:!0})],gt.prototype,"_overlaysView",null),e([M()],gt.prototype,"_panoramicViewer",void 0),e([M()],gt.prototype,"_previousCursor",void 0),e([M()],gt.prototype,"_referencePointOnGround",void 0),e([M()],gt.prototype,"_referencePointOnImage",void 0),e([M()],gt.prototype,"_sectorData",void 0),e([M({readOnly:!0})],gt.prototype,"_updatingHandles",void 0),e([M()],gt.prototype,"footprintExtent",void 0),e([M()],gt.prototype,"_featureChangedTask",void 0),gt=e([C("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],gt);const yt=gt;export{yt as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{isSome as a,equals as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import 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 I}from"../../core/sql.js";import{getMetersPerUnitForSR as M}from"../../core/unitUtils.js";import{property as S}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as C}from"../../core/accessorSupport/decorators/subclass.js";import{distance as k}from"../../core/libs/gl-matrix-2/math/vec2.js";import{UpdatingHandles as V}from"../../core/support/UpdatingHandles.js";import{union as A}from"../../geometry/geometryEngineAsync.js";import R from"../../geometry/Multipoint.js";import G from"../../geometry/Point.js";import O from"../../geometry/Polygon.js";import L from"../../geometry/Polyline.js";import{projectWithZConversion as x}from"../../geometry/projection.js";import j from"../../geometry/SpatialReference.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as z}from"../../geometry/support/webMercatorUtils.js";import B from"../../layers/GraphicsLayer.js";import{searchImages as H}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as D}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as T,computePolygonForInspection as U,resizePolygon as N,checkIfPolygonContainsSelectedPoint as W}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as q,isElevationSource as $}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as J,imageToWorldPanoramic as Z}from"../../layers/orientedImagery/transformations/imageToWorld.js";import K from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Q}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as X,convertPixelToHeadingPitch as Y,getImageToWorldProperties as ee,getUpdateElevationProps as te,isElevationSampler as ae,getImageToWorldPanoramicProperties as ie,pointToArray as re,transformGraphicCoordinatesToPixel as se,getWorldToImageProperties as oe,convertHeadingPitchToSphereVertex as ne,or as le}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as ce,worldToImage as he}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as ue}from"../../layers/support/floorFilterUtils.js";import pe from"../../symbols/SimpleLineSymbol.js";import me from"../../views/draw/Draw.js";import{scale as de}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ge}from"../../views/input/InputManager.js";import ye from"../PanoramicViewer.js";import{invalidCameraHeading as fe,sectorsInOrder as ve,sectorsRadii as we}from"./constants.js";import{configureSketchTool as be,extractFieldsFromDataCaptureLayer as Fe,isValidDataCaptureLayer as _e,constructGraphicFromImageGeometry as Pe}from"./dataCaptureUtils.js";import{isFeatureAttachment as Ie,getImageSourceFromAttachment as Me}from"./galleryUtils.js";import{formatPixels as Se,heightMeasurementPanoramic as Ce,heightMeasurement2D as ke,calculateHeightAccuracyPanoramic as Ve,calculateHeightAccuracy as Ae,pixelAreaMeasurement2D as Re,pixelAreaMeasurementPanoramic as Ge,pixelDistanceMeasurement2D as Oe,pixelDistanceMeasurementPanoramic as Le,generateCombinations as xe,getRootOfSumOfSquaredErrors as je,generateCombinationsPanoramic as Ee,calculateLocationAccuracyFromDeviations as ze,calculateReferenceImagePointPanoramic as Be,calculateAnglePano as He,calculateTempImagePoint as De,calculateAngle as Te,getModeCorrectedPoint as Ue,calculateCorrectedPixel as Ne,calculateHeightFromTemporaryDistance as We}from"./imageMeasurementUtils.js";import{crossSymbol as qe,crossSymbol3D as $e,measurementPolygonSymbol as Je,polylineSymbolPanoramic as Ze,measurementPolylineSymbol as Ke,sourcePointSymbol as Qe,diamondSymbol as Xe,diamondSymbol3D as Ye,locationSymbol as et,locationSymbol3D as tt,activeSourcePointSymbol as at}from"./symbols.js";import{isNoAttachmentError as it,getContentType as rt,isTifOrMrf as st,filterOILLayerView as ot,isSceneView as nt,isGraphic as lt,calculateSegment as ct,calculateDirection as ht}from"./utils.js";import ut from"./components/ImageViewer.js";const pt={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles",sketchHandles:"sketch-handles"},mt=new Set(["JPG","JPEG"]),dt=/\.(\w+)$/,gt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let yt=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,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadImage(a)}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.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.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 ut,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._overlays=new B({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new ye,this._previousCursor=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new V,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:a}=await t;return 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:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,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(pt.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,ge.WIDGET),pt.click)},this._createImageClickHandle=()=>{this.removeHandles(pt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;a.clickAction="pixel-location";let n=null;const l=b((()=>a),"pixel-location",(e=>{this.plotReferencePointOnImage(e),n?.abort(),n=r((async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return le(!t,e.spatialReference.equals(t))?e:x(e,t)}));f(a),this.plotReferencePointOnGround(r)}))}));this.addHandles(l,pt.imageClick)},this._createImageLocationHandle=()=>{this.removeHandles(pt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;a.clickAction="pixel-location";let n=null;const l=b((()=>a),"pixel-location",(e=>{this.pixelCoordinates=e,this.plotLocationPointOnImage(e),n?.abort(),n=r((async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});f(a);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),f(a)),this.groundCoordinates=r;const n=await this.calculateLocationAccuracy(e,r,t,a);f(a),n&&(this.groundCoordinatesAccuracy=n)}))}));this.addHandles(l,pt.imageClick)},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i)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?z(m):new G(m);let v=s;if(Ie(s))try{v=await Me(a,h,e)}catch(w){if(y(w))return;return it(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(v,{imageRotation:d,options:e,pitch:c,yaw:n,mode:i,cameraLocation:g}),f(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(dt)?.[1]:e.datasetFormat;if(!c)try{c=await rt(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(c??="UNKNOWN FORMAT",a){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:o.split("?")[0]},this._imageViewer.customParameters=Object.fromEntries(l),this._imageViewer.imageRotation=i??0,await this._imageViewer.loadImage(r);break;case"panoramic":if(mt.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=i??0;"number"==typeof n?l=n-l:s&&e&&(l=await X(s,e)-l),this._panoramicViewer.pitch=a??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:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,a)=>{if(await v(a),!e)return;const i=new G({...c.isSerializable(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:qe}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=Y(e,i,r),n=ne(s,o);this._crossSymbol=new t({geometry:new G(n,j.WebMercator),symbol:$e}),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]),(()=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();this._setMeasurementCursor()}),_),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 a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}]))),await this._featureChangedTask.promise}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(pt.interactionHandles),e){case"default":this.addHandles(F((()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null}),(e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>i(e,t,h)}),pt.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:a,vfov:i,hfov:r,pitch:s,yaw:o}=this._panoramicViewer;return e&&a&&!t.includes("loading")?[i,r,o,s]:null}),(e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;m(this._updateFootprintTask),this._updateFootprintTask=r((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>i(e,t,h)}),pt.interactionHandles)}}),_),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)}),_),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._locationPointOnImage=d(this._locationPointOnImage),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:a}=this;switch(a){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 st(t)||Ie(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===fe}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(ot(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ue(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:a}=e;return 360===t||a?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?ve.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:a},_featureChangedTask:i}=this;if(t)return"disabled";if(!this.isFulfilled()||a||!1===i?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:i}})=>{const r=e?.trim();return st(r)||Ie(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null})).filter(a)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new B({elevationInfo:{mode:"absolute-height"}});case"default":return new B;case"none":return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}async computeHeight(e,t,a=!0){const{currentBestFeature:i,activeViewer:r,layer:s,footprintExtent:o}=this,n=r?.imageSize,l=i?.attributes,c=s?.orientationAccuracy;if(!l||!n||!e||e.length<2||!c)return;const h="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(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=Se(m,!1),g="panoramic"===t?await Ce(m,h,c,i,!0,!1):await ke(m,h,c,!0,a);if(!g)return;const y="panoramic"===t?await Ve(c,d,h,g,i,!0):await Ae(c,d,h,g,!0);return y?{value:g,accuracy:y}:{value:g}}async calculateAreaMeasurement(e,t,a){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const i="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(a),i?"default"===t?await Re(e,i,!0):await Ge(e,i,!0,a):null}async calculateDistanceMeasurement(e,t,a){const{currentBestFeature:i,activeViewer:r}=this;if(e.length<2||!i||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(a),s?"default"===t?await Oe([e.at(0),e.at(-1)],s,!0):await Le([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s}=this,o=i?.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(a),!l)return null;const c="area"===t?await Re(e,l,!0):await Oe([e.at(0),e.at(-1)],l,!0);f(a);const{updateElevationProps:h,...u}=l,p=xe(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async i=>{const r="area"===t?await Re(e,i,!0):await Oe([e.at(0),e.at(-1)],i,!0);if(f(a),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(a);const g=d.filter((e=>null!==e));return 0===g.length?null:je(g)}async calculateLocationAccuracy(e,t,a="default",i){const{layer:r,currentBestFeature:s}=this,o=r?.orientationAccuracy,n=this.view?.spatialReference,l=o?.every((e=>0===e))||!o?.length;if(!s||l)return null;const c="default"===a?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();if(f(i),!c)return null;const{updateElevationProps:h,...u}=c,p="default"===a?xe(u,o):Ee(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async r=>{const{updateElevationProps:s,...o}=r;let l="default"===a?await J(e,o,s):await Z(e,o,s);return f(i),n&&!l.spatialReference.equals(n)&&(l=await x(l,n),f(i)),l&&t?[Math.abs(l.x-t.x),Math.abs(l.y-t.y),l.z&&t.z?Math.abs(l.z-t.z):0]:null})),d=await Promise.all(m);if(f(i),!d?.length)return null;const g=d.map((e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0])),[y,v,w]=ze(g);return{x:y,y:v,z:w}}async calculateAccuracyPanoramic(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s,mode:o}=this,n=i?.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(a),!c)return null;const h="area"===t?await Ge(e,c,!0):await Le([e.at(0),e.at(-1)],c,!0);f(a);const{updateElevationProps:u,...p}=c,m=Ee(p,n);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async i=>{const r="area"===t?await Ge(e,i,!0):await Le([e.at(0),e.at(-1)],i,!0);if(f(a),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(a);const y=g.filter((e=>null!==e));return 0===y.length?null:je(y)}async calculateHeightMeasurementInfo(e,t,a){const{currentBestFeature:i,activeViewer:r}=this,s=r?.imageSize;if(!i||!r||!s?.length||"none"===t)return;const{attributes:o}=i,[n]=Se([e],"panoramic"!==t),l="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(o,s[0],s[1]);if("panoramic"===t){if(!l)return;const e=await Be(n,l,i,a);if(!e)return;e?.heading>180&&(e.heading-=360);const t=He(n,e),r=k([n.x,n.y],[e.x,e.y]);if(!t||!r)return;return{measurementAngle:t,tempDistance:r}}const c=await De(n,l,a);if(!c)return;const h=Te(n,c),u=k([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.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null)}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:a,dataCaptureLayer:i}=this;if(!a)throw gt();be(i,e,a),await a.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw gt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw gt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw gt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw gt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw gt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw gt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t){const a=[],i=[],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,q(o.elevationSource)&&(o.elevationSource.constantElevation/=l);const{polygon:c,frustum:h}=T(o);if(n=c.clone(),o.isInspection&&(n=U(o)),s&&(n=N(n,s)),W(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!==fe&&(a.push(c),h&&i.push(h))}})),{features:r,polygons:a,frustums:i}}getMeasurementProperties(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ee(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:a,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:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ie(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ae(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimagery","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then((({features:e})=>t.applyEdits({deleteFeatures:e})))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[ve[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t];i?.length&&this._updateCurrentBestFeature(i.at(a))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s}=this,o=s?.imageSize;if(!e.vertices||!o)return;const n=Ue(e.vertices.at(-1),r,o);if(i.length<1||!n||!a||!t||"none"===r)return;const l=Ne(i[0],n,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const c=We(this.heightMeasurementPixels,a);c&&(this.heightMeasurementResult=c)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=Ue(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}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?z(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:a}=await t;f(e),this.sketch=new a({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:a}=await t;if(f(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async startMeasurement(e,t){await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=Je(o),this.sketch.polylineSymbol="panoramic"===s?Ze:Ke(o))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new me({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],(e=>this.handleDrawEvents(e)))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[e],spatialReference:a});else{const i=new L({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:Ke(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=Y(i,a[0],a[1]),{heading:n,pitch:l}=Y(r,a[0],a[1]),c=[[...ne(s,o)],[...ne(n,l)]];if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[c],spatialReference:e});else{const a=new L({paths:[c],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:Ze}),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:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n}=this,l=a?.imageSize;if(!l||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:c}=T(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:`${s.objectIdField} <> ${i.attributes.objectId}`,geometry:c,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:l,mode:o}),n=Qe.clone();return n.outline=new pe({color:[0,0,0],width:1}),new t({attributes:a,symbol:n,geometry:s})})));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,i=!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}=T(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Fe(e,c.imageGeometryField,c.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:p,returnGeometry:!0,outFields:["*"]}),d=new s((await Promise.all(m.map((async a=>{const r=a.symbol?.clone()??e.renderer?.getSymbol(a)?.clone(),{attributes:s,geometry:l}=a,c=l,{imageGeometryField:p,oiObjectIdField:m}=this;if(p&&m&&_e(e,p,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Pe(s,p,e,i,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:a,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(c?.type){case"point":{const a=await this.getPixels(c,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:a,visible:e.visible&&i})}case"polygon":{const{rings:a,spatialReference:l}=c,u=a.map((e=>e.map((([e,t,a])=>new G({x:e,y:t,z:a,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new O({rings:p,spatialReference:j.WebMercator}),visible:e.visible&&i})}case"polyline":{const{paths:a,spatialReference:l}=c,u=a.map((e=>e.map((([e,t,a])=>new G({x:e,y:t,z:a,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new L({paths:p,spatialReference:j.WebMercator}),visible:e.visible&&i})}case"multipoint":{const{points:a,spatialReference:l}=c,u=a.map((([e,t,a])=>new G({x:e,y:t,z:a,spatialReference:l}))),p=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re)));return new t({attributes:s,layer:e,symbol:r,geometry:new R({points:p,spatialReference:j.WebMercator}),visible:e.visible&&i})}}return null})))).filter(a));this.overlayGraphicsOnImage(`${e.id}`,d)}async getPixels(e,t){const{imageSize:a,mode:i}=t,r=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===i)return new G({x:e.x-.5,y:.5-e.y,spatialReference:j.WebMercator});const[t,r]=a,{heading:s,pitch:o}=Y(e,t,r),n=ne(s,o);return new G(n,j.WebMercator)}));return Array.isArray(e)?r:r[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:l,elevation:c,cameraHeight:h}=o;let u=l.clone();u.spatialReference.isGeographic&&(u=await x(u,j.WebMercator));const p=await te(c??(l.z??0)-h,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let m;if("elevationSample"in p&&ae(p.elevationSample)&&(a.elevationSample=p.elevationSample),"default"===i){const t=ee(o,r[0],r[1]);m=await J(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}else{const t=ie(o,r[0],r[1]);m=await Z(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:Xe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=c.isSerializable(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new G({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:Xe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=Y(e,i,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new G(n,j.WebMercator),symbol:Ye}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(),this.mode){case"default":this._plotLocationPointOnDefaultImage(e);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e)}}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{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce(((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(a&&(l[e.objectIdField]=a),i&&e.globalIdField&&(l[e.globalIdField]=i),t.success.push(n)),t}),{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:i,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!i||"none"===s)throw new n("orientedimagery","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimagery","Data capture layer is not available");const l=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:a}=t;if(!a)return;const n=a.type,l=r.hasZ,c=r.geometryType,h=n!==c,u=h?await import("./transformers.js"):null,p=u?.default[c],m=h?p?.(a):a;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(se(s,m,o),{feature:i,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,a])=>se(s,{x:e,y:t,z:a},o))),{feature:i,imageSize:o,mode:s}))));return t.geometry=new O({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,rings:e.map((e=>e.map(re)))}),t}case"polyline":{const e=await Promise.all(m.paths.map((async e=>this.getMapPoint(e.map((([e,t,a])=>se(s,{x:e,y:t,z:a},o))),{feature:i,imageSize:o,mode:s}))));return t.geometry=new L({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,paths:e.map((e=>e.map(re)))}),t}}}))),c=l.filter(a);return r.applyEdits({addFeatures:c}).then((e=>{const{addFeatureResults:t}=e;let a=0;const i=l.map((e=>{const i=t[a++];return e?i:{error:new n("orientedimagery","Error in saving data capture features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:i}}))}async searchBestImage(e,t){try{const a=await H(e,t);a&&await this._processFeatureResponse(a,e.point,{signal:t?.signal})}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),u.getLogger(this).error("error occurred while finding best image",a))}}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 startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);f(t),h.layer.addMany(l),h.layer.blendMode="source-atop",u.savedGraphics.addMany(l);a.ui.find("zoom").visible=!1,a.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=d(this.sketchAdapter),this.sketch=d(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const a=this.overlayedMapFeatures.get(e);a&&this._toggleVisiblity(a,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:a}=e;let i=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);i=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);r=s.extent.contains(e);break}}if(!i&&!r)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,a);if(o)return f(a),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 a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:a,features:i,invalidCameraHeading:r}=this;if(!e||!t||!a||!i||r)return void(this._sectorData=null);this._sectorData={};for(const c of ve)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:a,featureIndex:r}=e,s=t/l*we[2],o=ct(t,l),n=ht(a);if(!this._sectorData)return;const c=we[3]+s*Math.sin(a*Math.PI/180),h=we[3]+s*Math.cos(a*Math.PI/180);let u;const p=i.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-we[3],t=h-we[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),u=i}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:a,featureIndex:r,x:c,y:h,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}_plotLocationPointOnDefaultImage(e){const a=c.isSerializable(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._locationPointOnImage=new t({geometry:new G({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:et}),this._imageViewer.addGraphic(this._locationPointOnImage,0)}_plotLocationPointOnPanoramicImage(e){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=Y(e,i,r),n=ne(s,o);this._locationPointOnImage=new t({geometry:new G(n,j.WebMercator),symbol:tt}),this._panoramicViewer.addGraphic(this._locationPointOnImage,0)}async _processFeatureResponse(e,t,a){const{features:i}=e;if(!i?.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(i,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 a of s)e=await A(e,a);const t=[];for(const{geometry:a}of r)e.contains(a)||t.push([a.x,a.y]);if(t.sort(((e,t)=>+E([e,t]))),e.addRing(t),this.footprintExtent=de(e.extent,2,2),this.view?.supportsGround)try{n=await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(l){y(l)||u.getLogger(this).error(l)}}if((n||r[0].attributes.elevationSource)&&this.footprintExtent){const e=r[0].attributes.elevationSource;$(e)&&!n&&(n=await Q({extent:this.footprintExtent,lod:e.lod,url:e.url,rasterFunction:e.rasterFunction}));const a=await te((r[0].attributes.location.z??0)-r[0].attributes.cameraHeight,{elevationSample:n,elevationSource:e,extent:this.footprintExtent}),[i,...s]=await K([t,...r.map((e=>e.attributes.geometry.clone()))],a);r[0].elevationSample=n??a.elevationSample,t.elevation=i.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:nt(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await x(o,e.spatialReference),c=I("1=1",I(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,a)}_resetCursor(){const{activeViewer:e}=this;e&&(e.imageRenderer.cursor=this._previousCursor)}_setMeasurementCursor(){const{activeViewer:e}=this;e&&(this._previousCursor=e.imageRenderer.cursor,e.imageRenderer.cursor="crosshair")}_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._updateGroundElevation=!0,this.currentBestFeature=e[0]}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),f(e);for(const e of a)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:at,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:Qe,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 a;if(t)a=-90;else{const t=e.x-we[3],i=e.y-we[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}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))}clearLocationPointOnImage(){this._locationPointOnImage&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=d(this._locationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=d(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,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:i,feature:t})}}async worldToImage(e,t){const{footprintExtent:a}=this,{imageSize:i}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!i||!a)return;const{attributes:{location:r,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:l},elevationSample:c}=this.currentBestFeature;let h=r.clone();const u=await te(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(K(e,u));t(e)})))));if(r.spatialReference.isGeographic&&(h=await x(h,j.WebMercator,t)),d=await Promise.all(d.map((async e=>h.spatialReference.equals(e.spatialReference)?e:await x(e,h.spatialReference,t)))),f(t),"panoramic"===this.mode)m=ce(d,{imageHeight:i[1],imageWidth:i[0],cameraHeading:o,cameraLocation:h});else{const e=oe(this.currentBestFeature.attributes,i[0],i[1]);m=he(d,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:h}=this,{attributes:{objectId:u},elevationSample:p}=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=[...a,...i,s].filter(lt);l.supportsGround&&p&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e,p),"panoramic"===h&&c.updateGroundElevation([this.bestFeatureCurrentFootprint],p)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:qe.clone(),attributes:{imageID:u}}))),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&&p&&c?.updateGroundElevation&&"panoramic"===h&&c.updateGroundElevation([e],p),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],yt.prototype,"activeLayer",null),e([S({readOnly:!0})],yt.prototype,"activeViewer",null),e([S()],yt.prototype,"accuracyParametersMissing",null),e([S()],yt.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],yt.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],yt.prototype,"additionalFootprints",void 0),e([S()],yt.prototype,"areaMeasurementResult",void 0),e([S()],yt.prototype,"areaMeasurementAccuracy",void 0),e([S()],yt.prototype,"bestFeatureAngle",void 0),e([S()],yt.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],yt.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],yt.prototype,"brightness",null),e([S()],yt.prototype,"collectionId",void 0),e([S({type:Number})],yt.prototype,"contrast",null),e([S()],yt.prototype,"conversionProps",void 0),e([S()],yt.prototype,"coverageFrustums",void 0),e([S()],yt.prototype,"coveragePolygons",void 0),e([S()],yt.prototype,"currentBestFeature",void 0),e([S()],yt.prototype,"currentBestFeatureLocation",void 0),e([S()],yt.prototype,"currentCoverageVisible",void 0),e([S({json:{write:!1}})],yt.prototype,"determineWorkflowForFeature",void 0),e([S()],yt.prototype,"disabled",void 0),e([S()],yt.prototype,"displayMessage",void 0),e([S()],yt.prototype,"displayNewMeasurementButton",void 0),e([S()],yt.prototype,"distanceMeasurementResult",void 0),e([S()],yt.prototype,"distanceAccuracyArray",void 0),e([S()],yt.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],yt.prototype,"featureCount",null),e([S()],yt.prototype,"features",void 0),e([S()],yt.prototype,"groundCoordinates",void 0),e([S()],yt.prototype,"groundCoordinatesAccuracy",void 0),e([S()],yt.prototype,"heightMeasurementPixels",void 0),e([S()],yt.prototype,"heightGraphic",void 0),e([S()],yt.prototype,"heightMeasurementResult",void 0),e([S()],yt.prototype,"heightMeasurementAccuracy",void 0),e([S()],yt.prototype,"measurementAngle",void 0),e([S()],yt.prototype,"tempDistance",void 0),e([S({readOnly:!0})],yt.prototype,"imageGalleryEnabled",null),e([S()],yt.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],yt.prototype,"imageLoaded",null),e([S()],yt.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],yt.prototype,"invalidCameraHeading",null),e([S()],yt.prototype,"imagePointsInView",null),e([S()],yt.prototype,"isAdditionalCoverageVisible",void 0),e([S()],yt.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],yt.prototype,"layer",void 0),e([S()],yt.prototype,"layerView",null),e([S({readOnly:!0})],yt.prototype,"layerFloorFilterClause",null),e([S({type:Number})],yt.prototype,"localPort",void 0),e([S()],yt.prototype,"mapImageConversionToolState",void 0),e([S()],yt.prototype,"measureType",void 0),e([S()],yt.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],yt.prototype,"mode",null),e([S()],yt.prototype,"navigatorCurrentBestFeature",void 0),e([S()],yt.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],yt.prototype,"overlayedCameraLocations",void 0),e([S()],yt.prototype,"overlayedMapFeatures",void 0),e([S()],yt.prototype,"pixelCoordinates",void 0),e([S()],yt.prototype,"pointSources",void 0),e([S({readOnly:!0})],yt.prototype,"popupEnabled",null),e([S()],yt.prototype,"previousFeatureAngle",void 0),e([S()],yt.prototype,"referencePoint",null),e([S({readOnly:!0})],yt.prototype,"sectorData",null),e([S()],yt.prototype,"selectedPoint",void 0),e([S({type:Number})],yt.prototype,"sharpness",null),e([S()],yt.prototype,"shouldShowSelectedImage",void 0),e([S()],yt.prototype,"sketch",void 0),e([S()],yt.prototype,"draw",void 0),e([S()],yt.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],yt.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],yt.prototype,"state",null),e([S({readOnly:!0})],yt.prototype,"thumbnails",null),e([S()],yt.prototype,"updateFootprint",void 0),e([S()],yt.prototype,"updateFootprintPanorama",void 0),e([S({value:null})],yt.prototype,"view",null),e([S()],yt.prototype,"_adapter",void 0),e([S()],yt.prototype,"_sketchGraphicsLayer",null),e([S()],yt.prototype,"_highlightedFeatureHandle",void 0),e([S()],yt.prototype,"_imageViewer",void 0),e([S()],yt.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],yt.prototype,"_locationPointOnImage",void 0),e([S()],yt.prototype,"_overlays",void 0),e([S({readOnly:!0})],yt.prototype,"_overlaysView",null),e([S()],yt.prototype,"_panoramicViewer",void 0),e([S()],yt.prototype,"_previousCursor",void 0),e([S()],yt.prototype,"_referencePointOnGround",void 0),e([S()],yt.prototype,"_referencePointOnImage",void 0),e([S()],yt.prototype,"_sectorData",void 0),e([S({readOnly:!0})],yt.prototype,"_updatingHandles",void 0),e([S()],yt.prototype,"footprintExtent",void 0),e([S()],yt.prototype,"_featureChangedTask",void 0),yt=e([C("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],yt);const ft=yt;export{ft 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 o}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import{substitute as r}from"../../../intl/substitute.js";import s from"../../Widget.js";import{css as n}from"../css.js";import{copyToClipboard as i}from"../imageMeasurementUtils.js";import{loadCalciteComponents as c}from"../../support/componentsUtils.js";import{tsx as a}from"../../support/jsxFactory.js";let p=class extends s{constructor(o){super(o),this.messages=null}loadDependencies(){return c({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel")})}get _renderLocation(){const{groundCoordinates:o}=this;return o?a("calcite-block",{heading:this.getLocation(),headingLevel:6},a("calcite-action",{icon:"copy-to-clipboard",onclick:()=>this.copyLocation(),slot:"control",text:"Copy"})):null}copyLocation(){const{groundCoordinates:o}=this;if(!o)return;const t=this.getLocation();t&&i(t)}getLocation(){const{groundCoordinates:o}=this;if(null==o?.longitude||null==o?.latitude)return"";const t={groundX:o.longitude.toFixed(3),groundY:o.latitude.toFixed(3)};return r("{groundX}° , {groundY}°",t)}render(){return a("calcite-panel",{class:n.measurementResults,key:"ground-location-container"},this._renderLocation)}};o([t()],p.prototype,"messages",void 0),o([t()],p.prototype,"groundCoordinates",void 0),o([t()],p.prototype,"_renderLocation",null),p=o([e("esri.widgets.OrientedImageryViewer.components.ImageLocationWidget")],p);const l=p;export{l as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{substitute as o}from"../../../intl/substitute.js";import a from"../../Widget.js";import{css as n}from"../css.js";import{copyToClipboard as l}from"../imageMeasurementUtils.js";import{loadCalciteComponents as i}from"../../support/componentsUtils.js";import{tsx as r}from"../../support/jsxFactory.js";let s=class extends a{constructor(e){super(e),this.messages=null,this.accuracy=null,this._selectedSystem="Basemap",this._handleSystemSelection=e=>{this._selectedSystem=e.target.value}}loadDependencies(){return i({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),select:()=>import("@esri/calcite-components/dist/components/calcite-select"),option:()=>import("@esri/calcite-components/dist/components/calcite-option"),table:()=>import("@esri/calcite-components/dist/components/calcite-table"),"table-row":()=>import("@esri/calcite-components/dist/components/calcite-table-row"),"table-header":()=>import("@esri/calcite-components/dist/components/calcite-table-header"),"table-cell":()=>import("@esri/calcite-components/dist/components/calcite-table-cell")})}get _renderLocationBlock(){const{groundCoordinates:e,_selectedSystem:t}=this;return e&&"XY"===t?r("calcite-block",{heading:this.getLocation(),headingLevel:6}):null}get _renderLocationTable(){const{groundCoordinates:e,messages:t,_selectedSystem:c,accuracy:o}=this,a={groundX:e.x.toFixed(3),accuracyX:o?.x?o.x.toFixed(3):"",groundY:e.y.toFixed(3),accuracyY:o?.y?o.y.toFixed(3):"",groundZ:e.z?e.z.toFixed(3):"",accuracyZ:o?.z?o.z.toFixed(3):""};return e&&"Basemap"===c?r("calcite-table",{bordered:!0,caption:t.measurementTable,class:n.measurementsTable,scale:"s"},r("calcite-table-row",{slot:"table-header"},r("calcite-table-header",{alignment:"center",heading:t.type}),r("calcite-table-header",{alignment:"center",heading:t.value}),r("calcite-table-header",{alignment:"center",heading:t.accuracy})),r("calcite-table-row",null,r("calcite-table-cell",{alignment:"center"},t.x),r("calcite-table-cell",{alignment:"center"},a.groundX),r("calcite-table-cell",{alignment:"center"},a.accuracyX)),r("calcite-table-row",null,r("calcite-table-cell",{alignment:"center"},t.y),r("calcite-table-cell",{alignment:"center"},a.groundY),r("calcite-table-cell",{alignment:"center"},a.accuracyY)),r("calcite-table-row",null,r("calcite-table-cell",{alignment:"center"},t.z),r("calcite-table-cell",{alignment:"center"},a.groundZ),r("calcite-table-cell",{alignment:"center"},a.accuracyZ))):null}get _renderSystemSelect(){const{messages:e}=this;return r("div",{class:n.measurementsBar},r("calcite-select",{bind:this,label:e.selectUnitSystem,scale:"m",width:"full",onCalciteSelectChange:this._handleSystemSelection},r("calcite-option",{value:"Basemap"},e.basemap),r("calcite-option",{value:"XY"},e.xy)),r("calcite-action",{icon:"copy-to-clipboard",onclick:()=>this.copyLocation(),scale:"s",slot:"control",text:"Copy"}))}copyLocation(){const{groundCoordinates:e}=this;if(!e)return;const t=this.getLocation();t&&l(t)}getLocation(){const{_selectedSystem:e,groundCoordinates:t,accuracy:c}=this;return"Basemap"===e?this.getBasemapLocation(t,c):this.getXYLocation(t)}getXYLocation(e){if(null==e?.longitude||null==e?.latitude)return"";const t={groundX:e.longitude.toFixed(3),groundY:e.latitude.toFixed(3)};return o("{groundX}° , {groundY}°",t)}getBasemapLocation(e,t){if(null==e?.x||null==e?.y)return"";const c={groundX:e.x.toFixed(3),accuracyX:t?.x?t.x.toFixed(3):0,groundY:e.y.toFixed(3),accuracyY:t?.y?t.y.toFixed(3):0,groundZ:e.z?e.z.toFixed(3):0,accuracyZ:t?.z?t.z.toFixed(3):0};return o("{groundX} ± {accuracyX}, {groundY} ± {accuracyY}, {groundZ} ± {accuracyZ}",c)}render(){return r("calcite-panel",{class:n.measurementResults,key:"ground-location-container"},this._renderSystemSelect,this._renderLocationBlock,this._renderLocationTable)}};e([t()],s.prototype,"messages",void 0),e([t()],s.prototype,"groundCoordinates",void 0),e([t()],s.prototype,"accuracy",void 0),e([t()],s.prototype,"_selectedSystem",void 0),e([t()],s.prototype,"_renderLocationBlock",null),e([t()],s.prototype,"_renderLocationTable",null),e([t()],s.prototype,"_renderSystemSelect",null),s=e([c("esri.widgets.OrientedImageryViewer.components.ImageLocationWidget")],s);const d=s;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{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};
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 l,geodesicArea as f}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 g}from"../../geometry/projection.js";import x from"../../geometry/SpatialReference.js";import{isSupported as w,geodesicLengths as d,geodesicAreas as v}from"../../geometry/support/geodesicUtils.js";import{imageToWorld as R,imageToWorldPanoramic as z}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=d([e],"meters")[0];return{area:v([r],"square-meters")[0],perimeter:t}}const n=x.WGS84,a=g(e,n),o=g(r,n);let c=i(o,E);if(c=s(c),!c)return null;const u=d([a],"meters")[0];return{area:v([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=Q(n,e);if(!s)return null;const c=r.map((t=>[t.x,t.y])),u=c.at(0),l=c.at(-1);if(!u||!l)return null;const f=s.map((t=>tt([u,l],t,e,o,!1))),m=await Promise.all(f);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=X(n,e),u=r.map((t=>[t.x,t.y])),l=u.at(0),f=u.at(-1),m=c.map((t=>et([l,f],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=K(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 d([t],"meters")[0];const r=g(t,x.WGS84);return d([r],"meters")[0]}return e.isWebMercator?c(t,"meters"):u(t,"meters")}function U(t){if(!t?.length)throw new Error("Invalid deviations array");const[e,r,n]=[0,1,2].map((e=>t.map((t=>t[e])).filter((t=>null!==t)))).map((t=>t.length?$(t):0));return[e,r,n]}function F(t,e){const r=s(e);if(!r)return null;const n=u(t,"meters");return{area:l(r,"square-meters"),perimeter:n}}function S(t,e){let r=i(e,E,"meters");if(r=s(r),!r)return null;const n=c(t,"meters");return{area:f(r,"square-meters"),perimeter:n}}async function T(e,r,n){if(!r||!e)throw new Error("Missing required parameters");const a=await R(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,...l}=r;return P(o,l)}async function H(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,x.WebMercator));const l=await z(e,{...c,cameraLocation:u},s);t(a);const f=l.clone();return f.z?f.z+=20:f.z=20,j(f,c)}function O(t,e,r,n,a=0,i=1,s){const{averageElevation:c,cameraPitch:u,cameraRoll:l,farDistance:f,...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),g=o([r[0].x,r[0].y],[h.x,h.y]),x=r.at(0),w=r.at(-1);if(!x||!w)return null;const d=o([x.x,x.y],[w.x,w.y])*t/g;return O(d,e,r,n,a+1,Math.abs(t-d))}function V(t,e,r,n,a=0,i=1,s){const{averageElevation:c,horizontalFieldOfView:u,verticalFieldOfView:l,farDistance:f,...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),g=o([r[0].x,r[0].y],[h.x,h.y]),x=r.at(0),w=r.at(-1);if(!x||!w)return null;const d=o([x.x,x.y],[w.x,w.y])*t/g;return V(d,e,r,n,a+1,Math.abs(t-d))}async function A(t,e){const{updateElevationProps:r,...n}=e;return await R(t,n,r)}async function B(t,e){const{updateElevationProps:r,...n}=e;return z(t,n,r)}function C(t){navigator.clipboard.writeText(t).catch((t=>{throw t}))}function J(t){const e=t.map((t=>[t.x,t.y])),r=t[0].spatialReference;return new y({paths:[e],spatialReference:r})}function K(t,e){return t.map((t=>({x:e?.5+t[0]:t[0],y:e?.5-t[1]:t[1]})))}function N(t,r,a,o,i){const s="measurement"===t?r:a;if(i&&s)return e(o,n(s,"meters"),i,3)||null}function Q(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,l,,f,p]=e,y=[-f,0,f],h=[-p,0,p],g=[-u,0,u],x=[-l,0,l],w=[];for(const d of y)for(const e of h)for(const a of g)for(const u of g)for(const l of x){const f={...t};f.cameraPitch=r+d,f.cameraRoll=n+e,f.cameraLocation=new m({x:o+a,y:i+u,z:s?s+l:0,spatialReference:{wkid:c.wkid}}),w.push(f)}return w}function X(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,l]=e,f=l>0?[-l,0,l]:[],p=c>0?[-c,0,c]:[],y=u>0?[-u,0,u]:[],h=[];for(const g of f)for(const e of p)for(const n of p)for(const c of y){const u={...t};u.cameraHeading=r+g,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 Y(t,r,a,o,i){const s="measurement"===t?r:$(a);if(i&&s)return e(o,n(s,"meters"),i,3)||null}function Z(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 $(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 tt(e,r,n,a=!1,i=!1,s){if(!e||!r||e.length<2)return null;const c=K(e,a);if(!c||c.length<2)return null;const[u,l]=[c[0],c.at(-1)];if(!l)return null;const f=[u],m=await R(u,r);t(s);const p=m.clone();p.z?p.z+=20:p.z=20;const{averageElevation:y,cameraPitch:h,cameraRoll:g,farDistance:x,...w}=r,d=P(p,w),v=o([u.x,u.y],[d.x,d.y]),z=b(u,d);if(!z)return;const M=q([u.x,u.y],[l.x,l.y],z);if(!M?.length)return;f.push({x:M[0],y:M[1]});const j=20*o([f[0].x,f[0].y],[f[1].x,f[1].y])/v;if(!i)return j;const E=O(j,m,f,r,0,1);return E?.value}async function et(e,r,n,a,i=!1,s=!1,c){const{attributes:u}=a,{location:l}=u,{updateElevationProps:f,...m}=r;if(!e||!r||e.length<2)throw new Error("Invalid parameters");const p=K(e,i),[y,g]=[p[0],p.at(-1)],w=[y];let d=l.clone();d.spatialReference.isGeographic&&(d=await h(d,x.WebMercator));const v=await z(y,{...m,cameraLocation:d},f);t(c);const R=v.clone();R.z?R.z+=20:R.z=20;const M=j(R,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],[g.x,g.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=V(L,v,w,r,0,1);return W?.value}async function rt(t,e,r=!1){if(t.length<3)return null;const n=K(t,r),a=await A(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?S(s,c):F(s,c)}async function nt(e,r,n=!1,a){if(e.length<3)return null;const o=K(e,n),i=await B(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}),l=new p({rings:[s],spatialReference:c});return c.isGeographic?L(c,u,l):c.isWebMercator?S(u,l):F(u,l)}async function at(t,e,r=!1){const n=K(t,r);return D(J(await A(n,e)))}async function ot(e,r,n=!1,a){const o=K(e,n),i=await B(o,r);t(a);return D(J(i))}export{b as calculateAngle,I as calculateAnglePano,q as calculateCorrectedPixel,W as calculateHeightAccuracy,G as calculateHeightAccuracyPanoramic,k as calculateHeightFromTemporaryDistance,U as calculateLocationAccuracyFromDeviations,H as calculateReferenceImagePointPanoramic,T as calculateTempImagePoint,O as computeHeightIteratively,V as computeHeightIterativelyPanoramic,C as copyToClipboard,K as formatPixels,Q as generateCombinations,X as generateCombinationsPanoramic,Z as getConvertedArea,Y as getConvertedDistance,N as getConvertedHeight,_ as getModeCorrectedPoint,$ as getRootOfSumOfSquaredErrors,tt as heightMeasurement2D,et as heightMeasurementPanoramic,rt as pixelAreaMeasurement2D,nt as pixelAreaMeasurementPanoramic,at as pixelDistanceMeasurement2D,ot as pixelDistanceMeasurementPanoramic};
@@ -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"../intl.js";import{prefersReducedMotion as t}from"../core/a11yUtils.js";import{createTask as i}from"../core/asyncUtils.js";import a from"../core/Collection.js";import{deprecatedProperty as s}from"../core/deprecate.js";import o from"../core/Logger.js";import{isAbortError as r}from"../core/promiseUtils.js";import n from"../core/ReactiveMap.js";import{watch as l,initial as c,syncAndInitial as d,whenOnce as g}from"../core/reactiveUtils.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import{or as p}from"../layers/orientedImagery/transformations/utils.js";import u from"./Widget.js";import{getAllArcPath as v}from"./OrientedImageryViewer/arcUtils.js";import{defaultImageGeometryField as y,defaultOIObjectIDField as _,segmentArcs as w,sectorsRadii as b,featureCircleRadius as C,navigationToolDimensionLength as M,getDelegatedEvents as T}from"./OrientedImageryViewer/constants.js";import{css as f,navigation as I,navigationToolRotationFrom as L,navigationToolRotationTo as A,root as k}from"./OrientedImageryViewer/css.js";import{isFeatureAttachment as O,loadImageForAttachment as F,getThumbnailPixelBlock as S,renderImageWithRotation as E}from"./OrientedImageryViewer/galleryUtils.js";import V from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import P from"./OrientedImageryViewer/OrientedImageryViewerVisibleElements.js";import x from"./OrientedImageryViewer/components/ImageLocationWidget.js";import{loadCalciteComponents as G}from"./support/componentsUtils.js";import{globalCss as j}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as $}from"./support/decorators/messageBundle.js";import{vmEvent as D}from"./support/decorators/vmEvent.js";import{tsx as H}from"./support/jsxFactory.js";import{substitute as B}from"../intl/substitute.js";const R={overlayMapFeatures:"overlay-map-features",overlayed:"overlayed",overlaysActionHandles:"overlays-action-handles"};let W=class extends u{constructor(e,t){super(e,t),this.dataCaptureEnabled=!1,this.galleryOpened=!1,this.imageEnhancementToolActive=!1,this.imageOverlaysOpened=!1,this.navigationToolActive=!1,this.viewModel=new V,this.messagesCommon=null,this.messagesSketch=null,this.pixelMeasurementUnit="meters",this.pixelAreaMeasurementUnit="square-meters",this.showCameraLocations=!1,this.showMapFeatures=!1,this.visibleElements=new P,this._actionItems=new n,this._imageOverlaysLoaderTask=null,this._imageMeasurementToolsLoaderTask=null,this._clearMeasurements=()=>{this.viewModel.measureType=null,this.viewModel.clearPreviousMeasurements()},this._clearImageLocation=()=>{this.imageLocationToolActive=!1},this._navigationToolExpanded=!1,this._navigationTool=null,this._warningTitleElement=null,this._galleryController=new AbortController,this._galleryObserver=new IntersectionObserver(this._lazyLoadImage.bind(this)),this._overlayedLayers=new a,this._previousAction=null,this._handleDataCaptureLayerChange=async e=>{if(this.dataCaptureLayer&&await this.stopDataCapture(!0),this.dataCaptureLayer=this.dataCaptureLayer===e?null:e,this.dataCaptureLayer)return this.startDataCapture(this.dataCaptureLayer)},this._handleOverlayLayerDeselect=e=>{const t=e.layer;t===this.dataCaptureLayer&&(this.stopDataCapture(),this.dataCaptureLayer=null),this.removeOverlayedGraphicsOnImage(`${t.id}`)},this._handleOverlayLayerSelect=e=>{const t=e.layer;this.viewModel.overlayMapFeatures(t,this.showMapFeatures),this.addHandles(l((()=>t.visible),(()=>{this.viewModel.toggleOverlayMapFeatures(t.id,t.visible)})),`${R.overlayed}-${t.id}`)},this._highlight=e=>{const t=e.target?.dataset.objectid;t&&this.viewModel.highlight(t)},this._onAction=e=>{const{target:t}=e,{dataset:{action:i}}=t,{_previousAction:a}=this,s=a?.dataset.action,o=s?.includes("draw")??!1,r="select-feature"===s,n=s!==i;switch(i){case"draw-point":case"draw-polygon":case"draw-polyline":{a&&p(r,o&&n)&&(a.active=!1),t.active=!t.active;const e=i.replace("draw-","");this.viewModel.digitizeCreate(e),this._previousAction=t.active?t:null;break}case"save":this.viewModel.saveDrawing();break;case"select-feature":o&&(this._previousAction.active=!1),t.active=!t.active,this.viewModel.toggleSelection(t.active),this._previousAction=t.active?t:null;break;case"delete-feature":this.viewModel.digitizeDelete()}},this._onImageOverlayClosed=()=>{this.imageOverlaysOpened=!1},this._onShowCameraLocationsChanged=e=>{this.showCameraLocations=e},this._onShowMapFeaturesChanged=e=>{this.showMapFeatures=e},this._removeActionElement=e=>{this._actionItems.delete(e.text)},this._removeHighlight=()=>this.viewModel.removeHighlight(),this._restoreOverlays=async()=>Promise.all(this._overlayedLayers.map((e=>this.viewModel.overlayMapFeatures(e,this.showMapFeatures)))),this._scaleNavigationTool=()=>{this._navigationToolExpanded=!this._navigationToolExpanded},this._sketchLoaderTask=null,this._toggleImageAttributes=()=>{this.viewModel.toggleImageAttributes()},this._loadImageFromGallery=this._loadImageFromGallery.bind(this),this._registerGalleryItem=this._registerGalleryItem.bind(this),this._unregisterGalleryItem=this._unregisterGalleryItem.bind(this),this.loadImageFromSource=this.loadImageFromSource.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this)}initialize(){this.addHandles([l((()=>[this.viewModel?.bestFeatureAngle,this._navigationTool]),(([e,t])=>{t&&this._updateNavigationTool(t)}),c),l((()=>this.currentCoverageVisible),(e=>this._onCurrentCoverageVisibilityChange(e))),l((()=>this.isAdditionalCoverageVisible),(e=>this._onAdditionalCoverageVisibilityChange(e))),l((()=>this.isAdditionalPointSourcesVisible),(e=>this._onAdditionalCameraLocationsVisibility(e))),l((()=>({features:this.currentBestFeature,showCameraLocations:this.showCameraLocations,state:this.viewModel.state})),(({showCameraLocations:e,state:t})=>{"image-loaded"===t&&this.viewModel.overlayCameraLocations(e)}),d),l((()=>({feature:this.currentBestFeature,showMapFeatures:this.showMapFeatures,state:this.viewModel.state})),(async(e,t)=>{if(e.showMapFeatures!==t?.showMapFeatures&&this.viewModel.toggleAllOverlayMapFeatures(e.showMapFeatures),null!=e.feature&&e.feature!==t?.feature){if(this.viewModel.removeAllOverlayMapFeatures(),await g((()=>"image-loaded"===this.viewModel.state)),this.dataCaptureLayer&&this.stopDataCapture(),await this._restoreOverlays(),!this.dataCaptureLayer)return;await this.startDataCapture(this.dataCaptureLayer),this._previousAction?.active&&(this._previousAction.active=!1,this._previousAction=null)}}),c)])}loadDependencies(){return G({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),shell:()=>import("@esri/calcite-components/dist/components/calcite-shell"),dialog:()=>import("@esri/calcite-components/dist/components/calcite-dialog"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this._galleryController.abort(),this._galleryObserver.disconnect()}get accuracyParametersMissing(){return this.viewModel.accuracyParametersMissing}get activeLayer(){return s(o.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){s(o.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get currentBestFeature(){return this.viewModel.currentBestFeature}set currentBestFeature(e){this.viewModel.currentBestFeature=e}get currentCoverageVisible(){return this.viewModel.currentCoverageVisible}set currentCoverageVisible(e){this.viewModel.currentCoverageVisible=e}get dataCaptureLayer(){return this.viewModel.dataCaptureLayer}set dataCaptureLayer(e){this.viewModel.dataCaptureLayer=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get displayMessage(){return this.viewModel.displayMessage}get features(){return this.viewModel.features}get imagePointsInView(){return this.viewModel.imagePointsInView}get icon(){return"oriented-imagery-widget"}set icon(e){this._overrideIfSome("icon",e)}get imageGalleryEnabled(){return this.viewModel.imageGalleryEnabled}get imageLocationToolActive(){return this.viewModel.imageLocationToolState}set imageLocationToolActive(e){this.viewModel.imageLocationToolState=e}get invalidCameraHeading(){return this.viewModel.invalidCameraHeading}get isAdditionalCoverageVisible(){return this.viewModel.isAdditionalCoverageVisible}set isAdditionalCoverageVisible(e){this.viewModel.isAdditionalCoverageVisible=e}get isAdditionalPointSourcesVisible(){return this.viewModel.isAdditionalPointSourcesVisible}set isAdditionalPointSourcesVisible(e){this.viewModel.isAdditionalPointSourcesVisible=e}get mapImageConversionToolState(){return this.viewModel.mapImageConversionToolState}set mapImageConversionToolState(e){this.viewModel.mapImageConversionToolState=e}get measureType(){return this.viewModel.measureType}set measureType(e){this.viewModel.measureType=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get popupEnabled(){const{popupEnabled:e,state:t}=this.viewModel;return"image-loaded"===t&&e}get referencePoint(){return this.viewModel.referencePoint??null}get sketchViewModel(){return this.viewModel.sketch}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set determineWorkflowForFeature(e){this.viewModel.determineWorkflowForFeature=e}get determineWorkflowForFeature(){return this.viewModel.determineWorkflowForFeature}set updateFootprint(e){this.viewModel.updateFootprint=e}get updateFootprint(){return this.viewModel.updateFootprint}_renderActionBar(){return H("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},H("calcite-action-group",null,this._currentFootprintToggle(),this._additionalFootprintToggle(),this._additionalPointSourcesToggle()),H("calcite-action-group",null,this._mapImageConversionToggle(),this._navigationToolToggle(),this._imageEnhancementsToggle()),H("calcite-action-group",null,this._measurementToolsToggle(),this._imageGalleryToggle(),this._imageOverlaysToggle(),this._openPopupAction()),this._actionTooltips())}_actionTooltips(){return[...this._actionItems].map((([e,t])=>H("calcite-tooltip",{closeOnClick:!0,key:e,placement:"bottom",referenceElement:t},H("span",null,e))))}get _activeMeasurementIcon(){const{measureType:e,imageLocationToolActive:t}=this;if(t)return"pin-tear";switch(e){case"area":return"measure-area";case"height":return"measure-building-height-top-base";default:return"measure-line"}}get _activeMeasurementHeading(){const{measureType:e,messages:t}=this,{groundArea:i,heightAboveGround:a,groundDistance:s}=t;switch(e){case"area":return i;case"height":return a;default:return s}}_additionalFootprintToggle(){const{isAdditionalCoverageVisible:e,invalidCameraHeading:t,visibleElements:{additionalFootprintToggle:i}}=this;return i?H("calcite-action",{active:e,...this._commonActionProperties,class:f.addCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleAdditionalCoverage,text:this.messages.additionalFootprints}):null}_additionalPointSourcesToggle(){const{isAdditionalPointSourcesVisible:e,invalidCameraHeading:t,visibleElements:{additionalCameraLocationsToggle:i}}=this;return i?H("calcite-action",{active:e,...this._commonActionProperties,class:f.addExpPoints,disabled:t,icon:"circle-area",onclick:this._toggleAdditionalCameraLocations,text:this.messages.additionalCameraLocations}):null}get _measurementToggle(){const{viewModel:{state:e,measureType:t},id:i}=this;if("image-loaded"!==e||!t)return;this._imageMeasurementToolsLoaderTask||this._loadImageMeasurementResources();const a=this._imageMeasurementToolsLoaderTask?.value;return a?H("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:this._activeMeasurementHeading,id:`${i}-${t}-measurement`,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearMeasurements},H(a,{measurementType:t,measurementUnitMessages:this.measurementUnitMessages,messages:this.messages,oiViewModel:this.viewModel})):null}get _commonActionProperties(){return{afterCreate:this._storeActionElement,afterRemoved:this._removeActionElement,afterUpdate:this._storeActionElement,bind:this}}_renderRoot(){const{viewModel:{state:e}}=this;return H("calcite-panel",null,H("calcite-shell",null,H("calcite-panel",{bind:this,class:f.viewerContainer,heading:this.visibleElements.title?this.messages.title:void 0,loading:e.includes("loading")},this.visibleElements.menu?this._renderActionBar():null,this._imageViewer,this._panoramicViewer,this._messageBox,this.invalidCameraHeading?[this._renderWarning(this.messages.invalidCameraHeadingWarningTitle),this._renderWarningTooltip(this.messages.invalidCameraHeadingWarningDescription)]:[this._imageGalleryPanel,this._renderNavigation,this._imageOverlaysPanel()],this._imageEnhancementTools,this._renderSketch()),this._measurementToggle,this._locationToggle))}_currentFootprintToggle(){const{currentCoverageVisible:e,invalidCameraHeading:t}=this,{currentFootprintToggle:i}=this.visibleElements;return i?H("calcite-action",{active:e,...this._commonActionProperties,class:f.currentCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleCurrentCoverage,text:this.messages.currentFootprint}):null}get _imageEnhancementTools(){const{imageEnhancementToolActive:e,viewModel:{brightness:t,contrast:i,sharpness:a,state:s}}=this;return e&&"image-loaded"===s?H("calcite-panel",{bind:this,class:f.imageEnhancementWrapper,closable:!0,closed:!e,heading:this.messages.imageEnhancement,key:this.messages.imageEnhancement,onCalcitePanelClose:this._toggleImageEnhancementToolState},H("div",{class:f.imageEnhancementTools},H("div",{class:f.imageEnhancementToolContainer},H("calcite-label",null,this.messages.brightness,H("calcite-slider",{bind:this,labelTicks:!0,max:10,min:-10,ticks:5,value:t,onCalciteSliderInput:this._handleBrightnessChange}))),H("div",{class:f.imageEnhancementToolContainer},H("calcite-label",null,this.messages.contrast,H("calcite-slider",{bind:this,labelTicks:!0,max:10,min:-10,ticks:5,value:i,onCalciteSliderInput:this._handleContrastChange}))),H("div",{class:f.imageEnhancementToolContainer},H("calcite-label",null,this.messages.sharpness,H("calcite-slider",{bind:this,labelTicks:!0,max:1,min:0,step:.1,ticks:.5,value:a,onCalciteSliderInput:this._handleSharpnessChange})))),H("calcite-action",{bind:this,icon:"reset",onclick:this._resetImageTools,slot:"header-actions-end",text:this.messagesCommon.reset})):null}_imageEnhancementsToggle(){const{state:e,mode:t}=this.viewModel,{imageEnhancement:i}=this.visibleElements;return i?H("calcite-action",{active:this.imageEnhancementToolActive,...this._commonActionProperties,disabled:"default"!==t||"image-loaded"!==e,icon:"sliders-horizontal",onclick:this._toggleImageEnhancementToolState,text:this.messages.imageEnhancement}):null}get _imageGalleryPanel(){const{container:e,galleryOpened:t,imageGalleryEnabled:i}=this;return i&&t&&e?this._imageGalleryContext:null}get _imageGalleryContext(){const{galleryOpened:e,invalidCameraHeading:t}=this;return H("calcite-panel",{bind:this,class:f.carousel,closable:!0,closed:!e,disabled:t,heading:this.messages.imageGallery,key:this.messages.imageGallery,onCalcitePanelClose:this._toggleImageGallery},H("div",{class:f.carouselContainer},this._renderThumbnails))}_imageGalleryToggle(){const{imageGalleryEnabled:e,invalidCameraHeading:t,visibleElements:{imageGallery:i}}=this;return i?H("calcite-action",{active:this.galleryOpened,...this._commonActionProperties,disabled:!e||t,icon:"images",onclick:this._toggleImageGallery,text:this.messages.imageGallery}):null}get _imageOverlaysComponent(){const{_imageOverlayMessages:e,_imageOverlaysLoaderTask:t,_overlayedLayers:a,dataCaptureEnabled:s,dataCaptureLayer:o,imageOverlaysOpened:r,showCameraLocations:n,showMapFeatures:l,view:c,layer:d}=this;if(!d)return null;const g=d.imageGeometryField?.length?d.imageGeometryField:y,m=d.imageReferenceField?.length?d.imageReferenceField:_;t||(this._imageOverlaysLoaderTask=i((async()=>(await import("./OrientedImageryViewer/components/ImageOverlays.js")).default)));const h=this._imageOverlaysLoaderTask?.value;return h?H(h,{closed:!r,dataCaptureEnabled:s,dataCaptureLayer:o,imageGeometryField:g,imageReferenceField:m,messages:e,overlayedLayers:a,showCameraLocations:n,showMapFeatures:l,view:c,onDataCaptureLayerChanged:this._handleDataCaptureLayerChange,onImageOverlaysClosed:this._onImageOverlayClosed,onLayerDeselected:this._handleOverlayLayerDeselect,onLayerSelected:this._handleOverlayLayerSelect,onShowCameraLocationsChanged:this._onShowCameraLocationsChanged,onShowMapFeaturesChanged:this._onShowMapFeaturesChanged}):null}get _imageOverlayMessages(){return{...this.messages,...this.messagesSketch}}get _imageSketchToolsMessages(){return{...this.messagesSketch,...this.messagesCommon}}_imageOverlaysPanel(){const{imageOverlaysOpened:e,viewModel:{state:t}}=this,i=this.classes({[f.imageOverlaysContainer]:!0,[j.hidden]:!e||"image-loaded"!==t});return H("div",{class:i,key:this.messages.imageOverlays},this._imageOverlaysComponent)}_imageOverlaysToggle(){const{viewModel:{state:e},imageOverlaysOpened:t,invalidCameraHeading:i,visibleElements:{imageOverlays:a}}=this;return a?H("calcite-action",{active:t,...this._commonActionProperties,disabled:"image-loaded"!==e||i,icon:"layers",onclick:this._toggleImageOverlays,text:this.messages.imageOverlays}):null}get _imageViewer(){const{displayMessage:e,loadImageViewer:t,mode:i}=this.viewModel,a=null!=e||"default"!==i,s=this.classes({[f.viewer]:!a,[f.viewerHidden]:a});return H("calcite-panel",{afterCreate:t,bind:this,class:s},this._renderSketch())}get _locationToggle(){const{viewModel:{state:e,groundCoordinates:t},imageLocationToolActive:i,messages:{groundLocation:a}}=this;if("image-loaded"===e&&t&&i)return H("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:a,id:a,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearImageLocation},H(x,{groundCoordinates:t,messages:this.messages}))}_mapImageConversionToggle(){const{mapImageConversionToolState:e,viewModel:{state:t},invalidCameraHeading:i,visibleElements:{mapImageConversionTool:a}}=this;return a?H("calcite-action",{active:e,...this._commonActionProperties,disabled:"image-loaded"!==t||i,icon:"image-pin",onclick:this._toggleMapImageConversionToolState,text:this.messages.mapImageConversionTool}):null}_measurementToolsToggle(){const{_activeMeasurementIcon:e,measureType:t,viewModel:i,accuracyParametersMissing:a,messages:s,visibleElements:{measurementTools:o}}=this,{state:r}=i,{measurementTools:n,groundDistance:l,groundArea:c,heightAboveGround:d,groundLocation:g}=s;return o?H("calcite-dropdown",{disabled:a,key:"measurement-tools",width:"m"},H("calcite-action",{...this._commonActionProperties,disabled:"image-loaded"!==r||a,icon:e,slot:"trigger",text:n}),H("calcite-dropdown-group",null,H("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-line",key:"distance-measurement",onclick:e=>this._toggleMeasurementSketch(e,"distance"),selected:"distance"===t},l),H("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-area",key:"area-measurement",onclick:e=>this._toggleMeasurementSketch(e,"area"),selected:"area"===t},c),H("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-building-height-top-base",key:"height-dropdown",onclick:e=>this._toggleMeasurementSketch(e,"height"),selected:"height"===t},d),H("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"pin-tear",key:"surface-location",onclick:e=>this._toggleLocationTool(e),selected:this.imageLocationToolActive},g))):null}get _messageBox(){const{messages:e,viewModel:{displayMessage:t}}=this;if(!t)return null;const{data:i,key:a,map:s}=t,o=`${s?B(e[a],s):e[a]}`;return H("span",{class:f.messageBox},i?`${o} ${i}`:o)}_navigationToolToggle(){const{state:e}=this.viewModel,{visibleElements:{navigationTool:t}}=this;return t?H("calcite-action",{active:this.navigationToolActive,...this._commonActionProperties,disabled:"image-loaded"!==e||this.invalidCameraHeading,icon:"explore",onclick:this._toggleNavigationTool,text:this.messages.navigationTool}):null}_openPopupAction(){const{showPopupsAction:e}=this.visibleElements;return e?H("calcite-action",{...this._commonActionProperties,disabled:!this.popupEnabled,icon:"popup",onclick:this._toggleImageAttributes,text:this.messages.showPopups}):null}get _panoramicViewer(){const{displayMessage:e,loadPanoramicViewer:t,mode:i}=this.viewModel,a=null!=e||"panoramic"!==i,s=this.classes({[f.viewer]:!a,[f.viewerHidden]:a});return H("calcite-panel",{afterCreate:t,bind:this,class:s})}_closeAllImageTools(){this.imageEnhancementToolActive=!1,this.navigationToolActive=!1,this.imageOverlaysOpened=!1,this.galleryOpened=!1,this.measureType=null,this.imageLocationToolActive=!1}_handleBrightnessChange(e){this.viewModel.brightness=e.currentTarget.value??0}_handleContrastChange(e){this.viewModel.contrast=e.currentTarget.value??0}_handleSharpnessChange(e){this.viewModel.sharpness=e.currentTarget.value??0}_lazyLoadImage(e,t){e.forEach((async e=>{if(e.isIntersecting){const a=e.target,s=a.getAttribute("data-src"),n=a.getAttribute("data-rotation"),l=a.getAttribute("data-objectid"),c=n?parseFloat(n)%360:0,{layer:d,_galleryController:{signal:g}}=this;if(!s||!l)return;let m;try{m=O(s)?await F(d,l,{signal:g}):await S(s,{signal:g})}catch(i){r(i)||o.getLogger("esri.widgets.OrientedImageryViewer").error("#lazyLoadImage()",i)}finally{t.unobserve(a)}if(!m)return;E(m,a,c)}}))}_loadImageFromGallery(e){const{target:t}=e;if(!t)return;const i=t.getAttribute("data-objectid");i&&this.viewModel.currentBestFeature?.attributes.objectId!==Number(i)&&this.viewModel.selectBestFeature(i)}_loadImageMeasurementResources(){this._imageMeasurementToolsLoaderTask=i((async()=>{const{default:e}=await import("./OrientedImageryViewer/components/ImageMeasurementWidget.js");return e}))}_loadSketchResources(){this._sketchLoaderTask=i((async()=>(await import("./OrientedImageryViewer/components/SketchTools.js")).default))}_onAdditionalCoverageVisibilityChange(e){this.viewModel.setAdditionalCoverageVisibility(e)}_onAdditionalCameraLocationsVisibility(e){this.viewModel.setAdditionalCameraLocationsVisibility(e)}_onCurrentCoverageVisibilityChange(e){this.viewModel.setCurrentCoverageVisibility(e)}_registerGalleryItem(e){this._galleryObserver.observe(e)}_renderWarning(e){const{invalidCameraHeading:t,viewModel:{state:i}}=this;return t&&"image-loaded"===i?[H("calcite-notice",{class:f.alert,closable:!0,icon:"exclamation-mark-triangle-f",iconFlipRtl:!0,kind:"warning",open:!0,scale:"s"},H("div",{afterCreate:e=>this._storeWarningTitleElement(e),slot:"title"},e))]:null}_renderWarningTooltip(e){const{_warningTitleElement:t}=this;if(e?.length&&t)return H("calcite-tooltip",{closeOnClick:!0,referenceElement:t},e)}get _renderNavigation(){const{viewModel:{sectorData:e,navigatorCurrentBestFeature:i,currentBestFeature:a,state:s}}=this;if(!this.container||!a)return null;let o,r,n,l,c;if(i){const{x:e,y:t,direction:a}=i,[s,d,g,m]=w[a];o=`M ${e} ${t} L ${s} ${d} A ${b[2]} ${b[2]} 0 0 1 ${g} ${m} Z`,r=e,l=t,n=w[a][4],c=w[a][5]}const d=e=>{const t=e.target.dataset?.sector;t&&this.viewModel.handleSectorClick(+t)},g=e=>{const t=e.target.dataset;if(!t)return;const{featureIndexInSector:i,sector:a}=t;i&&a&&this.viewModel.handleFeatureClick({sector:a,featureIndexInSector:+i})},m=e=>{e.removeEventListener("click",g)},h=a.attributes.objectId,p=e?.map((e=>e?.items)).filter(Boolean).flatMap((e=>e?.map((({x:e,y:t,objectID:i,featureIndexInSector:a,sector:s})=>H("circle",{afterRemoved:m,class:this.classes(f.feature,{selected:h===i}),cx:e,cy:t,"data-feature-index-in-sector":a,"data-sector":s,key:`${f.feature}-${i}`,onclick:g,r:C}))))),u=e=>{e.removeEventListener("click",d)},y=this.classes({[f.navigationWrapper]:!0,[f.navigationZoomed]:this._navigationToolExpanded});return this.navigationToolActive&&"image-loaded"===s?H("div",{bind:this,class:y,key:this.messages.navigationTool},H("svg",{afterCreate:e=>this._storeNavigationToolReference(e),class:t()?I:f.rotateWithAnimation,focusable:"false",height:M,role:"img",width:M,xmlns:"http://www.w3.org/2000/svg"},H("defs",null,H("linearGradient",{gradientUnits:"userSpaceOnUse",id:`${this.id}-coverage-fill`,x1:r,x2:n,y1:l,y2:c},H("stop",{class:f.navigationPathOffset0,offset:0}),H("stop",{class:f.navigationPathOffset1,offset:1}))),H("g",null,H("circle",{class:this.classes(f.sector,f.outerSector),cx:b[3],cy:b[3],onclick:this._scaleNavigationTool,r:b[3]}),H("circle",{class:f.sector,cx:b[3],cy:b[3],r:b[2]}),H("circle",{class:f.sector,cx:b[3],cy:b[3],r:b[1]}),H("circle",{class:f.sector,cx:b[3],cy:b[3],r:b[0]}),H("path",{class:f.pointer,d:"M 56.5 6.06217782649107 L 60 0 L 63.5 6.06217782649107 Z",key:`${f.pointer}-west`}),H("path",{class:this.classes(f.pointer,f.north),d:"M 113.93782217350893 56.5 L 120 60 L 113.93782217350893 63.5 Z",key:`${f.pointer}-north`}),H("path",{class:f.pointer,d:"M 56.5 113.93782217350893 L 60 120 L 63.5 113.93782217350893 Z",key:`${f.pointer}-east`}),H("path",{class:f.pointer,d:"M 6.06217782649107 56.5 L 0 60 L 6.06217782649107 63.5 Z",key:`${f.pointer}-south`}),H("path",{class:this.classes(f.sector,f.sectorSeparator),d:"M 23.937554159486076 23.937554159486076 L 96.06244584051393 96.06244584051393 M 23.937554159486076 96.06244584051393 L 96.06244584051393 23.937554159486076",key:f.sectorSeparator}),v([b[2],b[1],b[0]],b[3],b[3]).map(((t,i)=>H("path",{afterRemoved:u,class:this.classes(f.sector,e?.[i]?.length?f.sectorEnabled:f.sectorDisabled),d:t,"data-sector":`${i}`,key:`${f.sector}-${i}`,onclick:d}))),H("path",{class:this.classes(f.sector,f.sectorCross),d:"M 56.4 56.4 L 63.53 63.53 M 63.53 56.4 L 56.4 63.53",key:f.sectorCross}),p,a.attributes.cameraPitch>=5&&o?H("path",{class:f.selectedFeaturePath,d:o,fill:`url(#${this.id}-coverage-fill)`,key:f.selectedFeaturePath}):null))):null}_renderSketch(){const{dataCaptureLayer:e,imageOverlaysOpened:t}=this;if(!e||t)return null;if(this._sketchLoaderTask||this._loadSketchResources(),!this._sketchLoaderTask?.value)return null;const{geometryType:i}=e,a="point"===i?"pin":"polyline"===i?"line":"polygon",s=this._sketchLoaderTask.value;return H("div",{class:f.sketchTools},H(s,{icon:a,messages:this._imageSketchToolsMessages,type:i,onAction:this._onAction}))}get _renderThumbnails(){const{currentBestFeature:e,thumbnails:t}=this.viewModel;return e?H("div",{class:f.carouselContent},t?.items.map((({url:t,objectId:i,rotation:a},s)=>H("div",{class:`${f.carouselItemWrapper}${e.attributes.objectId===i?"--selected":""}`,key:`${f.carouselItemWrapper}-${s}`},H("canvas",{afterCreate:this._registerGalleryItem,afterRemoved:this._unregisterGalleryItem,alt:`thumbnail-${i}`,class:f.carouselItem,"data-objectid":`${i}`,"data-rotation":`${a}`,"data-src":t,onclick:this._loadImageFromGallery,onmouseenter:this._highlight,onmouseleave:this._removeHighlight}))))):null}_resetImageTools(){this.viewModel.sharpness=this.viewModel.brightness=this.viewModel.contrast=0}_storeActionElement(e){this._actionItems.set(e.text,e)}_storeNavigationToolReference(e){this._navigationTool=e}_storeWarningTitleElement(e){this._warningTitleElement=e}_toggleAdditionalCameraLocations(){this.isAdditionalPointSourcesVisible=!this.isAdditionalPointSourcesVisible}_toggleAdditionalCoverage(){this.isAdditionalCoverageVisible=!this.isAdditionalCoverageVisible}_toggleCurrentCoverage(){this.currentCoverageVisible=!this.currentCoverageVisible}_toggleImageEnhancementToolState(e){e.stopPropagation();const t=this.imageEnhancementToolActive;this._closeAllImageTools(),this.imageEnhancementToolActive=!t}_toggleImageOverlays(e){e.stopPropagation();const t=this.imageOverlaysOpened;this._closeAllImageTools(),this.imageOverlaysOpened=!t}_toggleImageGallery(e){e.stopPropagation();const t=this.galleryOpened;this._closeAllImageTools(),this.galleryOpened=!!this.imageGalleryEnabled&&!t}_toggleLocationTool(e){const t=this.imageLocationToolActive;this._closeAllImageTools(),this.imageLocationToolActive=!t,e.stopPropagation()}_toggleMeasurementSketch(e,t){e.stopPropagation();const i=this.measureType;this._closeAllImageTools(),this.measureType=i===t?null:t,this.measureType===t&&(this.viewModel.displayNewMeasurementButton=!0)}_toggleNavigationTool(){const e=this.navigationToolActive;this._closeAllImageTools(),this.navigationToolActive=!e}_toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_unregisterGalleryItem(e){this._galleryObserver.unobserve(e)}_updateNavigationTool(e){const{previousFeatureAngle:t,bestFeatureAngle:i}=this.viewModel,a=(i-t+540)%360-180;e.style.setProperty(L,`${t}deg`),e.style.setProperty(A,`${t+a}deg`)}async loadBestImage(e){return this.viewModel.loadBestImage(e)}loadImageFromSource(e,t){return this.viewModel.loadImageFromSource(e,t)}async overlayMapFeatures(e,t){return this.removeHandles(`${R.overlayed}-${e.id}`),this.addHandles(l((()=>e.visible),(()=>{this.viewModel.toggleOverlayMapFeatures(e.id,e.visible)})),`${R.overlayed}-${e.id}`),this._overlayedLayers.add(e),this.viewModel.overlayMapFeatures(e,t&&this.showMapFeatures)}async plotMapPoint(e){return this.viewModel.plotMapPoint(e)}plotReferencePointOnGround(e){this.viewModel.plotReferencePointOnGround(e)}plotReferencePointOnImage(e){this.viewModel.plotReferencePointOnImage(e)}removeOverlayedGraphicsOnImage(e){this.removeHandles(`${R.overlayed}-${e}`),this._overlayedLayers.remove(this._overlayedLayers.find((t=>t.id===e))),this.viewModel.removeOverlayedGraphicsOnImage(e)}resetImage(){this.viewModel.resetImage()}render(){return H("div",{class:this.classes(j.widget,k)},this._renderRoot())}async startDataCapture(e){return this.viewModel.startDataCapture(e)}async stopDataCapture(e){return this.viewModel.stopDataCapture(e)}updateSuitabilities(e){this.viewModel.updateSuitabilities(e)}};e([m({readOnly:!0})],W.prototype,"accuracyParametersMissing",null),e([m()],W.prototype,"activeLayer",null),e([m()],W.prototype,"currentBestFeature",null),e([m()],W.prototype,"currentCoverageVisible",null),e([m()],W.prototype,"dataCaptureEnabled",void 0),e([m()],W.prototype,"dataCaptureLayer",null),e([m()],W.prototype,"disabled",null),e([m()],W.prototype,"features",null),e([m()],W.prototype,"imagePointsInView",null),e([m()],W.prototype,"galleryOpened",void 0),e([m()],W.prototype,"icon",null),e([m()],W.prototype,"imageEnhancementToolActive",void 0),e([m({readOnly:!0})],W.prototype,"imageGalleryEnabled",null),e([m()],W.prototype,"imageLocationToolActive",null),e([m()],W.prototype,"imageOverlaysOpened",void 0),e([m({readOnly:!0})],W.prototype,"invalidCameraHeading",null),e([m()],W.prototype,"isAdditionalCoverageVisible",null),e([m()],W.prototype,"isAdditionalPointSourcesVisible",null),e([m()],W.prototype,"mapImageConversionToolState",null),e([m()],W.prototype,"measureType",null),e([m()],W.prototype,"layer",null),e([m()],W.prototype,"navigationToolActive",void 0),e([D(T()),m({type:V})],W.prototype,"viewModel",void 0),e([m(),$("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],W.prototype,"messages",void 0),e([m(),$("esri/core/t9n/Units")],W.prototype,"measurementUnitMessages",void 0),e([m(),$("esri/t9n/common")],W.prototype,"messagesCommon",void 0),e([m(),$("esri/widgets/Sketch/t9n/Sketch")],W.prototype,"messagesSketch",void 0),e([m()],W.prototype,"pixelMeasurementUnit",void 0),e([m()],W.prototype,"pixelAreaMeasurementUnit",void 0),e([m({readOnly:!0})],W.prototype,"popupEnabled",null),e([m()],W.prototype,"referencePoint",null),e([m()],W.prototype,"showCameraLocations",void 0),e([m()],W.prototype,"showMapFeatures",void 0),e([D(["create","delete","redo","undo","update"]),m({readOnly:!0})],W.prototype,"sketchViewModel",null),e([m()],W.prototype,"view",null),e([m({type:P,nonNullable:!0})],W.prototype,"visibleElements",void 0),e([m()],W.prototype,"determineWorkflowForFeature",null),e([m()],W.prototype,"updateFootprint",null),e([m()],W.prototype,"_actionItems",void 0),e([m()],W.prototype,"_activeMeasurementIcon",null),e([m()],W.prototype,"_activeMeasurementHeading",null),e([m()],W.prototype,"_imageOverlaysLoaderTask",void 0),e([m()],W.prototype,"_imageMeasurementToolsLoaderTask",void 0),e([m()],W.prototype,"_measurementToggle",null),e([m()],W.prototype,"_commonActionProperties",null),e([m()],W.prototype,"_imageEnhancementTools",null),e([m()],W.prototype,"_imageGalleryPanel",null),e([m()],W.prototype,"_imageGalleryContext",null),e([m()],W.prototype,"_imageOverlaysComponent",null),e([m()],W.prototype,"_imageOverlayMessages",null),e([m()],W.prototype,"_imageSketchToolsMessages",null),e([m()],W.prototype,"_imageViewer",null),e([m()],W.prototype,"_locationToggle",null),e([m()],W.prototype,"_messageBox",null),e([m()],W.prototype,"_navigationToolExpanded",void 0),e([m()],W.prototype,"_navigationTool",void 0),e([m()],W.prototype,"_panoramicViewer",null),e([m()],W.prototype,"_warningTitleElement",void 0),e([m()],W.prototype,"_renderNavigation",null),e([m()],W.prototype,"_renderThumbnails",null),e([m()],W.prototype,"_sketchLoaderTask",void 0),W=e([h("esri.widgets.OrientedImageryViewer")],W);const U=W;export{U as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{prefersReducedMotion as t}from"../core/a11yUtils.js";import{createTask as i}from"../core/asyncUtils.js";import a from"../core/Collection.js";import{deprecatedProperty as s}from"../core/deprecate.js";import o from"../core/Logger.js";import{isAbortError as r}from"../core/promiseUtils.js";import n from"../core/ReactiveMap.js";import{watch as l,initial as c,syncAndInitial as d,whenOnce as g}from"../core/reactiveUtils.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import{or as p}from"../layers/orientedImagery/transformations/utils.js";import u from"./Widget.js";import{getAllArcPath as v}from"./OrientedImageryViewer/arcUtils.js";import{defaultImageGeometryField as y,defaultOIObjectIDField as _,segmentArcs as w,sectorsRadii as b,featureCircleRadius as C,navigationToolDimensionLength as M,getDelegatedEvents as T}from"./OrientedImageryViewer/constants.js";import{css as f,navigation as I,navigationToolRotationFrom as L,navigationToolRotationTo as A,root as k}from"./OrientedImageryViewer/css.js";import{isFeatureAttachment as O,loadImageForAttachment as F,getThumbnailPixelBlock as S,renderImageWithRotation as E}from"./OrientedImageryViewer/galleryUtils.js";import V from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import P from"./OrientedImageryViewer/OrientedImageryViewerVisibleElements.js";import x from"./OrientedImageryViewer/components/ImageLocationWidget.js";import{loadCalciteComponents as G}from"./support/componentsUtils.js";import{globalCss as j}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as $}from"./support/decorators/messageBundle.js";import{vmEvent as D}from"./support/decorators/vmEvent.js";import{tsx as H}from"./support/jsxFactory.js";import{substitute as B}from"../intl/substitute.js";const R={overlayMapFeatures:"overlay-map-features",overlayed:"overlayed",overlaysActionHandles:"overlays-action-handles"};let W=class extends u{constructor(e,t){super(e,t),this.dataCaptureEnabled=!1,this.galleryOpened=!1,this.imageEnhancementToolActive=!1,this.imageOverlaysOpened=!1,this.navigationToolActive=!1,this.viewModel=new V,this.messagesCommon=null,this.messagesSketch=null,this.pixelMeasurementUnit="meters",this.pixelAreaMeasurementUnit="square-meters",this.showCameraLocations=!1,this.showMapFeatures=!1,this.visibleElements=new P,this._actionItems=new n,this._imageOverlaysLoaderTask=null,this._imageMeasurementToolsLoaderTask=null,this._clearMeasurements=()=>{this.viewModel.measureType=null,this.viewModel.clearPreviousMeasurements()},this._clearImageLocation=()=>{this.imageLocationToolActive=!1},this._navigationToolExpanded=!1,this._navigationTool=null,this._warningTitleElement=null,this._galleryController=new AbortController,this._galleryObserver=new IntersectionObserver(this._lazyLoadImage.bind(this)),this._overlayedLayers=new a,this._previousAction=null,this._handleDataCaptureLayerChange=async e=>{if(this.dataCaptureLayer&&await this.stopDataCapture(!0),this.dataCaptureLayer=this.dataCaptureLayer===e?null:e,this.dataCaptureLayer)return this.startDataCapture(this.dataCaptureLayer)},this._handleOverlayLayerDeselect=e=>{const t=e.layer;t===this.dataCaptureLayer&&(this.stopDataCapture(),this.dataCaptureLayer=null),this.removeOverlayedGraphicsOnImage(`${t.id}`)},this._handleOverlayLayerSelect=e=>{const t=e.layer;this.viewModel.overlayMapFeatures(t,this.showMapFeatures),this.addHandles(l((()=>t.visible),(()=>{this.viewModel.toggleOverlayMapFeatures(t.id,t.visible)})),`${R.overlayed}-${t.id}`)},this._highlight=e=>{const t=e.target?.dataset.objectid;t&&this.viewModel.highlight(t)},this._onAction=e=>{const{target:t}=e,{dataset:{action:i}}=t,{_previousAction:a}=this,s=a?.dataset.action,o=s?.includes("draw")??!1,r="select-feature"===s,n=s!==i;switch(i){case"draw-point":case"draw-polygon":case"draw-polyline":{a&&p(r,o&&n)&&(a.active=!1),t.active=!t.active;const e=i.replace("draw-","");this.viewModel.digitizeCreate(e),this._previousAction=t.active?t:null;break}case"save":this.viewModel.saveDrawing();break;case"select-feature":o&&(this._previousAction.active=!1),t.active=!t.active,this.viewModel.toggleSelection(t.active),this._previousAction=t.active?t:null;break;case"delete-feature":this.viewModel.digitizeDelete()}},this._onImageOverlayClosed=()=>{this.imageOverlaysOpened=!1},this._onShowCameraLocationsChanged=e=>{this.showCameraLocations=e},this._onShowMapFeaturesChanged=e=>{this.showMapFeatures=e},this._removeActionElement=e=>{this._actionItems.delete(e.text)},this._removeHighlight=()=>this.viewModel.removeHighlight(),this._restoreOverlays=async()=>Promise.all(this._overlayedLayers.map((e=>this.viewModel.overlayMapFeatures(e,this.showMapFeatures)))),this._scaleNavigationTool=()=>{this._navigationToolExpanded=!this._navigationToolExpanded},this._sketchLoaderTask=null,this._toggleImageAttributes=()=>{this.viewModel.toggleImageAttributes()},this._loadImageFromGallery=this._loadImageFromGallery.bind(this),this._registerGalleryItem=this._registerGalleryItem.bind(this),this._unregisterGalleryItem=this._unregisterGalleryItem.bind(this),this.loadImageFromSource=this.loadImageFromSource.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this)}initialize(){this.addHandles([l((()=>[this.viewModel?.bestFeatureAngle,this._navigationTool]),(([e,t])=>{t&&this._updateNavigationTool(t)}),c),l((()=>this.currentCoverageVisible),(e=>this._onCurrentCoverageVisibilityChange(e))),l((()=>this.isAdditionalCoverageVisible),(e=>this._onAdditionalCoverageVisibilityChange(e))),l((()=>this.isAdditionalPointSourcesVisible),(e=>this._onAdditionalCameraLocationsVisibility(e))),l((()=>({features:this.currentBestFeature,showCameraLocations:this.showCameraLocations,state:this.viewModel.state})),(({showCameraLocations:e,state:t})=>{"image-loaded"===t&&this.viewModel.overlayCameraLocations(e)}),d),l((()=>({feature:this.currentBestFeature,showMapFeatures:this.showMapFeatures,state:this.viewModel.state})),(async(e,t)=>{if(e.showMapFeatures!==t?.showMapFeatures&&this.viewModel.toggleAllOverlayMapFeatures(e.showMapFeatures),null!=e.feature&&e.feature!==t?.feature){if(this.viewModel.removeAllOverlayMapFeatures(),await g((()=>"image-loaded"===this.viewModel.state)),this.dataCaptureLayer&&this.stopDataCapture(),await this._restoreOverlays(),!this.dataCaptureLayer)return;await this.startDataCapture(this.dataCaptureLayer),this._previousAction?.active&&(this._previousAction.active=!1,this._previousAction=null)}}),c)])}loadDependencies(){return G({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),shell:()=>import("@esri/calcite-components/dist/components/calcite-shell"),dialog:()=>import("@esri/calcite-components/dist/components/calcite-dialog"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this._galleryController.abort(),this._galleryObserver.disconnect()}get accuracyParametersMissing(){return this.viewModel.accuracyParametersMissing}get activeLayer(){return s(o.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){s(o.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get currentBestFeature(){return this.viewModel.currentBestFeature}set currentBestFeature(e){this.viewModel.currentBestFeature=e}get currentCoverageVisible(){return this.viewModel.currentCoverageVisible}set currentCoverageVisible(e){this.viewModel.currentCoverageVisible=e}get dataCaptureLayer(){return this.viewModel.dataCaptureLayer}set dataCaptureLayer(e){this.viewModel.dataCaptureLayer=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get displayMessage(){return this.viewModel.displayMessage}get features(){return this.viewModel.features}get imagePointsInView(){return this.viewModel.imagePointsInView}get icon(){return"oriented-imagery-widget"}set icon(e){this._overrideIfSome("icon",e)}get imageGalleryEnabled(){return this.viewModel.imageGalleryEnabled}get imageLocationToolActive(){return this.viewModel.imageLocationToolState}set imageLocationToolActive(e){this.viewModel.imageLocationToolState=e}get invalidCameraHeading(){return this.viewModel.invalidCameraHeading}get isAdditionalCoverageVisible(){return this.viewModel.isAdditionalCoverageVisible}set isAdditionalCoverageVisible(e){this.viewModel.isAdditionalCoverageVisible=e}get isAdditionalPointSourcesVisible(){return this.viewModel.isAdditionalPointSourcesVisible}set isAdditionalPointSourcesVisible(e){this.viewModel.isAdditionalPointSourcesVisible=e}get mapImageConversionToolState(){return this.viewModel.mapImageConversionToolState}set mapImageConversionToolState(e){this.viewModel.mapImageConversionToolState=e}get measureType(){return this.viewModel.measureType}set measureType(e){this.viewModel.measureType=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get popupEnabled(){const{popupEnabled:e,state:t}=this.viewModel;return"image-loaded"===t&&e}get referencePoint(){return this.viewModel.referencePoint??null}get sketchViewModel(){return this.viewModel.sketch}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set determineWorkflowForFeature(e){this.viewModel.determineWorkflowForFeature=e}get determineWorkflowForFeature(){return this.viewModel.determineWorkflowForFeature}set updateFootprint(e){this.viewModel.updateFootprint=e}get updateFootprint(){return this.viewModel.updateFootprint}_renderActionBar(){return H("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},H("calcite-action-group",null,this._currentFootprintToggle(),this._additionalFootprintToggle(),this._additionalPointSourcesToggle()),H("calcite-action-group",null,this._mapImageConversionToggle(),this._navigationToolToggle(),this._imageEnhancementsToggle()),H("calcite-action-group",null,this._measurementToolsToggle(),this._imageGalleryToggle(),this._imageOverlaysToggle(),this._openPopupAction()),this._actionTooltips())}_actionTooltips(){return[...this._actionItems].map((([e,t])=>H("calcite-tooltip",{closeOnClick:!0,key:e,placement:"bottom",referenceElement:t},H("span",null,e))))}get _activeMeasurementIcon(){const{measureType:e,imageLocationToolActive:t}=this;if(t)return"pin-tear";switch(e){case"area":return"measure-area";case"height":return"measure-building-height-top-base";default:return"measure-line"}}get _activeMeasurementHeading(){const{measureType:e,messages:t}=this,{groundArea:i,heightAboveGround:a,groundDistance:s}=t;switch(e){case"area":return i;case"height":return a;default:return s}}_additionalFootprintToggle(){const{isAdditionalCoverageVisible:e,invalidCameraHeading:t,visibleElements:{additionalFootprintToggle:i}}=this;return i?H("calcite-action",{active:e,...this._commonActionProperties,class:f.addCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleAdditionalCoverage,text:this.messages.additionalFootprints}):null}_additionalPointSourcesToggle(){const{isAdditionalPointSourcesVisible:e,invalidCameraHeading:t,visibleElements:{additionalCameraLocationsToggle:i}}=this;return i?H("calcite-action",{active:e,...this._commonActionProperties,class:f.addExpPoints,disabled:t,icon:"circle-area",onclick:this._toggleAdditionalCameraLocations,text:this.messages.additionalCameraLocations}):null}get _measurementToggle(){const{viewModel:{state:e,measureType:t},id:i}=this;if("image-loaded"!==e||!t)return;this._imageMeasurementToolsLoaderTask||this._loadImageMeasurementResources();const a=this._imageMeasurementToolsLoaderTask?.value;return a?H("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:this._activeMeasurementHeading,id:`${i}-${t}-measurement`,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearMeasurements},H(a,{measurementType:t,measurementUnitMessages:this.measurementUnitMessages,messages:this.messages,oiViewModel:this.viewModel})):null}get _commonActionProperties(){return{afterCreate:this._storeActionElement,afterRemoved:this._removeActionElement,afterUpdate:this._storeActionElement,bind:this}}_renderRoot(){const{viewModel:{state:e}}=this;return H("calcite-panel",null,H("calcite-shell",null,H("calcite-panel",{bind:this,class:f.viewerContainer,heading:this.visibleElements.title?this.messages.title:void 0,loading:e.includes("loading")},this.visibleElements.menu?this._renderActionBar():null,this._imageViewer,this._panoramicViewer,this._messageBox,this.invalidCameraHeading?[this._renderWarning(this.messages.invalidCameraHeadingWarningTitle),this._renderWarningTooltip(this.messages.invalidCameraHeadingWarningDescription)]:[this._imageGalleryPanel,this._renderNavigation,this._imageOverlaysPanel()],this._imageEnhancementTools,this._renderSketch()),this._measurementToggle,this._locationToggle))}_currentFootprintToggle(){const{currentCoverageVisible:e,invalidCameraHeading:t}=this,{currentFootprintToggle:i}=this.visibleElements;return i?H("calcite-action",{active:e,...this._commonActionProperties,class:f.currentCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleCurrentCoverage,text:this.messages.currentFootprint}):null}get _imageEnhancementTools(){const{imageEnhancementToolActive:e,viewModel:{brightness:t,contrast:i,sharpness:a,state:s}}=this;return e&&"image-loaded"===s?H("calcite-panel",{bind:this,class:f.imageEnhancementWrapper,closable:!0,closed:!e,heading:this.messages.imageEnhancement,key:this.messages.imageEnhancement,onCalcitePanelClose:this._toggleImageEnhancementToolState},H("div",{class:f.imageEnhancementTools},H("div",{class:f.imageEnhancementToolContainer},H("calcite-label",null,this.messages.brightness,H("calcite-slider",{bind:this,labelTicks:!0,max:10,min:-10,ticks:5,value:t,onCalciteSliderInput:this._handleBrightnessChange}))),H("div",{class:f.imageEnhancementToolContainer},H("calcite-label",null,this.messages.contrast,H("calcite-slider",{bind:this,labelTicks:!0,max:10,min:-10,ticks:5,value:i,onCalciteSliderInput:this._handleContrastChange}))),H("div",{class:f.imageEnhancementToolContainer},H("calcite-label",null,this.messages.sharpness,H("calcite-slider",{bind:this,labelTicks:!0,max:1,min:0,step:.1,ticks:.5,value:a,onCalciteSliderInput:this._handleSharpnessChange})))),H("calcite-action",{bind:this,icon:"reset",onclick:this._resetImageTools,slot:"header-actions-end",text:this.messagesCommon.reset})):null}_imageEnhancementsToggle(){const{state:e,mode:t}=this.viewModel,{imageEnhancement:i}=this.visibleElements;return i?H("calcite-action",{active:this.imageEnhancementToolActive,...this._commonActionProperties,disabled:"default"!==t||"image-loaded"!==e,icon:"sliders-horizontal",onclick:this._toggleImageEnhancementToolState,text:this.messages.imageEnhancement}):null}get _imageGalleryPanel(){const{container:e,galleryOpened:t,imageGalleryEnabled:i}=this;return i&&t&&e?this._imageGalleryContext:null}get _imageGalleryContext(){const{galleryOpened:e,invalidCameraHeading:t}=this;return H("calcite-panel",{bind:this,class:f.carousel,closable:!0,closed:!e,disabled:t,heading:this.messages.imageGallery,key:this.messages.imageGallery,onCalcitePanelClose:this._toggleImageGallery},H("div",{class:f.carouselContainer},this._renderThumbnails))}_imageGalleryToggle(){const{imageGalleryEnabled:e,invalidCameraHeading:t,visibleElements:{imageGallery:i}}=this;return i?H("calcite-action",{active:this.galleryOpened,...this._commonActionProperties,disabled:!e||t,icon:"images",onclick:this._toggleImageGallery,text:this.messages.imageGallery}):null}get _imageOverlaysComponent(){const{_imageOverlayMessages:e,_imageOverlaysLoaderTask:t,_overlayedLayers:a,dataCaptureEnabled:s,dataCaptureLayer:o,imageOverlaysOpened:r,showCameraLocations:n,showMapFeatures:l,view:c,layer:d}=this;if(!d)return null;const g=d.imageGeometryField?.length?d.imageGeometryField:y,m=d.imageReferenceField?.length?d.imageReferenceField:_;t||(this._imageOverlaysLoaderTask=i((async()=>(await import("./OrientedImageryViewer/components/ImageOverlays.js")).default)));const h=this._imageOverlaysLoaderTask?.value;return h?H(h,{closed:!r,dataCaptureEnabled:s,dataCaptureLayer:o,imageGeometryField:g,imageReferenceField:m,messages:e,overlayedLayers:a,showCameraLocations:n,showMapFeatures:l,view:c,onDataCaptureLayerChanged:this._handleDataCaptureLayerChange,onImageOverlaysClosed:this._onImageOverlayClosed,onLayerDeselected:this._handleOverlayLayerDeselect,onLayerSelected:this._handleOverlayLayerSelect,onShowCameraLocationsChanged:this._onShowCameraLocationsChanged,onShowMapFeaturesChanged:this._onShowMapFeaturesChanged}):null}get _imageOverlayMessages(){return{...this.messages,...this.messagesSketch}}get _imageSketchToolsMessages(){return{...this.messagesSketch,...this.messagesCommon}}_imageOverlaysPanel(){const{imageOverlaysOpened:e,viewModel:{state:t}}=this,i=this.classes({[f.imageOverlaysContainer]:!0,[j.hidden]:!e||"image-loaded"!==t});return H("div",{class:i,key:this.messages.imageOverlays},this._imageOverlaysComponent)}_imageOverlaysToggle(){const{viewModel:{state:e},imageOverlaysOpened:t,invalidCameraHeading:i,visibleElements:{imageOverlays:a}}=this;return a?H("calcite-action",{active:t,...this._commonActionProperties,disabled:"image-loaded"!==e||i,icon:"layers",onclick:this._toggleImageOverlays,text:this.messages.imageOverlays}):null}get _imageViewer(){const{displayMessage:e,loadImageViewer:t,mode:i}=this.viewModel,a=null!=e||"default"!==i,s=this.classes({[f.viewer]:!a,[f.viewerHidden]:a});return H("calcite-panel",{afterCreate:t,bind:this,class:s},this._renderSketch())}get _locationToggle(){const{viewModel:{state:e,groundCoordinates:t,groundCoordinatesAccuracy:i},imageLocationToolActive:a,messages:{groundLocation:s}}=this;if("image-loaded"===e&&t&&a)return H("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:s,id:s,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearImageLocation},H(x,{accuracy:i,groundCoordinates:t,messages:this.messages}))}_mapImageConversionToggle(){const{mapImageConversionToolState:e,viewModel:{state:t},invalidCameraHeading:i,visibleElements:{mapImageConversionTool:a}}=this;return a?H("calcite-action",{active:e,...this._commonActionProperties,disabled:"image-loaded"!==t||i,icon:"image-pin",onclick:this._toggleMapImageConversionToolState,text:this.messages.mapImageConversionTool}):null}_measurementToolsToggle(){const{_activeMeasurementIcon:e,measureType:t,viewModel:i,accuracyParametersMissing:a,messages:s,visibleElements:{measurementTools:o}}=this,{state:r}=i,{measurementTools:n,groundDistance:l,groundArea:c,heightAboveGround:d,groundLocation:g}=s;return o?H("calcite-dropdown",{disabled:a,key:"measurement-tools",width:"m"},H("calcite-action",{...this._commonActionProperties,disabled:"image-loaded"!==r||a,icon:e,slot:"trigger",text:n}),H("calcite-dropdown-group",null,H("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-line",key:"distance-measurement",onclick:e=>this._toggleMeasurementSketch(e,"distance"),selected:"distance"===t},l),H("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-area",key:"area-measurement",onclick:e=>this._toggleMeasurementSketch(e,"area"),selected:"area"===t},c),H("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-building-height-top-base",key:"height-dropdown",onclick:e=>this._toggleMeasurementSketch(e,"height"),selected:"height"===t},d),H("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"pin-tear",key:"surface-location",onclick:e=>this._toggleLocationTool(e),selected:this.imageLocationToolActive},g))):null}get _messageBox(){const{messages:e,viewModel:{displayMessage:t}}=this;if(!t)return null;const{data:i,key:a,map:s}=t,o=`${s?B(e[a],s):e[a]}`;return H("span",{class:f.messageBox},i?`${o} ${i}`:o)}_navigationToolToggle(){const{state:e}=this.viewModel,{visibleElements:{navigationTool:t}}=this;return t?H("calcite-action",{active:this.navigationToolActive,...this._commonActionProperties,disabled:"image-loaded"!==e||this.invalidCameraHeading,icon:"explore",onclick:this._toggleNavigationTool,text:this.messages.navigationTool}):null}_openPopupAction(){const{showPopupsAction:e}=this.visibleElements;return e?H("calcite-action",{...this._commonActionProperties,disabled:!this.popupEnabled,icon:"popup",onclick:this._toggleImageAttributes,text:this.messages.showPopups}):null}get _panoramicViewer(){const{displayMessage:e,loadPanoramicViewer:t,mode:i}=this.viewModel,a=null!=e||"panoramic"!==i,s=this.classes({[f.viewer]:!a,[f.viewerHidden]:a});return H("calcite-panel",{afterCreate:t,bind:this,class:s})}_closeAllImageTools(){this.imageEnhancementToolActive=!1,this.navigationToolActive=!1,this.imageOverlaysOpened=!1,this.galleryOpened=!1,this.measureType=null,this.imageLocationToolActive=!1}_handleBrightnessChange(e){this.viewModel.brightness=e.currentTarget.value??0}_handleContrastChange(e){this.viewModel.contrast=e.currentTarget.value??0}_handleSharpnessChange(e){this.viewModel.sharpness=e.currentTarget.value??0}_lazyLoadImage(e,t){e.forEach((async e=>{if(e.isIntersecting){const a=e.target,s=a.getAttribute("data-src"),n=a.getAttribute("data-rotation"),l=a.getAttribute("data-objectid"),c=n?parseFloat(n)%360:0,{layer:d,_galleryController:{signal:g}}=this;if(!s||!l)return;let m;try{m=O(s)?await F(d,l,{signal:g}):await S(s,{signal:g})}catch(i){r(i)||o.getLogger("esri.widgets.OrientedImageryViewer").error("#lazyLoadImage()",i)}finally{t.unobserve(a)}if(!m)return;E(m,a,c)}}))}_loadImageFromGallery(e){const{target:t}=e;if(!t)return;const i=t.getAttribute("data-objectid");i&&this.viewModel.currentBestFeature?.attributes.objectId!==Number(i)&&this.viewModel.selectBestFeature(i)}_loadImageMeasurementResources(){this._imageMeasurementToolsLoaderTask=i((async()=>{const{default:e}=await import("./OrientedImageryViewer/components/ImageMeasurementWidget.js");return e}))}_loadSketchResources(){this._sketchLoaderTask=i((async()=>(await import("./OrientedImageryViewer/components/SketchTools.js")).default))}_onAdditionalCoverageVisibilityChange(e){this.viewModel.setAdditionalCoverageVisibility(e)}_onAdditionalCameraLocationsVisibility(e){this.viewModel.setAdditionalCameraLocationsVisibility(e)}_onCurrentCoverageVisibilityChange(e){this.viewModel.setCurrentCoverageVisibility(e)}_registerGalleryItem(e){this._galleryObserver.observe(e)}_renderWarning(e){const{invalidCameraHeading:t,viewModel:{state:i}}=this;return t&&"image-loaded"===i?[H("calcite-notice",{class:f.alert,closable:!0,icon:"exclamation-mark-triangle-f",iconFlipRtl:!0,kind:"warning",open:!0,scale:"s"},H("div",{afterCreate:e=>this._storeWarningTitleElement(e),slot:"title"},e))]:null}_renderWarningTooltip(e){const{_warningTitleElement:t}=this;if(e?.length&&t)return H("calcite-tooltip",{closeOnClick:!0,referenceElement:t},e)}get _renderNavigation(){const{viewModel:{sectorData:e,navigatorCurrentBestFeature:i,currentBestFeature:a,state:s}}=this;if(!this.container||!a)return null;let o,r,n,l,c;if(i){const{x:e,y:t,direction:a}=i,[s,d,g,m]=w[a];o=`M ${e} ${t} L ${s} ${d} A ${b[2]} ${b[2]} 0 0 1 ${g} ${m} Z`,r=e,l=t,n=w[a][4],c=w[a][5]}const d=e=>{const t=e.target.dataset?.sector;t&&this.viewModel.handleSectorClick(+t)},g=e=>{const t=e.target.dataset;if(!t)return;const{featureIndexInSector:i,sector:a}=t;i&&a&&this.viewModel.handleFeatureClick({sector:a,featureIndexInSector:+i})},m=e=>{e.removeEventListener("click",g)},h=a.attributes.objectId,p=e?.map((e=>e?.items)).filter(Boolean).flatMap((e=>e?.map((({x:e,y:t,objectID:i,featureIndexInSector:a,sector:s})=>H("circle",{afterRemoved:m,class:this.classes(f.feature,{selected:h===i}),cx:e,cy:t,"data-feature-index-in-sector":a,"data-sector":s,key:`${f.feature}-${i}`,onclick:g,r:C}))))),u=e=>{e.removeEventListener("click",d)},y=this.classes({[f.navigationWrapper]:!0,[f.navigationZoomed]:this._navigationToolExpanded});return this.navigationToolActive&&"image-loaded"===s?H("div",{bind:this,class:y,key:this.messages.navigationTool},H("svg",{afterCreate:e=>this._storeNavigationToolReference(e),class:t()?I:f.rotateWithAnimation,focusable:"false",height:M,role:"img",width:M,xmlns:"http://www.w3.org/2000/svg"},H("defs",null,H("linearGradient",{gradientUnits:"userSpaceOnUse",id:`${this.id}-coverage-fill`,x1:r,x2:n,y1:l,y2:c},H("stop",{class:f.navigationPathOffset0,offset:0}),H("stop",{class:f.navigationPathOffset1,offset:1}))),H("g",null,H("circle",{class:this.classes(f.sector,f.outerSector),cx:b[3],cy:b[3],onclick:this._scaleNavigationTool,r:b[3]}),H("circle",{class:f.sector,cx:b[3],cy:b[3],r:b[2]}),H("circle",{class:f.sector,cx:b[3],cy:b[3],r:b[1]}),H("circle",{class:f.sector,cx:b[3],cy:b[3],r:b[0]}),H("path",{class:f.pointer,d:"M 56.5 6.06217782649107 L 60 0 L 63.5 6.06217782649107 Z",key:`${f.pointer}-west`}),H("path",{class:this.classes(f.pointer,f.north),d:"M 113.93782217350893 56.5 L 120 60 L 113.93782217350893 63.5 Z",key:`${f.pointer}-north`}),H("path",{class:f.pointer,d:"M 56.5 113.93782217350893 L 60 120 L 63.5 113.93782217350893 Z",key:`${f.pointer}-east`}),H("path",{class:f.pointer,d:"M 6.06217782649107 56.5 L 0 60 L 6.06217782649107 63.5 Z",key:`${f.pointer}-south`}),H("path",{class:this.classes(f.sector,f.sectorSeparator),d:"M 23.937554159486076 23.937554159486076 L 96.06244584051393 96.06244584051393 M 23.937554159486076 96.06244584051393 L 96.06244584051393 23.937554159486076",key:f.sectorSeparator}),v([b[2],b[1],b[0]],b[3],b[3]).map(((t,i)=>H("path",{afterRemoved:u,class:this.classes(f.sector,e?.[i]?.length?f.sectorEnabled:f.sectorDisabled),d:t,"data-sector":`${i}`,key:`${f.sector}-${i}`,onclick:d}))),H("path",{class:this.classes(f.sector,f.sectorCross),d:"M 56.4 56.4 L 63.53 63.53 M 63.53 56.4 L 56.4 63.53",key:f.sectorCross}),p,a.attributes.cameraPitch>=5&&o?H("path",{class:f.selectedFeaturePath,d:o,fill:`url(#${this.id}-coverage-fill)`,key:f.selectedFeaturePath}):null))):null}_renderSketch(){const{dataCaptureLayer:e,imageOverlaysOpened:t}=this;if(!e||t)return null;if(this._sketchLoaderTask||this._loadSketchResources(),!this._sketchLoaderTask?.value)return null;const{geometryType:i}=e,a="point"===i?"pin":"polyline"===i?"line":"polygon",s=this._sketchLoaderTask.value;return H("div",{class:f.sketchTools},H(s,{icon:a,messages:this._imageSketchToolsMessages,type:i,onAction:this._onAction}))}get _renderThumbnails(){const{currentBestFeature:e,thumbnails:t}=this.viewModel;return e?H("div",{class:f.carouselContent},t?.items.map((({url:t,objectId:i,rotation:a},s)=>H("div",{class:`${f.carouselItemWrapper}${e.attributes.objectId===i?"--selected":""}`,key:`${f.carouselItemWrapper}-${s}`},H("canvas",{afterCreate:this._registerGalleryItem,afterRemoved:this._unregisterGalleryItem,alt:`thumbnail-${i}`,class:f.carouselItem,"data-objectid":`${i}`,"data-rotation":`${a}`,"data-src":t,onclick:this._loadImageFromGallery,onmouseenter:this._highlight,onmouseleave:this._removeHighlight}))))):null}_resetImageTools(){this.viewModel.sharpness=this.viewModel.brightness=this.viewModel.contrast=0}_storeActionElement(e){this._actionItems.set(e.text,e)}_storeNavigationToolReference(e){this._navigationTool=e}_storeWarningTitleElement(e){this._warningTitleElement=e}_toggleAdditionalCameraLocations(){this.isAdditionalPointSourcesVisible=!this.isAdditionalPointSourcesVisible}_toggleAdditionalCoverage(){this.isAdditionalCoverageVisible=!this.isAdditionalCoverageVisible}_toggleCurrentCoverage(){this.currentCoverageVisible=!this.currentCoverageVisible}_toggleImageEnhancementToolState(e){e.stopPropagation();const t=this.imageEnhancementToolActive;this._closeAllImageTools(),this.imageEnhancementToolActive=!t}_toggleImageOverlays(e){e.stopPropagation();const t=this.imageOverlaysOpened;this._closeAllImageTools(),this.imageOverlaysOpened=!t}_toggleImageGallery(e){e.stopPropagation();const t=this.galleryOpened;this._closeAllImageTools(),this.galleryOpened=!!this.imageGalleryEnabled&&!t}_toggleLocationTool(e){const t=this.imageLocationToolActive;this._closeAllImageTools(),this.imageLocationToolActive=!t,e.stopPropagation()}_toggleMeasurementSketch(e,t){e.stopPropagation();const i=this.measureType;this._closeAllImageTools(),this.measureType=i===t?null:t,this.measureType===t&&(this.viewModel.displayNewMeasurementButton=!0)}_toggleNavigationTool(){const e=this.navigationToolActive;this._closeAllImageTools(),this.navigationToolActive=!e}_toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_unregisterGalleryItem(e){this._galleryObserver.unobserve(e)}_updateNavigationTool(e){const{previousFeatureAngle:t,bestFeatureAngle:i}=this.viewModel,a=(i-t+540)%360-180;e.style.setProperty(L,`${t}deg`),e.style.setProperty(A,`${t+a}deg`)}async loadBestImage(e){return this.viewModel.loadBestImage(e)}loadImageFromSource(e,t){return this.viewModel.loadImageFromSource(e,t)}async overlayMapFeatures(e,t){return this.removeHandles(`${R.overlayed}-${e.id}`),this.addHandles(l((()=>e.visible),(()=>{this.viewModel.toggleOverlayMapFeatures(e.id,e.visible)})),`${R.overlayed}-${e.id}`),this._overlayedLayers.add(e),this.viewModel.overlayMapFeatures(e,t&&this.showMapFeatures)}async plotMapPoint(e){return this.viewModel.plotMapPoint(e)}plotReferencePointOnGround(e){this.viewModel.plotReferencePointOnGround(e)}plotReferencePointOnImage(e){this.viewModel.plotReferencePointOnImage(e)}removeOverlayedGraphicsOnImage(e){this.removeHandles(`${R.overlayed}-${e}`),this._overlayedLayers.remove(this._overlayedLayers.find((t=>t.id===e))),this.viewModel.removeOverlayedGraphicsOnImage(e)}resetImage(){this.viewModel.resetImage()}render(){return H("div",{class:this.classes(j.widget,k)},this._renderRoot())}async startDataCapture(e){return this.viewModel.startDataCapture(e)}async stopDataCapture(e){return this.viewModel.stopDataCapture(e)}updateSuitabilities(e){this.viewModel.updateSuitabilities(e)}};e([m({readOnly:!0})],W.prototype,"accuracyParametersMissing",null),e([m()],W.prototype,"activeLayer",null),e([m()],W.prototype,"currentBestFeature",null),e([m()],W.prototype,"currentCoverageVisible",null),e([m()],W.prototype,"dataCaptureEnabled",void 0),e([m()],W.prototype,"dataCaptureLayer",null),e([m()],W.prototype,"disabled",null),e([m()],W.prototype,"features",null),e([m()],W.prototype,"imagePointsInView",null),e([m()],W.prototype,"galleryOpened",void 0),e([m()],W.prototype,"icon",null),e([m()],W.prototype,"imageEnhancementToolActive",void 0),e([m({readOnly:!0})],W.prototype,"imageGalleryEnabled",null),e([m()],W.prototype,"imageLocationToolActive",null),e([m()],W.prototype,"imageOverlaysOpened",void 0),e([m({readOnly:!0})],W.prototype,"invalidCameraHeading",null),e([m()],W.prototype,"isAdditionalCoverageVisible",null),e([m()],W.prototype,"isAdditionalPointSourcesVisible",null),e([m()],W.prototype,"mapImageConversionToolState",null),e([m()],W.prototype,"measureType",null),e([m()],W.prototype,"layer",null),e([m()],W.prototype,"navigationToolActive",void 0),e([D(T()),m({type:V})],W.prototype,"viewModel",void 0),e([m(),$("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],W.prototype,"messages",void 0),e([m(),$("esri/core/t9n/Units")],W.prototype,"measurementUnitMessages",void 0),e([m(),$("esri/t9n/common")],W.prototype,"messagesCommon",void 0),e([m(),$("esri/widgets/Sketch/t9n/Sketch")],W.prototype,"messagesSketch",void 0),e([m()],W.prototype,"pixelMeasurementUnit",void 0),e([m()],W.prototype,"pixelAreaMeasurementUnit",void 0),e([m({readOnly:!0})],W.prototype,"popupEnabled",null),e([m()],W.prototype,"referencePoint",null),e([m()],W.prototype,"showCameraLocations",void 0),e([m()],W.prototype,"showMapFeatures",void 0),e([D(["create","delete","redo","undo","update"]),m({readOnly:!0})],W.prototype,"sketchViewModel",null),e([m()],W.prototype,"view",null),e([m({type:P,nonNullable:!0})],W.prototype,"visibleElements",void 0),e([m()],W.prototype,"determineWorkflowForFeature",null),e([m()],W.prototype,"updateFootprint",null),e([m()],W.prototype,"_actionItems",void 0),e([m()],W.prototype,"_activeMeasurementIcon",null),e([m()],W.prototype,"_activeMeasurementHeading",null),e([m()],W.prototype,"_imageOverlaysLoaderTask",void 0),e([m()],W.prototype,"_imageMeasurementToolsLoaderTask",void 0),e([m()],W.prototype,"_measurementToggle",null),e([m()],W.prototype,"_commonActionProperties",null),e([m()],W.prototype,"_imageEnhancementTools",null),e([m()],W.prototype,"_imageGalleryPanel",null),e([m()],W.prototype,"_imageGalleryContext",null),e([m()],W.prototype,"_imageOverlaysComponent",null),e([m()],W.prototype,"_imageOverlayMessages",null),e([m()],W.prototype,"_imageSketchToolsMessages",null),e([m()],W.prototype,"_imageViewer",null),e([m()],W.prototype,"_locationToggle",null),e([m()],W.prototype,"_messageBox",null),e([m()],W.prototype,"_navigationToolExpanded",void 0),e([m()],W.prototype,"_navigationTool",void 0),e([m()],W.prototype,"_panoramicViewer",null),e([m()],W.prototype,"_warningTitleElement",void 0),e([m()],W.prototype,"_renderNavigation",null),e([m()],W.prototype,"_renderThumbnails",null),e([m()],W.prototype,"_sketchLoaderTask",void 0),W=e([h("esri.widgets.OrientedImageryViewer")],W);const U=W;export{U as default};