generaltranslation 6.1.1 → 6.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){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=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}"function"==typeof SuppressedError&&SuppressedError;var r="en-US",o=6e4,i=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],a=function(e){try{var t=new Intl.Locale(e),n=t.language,o=t.region,a=t.script;if(e.split("-").length!==(u=1,o&&(u+=1),a&&(u+=1),u))return!1;if(new Intl.DisplayNames([r],{type:"language"}).of(n)===n)return!1;if(o)if(new Intl.DisplayNames([r],{type:"region"}).of(o)===o)return!1;if(a)if(new Intl.DisplayNames([r],{type:"script"}).of(a)===a&&!i.includes(a))return!1;return!0}catch(e){return!1}var u},u=function(e){try{return Intl.getCanonicalLocales(e)[0]}catch(t){return e}};function c(){for(var e,t,n,r,o,i,a,c,l,s,f=[],p=0;p<arguments.length;p++)f[p]=arguments[p];try{for(var v=f.flat().map(u),d=0;d<v.length;d++)for(var m=d+1;m<v.length;m++)if(e=v[d],t=v[m],n=void 0,r=void 0,o=void 0,i=void 0,a=void 0,c=void 0,l=void 0,s=void 0,n=new Intl.Locale(e),r=n.language,o=n.region,i=n.script,a=new Intl.Locale(t),c=a.language,l=a.region,s=a.script,r!==c||o&&l&&o!==l||i&&s&&i!==s)return!1;return!0}catch(e){return console.error(e),!1}}function l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{var n=e.flat().map((function(e){return new Intl.Locale(e).language}));return n.every((function(e){return e===n[0]}))}catch(e){return console.error(e),!1}}function s(e,t,n){return!(!a(e)||!a(t)||n&&n.some((function(e){return!a(e)})))&&(!c(e,t)&&!(n&&!n.some((function(e){return l(t,e)}))))}function f(r,i,a,u){return t(this,void 0,void 0,(function(){var t,c,l,s,f,p,v,d;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,c=t.signal,(l=Math.min((null==u?void 0:u.timeout)||o,o))&&setTimeout((function(){return t.abort()}),l),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/content"),{method:"POST",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify({source:i,targetLocale:a,metadata:u}),signal:c})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(f=n.sent())?void 0:f.name))throw new Error("Translation request timed out. This has either occured due to the translation of an unusually large request or a translation failure in the API.");throw f;case 4:return s.ok?[3,6]:(p=Error.bind,d=(v="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(p.apply(Error,[void 0,d.apply(v,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}function p(r,i,a,u){return t(this,void 0,void 0,(function(){var t,c,l,s,f,p,v,d;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,c=t.signal,(l=Math.min((null==u?void 0:u.timeout)||o,o))&&setTimeout((function(){return t.abort()}),l),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/react"),{method:"POST",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify({source:i,targetLocale:a,metadata:u}),signal:c})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(f=n.sent())?void 0:f.name))throw new Error("Translation request timed out. This has either occured due to the translation of an unusually large request or a translation failure in the API.");throw f;case 4:return s.ok?[3,6]:(p=Error.bind,d=(v="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(p.apply(Error,[void 0,d.apply(v,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}function v(t){var n=t.value,o=t.locales,i=void 0===o?[r]:o,a=t.options,u=void 0===a?{}:a;return new Intl.NumberFormat(i,e({numberingSystem:"latn"},u)).format(n)}function d(t){var n=t.value,o=t.locales,i=void 0===o?[r]:o,a=t.options,u=void 0===a?{}:a;return new Intl.DateTimeFormat(i,e({calendar:"gregory",numberingSystem:"latn"},u)).format(n)}function m(t){var n=t.value,o=t.locales,i=void 0===o?[r]:o,a=t.currency,u=void 0===a?"USD":a,c=t.options,l=void 0===c?{}:c;return new Intl.NumberFormat(i,e({style:"currency",currency:u,numberingSystem:"latn"},l)).format(n)}function y(t){var n=t.value,o=t.locales,i=void 0===o?[r]:o,a=t.options,u=void 0===a?{}:a;return new Intl.ListFormat(i,e({type:"conjunction",style:"long"},u)).format(n)}var g={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function h(t){if("string"!=typeof t)throw new Error("splitStringToContent: ".concat(t," is not a string!"));for(var n,r=[],o=/{([^}]+)}/g,i=0;null!==(n=o.exec(t));){var a=n[0],u=n[1],c=n.index;if("^"!==t[c-1]){c>i&&r.push(t.slice(i,c));var l=u.split(",").map((function(e){return e.trim()})),s=l[0],f=l[1]?g[l[1]]:void 0,p=e({key:s},f&&{variable:f});r.push(p),i=c+a.length}else c-1>i&&r.push(t.slice(i,c-1)),r.push(a),i=c+a.length}return i<t.length&&r.push(t.slice(i)),r}function N(e,t){if(void 0===t&&(t={}),!a(e))return w;if(t[e=u(e)])return t[e];var n=new Intl.Locale(e),r=n.region;if(r&&I[r])return I[r];var o=n.maximize(),i=o.region||"";return S[o.language]||I[i]||w}var b="🌍",w=b,S={ca:b,eu:b,ku:b,bo:"🌏",ug:"🌏",gd:"🏴󠁧󠁢󠁳󠁣󠁴󠁿",cy:"🏴󠁧󠁢󠁷󠁬󠁳󠁿",gv:"🇮🇲",grc:"🏺"},I={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 T=function(e){return"undefined"!=typeof process&&process.env&&process.env[e]||""},C=function(){function r(e){var t=void 0===e?{}:e,n=t.apiKey,r=void 0===n?"":n,o=t.devApiKey,i=void 0===o?"":o,a=t.sourceLocale,c=void 0===a?"":a,l=t.projectId,s=void 0===l?"":l,f=t.baseUrl,p=void 0===f?"https://api.gtx.dev":f;this.apiKey=r||T("GT_API_KEY"),this.devApiKey=i||T("GT_DEV_API_KEY"),this.projectId=s||T("GT_PROJECT_ID"),this.sourceLocale=u(c)||"",this.baseUrl=p}return r.prototype.translate=function(r,o,i){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,f(this,r,o,e({sourceLocale:this.sourceLocale},i))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateJsx=function(r,o,i){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,p(this,r,o,e({sourceLocale:this.sourceLocale},i))];case 1:return[2,t.sent()]}}))}))},r}();exports.default=C,exports.determineLocale=function(e,t){return function(e,t){if("string"==typeof e&&(e=[e]),e=e.filter(a),!(t=t.filter(a)))return e[0];for(var n=function(e){if(!a(e))return"continue";for(var n=u(e),r=[],o=0,i=t;o<i.length;o++){var s=i[o],f=u(s);if(n===f)return{value:f};l(n,f)&&r.push(f)}return r.length?{value:r.find((function(e){return c(n,e)}))||r[0]}:void 0},r=0,o=e;r<o.length;r++){var i=n(o[r]);if("object"==typeof i)return i.value}}(e,t)},exports.formatCurrency=function(e){return m(e)},exports.formatDateTime=function(e){return d(e)},exports.formatList=function(e){return y(e)},exports.formatNum=function(e){return v(e)},exports.formatRelativeTime=function(t){return o=(n=t).value,i=n.unit,a=n.locales,u=void 0===a?[r]:a,c=n.options,l=void 0===c?{}:c,new Intl.RelativeTimeFormat(u,e({style:"long",numeric:"auto"},l)).format(o,i);var n,o,i,a,u,c,l},exports.getLocaleDirection=function(e){return function(e){var t;try{var n=new Intl.Locale(e);return"rtl"===(null===(t=null==n?void 0:n.textInfo)||void 0===t?void 0:t.direction)?"rtl":"ltr"}catch(e){return"ltr"}}(e)},exports.getLocaleEmoji=function(e,t){return N(e,t)},exports.getLocaleName=function(e,t){return void 0===t&&(t=r),function(e,t){void 0===t&&(t=r);try{return new Intl.DisplayNames([t,r],{type:"language"}).of(e)||""}catch(e){return""}}(e,t)},exports.getLocaleProperties=function(e,t){return function(e,t){void 0===t&&(t=r);try{e=u(e);var n=new Intl.Locale(e),o=n.language,i=n.region,a=new Intl.Locale(e).maximize(),c=a.toString(),l=a.region||"",s=a.script||"",f=new Intl.Locale(e).minimize().toString(),p=new Intl.DisplayNames([t,e,r],{type:"language"}),v=new Intl.DisplayNames([e,t,r],{type:"language"}),d=p.of(e)||e,m=v.of(e)||e,y=p.of(c)||e,g=v.of(c)||e,h=p.of(f)||e,b=v.of(f)||e,w=p.of(o)||e,S=v.of(o)||e,I=i?"".concat(w," (").concat(i,")"):w,T=i?"".concat(S," (").concat(i,")"):S,C=new Intl.DisplayNames([t,e,r],{type:"region"}),L=new Intl.DisplayNames([e,t,r],{type:"region"}),M=C.of(l)||"",x=L.of(l)||"",A=new Intl.DisplayNames([t,e,r],{type:"script"}),E=new Intl.DisplayNames([e,t,r],{type:"script"});return{code:e,name:d,nativeName:m,maximizedCode:c,maximizedName:y,nativeMaximizedName:g,minimizedCode:f,minimizedName:h,nativeMinimizedName:b,languageCode:o,languageName:w,nativeLanguageName:S,nameWithRegionCode:I,nativeNameWithRegionCode:T,regionCode:l,regionName:M,nativeRegionName:x,scriptCode:s,scriptName:A.of(s)||"",nativeScriptName:E.of(s)||"",emoji:N(e)}}catch(t){var G=e||"",K=null==G?void 0:G.split("-");return{code:G,name:G,nativeName:G,maximizedCode:G,maximizedName:G,nativeMaximizedName:G,minimizedCode:G,minimizedName:G,nativeMinimizedName:G,languageCode:o=(null==K?void 0:K[0])||G||"",languageName:o,nativeLanguageName:o,regionCode:l=K.length>2?null==K?void 0:K[2]:(null==K?void 0:K[1])||"",regionName:l,nativeRegionName:l,scriptCode:s=(null==K?void 0:K[3])||"",scriptName:s,nativeScriptName:s,nameWithRegionCode:I=o?l?"".concat(o," (").concat(l,")"):o:"",nativeNameWithRegionCode:G,emoji:N(G)}}}(e,t)},exports.isSameDialect=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return c.apply(void 0,e)},exports.isSameLanguage=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return l.apply(void 0,e)},exports.isValidLocale=function(e){return a(e)},exports.renderContentToString=function(t,n,o,i){return function(t,n,o,i){if(void 0===n&&(n=r),void 0===o&&(o={}),void 0===i&&(i={}),"string"==typeof t&&(t=h(t)),"string"==typeof t)return t;if(!Array.isArray(t))throw new Error("renderContentToString: content ".concat(t," is invalid"));return t.map((function(t){var r;if("string"==typeof t)return t;if("object"==typeof t){var a=o[t.key];return t.variable?"number"===t.variable?v({value:a,locales:n,options:i[t.key]}):"currency"===t.variable?m(e(e({value:a,locales:n},i[t.key]&&{options:i[t.key]}),(null===(r=i[t.key])||void 0===r?void 0:r.currency)&&{currency:i[t.key].currency})):"datetime"===t.variable?d(e({value:a,locales:n},i[t.key]&&{options:i[t.key]})):"list"===t.variable?y(e({value:a,locales:n},i[t.key]&&{options:i[t.key]})):a:a}})).join("")}(t,n,o,i)},exports.requiresRegionalTranslation=function(e,t,n){return s(e,t,n)},exports.requiresTranslation=function(e,t,n){return s(e,t,n)},exports.splitStringToContent=function(e){return h(e)},exports.standardizeLocale=function(e){return u(e)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){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=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}"function"==typeof SuppressedError&&SuppressedError;var r="en-US",o=6e4,i=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],a=function(e){try{var t=new Intl.Locale(e),n=t.language,o=t.region,a=t.script;if(e.split("-").length!==(u=1,o&&(u+=1),a&&(u+=1),u))return!1;if(new Intl.DisplayNames([r],{type:"language"}).of(n)===n)return!1;if(o)if(new Intl.DisplayNames([r],{type:"region"}).of(o)===o)return!1;if(a)if(new Intl.DisplayNames([r],{type:"script"}).of(a)===a&&!i.includes(a))return!1;return!0}catch(e){return!1}var u},u=function(e){try{return Intl.getCanonicalLocales(e)[0]}catch(t){return e}};function c(){for(var e,t,n,r,o,i,a,c,l,s,f=[],p=0;p<arguments.length;p++)f[p]=arguments[p];try{for(var v=f.flat().map(u),d=0;d<v.length;d++)for(var m=d+1;m<v.length;m++)if(e=v[d],t=v[m],n=void 0,r=void 0,o=void 0,i=void 0,a=void 0,c=void 0,l=void 0,s=void 0,n=new Intl.Locale(e),r=n.language,o=n.region,i=n.script,a=new Intl.Locale(t),c=a.language,l=a.region,s=a.script,r!==c||o&&l&&o!==l||i&&s&&i!==s)return!1;return!0}catch(e){return console.error(e),!1}}function l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{var n=e.flat().map((function(e){return new Intl.Locale(e).language}));return n.every((function(e){return e===n[0]}))}catch(e){return console.error(e),!1}}function s(r,i,a,u){return t(this,void 0,void 0,(function(){var t,c,l,s,f,p,v,d;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,c=t.signal,(l=Math.min((null==u?void 0:u.timeout)||o,o))&&setTimeout((function(){return t.abort()}),l),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/content"),{method:"POST",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify({source:i,targetLocale:a,metadata:u}),signal:c})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(f=n.sent())?void 0:f.name))throw new Error("Translation request timed out. This has either occured due to the translation of an unusually large request or a translation failure in the API.");throw f;case 4:return s.ok?[3,6]:(p=Error.bind,d=(v="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(p.apply(Error,[void 0,d.apply(v,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}function f(r,i,a,u){return t(this,void 0,void 0,(function(){var t,c,l,s,f,p,v,d;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,c=t.signal,(l=Math.min((null==u?void 0:u.timeout)||o,o))&&setTimeout((function(){return t.abort()}),l),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/react"),{method:"POST",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify({source:i,targetLocale:a,metadata:u}),signal:c})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(f=n.sent())?void 0:f.name))throw new Error("Translation request timed out. This has either occured due to the translation of an unusually large request or a translation failure in the API.");throw f;case 4:return s.ok?[3,6]:(p=Error.bind,d=(v="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(p.apply(Error,[void 0,d.apply(v,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}function p(t){var n=t.value,o=t.locales,i=void 0===o?[r]:o,a=t.options,u=void 0===a?{}:a;return new Intl.NumberFormat(i,e({numberingSystem:"latn"},u)).format(n)}function v(t){var n=t.value,o=t.locales,i=void 0===o?[r]:o,a=t.options,u=void 0===a?{}:a;return new Intl.DateTimeFormat(i,e({calendar:"gregory",numberingSystem:"latn"},u)).format(n)}function d(t){var n=t.value,o=t.locales,i=void 0===o?[r]:o,a=t.currency,u=void 0===a?"USD":a,c=t.options,l=void 0===c?{}:c;return new Intl.NumberFormat(i,e({style:"currency",currency:u,numberingSystem:"latn"},l)).format(n)}function m(t){var n=t.value,o=t.locales,i=void 0===o?[r]:o,a=t.options,u=void 0===a?{}:a;return new Intl.ListFormat(i,e({type:"conjunction",style:"long"},u)).format(n)}var y={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function g(t){if("string"!=typeof t)throw new Error("splitStringToContent: ".concat(t," is not a string!"));for(var n,r=[],o=/{([^}]+)}/g,i=0;null!==(n=o.exec(t));){var a=n[0],u=n[1],c=n.index;if("^"!==t[c-1]){c>i&&r.push(t.slice(i,c));var l=u.split(",").map((function(e){return e.trim()})),s=l[0],f=l[1]?y[l[1]]:void 0,p=e({key:s},f&&{variable:f});r.push(p),i=c+a.length}else c-1>i&&r.push(t.slice(i,c-1)),r.push(a),i=c+a.length}return i<t.length&&r.push(t.slice(i)),r}function h(e,t){if(void 0===t&&(t={}),!a(e))return b;if(t[e=u(e)])return t[e];var n=new Intl.Locale(e),r=n.region;if(r&&S[r])return S[r];var o=n.maximize(),i=o.region||"";return w[o.language]||S[i]||b}var N="🌍",b=N,w={ca:N,eu:N,ku:N,bo:"🌏",ug:"🌏",gd:"🏴󠁧󠁢󠁳󠁣󠁴󠁿",cy:"🏴󠁧󠁢󠁷󠁬󠁳󠁿",gv:"🇮🇲",grc:"🏺"},S={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 I=function(e){return"undefined"!=typeof process&&process.env&&process.env[e]||""},T=function(){function r(e){var t=void 0===e?{}:e,n=t.apiKey,r=void 0===n?"":n,o=t.devApiKey,i=void 0===o?"":o,a=t.sourceLocale,c=void 0===a?"":a,l=t.projectId,s=void 0===l?"":l,f=t.baseUrl,p=void 0===f?"https://api.gtx.dev":f;this.apiKey=r||I("GT_API_KEY"),this.devApiKey=i||I("GT_DEV_API_KEY"),this.projectId=s||I("GT_PROJECT_ID"),this.sourceLocale=u(c)||"",this.baseUrl=p}return r.prototype.translate=function(r,o,i){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,s(this,r,o,e({sourceLocale:this.sourceLocale},i))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateJsx=function(r,o,i){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,f(this,r,o,e({sourceLocale:this.sourceLocale},i))];case 1:return[2,t.sent()]}}))}))},r}();exports.default=T,exports.determineLocale=function(e,t){return function(e,t){if("string"==typeof e&&(e=[e]),e=e.filter(a),!(t=t.filter(a)))return e[0];for(var n=function(e){if(!a(e))return"continue";for(var n=u(e),r=[],o=0,i=t;o<i.length;o++){var s=i[o],f=u(s);if(n===f)return{value:f};l(n,f)&&r.push(f)}return r.length?{value:r.find((function(e){return c(n,e)}))||r[0]}:void 0},r=0,o=e;r<o.length;r++){var i=n(o[r]);if("object"==typeof i)return i.value}}(e,t)},exports.formatCurrency=function(e){return d(e)},exports.formatDateTime=function(e){return v(e)},exports.formatList=function(e){return m(e)},exports.formatNum=function(e){return p(e)},exports.formatRelativeTime=function(t){return o=(n=t).value,i=n.unit,a=n.locales,u=void 0===a?[r]:a,c=n.options,l=void 0===c?{}:c,new Intl.RelativeTimeFormat(u,e({style:"long",numeric:"auto"},l)).format(o,i);var n,o,i,a,u,c,l},exports.getLocaleDirection=function(e){return function(e){var t;try{var n=new Intl.Locale(e);return"rtl"===(null===(t=null==n?void 0:n.textInfo)||void 0===t?void 0:t.direction)?"rtl":"ltr"}catch(e){return"ltr"}}(e)},exports.getLocaleEmoji=function(e,t){return h(e,t)},exports.getLocaleName=function(e,t){return void 0===t&&(t=r),function(e,t){void 0===t&&(t=r);try{return new Intl.DisplayNames([t,r],{type:"language"}).of(e)||""}catch(e){return""}}(e,t)},exports.getLocaleProperties=function(e,t){return function(e,t){void 0===t&&(t=r);try{e=u(e);var n=new Intl.Locale(e),o=n.language,i=n.region,a=new Intl.Locale(e).maximize(),c=a.toString(),l=a.region||"",s=a.script||"",f=new Intl.Locale(e).minimize().toString(),p=new Intl.DisplayNames([t,e,r],{type:"language"}),v=new Intl.DisplayNames([e,t,r],{type:"language"}),d=p.of(e)||e,m=v.of(e)||e,y=p.of(c)||e,g=v.of(c)||e,N=p.of(f)||e,b=v.of(f)||e,w=p.of(o)||e,S=v.of(o)||e,I=i?"".concat(w," (").concat(i,")"):w,T=i?"".concat(S," (").concat(i,")"):S,C=new Intl.DisplayNames([t,e,r],{type:"region"}),L=new Intl.DisplayNames([e,t,r],{type:"region"}),M=C.of(l)||"",x=L.of(l)||"",A=new Intl.DisplayNames([t,e,r],{type:"script"}),E=new Intl.DisplayNames([e,t,r],{type:"script"});return{code:e,name:d,nativeName:m,maximizedCode:c,maximizedName:y,nativeMaximizedName:g,minimizedCode:f,minimizedName:N,nativeMinimizedName:b,languageCode:o,languageName:w,nativeLanguageName:S,nameWithRegionCode:I,nativeNameWithRegionCode:T,regionCode:l,regionName:M,nativeRegionName:x,scriptCode:s,scriptName:A.of(s)||"",nativeScriptName:E.of(s)||"",emoji:h(e)}}catch(t){var G=e||"",K=null==G?void 0:G.split("-");return{code:G,name:G,nativeName:G,maximizedCode:G,maximizedName:G,nativeMaximizedName:G,minimizedCode:G,minimizedName:G,nativeMinimizedName:G,languageCode:o=(null==K?void 0:K[0])||G||"",languageName:o,nativeLanguageName:o,regionCode:l=K.length>2?null==K?void 0:K[2]:(null==K?void 0:K[1])||"",regionName:l,nativeRegionName:l,scriptCode:s=(null==K?void 0:K[3])||"",scriptName:s,nativeScriptName:s,nameWithRegionCode:I=o?l?"".concat(o," (").concat(l,")"):o:"",nativeNameWithRegionCode:G,emoji:h(G)}}}(e,t)},exports.isSameDialect=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return c.apply(void 0,e)},exports.isSameLanguage=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return l.apply(void 0,e)},exports.isValidLocale=function(e){return a(e)},exports.renderContentToString=function(t,n,o,i){return function(t,n,o,i){if(void 0===n&&(n=r),void 0===o&&(o={}),void 0===i&&(i={}),"string"==typeof t&&(t=g(t)),"string"==typeof t)return t;if(!Array.isArray(t))throw new Error("renderContentToString: content ".concat(t," is invalid"));return t.map((function(t){var r;if("string"==typeof t)return t;if("object"==typeof t){var a=o[t.key];return t.variable?"number"===t.variable?p({value:a,locales:n,options:i[t.key]}):"currency"===t.variable?d(e(e({value:a,locales:n},i[t.key]&&{options:i[t.key]}),(null===(r=i[t.key])||void 0===r?void 0:r.currency)&&{currency:i[t.key].currency})):"datetime"===t.variable?v(e({value:a,locales:n},i[t.key]&&{options:i[t.key]})):"list"===t.variable?m(e({value:a,locales:n},i[t.key]&&{options:i[t.key]})):a:a}})).join("")}(t,n,o,i)},exports.requiresRegionalTranslation=function(e,t,n){return function(e,t,n){return!(!a(e)||!a(t)||n&&n.some((function(e){return!a(e)})))&&!(n&&!n.some((function(e){return l(t,e)})))&&l(e,t)&&!c(e,t)}(e,t,n)},exports.requiresTranslation=function(e,t,n){return function(e,t,n){return!(!a(e)||!a(t)||n&&n.some((function(e){return!a(e)}))||c(e,t)||n&&!n.some((function(e){return l(t,e)})))}(e,t,n)},exports.splitStringToContent=function(e){return g(e)},exports.standardizeLocale=function(e){return u(e)};
2
2
  //# sourceMappingURL=index.cjs.min.cjs.map