/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import f from"./MUPEYUVW.js";import{a as u}from"./EUYSSHX7.js";import{a as w}from"./DHVEHATY.js";import c from"./XGFQI67H.js";import b from"./L4T73YYG.js";import{g as m}from"./2GLF4DQN.js";import"./5AI6MQMZ.js";import a from"./KTDXN3YM.js";import{b as p}from"./ZNBKMZP7.js";import{O as h,P as d,R as g,U as v,a as l,b as e,x as n}from"./IWZQMWZ5.js";import"./ALDX5YZO.js";export default $arcgis.t(([y,,,{a:o},f])=>{var T=l`.arcgis-button{--calcite-icon-color: var(--calcite-color-text-3);--calcite-button-background-color: var(--calcite-color-foreground-1);color:var(--calcite-color-text-3);line-height:var(--calcite-font-line-height-relative-tight);display:flex;flex-flow:column;cursor:pointer;background-color:var(--calcite-color-foreground-1);font-size:var(--calcite-font-size);:hover{--calcite-icon-color: var(--calcite-color-text-1);--calcite-button-background-color: var(--calcite-color-transparent-hover)}}:host{width:fit-content;height:fit-content}`,$=f(y),r=class extends h{constructor(){super(...arguments),this.messages=u(),this.viewModel=$(this),this.view=this.viewModel.view,this.autoDestroyDisabled=!1,this.error=this.viewModel.error,this.geolocationOptions=this.viewModel.geolocationOptions,this.goToOverride=this.viewModel.goToOverride,this.goToLocationDisabled=this.viewModel.goToLocationEnabled,this.graphic=this.viewModel.graphic,this.icon="compass-north-circle",this.positionFilterFunction=this.viewModel.positionFilterFunction,this.rotationDisabled=this.viewModel.rotationEnabled,this.scale=this.viewModel.scale,this.state=this.viewModel.state,this.tracking=this.viewModel.tracking,this.visualScale="m",this.arcgisComplete=o(()=>this.viewModel,"track"),this.arcgisError=o(()=>this.viewModel,"track-error"),this.arcgisPropertyChange=m()("state"),this.arcgisReady=n()}static{this.properties={view:0,autoDestroyDisabled:5,error:0,geolocationOptions:0,goToOverride:0,goToLocationDisabled:7,graphic:0,icon:1,label:1,messageOverrides:0,positionFilterFunction:0,referenceElement:1,rotationDisabled:5,scale:9,state:0,tracking:36,visualScale:1}}static{this.styles=T}async destroy(){await this.manager.destroy()}async start(){this.viewModel.start()}async stop(){this.viewModel.stop()}_localizeError(t){if(t instanceof GeolocationPositionError)return t.code===GeolocationPositionError.PERMISSION_DENIED?this.messages?.permissionError:t.code===GeolocationPositionError.TIMEOUT?this.messages?.timeoutError:this.messages?.positionUnavailable;if(t instanceof Error)return t.message}_toggleTracking(){if(!this.viewModel)return;let{state:t}=this.viewModel;if(!(t==="feature-unsupported"||t==="disabled")){if(t==="tracking"||t==="waiting"){this.viewModel.stop();return}this.viewModel.start()}}render(){let{viewModel:t,messages:s,icon:M}=this,i=t?.state,b=i==="tracking",a=this._localizeError(this.viewModel?.error),c=(b?s?.stopTracking:s?.startTracking)??"",E=i==="feature-unsupported",k=(i==="tracking"?"pause":void 0)??M??void 0;return e`<div class=${d(p("root",w.arcgisButton))}>${!E&&e`<calcite-button .disabled=${i==="disabled"} .iconStart=${k} kind=neutral .label=${c} .loading=${i==="waiting"} @click=${this._toggleTracking} .scale=${this.visualScale} title=${c??g}></calcite-button>`||""}${a?e`<calcite-tooltip open overlay-positioning=fixed .referenceElement=${this.el}>${a}</calcite-tooltip>`:null}</div>`}};v("arcgis-track",r);return r},"widgets/Track/TrackViewModel",a,b,c,f)