/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.24/esri/copyright.txt for details. */ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../core/Accessor.js";import{isNone as r}from"../../core/maybe.js";import{createScreenPoint as s}from"../../core/screenUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{isSupported as n,geodesicLengths as a}from"../../geometry/support/geodesicUtils.js";import{straightLineDensify as c}from"../../geometry/support/normalizeUtils.js";import{getInfo as m}from"../../geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as l}from"../../geometry/support/webMercatorUtils.js";import p from"../../geometry/support/WKIDUnitConversion.js";import u from"../../geometry/SpatialReference.js";import d from"../../geometry/Polyline.js";import f from"../../geometry/Point.js";function g(e){const{wkid:t}=e;if(null!=p[t])return p.values[p[t]];const{wkt:r}=e,s=r.lastIndexOf(",")+1,o=r.lastIndexOf("]]");return parseFloat(r.substring(s,o))}function h(e,t){return e&&e.includes(t)}function w(e,t){const{x:r,y:s}="decimal-degrees"===e?l(t,!0):t;return[r,s]}function y({state:{paddedViewState:e},spatialReference:t,width:r}){return t.isWrappable&&e.worldScreenWidtho?a=o:a<0&&(a=0);const c=s(0,a),l=s(r,a);return[e.toMap(c),e.toMap(l)]}_getScaleBarProps(e,t,r){const{view:s}=this;let o=e*t/(y(s)?s.state.paddedViewState.worldScreenWidth:s.width),i="metric"===r?"km":"mi";if(o<.1)if("mi"===i){o*=5280,i="ft"}else if("km"===i){o*=1e3,i="m"}let n=0;for(;o>=1;)o/=10,n++;const a=this._getConstraints(o);if(!a)return null;const{min:c,max:m}=a,l=m/o>=o/c?c:m;return{length:e*(l/o),value:10**n*l,unit:i}}_getConstraints(e){return e>.5?{min:.5,max:1}:e>.3?{min:.3,max:.5}:e>.2?{min:.2,max:.3}:e>.15?{min:.15,max:.2}:e>=.1?{min:.15,max:.1}:void 0}};e([o()],S.prototype,"scaleComputedFrom",void 0),e([o({readOnly:!0})],S.prototype,"state",null),e([o()],S.prototype,"view",void 0),S=e([i("esri.widgets.Scalebar.ScaleBarViewModel")],S);const j=S;export{j as default};