/*! All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
v4.33.18 */
import{b as R}from"./IC36TD4R.js";import e from"./E5V5AKTV.js";import{a as L}from"./VK24LKXI.js";import{a as v}from"./LL7T22QC.js";import b from"./Y4DAIYBP.js";import a from"./DTE4O2DP.js";import"./LYMDZ73M.js";import"./MG6XDMQJ.js";import"./HITJFSBP.js";import{B as C,E as y,P as g,Q as r,R as _,U as w,a as d,k as c}from"./3VKC6PRK.js";export default $geoscene.t(([{getDefaultUnitForView:U},{watch:D},{formatNumber:S},x,,,B])=>{function M($=0,e=0){return{x:$,y:e}}var a="geoscene-scale-bar",t={base:a,labelContainer:`${a}__label-container`,rulerLabelContainer:`${a}__label-container--ruler`,lineLabelContainer:`${a}__label-container--line`,topLabelContainer:`${a}__label-container--top`,bottomLabelContainer:`${a}__label-container--bottom`,label:`${a}__label`,line:`${a}__line`,topLine:`${a}__line--top`,bottomLine:`${a}__line--bottom`,ruler:`${a}__ruler`,rulerBlock:`${a}__ruler-block`,barContainer:`${a}__bar-container`,rulerBarContainer:`${a}__bar-container--ruler`,lineBarContainer:`${a}__bar-container--line`},O=B(x),f=class extends g{constructor(){super(...arguments),this._defaultUnit="metric",this.messages=L(),this._scaleComputedFrom=M(),this.viewModel=O(this),this.autoDestroyDisabled=!1,this.barStyle="line",this.icon="actual-size",this.position="top-left",this.geosceneReady=C()}static{this.properties={autoDestroyDisabled:5,barStyle:1,icon:1,label:1,messageOverrides:0,position:3,referenceElement:1,unit:1}}static{this.shadowRootOptions=y}get unit(){return this._unit??this._defaultUnit}set unit(e){this._unit=e}async destroy(){await this.manager.destroy()}updated(){this._handleRootCreateOrUpdate()}loaded(){this.manager.onLifecycle(()=>D(()=>{let e=this.viewModel.view;return{defaultUnit:e?U(e):void 0,stationary:e?.stationary,center:e?.center,scale:e?.scale,zoom:e?.zoom}},({defaultUnit:e,stationary:i})=>{this._defaultUnit=e??"metric",i&&this.requestUpdate()}))}_handleContainerRef(e){e!==void 0&&this._handleRootCreateOrUpdate()}_handleRootCreateOrUpdate(){if(!this.viewModel)return;let e=this._scaleComputedFrom,i=this.el.getBoundingClientRect(),s=i.left+window.pageXOffset,l=i.top+window.pageYOffset,o=M(s,l);(o.x!==e.x||o.y!==e.y)&&(this._scaleComputedFrom=o)}_formatDistance(e,i){return S(e,{style:"unit",unit:i,unitDisplay:"short"})}render(){let e=this.viewModel.state==="disabled",i={[v.disabled]:e},s,l;if(!e){let{unit:o,barStyle:u}=this,b=o==="imperial"||o==="dual",p=o==="metric"||o==="dual",m=100,h=o==="dual"?"line":u;if(b){let n=this.viewModel.getScaleBarProperties(m,"imperial");n&&(l=h==="ruler"?this._renderRuler(n):this._renderLine(n,"bottom"))}if(p){let n=this.viewModel.getScaleBarProperties(m,"metric");n&&(s=h==="ruler"?this._renderRuler(n):this._renderLine(n,"top"))}}return c`<div class=${r(d(t.base,v.widget,i))} ${R(this._handleContainerRef)}>${s}${l}</div>`}_renderRuler(e){let{length:i,unit:s,value:l}=e,o=Math.round(i),u=this._formatDistance(l,s);return c`<div class=${r(d(t.barContainer,t.rulerBarContainer))}><div class=${r(t.ruler)} style=${_({width:`${o}px`})}><div class=${r(t.rulerBlock)}></div><div class=${r(t.rulerBlock)}></div><div class=${r(t.rulerBlock)}></div><div class=${r(t.rulerBlock)}></div></div><div class=${r(d(t.labelContainer,t.rulerLabelContainer))}><div class=${r(t.label)}>0</div><div class=${r(t.label)}>${u}</div></div></div>`}_renderLine(e,i){let{length:s,unit:l,value:o}=e,u=Math.round(s),b=this._formatDistance(o,l),p={[t.topLabelContainer]:i==="top",[t.bottomLabelContainer]:i==="bottom"},m=c`<div class=${r(d(t.labelContainer,t.lineLabelContainer,p))}><div class=${r(t.label)}>${b}</div></div>`,h={[t.topLine]:i==="top",[t.bottomLine]:i==="bottom"},n=c`<div class=${r(d(t.line,h))} style=${_({width:`${u}px`})}></div>`;return c`<div class=${r(d(t.barContainer,t.lineBarContainer))}>${[n,m]}</div>`}};w("geoscene-scale-bar",f);return f},"applications/Components/getDefaultUnits","core/reactiveUtils","intl","widgets/ScaleBar/ScaleBarViewModel",a,b,e)