{"version":3,"file":"resolveDictionaryLoader.mjs","names":[],"sources":["../../src/resolvers/resolveDictionaryLoader.ts"],"sourcesContent":["import { createUnresolvedCustomLoadDictionaryError } from '../errors/loaders';\n\ntype CustomLoader = (locale: string) => Promise<unknown>;\n\nlet customLoadDictionary: CustomLoader | undefined = undefined;\n\nexport function resolveDictionaryLoader(): CustomLoader | undefined {\n  // Singleton pattern\n  if (customLoadDictionary !== undefined) return customLoadDictionary;\n\n  // Check: local dictionary loader is enabled\n  if (process.env._GENERALTRANSLATION_LOCAL_DICTIONARY_ENABLED !== 'true')\n    return;\n\n  // get load dictionary file\n  let customLoadDictionaryConfig;\n  try {\n    customLoadDictionaryConfig = require('gt-next/internal/_load-dictionary');\n  } catch {\n    // No custom dictionary loader module was generated.\n  }\n\n  // Get custom loader\n  customLoadDictionary =\n    customLoadDictionaryConfig?.default ||\n    customLoadDictionaryConfig?.loadDictionary;\n\n  // Check: custom loader is exported\n  if (!customLoadDictionary) {\n    // So the custom loader doesnt eval to falsey\n    customLoadDictionary = async (_: string) => undefined;\n    const unresolvedCustomLoadDictionaryError =\n      createUnresolvedCustomLoadDictionaryError();\n\n    // Throw error in dev\n    if (process.env.NODE_ENV !== 'production') {\n      throw new Error(unresolvedCustomLoadDictionaryError);\n    }\n\n    // Custom loader file was defined but not exported\n    console.error(unresolvedCustomLoadDictionaryError);\n  }\n\n  return customLoadDictionary;\n}\n"],"mappings":";;AAIA,IAAI,uBAAiD,KAAA;AAErD,SAAgB,0BAAoD;AAElE,KAAI,yBAAyB,KAAA,EAAW,QAAO;AAG/C,KAAI,QAAQ,IAAI,iDAAiD,OAC/D;CAGF,IAAI;AACJ,KAAI;AACF,+BAA6B,QAAQ,oCAAoC;SACnE;AAKR,wBACE,4BAA4B,WAC5B,4BAA4B;AAG9B,KAAI,CAAC,sBAAsB;AAEzB,yBAAuB,OAAO,MAAc,KAAA;EAC5C,MAAM,sCACJ,2CAA2C;AAG7C,MAAI,QAAQ,IAAI,aAAa,aAC3B,OAAM,IAAI,MAAM,oCAAoC;AAItD,UAAQ,MAAM,oCAAoC;;AAGpD,QAAO"}