Build 589089stable
Module 641277
2,446 characters · in 514.d733764d42c2ab66.jsDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{B:()=>o});var r=n(26232);function i(e){return Intl.getCanonicalLocales(e)[0]}var a=n(183580);function o(e,t,n,o,s,l){let u,c;if("lookup"===n.localeMatcher)u=function(e,t,n){let i={locale:""};for(let n of t){let t=n.replace(r.KB,""),o=(0,a.q)(e,t);if(o)return i.locale=o,n!==t&&(i.extension=n.slice(t.length,n.length)),i}return i.locale=n(),i}(Array.from(e),t,l);else{var d;let n,i,a,o,s;d=Array.from(e),a=[],o=t.reduce((e,t)=>{let n=t.replace(r.KB,"");return a.push(n),e[n]=t,e},{}),(s=(0,r.B4)(a,d)).matchedSupportedLocale&&s.matchedDesiredLocale&&(n=s.matchedSupportedLocale,i=o[s.matchedDesiredLocale].slice(s.matchedDesiredLocale.length)||void 0),u=n?{locale:n,extension:i}:{locale:l()}}null==u&&(u={locale:l(),extension:""});let f=u.locale,p=s[f],h={locale:"en",dataLocale:f};c=u.extension?function(e){let t;(0,r.V1)(e===e.toLowerCase(),"Expected extension to be lowercase"),(0,r.V1)("-u-"===e.slice(0,3),"Expected extension to be a Unicode locale extension");let n=[],i=[],a=e.length,o=3;for(;o<a;){let s,l=e.indexOf("-",o);s=-1===l?a-o:l-o;let u=e.slice(o,o+s);(0,r.V1)(s>=2,"Expected a subtag to have at least 2 characters"),void 0===t&&2!=s?-1===n.indexOf(u)&&n.push(u):2===s?(t={key:u,value:""},void 0===i.find(e=>e.key===t?.key)&&i.push(t)):t?.value===""?t.value=u:((0,r.V1)(void 0!==t,"Expected keyword to be defined"),t.value+="-"+u),o+=s+1}return{attributes:n,keywords:i}}(u.extension).keywords:[];let m=[];for(let e of o){let t,i=p?.[e]??[];(0,r.V1)(Array.isArray(i),`keyLocaleData for ${e} must be an array`);let a=i[0];(0,r.V1)(void 0===a||"string"==typeof a,"value must be a string or undefined");let o=c.find(t=>t.key===e);if(o){let n=o.value;""!==n?i.indexOf(n)>-1&&(t={key:e,value:a=n}):i.indexOf("true")>-1&&(t={key:e,value:a="true"})}let s=n[e];(0,r.V1)(null==s||"string"==typeof s,"optionsValue must be a string or undefined"),"string"==typeof s&&""===(s=function(e,t){let n=t.toLowerCase();return(0,r.V1)(void 0!==e,"ukey must be defined"),n}(e.toLowerCase(),s))&&(s="true"),s!==a&&i.indexOf(s)>-1&&(a=s,t=void 0),t&&m.push(t),h[e]=a}return m.length>0&&(f=function(e,t,n){(0,r.V1)(-1===e.indexOf("-u-"),"Expected locale to not have a Unicode locale extension");let a="-u";for(let e of t)a+=`-${e}`;for(let e of n){let{key:t,value:n}=e;a+=`-${t}`,""!==n&&(a+=`-${n}`)}if("-u"===a)return i(e);let o=e.indexOf("-x-");return i(-1===o?e+a:e.slice(0,o)+a+e.slice(o))}(f,[],m)),h.locale=f,h}}