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