/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../../../chunks/tslib.es6","../../../core/maybe","../../../core/throttle","../../../core/unitFormatUtils","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","../../Widget","../css","../support/constants","../../support/widgetUtils","../../support/decorators/messageBundle","../../support/jsxFactory"],(function(t,e,s,i,r,a,o,n,c,l,d,S,p,u,_,h,v){"use strict";const g=100;t.Statistics=function(t){function s(e,s){var i;return(i=t.call(this,e,s)||this)._messagesUnits=null,i._updateLayout=t=>{const e=t.parentElement,s=t.style.display;e.removeChild(t),document.body.appendChild(t),t.style.display="block";let i=80;for(const r of t.childNodes)r instanceof HTMLElement&&(i=Math.max(i,r.offsetWidth));document.body.removeChild(t),e.appendChild(t),t.style.display=s,t.style.setProperty("--max-width",`${i}px`)},i._updateLayoutThrottled=r.throttle(i._updateLayout,g),i}e._inheritsLoose(s,t);var o=s.prototype;return o.initialize=function(){this.own(this._updateLayoutThrottled)},o.render=function(){return v.tsx("div",{bind:this,class:p.STATISTICS_CSS.base,afterCreate:this._updateLayout,afterUpdate:this._updateLayoutThrottled},this._renderStatistics())},o._renderStatistics=function(){var t;const e=null==(t=this._messages)?void 0:t.statistics;return e?[this._renderDistanceStatistic("maxDistance",e.maxDistance),this._renderElevationStatistic("elevationGain",e.gain),this._renderElevationStatistic("elevationLoss",e.loss),this._renderElevationStatistic("minElevation",e.minElevation),this._renderElevationStatistic("maxElevation",e.maxElevation),this._renderElevationStatistic("avgElevation",e.avgElevation),this._renderSlopeStatistic("maxPositiveSlope","maxNegativeSlope",e.maxSlope),this._renderSlopeStatistic("avgPositiveSlope","avgNegativeSlope",e.avgSlope)]:[]},o._renderDistanceStatistic=function(t,e){const s=this._renderValue(t,(t=>{const e=this.effectiveUnits.distance;return a.formatDecimal(this._messagesUnits,t,e,u.FORMAT_PRECISION)}));return this._renderStatistic(e,s)},o._renderElevationStatistic=function(t,e){const s=this._renderValue(t,(t=>{const e=this.effectiveUnits.elevation;return a.formatDecimal(this._messagesUnits,t,e,u.FORMAT_PRECISION)}));return this._renderStatistic(e,s)},o._renderSlopeStatistic=function(t,e,s){const i=v.tsx("div",{key:"slope-up",class:p.STATISTICS_CSS.slopeValue},v.tsx("div",{class:p.STATISTICS_CSS.slopeUpIcon}),this._renderValue(t,(t=>a.formatAngleDegrees(t,"degrees","geographic","geographic",u.FORMAT_PRECISION))),v.tsx("div",{class:p.STATISTICS_CSS.slopeDownIcon}),this._renderValue(e,(t=>a.formatAngleDegrees(t,"degrees","geographic","geographic",u.FORMAT_PRECISION))));return this._renderStatistic(s,i)},o._renderStatistic=function(t,e){return v.tsx("div",{class:p.STATISTICS_CSS.statistic},v.tsx("label",{class:p.STATISTICS_CSS.statisticLabel},t),v.tsx("div",{class:p.STATISTICS_CSS.statisticValue},e))},o._renderValue=function(t,e){const s=this.line,r=1===s.progress?s.statistics:null,a=i.applySome(r,(e=>e[t]));return i.isSome(a)?e(a):u.NOT_AVAILABLE},s}(S),s.__decorate([o.property()],t.Statistics.prototype,"effectiveUnits",void 0),s.__decorate([o.property()],t.Statistics.prototype,"line",void 0),s.__decorate([o.property(),h.messageBundle("esri/widgets/ElevationProfile/t9n/ElevationProfile")],t.Statistics.prototype,"_messages",void 0),s.__decorate([o.property(),h.messageBundle("esri/core/t9n/Units")],t.Statistics.prototype,"_messagesUnits",void 0),t.Statistics=s.__decorate([d.subclass("esri.widgets.ElevationProfile.Statistics")],t.Statistics),Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
