/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import{property as t,subclass as c}from"../../../core/accessorSupport/decorators.js";import{substitute as o}from"../../../intl/substitute.js";import n from"../../Widget.js";import{css as a}from"../css.js";import{copyToClipboard as l}from"../imageMeasurementUtils.js";import{loadCalciteComponents as i}from"../../support/componentsUtils.js";import{tsx as r}from"../../support/widget.js";import{messageBundle as s}from"../../support/decorators/messageBundle.js";let d=class extends n{constructor(e){super(e),this.messages=null,this.messagesCommon=null,this.accuracy=null,this._selectedSystem="Basemap",this._handleSystemSelection=e=>{this._selectedSystem=e.target.value}}loadDependencies(){return i({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),select:()=>import("@esri/calcite-components/dist/components/calcite-select"),option:()=>import("@esri/calcite-components/dist/components/calcite-option"),table:()=>import("@esri/calcite-components/dist/components/calcite-table"),"table-row":()=>import("@esri/calcite-components/dist/components/calcite-table-row"),"table-header":()=>import("@esri/calcite-components/dist/components/calcite-table-header"),"table-cell":()=>import("@esri/calcite-components/dist/components/calcite-table-cell")})}get _renderLocationBlock(){const{groundCoordinates:e,_selectedSystem:t}=this;return e&&"XY"===t?r("calcite-block",{heading:this.getLocation(),headingLevel:6}):null}get _renderLocationTable(){const{groundCoordinates:e,messages:t,_selectedSystem:c,accuracy:o}=this,n={groundX:e.x.toFixed(3),accuracyX:null!=o?.x?o.x.toFixed(3):"",groundY:e.y.toFixed(3),accuracyY:null!=o?.y?o.y.toFixed(3):"",groundZ:e.z?e.z.toFixed(3):"",accuracyZ:null!=o?.z?o.z.toFixed(3):""};return e&&"Basemap"===c?r("calcite-table",{bordered:!0,caption:t.measurementTable,class:a.measurementsTable,scale:"s"},r("calcite-table-row",{slot:"table-header"},r("calcite-table-header",{alignment:"center",heading:t.type}),r("calcite-table-header",{alignment:"center",heading:t.value}),r("calcite-table-header",{alignment:"center",heading:t.accuracy})),r("calcite-table-row",null,r("calcite-table-cell",{alignment:"center"},t.x),r("calcite-table-cell",{alignment:"center"},n.groundX),r("calcite-table-cell",{alignment:"center"},n.accuracyX)),r("calcite-table-row",null,r("calcite-table-cell",{alignment:"center"},t.y),r("calcite-table-cell",{alignment:"center"},n.groundY),r("calcite-table-cell",{alignment:"center"},n.accuracyY)),r("calcite-table-row",null,r("calcite-table-cell",{alignment:"center"},t.z),r("calcite-table-cell",{alignment:"center"},n.groundZ),r("calcite-table-cell",{alignment:"center"},n.accuracyZ))):null}get _renderSystemSelect(){const{messages:e,messagesCommon:t,groundCoordinates:c}=this,o="feet"===c.spatialReference.unit?e.xyzFeet:e.xyz;return r("div",{class:a.measurementsBar},r("calcite-select",{bind:this,label:e.selectUnitSystem,scale:"m",width:"full",onCalciteSelectChange:this._handleSystemSelection},r("calcite-option",{value:"Basemap"},o),r("calcite-option",{value:"XY"},e.decimalDegrees)),r("calcite-action",{icon:"copy-to-clipboard",onclick:()=>this.copyLocation(),scale:"s",slot:"control",text:"Copy",title:t.copy}))}copyLocation(){const{groundCoordinates:e}=this;if(!e)return;const t=this.getLocation();t&&l(t)}getLocation(){const{_selectedSystem:e,groundCoordinates:t,accuracy:c}=this;return"Basemap"===e?this.getBasemapLocation(t,c):this.getXYLocation(t)}getXYLocation(e){if(null==e?.longitude||null==e?.latitude)return"";const t={groundX:e.longitude.toFixed(6),groundY:e.latitude.toFixed(6)};return o("{groundX}° , {groundY}°",t)}getBasemapLocation(e,t){if(null==e?.x||null==e?.y)return"";const c={groundX:e.x.toFixed(3),accuracyX:t?.x?t.x.toFixed(3):0,groundY:e.y.toFixed(3),accuracyY:t?.y?t.y.toFixed(3):0,groundZ:e.z?e.z.toFixed(3):0,accuracyZ:t?.z?t.z.toFixed(3):0};return o("{groundX} ± {accuracyX},  {groundY} ± {accuracyY}, {groundZ} ± {accuracyZ}",c)}render(){return r("calcite-panel",{class:a.measurementResults,key:"ground-location-container"},this._renderSystemSelect,this._renderLocationBlock,this._renderLocationTable)}};e([t()],d.prototype,"messages",void 0),e([t(),s("esri/t9n/common")],d.prototype,"messagesCommon",void 0),e([t()],d.prototype,"groundCoordinates",void 0),e([t()],d.prototype,"accuracy",void 0),e([t()],d.prototype,"_selectedSystem",void 0),e([t()],d.prototype,"_renderLocationBlock",null),e([t()],d.prototype,"_renderLocationTable",null),e([t()],d.prototype,"_renderSystemSelect",null),d=e([c("esri.widgets.OrientedImageryViewer.components.ImageLocationWidget")],d);const m=d;export{m as default};
