/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{getLocaleLanguage as n,normalizeLocale as t,beforeLocaleChange as e,getLocale as u}from"./locale.js";const i={ar:"ar-u-nu-latn",bs:"sr-Latn-CS",nn:"no-NN"};let r=new WeakMap,a={};function o(e){const u=e||a;if(!r.has(u)){const a=n(),o=a&&i[a]||t();r.set(u,new Intl.NumberFormat(o,e))}return r.get(u)}function l(n={}){const t={};return null!=n.digitSeparator&&(t.useGrouping=n.digitSeparator),null!=n.places&&(t.minimumFractionDigits=t.maximumFractionDigits=n.places),t}function s(n){const{minimumFractionDigits:t,maximumFractionDigits:e,useGrouping:u}=n;return{minimumFractionDigits:t,maximumFractionDigits:e,useGrouping:"auto"===u?"auto":"always"===u}}function c(n,t){return Object.is(n,-0)&&(n=0),o(t).format(n)}function m(n,t=u()){if(!n)return null;let e=p.get(t);if(!e){const n=o().formatToParts(12345.6),u=[...o({useGrouping:!1}).format(9876543210)].reverse(),i=new Map(u.map((n,t)=>[n,t])),r=new RegExp(`[${n.find(n=>"group"===n.type)?.value}]`,"g"),a=new RegExp(`[${n.find(n=>"decimal"===n.type)?.value}]`),l=new RegExp(`[${u.join("")}]`,"g"),s=/[\u200E\u200F\u202A\u202B\u202C\u202D\u202E\u2066\u2067\u2068\u2069\u061C]/g,c=/[-\u2212\u2013\u2014\u2015]/g;e=n=>{if(""===(n=n.trim().replaceAll(r,"").replace(a,".").replace(l,n=>String(i.get(n))).replaceAll(s,"").replaceAll(c,"-")))return null;const t=Number(n);return isNaN(t)?null:t},p.set(t,e)}return e(n)}e(()=>{r=new WeakMap,a={}});const p=new Map;export{s as convertNumberFieldFormatToIntlOptions,l as convertNumberFormatToIntlOptions,c as formatNumber,o as getFormatter,m as parseNumber};
