/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../intl","../../intl/number"],(function(t,n,e){"use strict";const r=/^-?(\d+)(\.(\d+))?$/i;function o(t,n){return t-n}function i(t,n){let e,r;return e=Number(t.toFixed(n)),e<t?r=e+1/10**n:(r=e,e-=1/10**n),e=Number(e.toFixed(n)),r=Number(r.toFixed(n)),[e,r]}function u(t,n,e,r,o){const i=s(t,n,e,r),u=null==i.previous||i.previous<=o,l=null==i.next||i.next<=o;return u&&l||i.previous+i.next<=2*o}function l(t){const n=String(t),e=n.match(r);if(e&&e[1])return{integer:e[1].split("").length,fractional:e[3]?e[3].split("").length:0};if(n.toLowerCase().includes("e")){const t=n.split("e"),e=t[0],r=t[1];if(e&&r){const t=Number(e);let n=Number(r);const o=n>0;o||(n=Math.abs(n));const i=l(t);return o?(i.integer+=n,n>i.fractional?i.fractional=0:i.fractional-=n):(i.fractional+=n,n>i.integer?i.integer=1:i.integer-=n),i}}return{integer:0,fractional:0}}function s(t,n,e,r){const o={previous:null,next:null};if(null!=e){const r=t-e,i=n-e-r;o.previous=Math.floor(Math.abs(100*i/r))}if(null!=r){const e=r-t,i=r-n-e;o.next=Math.floor(Math.abs(100*i/e))}return o}function c(t,n={}){const e=t.slice(0),{tolerance:r=2,strictBounds:s=!1,indexes:c=e.map(((t,n)=>n))}=n;c.sort(o);for(let o=0;o<c.length;o++){const t=c[o],n=e[t],a=0===t?null:e[t-1],f=t===e.length-1?null:e[t+1],g=l(n).fractional;if(g){let l,c=0,m=!1;for(;c<=g&&!m;){const t=i(n,c);l=s&&0===o?t[1]:t[0],m=u(n,l,a,f,r),c++}m&&(e[t]=l)}}return e}const a={maximumFractionDigits:20};function f(t){return e.formatNumber(t,a)}t.format=f,t.numDigits=l,t.percentChange=s,t.round=c,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
