@arcgis/core 5.0.0-next.46 → 5.0.0-next.47
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.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/108675a17e432a02cf66.js +1 -0
- package/assets/esri/core/workers/chunks/19270a2de33f2662005b.js +1 -0
- package/assets/esri/core/workers/chunks/{c5d6b416baf24e74b9ba.js → 1dfa949cc4f4c18ed4cf.js} +1 -1
- package/assets/esri/core/workers/chunks/404229f10aef5ac23c87.js +1 -0
- package/assets/esri/core/workers/chunks/46b63a65484b102e9ccb.js +1 -0
- package/assets/esri/core/workers/chunks/{9f6c63a580b28ab715bd.js → 5ffeb8fb58d59bad68c3.js} +1 -1
- package/assets/esri/core/workers/chunks/657602e6a84e8b4576fb.js +1 -0
- package/assets/esri/core/workers/chunks/6d3ae7969ea86a2e0b13.js +1 -0
- package/assets/esri/core/workers/chunks/75d8244b725a2aee2003.js +1 -0
- package/assets/esri/core/workers/chunks/{a4f492aa5444e6381063.js → 7d631ebf8f79225cf0f6.js} +1 -1
- package/assets/esri/core/workers/chunks/9319d57494482668ab19.js +1 -0
- package/assets/esri/core/workers/chunks/dae715b2b0094641e42f.js +1 -0
- package/assets/esri/core/workers/chunks/ecb4c223c0278971cdc9.js +1 -0
- package/assets/esri/core/workers/chunks/f92a78ce5510e0d0d0f7.js +1 -0
- package/assets/esri/core/workers/chunks/fa92a7c11befbad8739f.js +1 -0
- package/config.js +1 -1
- package/interfaces.d.ts +57 -57
- package/kernel.js +1 -1
- package/layers/ParquetLayer.js +1 -1
- package/layers/graphics/sources/ParquetSource.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/support/{ParquetEncodingBase.js → ParquetGeometryEncodingBase.js} +1 -1
- package/layers/support/ParquetGeometryEncodingLocation.d.ts +4 -0
- package/layers/support/ParquetGeometryEncodingLocation.js +5 -0
- package/layers/support/ParquetGeometryEncodingWkb.d.ts +4 -0
- package/layers/support/ParquetGeometryEncodingWkb.js +5 -0
- package/layers/support/parquetEncodingUtils.js +1 -1
- package/layers/support/parquetUtils.js +1 -1
- package/libs/parquet/parquet.js +1 -1
- package/package.json +2 -2
- package/support/revision.js +1 -1
- package/views/2d/engine/vectorTiles/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
- package/views/3d/webgl-engine/lib/CutFillDepth.js +1 -1
- package/views/SelectionManager.js +1 -1
- package/views/support/selectionUtils.js +1 -1
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
- package/widgets/Editor/support/SketchController.js +1 -1
- package/widgets/FeatureForm/TextElementInput.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/Search.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
- package/widgets/support/Selector2D/selectorUtils.js +1 -1
- package/assets/esri/core/workers/chunks/024104997daea0d74b38.js +0 -1
- package/assets/esri/core/workers/chunks/08ef90e3fcfd4eda4301.js +0 -1
- package/assets/esri/core/workers/chunks/2d3ae187f8aa3495d4ae.js +0 -1
- package/assets/esri/core/workers/chunks/2f8cf7d9ff1f4de19a4c.js +0 -1
- package/assets/esri/core/workers/chunks/338570424337be05cef5.js +0 -1
- package/assets/esri/core/workers/chunks/36130910ba141f34531b.js +0 -1
- package/assets/esri/core/workers/chunks/59889855d23baec1adf9.js +0 -1
- package/assets/esri/core/workers/chunks/8d4cc5f1d07b4aa3aea0.js +0 -1
- package/assets/esri/core/workers/chunks/a00bba1c7cbf8cd7892c.js +0 -1
- package/assets/esri/core/workers/chunks/a34a14fd989dbbd3c2d0.js +0 -1
- package/assets/esri/core/workers/chunks/d0014b4a8c013f59b113.js +0 -1
- package/assets/esri/core/workers/chunks/e6784251bbb8b71ead93.js +0 -1
- package/layers/support/ParquetEncodingLocation.d.ts +0 -4
- package/layers/support/ParquetEncodingLocation.js +0 -5
- package/layers/support/ParquetEncodingWkb.d.ts +0 -4
- package/layers/support/ParquetEncodingWkb.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{prefersReducedMotion as i}from"../core/a11yUtils.js";import{createTask as a}from"../core/asyncUtils.js";import o from"../core/Collection.js";import{deprecatedProperty as s}from"../core/deprecate.js";import n from"../core/Logger.js";import{isAbortError as r}from"../core/promiseUtils.js";import{watch as l,initial as d,syncAndInitial as c,whenOnce as g}from"../core/reactiveUtils.js";import{property as h,subclass as m}from"../core/accessorSupport/decorators.js";import{or as u}from"../layers/orientedImagery/transformations/utils.js";import v from"./Expand.js";import p from"./PanoramicVideoViewer.js";import y from"./PanoramicViewer.js";import w from"./Widget.js";import{getAllArcPath as _}from"./OrientedImageryViewer/arcUtils.js";import{getDelegatedEvents as M,defaultImageGeometryField as T,defaultOIObjectIDField as b,segmentArcs as C,featureCircleRadius as A,navigationToolDimensionLength as I,sectorsRadii as f}from"./OrientedImageryViewer/constants.js";import{css as L,navigation as V,navigationToolRotationFrom as k,navigationToolRotationTo as S,root as O}from"./OrientedImageryViewer/css.js";import{loadImageForAttachment as F,getThumbnailPixelBlock as E,isFeatureAttachment as P,renderImageWithRotation as x}from"./OrientedImageryViewer/galleryUtils.js";import H from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import N from"./OrientedImageryViewer/OrientedImageryViewerVisibleElements.js";import{loadAlertComponents as j,Alert as D}from"./OrientedImageryViewer/components/Alert.js";import G from"./OrientedImageryViewer/components/ImageLocationWidget.js";import $ from"./OrientedImageryViewer/components/ImageViewer.js";import B from"./OrientedImageryViewer/components/NavigationAction.js";import{loadNavigationActionsComponents as R,NavigationActionsCollection as W,NavigationActions as U}from"./OrientedImageryViewer/components/NavigationActions.js";import{loadVideoEnhancementComponents as z,renderEnhancementSlider as q,VideoEnhancementTools as Z}from"./OrientedImageryViewer/components/VideoEnhancementTools.js";import{NoImageLoadedError as J}from"./OrientedImageryViewer/navigation/errors.js";import{loadCalciteComponents as K}from"./support/componentsUtils.js";import{globalCss as Q}from"./support/globalCss.js";import{vmEvent as X,messageBundle as Y,tsx as ee}from"./support/widget.js";const te={overlayed:"overlayed"};let ie=class extends w{constructor(e,t){super(e,t),this.dataCaptureEnabled=!1,this.galleryOpened=!1,this.imageEnhancementToolActive=!1,this.videoEnhancementToolActive=!1,this.imageOverlaysOpened=!1,this.navigationToolActive=!1,this.viewModel=new H,this.messagesCommon=null,this.messagesSketch=null,this.pixelMeasurementUnit="meters",this.pixelAreaMeasurementUnit="square-meters",this.showCameraLocations=!1,this.showMapFeatures=!1,this.visibleElements=new N,this._imageOverlaysLoaderTask=null,this._imageMeasurementToolsLoaderTask=null,this._navigationSettingsLoaderTask=null,this._clearMeasurements=()=>{this.viewModel.measureType=null,this.viewModel.triangularMeasurementActive=!1,this.viewModel.clearPreviousMeasurements()},this._clearImageLocation=()=>{this.imageLocationToolActive=!1,this.triangularMeasurementActive=!1},this._navigationToolExpanded=!1,this._navigationTool=null,this._galleryController=new AbortController,this._galleryObserver=new IntersectionObserver(this._lazyLoadImage.bind(this)),this._overlayedLayers=new o,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._handleNavigationSettingsInputChange=(e,t)=>{this.set(`${e}Threshold`,t)},this._handleNavigationSettingsToggle=e=>{this.viewModel.preserveAngle=e},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,this.showMapFeatures)}),`${te.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,o=a?.dataset.action,s=o?.includes("draw")??!1,n="select-feature"===o,r=o!==i;switch(i){case"draw-point":case"draw-polygon":case"draw-polyline":{a&&u(n,s&&r)&&(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":s&&(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._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._settingsToggle=null,this._toggleImageNavigation=async e=>{const t=this.navigationMode;this._closeAllImageTools(),this.navigationMode=t!==e?e:null;const{activeViewer:i}=this.viewModel;if(!i)return;const{mode:a,preserveAngle:o}=this.viewModel;if("default"===a)if("directional"===this.navigationMode){const e=await this._loadNavigationSettings(),t="heading"===o||"both"===o,i="pitch"===o||"both"===o,{messages:a,messagesCommon:s}=this,n=new e({cameraHeadingThreshold:this.cameraHeadingThreshold,cameraPitchThreshold:this.cameraPitchThreshold,uiStrings:{configureNavigation:a.configureNavigation,preserveHeading:a.preserveHeading,preserveHeadingDescription:a.preserveHeadingDescription,preservePitch:a.preservePitch,preservePitchDescription:a.preservePitchDescription,settings:s.settings,thresholdLabel:a.thresholdLabel},onInputChange:this._handleNavigationSettingsInputChange,onToggle:this._handleNavigationSettingsToggle,preserveHeading:t,preservePitch:i});this._settingsToggle=new v({content:n,expandIcon:"configure"}),this.viewModel.activeViewer?.ui.add(this._settingsToggle,{position:"top-left"})}else this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))},this._toggleImageAttributes=()=>{this.viewModel.toggleImageAttributes()},this.navigate=async e=>{let t=null;try{const{currentNode:i}=this.viewModel;if(!i)throw new J;t=await this.viewModel.navigate(i,e)}catch(i){r(i)||n.getLogger(this).error("Error occurred while navigating",i)}return t},this.reset=()=>{this._closeAllImageTools(),this.viewModel.reset()},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),this._handleVideoBrightnessChange=this._handleVideoBrightnessChange.bind(this),this._handleVideoContrastChange=this._handleVideoContrastChange.bind(this),this._handleBrightnessChange=this._handleBrightnessChange.bind(this),this._handleContrastChange=this._handleContrastChange.bind(this),this._handleSharpnessChange=this._handleSharpnessChange.bind(this),this._resetVideoTools=this._resetVideoTools.bind(this),this._toggleEnhancementToolState=this._toggleEnhancementToolState.bind(this)}initialize(){this.addHandles([l(()=>[this.viewModel?.bestFeatureAngle,this._navigationTool],([e,t])=>{t&&this._updateNavigationTool(t)},d),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)},c),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)}},d)])}loadDependencies(){return Promise.all([R(),z(),K({"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"),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")}),j()])}destroy(){this._galleryController.abort(),this._galleryObserver.disconnect(),this.currentBestFeature=null}get accuracyParametersMissing(){return this.viewModel.accuracyParametersMissing}get activeLayer(){return s(n.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){s(n.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeVideoIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?t.videoPaused?"play":"pause":"play"}get activeAudioIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?.videoMuted?"sound-off":"sound"}get cameraHeadingThreshold(){return this.viewModel.cameraHeadingThreshold}set cameraHeadingThreshold(e){this.viewModel.cameraHeadingThreshold=e}get cameraPitchThreshold(){return this.viewModel.cameraPitchThreshold}set cameraPitchThreshold(e){this.viewModel.cameraPitchThreshold=e}get canNavigateSequentially(){const{layer:e}=this;if(!e)return!1;const{fields:t,sequenceOrderField:i}=e;return t.some(({name:e})=>e.toLowerCase()===`${i??"sequenceorder"}`.toLowerCase())}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 depthImageNotSupported(){return this.viewModel.depthImageNotSupported}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get displayMessage(){return this.viewModel.displayMessage}get enhancementToolActive(){return"video"===this.viewModel.mode?this.videoEnhancementToolActive:this.imageEnhancementToolActive}set enhancementToolActive(e){"video"===this.viewModel.mode?this.videoEnhancementToolActive=e:this.imageEnhancementToolActive=e}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 navigationMode(){return this.viewModel.navigationMode}set navigationMode(e){this.viewModel.navigationMode=e}get popupEnabled(){const{popupEnabled:e,state:t}=this.viewModel;return("image-loaded"===t||this.videoLoaded)&&e}get referencePoint(){return this.viewModel.referencePoint??null}get sketchViewModel(){return this.viewModel.sketch}get triangularMeasurementActive(){return this.viewModel.triangularMeasurementActive}set triangularMeasurementActive(e){this.viewModel.triangularMeasurementActive=e}get videoLoaded(){const{mode:e,videoElement:t,panoramicVideoLoaded:i}=this.viewModel;return("video"===e&&!0===t?.loaded||i)??!1}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 ee("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},ee("calcite-action-group",null,this._currentFootprintToggle(),this._additionalFootprintToggle(),this._additionalPointSourcesToggle()),ee("calcite-action-group",null,this._directionToolToggle(),this._mapImageConversionToggle(),this._navigationToolToggle(),this._imageEnhancementsToggle(),this._videoEnhancementsToggle()),ee("calcite-action-group",null,this._measurementToolsToggle(),this._imageGalleryToggle(),this._imageOverlaysToggle(),this._openPopupAction()))}get _activeMeasurementIcon(){const{measureType:e,imageLocationToolActive:t,triangularMeasurementActive:i}=this;if(t)return i?"dual-image-location":"pin-tear";if(i)return"area"===e?"dual-image-area":"dual-image-distance";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,triangularMeasurementActive:i}=this,{groundArea:a,heightAboveGround:o,groundDistance:s,triangulatedAreaHeading:n,triangulatedDistanceHeading:r}=t;if(i)return"area"===e?n:r;switch(e){case"area":return a;case"height":return o;default:return s}}_additionalFootprintToggle(){const{isAdditionalCoverageVisible:e,invalidCameraHeading:t,visibleElements:{additionalFootprintToggle:i}}=this;return i?ee("calcite-action",{active:e,bind:this,class:L.addCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleAdditionalCoverage,text:this.messages.additionalFootprints,title:this.messages.additionalFootprints}):null}_additionalPointSourcesToggle(){const{isAdditionalPointSourcesVisible:e,invalidCameraHeading:t,visibleElements:{additionalCameraLocationsToggle:i}}=this;return i?ee("calcite-action",{active:e,bind:this,class:L.addExpPoints,disabled:t,icon:"circle-area",onclick:this._toggleAdditionalCameraLocations,text:this.messages.additionalCameraLocations,title:this.messages.additionalCameraLocations}):null}get _measurementToggle(){const{viewModel:{state:e,measureType:t,currentBestFeatureMeasurementImage:i},triangularMeasurementActive:a,id:o}=this;if("image-loaded"!==e||!t||a&&!i)return;this._imageMeasurementToolsLoaderTask||this._loadImageMeasurementResources();const s=this._imageMeasurementToolsLoaderTask?.value;return s?ee("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:this._activeMeasurementHeading,id:`${o}-${t}-measurement`,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearMeasurements},ee(s,{measurementType:t,measurementUnitMessages:this.measurementUnitMessages,messages:this.messages,oiViewModel:this.viewModel})):null}get _renderRoot(){const{viewModel:{state:e},triangularMeasurementActive:t}=this;return ee("calcite-panel",{bind:this,class:t?L.viewerContainerMeasurement:L.viewerContainer,heading:this.visibleElements.title?this.messages.title:void 0,loading:e.includes("loading")&&!t},this.visibleElements.menu?this._renderActionBar():null,ee("calcite-shell",null,ee("calcite-panel",null,this._imageViewer,this._panoramicViewer,this._panoramicVideoViewer,this._videoViewer,this._messageBox,this.invalidCameraHeading?null:[this._imageGalleryPanel,this._renderNavigation,this._imageOverlaysPanel()],this._imageEnhancementTools,this._videoEnhancementTools,this._renderSketch()),this._imageViewerTriangular,this._measurementToggle,this._locationToggle,this.invalidCameraHeading?this._renderWarning(this.messages.invalidCameraHeadingWarningTitle,this.messages.invalidCameraHeadingWarningDescription):null,this.depthImageNotSupported?this._renderWarning(this.messages.depthImageNotSupportedTitle,this.messages.depthImageNotSupportedDescription):null))}_currentFootprintToggle(){const{currentCoverageVisible:e,invalidCameraHeading:t}=this,{currentFootprintToggle:i}=this.visibleElements;return i?ee("calcite-action",{active:e,bind:this,class:L.currentCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleCurrentCoverage,text:this.messages.currentFootprint,title:this.messages.currentFootprint}):null}get _imageEnhancementTools(){const{enhancementToolActive:e,viewModel:{brightness:t,contrast:i,sharpness:a,state:o}}=this;return e&&"image-loaded"===o?ee("calcite-panel",{bind:this,class:L.imageEnhancementWrapper,closable:!0,closed:!e,heading:this.messages.imageEnhancement,key:this.messages.imageEnhancement,onCalcitePanelClose:this._toggleEnhancementToolState},ee("div",{class:L.imageEnhancementTools},q({title:this.messages.brightness,value:t,max:10,min:-10,ticks:5,handleChange:this._handleBrightnessChange}),q({title:this.messages.contrast,value:i,max:10,min:-10,ticks:5,handleChange:this._handleContrastChange}),q({title:this.messages.sharpness,value:a,max:1,min:0,ticks:.5,step:.1,handleChange:this._handleSharpnessChange})),ee("calcite-action",{bind:this,icon:"reset",onclick:this._resetImageTools,slot:"header-actions-end",text:this.messagesCommon.reset,title:this.messagesCommon.reset})):null}get _videoEnhancementTools(){const{enhancementToolActive:e,viewModel:{videoViewModel:t,mode:i},messages:{videoEnhancement:a,brightness:o,contrast:s},messagesCommon:{reset:n}}=this;return e&&"video"===i&&t?ee(Z,{brightness:t.videoBrightness,constrast:t.videoContrast,handleBrightnessChange:this._handleVideoBrightnessChange,handleContrastChange:this._handleVideoContrastChange,resetTools:this._resetVideoTools,uiStrings:{videoEnhancement:a,brightness:o,contrast:s,reset:n},videoEnhancementToolActive:e,onClose:this._toggleEnhancementToolState}):null}_imageEnhancementsToggle(){const{state:e,mode:t}=this.viewModel,{imageEnhancement:i}=this.visibleElements;return i&&"video"!==t?ee("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"default"!==t||"image-loaded"!==e,icon:"sliders-horizontal",onclick:this._toggleEnhancementToolState,text:this.messages.imageEnhancement,title:this.messages.imageEnhancement}):null}_videoEnhancementsToggle(){const{mode:e}=this.viewModel,{videoEnhancement:t}=this.messages;return"video"===e?ee("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"video"!==e,icon:"sliders-horizontal",onclick:this._toggleEnhancementToolState,text:t,title:t}):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 ee("calcite-panel",{bind:this,class:L.carousel,closable:!0,closed:!e,disabled:t,heading:this.messages.imageGallery,key:this.messages.imageGallery,onCalcitePanelClose:this._toggleImageGallery},ee("div",{class:L.carouselContainer},this._renderThumbnails))}_imageGalleryToggle(){const{imageGalleryEnabled:e,invalidCameraHeading:t,visibleElements:{imageGallery:i}}=this;return i?ee("calcite-action",{active:this.galleryOpened,bind:this,disabled:!e||t,icon:"images",onclick:this._toggleImageGallery,text:this.messages.imageGallery,title:this.messages.imageGallery}):null}get _imageOverlaysComponent(){const{_imageOverlayMessages:e,_imageOverlaysLoaderTask:t,_overlayedLayers:i,dataCaptureEnabled:o,dataCaptureLayer:s,imageOverlaysOpened:n,showCameraLocations:r,showMapFeatures:l,view:d,layer:c}=this;if(!c)return null;const g=c.imageGeometryField?.length?c.imageGeometryField:T,h=c.imageReferenceField?.length?c.imageReferenceField:b;t||(this._imageOverlaysLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/ImageOverlays.js")).default));const m=this._imageOverlaysLoaderTask?.value;return m?ee(m,{closed:!n,dataCaptureEnabled:o,dataCaptureLayer:s,imageGeometryField:g,imageReferenceField:h,messages:e,overlayedLayers:i,showCameraLocations:r,showMapFeatures:l,view:d,onDataCaptureLayerChanged:this._handleDataCaptureLayerChange,onFilterCapturedFeatures:this.viewModel.filterCapturedFeatures,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({[L.imageOverlaysContainer]:!0,[Q.hidden]:!e||"image-loaded"!==t});return ee("div",{class:i,key:this.messages.imageOverlays},this._imageOverlaysComponent)}_imageOverlaysToggle(){const{viewModel:{state:e},imageOverlaysOpened:t,invalidCameraHeading:i,visibleElements:{imageOverlays:a}}=this;return a?ee("calcite-action",{active:t,bind:this,disabled:"image-loaded"!==e||i,icon:"layers",onclick:this._toggleImageOverlays,text:this.messages.imageOverlays,title:this.messages.imageOverlays}):null}get _imageViewer(){const{displayMessage:e,loadImageViewer:t,mode:i,clickAction:a,state:o}=this.viewModel,s=null!=e||"default"!==i||o.includes("loading"),{messages:{end:n,next:r,previous:l,start:d}}=this;return ee($,{afterCreate:t,clickAction:a,navigationEnabled:!s&&null!==this.navigationMode,navigationViewModel:this.viewModel,uiStrings:{end:n,next:r,previous:l,start:d},visible:!s})}get _imageViewerTriangular(){const{messages:e,triangularMeasurementActive:t}=this,{displayMessage:i,storeImageMeasurementViewer:a,storePanoramicMeasurementViewer:o,mode:s,state:n,clickAction:r}=this.viewModel,l=null!=i||"none"===s||"video"===s,d=this.classes({[L.viewer]:!l,[L.viewerHidden]:l});return t?ee("calcite-panel",{class:L.viewerContainerMeasurement,heading:e.measurementViewerHeading,loading:n.includes("loading")},ee("calcite-panel",{bind:this,class:d},"default"===s?ee($,{afterCreate:a,clickAction:r,uiStrings:e}):ee(y,{afterCreate:o,clickAction:r,uiStrings:e}))):null}get _videoViewer(){const{mode:e,loadVideoViewer:t,videoViewModel:i}=this.viewModel,{control:a,reset:o}=this.messagesCommon,{mute:s,unmute:n}=this.messages,r="video"!==e,l=this.classes({[L.viewer]:!r,[L.viewerHidden]:r}),d="esri-image-viewer";return ee("calcite-panel",{bind:this,class:l},ee("calcite-panel",{afterCreate:t,class:this.classes(Q.widget,d)}),ee("calcite-slider",{bind:this,labelHandles:!0,labelTicks:!0,max:i?.videoDuration,minLabel:"0",value:i?.currentTime??0,onCalciteSliderChange:this._handleVideoSeek}),ee("calcite-action-bar",{expandDisabled:!0,layout:"horizontal"},ee("calcite-action-group",null,ee("calcite-action",{bind:this,icon:this.activeVideoIcon,onclick:()=>i?.playVideoHandler(),text:"Play",title:i?.videoPaused?a.play:a.pause})),ee("calcite-action-group",null,ee("calcite-action",{bind:this,icon:"refresh",onclick:()=>i?.rewindVideoHandler(),text:"Rewind",title:o})),ee("calcite-action-group",null,ee("calcite-action",{bind:this,icon:this.activeAudioIcon,onclick:()=>i?.toggleAudio(),text:"Audio",title:i?.videoMuted?s:n}))))}get _locationToggle(){const{viewModel:{state:e,groundCoordinates:t,groundCoordinatesAccuracy:i,triangulatedPoint:a},imageLocationToolActive:o,triangularMeasurementActive:s,messages:{groundLocation:n,triangulatedLocationHeading:r}}=this;if("image-loaded"!==e||!t||!o)return;let l=t;if(s){if(!a)return;l=a}return ee("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:s?r:n,id:n,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearImageLocation},ee(G,{accuracy:i,groundCoordinates:l,messages:this.messages}))}_mapImageConversionToggle(){const{mapImageConversionToolState:e,viewModel:{state:t,disabled:i},invalidCameraHeading:a,visibleElements:{mapImageConversionTool:o}}=this;return o?ee("calcite-action",{active:e,bind:this,disabled:"image-loaded"!==t||a||i,icon:"image-pin",onclick:this._toggleMapImageConversionToolState,text:this.messages.mapImageConversionTool,title:this.messages.mapImageConversionTool}):null}_measurementToolsToggle(){const{_activeMeasurementIcon:e,measureType:t,viewModel:i,accuracyParametersMissing:a,messages:o,triangularMeasurementActive:s,visibleElements:{measurementTools:n}}=this,{state:r}=i,{measurementTools:l,groundDistance:d,groundArea:c,heightAboveGround:g,groundLocation:h,triangulatedDistanceHeading:m,triangulatedAreaHeading:u,triangulatedLocationHeading:v}=o;return n?ee("calcite-dropdown",{disabled:a,key:"measurement-tools",maxItems:5,title:l,width:"m"},ee("calcite-action",{bind:this,disabled:"image-loaded"!==r||a,icon:e,slot:"trigger",text:l}),ee("calcite-dropdown-group",null,ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-line",key:"distance-measurement",onclick:e=>this._toggleMeasurementSketch(e,"distance"),selected:"distance"===t&&!s},d),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-area",key:"area-measurement",onclick:e=>this._toggleMeasurementSketch(e,"area"),selected:"area"===t&&!s},c),ee("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},g),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"pin-tear",key:"surface-location",onclick:this._toggleLocationTool,selected:!!this.imageLocationToolActive&&!s},h),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"dual-image-location",key:"triangular-location",selected:!!s&&this.imageLocationToolActive,onCalciteDropdownItemSelect:this._toggleTriangularLocation},v),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"dual-image-distance",key:"triangular-measurement-distance",selected:!!s&&"distance"===this.measureType,onCalciteDropdownItemSelect:this._toggleTriangularDistanceMeasurements},m),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"dual-image-area",key:"triangular-measurement-area",selected:!!s&&"area"===this.measureType,onCalciteDropdownItemSelect:this._toggleTriangularAreaMeasurements},u))):null}get _messageBox(){const{messages:e,viewModel:{displayMessage:i,mode:a}}=this;if(!i||"video"===a)return null;const{data:o,key:s,map:n}=i,r=`${n?t(e[s],n):e[s]}`;return ee("span",{class:L.messageBox},o?`${r} ${o}`:r)}async _loadNavigationSettings(){return this._navigationSettingsLoaderTask||(this._navigationSettingsLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/NavigationSettings.js")).default)),await this._navigationSettingsLoaderTask.promise}_navigationToolToggle(){const{state:e}=this.viewModel,{visibleElements:{navigationTool:t},videoLoaded:i}=this;return t?ee("calcite-action",{active:this.navigationToolActive,bind:this,disabled:"image-loaded"!==e&&!i||this.invalidCameraHeading,icon:"explore",onclick:this._toggleNavigationTool,text:this.messages.navigationTool,title:this.messages.navigationTool}):null}_directionToolToggle(){const{state:e}=this.viewModel,{visibleElements:{directionalNavigation:t,sequentialNavigation:i}}=this,a=new W;t&&a.push(new B({active:"directional"===this.navigationMode,disabled:"image-loaded"!==e||this.invalidCameraHeading,icon:"directional-navigation",onclick:()=>{this._toggleImageNavigation("directional")},text:this.messages.directionalNavigation,title:this.messages.directionalNavigationDescription})),i&&a.push(new B({active:"sequential"===this.navigationMode,disabled:"image-loaded"!==e||this.invalidCameraHeading||!this.canNavigateSequentially,icon:"sequential-navigation",onclick:()=>{this._toggleImageNavigation("sequential")},text:this.messages.sequentialNavigation,title:this.messages.sequentialNavigationDescription}));return t||i?ee(U,{actions:a,activeAction:a.items.find(e=>e.active),icon:"absolute-direction",label:this.messages.imageNavigation,scale:"m",title:this.messages.imageNavigation}):null}_openPopupAction(){const{showPopupsAction:e}=this.visibleElements;return e?ee("calcite-action",{bind:this,disabled:!this.popupEnabled,icon:"popup",onclick:this._toggleImageAttributes,text:this.messages.showPopups,title:this.messages.showPopups}):null}get _panoramicVideoViewer(){const{displayMessage:e,loadPanoramicVideoViewer:t,mode:i,clickAction:a,state:o,currentBestFeature:s}=this.viewModel,n=s?.attributes.imagePath,r=null!=e||"panoramic-video"!==i||o.includes("loading")||!n;return ee(p,{afterCreate:t,clickAction:a,oiViewModel:this.viewModel,videoSource:n,visible:!r})}get _panoramicViewer(){const{displayMessage:e,loadPanoramicViewer:t,mode:i,clickAction:a,state:o}=this.viewModel,{messages:{end:s,next:n,previous:r,start:l}}=this,d=null!=e||"panoramic"!==i||o.includes("loading");return ee(y,{afterCreate:t,clickAction:a,navigationEnabled:!d&&null!==this.navigationMode,navigationViewModel:this.viewModel,uiStrings:{end:s,next:n,previous:r,start:l},visible:!d})}_activateTriangulatedImageLocationTool(){this.navigationToolActive=!0,this.imageLocationToolActive=!0}_activateTriangulatedImageLocationWorkflow(e,t){this._closeAllImageTools(),this.imageLocationToolActive=!0,this.triangularMeasurementActive=!e,this.navigationToolActive=!!t||!t}_closeImageToolsAndToggleNavigation(e,t){this._closeAllImageTools(),this.triangularMeasurementActive=!e,this.navigationToolActive=!t}_resetMeasureTypeAndActivateImageLocationTool(){this.measureType=null,this.imageLocationToolActive=!0}_closeAllImageTools(){this.enhancementToolActive=!1,this.navigationToolActive=!1,this.imageOverlaysOpened=!1,this.galleryOpened=!1,this.measureType=null,this.imageLocationToolActive=!1,this.navigationMode=null,this.triangularMeasurementActive=!1,this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))}_handleBrightnessChange(e){this.viewModel.brightness=e.currentTarget.value??0}_handleVideoBrightnessChange(e){this.viewModel.videoViewModel?.handleVideoBrightnessChange(e.target.value)}_handleContrastChange(e){this.viewModel.contrast=e.currentTarget.value??0}_handleVideoContrastChange(e){this.viewModel.videoViewModel?.handleVideoContrastChange(e.target.value)}_handleVideoSeek(e){const t=this.viewModel?.videoElement?.content;t&&(t.currentTime=e.target.value,t.play())}_handleSharpnessChange(e){this.viewModel.sharpness=e.currentTarget.value??0}_lazyLoadImage(e,t){e.forEach(async e=>{if(e.isIntersecting){const a=e.target,o=a.getAttribute("data-src"),s=a.getAttribute("data-rotation"),l=a.getAttribute("data-objectid"),d=s?parseFloat(s)%360:0,{layer:c,_galleryController:{signal:g}}=this;if(!o||!l)return;let h;try{h=P(o)?await F(c,l,{signal:g}):await E(o,{signal:g})}catch(i){r(i)||n.getLogger("esri.widgets.OrientedImageryViewer").error("#lazyLoadImage()",i)}finally{t.unobserve(a)}if(!h)return;x(h,a,d)}})}_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=a(async()=>{const{default:e}=await import("./OrientedImageryViewer/components/ImageMeasurementWidget.js");return e})}_loadSketchResources(){this._sketchLoaderTask=a(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,t){const{viewModel:{state:i}}=this;return"image-loaded"===i?ee(D,{icon:"exclamation-mark-triangle-f",kind:"warning",message:t,open:!0,title:e,tooltip:t}):null}get _renderNavigation(){const{viewModel:{sectorData:e,navigatorCurrentBestFeature:t,currentBestFeature:a,state:o}}=this;if(!this.container||!a)return null;let s,n,r,l,d;if(t){const{x:e,y:i,direction:a}=t,[o,c,g,h]=C[a];s=`M ${e} ${i} L ${o} ${c} A ${f[2]} ${f[2]} 0 0 1 ${g} ${h} Z`,n=e,l=i,r=C[a][4],d=C[a][5]}const c=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})},h=e=>{e.removeEventListener("click",g)},m=a.attributes.objectId,u=e?.map(e=>e?.items).filter(Boolean).flatMap(e=>e?.map(({x:e,y:t,objectID:i,featureIndexInSector:a,sector:o})=>ee("circle",{afterRemoved:h,class:this.classes(L.feature,{selected:m===i}),cx:e,cy:t,"data-feature-index-in-sector":a,"data-sector":o,key:`${L.feature}-${i}`,onclick:g,r:A}))),v=e=>{e.removeEventListener("click",c)},p=this.classes({[L.navigationWrapper]:!0,[L.navigationZoomed]:this._navigationToolExpanded});return this.navigationToolActive&&("image-loaded"===o||this.videoLoaded)?ee("div",{bind:this,class:p,key:this.messages.navigationTool},ee("svg",{afterCreate:e=>this._storeNavigationToolReference(e),class:i()?V:L.rotateWithAnimation,focusable:"false",height:I,role:"img",width:I,xmlns:"http://www.w3.org/2000/svg"},ee("defs",null,ee("linearGradient",{gradientUnits:"userSpaceOnUse",id:`${this.id}-coverage-fill`,x1:n,x2:r,y1:l,y2:d},ee("stop",{class:L.navigationPathOffset0,offset:0}),ee("stop",{class:L.navigationPathOffset1,offset:1}))),ee("g",null,ee("circle",{class:this.classes(L.sector,L.outerSector),cx:f[3],cy:f[3],onclick:this._scaleNavigationTool,r:f[3]}),ee("circle",{class:L.sector,cx:f[3],cy:f[3],r:f[2]}),ee("circle",{class:L.sector,cx:f[3],cy:f[3],r:f[1]}),ee("circle",{class:L.sector,cx:f[3],cy:f[3],r:f[0]}),ee("path",{class:L.pointer,d:"M 56.5 6.06217782649107 L 60 0 L 63.5 6.06217782649107 Z",key:`${L.pointer}-west`}),ee("path",{class:this.classes(L.pointer,L.north),d:"M 113.93782217350893 56.5 L 120 60 L 113.93782217350893 63.5 Z",key:`${L.pointer}-north`}),ee("path",{class:L.pointer,d:"M 56.5 113.93782217350893 L 60 120 L 63.5 113.93782217350893 Z",key:`${L.pointer}-east`}),ee("path",{class:L.pointer,d:"M 6.06217782649107 56.5 L 0 60 L 6.06217782649107 63.5 Z",key:`${L.pointer}-south`}),ee("path",{class:this.classes(L.sector,L.sectorSeparator),d:"M 23.937554159486076 23.937554159486076 L 96.06244584051393 96.06244584051393 M 23.937554159486076 96.06244584051393 L 96.06244584051393 23.937554159486076",key:L.sectorSeparator}),_([f[2],f[1],f[0]],f[3],f[3]).map((t,i)=>ee("path",{afterRemoved:v,class:this.classes(L.sector,e?.[i]?.length?L.sectorEnabled:L.sectorDisabled),d:t,"data-sector":`${i}`,key:`${L.sector}-${i}`,onclick:c})),ee("path",{class:this.classes(L.sector,L.sectorCross),d:"M 56.4 56.4 L 63.53 63.53 M 63.53 56.4 L 56.4 63.53",key:L.sectorCross}),u,a.attributes.cameraPitch>=5&&s?ee("path",{class:L.selectedFeaturePath,d:s,fill:`url(#${this.id}-coverage-fill)`,key:L.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",o=this._sketchLoaderTask.value;return ee("div",{class:L.sketchTools},ee(o,{icon:a,messages:this._imageSketchToolsMessages,type:i,onAction:this._onAction}))}get _renderThumbnails(){const{currentBestFeature:e,thumbnails:t}=this.viewModel;return e?ee("div",{class:L.carouselContent},t?.items.map(({url:t,objectId:i,rotation:a},o)=>ee("div",{class:`${L.carouselItemWrapper}${e.attributes.objectId===i?"--selected":""}`,key:`${L.carouselItemWrapper}-${o}`},ee("canvas",{afterCreate:this._registerGalleryItem,afterRemoved:this._unregisterGalleryItem,alt:`thumbnail-${i}`,class:L.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}_resetVideoTools(){this.viewModel.videoViewModel?.resetVideoEnhancementTools()}_storeNavigationToolReference(e){this._navigationTool=e}_toggleAdditionalCameraLocations(){this.isAdditionalPointSourcesVisible=!this.isAdditionalPointSourcesVisible}_toggleAdditionalCoverage(){this.isAdditionalCoverageVisible=!this.isAdditionalCoverageVisible}_toggleCurrentCoverage(){this.currentCoverageVisible=!this.currentCoverageVisible}_toggleEnhancementToolState(e){e.stopPropagation();const t=this.enhancementToolActive;this._closeAllImageTools(),this.enhancementToolActive=!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,i=this.triangularMeasurementActive&&t;this._closeAllImageTools(),this.imageLocationToolActive=i||!t,e.stopPropagation()}_toggleMeasurementSketch(e,t){e.stopPropagation();const i=this.measureType,a=this.triangularMeasurementActive;this._closeAllImageTools(),this.measureType=i!==t||a?t:null,this.measureType===t&&(this.viewModel.displayNewMeasurementButton=!0)}_toggleNavigationTool(){const e=this.navigationToolActive;this._closeAllImageTools(),this.navigationToolActive=!e}_toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_toggleTriangularAreaMeasurements(){this._toggleTriangularMeasurements("area")}_toggleTriangularDistanceMeasurements(){this._toggleTriangularMeasurements("distance")}_toggleTriangularLocation(){const e=this.triangularMeasurementActive,t=this.navigationToolActive;e?null===this.measureType?this.imageLocationToolActive?this._closeImageToolsAndToggleNavigation(e,t):this._activateTriangulatedImageLocationTool():this._resetMeasureTypeAndActivateImageLocationTool():this._activateTriangulatedImageLocationWorkflow(e,t)}_toggleTriangularMeasurements(e){const t=this.triangularMeasurementActive,i=this.viewModel.measureType,a=this.navigationToolActive;t?e===i?(this._closeAllImageTools(),this.triangularMeasurementActive=!t,this.navigationToolActive=!a):(this.imageLocationToolActive=!1,this.measureType=e):(this._closeAllImageTools(),this.measureType=e,this.triangularMeasurementActive=!t,this.navigationToolActive=!!a||!a)}_unregisterGalleryItem(e){this._galleryObserver.unobserve(e)}_updateNavigationTool(e){const{previousFeatureAngle:t,bestFeatureAngle:i}=this.viewModel,a=(i-t+540)%360-180;e.style.setProperty(k,`${t}deg`),e.style.setProperty(S,`${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(`${te.overlayed}-${e.id}`),this.addHandles(l(()=>e.visible,()=>{this.viewModel.toggleOverlayMapFeatures(e.id,e.visible,this.showMapFeatures)}),`${te.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(`${te.overlayed}-${e}`),this._overlayedLayers.remove(this._overlayedLayers.find(t=>t.id===e)),this.viewModel.removeOverlayedGraphicsOnImage(e)}resetImage(){this.viewModel.resetImage()}render(){return ee("div",{class:this.classes(Q.widget,O)},this._renderRoot)}async showImageByObjectId(e,t){return this.viewModel.showImageByObjectId(e,t)}async startDataCapture(e){return this.viewModel.startDataCapture(e)}async stopDataCapture(e){return this.viewModel.stopDataCapture(e)}updateSuitabilities(e){this.viewModel.updateSuitabilities(e)}};e([h({readOnly:!0})],ie.prototype,"accuracyParametersMissing",null),e([h()],ie.prototype,"activeLayer",null),e([h()],ie.prototype,"activeVideoIcon",null),e([h()],ie.prototype,"activeAudioIcon",null),e([h()],ie.prototype,"cameraHeadingThreshold",null),e([h()],ie.prototype,"cameraPitchThreshold",null),e([h()],ie.prototype,"canNavigateSequentially",null),e([h()],ie.prototype,"currentBestFeature",null),e([h()],ie.prototype,"currentCoverageVisible",null),e([h()],ie.prototype,"dataCaptureEnabled",void 0),e([h()],ie.prototype,"dataCaptureLayer",null),e([h()],ie.prototype,"depthImageNotSupported",null),e([h()],ie.prototype,"disabled",null),e([h()],ie.prototype,"enhancementToolActive",null),e([h()],ie.prototype,"features",null),e([h()],ie.prototype,"imagePointsInView",null),e([h()],ie.prototype,"galleryOpened",void 0),e([h()],ie.prototype,"icon",null),e([h()],ie.prototype,"imageEnhancementToolActive",void 0),e([h()],ie.prototype,"videoEnhancementToolActive",void 0),e([h({readOnly:!0})],ie.prototype,"imageGalleryEnabled",null),e([h()],ie.prototype,"imageLocationToolActive",null),e([h()],ie.prototype,"imageOverlaysOpened",void 0),e([h({readOnly:!0})],ie.prototype,"invalidCameraHeading",null),e([h()],ie.prototype,"isAdditionalCoverageVisible",null),e([h()],ie.prototype,"isAdditionalPointSourcesVisible",null),e([h()],ie.prototype,"mapImageConversionToolState",null),e([h()],ie.prototype,"measureType",null),e([h()],ie.prototype,"layer",null),e([h()],ie.prototype,"navigationToolActive",void 0),e([h()],ie.prototype,"navigationMode",null),e([X(M()),h({type:H})],ie.prototype,"viewModel",void 0),e([h(),Y("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],ie.prototype,"messages",void 0),e([h(),Y("esri/core/t9n/Units")],ie.prototype,"measurementUnitMessages",void 0),e([h(),Y("esri/t9n/common")],ie.prototype,"messagesCommon",void 0),e([h(),Y("esri/widgets/Sketch/t9n/Sketch")],ie.prototype,"messagesSketch",void 0),e([h()],ie.prototype,"pixelMeasurementUnit",void 0),e([h()],ie.prototype,"pixelAreaMeasurementUnit",void 0),e([h({readOnly:!0})],ie.prototype,"popupEnabled",null),e([h()],ie.prototype,"referencePoint",null),e([h()],ie.prototype,"showCameraLocations",void 0),e([h()],ie.prototype,"showMapFeatures",void 0),e([X(["create","delete","redo","undo","update"]),h({readOnly:!0})],ie.prototype,"sketchViewModel",null),e([h()],ie.prototype,"triangularMeasurementActive",null),e([h()],ie.prototype,"videoLoaded",null),e([h()],ie.prototype,"view",null),e([h({type:N,nonNullable:!0})],ie.prototype,"visibleElements",void 0),e([h()],ie.prototype,"determineWorkflowForFeature",null),e([h()],ie.prototype,"updateFootprint",null),e([h()],ie.prototype,"_activeMeasurementIcon",null),e([h()],ie.prototype,"_activeMeasurementHeading",null),e([h()],ie.prototype,"_imageOverlaysLoaderTask",void 0),e([h()],ie.prototype,"_imageMeasurementToolsLoaderTask",void 0),e([h()],ie.prototype,"_navigationSettingsLoaderTask",void 0),e([h()],ie.prototype,"_measurementToggle",null),e([h()],ie.prototype,"_renderRoot",null),e([h()],ie.prototype,"_imageEnhancementTools",null),e([h()],ie.prototype,"_videoEnhancementTools",null),e([h()],ie.prototype,"_imageGalleryPanel",null),e([h()],ie.prototype,"_imageGalleryContext",null),e([h()],ie.prototype,"_imageOverlaysComponent",null),e([h()],ie.prototype,"_imageOverlayMessages",null),e([h()],ie.prototype,"_imageSketchToolsMessages",null),e([h()],ie.prototype,"_imageViewer",null),e([h()],ie.prototype,"_imageViewerTriangular",null),e([h()],ie.prototype,"_videoViewer",null),e([h()],ie.prototype,"_locationToggle",null),e([h()],ie.prototype,"_messageBox",null),e([h()],ie.prototype,"_navigationToolExpanded",void 0),e([h()],ie.prototype,"_navigationTool",void 0),e([h()],ie.prototype,"_panoramicVideoViewer",null),e([h()],ie.prototype,"_panoramicViewer",null),e([h()],ie.prototype,"_renderNavigation",null),e([h()],ie.prototype,"_renderThumbnails",null),e([h()],ie.prototype,"_sketchLoaderTask",void 0),ie=e([m("esri.widgets.OrientedImageryViewer")],ie);const ae=ie;export{ae as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{prefersReducedMotion as i}from"../core/a11yUtils.js";import{createTask as a}from"../core/asyncUtils.js";import o from"../core/Collection.js";import{deprecatedProperty as s}from"../core/deprecate.js";import n from"../core/Logger.js";import{isAbortError as r}from"../core/promiseUtils.js";import{watch as l,initial as d,syncAndInitial as c,whenOnce as g}from"../core/reactiveUtils.js";import{property as h,subclass as m}from"../core/accessorSupport/decorators.js";import{or as u}from"../layers/orientedImagery/transformations/utils.js";import v from"./Expand.js";import p from"./PanoramicVideoViewer.js";import y from"./PanoramicViewer.js";import w from"./Widget.js";import{getAllArcPath as _}from"./OrientedImageryViewer/arcUtils.js";import{getDelegatedEvents as M,defaultImageGeometryField as T,defaultOIObjectIDField as b,segmentArcs as C,featureCircleRadius as A,navigationToolDimensionLength as I,sectorsRadii as f}from"./OrientedImageryViewer/constants.js";import{css as L,navigation as V,navigationToolRotationFrom as k,navigationToolRotationTo as S,root as O}from"./OrientedImageryViewer/css.js";import{loadImageForAttachment as F,getThumbnailPixelBlock as E,isFeatureAttachment as P,renderImageWithRotation as x}from"./OrientedImageryViewer/galleryUtils.js";import H from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import N from"./OrientedImageryViewer/OrientedImageryViewerVisibleElements.js";import{loadAlertComponents as j,Alert as D}from"./OrientedImageryViewer/components/Alert.js";import G from"./OrientedImageryViewer/components/ImageLocationWidget.js";import $ from"./OrientedImageryViewer/components/ImageViewer.js";import B from"./OrientedImageryViewer/components/NavigationAction.js";import{loadNavigationActionsComponents as R,NavigationActionsCollection as W,NavigationActions as U}from"./OrientedImageryViewer/components/NavigationActions.js";import{loadVideoEnhancementComponents as z,renderEnhancementSlider as q,VideoEnhancementTools as Z}from"./OrientedImageryViewer/components/VideoEnhancementTools.js";import{NoImageLoadedError as J}from"./OrientedImageryViewer/navigation/errors.js";import{loadCalciteComponents as K}from"./support/componentsUtils.js";import{globalCss as Q}from"./support/globalCss.js";import{vmEvent as X,messageBundle as Y,tsx as ee}from"./support/widget.js";const te={overlayed:"overlayed"};let ie=class extends w{constructor(e,t){super(e,t),this.dataCaptureEnabled=!1,this.galleryOpened=!1,this.imageEnhancementToolActive=!1,this.videoEnhancementToolActive=!1,this.imageOverlaysOpened=!1,this.navigationToolActive=!1,this.viewModel=new H,this.messagesCommon=null,this.messagesSketch=null,this.pixelMeasurementUnit="meters",this.pixelAreaMeasurementUnit="square-meters",this.showCameraLocations=!1,this.showMapFeatures=!1,this.visibleElements=new N,this._imageOverlaysLoaderTask=null,this._imageMeasurementToolsLoaderTask=null,this._navigationSettingsLoaderTask=null,this._clearMeasurements=()=>{this.viewModel.measureType=null,this.viewModel.triangularMeasurementActive=!1,this.viewModel.clearPreviousMeasurements()},this._clearImageLocation=()=>{this.imageLocationToolActive=!1,this.triangularMeasurementActive=!1},this._navigationToolExpanded=!1,this._navigationTool=null,this._galleryController=new AbortController,this._galleryObserver=new IntersectionObserver(this._lazyLoadImage.bind(this)),this._overlayedLayers=new o,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._handleNavigationSettingsInputChange=(e,t)=>{this.set(`${e}Threshold`,t)},this._handleNavigationSettingsToggle=e=>{this.viewModel.preserveAngle=e},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,this.showMapFeatures)}),`${te.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,o=a?.dataset.action,s=o?.includes("draw")??!1,n="select-feature"===o,r=o!==i;switch(i){case"draw-point":case"draw-polygon":case"draw-polyline":{a&&u(n,s&&r)&&(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":s&&(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._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._settingsToggle=null,this._toggleImageNavigation=async e=>{const t=this.navigationMode;this._closeAllImageTools(),this.navigationMode=t!==e?e:null;const{activeViewer:i}=this.viewModel;if(!i)return;const{mode:a,preserveAngle:o}=this.viewModel;if("default"===a)if("directional"===this.navigationMode){const e=await this._loadNavigationSettings(),t="heading"===o||"both"===o,i="pitch"===o||"both"===o,{messages:a,messagesCommon:s}=this,n=new e({cameraHeadingThreshold:this.cameraHeadingThreshold,cameraPitchThreshold:this.cameraPitchThreshold,uiStrings:{configureNavigation:a.configureNavigation,preserveHeading:a.preserveHeading,preserveHeadingDescription:a.preserveHeadingDescription,preservePitch:a.preservePitch,preservePitchDescription:a.preservePitchDescription,settings:s.settings,thresholdLabel:a.thresholdLabel},onInputChange:this._handleNavigationSettingsInputChange,onToggle:this._handleNavigationSettingsToggle,preserveHeading:t,preservePitch:i});this._settingsToggle=new v({content:n,expandIcon:"configure"}),this.viewModel.activeViewer?.ui.add(this._settingsToggle,{position:"top-left"})}else this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))},this._toggleImageAttributes=()=>{this.viewModel.toggleImageAttributes()},this.navigate=async e=>{let t=null;try{const{currentNode:i}=this.viewModel;if(!i)throw new J;t=await this.viewModel.navigate(i,e)}catch(i){r(i)||n.getLogger(this).error("Error occurred while navigating",i)}return t},this.reset=()=>{this._closeAllImageTools(),this.viewModel.reset()},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),this._handleVideoBrightnessChange=this._handleVideoBrightnessChange.bind(this),this._handleVideoContrastChange=this._handleVideoContrastChange.bind(this),this._handleBrightnessChange=this._handleBrightnessChange.bind(this),this._handleContrastChange=this._handleContrastChange.bind(this),this._handleSharpnessChange=this._handleSharpnessChange.bind(this),this._resetVideoTools=this._resetVideoTools.bind(this),this._toggleEnhancementToolState=this._toggleEnhancementToolState.bind(this)}initialize(){this.addHandles([l(()=>[this.viewModel?.bestFeatureAngle,this._navigationTool],([e,t])=>{t&&this._updateNavigationTool(t)},d),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)},c),l(()=>({feature:this.currentBestFeature,showMapFeatures:this.showMapFeatures,state:this.viewModel.state}),async(e,t)=>{if(e.showMapFeatures!==t?.showMapFeatures&&await 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)}},d)])}loadDependencies(){return Promise.all([R(),z(),K({"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"),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")}),j()])}destroy(){this._galleryController.abort(),this._galleryObserver.disconnect(),this.currentBestFeature=null}get accuracyParametersMissing(){return this.viewModel.accuracyParametersMissing}get activeLayer(){return s(n.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){s(n.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeVideoIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?t.videoPaused?"play":"pause":"play"}get activeAudioIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?.videoMuted?"sound-off":"sound"}get cameraHeadingThreshold(){return this.viewModel.cameraHeadingThreshold}set cameraHeadingThreshold(e){this.viewModel.cameraHeadingThreshold=e}get cameraPitchThreshold(){return this.viewModel.cameraPitchThreshold}set cameraPitchThreshold(e){this.viewModel.cameraPitchThreshold=e}get canNavigateSequentially(){const{layer:e}=this;if(!e)return!1;const{fields:t,sequenceOrderField:i}=e;return t.some(({name:e})=>e.toLowerCase()===`${i??"sequenceorder"}`.toLowerCase())}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 depthImageNotSupported(){return this.viewModel.depthImageNotSupported}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get displayMessage(){return this.viewModel.displayMessage}get enhancementToolActive(){return"video"===this.viewModel.mode?this.videoEnhancementToolActive:this.imageEnhancementToolActive}set enhancementToolActive(e){"video"===this.viewModel.mode?this.videoEnhancementToolActive=e:this.imageEnhancementToolActive=e}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 navigationMode(){return this.viewModel.navigationMode}set navigationMode(e){this.viewModel.navigationMode=e}get popupEnabled(){const{popupEnabled:e,state:t}=this.viewModel;return("image-loaded"===t||this.videoLoaded)&&e}get referencePoint(){return this.viewModel.referencePoint??null}get sketchViewModel(){return this.viewModel.sketch}get triangularMeasurementActive(){return this.viewModel.triangularMeasurementActive}set triangularMeasurementActive(e){this.viewModel.triangularMeasurementActive=e}get videoLoaded(){const{mode:e,videoElement:t,panoramicVideoLoaded:i}=this.viewModel;return("video"===e&&!0===t?.loaded||i)??!1}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 ee("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},ee("calcite-action-group",null,this._currentFootprintToggle(),this._additionalFootprintToggle(),this._additionalPointSourcesToggle()),ee("calcite-action-group",null,this._directionToolToggle(),this._mapImageConversionToggle(),this._navigationToolToggle(),this._imageEnhancementsToggle(),this._videoEnhancementsToggle()),ee("calcite-action-group",null,this._measurementToolsToggle(),this._imageGalleryToggle(),this._imageOverlaysToggle(),this._openPopupAction()))}get _activeMeasurementIcon(){const{measureType:e,imageLocationToolActive:t,triangularMeasurementActive:i}=this;if(t)return i?"dual-image-location":"pin-tear";if(i)return"area"===e?"dual-image-area":"dual-image-distance";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,triangularMeasurementActive:i}=this,{groundArea:a,heightAboveGround:o,groundDistance:s,triangulatedAreaHeading:n,triangulatedDistanceHeading:r}=t;if(i)return"area"===e?n:r;switch(e){case"area":return a;case"height":return o;default:return s}}_additionalFootprintToggle(){const{isAdditionalCoverageVisible:e,invalidCameraHeading:t,visibleElements:{additionalFootprintToggle:i}}=this;return i?ee("calcite-action",{active:e,bind:this,class:L.addCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleAdditionalCoverage,text:this.messages.additionalFootprints,title:this.messages.additionalFootprints}):null}_additionalPointSourcesToggle(){const{isAdditionalPointSourcesVisible:e,invalidCameraHeading:t,visibleElements:{additionalCameraLocationsToggle:i}}=this;return i?ee("calcite-action",{active:e,bind:this,class:L.addExpPoints,disabled:t,icon:"circle-area",onclick:this._toggleAdditionalCameraLocations,text:this.messages.additionalCameraLocations,title:this.messages.additionalCameraLocations}):null}get _measurementToggle(){const{viewModel:{state:e,measureType:t,currentBestFeatureMeasurementImage:i},triangularMeasurementActive:a,id:o}=this;if("image-loaded"!==e||!t||a&&!i)return;this._imageMeasurementToolsLoaderTask||this._loadImageMeasurementResources();const s=this._imageMeasurementToolsLoaderTask?.value;return s?ee("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:this._activeMeasurementHeading,id:`${o}-${t}-measurement`,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearMeasurements},ee(s,{measurementType:t,measurementUnitMessages:this.measurementUnitMessages,messages:this.messages,oiViewModel:this.viewModel})):null}get _renderRoot(){const{viewModel:{state:e},triangularMeasurementActive:t}=this;return ee("calcite-panel",{bind:this,class:t?L.viewerContainerMeasurement:L.viewerContainer,heading:this.visibleElements.title?this.messages.title:void 0,loading:e.includes("loading")&&!t},this.visibleElements.menu?this._renderActionBar():null,ee("calcite-shell",null,ee("calcite-panel",null,this._imageViewer,this._panoramicViewer,this._panoramicVideoViewer,this._videoViewer,this._messageBox,this.invalidCameraHeading?null:[this._imageGalleryPanel,this._renderNavigation,this._imageOverlaysPanel()],this._imageEnhancementTools,this._videoEnhancementTools,this._renderSketch()),this._imageViewerTriangular,this._measurementToggle,this._locationToggle,this.invalidCameraHeading?this._renderWarning(this.messages.invalidCameraHeadingWarningTitle,this.messages.invalidCameraHeadingWarningDescription):null,this.depthImageNotSupported?this._renderWarning(this.messages.depthImageNotSupportedTitle,this.messages.depthImageNotSupportedDescription):null))}_currentFootprintToggle(){const{currentCoverageVisible:e,invalidCameraHeading:t}=this,{currentFootprintToggle:i}=this.visibleElements;return i?ee("calcite-action",{active:e,bind:this,class:L.currentCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleCurrentCoverage,text:this.messages.currentFootprint,title:this.messages.currentFootprint}):null}get _imageEnhancementTools(){const{enhancementToolActive:e,viewModel:{brightness:t,contrast:i,sharpness:a,state:o}}=this;return e&&"image-loaded"===o?ee("calcite-panel",{bind:this,class:L.imageEnhancementWrapper,closable:!0,closed:!e,heading:this.messages.imageEnhancement,key:this.messages.imageEnhancement,onCalcitePanelClose:this._toggleEnhancementToolState},ee("div",{class:L.imageEnhancementTools},q({title:this.messages.brightness,value:t,max:10,min:-10,ticks:5,handleChange:this._handleBrightnessChange}),q({title:this.messages.contrast,value:i,max:10,min:-10,ticks:5,handleChange:this._handleContrastChange}),q({title:this.messages.sharpness,value:a,max:1,min:0,ticks:.5,step:.1,handleChange:this._handleSharpnessChange})),ee("calcite-action",{bind:this,icon:"reset",onclick:this._resetImageTools,slot:"header-actions-end",text:this.messagesCommon.reset,title:this.messagesCommon.reset})):null}get _videoEnhancementTools(){const{enhancementToolActive:e,viewModel:{videoViewModel:t,mode:i},messages:{videoEnhancement:a,brightness:o,contrast:s},messagesCommon:{reset:n}}=this;return e&&"video"===i&&t?ee(Z,{brightness:t.videoBrightness,constrast:t.videoContrast,handleBrightnessChange:this._handleVideoBrightnessChange,handleContrastChange:this._handleVideoContrastChange,resetTools:this._resetVideoTools,uiStrings:{videoEnhancement:a,brightness:o,contrast:s,reset:n},videoEnhancementToolActive:e,onClose:this._toggleEnhancementToolState}):null}_imageEnhancementsToggle(){const{state:e,mode:t}=this.viewModel,{imageEnhancement:i}=this.visibleElements;return i&&"video"!==t?ee("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"default"!==t||"image-loaded"!==e,icon:"sliders-horizontal",onclick:this._toggleEnhancementToolState,text:this.messages.imageEnhancement,title:this.messages.imageEnhancement}):null}_videoEnhancementsToggle(){const{mode:e}=this.viewModel,{videoEnhancement:t}=this.messages;return"video"===e?ee("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"video"!==e,icon:"sliders-horizontal",onclick:this._toggleEnhancementToolState,text:t,title:t}):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 ee("calcite-panel",{bind:this,class:L.carousel,closable:!0,closed:!e,disabled:t,heading:this.messages.imageGallery,key:this.messages.imageGallery,onCalcitePanelClose:this._toggleImageGallery},ee("div",{class:L.carouselContainer},this._renderThumbnails))}_imageGalleryToggle(){const{imageGalleryEnabled:e,invalidCameraHeading:t,visibleElements:{imageGallery:i}}=this;return i?ee("calcite-action",{active:this.galleryOpened,bind:this,disabled:!e||t,icon:"images",onclick:this._toggleImageGallery,text:this.messages.imageGallery,title:this.messages.imageGallery}):null}get _imageOverlaysComponent(){const{_imageOverlayMessages:e,_imageOverlaysLoaderTask:t,_overlayedLayers:i,dataCaptureEnabled:o,dataCaptureLayer:s,imageOverlaysOpened:n,showCameraLocations:r,showMapFeatures:l,view:d,layer:c}=this;if(!c)return null;const g=c.imageGeometryField?.length?c.imageGeometryField:T,h=c.imageReferenceField?.length?c.imageReferenceField:b;t||(this._imageOverlaysLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/ImageOverlays.js")).default));const m=this._imageOverlaysLoaderTask?.value;return m?ee(m,{closed:!n,dataCaptureEnabled:o,dataCaptureLayer:s,imageGeometryField:g,imageReferenceField:h,messages:e,overlayedLayers:i,showCameraLocations:r,showMapFeatures:l,view:d,onDataCaptureLayerChanged:this._handleDataCaptureLayerChange,onFilterCapturedFeatures:this.viewModel.filterCapturedFeatures,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({[L.imageOverlaysContainer]:!0,[Q.hidden]:!e||"image-loaded"!==t});return ee("div",{class:i,key:this.messages.imageOverlays},this._imageOverlaysComponent)}_imageOverlaysToggle(){const{viewModel:{state:e},imageOverlaysOpened:t,invalidCameraHeading:i,visibleElements:{imageOverlays:a}}=this;return a?ee("calcite-action",{active:t,bind:this,disabled:"image-loaded"!==e||i,icon:"layers",onclick:this._toggleImageOverlays,text:this.messages.imageOverlays,title:this.messages.imageOverlays}):null}get _imageViewer(){const{displayMessage:e,loadImageViewer:t,mode:i,clickAction:a,state:o}=this.viewModel,s=null!=e||"default"!==i||o.includes("loading"),{messages:{end:n,next:r,previous:l,start:d}}=this;return ee($,{afterCreate:t,clickAction:a,navigationEnabled:!s&&null!==this.navigationMode,navigationViewModel:this.viewModel,uiStrings:{end:n,next:r,previous:l,start:d},visible:!s})}get _imageViewerTriangular(){const{messages:e,triangularMeasurementActive:t}=this,{displayMessage:i,storeImageMeasurementViewer:a,storePanoramicMeasurementViewer:o,mode:s,state:n,clickAction:r}=this.viewModel,l=null!=i||"none"===s||"video"===s,d=this.classes({[L.viewer]:!l,[L.viewerHidden]:l});return t?ee("calcite-panel",{class:L.viewerContainerMeasurement,heading:e.measurementViewerHeading,loading:n.includes("loading")},ee("calcite-panel",{bind:this,class:d},"default"===s?ee($,{afterCreate:a,clickAction:r,uiStrings:e}):ee(y,{afterCreate:o,clickAction:r,uiStrings:e}))):null}get _videoViewer(){const{mode:e,loadVideoViewer:t,videoViewModel:i}=this.viewModel,{control:a,reset:o}=this.messagesCommon,{mute:s,unmute:n}=this.messages,r="video"!==e,l=this.classes({[L.viewer]:!r,[L.viewerHidden]:r}),d="esri-image-viewer";return ee("calcite-panel",{bind:this,class:l},ee("calcite-panel",{afterCreate:t,class:this.classes(Q.widget,d)}),ee("calcite-slider",{bind:this,labelHandles:!0,labelTicks:!0,max:i?.videoDuration,minLabel:"0",value:i?.currentTime??0,onCalciteSliderChange:this._handleVideoSeek}),ee("calcite-action-bar",{expandDisabled:!0,layout:"horizontal"},ee("calcite-action-group",null,ee("calcite-action",{bind:this,icon:this.activeVideoIcon,onclick:()=>i?.playVideoHandler(),text:"Play",title:i?.videoPaused?a.play:a.pause})),ee("calcite-action-group",null,ee("calcite-action",{bind:this,icon:"refresh",onclick:()=>i?.rewindVideoHandler(),text:"Rewind",title:o})),ee("calcite-action-group",null,ee("calcite-action",{bind:this,icon:this.activeAudioIcon,onclick:()=>i?.toggleAudio(),text:"Audio",title:i?.videoMuted?s:n}))))}get _locationToggle(){const{viewModel:{state:e,groundCoordinates:t,groundCoordinatesAccuracy:i,triangulatedPoint:a},imageLocationToolActive:o,triangularMeasurementActive:s,messages:{groundLocation:n,triangulatedLocationHeading:r}}=this;if("image-loaded"!==e||!t||!o)return;let l=t;if(s){if(!a)return;l=a}return ee("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:s?r:n,id:n,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearImageLocation},ee(G,{accuracy:i,groundCoordinates:l,messages:this.messages}))}_mapImageConversionToggle(){const{mapImageConversionToolState:e,viewModel:{state:t,disabled:i},invalidCameraHeading:a,visibleElements:{mapImageConversionTool:o}}=this;return o?ee("calcite-action",{active:e,bind:this,disabled:"image-loaded"!==t||a||i,icon:"image-pin",onclick:this._toggleMapImageConversionToolState,text:this.messages.mapImageConversionTool,title:this.messages.mapImageConversionTool}):null}_measurementToolsToggle(){const{_activeMeasurementIcon:e,measureType:t,viewModel:i,accuracyParametersMissing:a,messages:o,triangularMeasurementActive:s,visibleElements:{measurementTools:n}}=this,{state:r}=i,{measurementTools:l,groundDistance:d,groundArea:c,heightAboveGround:g,groundLocation:h,triangulatedDistanceHeading:m,triangulatedAreaHeading:u,triangulatedLocationHeading:v}=o;return n?ee("calcite-dropdown",{disabled:a,key:"measurement-tools",maxItems:5,title:l,width:"m"},ee("calcite-action",{bind:this,disabled:"image-loaded"!==r||a,icon:e,slot:"trigger",text:l}),ee("calcite-dropdown-group",null,ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-line",key:"distance-measurement",onclick:e=>this._toggleMeasurementSketch(e,"distance"),selected:"distance"===t&&!s},d),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"measure-area",key:"area-measurement",onclick:e=>this._toggleMeasurementSketch(e,"area"),selected:"area"===t&&!s},c),ee("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},g),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"pin-tear",key:"surface-location",onclick:this._toggleLocationTool,selected:!!this.imageLocationToolActive&&!s},h),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"dual-image-location",key:"triangular-location",selected:!!s&&this.imageLocationToolActive,onCalciteDropdownItemSelect:this._toggleTriangularLocation},v),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"dual-image-distance",key:"triangular-measurement-distance",selected:!!s&&"distance"===this.measureType,onCalciteDropdownItemSelect:this._toggleTriangularDistanceMeasurements},m),ee("calcite-dropdown-item",{bind:this,disabled:"image-loaded"!==r,iconStart:"dual-image-area",key:"triangular-measurement-area",selected:!!s&&"area"===this.measureType,onCalciteDropdownItemSelect:this._toggleTriangularAreaMeasurements},u))):null}get _messageBox(){const{messages:e,viewModel:{displayMessage:i,mode:a}}=this;if(!i||"video"===a)return null;const{data:o,key:s,map:n}=i,r=`${n?t(e[s],n):e[s]}`;return ee("span",{class:L.messageBox},o?`${r} ${o}`:r)}async _loadNavigationSettings(){return this._navigationSettingsLoaderTask||(this._navigationSettingsLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/NavigationSettings.js")).default)),await this._navigationSettingsLoaderTask.promise}_navigationToolToggle(){const{state:e}=this.viewModel,{visibleElements:{navigationTool:t},videoLoaded:i}=this;return t?ee("calcite-action",{active:this.navigationToolActive,bind:this,disabled:"image-loaded"!==e&&!i||this.invalidCameraHeading,icon:"explore",onclick:this._toggleNavigationTool,text:this.messages.navigationTool,title:this.messages.navigationTool}):null}_directionToolToggle(){const{state:e}=this.viewModel,{visibleElements:{directionalNavigation:t,sequentialNavigation:i}}=this,a=new W;t&&a.push(new B({active:"directional"===this.navigationMode,disabled:"image-loaded"!==e||this.invalidCameraHeading,icon:"directional-navigation",onclick:()=>{this._toggleImageNavigation("directional")},text:this.messages.directionalNavigation,title:this.messages.directionalNavigationDescription})),i&&a.push(new B({active:"sequential"===this.navigationMode,disabled:"image-loaded"!==e||this.invalidCameraHeading||!this.canNavigateSequentially,icon:"sequential-navigation",onclick:()=>{this._toggleImageNavigation("sequential")},text:this.messages.sequentialNavigation,title:this.messages.sequentialNavigationDescription}));return t||i?ee(U,{actions:a,activeAction:a.items.find(e=>e.active),icon:"absolute-direction",label:this.messages.imageNavigation,scale:"m",title:this.messages.imageNavigation}):null}_openPopupAction(){const{showPopupsAction:e}=this.visibleElements;return e?ee("calcite-action",{bind:this,disabled:!this.popupEnabled,icon:"popup",onclick:this._toggleImageAttributes,text:this.messages.showPopups,title:this.messages.showPopups}):null}get _panoramicVideoViewer(){const{displayMessage:e,loadPanoramicVideoViewer:t,mode:i,clickAction:a,state:o,currentBestFeature:s}=this.viewModel,n=s?.attributes.imagePath,r=null!=e||"panoramic-video"!==i||o.includes("loading")||!n;return ee(p,{afterCreate:t,clickAction:a,oiViewModel:this.viewModel,videoSource:n,visible:!r})}get _panoramicViewer(){const{displayMessage:e,loadPanoramicViewer:t,mode:i,clickAction:a,state:o}=this.viewModel,{messages:{end:s,next:n,previous:r,start:l}}=this,d=null!=e||"panoramic"!==i||o.includes("loading");return ee(y,{afterCreate:t,clickAction:a,navigationEnabled:!d&&null!==this.navigationMode,navigationViewModel:this.viewModel,uiStrings:{end:s,next:n,previous:r,start:l},visible:!d})}_activateTriangulatedImageLocationTool(){this.navigationToolActive=!0,this.imageLocationToolActive=!0}_activateTriangulatedImageLocationWorkflow(e,t){this._closeAllImageTools(),this.imageLocationToolActive=!0,this.triangularMeasurementActive=!e,this.navigationToolActive=!!t||!t}_closeImageToolsAndToggleNavigation(e,t){this._closeAllImageTools(),this.triangularMeasurementActive=!e,this.navigationToolActive=!t}_resetMeasureTypeAndActivateImageLocationTool(){this.measureType=null,this.imageLocationToolActive=!0}_closeAllImageTools(){this.enhancementToolActive=!1,this.navigationToolActive=!1,this.imageOverlaysOpened=!1,this.galleryOpened=!1,this.measureType=null,this.imageLocationToolActive=!1,this.navigationMode=null,this.triangularMeasurementActive=!1,this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))}_handleBrightnessChange(e){this.viewModel.brightness=e.currentTarget.value??0}_handleVideoBrightnessChange(e){this.viewModel.videoViewModel?.handleVideoBrightnessChange(e.target.value)}_handleContrastChange(e){this.viewModel.contrast=e.currentTarget.value??0}_handleVideoContrastChange(e){this.viewModel.videoViewModel?.handleVideoContrastChange(e.target.value)}_handleVideoSeek(e){const t=this.viewModel?.videoElement?.content;t&&(t.currentTime=e.target.value,t.play())}_handleSharpnessChange(e){this.viewModel.sharpness=e.currentTarget.value??0}_lazyLoadImage(e,t){e.forEach(async e=>{if(e.isIntersecting){const a=e.target,o=a.getAttribute("data-src"),s=a.getAttribute("data-rotation"),l=a.getAttribute("data-objectid"),d=s?parseFloat(s)%360:0,{layer:c,_galleryController:{signal:g}}=this;if(!o||!l)return;let h;try{h=P(o)?await F(c,l,{signal:g}):await E(o,{signal:g})}catch(i){r(i)||n.getLogger("esri.widgets.OrientedImageryViewer").error("#lazyLoadImage()",i)}finally{t.unobserve(a)}if(!h)return;x(h,a,d)}})}_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=a(async()=>{const{default:e}=await import("./OrientedImageryViewer/components/ImageMeasurementWidget.js");return e})}_loadSketchResources(){this._sketchLoaderTask=a(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,t){const{viewModel:{state:i}}=this;return"image-loaded"===i?ee(D,{icon:"exclamation-mark-triangle-f",kind:"warning",message:t,open:!0,title:e,tooltip:t}):null}get _renderNavigation(){const{viewModel:{sectorData:e,navigatorCurrentBestFeature:t,currentBestFeature:a,state:o}}=this;if(!this.container||!a)return null;let s,n,r,l,d;if(t){const{x:e,y:i,direction:a}=t,[o,c,g,h]=C[a];s=`M ${e} ${i} L ${o} ${c} A ${f[2]} ${f[2]} 0 0 1 ${g} ${h} Z`,n=e,l=i,r=C[a][4],d=C[a][5]}const c=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})},h=e=>{e.removeEventListener("click",g)},m=a.attributes.objectId,u=e?.map(e=>e?.items).filter(Boolean).flatMap(e=>e?.map(({x:e,y:t,objectID:i,featureIndexInSector:a,sector:o})=>ee("circle",{afterRemoved:h,class:this.classes(L.feature,{selected:m===i}),cx:e,cy:t,"data-feature-index-in-sector":a,"data-sector":o,key:`${L.feature}-${i}`,onclick:g,r:A}))),v=e=>{e.removeEventListener("click",c)},p=this.classes({[L.navigationWrapper]:!0,[L.navigationZoomed]:this._navigationToolExpanded});return this.navigationToolActive&&("image-loaded"===o||this.videoLoaded)?ee("div",{bind:this,class:p,key:this.messages.navigationTool},ee("svg",{afterCreate:e=>this._storeNavigationToolReference(e),class:i()?V:L.rotateWithAnimation,focusable:"false",height:I,role:"img",width:I,xmlns:"http://www.w3.org/2000/svg"},ee("defs",null,ee("linearGradient",{gradientUnits:"userSpaceOnUse",id:`${this.id}-coverage-fill`,x1:n,x2:r,y1:l,y2:d},ee("stop",{class:L.navigationPathOffset0,offset:0}),ee("stop",{class:L.navigationPathOffset1,offset:1}))),ee("g",null,ee("circle",{class:this.classes(L.sector,L.outerSector),cx:f[3],cy:f[3],onclick:this._scaleNavigationTool,r:f[3]}),ee("circle",{class:L.sector,cx:f[3],cy:f[3],r:f[2]}),ee("circle",{class:L.sector,cx:f[3],cy:f[3],r:f[1]}),ee("circle",{class:L.sector,cx:f[3],cy:f[3],r:f[0]}),ee("path",{class:L.pointer,d:"M 56.5 6.06217782649107 L 60 0 L 63.5 6.06217782649107 Z",key:`${L.pointer}-west`}),ee("path",{class:this.classes(L.pointer,L.north),d:"M 113.93782217350893 56.5 L 120 60 L 113.93782217350893 63.5 Z",key:`${L.pointer}-north`}),ee("path",{class:L.pointer,d:"M 56.5 113.93782217350893 L 60 120 L 63.5 113.93782217350893 Z",key:`${L.pointer}-east`}),ee("path",{class:L.pointer,d:"M 6.06217782649107 56.5 L 0 60 L 6.06217782649107 63.5 Z",key:`${L.pointer}-south`}),ee("path",{class:this.classes(L.sector,L.sectorSeparator),d:"M 23.937554159486076 23.937554159486076 L 96.06244584051393 96.06244584051393 M 23.937554159486076 96.06244584051393 L 96.06244584051393 23.937554159486076",key:L.sectorSeparator}),_([f[2],f[1],f[0]],f[3],f[3]).map((t,i)=>ee("path",{afterRemoved:v,class:this.classes(L.sector,e?.[i]?.length?L.sectorEnabled:L.sectorDisabled),d:t,"data-sector":`${i}`,key:`${L.sector}-${i}`,onclick:c})),ee("path",{class:this.classes(L.sector,L.sectorCross),d:"M 56.4 56.4 L 63.53 63.53 M 63.53 56.4 L 56.4 63.53",key:L.sectorCross}),u,a.attributes.cameraPitch>=5&&s?ee("path",{class:L.selectedFeaturePath,d:s,fill:`url(#${this.id}-coverage-fill)`,key:L.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",o=this._sketchLoaderTask.value;return ee("div",{class:L.sketchTools},ee(o,{icon:a,messages:this._imageSketchToolsMessages,type:i,onAction:this._onAction}))}get _renderThumbnails(){const{currentBestFeature:e,thumbnails:t}=this.viewModel;return e?ee("div",{class:L.carouselContent},t?.items.map(({url:t,objectId:i,rotation:a},o)=>ee("div",{class:`${L.carouselItemWrapper}${e.attributes.objectId===i?"--selected":""}`,key:`${L.carouselItemWrapper}-${o}`},ee("canvas",{afterCreate:this._registerGalleryItem,afterRemoved:this._unregisterGalleryItem,alt:`thumbnail-${i}`,class:L.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}_resetVideoTools(){this.viewModel.videoViewModel?.resetVideoEnhancementTools()}_storeNavigationToolReference(e){this._navigationTool=e}_toggleAdditionalCameraLocations(){this.isAdditionalPointSourcesVisible=!this.isAdditionalPointSourcesVisible}_toggleAdditionalCoverage(){this.isAdditionalCoverageVisible=!this.isAdditionalCoverageVisible}_toggleCurrentCoverage(){this.currentCoverageVisible=!this.currentCoverageVisible}_toggleEnhancementToolState(e){e.stopPropagation();const t=this.enhancementToolActive;this._closeAllImageTools(),this.enhancementToolActive=!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,i=this.triangularMeasurementActive&&t;this._closeAllImageTools(),this.imageLocationToolActive=i||!t,e.stopPropagation()}_toggleMeasurementSketch(e,t){e.stopPropagation();const i=this.measureType,a=this.triangularMeasurementActive;this._closeAllImageTools(),this.measureType=i!==t||a?t:null,this.measureType===t&&(this.viewModel.displayNewMeasurementButton=!0)}_toggleNavigationTool(){const e=this.navigationToolActive;this._closeAllImageTools(),this.navigationToolActive=!e}_toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_toggleTriangularAreaMeasurements(){this._toggleTriangularMeasurements("area")}_toggleTriangularDistanceMeasurements(){this._toggleTriangularMeasurements("distance")}_toggleTriangularLocation(){const e=this.triangularMeasurementActive,t=this.navigationToolActive;e?null===this.measureType?this.imageLocationToolActive?this._closeImageToolsAndToggleNavigation(e,t):this._activateTriangulatedImageLocationTool():this._resetMeasureTypeAndActivateImageLocationTool():this._activateTriangulatedImageLocationWorkflow(e,t)}_toggleTriangularMeasurements(e){const t=this.triangularMeasurementActive,i=this.viewModel.measureType,a=this.navigationToolActive;t?e===i?(this._closeAllImageTools(),this.triangularMeasurementActive=!t,this.navigationToolActive=!a):(this.imageLocationToolActive=!1,this.measureType=e):(this._closeAllImageTools(),this.measureType=e,this.triangularMeasurementActive=!t,this.navigationToolActive=!!a||!a)}_unregisterGalleryItem(e){this._galleryObserver.unobserve(e)}_updateNavigationTool(e){const{previousFeatureAngle:t,bestFeatureAngle:i}=this.viewModel,a=(i-t+540)%360-180;e.style.setProperty(k,`${t}deg`),e.style.setProperty(S,`${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(`${te.overlayed}-${e.id}`),this.addHandles(l(()=>e.visible,()=>{this.viewModel.toggleOverlayMapFeatures(e.id,e.visible,this.showMapFeatures)}),`${te.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(`${te.overlayed}-${e}`),this._overlayedLayers.remove(this._overlayedLayers.find(t=>t.id===e)),this.viewModel.removeOverlayedGraphicsOnImage(e)}resetImage(){this.viewModel.resetImage()}render(){return ee("div",{class:this.classes(Q.widget,O)},this._renderRoot)}async showImageByObjectId(e,t){return this.viewModel.showImageByObjectId(e,t)}async startDataCapture(e){return this.viewModel.startDataCapture(e)}async stopDataCapture(e){return this.viewModel.stopDataCapture(e)}updateSuitabilities(e){this.viewModel.updateSuitabilities(e)}};e([h({readOnly:!0})],ie.prototype,"accuracyParametersMissing",null),e([h()],ie.prototype,"activeLayer",null),e([h()],ie.prototype,"activeVideoIcon",null),e([h()],ie.prototype,"activeAudioIcon",null),e([h()],ie.prototype,"cameraHeadingThreshold",null),e([h()],ie.prototype,"cameraPitchThreshold",null),e([h()],ie.prototype,"canNavigateSequentially",null),e([h()],ie.prototype,"currentBestFeature",null),e([h()],ie.prototype,"currentCoverageVisible",null),e([h()],ie.prototype,"dataCaptureEnabled",void 0),e([h()],ie.prototype,"dataCaptureLayer",null),e([h()],ie.prototype,"depthImageNotSupported",null),e([h()],ie.prototype,"disabled",null),e([h()],ie.prototype,"enhancementToolActive",null),e([h()],ie.prototype,"features",null),e([h()],ie.prototype,"imagePointsInView",null),e([h()],ie.prototype,"galleryOpened",void 0),e([h()],ie.prototype,"icon",null),e([h()],ie.prototype,"imageEnhancementToolActive",void 0),e([h()],ie.prototype,"videoEnhancementToolActive",void 0),e([h({readOnly:!0})],ie.prototype,"imageGalleryEnabled",null),e([h()],ie.prototype,"imageLocationToolActive",null),e([h()],ie.prototype,"imageOverlaysOpened",void 0),e([h({readOnly:!0})],ie.prototype,"invalidCameraHeading",null),e([h()],ie.prototype,"isAdditionalCoverageVisible",null),e([h()],ie.prototype,"isAdditionalPointSourcesVisible",null),e([h()],ie.prototype,"mapImageConversionToolState",null),e([h()],ie.prototype,"measureType",null),e([h()],ie.prototype,"layer",null),e([h()],ie.prototype,"navigationToolActive",void 0),e([h()],ie.prototype,"navigationMode",null),e([X(M()),h({type:H})],ie.prototype,"viewModel",void 0),e([h(),Y("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],ie.prototype,"messages",void 0),e([h(),Y("esri/core/t9n/Units")],ie.prototype,"measurementUnitMessages",void 0),e([h(),Y("esri/t9n/common")],ie.prototype,"messagesCommon",void 0),e([h(),Y("esri/widgets/Sketch/t9n/Sketch")],ie.prototype,"messagesSketch",void 0),e([h()],ie.prototype,"pixelMeasurementUnit",void 0),e([h()],ie.prototype,"pixelAreaMeasurementUnit",void 0),e([h({readOnly:!0})],ie.prototype,"popupEnabled",null),e([h()],ie.prototype,"referencePoint",null),e([h()],ie.prototype,"showCameraLocations",void 0),e([h()],ie.prototype,"showMapFeatures",void 0),e([X(["create","delete","redo","undo","update"]),h({readOnly:!0})],ie.prototype,"sketchViewModel",null),e([h()],ie.prototype,"triangularMeasurementActive",null),e([h()],ie.prototype,"videoLoaded",null),e([h()],ie.prototype,"view",null),e([h({type:N,nonNullable:!0})],ie.prototype,"visibleElements",void 0),e([h()],ie.prototype,"determineWorkflowForFeature",null),e([h()],ie.prototype,"updateFootprint",null),e([h()],ie.prototype,"_activeMeasurementIcon",null),e([h()],ie.prototype,"_activeMeasurementHeading",null),e([h()],ie.prototype,"_imageOverlaysLoaderTask",void 0),e([h()],ie.prototype,"_imageMeasurementToolsLoaderTask",void 0),e([h()],ie.prototype,"_navigationSettingsLoaderTask",void 0),e([h()],ie.prototype,"_measurementToggle",null),e([h()],ie.prototype,"_renderRoot",null),e([h()],ie.prototype,"_imageEnhancementTools",null),e([h()],ie.prototype,"_videoEnhancementTools",null),e([h()],ie.prototype,"_imageGalleryPanel",null),e([h()],ie.prototype,"_imageGalleryContext",null),e([h()],ie.prototype,"_imageOverlaysComponent",null),e([h()],ie.prototype,"_imageOverlayMessages",null),e([h()],ie.prototype,"_imageSketchToolsMessages",null),e([h()],ie.prototype,"_imageViewer",null),e([h()],ie.prototype,"_imageViewerTriangular",null),e([h()],ie.prototype,"_videoViewer",null),e([h()],ie.prototype,"_locationToggle",null),e([h()],ie.prototype,"_messageBox",null),e([h()],ie.prototype,"_navigationToolExpanded",void 0),e([h()],ie.prototype,"_navigationTool",void 0),e([h()],ie.prototype,"_panoramicVideoViewer",null),e([h()],ie.prototype,"_panoramicViewer",null),e([h()],ie.prototype,"_renderNavigation",null),e([h()],ie.prototype,"_renderThumbnails",null),e([h()],ie.prototype,"_sketchLoaderTask",void 0),ie=e([m("esri.widgets.OrientedImageryViewer")],ie);const ae=ie;export{ae as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{getAssetUrl as t}from"../../assets.js";import s from"../../Graphic.js";import r from"../../PopupTemplate.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Error.js";import{EventedAccessor as l}from"../../core/Evented.js";import a from"../../core/Logger.js";import{mappedFind as n}from"../../core/maybe.js";import{eachAlways as u,after as c}from"../../core/promiseUtils.js";import{watch as h,initial as p,whenOnce as g}from"../../core/reactiveUtils.js";import{property as d,subclass as m}from"../../core/accessorSupport/decorators.js";import y from"../../geometry/Point.js";import f from"../../geometry/SpatialReference.js";import{getPointFromGeometry as S,getPointWithElevation as _}from"../../geometry/support/geometryUtils.js";import v from"../../portal/Portal.js";import{isApiKeyApplicable as w}from"../../support/apiKeyUtils.js";import b from"../../symbols/PictureMarkerSymbol.js";import x from"../../symbols/SimpleFillSymbol.js";import L from"../../symbols/SimpleLineSymbol.js";import I from"../../symbols/TextSymbol.js";import{popupFromView as T,closePopup as E}from"../../views/popupAdapter.js";import{highlightsSupported as R}from"../../views/support/layerViewUtils.js";import F from"./LayerSearchSource.js";import P from"./LocatorSearchSource.js";import{SourceCollection as j}from"./types.js";import{isArcGISWorldGeocoder as G,meteredArcGISLocatorUrl as C,isProxiedArcGISWorldGeocoder as O,isMeteredArcGISWorldGeocoder as A}from"./support/locatorUtils.js";import{supported as N,getCurrentPosition as D,positionToPoint as M}from"../support/geolocationUtils.js";import{GoTo as V}from"../support/GoTo.js";function J(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const U="highlight",H=f.WGS84,k="esri/images/search/search-symbol-32.png",B=/<[\s\S]*?>/g,Q=-1;let Z=class extends(V(l)){constructor(e){super(e),this._defaultPopupTemplate=new r({content:"{Match_addr}"}),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultSources=new j,this.defaultSymbols={point:new b({url:t(k),size:24,width:24,height:24}),polyline:new L({color:[130,130,130,1],width:2}),polygon:new x({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=v.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new j,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){this.addHandles([h(()=>[this.includeDefaultSources,this.view,this.portal],()=>this._update(),p),h(()=>this.messages,()=>{this._defaultPopupTemplate.title=this.messages?.searchResult??"",this._update()},p)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}static{this.ALL_INDEX=Q}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:Q}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:s}=this,r="function"==typeof s?s.call(null,{sources:e,defaultSources:t}):s?t.concat(e):e,o=this._get("allSources")||new j;return o.removeAll(),o.addMany(r.filter(Boolean)),o}get defaultPopupTemplate(){return this._defaultPopupTemplate}set defaultPopupTemplate(e){this._overrideIfSome("defaultPopupTemplate",e)}get locationEnabled(){return this._get("locationEnabled")||N()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=N();if(e&&!t){const e=new i("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});a.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:s}=this;if(t===Q)return s??"";const r=e.at(t);return r?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const s=this._createSuggestionForSearch(e),r=(async()=>{try{await this.when();const e=await this._getResultsFromSources(s,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:s.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(r,e,s);const o=this._getFirstResult(r.results),i=s.location&&o?o.name:s.text,l=i?.replaceAll(B,"");return this._set("searchTerm",l),(s.key&&"number"==typeof s.sourceIndex||s.location)&&this._set("selectedSuggestion",s),this._set("results",r.results),this._set("resultCount",r.results.reduce((e,t)=>e+(t.results?.length??0),0)),this.emit("search-complete",r),await this._selectFirstResult(o),r}finally{this._clearSearching()}})();return this._searching=r,r}async searchNearby(e){if(!this.locationEnabled){const e=new i("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw a.getLogger(this).error(e),e}const t=(async()=>{try{const t=await D(),s=await M({position:t,view:this.view},e);return await this.search(s,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new i("select:missing-parameter","Cannot select without a searchResult.",{value:e});throw a.getLogger(this).error(t),t}const{view:t}=this,r=J(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=r?this.allSources.at(r):null;if(!o){const e=new i("select:missing-source","Cannot select without a source.",{source:o});throw a.getLogger(this).error(e),e}const l=o instanceof F?this._getLayerSourcePopupTemplate(o):o.popupTemplate,n=o.resultSymbol||this._getDefaultSymbol(e),c=J(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,h=J(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,p=J(o,"popupEnabled")?o.popupEnabled:this.popupEnabled,g=p?l||this.popupTemplate||this.defaultPopupTemplate:null,{feature:d}=e;if(!d){const e=new i("select:missing-feature","Cannot select without a feature.",{feature:d});throw a.getLogger(this).error(e),e}const{attributes:m,geometry:y,layer:f,sourceLayer:v}=d,w=y?S(y):null,b={layerViewQuery:this._getLayerView(d),elevationQuery:t&&null!=w?_(w,t):Promise.resolve(w)},x=await u(b),L=x.layerViewQuery.value,E=x.elevationQuery.value;n instanceof I&&(n.text=e.name);const P=t&&h?e.target||e.extent:null,j=null!=P?this._goToSearchResult(P):Promise.resolve();await j;const G=L?d:new s({geometry:y,symbol:n,attributes:m,layer:f,sourceLayer:v,popupTemplate:g}),C=T(t),O=C&&p&&G.getEffectivePopupTemplate(C.defaultPopupTemplateEnabled);return O&&await(t?.openPopup({features:[G],location:E})),L&&R(L)&&!O&&this._highlightFeature({graphic:G,layerView:L}),!L&&c&&t&&t.graphics.push(G),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",G),this.emit("select-result",{result:e,source:o,sourceIndex:r}),e}async suggest(e,t,s){const r=e||this.searchTerm;this.emit("suggest-start",{searchTerm:r}),await this._suggestTimer(t,s);const o=await this._suggestImmediate(r,s);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce((e,t)=>e+(t.results?.length??0),0)??null),this.emit("suggest-complete",o),o}async when(){await g(()=>!this.updating)}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const s=this._updatingPromise=u([e?.load(),t?.when()]);if(this.destroyed)return;if(await s,s!==this._updatingPromise)return}this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map(e=>{if(!1===e.placefinding)return;const t=G(e.url)&&w(e.url)?{url:C}:null,s=P.fromJSON({...e,...t}),r=s.url;if(G(r)||O(r)||A(r)){const e=s.outFields??["Addr_type","Match_addr","StAddr","City"],t=(s.placeholder||this.messages?.placeholder)??"",r="number"==typeof s.defaultZoomScale?s.defaultZoomScale:2500;s.singleLineFieldName="SingleLine",s.outFields=e,s.placeholder=t,s.defaultZoomScale=r}return s.singleLineFieldName?s:void 0}).filter(o)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach(e=>e?.destroy()),this._createdFeatureLayers=[]}_getLayerSources(e,t){const s=this.view?.map;return e.map(e=>{const r=s.findLayerById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=F.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_getTableSources(e,t){const s=this.view?.map;return e.map(e=>{if(!e.id)return;const r=s.findTableById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=F.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:s,hintText:r,layers:o,tables:i}=t;if(!s)return[];return[...this._getLayerSources(o,r),...this._getTableSources(i,r)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const s=e.allSublayers.find(e=>e.id===t.subLayer);if(!s)throw new Error;const r=await(s.createFeatureLayer?.());if(!r)throw new Error;return this._createdFeatureLayers.push(r),r}async _getBuildingSubLayer(e,t){await e.load();const s=e.allSublayers.find(e=>e.id===t.subLayer);if("building-component"!==s?.type)throw new Error;if(await s.load(),null==s.associatedLayer)throw new Error;return await s.associatedLayer.load(),s}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(s){const t=new i("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return a.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=T(this.view),{resultGraphic:t}=this;if(!e||!t)return;const s="selectedFeature"in e,r=s?e.selectedFeature:null;s&&(r&&r===t)&&E(this.view?.popup,this.view?.popupElement)}_suggestTimer(e,t){const s=null!=e?e:this.suggestionDelay;return c(s,null,t?.signal)}_createLocationForSearch(e){return e instanceof s&&e.geometry?S(e.geometry):e instanceof y?e:Array.isArray(e)&&2===e.length?new y({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&J(e,"key")&&J(e,"text")&&J(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),s="string"==typeof e?e:this.searchTerm,{selectedSuggestion:r,selectedResult:o}=this,i=!e&&r&&o,l=i&&r.key===o.key&&r.sourceIndex===o.sourceIndex,a=i&&r.location;return l||a?r:{location:t,text:t?"":s,sourceIndex:null,key:null}}_getFirstResult(e){return n(e,({results:e})=>e?.[0])??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const s=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(r,s),r}_formatSourceResponse(e,t,s){const r=t?.value||[],o=t?.error,i=this.allSources.at(s);if(o){const t={sourceIndex:s,source:i,error:o};e.errors.push(t),a.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:s,source:i,results:r};e.results.push(t),e.numResults+=r.length}}_formatResponse(e,t,s){if(t)if(e.activeSourceIndex===Q){const r=s&&J(s,"sourceIndex")&&-1!==s.sourceIndex?s.sourceIndex:void 0;t.forEach((t,s)=>{const o=void 0!==r?r:s;this._formatSourceResponse(e,t,o)})}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:s}=this,r=!e.location&&J(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!s.length){const e=new i("search:no-sources-defined","At least one source is required.",{allSources:s});throw a.getLogger(this).error(e),e}return r===Q?s.forEach((s,r)=>{o.push(this._getResultsFromSource(e,r,t))}):o.push(this._getResultsFromSource(e,r,t)),u(o)}async _getSuggestionsFromSources(e,t){const{allSources:s,activeSourceIndex:r}=this,o=[];if(!s.length){const e=new i("suggest:no-sources-defined","At least one source is required.",{allSources:s});throw a.getLogger(this).error(e),e}return r===Q?s.forEach((s,r)=>{o.push(this._getSuggestionsFromSource(e,r,t))}):o.push(this._getSuggestionsFromSource(e,r,t)),u(o)}async _getResultsFromSource(e,t,s){const r=null!=t?this.allSources.at(t):null;if(!r)return null;const{location:o=null}=e,i=this.view?.spatialReference??H,l=J(r,"maxResults")?r.maxResults:this.maxResults,a=!!(r instanceof F&&J(r,"exactMatch"))&&r.exactMatch,{view:n}=this;return r.getResults?.({exactMatch:a,location:o,maxResults:l,sourceIndex:t,spatialReference:i,suggestResult:e,view:n},s)}async _getSuggestionsFromSource(e,t,s){const r=this.allSources.at(t);if(!r)return null;e??="";const o=J(r,"suggestionsEnabled")?r.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=J(r,"minSuggestCharacters")?r.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||H,i=J(r,"maxSuggestions")?r.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(r instanceof F&&J(r,"exactMatch"))&&r.exactMatch;return r.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},s)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return J(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return n(this.results??[],({results:t,sourceIndex:s})=>{const r=t?.includes(e);return r?s:null})??null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const s={target:{target:e},options:{signal:t.signal}};e||(s.options.animate=!1),await this.callGoTo(s),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,s=e.feature?.geometry;if(null==s)return null;switch(s.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(U)}async _getLayerView(e){const{view:t}=this;if(!e||!t)return null;const{layer:s,sourceLayer:r}=e,o=s??r;return o&&"building-component"!==o.type&&"subtype-sublayer"!==o.type?(await t.when(),t.whenLayerView(o)):null}_highlightFeature(e){const{graphic:t,layerView:s}=e,{attributes:r,layer:o,sourceLayer:i}=t,l=o??i,{objectIdField:a}=l,n=(a&&r?.[a])??null,u=s.highlight(n??t);this.addHandles(u,U)}_setResultFloor(e){const{view:t}=this,s=e.feature?.attributes,r=e.feature?.sourceLayer;if(r&&"floorInfo"in r&&r?.floorInfo?.floorField&&s){const e=s[r.floorInfo.floorField];t?.emit("select-result-floor",e)}}};e([d()],Z.prototype,"_searching",void 0),e([d()],Z.prototype,"_updatingPromise",void 0),e([d({readOnly:!0,value:null})],Z.prototype,"activeSource",null),e([d()],Z.prototype,"activeSourceIndex",null),e([d()],Z.prototype,"allPlaceholder",null),e([d({readOnly:!0})],Z.prototype,"allSources",null),e([d()],Z.prototype,"autoNavigate",void 0),e([d()],Z.prototype,"autoSelect",void 0),e([d({type:r})],Z.prototype,"defaultPopupTemplate",null),e([d({readOnly:!0})],Z.prototype,"defaultSources",void 0),e([d()],Z.prototype,"defaultSymbols",void 0),e([d()],Z.prototype,"includeDefaultSources",void 0),e([d()],Z.prototype,"locationEnabled",null),e([d()],Z.prototype,"maxInputLength",void 0),e([d()],Z.prototype,"maxResults",void 0),e([d()],Z.prototype,"maxSuggestions",void 0),e([d()],Z.prototype,"messages",void 0),e([d()],Z.prototype,"minSuggestCharacters",void 0),e([d({readOnly:!0})],Z.prototype,"placeholder",null),e([d()],Z.prototype,"popupEnabled",void 0),e([d({type:r})],Z.prototype,"popupTemplate",void 0),e([d({type:v})],Z.prototype,"portal",void 0),e([d()],Z.prototype,"resultCount",void 0),e([d()],Z.prototype,"resultGraphicEnabled",void 0),e([d({readOnly:!0})],Z.prototype,"resultGraphic",void 0),e([d({readOnly:!0})],Z.prototype,"results",void 0),e([d({readOnly:!0})],Z.prototype,"selectedSuggestion",void 0),e([d()],Z.prototype,"searchAllEnabled",void 0),e([d({readOnly:!0})],Z.prototype,"selectedResult",void 0),e([d()],Z.prototype,"searchTerm",null),e([d({type:j})],Z.prototype,"sources",void 0),e([d({readOnly:!0})],Z.prototype,"state",null),e([d()],Z.prototype,"suggestionDelay",void 0),e([d()],Z.prototype,"suggestionCount",void 0),e([d({readOnly:!0})],Z.prototype,"suggestions",void 0),e([d()],Z.prototype,"suggestionsEnabled",void 0),e([d({readOnly:!0})],Z.prototype,"updating",null),e([d()],Z.prototype,"view",void 0),e([d()],Z.prototype,"clear",null),Z=e([m("esri.widgets.Search.SearchViewModel")],Z);const q=Z;export{q as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import{getAssetUrl as t}from"../../assets.js";import s from"../../Graphic.js";import r from"../../PopupTemplate.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Error.js";import{EventedAccessor as l}from"../../core/Evented.js";import a from"../../core/Logger.js";import{mappedFind as n}from"../../core/maybe.js";import{eachAlways as u,after as c}from"../../core/promiseUtils.js";import{watch as h,initial as p,whenOnce as g}from"../../core/reactiveUtils.js";import{property as d,subclass as m}from"../../core/accessorSupport/decorators.js";import y from"../../geometry/Point.js";import f from"../../geometry/SpatialReference.js";import{getPointFromGeometry as S,getPointWithElevation as _}from"../../geometry/support/geometryUtils.js";import v from"../../portal/Portal.js";import{isApiKeyApplicable as w}from"../../support/apiKeyUtils.js";import b from"../../symbols/PictureMarkerSymbol.js";import x from"../../symbols/SimpleFillSymbol.js";import L from"../../symbols/SimpleLineSymbol.js";import I from"../../symbols/TextSymbol.js";import{popupFromView as T,closePopup as E}from"../../views/popupAdapter.js";import{highlightsSupported as R}from"../../views/support/layerViewUtils.js";import F from"./LayerSearchSource.js";import P from"./LocatorSearchSource.js";import{SourceCollection as j}from"./types.js";import{isArcGISWorldGeocoder as G,meteredArcGISLocatorUrl as C,isProxiedArcGISWorldGeocoder as O,isMeteredArcGISWorldGeocoder as A}from"./support/locatorUtils.js";import{supported as N,getCurrentPosition as D,positionToPoint as M}from"../support/geolocationUtils.js";import{GoTo as V}from"../support/GoTo.js";function J(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const U="highlight",H=f.WGS84,k="esri/images/search/search-symbol-32.png",B=/<[\s\S]*?>/g,Q=-1;let Z=class extends(V(l)){constructor(e){super(e),this._defaultPopupTemplate=new r({content:"{Match_addr}"}),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultSources=new j,this.defaultSymbols={point:new b({url:t(k),size:24,width:24,height:24}),polyline:new L({color:[130,130,130,1],width:2}),polygon:new x({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=v.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new j,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){this.addHandles([h(()=>[this.includeDefaultSources,this.view,this.portal],()=>this._update(),p),h(()=>this.messages,()=>{this._defaultPopupTemplate.title=this.messages?.searchResult??"",this._update()},p)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}static{this.ALL_INDEX=Q}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:Q}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:s}=this,r="function"==typeof s?s.call(null,{sources:e,defaultSources:t}):s?t.concat(e):e,o=this._get("allSources")||new j;return o.removeAll(),o.addMany(r.filter(Boolean)),o}get defaultPopupTemplate(){return this._defaultPopupTemplate}set defaultPopupTemplate(e){this._overrideIfSome("defaultPopupTemplate",e)}get locationEnabled(){return this._get("locationEnabled")||N()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=N();if(e&&!t){const e=new i("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});a.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:s}=this;if(t===Q)return s??"";const r=e.at(t);return r?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const s=this._createSuggestionForSearch(e),r=(async()=>{try{await this.when();const e=await this._getResultsFromSources(s,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:s.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(r,e,s);const o=this._getFirstResult(r.results),i=s.location&&o?o.name:s.text,l=i?.replaceAll(B,"");return this._set("searchTerm",l),(s.key&&"number"==typeof s.sourceIndex||s.location)&&this._set("selectedSuggestion",s),this._set("results",r.results),this._set("resultCount",r.results.reduce((e,t)=>e+(t.results?.length??0),0)),this.emit("search-complete",r),await this._selectFirstResult(o),r}finally{this._clearSearching()}})();return this._searching=r,r}async searchNearby(e){if(!this.locationEnabled){const e=new i("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw a.getLogger(this).error(e),e}const t=(async()=>{try{const t=await D(),s=await M({position:t,view:this.view},e);return await this.search(s,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new i("select:missing-parameter","Cannot select without a searchResult.",{value:e});throw a.getLogger(this).error(t),t}const{view:t}=this,r=J(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=r?this.allSources.at(r):null;if(!o){const e=new i("select:missing-source","Cannot select without a source.",{source:o});throw a.getLogger(this).error(e),e}const l=o instanceof F?this._getLayerSourcePopupTemplate(o):o.popupTemplate,n=o.resultSymbol||this._getDefaultSymbol(e),c=J(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,h=J(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,p=J(o,"popupEnabled")?o.popupEnabled:this.popupEnabled,g=p?l||this.popupTemplate||this.defaultPopupTemplate:null,{feature:d}=e;if(!d){const e=new i("select:missing-feature","Cannot select without a feature.",{feature:d});throw a.getLogger(this).error(e),e}const{attributes:m,geometry:y,layer:f,sourceLayer:v}=d,w=y?S(y):null,b={layerViewQuery:this._getLayerView(d),elevationQuery:t&&null!=w?_(w,t):Promise.resolve(w)},x=await u(b),L=x.layerViewQuery.value,E=x.elevationQuery.value;n instanceof I&&(n.text=e.name);const P=t&&h?e.target||e.extent:null,j=null!=P?this._goToSearchResult(P):Promise.resolve();await j;const G=L?d:new s({geometry:y,symbol:n,attributes:m,layer:f,sourceLayer:v,popupTemplate:g}),C=T(t),O=C&&p&&G.getEffectivePopupTemplate(C.defaultPopupTemplateEnabled);return O&&this.emit("popup-open",{features:[G],location:E??null}),L&&R(L)&&!O&&this._highlightFeature({graphic:G,layerView:L}),!L&&c&&t&&t.graphics.push(G),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",G),this.emit("select-result",{result:e,source:o,sourceIndex:r}),e}async suggest(e,t,s){const r=e||this.searchTerm;this.emit("suggest-start",{searchTerm:r}),await this._suggestTimer(t,s);const o=await this._suggestImmediate(r,s);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce((e,t)=>e+(t.results?.length??0),0)??null),this.emit("suggest-complete",o),o}async when(){await g(()=>!this.updating)}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const s=this._updatingPromise=u([e?.load(),t?.when()]);if(this.destroyed)return;if(await s,s!==this._updatingPromise)return}this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map(e=>{if(!1===e.placefinding)return;const t=G(e.url)&&w(e.url)?{url:C}:null,s=P.fromJSON({...e,...t}),r=s.url;if(G(r)||O(r)||A(r)){const e=s.outFields??["Addr_type","Match_addr","StAddr","City"],t=(s.placeholder||this.messages?.placeholder)??"",r="number"==typeof s.defaultZoomScale?s.defaultZoomScale:2500;s.singleLineFieldName="SingleLine",s.outFields=e,s.placeholder=t,s.defaultZoomScale=r}return s.singleLineFieldName?s:void 0}).filter(o)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach(e=>e?.destroy()),this._createdFeatureLayers=[]}_getLayerSources(e,t){const s=this.view?.map;return e.map(e=>{const r=s.findLayerById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=F.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_getTableSources(e,t){const s=this.view?.map;return e.map(e=>{if(!e.id)return;const r=s.findTableById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=F.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:s,hintText:r,layers:o,tables:i}=t;if(!s)return[];return[...this._getLayerSources(o,r),...this._getTableSources(i,r)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const s=e.allSublayers.find(e=>e.id===t.subLayer);if(!s)throw new Error;const r=await(s.createFeatureLayer?.());if(!r)throw new Error;return this._createdFeatureLayers.push(r),r}async _getBuildingSubLayer(e,t){await e.load();const s=e.allSublayers.find(e=>e.id===t.subLayer);if("building-component"!==s?.type)throw new Error;if(await s.load(),null==s.associatedLayer)throw new Error;return await s.associatedLayer.load(),s}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(s){const t=new i("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return a.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=T(this.view),{resultGraphic:t}=this;if(!e||!t)return;const s="selectedFeature"in e,r=s?e.selectedFeature:null;s&&(r&&r===t)&&E(this.view?.popup,this.view?.popupElement)}_suggestTimer(e,t){const s=null!=e?e:this.suggestionDelay;return c(s,null,t?.signal)}_createLocationForSearch(e){return e instanceof s&&e.geometry?S(e.geometry):e instanceof y?e:Array.isArray(e)&&2===e.length?new y({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&J(e,"key")&&J(e,"text")&&J(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),s="string"==typeof e?e:this.searchTerm,{selectedSuggestion:r,selectedResult:o}=this,i=!e&&r&&o,l=i&&r.key===o.key&&r.sourceIndex===o.sourceIndex,a=i&&r.location;return l||a?r:{location:t,text:t?"":s,sourceIndex:null,key:null}}_getFirstResult(e){return n(e,({results:e})=>e?.[0])??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const s=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(r,s),r}_formatSourceResponse(e,t,s){const r=t?.value||[],o=t?.error,i=this.allSources.at(s);if(o){const t={sourceIndex:s,source:i,error:o};e.errors.push(t),a.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:s,source:i,results:r};e.results.push(t),e.numResults+=r.length}}_formatResponse(e,t,s){if(t)if(e.activeSourceIndex===Q){const r=s&&J(s,"sourceIndex")&&-1!==s.sourceIndex?s.sourceIndex:void 0;t.forEach((t,s)=>{const o=void 0!==r?r:s;this._formatSourceResponse(e,t,o)})}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:s}=this,r=!e.location&&J(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!s.length){const e=new i("search:no-sources-defined","At least one source is required.",{allSources:s});throw a.getLogger(this).error(e),e}return r===Q?s.forEach((s,r)=>{o.push(this._getResultsFromSource(e,r,t))}):o.push(this._getResultsFromSource(e,r,t)),u(o)}async _getSuggestionsFromSources(e,t){const{allSources:s,activeSourceIndex:r}=this,o=[];if(!s.length){const e=new i("suggest:no-sources-defined","At least one source is required.",{allSources:s});throw a.getLogger(this).error(e),e}return r===Q?s.forEach((s,r)=>{o.push(this._getSuggestionsFromSource(e,r,t))}):o.push(this._getSuggestionsFromSource(e,r,t)),u(o)}async _getResultsFromSource(e,t,s){const r=null!=t?this.allSources.at(t):null;if(!r)return null;const{location:o=null}=e,i=this.view?.spatialReference??H,l=J(r,"maxResults")?r.maxResults:this.maxResults,a=!!(r instanceof F&&J(r,"exactMatch"))&&r.exactMatch,{view:n}=this;return r.getResults?.({exactMatch:a,location:o,maxResults:l,sourceIndex:t,spatialReference:i,suggestResult:e,view:n},s)}async _getSuggestionsFromSource(e,t,s){const r=this.allSources.at(t);if(!r)return null;e??="";const o=J(r,"suggestionsEnabled")?r.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=J(r,"minSuggestCharacters")?r.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||H,i=J(r,"maxSuggestions")?r.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(r instanceof F&&J(r,"exactMatch"))&&r.exactMatch;return r.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},s)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return J(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return n(this.results??[],({results:t,sourceIndex:s})=>{const r=t?.includes(e);return r?s:null})??null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const s={target:{target:e},options:{signal:t.signal}};e||(s.options.animate=!1),await this.callGoTo(s),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,s=e.feature?.geometry;if(null==s)return null;switch(s.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(U)}async _getLayerView(e){const{view:t}=this;if(!e||!t)return null;const{layer:s,sourceLayer:r}=e,o=s??r;return o&&"building-component"!==o.type&&"subtype-sublayer"!==o.type?(await t.when(),t.whenLayerView(o)):null}_highlightFeature(e){const{graphic:t,layerView:s}=e,{attributes:r,layer:o,sourceLayer:i}=t,l=o??i,{objectIdField:a}=l,n=(a&&r?.[a])??null,u=s.highlight(n??t);this.addHandles(u,U)}_setResultFloor(e){const{view:t}=this,s=e.feature?.attributes,r=e.feature?.sourceLayer;if(r&&"floorInfo"in r&&r?.floorInfo?.floorField&&s){const e=s[r.floorInfo.floorField];t?.emit("select-result-floor",e)}}};e([d()],Z.prototype,"_searching",void 0),e([d()],Z.prototype,"_updatingPromise",void 0),e([d({readOnly:!0,value:null})],Z.prototype,"activeSource",null),e([d()],Z.prototype,"activeSourceIndex",null),e([d()],Z.prototype,"allPlaceholder",null),e([d({readOnly:!0})],Z.prototype,"allSources",null),e([d()],Z.prototype,"autoNavigate",void 0),e([d()],Z.prototype,"autoSelect",void 0),e([d({type:r})],Z.prototype,"defaultPopupTemplate",null),e([d({readOnly:!0})],Z.prototype,"defaultSources",void 0),e([d()],Z.prototype,"defaultSymbols",void 0),e([d()],Z.prototype,"includeDefaultSources",void 0),e([d()],Z.prototype,"locationEnabled",null),e([d()],Z.prototype,"maxInputLength",void 0),e([d()],Z.prototype,"maxResults",void 0),e([d()],Z.prototype,"maxSuggestions",void 0),e([d()],Z.prototype,"messages",void 0),e([d()],Z.prototype,"minSuggestCharacters",void 0),e([d({readOnly:!0})],Z.prototype,"placeholder",null),e([d()],Z.prototype,"popupEnabled",void 0),e([d({type:r})],Z.prototype,"popupTemplate",void 0),e([d({type:v})],Z.prototype,"portal",void 0),e([d()],Z.prototype,"resultCount",void 0),e([d()],Z.prototype,"resultGraphicEnabled",void 0),e([d({readOnly:!0})],Z.prototype,"resultGraphic",void 0),e([d({readOnly:!0})],Z.prototype,"results",void 0),e([d({readOnly:!0})],Z.prototype,"selectedSuggestion",void 0),e([d()],Z.prototype,"searchAllEnabled",void 0),e([d({readOnly:!0})],Z.prototype,"selectedResult",void 0),e([d()],Z.prototype,"searchTerm",null),e([d({type:j})],Z.prototype,"sources",void 0),e([d({readOnly:!0})],Z.prototype,"state",null),e([d()],Z.prototype,"suggestionDelay",void 0),e([d()],Z.prototype,"suggestionCount",void 0),e([d({readOnly:!0})],Z.prototype,"suggestions",void 0),e([d()],Z.prototype,"suggestionsEnabled",void 0),e([d({readOnly:!0})],Z.prototype,"updating",null),e([d()],Z.prototype,"view",void 0),e([d()],Z.prototype,"clear",null),Z=e([m("esri.widgets.Search.SearchViewModel")],Z);const q=Z;export{q as default};
|
package/widgets/Search.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import s from"../PopupTemplate.js";import{deprecateWidget as o,deprecatedPropertyValue as r}from"../core/deprecate.js";import i from"../core/Logger.js";import{destroyMaybe as l,abortMaybe as n}from"../core/maybe.js";import{ignoreAbortErrors as a,isAbortError as c}from"../core/promiseUtils.js";import{watch as u,initial as h}from"../core/reactiveUtils.js";import{waitAnimationFrame as d}from"../core/scheduling.js";import{property as p,subclass as g}from"../core/accessorSupport/decorators.js";import m from"../portal/Portal.js";import v from"./Widget.js";import{css as _}from"./Search/css.js";import w from"./Search/SearchResultRenderer.js";import M from"./Search/SearchViewModel.js";import{SourceCollection as S}from"./Search/types.js";import{loadCalciteComponents as b}from"./support/componentsUtils.js";import{globalCss as y}from"./support/globalCss.js";import{messageBundle as f,vmEvent as C,tsx as T}from"./support/widget.js";let A=class extends v{constructor(e,t){super(e,t),this._currentLocationValue=`${this.id}-search-use-current-location`,this._autocompleteNode=null,this._focusAbortController=null,this._searchResultRenderer=new w,this._suggestController=null,this._searchController=null,this._lastSearchTerm="",this._locateFailed=!1,this._showNoResults=!1,this.disabled=!1,this.messages=null,this.messagesCommon=null,this.viewModel=new M,this._renderSearchResultsContent=()=>this._searchResultRenderer,o(i.getLogger(this),"Search","arcgis-search",{version:"4.33"}),this.addHandles([u(()=>this.viewModel,e=>this._searchResultRenderer.viewModel=e,h),u(()=>this.viewModel.results,()=>this._searchResultRenderer.showMoreResultsOpen=!1),u(()=>this.messages,e=>this.viewModel.messages=e),u(()=>this.viewModel?.defaultPopupTemplate,e=>{e&&(e.content=this._renderSearchResultsContent)},h),u(()=>this.viewModel?.view?.popupElement&&this.viewModel?.defaultPopupTemplate,()=>{if(this.viewModel?.defaultPopupTemplate&&this.viewModel?.view?.popupElement){const e=document.createElement("arcgis-search-result-renderer");e.viewModel=this.viewModel,e.messages=this.messages,this.viewModel.defaultPopupTemplate.content=e}},h)])}loadDependencies(){return b({autocomplete:()=>import("@esri/calcite-components/dist/components/calcite-autocomplete"),"autocomplete-item-group":()=>import("@esri/calcite-components/dist/components/calcite-autocomplete-item-group"),"autocomplete-item":()=>import("@esri/calcite-components/dist/components/calcite-autocomplete-item"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),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"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._cancelQueries(),this._searchResultRenderer=l(this._searchResultRenderer),this._focusAbortController?.abort()}get _isDisabled(){const{state:e}=this.viewModel;return"disabled"===e||"loading"===e||this.disabled}get _showCurrentLocation(){return this.locationEnabled&&!this.searchTerm?.trim()}get _effectiveActiveMenu(){const{activeMenu:e}=this;return this._isDisabled?"none":"warning"===e?"suggestion":e}get activeMenu(){return"none"}set activeMenu(e){"warning"===e&&r(i.getLogger(this),"activeMenu","warning",{replacement:"Use the value 'suggestion' instead",version:"4.32",warnOnce:!0}),this._overrideIfSome("activeMenu",e)}get activeSource(){return this.viewModel?.activeSource}get activeSourceIndex(){return this.viewModel.activeSourceIndex}set activeSourceIndex(e){this.viewModel.activeSourceIndex=e}get allPlaceholder(){return this.viewModel.allPlaceholder}set allPlaceholder(e){this.viewModel.allPlaceholder=e}get allSources(){return this.viewModel.allSources}get autoNavigate(){return this.viewModel.autoNavigate}set autoNavigate(e){this.viewModel.autoNavigate=e}get autoSelect(){return this.viewModel.autoSelect}set autoSelect(e){this.viewModel.autoSelect=e}get defaultSources(){return this.viewModel.defaultSources}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"search"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultSources(){return this.viewModel.includeDefaultSources}set includeDefaultSources(e){this.viewModel.includeDefaultSources=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get locationEnabled(){return this.viewModel.locationEnabled}set locationEnabled(e){this.viewModel.locationEnabled=e}get maxResults(){return this.viewModel.maxResults}set maxResults(e){this.viewModel.maxResults=e}get maxSuggestions(){return this.viewModel.maxSuggestions}set maxSuggestions(e){this.viewModel.maxSuggestions=e}get minSuggestCharacters(){return this.viewModel.minSuggestCharacters}set minSuggestCharacters(e){this.viewModel.minSuggestCharacters=e}get popupEnabled(){return this.viewModel.popupEnabled}set popupEnabled(e){this.viewModel.popupEnabled=e}get popupTemplate(){return this.viewModel.popupTemplate}set popupTemplate(e){this.viewModel.popupTemplate=e}get portal(){return this.viewModel?.portal}set portal(e){this.viewModel&&(this.viewModel.portal=e)}get resultGraphic(){return this.viewModel.resultGraphic}set resultGraphic(e){this.viewModel.resultGraphic=e}get resultGraphicEnabled(){return this.viewModel.resultGraphicEnabled}set resultGraphicEnabled(e){this.viewModel.resultGraphicEnabled=e}get results(){return this.viewModel.results}get searchAllEnabled(){return this.viewModel.searchAllEnabled}set searchAllEnabled(e){this.viewModel.searchAllEnabled=e}get searchTerm(){return this.viewModel.searchTerm}set searchTerm(e){this.viewModel.searchTerm=e}get selectedResult(){return this.viewModel.selectedResult}get sources(){return this.viewModel.sources}set sources(e){this.viewModel.sources=e}get suggestions(){return this.viewModel.suggestions}get suggestionsEnabled(){return this.viewModel.suggestionsEnabled}set suggestionsEnabled(e){this.viewModel.suggestionsEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}clear(){this._locateFailed=!1,this.viewModel.clear()}focus(){this._handleFocus(),this._emitFocus()}blur(){this._autocompleteNode?.blur(),this._emitBlur()}async search(e){this._cancelQueries();const t=new AbortController,{signal:s}=t;this._searchController=t;try{const o=await this.viewModel.search(e,{signal:s});if(this._searchController!==t)return;return o?.numResults||(this._showNoResults=!0,this.activeMenu="suggestion"),this._searchController=null,o}catch(o){if(this._searchController!==t)return;return void(this._searchController=null)}}async suggest(e){this._cancelSuggest();const t=new AbortController,{signal:s}=t;this._suggestController=t;try{const o=await this.viewModel.suggest(e,null,{signal:s});if(this._suggestController!==t)return;return this._suggestController=null,o?.numResults&&(this.activeMenu="suggestion",this._scrollToTopSuggestion()),o}catch(o){return this._suggestController!==t||(this._suggestController=null),null}}render(){return T("div",{class:this.classes(_.base,y.widget)},T("div",{class:_.container},this._renderSourcesMenu(),this._renderForm()))}_handleInputKeydown(e){"Tab"===e.key&&this._cancelSuggest()}_emitFocus(){this.emit("search-focus")}_emitBlur(){this.emit("search-blur")}async _handleFocus(){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const e=this._focusAbortController.signal;await a(d(e)),this._autocompleteNode?.setFocus()}_renderSourcesMenu(){const{messages:e,_isDisabled:t,_effectiveActiveMenu:s}=this,{allSources:o,searchAllEnabled:r}=this.viewModel;return o.length>1?T("calcite-dropdown",{bind:this,class:_.dropdown,disabled:t,open:"source"===s,overlayPositioning:"fixed",onCalciteDropdownClose:this._handleSourceClose,onCalciteDropdownOpen:this._handleSourceOpen,onCalciteDropdownSelect:this._handleSourceSelect},T("calcite-button",{appearance:"outline-fill",iconStart:"caret-down",kind:"neutral",label:e.searchIn,slot:"trigger"}),T("calcite-dropdown-group",{groupTitle:e.searchIn},r?this._renderSource(M.ALL_INDEX):null,o.map((e,t)=>this._renderSource(t)).toArray())):null}_renderUseCurrentLocation(){const{_currentLocationValue:e}=this;return T("calcite-autocomplete-item",{heading:this.messages.useCurrentLocation,iconStart:"gps-on",key:e,value:e})}_handleAutocompleteCreate(e){this._autocompleteNode=e}_handleCalciteAutocompleteTextInput(e){const t=e.target.inputValue;t!==this.viewModel.searchTerm&&(this.viewModel.searchTerm=t,t||this.clear(),this.suggest())}_handleAutocompleteOpen(){this.activeMenu="suggestion"}_handleAutocompleteClose(){"suggestion"===this.activeMenu&&(this.activeMenu="none")}_handleCalciteAutocompleteChange(e){const t=e.target.value;if(t===this._currentLocationValue)return void this._useCurrentLocation();const s=JSON.parse(t),o=this.viewModel.suggestions?.find(({sourceIndex:e})=>e===s.sourceIndex)?.results?.find(({key:e})=>`${e}`==`${s.key}`);o&&this.search(o)}_renderAutocomplete(){const{_effectiveActiveMenu:e,messages:t,_isDisabled:s}=this,{maxInputLength:o,placeholder:r,searchTerm:i,state:l}=this.viewModel,n=this.label??t.searchButtonTitle??"";return T("calcite-autocomplete",{afterCreate:this._handleAutocompleteCreate,autocomplete:"off",bind:this,class:_.autocomplete,disabled:s,icon:this.icon||!1,inputValue:i,label:n,loading:"searching"===l,maxLength:o,name:this.id,onblur:this._emitBlur,onfocus:this._emitFocus,onkeydown:this._handleInputKeydown,open:"suggestion"===e,overlayPositioning:"fixed",placeholder:r,title:i?"":r,onCalciteAutocompleteChange:this._handleCalciteAutocompleteChange,onCalciteAutocompleteClose:this._handleAutocompleteClose,onCalciteAutocompleteOpen:this._handleAutocompleteOpen,onCalciteAutocompleteTextChange:this._handleCalciteAutocompleteTextInput,onCalciteAutocompleteTextInput:this._handleCalciteAutocompleteTextInput},this._renderSuggestions(),this._renderNotices())}_renderForm(){return T("form",{bind:this,class:_.form,disabled:this._isDisabled,key:_.form,onsubmit:this._formSubmit,role:"search"},this._renderAutocomplete(),T("button",{class:_.submitButton,type:"submit"},this.label??this.messages.searchButtonTitle??""))}_renderSuggestGroup(e){return e.results?.map(e=>this._renderSuggestion(e))}_renderSuggestions(){const{suggestions:e}=this.viewModel;return this._showNoResults?null:this._showCurrentLocation?this._renderUseCurrentLocation():e?.map(e=>this._renderSuggestResults(e))}_renderSuggestResults(e){const{allSources:t,activeSourceIndex:s}=this.viewModel,{sourceIndex:o}=e,r=e.results?.length,i=t.length>1&&s===M.ALL_INDEX,l=this._getSourceName(o);return r&&i?T("calcite-autocomplete-item-group",{heading:l,key:`suggestion-group-${l}-${o}`},this._renderSuggestGroup(e)):this._renderSuggestGroup(e)}_renderSuggestion({key:e,sourceIndex:t,text:s}){const o={key:e,sourceIndex:t};return T("calcite-autocomplete-item",{heading:s??this.messages.untitledResult,key:`suggestion_${e}`,value:JSON.stringify(o)})}_renderSource(e){const t=this._getSourceName(e);return T("calcite-dropdown-item",{"data-source-index":`${e}`,key:`source-${t}-${e}`,selected:e===this.viewModel.activeSourceIndex},t)}_renderNoResultsWarning(e){const{messages:s}=this,o=e?t(s.noResultsFoundForValue,{value:`"${e}"`}):s.noResultsFound;return T("calcite-notice",{icon:"exclamation-mark-triangle",key:"no-results-warning",kind:"warning",open:!0,slot:"content-bottom"},T("div",{slot:"title"},s.noResults),T("div",{slot:"message"},o))}_renderLocateError(){return T("calcite-notice",{icon:"exclamation-mark-circle",key:"locate-warning",kind:"danger",open:!0,slot:"content-bottom"},T("div",{slot:"message"},this.messages.locateError))}_renderNotices(){return this._locateFailed?this._renderLocateError():this._showNoResults?this._renderNoResultsWarning(this._lastSearchTerm??this.viewModel.searchTerm):null}async _useCurrentLocation(){this._cancelQueries();const e=new AbortController,{signal:t}=e;this._searchController=e;try{await this.viewModel.searchNearby({signal:t})}catch(s){c(s)||(this._locateFailed=!0,this.activeMenu="suggestion")}finally{this._searchController=null}}_handleSourceOpen(){this.activeMenu="source"}_handleSourceClose(){"source"===this.activeMenu&&(this.activeMenu="none")}_handleSourceSelect(e){const t=e.target.selectedItems[0].getAttribute("data-source-index");t&&(this.viewModel.activeSourceIndex=parseInt(t,10))}_cancelSuggest(){this.activeMenu="none",this._locateFailed=!1,this._showNoResults=!1,this._suggestController=n(this._suggestController)}_cancelQueries(){this._cancelSuggest(),this._searchController=n(this._searchController)}_scrollToTopSuggestion(){this._autocompleteNode?.scrollContentTo({top:0})}_formSubmit(e){e.preventDefault(),this.activeMenu="none",this._lastSearchTerm=this.searchTerm,this.searchTerm&&this.search()}_getSourceName(e){const{messages:t}=this,{allSources:s}=this.viewModel,o=s.at(e);return e===M.ALL_INDEX?t.all:o?.name||t.untitledSource}};e([p()],A.prototype,"_locateFailed",void 0),e([p()],A.prototype,"_showNoResults",void 0),e([p()],A.prototype,"_isDisabled",null),e([p()],A.prototype,"_showCurrentLocation",null),e([p()],A.prototype,"_effectiveActiveMenu",null),e([p()],A.prototype,"activeMenu",null),e([p({readOnly:!0})],A.prototype,"activeSource",null),e([p()],A.prototype,"activeSourceIndex",null),e([p()],A.prototype,"allPlaceholder",null),e([p({readOnly:!0})],A.prototype,"allSources",null),e([p()],A.prototype,"autoNavigate",null),e([p()],A.prototype,"autoSelect",null),e([p({readOnly:!0})],A.prototype,"defaultSources",null),e([p()],A.prototype,"disabled",void 0),e([p()],A.prototype,"goToOverride",null),e([p()],A.prototype,"icon",null),e([p()],A.prototype,"includeDefaultSources",null),e([p()],A.prototype,"label",null),e([p()],A.prototype,"locationEnabled",null),e([p()],A.prototype,"maxResults",null),e([p()],A.prototype,"maxSuggestions",null),e([p(),f("esri/widgets/Search/t9n/Search")],A.prototype,"messages",void 0),e([p(),f("esri/t9n/common")],A.prototype,"messagesCommon",void 0),e([p()],A.prototype,"minSuggestCharacters",null),e([p()],A.prototype,"popupEnabled",null),e([p({type:s})],A.prototype,"popupTemplate",null),e([p({type:m})],A.prototype,"portal",null),e([p()],A.prototype,"resultGraphic",null),e([p()],A.prototype,"resultGraphicEnabled",null),e([p({readOnly:!0})],A.prototype,"results",null),e([p()],A.prototype,"searchAllEnabled",null),e([p()],A.prototype,"searchTerm",null),e([p({readOnly:!0})],A.prototype,"selectedResult",null),e([p({type:S})],A.prototype,"sources",null),e([p({readOnly:!0})],A.prototype,"suggestions",null),e([p()],A.prototype,"suggestionsEnabled",null),e([p()],A.prototype,"view",null),e([C(["search-complete","search-clear","search-start","select-result","suggest-start","suggest-complete"]),p({type:M})],A.prototype,"viewModel",void 0),A=e([g("esri.widgets.Search")],A);const R=A;export{R as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import s from"../PopupTemplate.js";import{deprecateWidget as o,deprecatedPropertyValue as r}from"../core/deprecate.js";import i from"../core/Logger.js";import{destroyMaybe as l,abortMaybe as n}from"../core/maybe.js";import{ignoreAbortErrors as a,isAbortError as c}from"../core/promiseUtils.js";import{watch as u,on as h,initial as d}from"../core/reactiveUtils.js";import{waitAnimationFrame as p}from"../core/scheduling.js";import{property as g,subclass as m}from"../core/accessorSupport/decorators.js";import v from"../portal/Portal.js";import _ from"./Widget.js";import{css as w}from"./Search/css.js";import M from"./Search/SearchResultRenderer.js";import S from"./Search/SearchViewModel.js";import{SourceCollection as b}from"./Search/types.js";import{loadCalciteComponents as y}from"./support/componentsUtils.js";import{globalCss as f}from"./support/globalCss.js";import{messageBundle as C,vmEvent as T,tsx as A}from"./support/widget.js";let R=class extends _{constructor(e,t){super(e,t),this._currentLocationValue=`${this.id}-search-use-current-location`,this._autocompleteNode=null,this._focusAbortController=null,this._searchResultRenderer=new M,this._suggestController=null,this._searchController=null,this._lastSearchTerm="",this._locateFailed=!1,this._showNoResults=!1,this.disabled=!1,this.messages=null,this.messagesCommon=null,this.viewModel=new S,this._renderSearchResultsContent=()=>this._searchResultRenderer,o(i.getLogger(this),"Search","arcgis-search",{version:"4.33"}),this.addHandles([u(()=>this.viewModel,e=>this._searchResultRenderer.viewModel=e,d),u(()=>this.viewModel.results,()=>this._searchResultRenderer.showMoreResultsOpen=!1),u(()=>this.messages,e=>this.viewModel.messages=e),u(()=>this.viewModel?.defaultPopupTemplate,e=>{e&&(e.content=this._renderSearchResultsContent)},d),u(()=>this.viewModel?.view?.popupElement&&this.viewModel?.defaultPopupTemplate,()=>{if(this.viewModel?.defaultPopupTemplate&&this.viewModel?.view?.popupElement){const e=document.createElement("arcgis-search-result-renderer");e.viewModel=this.viewModel,e.messages=this.messages,this.viewModel.defaultPopupTemplate.content=e}},d),h(()=>this.viewModel,"popup-open",async e=>{const{features:t,location:s}=e;await(this.view?.openPopup({features:t,location:s??void 0}))})])}loadDependencies(){return y({autocomplete:()=>import("@esri/calcite-components/dist/components/calcite-autocomplete"),"autocomplete-item-group":()=>import("@esri/calcite-components/dist/components/calcite-autocomplete-item-group"),"autocomplete-item":()=>import("@esri/calcite-components/dist/components/calcite-autocomplete-item"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),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"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._cancelQueries(),this._searchResultRenderer=l(this._searchResultRenderer),this._focusAbortController?.abort()}get _isDisabled(){const{state:e}=this.viewModel;return"disabled"===e||"loading"===e||this.disabled}get _showCurrentLocation(){return this.locationEnabled&&!this.searchTerm?.trim()}get _effectiveActiveMenu(){const{activeMenu:e}=this;return this._isDisabled?"none":"warning"===e?"suggestion":e}get activeMenu(){return"none"}set activeMenu(e){"warning"===e&&r(i.getLogger(this),"activeMenu","warning",{replacement:"Use the value 'suggestion' instead",version:"4.32",warnOnce:!0}),this._overrideIfSome("activeMenu",e)}get activeSource(){return this.viewModel?.activeSource}get activeSourceIndex(){return this.viewModel.activeSourceIndex}set activeSourceIndex(e){this.viewModel.activeSourceIndex=e}get allPlaceholder(){return this.viewModel.allPlaceholder}set allPlaceholder(e){this.viewModel.allPlaceholder=e}get allSources(){return this.viewModel.allSources}get autoNavigate(){return this.viewModel.autoNavigate}set autoNavigate(e){this.viewModel.autoNavigate=e}get autoSelect(){return this.viewModel.autoSelect}set autoSelect(e){this.viewModel.autoSelect=e}get defaultSources(){return this.viewModel.defaultSources}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"search"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultSources(){return this.viewModel.includeDefaultSources}set includeDefaultSources(e){this.viewModel.includeDefaultSources=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get locationEnabled(){return this.viewModel.locationEnabled}set locationEnabled(e){this.viewModel.locationEnabled=e}get maxResults(){return this.viewModel.maxResults}set maxResults(e){this.viewModel.maxResults=e}get maxSuggestions(){return this.viewModel.maxSuggestions}set maxSuggestions(e){this.viewModel.maxSuggestions=e}get minSuggestCharacters(){return this.viewModel.minSuggestCharacters}set minSuggestCharacters(e){this.viewModel.minSuggestCharacters=e}get popupEnabled(){return this.viewModel.popupEnabled}set popupEnabled(e){this.viewModel.popupEnabled=e}get popupTemplate(){return this.viewModel.popupTemplate}set popupTemplate(e){this.viewModel.popupTemplate=e}get portal(){return this.viewModel?.portal}set portal(e){this.viewModel&&(this.viewModel.portal=e)}get resultGraphic(){return this.viewModel.resultGraphic}set resultGraphic(e){this.viewModel.resultGraphic=e}get resultGraphicEnabled(){return this.viewModel.resultGraphicEnabled}set resultGraphicEnabled(e){this.viewModel.resultGraphicEnabled=e}get results(){return this.viewModel.results}get searchAllEnabled(){return this.viewModel.searchAllEnabled}set searchAllEnabled(e){this.viewModel.searchAllEnabled=e}get searchTerm(){return this.viewModel.searchTerm}set searchTerm(e){this.viewModel.searchTerm=e}get selectedResult(){return this.viewModel.selectedResult}get sources(){return this.viewModel.sources}set sources(e){this.viewModel.sources=e}get suggestions(){return this.viewModel.suggestions}get suggestionsEnabled(){return this.viewModel.suggestionsEnabled}set suggestionsEnabled(e){this.viewModel.suggestionsEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}clear(){this._locateFailed=!1,this.viewModel.clear()}focus(){this._handleFocus(),this._emitFocus()}blur(){this._autocompleteNode?.blur(),this._emitBlur()}async search(e){this._cancelQueries();const t=new AbortController,{signal:s}=t;this._searchController=t;try{const o=await this.viewModel.search(e,{signal:s});if(this._searchController!==t)return;return o?.numResults||(this._showNoResults=!0,this.activeMenu="suggestion"),this._searchController=null,o}catch(o){if(this._searchController!==t)return;return void(this._searchController=null)}}async suggest(e){this._cancelSuggest();const t=new AbortController,{signal:s}=t;this._suggestController=t;try{const o=await this.viewModel.suggest(e,null,{signal:s});if(this._suggestController!==t)return;return this._suggestController=null,o?.numResults&&(this.activeMenu="suggestion",this._scrollToTopSuggestion()),o}catch(o){return this._suggestController!==t||(this._suggestController=null),null}}render(){return A("div",{class:this.classes(w.base,f.widget)},A("div",{class:w.container},this._renderSourcesMenu(),this._renderForm()))}_handleInputKeydown(e){"Tab"===e.key&&this._cancelSuggest()}_emitFocus(){this.emit("search-focus")}_emitBlur(){this.emit("search-blur")}async _handleFocus(){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const e=this._focusAbortController.signal;await a(p(e)),this._autocompleteNode?.setFocus()}_renderSourcesMenu(){const{messages:e,_isDisabled:t,_effectiveActiveMenu:s}=this,{allSources:o,searchAllEnabled:r}=this.viewModel;return o.length>1?A("calcite-dropdown",{bind:this,class:w.dropdown,disabled:t,open:"source"===s,overlayPositioning:"fixed",onCalciteDropdownClose:this._handleSourceClose,onCalciteDropdownOpen:this._handleSourceOpen,onCalciteDropdownSelect:this._handleSourceSelect},A("calcite-button",{appearance:"outline-fill",iconStart:"caret-down",kind:"neutral",label:e.searchIn,slot:"trigger"}),A("calcite-dropdown-group",{groupTitle:e.searchIn},r?this._renderSource(S.ALL_INDEX):null,o.map((e,t)=>this._renderSource(t)).toArray())):null}_renderUseCurrentLocation(){const{_currentLocationValue:e}=this;return A("calcite-autocomplete-item",{heading:this.messages.useCurrentLocation,iconStart:"gps-on",key:e,value:e})}_handleAutocompleteCreate(e){this._autocompleteNode=e}_handleCalciteAutocompleteTextInput(e){const t=e.target.inputValue;t!==this.viewModel.searchTerm&&(this.viewModel.searchTerm=t,t||this.clear(),this.suggest())}_handleAutocompleteOpen(){this.activeMenu="suggestion"}_handleAutocompleteClose(){"suggestion"===this.activeMenu&&(this.activeMenu="none")}_handleCalciteAutocompleteChange(e){const t=e.target.value;if(t===this._currentLocationValue)return void this._useCurrentLocation();const s=JSON.parse(t),o=this.viewModel.suggestions?.find(({sourceIndex:e})=>e===s.sourceIndex)?.results?.find(({key:e})=>`${e}`==`${s.key}`);o&&this.search(o)}_renderAutocomplete(){const{_effectiveActiveMenu:e,messages:t,_isDisabled:s}=this,{maxInputLength:o,placeholder:r,searchTerm:i,state:l}=this.viewModel,n=this.label??t.searchButtonTitle??"";return A("calcite-autocomplete",{afterCreate:this._handleAutocompleteCreate,autocomplete:"off",bind:this,class:w.autocomplete,disabled:s,icon:this.icon||!1,inputValue:i,label:n,loading:"searching"===l,maxLength:o,name:this.id,onblur:this._emitBlur,onfocus:this._emitFocus,onkeydown:this._handleInputKeydown,open:"suggestion"===e,overlayPositioning:"fixed",placeholder:r,title:i?"":r,onCalciteAutocompleteChange:this._handleCalciteAutocompleteChange,onCalciteAutocompleteClose:this._handleAutocompleteClose,onCalciteAutocompleteOpen:this._handleAutocompleteOpen,onCalciteAutocompleteTextChange:this._handleCalciteAutocompleteTextInput,onCalciteAutocompleteTextInput:this._handleCalciteAutocompleteTextInput},this._renderSuggestions(),this._renderNotices())}_renderForm(){return A("form",{bind:this,class:w.form,disabled:this._isDisabled,key:w.form,onsubmit:this._formSubmit,role:"search"},this._renderAutocomplete(),A("button",{class:w.submitButton,type:"submit"},this.label??this.messages.searchButtonTitle??""))}_renderSuggestGroup(e){return e.results?.map(e=>this._renderSuggestion(e))}_renderSuggestions(){const{suggestions:e}=this.viewModel;return this._showNoResults?null:this._showCurrentLocation?this._renderUseCurrentLocation():e?.map(e=>this._renderSuggestResults(e))}_renderSuggestResults(e){const{allSources:t,activeSourceIndex:s}=this.viewModel,{sourceIndex:o}=e,r=e.results?.length,i=t.length>1&&s===S.ALL_INDEX,l=this._getSourceName(o);return r&&i?A("calcite-autocomplete-item-group",{heading:l,key:`suggestion-group-${l}-${o}`},this._renderSuggestGroup(e)):this._renderSuggestGroup(e)}_renderSuggestion({key:e,sourceIndex:t,text:s}){const o={key:e,sourceIndex:t};return A("calcite-autocomplete-item",{heading:s??this.messages.untitledResult,key:`suggestion_${e}`,value:JSON.stringify(o)})}_renderSource(e){const t=this._getSourceName(e);return A("calcite-dropdown-item",{"data-source-index":`${e}`,key:`source-${t}-${e}`,selected:e===this.viewModel.activeSourceIndex},t)}_renderNoResultsWarning(e){const{messages:s}=this,o=e?t(s.noResultsFoundForValue,{value:`"${e}"`}):s.noResultsFound;return A("calcite-notice",{icon:"exclamation-mark-triangle",key:"no-results-warning",kind:"warning",open:!0,slot:"content-bottom"},A("div",{slot:"title"},s.noResults),A("div",{slot:"message"},o))}_renderLocateError(){return A("calcite-notice",{icon:"exclamation-mark-circle",key:"locate-warning",kind:"danger",open:!0,slot:"content-bottom"},A("div",{slot:"message"},this.messages.locateError))}_renderNotices(){return this._locateFailed?this._renderLocateError():this._showNoResults?this._renderNoResultsWarning(this._lastSearchTerm??this.viewModel.searchTerm):null}async _useCurrentLocation(){this._cancelQueries();const e=new AbortController,{signal:t}=e;this._searchController=e;try{await this.viewModel.searchNearby({signal:t})}catch(s){c(s)||(this._locateFailed=!0,this.activeMenu="suggestion")}finally{this._searchController=null}}_handleSourceOpen(){this.activeMenu="source"}_handleSourceClose(){"source"===this.activeMenu&&(this.activeMenu="none")}_handleSourceSelect(e){const t=e.target.selectedItems[0].getAttribute("data-source-index");t&&(this.viewModel.activeSourceIndex=parseInt(t,10))}_cancelSuggest(){this.activeMenu="none",this._locateFailed=!1,this._showNoResults=!1,this._suggestController=n(this._suggestController)}_cancelQueries(){this._cancelSuggest(),this._searchController=n(this._searchController)}_scrollToTopSuggestion(){this._autocompleteNode?.scrollContentTo({top:0})}_formSubmit(e){e.preventDefault(),this.activeMenu="none",this._lastSearchTerm=this.searchTerm,this.searchTerm&&this.search()}_getSourceName(e){const{messages:t}=this,{allSources:s}=this.viewModel,o=s.at(e);return e===S.ALL_INDEX?t.all:o?.name||t.untitledSource}};e([g()],R.prototype,"_locateFailed",void 0),e([g()],R.prototype,"_showNoResults",void 0),e([g()],R.prototype,"_isDisabled",null),e([g()],R.prototype,"_showCurrentLocation",null),e([g()],R.prototype,"_effectiveActiveMenu",null),e([g()],R.prototype,"activeMenu",null),e([g({readOnly:!0})],R.prototype,"activeSource",null),e([g()],R.prototype,"activeSourceIndex",null),e([g()],R.prototype,"allPlaceholder",null),e([g({readOnly:!0})],R.prototype,"allSources",null),e([g()],R.prototype,"autoNavigate",null),e([g()],R.prototype,"autoSelect",null),e([g({readOnly:!0})],R.prototype,"defaultSources",null),e([g()],R.prototype,"disabled",void 0),e([g()],R.prototype,"goToOverride",null),e([g()],R.prototype,"icon",null),e([g()],R.prototype,"includeDefaultSources",null),e([g()],R.prototype,"label",null),e([g()],R.prototype,"locationEnabled",null),e([g()],R.prototype,"maxResults",null),e([g()],R.prototype,"maxSuggestions",null),e([g(),C("esri/widgets/Search/t9n/Search")],R.prototype,"messages",void 0),e([g(),C("esri/t9n/common")],R.prototype,"messagesCommon",void 0),e([g()],R.prototype,"minSuggestCharacters",null),e([g()],R.prototype,"popupEnabled",null),e([g({type:s})],R.prototype,"popupTemplate",null),e([g({type:v})],R.prototype,"portal",null),e([g()],R.prototype,"resultGraphic",null),e([g()],R.prototype,"resultGraphicEnabled",null),e([g({readOnly:!0})],R.prototype,"results",null),e([g()],R.prototype,"searchAllEnabled",null),e([g()],R.prototype,"searchTerm",null),e([g({readOnly:!0})],R.prototype,"selectedResult",null),e([g({type:b})],R.prototype,"sources",null),e([g({readOnly:!0})],R.prototype,"suggestions",null),e([g()],R.prototype,"suggestionsEnabled",null),e([g()],R.prototype,"view",null),e([T(["search-complete","search-clear","search-start","select-result","suggest-start","suggest-complete"]),g({type:S})],R.prototype,"viewModel",void 0),R=e([m("esri.widgets.Search")],R);const x=R;export{x as default};
|
package/widgets/Sketch.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{isSome as o}from"../core/arrayUtils.js";import{handlesGroup as i}from"../core/handleUtils.js";import l from"../core/Logger.js";import{removeMaybe as s,destroyMaybe as n}from"../core/maybe.js";import{ignoreAbortErrors as r}from"../core/promiseUtils.js";import{watch as a,when as p,syncAndInitial as c}from"../core/reactiveUtils.js";import{property as d,subclass as h}from"../core/accessorSupport/decorators.js";import{symbolTypes as u}from"../symbols/support/typeUtils.js";import v from"../views/interactive/sketch/SketchLabelOptions.js";import m from"../views/interactive/sketch/SketchTooltipOptions.js";import g from"../views/interactive/sketch/SketchValueOptions.js";import y from"./Widget.js";import f from"./Sketch/SketchViewModel.js";import{VisibleElements as b}from"./Sketch/VisibleElements.js";import _ from"./Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js";import{loadCalciteComponents as w}from"./support/componentsUtils.js";import T from"./support/SelectionToolbar.js";import M from"./support/SketchTooltipControls.js";import C from"./support/SnappingControls.js";import{tsx as O,messageBundle as S,vmEvent as k}from"./support/widget.js";import P from"./support/SelectionToolbar/VisibleElements.js";import x from"./support/SketchTooltipControls/VisibleElements.js";const E="esri-sketch",I={base:E,vertical:`${E}--vertical`,docked:`${E}-bar`,floating:`${E}-pad`,chipHorizontal:`${E}__selection-count-chip--horizontal`,chipVertical:`${E}__selection-count-chip--vertical`,chipVerticalSmall:`${E}__selection-count-chip--vertical--s`,popoverWrapper:`${E}__popover-wrapper`},R={point:"pin",polyline:"line",polygon:"polygon",rectangle:"rectangle",circle:"circle",multipoint:"pins",mesh:"i3d-building",freehandPolygon:"freehand-area",freehandPolyline:"freehand",text:"add-text"};let G=class extends y{constructor(e,t){super(e,t),this._selectionToolbar=null,this._viewModelHandlesGroup=null,this._popoverElement=null,this.availableCreateTools=["point","polyline","polygon","rectangle","circle"],this.customToolOptions=null,this.customActions=null,this.toolbarKind="floating",this.contextualToolLocation="separate",this.groupCollapsePriorities=null,this.groupAllowCollapseOptions=null,this.messages=null,this.messagesCommon=null,this.visibleElements=new b,this._defaultViewModel=null,this._activeCustomToolOptions=null,this._calcitePopoverReferenceElement=null,this._relativeLocation="top",this._popoverOpen=!1,this._activateCreateTool=this._activateCreateTool.bind(this),this.viewModel=e?.viewModel||(this._defaultViewModel=new f({creationMode:e?.creationMode??"continuous"}))}initialize(){const{layer:e,view:t}=this,o="2d"===t?.type,l=new T({persistSelection:!1,visibleElements:new P({chip:!1,lassoTool:o,operationTypeControls:!1,pan:!1,pointTool:!1,rectangleTool:o}),view:t,sources:e?[e]:null,scale:this.scale});this.addHandles([a(()=>this.viewModel,e=>{this._viewModelHandlesGroup=s(this._viewModelHandlesGroup),e&&(this._viewModelHandlesGroup=i([e.on("create",()=>this.scheduleRender()),e.on("update",()=>this.scheduleRender()),e.on("delete",e=>this.emit("delete",e)),e.on("undo",()=>this.scheduleRender()),e.on("redo",()=>this.scheduleRender()),a(()=>e.layer,e=>{this._selectionToolbar&&(this._selectionToolbar.sources=e?[e]:null)}),a(()=>e.view,e=>{this._selectionToolbar&&(this._selectionToolbar.view=e)}),a(()=>e.state,()=>this.notifyChange("state"))]))},c),p(()=>l.activeOperation,()=>this.viewModel.cancel()),l.on("complete",e=>this._onSelectionOperationComplete(e)),a(()=>{const{view:e,visibleElements:{selectionTools:t}}=this;return{lassoTool:"3d"!==e?.type&&!!t?.["lasso-selection"],rectangleTool:"3d"!==e?.type&&!!t?.["rectangle-selection"]}},e=>{Object.assign(l.visibleElements,e)},c)]),this._selectionToolbar=l}loadDependencies(){return w({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._selectionToolbar?.destroy(),this._viewModelHandlesGroup=s(this._viewModelHandlesGroup)}get activeTool(){const e=this._selectionToolbar?.activeOperation;if(e)switch(e.toolName){case"lasso":return"lasso-selection";case"rectangle":return"rectangle-selection";case"default":return"custom-selection"}const t=this._effectiveAvailableCreateTools,{activeTool:o,activeCreateToolDrawMode:i}=this.viewModel;return"polygon"===o&&"freehand"===i&&t?.includes("freehandPolygon")?"freehandPolygon":"polyline"===o&&"freehand"===i&&t?.includes("freehandPolyline")?"freehandPolyline":this.viewModel.activeTool}get activeTooltip(){return this.viewModel.activeTooltip}get createGraphic(){return this.viewModel.createGraphic}get creationMode(){return this.viewModel.creationMode}set creationMode(e){this.viewModel.creationMode=e}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultUpdateOptions(){return this.viewModel.defaultUpdateOptions}set defaultUpdateOptions(e){this.viewModel.defaultUpdateOptions=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}set layout(e){this._set("layout",e),this._selectionToolbar&&(this._selectionToolbar.layout=e)}get pointSymbol(){return this.viewModel.pointSymbol}set pointSymbol(e){this.viewModel.pointSymbol=e}get polygonSymbol(){return this.viewModel.polygonSymbol}set polygonSymbol(e){this.viewModel.polygonSymbol=e}get polylineSymbol(){return this.viewModel.polylineSymbol}set polylineSymbol(e){this.viewModel.polylineSymbol=e}get textSymbol(){return this.viewModel.textSymbol}set textSymbol(e){this.viewModel.textSymbol=e}set scale(e){this._set("scale",e),this._selectionToolbar&&(this._selectionToolbar.scale=e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get state(){return this._selectionToolbar?.activeOperation?"active":this.viewModel.state}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get updateGraphics(){return this.viewModel.updateGraphics}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){const t=this._get("viewModel");e!==t&&(t&&t===this._defaultViewModel&&n(t),this._set("viewModel",e))}get _effectiveAvailableCreateTools(){const{availableCreateTools:e,view:t,visibleElements:o}=this,i=e?.filter(e=>!!o.createTools?.[e]);return"3d"===t?.type?i?.filter(e=>"multipoint"!==e):i}create(e,t,o){const i=o?.createOptions??t;return this._activeCustomToolOptions=o,r(this.viewModel.create(e,i))}update(e,t){return r(this.viewModel.update(e,t))}complete(){this.viewModel.complete()}cancel(){this._selectionToolbar?.cancel(),this.viewModel.cancel(),this._activeCustomToolOptions=null}undo(){this.viewModel.undo(),this.view?.focus()}redo(){this.viewModel.redo(),this.view?.focus()}delete(){this.viewModel.delete()}duplicate(){return this.viewModel.duplicate()}dismissFloatingElements(){this._popoverOpen=!1}render(){const{toolbarKind:e,layout:t,scale:o}=this,i=this.customActions?.filter(e=>"selection-toolbar"===e.position);return O("div",null,O("div",{classes:{[I.base]:!0,[I.floating]:"floating"===e,[I.docked]:"docked"===e,[I.vertical]:"vertical"===t}},O(_,{barStyle:e,layout:t,scale:o},this._renderSelectionSetItemGroupInline(),O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionTools")??!0,"group-kind":"split-button",key:"selection-split-button",priority:this.groupCollapsePriorities?.get("selectionTools")??0},this._renderDefaultSelectionButton(),this._selectionToolbar?.render(),i?.map(e=>this._renderToolbarItem(e))),this._renderCreateToolActionGroup(),this._renderUndoRedoMenuItemGroup(),this._renderSettingsMenuItemGroup()),this._renderSelectionSetToolbar(),this._renderSettingsMenuPopover()))}_renderSettingsMenuPopover(){const{messagesCommon:e,snappingOptions:t,view:o,viewModel:i,visibleElements:l}=this;if(!this._calcitePopoverReferenceElement)return;const s={directionModePicker:l.directionModePicker,labelsToggle:l.labelsToggle,tooltipsToggle:l.tooltipsToggle},n="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return O("calcite-popover",{afterCreate:e=>this._popoverElement=e,closable:!0,heading:e.settings,label:e.settings,open:this._popoverOpen,overlayPositioning:"fixed",placement:n,referenceElement:this._calcitePopoverReferenceElement,scale:this.scale,onCalcitePopoverBeforeClose:e=>this._beforePopoverClose(e.target),onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget),onCalcitePopoverClose:e=>this._refocusOnView(e.target)},O("div",{class:I.popoverWrapper},Object.values(s).includes(!0)?O(M,{sketchOptions:i.sketchOptions,visibleElements:new x(s)}):void 0,l.snappingControls&&o&&t?O(C,{snappingManager:this.viewModel.snappingManager,snappingOptions:t,view:o,visibleElements:l.snappingControlsElements}):void 0))}_beforePopoverClose(e){e===this._popoverElement&&(this._popoverOpen=!1)}_renderSelectionSetToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSelectionSetItemGroup();return e?.length?O(_,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSelectionSetItemGroupInline(){return"separate"===this.contextualToolLocation?[]:this._renderSelectionSetItemGroup()}_renderUndoRedoMenuItemGroup(){return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("undoRedo")??!0,"group-kind":"split-button",key:"undo-redo-menu",priority:this.groupCollapsePriorities?.get("undoRedo")??10,slot:"actions-end"},this._renderUndoButton(),this._renderRedoButton())}_renderSettingsMenuItemGroup(){const e=[],t=[];this.customActions?.forEach(o=>{"settings-before"===o.position?t.push(o):"settings-after"===o.position&&e.push(o)});const i=[...t.map(e=>this._renderToolbarItem(e)),this._renderSettingsMenuButton(),...e.map(e=>this._renderToolbarItem(e))].filter(o);if(i.length)return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("settings")??!1,"group-kind":"overflow-group",key:"settings-menu",priority:this.groupCollapsePriorities?.get("settings")??1e3,slot:"actions-end"},i)}_renderSelectionSetItemGroup(){if(!this.updateGraphics.length)return[];const e="inline-end"===this.contextualToolLocation?"actions-end":void 0,t=this.customActions?.filter(e=>"before-selection-set"===e.position),o=this.customActions?.filter(e=>"after-selection-set"===e.position),i=this.groupCollapsePriorities?.get("selectionSet")??100;return[O("div",{"group-kind":"measured-content",key:"selection-count-chip-group",priority:i,slot:e},this._renderFeatureCountChip()),O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionSet")??!1,"group-kind":"overflow-group",key:"selection-set-tool-group",priority:i,slot:e},t?.map(e=>this._renderToolbarItem(e)),this._renderDuplicateButton(),this._renderDeleteButton(),o?.map(e=>this._renderToolbarItem(e)))]}_renderDefaultSelectionButton(){if(!this.viewModel.updateOnGraphicClick)return[];const{messages:e,state:t}=this;return this._renderToolbarItem({id:"pointer-select",text:e.selectFeature,icon:"cursor",onclick:this._activateDefaultSelectTool,active:"ready"===t})}_renderCreateToolActionGroup(){const e=this._effectiveAvailableCreateTools?.flatMap(e=>this._renderBuiltInCreateToolItem(e))??[],t=this.customToolOptions?.flatMap(e=>this._renderCustomToolItem(e))??[];return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("createTools")??!0,"group-kind":"overflow-group",key:"create-tools-group",priority:this.groupCollapsePriorities?.get("createTools")??100},e,t)}_renderBuiltInCreateToolItem(e){return this._renderToolbarItem({id:`${e}-button`,text:this.messages.draw[e],icon:R[e],onclick:()=>this._activateCreateTool(e),active:this.activeTool===e&&!this._activeCustomToolOptions})}_renderCustomToolItem(e){const{toolKey:t}=e;return this._renderToolbarItem({id:`custom-${e.toolKey}`,text:e.label,icon:e.icon,onclick:()=>this._activateCreateTool(e.toolName,null,e),active:this._activeCustomToolOptions?.toolKey===t})}_renderUndoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"undo-button",text:this.messages.undo,icon:"undo",disabled:!this.viewModel.canUndo(),onclick:this.undo,flipRTL:!0}):[]}_renderRedoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"redo-button",text:this.messages.redo,icon:"redo",disabled:!this.viewModel.canRedo(),onclick:this.redo,flipRTL:!0}):[]}_renderSettingsMenuButton(){return this.visibleElements.settingsMenu?this._renderToolbarItem({id:"settings-menu-action",text:this.messagesCommon.settings,icon:"gear",active:this._popoverOpen,onclick:()=>this._popoverOpen=!this._popoverOpen,afterCreate:e=>this._calcitePopoverReferenceElement=e,afterUpdate:e=>this._calcitePopoverReferenceElement=e,afterRemoved:()=>this._calcitePopoverReferenceElement=null}):[]}_renderFeatureCountChip(){if(!this.visibleElements.selectionCountLabel)return[];const{layout:e,messages:o,scale:i,id:l,updateGraphics:{length:s}}=this,n=t(o.selectedCount,{count:s}),r="s"===i?99:999,a=s>r?t(o.selectedCountTruncated,{truncated:r}):s,p="s"===i&&"vertical"===e,c=p?`${l}-selection-chip-small`:`${l}-selection-chip`;return[p?O("span",{classes:{[I.chipVertical]:!0,[I.chipVerticalSmall]:"s"===this.scale},id:c,tabIndex:0,title:n},a):O("calcite-chip",{appearance:"outline",class:"horizontal"===e?I.chipHorizontal:I.chipVertical,id:c,kind:"brand",label:n,scale:"l"===i?"m":"s",tabIndex:0,title:"vertical"===e?n:void 0},"vertical"===e?a:n)]}_renderDuplicateButton(){if(!this.visibleElements.duplicateButton)return[];const{messages:e}=this;return this._renderToolbarItem({id:"duplicate",text:this.updateGraphics.length>1?e.duplicateFeatures:e.duplicateFeature,icon:"copy",onclick:this._onDuplicateSelect})}_renderDeleteButton(){if(!this.visibleElements.deleteButton)return[];const{messages:e}=this,t=this.updateGraphics.length>1?e.deleteFeatures:e.deleteFeature;return this._renderToolbarItem({id:"delete",text:t,icon:"trash",onclick:this.delete})}_renderToolbarItem({id:e,text:t,icon:o,disabled:i,onclick:l,active:s,flipRTL:n,afterCreate:r,afterUpdate:a,afterRemoved:p}){const c=`${this.id}-${e}`;return[O("calcite-action",{active:s,afterCreate:r,afterRemoved:p,afterUpdate:a,bind:this,"data-testid":e,disabled:i||"disabled"===this.state,icon:o,iconFlipRtl:n??!1,id:c,key:e,onclick:l,scale:this.scale,text:t,title:t})]}_remeasurePopoverSizes(e){try{const t=e.parentElement,o=this?.view?.container?.getBoundingClientRect(),i=t?.style;if(!(t&&o&&i&&this.view?.container?.contains(t)))return;const l=this._calcitePopoverReferenceElement;if(!l)return;const{bottom:s,top:n}=l.getBoundingClientRect();if("horizontal"===this.layout){const e=s<o.height/2;e!==("top"===this._relativeLocation)&&(this._relativeLocation=e?"top":"bottom"),e?(i?.setProperty("--sketch-view-height-offset",s-o.top+"px"),i?.setProperty("--sketch-view-margin-offset","30px")):(i?.setProperty("--sketch-view-height-offset",o.bottom-n+"px"),i?.setProperty("--sketch-view-margin-offset","15px"))}else"vertical"===this.layout&&(i.setProperty("--sketch-view-height-offset","15px"),i.setProperty("--sketch-view-margin-offset","15px"));const r=e.shadowRoot?.querySelector("div.header")?.getBoundingClientRect().height;i.setProperty("--sketch-popover-header-offset",`${r}px`)}catch(t){l.getLogger(this.declaredClass).warnOnce("Sketch failed to lay out settings menu.",t)}}_activateCreateTool(e,t,o){const i=this._activeCustomToolOptions;if(o||i){if(o?.toolKey===i?.toolKey)return void this.cancel()}else if(this.activeTool===e)return void this.cancel();this._selectionToolbar?.cancel(),this.create(e,t,o)}_onDuplicateSelect(){const e=this.duplicate(),t=this.viewModel.activeTool;"transform"!==t&&"reshape"!==t||this.update(e,{tool:t})}_onSelectionOperationComplete(e){const{viewModel:{defaultUpdateOptions:t}}=this,{selection:o}=e;if(!e.aborted&&o.length){const e=t.tool,i=o.length>1&&"reshape"===e?"transform":e;this.update(o,{...t,tool:i})}this.notifyChange("state")}_activateDefaultSelectTool(){this.cancel(),this.view?.focus()}_refocusOnView(e){this.activeTool&&e===this._popoverElement&&this.view?.focus()}};e([d()],G.prototype,"activeTool",null),e([d({readOnly:!0})],G.prototype,"activeTooltip",null),e([d({cast:e=>{if(!e?.length)return null;const t=new Set(["point","polyline","polygon","rectangle","circle","multipoint","freehandPolyline","freehandPolygon","mesh","text"]);return e.filter(e=>t.has(e))}})],G.prototype,"availableCreateTools",void 0),e([d({readOnly:!0})],G.prototype,"createGraphic",null),e([d()],G.prototype,"creationMode",null),e([d()],G.prototype,"customToolOptions",void 0),e([d()],G.prototype,"customActions",void 0),e([d()],G.prototype,"defaultCreateOptions",null),e([d()],G.prototype,"defaultUpdateOptions",null),e([d()],G.prototype,"icon",null),e([d()],G.prototype,"label",null),e([d({type:v})],G.prototype,"labelOptions",null),e([d()],G.prototype,"layer",null),e([d({type:["horizontal","vertical"],value:"horizontal"})],G.prototype,"layout",null),e([d({types:u})],G.prototype,"pointSymbol",null),e([d({types:u})],G.prototype,"polygonSymbol",null),e([d({types:u})],G.prototype,"polylineSymbol",null),e([d()],G.prototype,"textSymbol",null),e([d({value:"m"})],G.prototype,"scale",null),e([d()],G.prototype,"toolbarKind",void 0),e([d()],G.prototype,"contextualToolLocation",void 0),e([d()],G.prototype,"groupCollapsePriorities",void 0),e([d()],G.prototype,"groupAllowCollapseOptions",void 0),e([d(),S("esri/widgets/Sketch/t9n/Sketch")],G.prototype,"messages",void 0),e([d(),S("esri/t9n/common")],G.prototype,"messagesCommon",void 0),e([d()],G.prototype,"snappingOptions",null),e([d()],G.prototype,"state",null),e([d({type:m})],G.prototype,"tooltipOptions",null),e([d({readOnly:!0})],G.prototype,"updateGraphics",null),e([d({type:g,nonNullable:!0})],G.prototype,"valueOptions",null),e([d()],G.prototype,"view",null),e([d({type:f}),k(["create","update","undo","redo"])],G.prototype,"viewModel",null),e([d({type:b,nonNullable:!0})],G.prototype,"visibleElements",void 0),e([d()],G.prototype,"_effectiveAvailableCreateTools",null),e([d()],G.prototype,"_defaultViewModel",void 0),e([d()],G.prototype,"_activeCustomToolOptions",void 0),e([d()],G.prototype,"_calcitePopoverReferenceElement",void 0),e([d()],G.prototype,"_relativeLocation",void 0),e([d()],G.prototype,"_popoverOpen",void 0),G=e([h("esri.widgets.Sketch")],G);const j=G;export{j as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{isSome as o}from"../core/arrayUtils.js";import{handlesGroup as i}from"../core/handleUtils.js";import l from"../core/Logger.js";import{removeMaybe as s,destroyMaybe as n}from"../core/maybe.js";import{ignoreAbortErrors as r}from"../core/promiseUtils.js";import{watch as a,when as p,syncAndInitial as c}from"../core/reactiveUtils.js";import{property as d,subclass as h}from"../core/accessorSupport/decorators.js";import{symbolTypes as u}from"../symbols/support/typeUtils.js";import v from"../views/interactive/sketch/SketchLabelOptions.js";import m from"../views/interactive/sketch/SketchTooltipOptions.js";import g from"../views/interactive/sketch/SketchValueOptions.js";import y from"./Widget.js";import f from"./Sketch/SketchViewModel.js";import{VisibleElements as b}from"./Sketch/VisibleElements.js";import _ from"./Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js";import{loadCalciteComponents as w}from"./support/componentsUtils.js";import T from"./support/SelectionToolbar.js";import M from"./support/SketchTooltipControls.js";import C from"./support/SnappingControls.js";import{tsx as O,messageBundle as S,vmEvent as k}from"./support/widget.js";import P from"./support/SelectionToolbar/VisibleElements.js";import x from"./support/SketchTooltipControls/VisibleElements.js";const E="esri-sketch",I={base:E,vertical:`${E}--vertical`,docked:`${E}-bar`,floating:`${E}-pad`,chipHorizontal:`${E}__selection-count-chip--horizontal`,chipVertical:`${E}__selection-count-chip--vertical`,chipVerticalSmall:`${E}__selection-count-chip--vertical--s`,popoverWrapper:`${E}__popover-wrapper`},R={point:"pin",polyline:"line",polygon:"polygon",rectangle:"rectangle",circle:"circle",multipoint:"pins",mesh:"i3d-building",freehandPolygon:"freehand-area",freehandPolyline:"freehand",text:"add-text"};let G=class extends y{constructor(e,t){super(e,t),this._selectionToolbar=null,this._viewModelHandlesGroup=null,this._popoverElement=null,this.availableCreateTools=["point","polyline","polygon","rectangle","circle"],this.customToolOptions=null,this.customActions=null,this.toolbarKind="floating",this.contextualToolLocation="separate",this.groupCollapsePriorities=null,this.groupAllowCollapseOptions=null,this.messages=null,this.messagesCommon=null,this.visibleElements=new b,this._defaultViewModel=null,this._activeCustomToolOptions=null,this._calcitePopoverReferenceElement=null,this._relativeLocation="top",this._popoverOpen=!1,this._activateCreateTool=this._activateCreateTool.bind(this),this.viewModel=e?.viewModel||(this._defaultViewModel=new f({creationMode:e?.creationMode??"continuous"}))}initialize(){const{layer:e,view:t}=this,o="2d"===t?.type,l=new T({persistSelection:!1,visibleElements:new P({chip:!1,lassoTool:o,operationTypeControls:!1,pan:!1,pointTool:!1,rectangleTool:o}),view:t,sources:e?[e]:null,scale:this.scale});this.addHandles([a(()=>this.viewModel,e=>{this._viewModelHandlesGroup=s(this._viewModelHandlesGroup),e&&(this._viewModelHandlesGroup=i([e.on("create",()=>this.scheduleRender()),e.on("update",()=>this.scheduleRender()),e.on("delete",e=>this.emit("delete",e)),e.on("undo",()=>this.scheduleRender()),e.on("redo",()=>this.scheduleRender()),a(()=>e.layer,e=>{this._selectionToolbar&&(this._selectionToolbar.sources=e?[e]:null)}),a(()=>e.view,e=>{this._selectionToolbar&&(this._selectionToolbar.view=e)}),a(()=>e.state,()=>this.notifyChange("state"))]))},c),p(()=>l.activeOperation,()=>{this.viewModel.cancel(),this._activeCustomToolOptions=null}),l.on("complete",e=>this._onSelectionOperationComplete(e)),a(()=>{const{view:e,visibleElements:{selectionTools:t}}=this;return{lassoTool:"3d"!==e?.type&&!!t?.["lasso-selection"],rectangleTool:"3d"!==e?.type&&!!t?.["rectangle-selection"]}},e=>{Object.assign(l.visibleElements,e)},c)]),this._selectionToolbar=l}loadDependencies(){return w({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._selectionToolbar?.destroy(),this._viewModelHandlesGroup=s(this._viewModelHandlesGroup)}get activeTool(){const e=this._selectionToolbar?.activeOperation;if(e)switch(e.toolName){case"lasso":return"lasso-selection";case"rectangle":return"rectangle-selection";case"default":return"custom-selection"}const t=this._effectiveAvailableCreateTools,{activeTool:o,activeCreateToolDrawMode:i}=this.viewModel;return"polygon"===o&&"freehand"===i&&t?.includes("freehandPolygon")?"freehandPolygon":"polyline"===o&&"freehand"===i&&t?.includes("freehandPolyline")?"freehandPolyline":this.viewModel.activeTool}get activeTooltip(){return this.viewModel.activeTooltip}get createGraphic(){return this.viewModel.createGraphic}get creationMode(){return this.viewModel.creationMode}set creationMode(e){this.viewModel.creationMode=e}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultUpdateOptions(){return this.viewModel.defaultUpdateOptions}set defaultUpdateOptions(e){this.viewModel.defaultUpdateOptions=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}set layout(e){this._set("layout",e),this._selectionToolbar&&(this._selectionToolbar.layout=e)}get pointSymbol(){return this.viewModel.pointSymbol}set pointSymbol(e){this.viewModel.pointSymbol=e}get polygonSymbol(){return this.viewModel.polygonSymbol}set polygonSymbol(e){this.viewModel.polygonSymbol=e}get polylineSymbol(){return this.viewModel.polylineSymbol}set polylineSymbol(e){this.viewModel.polylineSymbol=e}get textSymbol(){return this.viewModel.textSymbol}set textSymbol(e){this.viewModel.textSymbol=e}set scale(e){this._set("scale",e),this._selectionToolbar&&(this._selectionToolbar.scale=e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get state(){return this._selectionToolbar?.activeOperation?"active":this.viewModel.state}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get updateGraphics(){return this.viewModel.updateGraphics}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){const t=this._get("viewModel");e!==t&&(t&&t===this._defaultViewModel&&n(t),this._set("viewModel",e))}get _effectiveAvailableCreateTools(){const{availableCreateTools:e,view:t,visibleElements:o}=this,i=e?.filter(e=>!!o.createTools?.[e]);return"3d"===t?.type?i?.filter(e=>"multipoint"!==e):i}create(e,t,o){const i=o?.createOptions??t;return this._activeCustomToolOptions=o,r(this.viewModel.create(e,i))}update(e,t){return r(this.viewModel.update(e,t))}complete(){this.viewModel.complete()}cancel(){this._selectionToolbar?.cancel(),this.viewModel.cancel(),this._activeCustomToolOptions=null}undo(){this.viewModel.undo(),this.view?.focus()}redo(){this.viewModel.redo(),this.view?.focus()}delete(){this.viewModel.delete()}duplicate(){return this.viewModel.duplicate()}dismissFloatingElements(){this._popoverOpen=!1}render(){const{toolbarKind:e,layout:t,scale:o}=this,i=this.customActions?.filter(e=>"selection-toolbar"===e.position);return O("div",null,O("div",{classes:{[I.base]:!0,[I.floating]:"floating"===e,[I.docked]:"docked"===e,[I.vertical]:"vertical"===t}},O(_,{barStyle:e,layout:t,scale:o},this._renderSelectionSetItemGroupInline(),O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionTools")??!0,"group-kind":"split-button",key:"selection-split-button",priority:this.groupCollapsePriorities?.get("selectionTools")??0},this._renderDefaultSelectionButton(),this._selectionToolbar?.render(),i?.map(e=>this._renderToolbarItem(e))),this._renderCreateToolActionGroup(),this._renderUndoRedoMenuItemGroup(),this._renderSettingsMenuItemGroup()),this._renderSelectionSetToolbar(),this._renderSettingsMenuPopover()))}_renderSettingsMenuPopover(){const{messagesCommon:e,snappingOptions:t,view:o,viewModel:i,visibleElements:l}=this;if(!this._calcitePopoverReferenceElement)return;const s={directionModePicker:l.directionModePicker,labelsToggle:l.labelsToggle,tooltipsToggle:l.tooltipsToggle},n="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return O("calcite-popover",{afterCreate:e=>this._popoverElement=e,closable:!0,heading:e.settings,label:e.settings,open:this._popoverOpen,overlayPositioning:"fixed",placement:n,referenceElement:this._calcitePopoverReferenceElement,scale:this.scale,onCalcitePopoverBeforeClose:e=>this._beforePopoverClose(e.target),onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget),onCalcitePopoverClose:e=>this._refocusOnView(e.target)},O("div",{class:I.popoverWrapper},Object.values(s).includes(!0)?O(M,{sketchOptions:i.sketchOptions,visibleElements:new x(s)}):void 0,l.snappingControls&&o&&t?O(C,{snappingManager:this.viewModel.snappingManager,snappingOptions:t,view:o,visibleElements:l.snappingControlsElements}):void 0))}_beforePopoverClose(e){e===this._popoverElement&&(this._popoverOpen=!1)}_renderSelectionSetToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSelectionSetItemGroup();return e?.length?O(_,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSelectionSetItemGroupInline(){return"separate"===this.contextualToolLocation?[]:this._renderSelectionSetItemGroup()}_renderUndoRedoMenuItemGroup(){return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("undoRedo")??!0,"group-kind":"split-button",key:"undo-redo-menu",priority:this.groupCollapsePriorities?.get("undoRedo")??10,slot:"actions-end"},this._renderUndoButton(),this._renderRedoButton())}_renderSettingsMenuItemGroup(){const e=[],t=[];this.customActions?.forEach(o=>{"settings-before"===o.position?t.push(o):"settings-after"===o.position&&e.push(o)});const i=[...t.map(e=>this._renderToolbarItem(e)),this._renderSettingsMenuButton(),...e.map(e=>this._renderToolbarItem(e))].filter(o);if(i.length)return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("settings")??!1,"group-kind":"overflow-group",key:"settings-menu",priority:this.groupCollapsePriorities?.get("settings")??1e3,slot:"actions-end"},i)}_renderSelectionSetItemGroup(){if(!this.updateGraphics.length)return[];const e="inline-end"===this.contextualToolLocation?"actions-end":void 0,t=this.customActions?.filter(e=>"before-selection-set"===e.position),o=this.customActions?.filter(e=>"after-selection-set"===e.position),i=this.groupCollapsePriorities?.get("selectionSet")??100;return[O("div",{"group-kind":"measured-content",key:"selection-count-chip-group",priority:i,slot:e},this._renderFeatureCountChip()),O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionSet")??!1,"group-kind":"overflow-group",key:"selection-set-tool-group",priority:i,slot:e},t?.map(e=>this._renderToolbarItem(e)),this._renderDuplicateButton(),this._renderDeleteButton(),o?.map(e=>this._renderToolbarItem(e)))]}_renderDefaultSelectionButton(){if(!this.viewModel.updateOnGraphicClick)return[];const{messages:e,state:t}=this;return this._renderToolbarItem({id:"pointer-select",text:e.selectFeature,icon:"cursor",onclick:this._activateDefaultSelectTool,active:"ready"===t})}_renderCreateToolActionGroup(){const e=this._effectiveAvailableCreateTools?.flatMap(e=>this._renderBuiltInCreateToolItem(e))??[],t=this.customToolOptions?.flatMap(e=>this._renderCustomToolItem(e))??[];return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("createTools")??!0,"group-kind":"overflow-group",key:"create-tools-group",priority:this.groupCollapsePriorities?.get("createTools")??100},e,t)}_renderBuiltInCreateToolItem(e){return this._renderToolbarItem({id:`${e}-button`,text:this.messages.draw[e],icon:R[e],onclick:()=>this._activateCreateTool(e),active:this.activeTool===e&&!this._activeCustomToolOptions})}_renderCustomToolItem(e){const{toolKey:t}=e;return this._renderToolbarItem({id:`custom-${e.toolKey}`,text:e.label,icon:e.icon,onclick:()=>this._activateCreateTool(e.toolName,null,e),active:this._activeCustomToolOptions?.toolKey===t})}_renderUndoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"undo-button",text:this.messages.undo,icon:"undo",disabled:!this.viewModel.canUndo(),onclick:this.undo,flipRTL:!0}):[]}_renderRedoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"redo-button",text:this.messages.redo,icon:"redo",disabled:!this.viewModel.canRedo(),onclick:this.redo,flipRTL:!0}):[]}_renderSettingsMenuButton(){return this.visibleElements.settingsMenu?this._renderToolbarItem({id:"settings-menu-action",text:this.messagesCommon.settings,icon:"gear",active:this._popoverOpen,onclick:()=>this._popoverOpen=!this._popoverOpen,afterCreate:e=>this._calcitePopoverReferenceElement=e,afterUpdate:e=>this._calcitePopoverReferenceElement=e,afterRemoved:()=>this._calcitePopoverReferenceElement=null}):[]}_renderFeatureCountChip(){if(!this.visibleElements.selectionCountLabel)return[];const{layout:e,messages:o,scale:i,id:l,updateGraphics:{length:s}}=this,n=t(o.selectedCount,{count:s}),r="s"===i?99:999,a=s>r?t(o.selectedCountTruncated,{truncated:r}):s,p="s"===i&&"vertical"===e,c=p?`${l}-selection-chip-small`:`${l}-selection-chip`;return[p?O("span",{classes:{[I.chipVertical]:!0,[I.chipVerticalSmall]:"s"===this.scale},id:c,tabIndex:0,title:n},a):O("calcite-chip",{appearance:"outline",class:"horizontal"===e?I.chipHorizontal:I.chipVertical,id:c,kind:"brand",label:n,scale:"l"===i?"m":"s",tabIndex:0,title:"vertical"===e?n:void 0},"vertical"===e?a:n)]}_renderDuplicateButton(){if(!this.visibleElements.duplicateButton)return[];const{messages:e}=this;return this._renderToolbarItem({id:"duplicate",text:this.updateGraphics.length>1?e.duplicateFeatures:e.duplicateFeature,icon:"copy",onclick:this._onDuplicateSelect})}_renderDeleteButton(){if(!this.visibleElements.deleteButton)return[];const{messages:e}=this,t=this.updateGraphics.length>1?e.deleteFeatures:e.deleteFeature;return this._renderToolbarItem({id:"delete",text:t,icon:"trash",onclick:this.delete})}_renderToolbarItem({id:e,text:t,icon:o,disabled:i,onclick:l,active:s,flipRTL:n,afterCreate:r,afterUpdate:a,afterRemoved:p}){const c=`${this.id}-${e}`;return[O("calcite-action",{active:s,afterCreate:r,afterRemoved:p,afterUpdate:a,bind:this,"data-testid":e,disabled:i||"disabled"===this.state,icon:o,iconFlipRtl:n??!1,id:c,key:e,onclick:l,scale:this.scale,text:t,title:t})]}_remeasurePopoverSizes(e){try{const t=e.parentElement,o=this?.view?.container?.getBoundingClientRect(),i=t?.style;if(!(t&&o&&i&&this.view?.container?.contains(t)))return;const l=this._calcitePopoverReferenceElement;if(!l)return;const{bottom:s,top:n}=l.getBoundingClientRect();if("horizontal"===this.layout){const e=s<o.height/2;e!==("top"===this._relativeLocation)&&(this._relativeLocation=e?"top":"bottom"),e?(i?.setProperty("--sketch-view-height-offset",s-o.top+"px"),i?.setProperty("--sketch-view-margin-offset","30px")):(i?.setProperty("--sketch-view-height-offset",o.bottom-n+"px"),i?.setProperty("--sketch-view-margin-offset","15px"))}else"vertical"===this.layout&&(i.setProperty("--sketch-view-height-offset","15px"),i.setProperty("--sketch-view-margin-offset","15px"));const r=e.shadowRoot?.querySelector("div.header")?.getBoundingClientRect().height;i.setProperty("--sketch-popover-header-offset",`${r}px`)}catch(t){l.getLogger(this.declaredClass).warnOnce("Sketch failed to lay out settings menu.",t)}}_activateCreateTool(e,t,o){const i=this._activeCustomToolOptions;if(o||i){if(o?.toolKey===i?.toolKey)return void this.cancel()}else if(this.activeTool===e)return void this.cancel();this._selectionToolbar?.cancel(),this.create(e,t,o)}_onDuplicateSelect(){const e=this.duplicate(),t=this.viewModel.activeTool;"transform"!==t&&"reshape"!==t||this.update(e,{tool:t})}_onSelectionOperationComplete(e){const{viewModel:{defaultUpdateOptions:t}}=this,{selection:o}=e;if(!e.aborted&&o.length){const e=t.tool,i=o.length>1&&"reshape"===e?"transform":e;this.update(o,{...t,tool:i})}this.notifyChange("state")}_activateDefaultSelectTool(){this.cancel(),this.view?.focus()}_refocusOnView(e){this.activeTool&&e===this._popoverElement&&this.view?.focus()}};e([d()],G.prototype,"activeTool",null),e([d({readOnly:!0})],G.prototype,"activeTooltip",null),e([d({cast:e=>{if(!e?.length)return null;const t=new Set(["point","polyline","polygon","rectangle","circle","multipoint","freehandPolyline","freehandPolygon","mesh","text"]);return e.filter(e=>t.has(e))}})],G.prototype,"availableCreateTools",void 0),e([d({readOnly:!0})],G.prototype,"createGraphic",null),e([d()],G.prototype,"creationMode",null),e([d()],G.prototype,"customToolOptions",void 0),e([d()],G.prototype,"customActions",void 0),e([d()],G.prototype,"defaultCreateOptions",null),e([d()],G.prototype,"defaultUpdateOptions",null),e([d()],G.prototype,"icon",null),e([d()],G.prototype,"label",null),e([d({type:v})],G.prototype,"labelOptions",null),e([d()],G.prototype,"layer",null),e([d({type:["horizontal","vertical"],value:"horizontal"})],G.prototype,"layout",null),e([d({types:u})],G.prototype,"pointSymbol",null),e([d({types:u})],G.prototype,"polygonSymbol",null),e([d({types:u})],G.prototype,"polylineSymbol",null),e([d()],G.prototype,"textSymbol",null),e([d({value:"m"})],G.prototype,"scale",null),e([d()],G.prototype,"toolbarKind",void 0),e([d()],G.prototype,"contextualToolLocation",void 0),e([d()],G.prototype,"groupCollapsePriorities",void 0),e([d()],G.prototype,"groupAllowCollapseOptions",void 0),e([d(),S("esri/widgets/Sketch/t9n/Sketch")],G.prototype,"messages",void 0),e([d(),S("esri/t9n/common")],G.prototype,"messagesCommon",void 0),e([d()],G.prototype,"snappingOptions",null),e([d()],G.prototype,"state",null),e([d({type:m})],G.prototype,"tooltipOptions",null),e([d({readOnly:!0})],G.prototype,"updateGraphics",null),e([d({type:g,nonNullable:!0})],G.prototype,"valueOptions",null),e([d()],G.prototype,"view",null),e([d({type:f}),k(["create","update","undo","redo"])],G.prototype,"viewModel",null),e([d({type:b,nonNullable:!0})],G.prototype,"visibleElements",void 0),e([d()],G.prototype,"_effectiveAvailableCreateTools",null),e([d()],G.prototype,"_defaultViewModel",void 0),e([d()],G.prototype,"_activeCustomToolOptions",void 0),e([d()],G.prototype,"_calcitePopoverReferenceElement",void 0),e([d()],G.prototype,"_relativeLocation",void 0),e([d()],G.prototype,"_popoverOpen",void 0),G=e([h("esri.widgets.Sketch")],G);const j=G;export{j as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import r from"../../../core/Collection.js";import o from"../../../core/Logger.js";import{removeMaybe as i,abortMaybe as s}from"../../../core/maybe.js";import{ignoreAbortErrors as a,debounce as l,whenOrTimeout as n}from"../../../core/promiseUtils.js";import{watch as c,on as h,whenOnce as g}from"../../../core/reactiveUtils.js";import{property as y,subclass as p}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as d}from"../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as u,isSubtypeSublayer as m}from"../../../layers/support/layerUtils.js";import{isISelectableLayer as
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import r from"../../../core/Collection.js";import o from"../../../core/Logger.js";import{removeMaybe as i,abortMaybe as s}from"../../../core/maybe.js";import{ignoreAbortErrors as a,debounce as l,whenOrTimeout as n}from"../../../core/promiseUtils.js";import{watch as c,on as h,whenOnce as g}from"../../../core/reactiveUtils.js";import{property as y,subclass as p}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as d}from"../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as u,isSubtypeSublayer as m}from"../../../layers/support/layerUtils.js";import{isISelectableLayerViewWithHighlights as f,isISelectableLayer as v,isISelectableLayerBaseWithEditing as _}from"../../../views/support/selectionUtils.js";import{goTo as I}from"../goToUtils.js";import b from"./GroupLayerItem.js";import C from"./LayerItem.js";import{computeEffectiveCount as S,getNestedLayerItems as L,isLayerItem as w,isGroupLayerItem as M,getNestedFeatureItems as H}from"./selectionListUtils.js";const A=100;let E=class extends t{constructor(e){super(e),this._allLayerItems=null,this._groupItemCache=new Map,this._hoverHighlightHandle=null,this._layerEditAbortControllers=new Map,this._layerEditHandles=new r,this._layerItemCache=new Map,this._onChangeAbortController=null,this._updatingHandles=new d,this.filterText=void 0,this.layer=null,this.maxVisibleFeatureCountPerLayer=500,this.selectionManager=null,this._onSelectionChangeController=async()=>{this._cancelOnSelectionChange();const e=new AbortController;this._onChangeAbortController=e,await this._updatingHandles.addPromise(a(this._generateListItems(e))),this._onChangeAbortController===e&&(this._onChangeAbortController=null);const t=this.layer&&this.effectiveSelectionManager?.getSelection(this.layer);t?.length||(this.layer=null)},this._cancelOnSelectionChange=()=>this._onChangeAbortController?.abort(),this._onSelectionChangeDebounced=l(this._onSelectionChangeController,A),this._cancelOnLayerEdit=e=>this._layerEditAbortControllers.get(e)?.abort()}initialize(){this.addHandles([c(()=>[this.view,this.effectiveSelectionManager,...this._sources],()=>{this._onSelectionChange(),this._refreshLayerEditHandles()}),h(()=>this.effectiveSelectionManager?.sources,"change",()=>{this._onSelectionChange(),this._refreshLayerEditHandles()}),h(()=>this.effectiveSelectionManager,"selection-change",()=>this._onSelectionChange())])}destroy(){this._cancelOnSelectionChange(),this.removeTemporaryHighlight(),this._updatingHandles.destroy(),this._layerEditHandles.drain(i),this._layerEditAbortControllers.forEach(s)}get _sources(){return this.effectiveSelectionManager?.sources.toArray()??[]}get activeLayerItem(){const{layer:e}=this;return e&&this.layerItems.find(t=>t.layer===e)}get allLayerItems(){return this._allLayerItems??[]}get effectiveCount(){return S(this.allLayerItems)}get effectiveSelectionManager(){return this.selectionManager??this.view?.selectionManager}get isUpdating(){return!(!this._onChangeAbortController&&!this._updatingHandles.updating)}get layerItems(){return L(this.allLayerItems)}get layerViewMap(){const e=new Map,{view:t}=this;if(!t)return e;for(const r of t.allLayerViews)if(e.set(r.layer.id,r),u(r.layer))for(const t of r.layer.sublayers)e.set(t.id,r);return e}get maxVisibleFeatureCountExceeded(){return this.allLayerItems.some(e=>e.maxVisibleFeatureCountExceeded)}get state(){const{view:e}=this;return e?e.ready?this.effectiveSelectionManager?"ready":"error":"loading":"disabled"}get viewLayersAndTables(){const{view:e}=this;return e?.map?[...e.map.layers.toArray().reverse(),...e.map.tables.toArray().reverse()]:[]}get visibleFeatureCount(){return this.activeLayerItem?.visibleTotal??this.visibleFeatureItems.length}get visibleFeatureItems(){return this.layerItems.flatMap(e=>e.featureItems.filter(e=>e.visible))}get visibleLayerCount(){const{effectiveSelectionManager:e}=this;return e&&0!==e.count?1===e.count||this.activeLayerItem?1:this.layerItems.filter(e=>e.visible).length:0}addTemporaryHighlight({graphic:e,layerView:t}){this.removeTemporaryHighlight(),t&&e&&f(t)&&(this._hoverHighlightHandle=t.highlight(e,{name:"temporary"}))}clear(){this.effectiveSelectionManager?.clear()}deselectFeatureItem(e){const t=e.graphic.getObjectId();null!=t&&this.effectiveSelectionManager?.removeFromSelection(e.layer,[t])}deselectGroupItem(e){e.items.forEach(e=>{w(e)?this.deselectLayerItem(e):this.deselectGroupItem(e)})}deselectLayerItem(e){this.effectiveSelectionManager?.setSelection(e.layer,[])}deselectItem(e){M(e)?this.deselectGroupItem(e):w(e)?this.deselectLayerItem(e):this.deselectFeatureItem(e)}goToItem(e){w(e)||M(e)?this._goTo(H([e]).map(e=>e.graphic)):this._goTo(e.graphic)}layersToItems(e){const{controller:t,groupLayerItem:r,layers:o,promises:i}=e,{_groupItemCache:s,_layerItemCache:a,effectiveSelectionManager:l,viewLayersAndTables:n}=this,c=o??n;if(!l||0===l.count)return[];const h=[];for(const g of c)switch(g.type){case"subtype-group":case"knowledge-graph":case"group":{const e=s.get(g),r=e??new b({layer:g,viewModel:this});e||s.set(g,r),i.push(r.sync({controller:t,promises:i})),h.push(r)}break;default:if(v(g)){const e=l.getSelection(g);if(!e?.length)continue;const o=a.get(g),s=o??new C({groupLayerItem:r,layer:g,viewModel:this});o||a.set(g,s),i.push(s.sync({controller:t,promises:i})),h.push(s)}}return h}removeFromSelection(e){this.effectiveSelectionManager?.removeFromSelection(e.layer,e.objectIds)}removeTemporaryHighlight(){this._hoverHighlightHandle=i(this._hoverHighlightHandle)}selectSingleFeatureItem(e){const t=e.objectId;if(null!=t&&this.effectiveSelectionManager)for(const{layer:r}of this.effectiveSelectionManager.selections)this.setSelection({layer:r,objectIds:r===e.layer?[t]:[]})}selectSingleGroupItem(e){if(this.effectiveSelectionManager)for(const{layer:t,selection:r}of this.effectiveSelectionManager.selections)this.setSelection({layer:t,objectIds:t.parent===e.layer?r:[]})}selectSingleItem(e){M(e)?this.selectSingleGroupItem(e):w(e)?this.selectSingleLayerItem(e):this.selectSingleFeatureItem(e)}selectSingleLayerItem(e){if(this.effectiveSelectionManager)for(const{layer:t,selection:r}of this.effectiveSelectionManager.selections)this.setSelection({layer:t,objectIds:t===e.layer?r:[]})}setSelection(e){this.effectiveSelectionManager?.setSelection(e.layer,e.objectIds)}async _goTo(e){const{view:t}=this;if(t)try{await I(t,e)}catch(r){"AbortError"!==r.name&&o.getLogger(this).warn("Failed to go to feature(s)",r)}}async _generateListItems(e){try{this.removeTemporaryHighlight();const t=[],r=this.layersToItems({controller:e,promises:t});t.length>0&&await Promise.all(t),this._onChangeAbortController===e&&(this._allLayerItems=r)}catch(t){o.getLogger(this).warn("Failed updating selection",t)}}_onSelectionChange(){a(this._onSelectionChangeDebounced())}_refreshLayerEditHandles(){const{effectiveSelectionManager:e}=this;if(this._layerEditHandles.drain(i),!e?.sources.length)return;const t=new Set(e.sources.map(e=>m(e)?e.parent:e));for(const r of t)v(r)&&_(r)&&this._layerEditHandles.push(r.on("edits",e=>{this._onLayerEdit(e,r)}))}async _onLayerEdit(e,t){try{if(this.removeTemporaryHighlight(),this._cancelOnLayerEdit(t),!e.updatedFeatures.some(e=>null!=e.objectId&&!e.error))return;const r=new AbortController;this._layerEditAbortControllers.set(t,r);const o="subtype-group"===t.type||"knowledge-graph"===t.type?this.allLayerItems.find(e=>e.layer===t):this.layerItems.find(e=>e.layer===t);if(o?.layerView){const e=o.layerView;if(await this._onLayerViewUpdate(e),r.signal.aborted)return;o.reset(),this._onSelectionChange()}this._layerEditAbortControllers.get(t)===r&&this._layerEditAbortControllers.delete(t)}catch(r){o.getLogger(this).warn("Failed updating selected features",r)}}async _onLayerViewUpdate(e){await n(g(()=>e.updating),2e3),await g(()=>!e.updating)}};e([y()],E.prototype,"_allLayerItems",void 0),e([y()],E.prototype,"_groupItemCache",void 0),e([y()],E.prototype,"_hoverHighlightHandle",void 0),e([y()],E.prototype,"_layerEditAbortControllers",void 0),e([y()],E.prototype,"_layerEditHandles",void 0),e([y()],E.prototype,"_layerItemCache",void 0),e([y()],E.prototype,"_onChangeAbortController",void 0),e([y()],E.prototype,"_sources",null),e([y()],E.prototype,"_updatingHandles",void 0),e([y()],E.prototype,"activeLayerItem",null),e([y()],E.prototype,"allLayerItems",null),e([y()],E.prototype,"effectiveCount",null),e([y()],E.prototype,"effectiveSelectionManager",null),e([y()],E.prototype,"filterText",void 0),e([y()],E.prototype,"isUpdating",null),e([y()],E.prototype,"layer",void 0),e([y()],E.prototype,"layerItems",null),e([y()],E.prototype,"layerViewMap",null),e([y()],E.prototype,"maxVisibleFeatureCountExceeded",null),e([y()],E.prototype,"maxVisibleFeatureCountPerLayer",void 0),e([y()],E.prototype,"selectionManager",void 0),e([y()],E.prototype,"state",null),e([y()],E.prototype,"view",void 0),e([y()],E.prototype,"viewLayersAndTables",null),e([y()],E.prototype,"visibleFeatureCount",null),e([y()],E.prototype,"visibleFeatureItems",null),e([y()],E.prototype,"visibleLayerCount",null),E=e([p("esri.widgets.support.SelectionList.SelectionListViewModel")],E);const j=E;export{j as default};
|