{"version":3,"file":"js/439-555184c6f24a8944f392.js","mappings":"yypTAQA,MAAMA,EAAO,IAAIC,EAAAA,GAEjBD,EAAKE,MAAMC,GACXH,EAAKI,cAAgB,KACrBJ,EAAKK,gBAAiB,EAEtBL,EAAKM,mBAAmBC,SAAS,UAAU,CAACC,EAAMC,KAChD,IAAIC,EAAQD,EACRE,OAAOC,SAAWA,QAAQC,SAC5BD,QAAQC,QACL,2BAA0BH,WAAeF,EAAKM,kBAI/CJ,aAAiBK,QACnBL,EAAQA,EAAMM,KAAKR,EAAKS,mBAK1B,IAAIC,EAAUR,EAAMS,MAAMX,EAAKS,kBAAkBG,OAAO,GAAG,GAY3D,OAXAF,EAAUA,EACPG,QAAQ,IAAK,KACbA,QACC,mBACA,CAACC,EAAgBC,EAAYC,IAAgB,GAAED,KAAMC,EAAGC,kBAGxDC,UAAUC,YACZT,EAAW,6BAA4BA,KAGlCA,CAAO,IAGhBlB,EAAK4B,gBAAkB,SAEhB,MAAMC,EAAwBC,IACnC,MAAMhB,EAASgB,GAAenB,OAAOoB,MAAMC,MAAMC,cAAcnB,QAAU,KAEzE,GAAId,EAAKc,SAAWA,EAApB,CAEA,OAAQA,GACN,IAAK,QACHd,EAAKE,MAAMgC,GACX,MACF,IAAK,QACHlC,EAAKE,MAAMiC,GACX,MACF,IAAK,QACHnC,EAAKE,MAAMkC,GAMfpC,EAAKc,OAASA,CAhBoB,CAgBd,EAGtBe,IAEAQ,SAASC,iBAAiB,4BAA4B,IACpDT,MAGF,O","sources":["webpack://hnry-rails/./app/javascript/utilities/translations.ts"],"sourcesContent":["import { I18n as I18nJS } from \"i18n-js\";\nimport { hnryLocales } from \"../types/jurisdictions.type\";\n\nimport en from \"../locales/en.json\";\nimport enAU from \"../locales/en-AU.json\";\nimport enGB from \"../locales/en-GB.json\";\nimport enNZ from \"../locales/en-NZ.json\";\n\nconst I18n = new I18nJS();\n\nI18n.store(en);\nI18n.defaultLocale = \"en\";\nI18n.enableFallback = true;\n\nI18n.missingTranslation.register(\"notify\", (i18n, thescope) => {\n let scope = thescope;\n if (window.Rollbar && Rollbar.warning) {\n Rollbar.warning(\n `Missing translation for ${scope} using ${i18n.locale} locale.`,\n );\n }\n\n if (scope instanceof Array) {\n scope = scope.join(i18n.defaultSeparator);\n }\n\n // Get only the last portion of the scope.\n // Replace underscore with space and camelcase with space and lowercase letter.\n let message = scope.split(i18n.defaultSeparator).slice(-1)[0];\n message = message\n .replace(\"_\", \" \")\n .replace(\n /([a-z])([A-Z])/g,\n (_match: string, p1: string, p2: string) => `${p1} ${p2.toLowerCase()}`,\n );\n\n if (navigator.webdriver) {\n message = `[[[MISSING TRANSLATION]]] ${message}`;\n }\n\n return message;\n});\n\nI18n.missingBehavior = \"notify\";\n\nexport const storeRequiredLocales = (forceLocale?: hnryLocales) => {\n const locale = forceLocale || window.Hnry?.User?.jurisdiction?.locale || \"en\";\n\n if (I18n.locale === locale) return;\n\n switch (locale) {\n case \"en-AU\":\n I18n.store(enAU);\n break;\n case \"en-GB\":\n I18n.store(enGB);\n break;\n case \"en-NZ\":\n I18n.store(enNZ);\n break;\n default:\n break;\n }\n\n I18n.locale = locale;\n};\n\nstoreRequiredLocales();\n\ndocument.addEventListener(\"turbolinks:before-render\", () =>\n storeRequiredLocales(),\n);\n\nexport default I18n;\n"],"names":["I18n","I18nJS","store","en","defaultLocale","enableFallback","missingTranslation","register","i18n","thescope","scope","window","Rollbar","warning","locale","Array","join","defaultSeparator","message","split","slice","replace","_match","p1","p2","toLowerCase","navigator","webdriver","missingBehavior","storeRequiredLocales","forceLocale","Hnry","User","jurisdiction","enAU","enGB","enNZ","document","addEventListener"],"sourceRoot":""}