/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../Graphic.js";import{deprecateWidget as o}from"../core/deprecate.js";import i from"../core/Logger.js";import{property as r,subclass as s}from"../core/accessorSupport/decorators.js";import a from"./Widget.js";import{loadCalciteComponents as n}from"./support/componentsUtils.js";import{globalCss as l}from"./support/globalCss.js";import{messageBundle as c,vmEvent as p,tsx as d}from"./support/widget.js";import g from"./Track/TrackViewModel.js";const u={base:"esri-track"};let h=class extends a{constructor(e,t){super(e,t),this.messages=null,this.viewModel=new g({suppressDeprecationWarning:!0}),this._toggleTracking=()=>{const e=this.viewModel;e&&"feature-unsupported"!==e.state&&"disabled"!==e.state&&("tracking"!==e.state&&"waiting"!==e.state?this.viewModel.start():this.viewModel.stop())},o(i.getLogger(this),"Track","arcgis-track",{version:"4.32"})}loadDependencies(){return n({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}get geolocationOptions(){return this.viewModel.geolocationOptions}set geolocationOptions(e){this.viewModel.geolocationOptions=e}get goToLocationEnabled(){return this.viewModel.goToLocationEnabled}set goToLocationEnabled(e){this.viewModel.goToLocationEnabled=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get icon(){return"compass-north-circle"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get rotationEnabled(){return this.viewModel.rotationEnabled}set rotationEnabled(e){this.viewModel.rotationEnabled=e}get scale(){return this.viewModel.scale}set scale(e){this.viewModel.scale=e}get tracking(){return this.viewModel.tracking}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}start(){this.viewModel.start()}stop(){this.viewModel.stop()}render(){const{viewModel:e,messages:t,icon:o}=this,i=e?.state,r="tracking"===i,s=this._localizeError(this.viewModel?.error),a=(r?t?.stopTracking:t?.startTracking)??"",n="feature-unsupported"===i,c=("tracking"===i?"pause":void 0)??o;return d("div",{class:this.classes(u.base,l.widget)},!n&&d("calcite-button",{class:l.widgetButton,disabled:"disabled"===i,iconStart:c,kind:"neutral",label:a,loading:"waiting"===i,title:a,onclick:this._toggleTracking}),s?d("calcite-tooltip",{open:!0,overlayPositioning:"fixed",referenceElement:this.container,topLayerDisabled:this.topLayerDisabled},s):null)}_localizeError(e){return e instanceof GeolocationPositionError?e.code===GeolocationPositionError.PERMISSION_DENIED?this.messages?.permissionError:e.code===GeolocationPositionError.TIMEOUT?this.messages?.timeoutError:this.messages?.positionUnavailable:e instanceof Error?e.message:void 0}};e([r()],h.prototype,"geolocationOptions",null),e([r()],h.prototype,"goToLocationEnabled",null),e([r()],h.prototype,"goToOverride",null),e([r({type:t})],h.prototype,"graphic",null),e([r()],h.prototype,"icon",null),e([r()],h.prototype,"label",null),e([r(),c("esri/widgets/Track/t9n/Track")],h.prototype,"messages",void 0),e([r()],h.prototype,"rotationEnabled",null),e([r()],h.prototype,"scale",null),e([r({readOnly:!0})],h.prototype,"tracking",null),e([r()],h.prototype,"view",null),e([r({type:g}),p(["track","track-error"])],h.prototype,"viewModel",void 0),h=e([s("esri.widgets.Track")],h);const v=h;export{v as default};
