polyfills.Intl.raw.js Maven / Gradle / Ivy
The newest version!
// Intl
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):e.IntlPolyfill=r()}(this,function(){"use strict";function e(e){if("function"==typeof Math.log10)return Math.floor(Math.log10(e));var r=Math.round(Math.log(e)*Math.LOG10E);return r-(Number("1e"+r)>e)}function r(e){for(var t in e)(e instanceof r||Me.call(e,t))&&Ie(this,t,{value:e[t],enumerable:!0,writable:!0,configurable:!0})}function t(){Ie(this,"length",{writable:!0,value:0}),arguments.length&&Ge.apply(this,qe.call(arguments))}function n(){if($e.disableRegExpRestore)return function(){};for(var e={lastMatch:RegExp.lastMatch||"",leftContext:RegExp.leftContext,multiline:RegExp.multiline,input:RegExp.input},r=!1,n=1;n<=9;n++)r=(e["$"+n]=RegExp["$"+n])||r;return function(){var n=/[.?*+^$[\]\\(){}|-]/g,a=e.lastMatch.replace(n,"\\$&"),i=new t;if(r)for(var o=1;o<=9;o++){var s=e["$"+o];s?(s=s.replace(n,"\\$&"),a=a.replace(s,"("+s+")")):a="()"+a,Ge.call(i,a.slice(0,a.indexOf("(")+1)),a=a.slice(a.indexOf("(")+1)}var l=Ze.call(i,"")+a;l=l.replace(/(\\\(|\\\)|[^()])+/g,function(e){return"[\\s\\S]{"+e.replace("\\","").length+"}"});var c=new RegExp(l,e.multiline?"gm":"g");c.lastIndex=e.leftContext.length,c.exec(e.input)}}function a(e){if(null===e)throw new TypeError("Cannot convert null or undefined to object");return"object"===("undefined"==typeof e?"undefined":Ne.typeof(e))?e:Object(e)}function i(e){return"number"==typeof e?e:Number(e)}function o(e){var r=i(e);return isNaN(r)?0:0===r||r===-0||r===+(1/0)||r===-(1/0)?r:r<0?Math.floor(Math.abs(r))*-1:Math.floor(Math.abs(r))}function s(e){var r=o(e);return r<=0?0:r===1/0?Math.pow(2,53)-1:Math.min(r,Math.pow(2,53)-1)}function l(e){return Me.call(e,"__getInternalProperties")?e.__getInternalProperties(Ke):Re(null)}function c(e){cr=e}function u(e){for(var r=e.length;r--;){var t=e.charAt(r);t>="a"&&t<="z"&&(e=e.slice(0,r)+t.toUpperCase()+e.slice(r+1))}return e}function g(e){return!!ir.test(e)&&(!or.test(e)&&!sr.test(e))}function f(e){var r=void 0,t=void 0;e=e.toLowerCase(),t=e.split("-");for(var n=1,a=t.length;n1&&(r.sort(),e=e.replace(RegExp("(?:"+lr.source+")+","i"),Ze.call(r,""))),Me.call(ur.tags,e)&&(e=ur.tags[e]),t=e.split("-");for(var i=1,o=t.length;i-1)return t;var n=t.lastIndexOf("-");if(n<0)return;n>=2&&"-"===t.charAt(n-2)&&(n-=2),t=t.substring(0,n)}}function p(e,t){for(var n=0,a=t.length,i=void 0,o=void 0,s=void 0;n2){var F=c[O+1],S=k.call(j,F);S!==-1&&(D=F,z="-"+w+"-"+D)}else{var E=k(j,"true");E!==-1&&(D="true")}}if(Me.call(n,"[["+w+"]]")){var L=n["[["+w+"]]"];k.call(j,L)!==-1&&L!==D&&(D=L,z="")}v["[["+w+"]]"]=D,d+=z,h++}if(d.length>2){var P=l.indexOf("-x-");if(P===-1)l+=d;else{var N=l.substring(0,P),T=l.substring(P);l=N+d+T}l=f(l)}return v["[[locale]]"]=l,v}function w(e,r){for(var n=r.length,a=new t,i=0;in)throw new RangeError("Value is not a number or outside accepted range");return Math.floor(i)}return a}function k(e){for(var r=d(e),t=[],n=r.length,a=0;ai;i++){var o=t[i],s={};s.type=o["[[type]]"],s.value=o["[[value]]"],n[a]=s,a+=1}return n}function N(e,r){var n=l(e),a=n["[[dataLocale]]"],i=n["[[numberingSystem]]"],o=$e.NumberFormat["[[localeData]]"][a],s=o.symbols[i]||o.symbols.latn,c=void 0;!isNaN(r)&&r<0?(r=-r,c=n["[[negativePattern]]"]):c=n["[[positivePattern]]"];for(var u=new t,g=c.indexOf("{",0),f=0,m=0,v=c.length;g>-1&&gm){var d=c.substring(m,g);Ge.call(u,{"[[type]]":"literal","[[value]]":d})}var h=c.substring(g+1,f);if("number"===h)if(isNaN(r)){var p=s.nan;Ge.call(u,{"[[type]]":"nan","[[value]]":p})}else if(isFinite(r)){"percent"===n["[[style]]"]&&isFinite(r)&&(r*=100);var y=void 0;y=Me.call(n,"[[minimumSignificantDigits]]")&&Me.call(n,"[[maximumSignificantDigits]]")?_(r,n["[[minimumSignificantDigits]]"],n["[[maximumSignificantDigits]]"]):M(r,n["[[minimumIntegerDigits]]"],n["[[minimumFractionDigits]]"],n["[[maximumFractionDigits]]"]),dr[i]?!function(){var e=dr[i];y=String(y).replace(/\d/g,function(r){return e[r]})}():y=String(y);var b=void 0,w=void 0,x=y.indexOf(".",0);if(x>0?(b=y.substring(0,x),w=y.substring(x+1,x.length)):(b=y,w=void 0),n["[[useGrouping]]"]===!0){var j=s.group,D=[],z=o.patterns.primaryGroupSize||3,k=o.patterns.secondaryGroupSize||z;if(b.length>z){var O=b.length-z,F=O%k,S=b.slice(0,F);for(S.length&&Ge.call(D,S);Fa;a++){var i=t[a];n+=i["[[value]]"]}return n}function _(r,t,n){var a=n,i=void 0,o=void 0;if(0===r)i=Ze.call(Array(a+1),"0"),o=0;else{o=e(Math.abs(r));var s=Math.round(Math.exp(Math.abs(o-a+1)*Math.LN10));i=String(Math.round(o-a+1<0?r*s:r/s))}if(o>=a)return i+Ze.call(Array(o-a+1+1),"0");if(o===a-1)return i;if(o>=0?i=i.slice(0,o+1)+"."+i.slice(o+1):o<0&&(i="0."+Ze.call(Array(-(o+1)+1),"0")+i),i.indexOf(".")>=0&&n>t){for(var l=n-t;l>0&&"0"===i.charAt(i.length-1);)i=i.slice(0,-1),l--;"."===i.charAt(i.length-1)&&(i=i.slice(0,-1))}return i}function M(e,r,t,n){var a=n,i=Math.pow(10,a)*e,o=0===i?"0":i.toFixed(0),s=void 0,l=(s=o.indexOf("e"))>-1?o.slice(s+1):0;l&&(o=o.slice(0,s).replace(".",""),o+=Ze.call(Array(l-(o.length-1)+1),"0"));var c=void 0;if(0!==a){var u=o.length;if(u<=a){var g=Ze.call(Array(a+1-u+1),"0");o=g+o,u=a+1}var f=o.substring(0,u-a),m=o.substring(u-a,o.length);o=f+"."+m,c=f.length}else c=o.length;for(var v=n-t;v>0&&"0"===o.slice(-1);)o=o.slice(0,-1),v--;if("."===o.slice(-1)&&(o=o.slice(0,-1)),cl&&(l=m,c=f),u++}return c}function X(e,r){var t=[];for(var n in Dr)Me.call(Dr,n)&&void 0!==e["[["+n+"]]"]&&t.push(n);if(1===t.length){var a=B(t[0],e["[["+t[0]+"]]"]);if(a)return a}for(var i=120,o=20,s=8,l=6,c=6,u=3,g=2,f=1,m=-(1/0),v=void 0,d=0,h=r.length;d=2||k>=2&&z<=1?O>0?y-=l:O<0&&(y-=s):O>1?y-=u:O<-1&&(y-=c)}}p._.hour12!==e.hour12&&(y-=f),y>m&&(m=y,v=p),d++}return v}function V(){var e=null!==this&&"object"===Ne.typeof(this)&&l(this);if(!e||!e["[[initializedDateTimeFormat]]"])throw new TypeError("`this` value for format() is not an initialized Intl.DateTimeFormat object.");if(void 0===e["[[boundFormat]]"]){var r=function(){var e=arguments.length<=0||void 0===arguments[0]?void 0:arguments[0],r=void 0===e?Date.now():i(e);return ee(this,r)},t=Ue.call(r,this);e["[[boundFormat]]"]=t}return e["[[boundFormat]]"]}function J(){var e=arguments.length<=0||void 0===arguments[0]?void 0:arguments[0],r=null!==this&&"object"===Ne.typeof(this)&&l(this);if(!r||!r["[[initializedDateTimeFormat]]"])throw new TypeError("`this` value for formatToParts() is not an initialized Intl.DateTimeFormat object.");var t=void 0===e?Date.now():i(e);return re(this,t)}function Q(e,r){if(!isFinite(r))throw new RangeError("Invalid valid date passed to format");var a=e.__getInternalProperties(Ke);n();for(var i=a["[[locale]]"],o=new mr.NumberFormat([i],{useGrouping:!1}),s=new mr.NumberFormat([i],{minimumIntegerDigits:2,useGrouping:!1}),l=te(r,a["[[calendar]]"],a["[[timeZone]]"]),c=a["[[pattern]]"],u=new t,g=0,f=c.indexOf("{"),m=0,v=a["[[dataLocale]]"],d=$e.DateTimeFormat["[[localeData]]"][v].calendars,h=a["[[calendar]]"];f!==-1;){var p=void 0;if(m=c.indexOf("}",f),m===-1)throw new Error("Unclosed pattern");f>g&&Ge.call(u,{type:"literal",value:c.substring(g,f)});var y=c.substring(f+1,m);if(Dr.hasOwnProperty(y)){var b=a["[["+y+"]]"],w=l["[["+y+"]]"];if("year"===y&&w<=0?w=1-w:"month"===y?w++:"hour"===y&&a["[[hour12]]"]===!0&&(w%=12,0===w&&a["[[hourNo0]]"]===!0&&(w=12)),"numeric"===b)p=T(o,w);else if("2-digit"===b)p=T(s,w),p.length>2&&(p=p.slice(-2));else if(b in jr)switch(y){case"month":p=U(d,h,"months",b,l["[["+y+"]]"]);break;case"weekday":try{p=U(d,h,"days",b,l["[["+y+"]]"])}catch(e){throw new Error("Could not find weekday data for locale "+i)}break;case"timeZoneName":p="";break;case"era":try{p=U(d,h,"eras",b,l["[["+y+"]]"])}catch(e){throw new Error("Could not find era data for locale "+i)}break;default:p=l["[["+y+"]]"]}Ge.call(u,{type:y,value:p})}else if("ampm"===y){var x=l["[[hour]]"];p=U(d,h,"dayPeriods",x>11?"pm":"am",null),Ge.call(u,{type:"dayPeriod",value:p})}else Ge.call(u,{type:"literal",value:c.substring(f,m+1)});g=m+1,f=c.indexOf("{",g)}return ma;a++){var i=t[a];n+=i.value}return n}function re(e,r){for(var t=Q(e,r),n=[],a=0;t.length>a;a++){var i=t[a];n.push({type:i.type,value:i.value})}return n}function te(e,t,n){var a=new Date(e),i="get"+(n||"");return new r({"[[weekday]]":a[i+"Day"](),"[[era]]":+(a[i+"FullYear"]()>=0),"[[year]]":a[i+"FullYear"](),"[[month]]":a[i+"Month"](),"[[day]]":a[i+"Date"](),"[[hour]]":a[i+"Hours"](),"[[minute]]":a[i+"Minutes"](),"[[second]]":a[i+"Seconds"](),"[[inDST]]":!1})}function ne(e,r){if(!e.number)throw new Error("Object passed doesn't contain locale data for Intl.NumberFormat");var t=void 0,n=[r],a=r.split("-");for(a.length>2&&4===a[1].length&&Ge.call(n,a[0]+"-"+a[2]);t=Be.call(n);)Ge.call($e.NumberFormat["[[availableLocales]]"],t),$e.NumberFormat["[[localeData]]"][t]=e.number,e.date&&(e.date.nu=e.number.nu,Ge.call($e.DateTimeFormat["[[availableLocales]]"],t),$e.DateTimeFormat["[[localeData]]"][t]=e.date);void 0===cr&&c(r)}var ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},ie=function(){var e="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103;return function(r,t,n,a){var i=r&&r.defaultProps,o=arguments.length-3;if(t||0===o||(t={}),t&&i)for(var s in i)void 0===t[s]&&(t[s]=i[s]);else t||(t=i||{});if(1===o)t.children=a;else if(o>1){for(var l=Array(o),c=0;c=0||Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},xe=function(e,r){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!r||"object"!=typeof r&&"function"!=typeof r?e:r},je="undefined"==typeof global?self:global,De=function e(r,t,n,a){var i=Object.getOwnPropertyDescriptor(r,t);if(void 0===i){var o=Object.getPrototypeOf(r);null!==o&&e(o,t,n,a)}else if("value"in i&&i.writable)i.value=n;else{var s=i.set;void 0!==s&&s.call(a,n)}return n},ze=function(){function e(e,r){var t=[],n=!0,a=!1,i=void 0;try{for(var o,s=e[Symbol.iterator]();!(n=(o=s.next()).done)&&(t.push(o.value),!r||t.length!==r);n=!0);}catch(e){a=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(a)throw i}}return t}return function(r,t){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return e(r,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),ke=function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e)){for(var t,n=[],a=e[Symbol.iterator]();!(t=a.next()).done&&(n.push(t.value),!r||n.length!==r););return n}throw new TypeError("Invalid attempt to destructure non-iterable instance")},Oe=function(e,r){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(r)}}))},Fe=function(e,r){return e.raw=r,e},Se=function(e,r,t){if(e===t)throw new ReferenceError(r+" is not defined - temporal dead zone");return e},Ee={},Le=function(e){return Array.isArray(e)?e:Array.from(e)},Pe=function(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r