generaltranslation 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,2 @@
1
- var t=function(){return t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};function e(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}u((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}"function"==typeof SuppressedError&&SuppressedError;var r="/v1/translate/batch",o="/v1/translate/react",i="/v1/translate/content",a="/v1/project/dictionary/update",c="/v1/project/locales";function u(t,o){return e(this,void 0,void 0,(function(){var e,i,a,c,u,l,s,f,v;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,i=e.signal,(null===(v=null===(f=null===(s=o[0])||void 0===s?void 0:s.data)||void 0===f?void 0:f.metadata)||void 0===v?void 0:v.timeout)&&setTimeout((function(){return e.abort()}),o[0].data.metadata.timeout),[4,fetch("".concat(t.baseURL).concat(r),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify(o),signal:i})];case 1:return(a=n.sent()).ok?[3,3]:(c=Error.bind,l=(u="".concat(a.status,": ")).concat,[4,a.text()]);case 2:throw new(c.apply(Error,[void 0,l.apply(u,[n.sent()])]));case 3:return[4,a.json()];case 4:return[2,n.sent()]}}))}))}function l(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{var n=t.flat().map((function(t){return new Intl.Locale(t).language}));return n.every((function(t){return t===n[0]}))}catch(t){return console.error(t),!1}}var s="en-US",f=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],v=function(t){try{var e=new Intl.Locale(t),n=e.language,r=e.region,o=e.script;if(new Intl.DisplayNames([s],{type:"language"}).of(n)===n)return!1;if(r)if(new Intl.DisplayNames([s],{type:"region"}).of(r)===r)return!1;if(o)if(new Intl.DisplayNames([s],{type:"script"}).of(o)===o&&!f.includes(o))return!1;return!0}catch(t){return!1}},p=function(t){return Intl.getCanonicalLocales(t)[0]};function d(){for(var t,e,n,r,o,i,a,c,u,l,s=[],f=0;f<arguments.length;f++)s[f]=arguments[f];try{for(var v=s.flat().map(p),d=0;d<v.length;d++)for(var y=d+1;y<v.length;y++)if(t=v[d],e=v[y],n=void 0,r=void 0,o=void 0,i=void 0,a=void 0,c=void 0,u=void 0,l=void 0,n=new Intl.Locale(t),r=n.language,o=n.region,i=n.script,a=new Intl.Locale(e),c=a.language,u=a.region,l=a.script,r!==c||o&&u&&o!==u||i&&l&&i!==l)return!1;return!0}catch(t){return console.error(t),!1}}function y(t,r,o,a){return e(this,void 0,void 0,(function(){var e,c,u,l,s,f;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,c=e.signal,a.timeout&&setTimeout((function(){return e.abort()}),a.timeout),[4,fetch("".concat(t.baseURL).concat(i),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({content:r,targetLocale:o,metadata:a}),signal:c})];case 1:return(u=n.sent()).ok?[3,3]:(l=Error.bind,f=(s="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(l.apply(Error,[void 0,f.apply(s,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function m(t,r,i,a){return e(this,void 0,void 0,(function(){var e,c,u,l,s,f;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,c=e.signal,a.timeout&&setTimeout((function(){return e.abort()}),a.timeout),[4,fetch("".concat(t.baseURL).concat(o),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({children:r,targetLocale:i,metadata:a}),signal:c})];case 1:return(u=n.sent()).ok?[3,3]:(l=Error.bind,f=(s="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(l.apply(Error,[void 0,f.apply(s,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function h(t,r,o,i){return e(this,void 0,void 0,(function(){var e,c,u,l,s;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(t.baseURL).concat(a),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({updates:r,locales:o,options:i})})];case 1:return(e=n.sent()).ok?[3,3]:(c=Error.bind,l=(u="".concat(e.status,": ")).concat,[4,e.text()]);case 2:throw new(c.apply(Error,[void 0,l.apply(u,[n.sent()])]));case 3:return[4,e.json()];case 4:return[2,null==(s=n.sent())?void 0:s.locales]}}))}))}function g(t,r){return e(this,void 0,void 0,(function(){var e,o,i,a;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(t.baseURL).concat(c,"?projectID=").concat(r),{method:"GET",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey}})];case 1:return(e=n.sent()).ok?[3,3]:(o=Error.bind,a=(i="".concat(e.status,": ")).concat,[4,e.text()]);case 2:throw new(o.apply(Error,[void 0,a.apply(i,[n.sent()])]));case 3:return[4,e.json()];case 4:return[2,n.sent()]}}))}))}function b(e){var n=e.value,r=e.locales,o=void 0===r?[s]:r,i=e.options,a=void 0===i?{}:i;return new Intl.NumberFormat(o,t({numberingSystem:"latn"},a)).format(n)}function N(e){var n=e.value,r=e.locales,o=void 0===r?[s]:r,i=e.options,a=void 0===i?{}:i;return new Intl.DateTimeFormat(o,t({calendar:"gregory",numberingSystem:"latn"},a)).format(n)}function w(e){var n=e.value,r=e.locales,o=void 0===r?[s]:r,i=e.currency,a=void 0===i?"USD":i,c=e.options,u=void 0===c?{}:c;return new Intl.NumberFormat(o,t({style:"currency",currency:a,numberingSystem:"latn"},u)).format(n)}function S(e){var n=e.value,r=e.locales,o=void 0===r?[s]:r,i=e.options,a=void 0===i?{}:i;return new Intl.ListFormat(o,t({type:"conjunction",style:"long"},a)).format(n)}var C={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function I(e){if("string"!=typeof e)throw new Error("splitStringToContent: ".concat(e," is not a string!"));for(var n,r=[],o=/{([^}]+)}/g,i=0;null!==(n=o.exec(e));){var a=n[0],c=n[1],u=n.index;if("^"!==e[u-1]){u>i&&r.push(e.slice(i,u));var l=c.split(",").map((function(t){return t.trim()})),s=l[0],f=l[1]?C[l[1]]:void 0,v=t({key:s},f&&{variable:f});r.push(v),i=u+a.length}else u-1>i&&r.push(e.slice(i,u-1)),r.push(a),i=u+a.length}return i<e.length&&r.push(e.slice(i)),r}function L(t,e){if(void 0===e&&(e={}),!v(t))return M;if(e[t=p(t)])return e[t];var n=new Intl.Locale(t),r=n.region;if(r&&G[r])return G[r];var o=n.maximize(),i=o.region||"";return E[o.language]||G[i]||M}var T="🌍",M=T,E={ca:T,eu:T,ku:T,bo:"🌏",ug:"🌏",gd:"🏴󠁧󠁢󠁳󠁣󠁴󠁿",cy:"🏴󠁧󠁢󠁷󠁬󠁳󠁿",gv:"🇮🇲",grc:"🏺"},G={AF:"🇦🇫",AX:"🇦🇽",AL:"🇦🇱",DZ:"🇩🇿",AS:"🇦🇸",AD:"🇦🇩",AO:"🇦🇴",AI:"🇦🇮",AQ:"🇦🇶",AG:"🇦🇬",AR:"🇦🇷",AM:"🇦🇲",AW:"🇦🇼",AU:"🇦🇺",AT:"🇦🇹",AZ:"🇦🇿",BS:"🇧🇸",BH:"🇧🇭",BD:"🇧🇩",BB:"🇧🇧",BY:"🇧🇾",BE:"🇧🇪",BZ:"🇧🇿",BJ:"🇧🇯",BM:"🇧🇲",BT:"🇧🇹",BO:"🇧🇴",BQ:"🇧🇶",BA:"🇧🇦",BW:"🇧🇼",BV:"🇧🇻",BR:"🇧🇷",IO:"🇮🇴",BN:"🇧🇳",BG:"🇧🇬",BF:"🇧🇫",BI:"🇧🇮",CV:"🇨🇻",KH:"🇰🇭",CM:"🇨🇲",CA:"🇨🇦",KY:"🇰🇾",CF:"🇨🇫",TD:"🇹🇩",CL:"🇨🇱",CN:"🇨🇳",CX:"🇨🇽",CC:"🇨🇨",CO:"🇨🇴",KM:"🇰🇲",CD:"🇨🇩",CG:"🇨🇬",CK:"🇨🇰",CR:"🇨🇷",CI:"🇨🇮",HR:"🇭🇷",CU:"🇨🇺",CW:"🇨🇼",CY:"🇨🇾",CZ:"🇨🇿",DK:"🇩🇰",DJ:"🇩🇯",DM:"🇩🇲",DO:"🇩🇴",EC:"🇪🇨",EG:"🇪🇬",SV:"🇸🇻",GQ:"🇬🇶",ER:"🇪🇷",EE:"🇪🇪",SZ:"🇸🇿",ET:"🇪🇹",FK:"🇫🇰",FO:"🇫🇴",FJ:"🇫🇯",FI:"🇫🇮",FR:"🇫🇷",GF:"🇬🇫",PF:"🇵🇫",TF:"🇹🇫",GA:"🇬🇦",GM:"🇬🇲",GE:"🇬🇪",DE:"🇩🇪",GH:"🇬🇭",GI:"🇬🇮",GR:"🇬🇷",GL:"🇬🇱",GD:"🇬🇩",GP:"🇬🇵",GU:"🇬🇺",GT:"🇬🇹",GG:"🇬🇬",GN:"🇬🇳",GW:"🇬🇼",GY:"🇬🇾",HT:"🇭🇹",HM:"🇭🇲",VA:"🇻🇦",HN:"🇭🇳",HK:"🇭🇰",HU:"🇭🇺",IS:"🇮🇸",IN:"🇮🇳",ID:"🇮🇩",IR:"🇮🇷",IQ:"🇮🇶",IE:"🇮🇪",IM:"🇮🇲",IL:"🇮🇱",IT:"🇮🇹",JM:"🇯🇲",JP:"🇯🇵",JE:"🇯🇪",JO:"🇯🇴",KZ:"🇰🇿",KE:"🇰🇪",KI:"🇰🇮",KP:"🇰🇵",KR:"🇰🇷",KW:"🇰🇼",KG:"🇰🇬",LA:"🇱🇦",LV:"🇱🇻",LB:"🇱🇧",LS:"🇱🇸",LR:"🇱🇷",LY:"🇱🇾",LI:"🇱🇮",LT:"🇱🇹",LU:"🇱🇺",MO:"🇲🇴",MG:"🇲🇬",MW:"🇲🇼",MY:"🇲🇾",MV:"🇲🇻",ML:"🇲🇱",MT:"🇲🇹",MH:"🇲🇭",MQ:"🇲🇶",MR:"🇲🇷",MU:"🇲🇺",YT:"🇾🇹",MX:"🇲🇽",FM:"🇫🇲",MD:"🇲🇩",MC:"🇲🇨",MN:"🇲🇳",ME:"🇲🇪",MS:"🇲🇸",MA:"🇲🇦",MZ:"🇲🇿",MM:"🇲🇲",NA:"🇳🇦",NR:"🇳🇷",NP:"🇳🇵",NL:"🇳🇱",NC:"🇳🇨",NZ:"🇳🇿",NI:"🇳🇮",NE:"🇳🇪",NG:"🇳🇬",NU:"🇳🇺",NF:"🇳🇫",MK:"🇲🇰",MP:"🇲🇵",NO:"🇳🇴",OM:"🇴🇲",PK:"🇵🇰",PW:"🇵🇼",PS:"🇵🇸",PA:"🇵🇦",PG:"🇵🇬",PY:"🇵🇾",PE:"🇵🇪",PH:"🇵🇭",PN:"🇵🇳",PL:"🇵🇱",PT:"🇵🇹",PR:"🇵🇷",QA:"🇶🇦",RE:"🇷🇪",RO:"🇷🇴",RU:"🇷🇺",RW:"🇷🇼",BL:"🇧🇱",SH:"🇸🇭",KN:"🇰🇳",LC:"🇱🇨",MF:"🇲🇫",PM:"🇵🇲",VC:"🇻🇨",WS:"🇼🇸",SM:"🇸🇲",ST:"🇸🇹",SA:"🇸🇦",SN:"🇸🇳",RS:"🇷🇸",SC:"🇸🇨",SL:"🇸🇱",SG:"🇸🇬",SX:"🇸🇽",SK:"🇸🇰",SI:"🇸🇮",SB:"🇸🇧",SO:"🇸🇴",ZA:"🇿🇦",GS:"🇬🇸",SS:"🇸🇸",ES:"🇪🇸",LK:"🇱🇰",SD:"🇸🇩",SR:"🇸🇷",SJ:"🇸🇯",SE:"🇸🇪",CH:"🇨🇭",SY:"🇸🇾",TW:"🇹🇼",TJ:"🇹🇯",TZ:"🇹🇿",TH:"🇹🇭",TL:"🇹🇱",TG:"🇹🇬",TK:"🇹🇰",TO:"🇹🇴",TT:"🇹🇹",TN:"🇹🇳",TR:"🇹🇷",TM:"🇹🇲",TC:"🇹🇨",TV:"🇹🇻",UG:"🇺🇬",UA:"🇺🇦",AE:"🇦🇪",GB:"🇬🇧",US:"🇺🇸",UM:"🇺🇲",UY:"🇺🇾",UZ:"🇺🇿",VU:"🇻🇺",VE:"🇻🇪",VN:"🇻🇳",VG:"🇻🇬",VI:"🇻🇮",WF:"🇼🇫",EH:"🇪🇭",YE:"🇾🇪",ZM:"🇿🇲",ZW:"🇿🇼",EU:"🇪🇺"};var R=function(t){return"undefined"!=typeof process&&process.env&&process.env[t]||""},A=function(){function r(t){var e=void 0===t?{}:t,n=e.apiKey,r=void 0===n?"":n,o=e.defaultLocale,i=void 0===o?s:o,a=e.projectID,c=void 0===a?"":a,u=e.baseURL,l=void 0===u?"https://prod.gtx.dev":u;this.apiKey=r||R("GT_API_KEY"),this.projectID=c||R("GT_PROJECT_ID"),this.defaultLocale=p(i)||s,this.baseURL=l}return r.prototype.translate=function(r,o,i){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,y(this,r,o,t({defaultLocale:this.defaultLocale},i))];case 1:return[2,e.sent()]}}))}))},r.prototype.translateReact=function(r,o,i){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,m(this,r,o,t({defaultLocale:this.defaultLocale},i))];case 1:return[2,e.sent()]}}))}))},r.prototype.translateBatch=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,u(this,t)]}))}))},r.prototype.updateProjectDictionary=function(t){return e(this,arguments,void 0,(function(t,e,r){return void 0===e&&(e=[]),void 0===r&&(r={}),n(this,(function(n){return[2,h(this,t,e,r)]}))}))},r.prototype.getProjectLocales=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,g(this,t||this.projectID)]}))}))},r}();function D(t){return function(t){var e;try{var n=new Intl.Locale(t);return"rtl"===(null===(e=null==n?void 0:n.textInfo)||void 0===e?void 0:e.direction)?"rtl":"ltr"}catch(t){return"ltr"}}(t)}function K(t,e){return void 0===e&&(e=s),function(t,e){void 0===e&&(e=s);try{return new Intl.DisplayNames([e,s],{type:"language"}).of(t)||""}catch(t){return""}}(t,e)}function P(t,e){return function(t,e){void 0===e&&(e=s);try{t=O(t);var n=new Intl.Locale(t),r=n.language,o=n.region,i=new Intl.Locale(t).maximize(),a=i.toString(),c=i.region||"",u=i.script||"",l=new Intl.Locale(t).minimize().toString(),f=new Intl.DisplayNames([e,t,s],{type:"language"}),v=new Intl.DisplayNames([t,e,s],{type:"language"}),p=f.of(t)||t,d=v.of(t)||t,y=f.of(a)||t,m=v.of(a)||t,h=f.of(l)||t,g=v.of(l)||t,b=f.of(r)||t,N=v.of(r)||t,w=o?"".concat(b," (").concat(o,")"):b,S=o?"".concat(N," (").concat(o,")"):N,C=new Intl.DisplayNames([e,t,s],{type:"region"}),I=new Intl.DisplayNames([t,e,s],{type:"region"}),T=C.of(c)||"",M=I.of(c)||"",E=new Intl.DisplayNames([e,t,s],{type:"script"}),G=new Intl.DisplayNames([t,e,s],{type:"script"});return{code:t,name:p,nativeName:d,maximizedCode:a,maximizedName:y,nativeMaximizedName:m,minimizedCode:l,minimizedName:h,nativeMinimizedName:g,languageCode:r,languageName:b,nativeLanguageName:N,nameWithRegionCode:w,nativeNameWithRegionCode:S,regionCode:c,regionName:T,nativeRegionName:M,scriptCode:u,scriptName:E.of(u)||"",nativeScriptName:G.of(u)||"",emoji:L(t)}}catch(e){var R=t||"",A=null==R?void 0:R.split("-");return{code:R,name:R,nativeName:R,maximizedCode:R,maximizedName:R,nativeMaximizedName:R,minimizedCode:R,minimizedName:R,nativeMinimizedName:R,languageCode:r=(null==A?void 0:A[0])||R||"",languageName:r,nativeLanguageName:r,regionCode:c=A.length>2?null==A?void 0:A[2]:(null==A?void 0:A[1])||"",regionName:c,nativeRegionName:c,scriptCode:u=(null==A?void 0:A[3])||"",scriptName:u,nativeScriptName:u,nameWithRegionCode:w=r?c?"".concat(r," (").concat(c,")"):r:"",nativeNameWithRegionCode:R,emoji:L(R)}}}(t,e)}function j(t,e){return L(t,e)}function x(t){return v(t)}function O(t){return p(t)}function k(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return d.apply(void 0,t)}function B(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return l.apply(void 0,t)}function U(t){return b(t)}function F(t){return N(t)}function W(t){return w(t)}function z(t){return S(t)}function H(e){return r=(n=e).value,o=n.unit,i=n.locales,a=void 0===i?[s]:i,c=n.options,u=void 0===c?{}:c,new Intl.RelativeTimeFormat(a,t({style:"long",numeric:"auto"},u)).format(r,o);var n,r,o,i,a,c,u}function J(t){return I(t)}function V(e,n,r,o){return function(e,n,r,o){if(void 0===n&&(n=s),void 0===r&&(r={}),void 0===o&&(o={}),"string"==typeof e&&(e=I(e)),"string"==typeof e)return e;if(!Array.isArray(e))throw new Error("renderContentToString: content ".concat(e," is invalid"));return e.map((function(e){var i;if("string"==typeof e)return e;if("object"==typeof e){var a=r[e.key];return e.variable?"number"===e.variable?b({value:a,locales:n,options:o[e.key]}):"currency"===e.variable?w(t(t({value:a,locales:n},o[e.key]&&{options:o[e.key]}),(null===(i=o[e.key])||void 0===i?void 0:i.currency)&&{currency:o[e.key].currency})):"datetime"===e.variable?N(t({value:a,locales:n},o[e.key]&&{options:o[e.key]})):"list"===e.variable?S(t({value:a,locales:n},o[e.key]&&{options:o[e.key]})):a:a}})).join("")}(e,n,r,o)}function Z(t,e){return function(t,e){if("string"==typeof t&&(t=[t]),!e)return t[0];for(var n=function(t){for(var n=p(t),r=[],o=0,i=e;o<i.length;o++){var a=i[o],c=p(a);if(n===c)return{value:c};l(n,c)&&r.push(c)}if(r.length)return{value:r.find((function(t){return d(n,t)}))||r[0]}},r=0,o=t;r<o.length;r++){var i=n(o[r]);if("object"==typeof i)return i.value}}(t,e)}function Y(t,e,n){return function(t,e,n){return!(!v(t)||!v(e)||n&&n.some((function(t){return!v(t)}))||d(t,e)||n&&!n.some((function(t){return l(e,t)})))}(t,e,n)}export{A as default,Z as determineLocale,W as formatCurrency,F as formatDateTime,z as formatList,U as formatNum,H as formatRelativeTime,D as getLocaleDirection,j as getLocaleEmoji,K as getLocaleName,P as getLocaleProperties,k as isSameDialect,B as isSameLanguage,x as isValidLocale,V as renderContentToString,Y as requiresTranslation,J as splitStringToContent,O as standardizeLocale};
1
+ var t=function(){return t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};function e(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}u((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}"function"==typeof SuppressedError&&SuppressedError;var r="/v1/translate/batch",o="/v1/translate/react",i="/v1/translate/content",a="/v1/project/dictionary/update",c="/v1/project/locales";function u(t,o){return e(this,void 0,void 0,(function(){var e,i,a,c,u,l,s,f,v;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,i=e.signal,(null===(v=null===(f=null===(s=o[0])||void 0===s?void 0:s.data)||void 0===f?void 0:f.metadata)||void 0===v?void 0:v.timeout)&&setTimeout((function(){return e.abort()}),o[0].data.metadata.timeout),[4,fetch("".concat(t.baseURL).concat(r),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify(o),signal:i})];case 1:return(a=n.sent()).ok?[3,3]:(c=Error.bind,l=(u="".concat(a.status,": ")).concat,[4,a.text()]);case 2:throw new(c.apply(Error,[void 0,l.apply(u,[n.sent()])]));case 3:return[4,a.json()];case 4:return[2,n.sent()]}}))}))}function l(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{var n=t.flat().map((function(t){return new Intl.Locale(t).language}));return n.every((function(t){return t===n[0]}))}catch(t){return console.error(t),!1}}var s="en-US",f=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],v=function(t){try{var e=new Intl.Locale(t),n=e.language,r=e.region,o=e.script;if(new Intl.DisplayNames([s],{type:"language"}).of(n)===n)return!1;if(r)if(new Intl.DisplayNames([s],{type:"region"}).of(r)===r)return!1;if(o)if(new Intl.DisplayNames([s],{type:"script"}).of(o)===o&&!f.includes(o))return!1;return!0}catch(t){return!1}},p=function(t){return Intl.getCanonicalLocales(t)[0]};function d(){for(var t,e,n,r,o,i,a,c,u,l,s=[],f=0;f<arguments.length;f++)s[f]=arguments[f];try{for(var v=s.flat().map(p),d=0;d<v.length;d++)for(var y=d+1;y<v.length;y++)if(t=v[d],e=v[y],n=void 0,r=void 0,o=void 0,i=void 0,a=void 0,c=void 0,u=void 0,l=void 0,n=new Intl.Locale(t),r=n.language,o=n.region,i=n.script,a=new Intl.Locale(e),c=a.language,u=a.region,l=a.script,r!==c||o&&u&&o!==u||i&&l&&i!==l)return!1;return!0}catch(t){return console.error(t),!1}}function y(t,r,o,a){return e(this,void 0,void 0,(function(){var e,c,u,l,s,f;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,c=e.signal,a.timeout&&setTimeout((function(){return e.abort()}),a.timeout),[4,fetch("".concat(t.baseURL).concat(i),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({content:r,targetLocale:o,metadata:a}),signal:c})];case 1:return(u=n.sent()).ok?[3,3]:(l=Error.bind,f=(s="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(l.apply(Error,[void 0,f.apply(s,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function m(t,r,i,a){return e(this,void 0,void 0,(function(){var e,c,u,l,s,f;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,c=e.signal,a.timeout&&setTimeout((function(){return e.abort()}),a.timeout),[4,fetch("".concat(t.baseURL).concat(o),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({children:r,targetLocale:i,metadata:a}),signal:c})];case 1:return(u=n.sent()).ok?[3,3]:(l=Error.bind,f=(s="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(l.apply(Error,[void 0,f.apply(s,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function h(t,r,o,i){return e(this,void 0,void 0,(function(){var e,c,u,l;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(t.baseURL).concat(a),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({updates:r,locales:o,options:i})})];case 1:return(e=n.sent()).ok?[3,3]:(c=Error.bind,l=(u="".concat(e.status,": ")).concat,[4,e.text()]);case 2:throw new(c.apply(Error,[void 0,l.apply(u,[n.sent()])]));case 3:return[4,e.json()];case 4:return[2,n.sent()]}}))}))}function g(t,r){return e(this,void 0,void 0,(function(){var e,o,i,a;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(t.baseURL).concat(c,"?projectID=").concat(r),{method:"GET",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey}})];case 1:return(e=n.sent()).ok?[3,3]:(o=Error.bind,a=(i="".concat(e.status,": ")).concat,[4,e.text()]);case 2:throw new(o.apply(Error,[void 0,a.apply(i,[n.sent()])]));case 3:return[4,e.json()];case 4:return[2,n.sent()]}}))}))}function b(e){var n=e.value,r=e.locales,o=void 0===r?[s]:r,i=e.options,a=void 0===i?{}:i;return new Intl.NumberFormat(o,t({numberingSystem:"latn"},a)).format(n)}function N(e){var n=e.value,r=e.locales,o=void 0===r?[s]:r,i=e.options,a=void 0===i?{}:i;return new Intl.DateTimeFormat(o,t({calendar:"gregory",numberingSystem:"latn"},a)).format(n)}function w(e){var n=e.value,r=e.locales,o=void 0===r?[s]:r,i=e.currency,a=void 0===i?"USD":i,c=e.options,u=void 0===c?{}:c;return new Intl.NumberFormat(o,t({style:"currency",currency:a,numberingSystem:"latn"},u)).format(n)}function S(e){var n=e.value,r=e.locales,o=void 0===r?[s]:r,i=e.options,a=void 0===i?{}:i;return new Intl.ListFormat(o,t({type:"conjunction",style:"long"},a)).format(n)}var C={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function I(e){if("string"!=typeof e)throw new Error("splitStringToContent: ".concat(e," is not a string!"));for(var n,r=[],o=/{([^}]+)}/g,i=0;null!==(n=o.exec(e));){var a=n[0],c=n[1],u=n.index;if("^"!==e[u-1]){u>i&&r.push(e.slice(i,u));var l=c.split(",").map((function(t){return t.trim()})),s=l[0],f=l[1]?C[l[1]]:void 0,v=t({key:s},f&&{variable:f});r.push(v),i=u+a.length}else u-1>i&&r.push(e.slice(i,u-1)),r.push(a),i=u+a.length}return i<e.length&&r.push(e.slice(i)),r}function L(t,e){if(void 0===e&&(e={}),!v(t))return M;if(e[t=p(t)])return e[t];var n=new Intl.Locale(t),r=n.region;if(r&&G[r])return G[r];var o=n.maximize(),i=o.region||"";return E[o.language]||G[i]||M}var T="🌍",M=T,E={ca:T,eu:T,ku:T,bo:"🌏",ug:"🌏",gd:"🏴󠁧󠁢󠁳󠁣󠁴󠁿",cy:"🏴󠁧󠁢󠁷󠁬󠁳󠁿",gv:"🇮🇲",grc:"🏺"},G={AF:"🇦🇫",AX:"🇦🇽",AL:"🇦🇱",DZ:"🇩🇿",AS:"🇦🇸",AD:"🇦🇩",AO:"🇦🇴",AI:"🇦🇮",AQ:"🇦🇶",AG:"🇦🇬",AR:"🇦🇷",AM:"🇦🇲",AW:"🇦🇼",AU:"🇦🇺",AT:"🇦🇹",AZ:"🇦🇿",BS:"🇧🇸",BH:"🇧🇭",BD:"🇧🇩",BB:"🇧🇧",BY:"🇧🇾",BE:"🇧🇪",BZ:"🇧🇿",BJ:"🇧🇯",BM:"🇧🇲",BT:"🇧🇹",BO:"🇧🇴",BQ:"🇧🇶",BA:"🇧🇦",BW:"🇧🇼",BV:"🇧🇻",BR:"🇧🇷",IO:"🇮🇴",BN:"🇧🇳",BG:"🇧🇬",BF:"🇧🇫",BI:"🇧🇮",CV:"🇨🇻",KH:"🇰🇭",CM:"🇨🇲",CA:"🇨🇦",KY:"🇰🇾",CF:"🇨🇫",TD:"🇹🇩",CL:"🇨🇱",CN:"🇨🇳",CX:"🇨🇽",CC:"🇨🇨",CO:"🇨🇴",KM:"🇰🇲",CD:"🇨🇩",CG:"🇨🇬",CK:"🇨🇰",CR:"🇨🇷",CI:"🇨🇮",HR:"🇭🇷",CU:"🇨🇺",CW:"🇨🇼",CY:"🇨🇾",CZ:"🇨🇿",DK:"🇩🇰",DJ:"🇩🇯",DM:"🇩🇲",DO:"🇩🇴",EC:"🇪🇨",EG:"🇪🇬",SV:"🇸🇻",GQ:"🇬🇶",ER:"🇪🇷",EE:"🇪🇪",SZ:"🇸🇿",ET:"🇪🇹",FK:"🇫🇰",FO:"🇫🇴",FJ:"🇫🇯",FI:"🇫🇮",FR:"🇫🇷",GF:"🇬🇫",PF:"🇵🇫",TF:"🇹🇫",GA:"🇬🇦",GM:"🇬🇲",GE:"🇬🇪",DE:"🇩🇪",GH:"🇬🇭",GI:"🇬🇮",GR:"🇬🇷",GL:"🇬🇱",GD:"🇬🇩",GP:"🇬🇵",GU:"🇬🇺",GT:"🇬🇹",GG:"🇬🇬",GN:"🇬🇳",GW:"🇬🇼",GY:"🇬🇾",HT:"🇭🇹",HM:"🇭🇲",VA:"🇻🇦",HN:"🇭🇳",HK:"🇭🇰",HU:"🇭🇺",IS:"🇮🇸",IN:"🇮🇳",ID:"🇮🇩",IR:"🇮🇷",IQ:"🇮🇶",IE:"🇮🇪",IM:"🇮🇲",IL:"🇮🇱",IT:"🇮🇹",JM:"🇯🇲",JP:"🇯🇵",JE:"🇯🇪",JO:"🇯🇴",KZ:"🇰🇿",KE:"🇰🇪",KI:"🇰🇮",KP:"🇰🇵",KR:"🇰🇷",KW:"🇰🇼",KG:"🇰🇬",LA:"🇱🇦",LV:"🇱🇻",LB:"🇱🇧",LS:"🇱🇸",LR:"🇱🇷",LY:"🇱🇾",LI:"🇱🇮",LT:"🇱🇹",LU:"🇱🇺",MO:"🇲🇴",MG:"🇲🇬",MW:"🇲🇼",MY:"🇲🇾",MV:"🇲🇻",ML:"🇲🇱",MT:"🇲🇹",MH:"🇲🇭",MQ:"🇲🇶",MR:"🇲🇷",MU:"🇲🇺",YT:"🇾🇹",MX:"🇲🇽",FM:"🇫🇲",MD:"🇲🇩",MC:"🇲🇨",MN:"🇲🇳",ME:"🇲🇪",MS:"🇲🇸",MA:"🇲🇦",MZ:"🇲🇿",MM:"🇲🇲",NA:"🇳🇦",NR:"🇳🇷",NP:"🇳🇵",NL:"🇳🇱",NC:"🇳🇨",NZ:"🇳🇿",NI:"🇳🇮",NE:"🇳🇪",NG:"🇳🇬",NU:"🇳🇺",NF:"🇳🇫",MK:"🇲🇰",MP:"🇲🇵",NO:"🇳🇴",OM:"🇴🇲",PK:"🇵🇰",PW:"🇵🇼",PS:"🇵🇸",PA:"🇵🇦",PG:"🇵🇬",PY:"🇵🇾",PE:"🇵🇪",PH:"🇵🇭",PN:"🇵🇳",PL:"🇵🇱",PT:"🇵🇹",PR:"🇵🇷",QA:"🇶🇦",RE:"🇷🇪",RO:"🇷🇴",RU:"🇷🇺",RW:"🇷🇼",BL:"🇧🇱",SH:"🇸🇭",KN:"🇰🇳",LC:"🇱🇨",MF:"🇲🇫",PM:"🇵🇲",VC:"🇻🇨",WS:"🇼🇸",SM:"🇸🇲",ST:"🇸🇹",SA:"🇸🇦",SN:"🇸🇳",RS:"🇷🇸",SC:"🇸🇨",SL:"🇸🇱",SG:"🇸🇬",SX:"🇸🇽",SK:"🇸🇰",SI:"🇸🇮",SB:"🇸🇧",SO:"🇸🇴",ZA:"🇿🇦",GS:"🇬🇸",SS:"🇸🇸",ES:"🇪🇸",LK:"🇱🇰",SD:"🇸🇩",SR:"🇸🇷",SJ:"🇸🇯",SE:"🇸🇪",CH:"🇨🇭",SY:"🇸🇾",TW:"🇹🇼",TJ:"🇹🇯",TZ:"🇹🇿",TH:"🇹🇭",TL:"🇹🇱",TG:"🇹🇬",TK:"🇹🇰",TO:"🇹🇴",TT:"🇹🇹",TN:"🇹🇳",TR:"🇹🇷",TM:"🇹🇲",TC:"🇹🇨",TV:"🇹🇻",UG:"🇺🇬",UA:"🇺🇦",AE:"🇦🇪",GB:"🇬🇧",US:"🇺🇸",UM:"🇺🇲",UY:"🇺🇾",UZ:"🇺🇿",VU:"🇻🇺",VE:"🇻🇪",VN:"🇻🇳",VG:"🇻🇬",VI:"🇻🇮",WF:"🇼🇫",EH:"🇪🇭",YE:"🇾🇪",ZM:"🇿🇲",ZW:"🇿🇼",EU:"🇪🇺"};var R=function(t){return"undefined"!=typeof process&&process.env&&process.env[t]||""},A=function(){function r(t){var e=void 0===t?{}:t,n=e.apiKey,r=void 0===n?"":n,o=e.defaultLocale,i=void 0===o?s:o,a=e.projectID,c=void 0===a?"":a,u=e.baseURL,l=void 0===u?"https://prod.gtx.dev":u;this.apiKey=r||R("GT_API_KEY"),this.projectID=c||R("GT_PROJECT_ID"),this.defaultLocale=p(i)||s,this.baseURL=l}return r.prototype.translate=function(r,o,i){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,y(this,r,o,t({defaultLocale:this.defaultLocale},i))];case 1:return[2,e.sent()]}}))}))},r.prototype.translateReact=function(r,o,i){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,m(this,r,o,t({defaultLocale:this.defaultLocale},i))];case 1:return[2,e.sent()]}}))}))},r.prototype.translateBatch=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,u(this,t)]}))}))},r.prototype.updateProjectDictionary=function(t){return e(this,arguments,void 0,(function(t,e,r){return void 0===e&&(e=[]),void 0===r&&(r={}),n(this,(function(n){switch(n.label){case 0:return[4,h(this,t,e,r)];case 1:return[2,n.sent()]}}))}))},r.prototype.getProjectLocales=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,g(this,t||this.projectID)]}))}))},r}();function D(t){return function(t){var e;try{var n=new Intl.Locale(t);return"rtl"===(null===(e=null==n?void 0:n.textInfo)||void 0===e?void 0:e.direction)?"rtl":"ltr"}catch(t){return"ltr"}}(t)}function K(t,e){return void 0===e&&(e=s),function(t,e){void 0===e&&(e=s);try{return new Intl.DisplayNames([e,s],{type:"language"}).of(t)||""}catch(t){return""}}(t,e)}function P(t,e){return function(t,e){void 0===e&&(e=s);try{t=O(t);var n=new Intl.Locale(t),r=n.language,o=n.region,i=new Intl.Locale(t).maximize(),a=i.toString(),c=i.region||"",u=i.script||"",l=new Intl.Locale(t).minimize().toString(),f=new Intl.DisplayNames([e,t,s],{type:"language"}),v=new Intl.DisplayNames([t,e,s],{type:"language"}),p=f.of(t)||t,d=v.of(t)||t,y=f.of(a)||t,m=v.of(a)||t,h=f.of(l)||t,g=v.of(l)||t,b=f.of(r)||t,N=v.of(r)||t,w=o?"".concat(b," (").concat(o,")"):b,S=o?"".concat(N," (").concat(o,")"):N,C=new Intl.DisplayNames([e,t,s],{type:"region"}),I=new Intl.DisplayNames([t,e,s],{type:"region"}),T=C.of(c)||"",M=I.of(c)||"",E=new Intl.DisplayNames([e,t,s],{type:"script"}),G=new Intl.DisplayNames([t,e,s],{type:"script"});return{code:t,name:p,nativeName:d,maximizedCode:a,maximizedName:y,nativeMaximizedName:m,minimizedCode:l,minimizedName:h,nativeMinimizedName:g,languageCode:r,languageName:b,nativeLanguageName:N,nameWithRegionCode:w,nativeNameWithRegionCode:S,regionCode:c,regionName:T,nativeRegionName:M,scriptCode:u,scriptName:E.of(u)||"",nativeScriptName:G.of(u)||"",emoji:L(t)}}catch(e){var R=t||"",A=null==R?void 0:R.split("-");return{code:R,name:R,nativeName:R,maximizedCode:R,maximizedName:R,nativeMaximizedName:R,minimizedCode:R,minimizedName:R,nativeMinimizedName:R,languageCode:r=(null==A?void 0:A[0])||R||"",languageName:r,nativeLanguageName:r,regionCode:c=A.length>2?null==A?void 0:A[2]:(null==A?void 0:A[1])||"",regionName:c,nativeRegionName:c,scriptCode:u=(null==A?void 0:A[3])||"",scriptName:u,nativeScriptName:u,nameWithRegionCode:w=r?c?"".concat(r," (").concat(c,")"):r:"",nativeNameWithRegionCode:R,emoji:L(R)}}}(t,e)}function j(t,e){return L(t,e)}function x(t){return v(t)}function O(t){return p(t)}function k(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return d.apply(void 0,t)}function B(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return l.apply(void 0,t)}function U(t){return b(t)}function F(t){return N(t)}function W(t){return w(t)}function z(t){return S(t)}function H(e){return r=(n=e).value,o=n.unit,i=n.locales,a=void 0===i?[s]:i,c=n.options,u=void 0===c?{}:c,new Intl.RelativeTimeFormat(a,t({style:"long",numeric:"auto"},u)).format(r,o);var n,r,o,i,a,c,u}function J(t){return I(t)}function V(e,n,r,o){return function(e,n,r,o){if(void 0===n&&(n=s),void 0===r&&(r={}),void 0===o&&(o={}),"string"==typeof e&&(e=I(e)),"string"==typeof e)return e;if(!Array.isArray(e))throw new Error("renderContentToString: content ".concat(e," is invalid"));return e.map((function(e){var i;if("string"==typeof e)return e;if("object"==typeof e){var a=r[e.key];return e.variable?"number"===e.variable?b({value:a,locales:n,options:o[e.key]}):"currency"===e.variable?w(t(t({value:a,locales:n},o[e.key]&&{options:o[e.key]}),(null===(i=o[e.key])||void 0===i?void 0:i.currency)&&{currency:o[e.key].currency})):"datetime"===e.variable?N(t({value:a,locales:n},o[e.key]&&{options:o[e.key]})):"list"===e.variable?S(t({value:a,locales:n},o[e.key]&&{options:o[e.key]})):a:a}})).join("")}(e,n,r,o)}function Z(t,e){return function(t,e){if("string"==typeof t&&(t=[t]),!e)return t[0];for(var n=function(t){for(var n=p(t),r=[],o=0,i=e;o<i.length;o++){var a=i[o],c=p(a);if(n===c)return{value:c};l(n,c)&&r.push(c)}if(r.length)return{value:r.find((function(t){return d(n,t)}))||r[0]}},r=0,o=t;r<o.length;r++){var i=n(o[r]);if("object"==typeof i)return i.value}}(t,e)}function Y(t,e,n){return function(t,e,n){return!(!v(t)||!v(e)||n&&n.some((function(t){return!v(t)}))||d(t,e)||n&&!n.some((function(t){return l(e,t)})))}(t,e,n)}export{A as default,Z as determineLocale,W as formatCurrency,F as formatDateTime,z as formatList,U as formatNum,H as formatRelativeTime,D as getLocaleDirection,j as getLocaleEmoji,K as getLocaleName,P as getLocaleProperties,k as isSameDialect,B as isSameLanguage,x as isValidLocale,V as renderContentToString,Y as requiresTranslation,J as splitStringToContent,O as standardizeLocale};
2
2
  //# sourceMappingURL=index.esm.min.mjs.map