{"version":3,"file":"createErrors.mjs","names":[],"sources":["../../src/errors/createErrors.ts"],"sourcesContent":["// ---- ERRORS ---- //\n\nimport {\n  createGtNextDiagnostic,\n  createGtNextPluginDiagnostic,\n} from './diagnostics';\nimport { BABEL_PLUGIN_SUPPORT, SWC_PLUGIN_SUPPORT } from '../plugin/constants';\n\nexport const remoteTranslationsError = createGtNextDiagnostic({\n  severity: 'Error',\n  whatHappened: 'Remote translations could not be loaded',\n  fix: 'Check your project ID, API key, and network connection, then try again',\n  wayOut: 'Source content will render as a fallback',\n});\n\nexport const customLoadTranslationsError = (locale: string = '') =>\n  createGtNextDiagnostic({\n    severity: 'Error',\n    whatHappened: `Locally stored translations could not be loaded${locale ? ` for \"${locale}\"` : ''}`,\n    fix: 'If you use loadTranslations(), make sure it returns translations for the requested locale',\n  });\n\nexport const customLoadDictionaryWarning = (locale: string = '') =>\n  createGtNextDiagnostic({\n    severity: 'Warning',\n    whatHappened: `The local dictionary could not be loaded${locale ? ` for \"${locale}\"` : ''}`,\n    fix: 'If you use loadDictionary(), make sure it returns a dictionary for the requested locale',\n  });\n\nexport const createUnresolvedNextVersionError = (error: Error) =>\n  createGtNextDiagnostic({\n    severity: 'Error',\n    whatHappened: 'The installed Next.js version could not be resolved',\n    fix: 'Check that next is installed in this project',\n    details: error.message,\n  });\n\nexport const createUnresolvedReactVersionError = (error: Error) =>\n  createGtNextDiagnostic({\n    severity: 'Error',\n    whatHappened: 'The installed React version could not be resolved',\n    fix: 'Check that react is installed in this project',\n    details: error.message,\n  });\n\nexport const createDictionarySubsetError = (id: string, functionName: string) =>\n  createGtNextDiagnostic({\n    severity: 'Error',\n    whatHappened: `${functionName} with id \"${id}\" could not read a valid dictionary subtree`,\n    fix: 'Make sure the id maps to the correct subroute of the dictionary',\n  });\n\nexport const unresolvedLoadDictionaryBuildError = (path: string) =>\n  createGtNextDiagnostic({\n    severity: 'Error',\n    whatHappened: `The file defining loadDictionary() could not be resolved at ${path}`,\n    fix: 'Check the configured path and try again',\n  });\n\nexport const unresolvedLoadTranslationsBuildError = (path: string) =>\n  createGtNextDiagnostic({\n    severity: 'Error',\n    whatHappened: `The file defining loadTranslations() could not be resolved at ${path}`,\n    fix: 'Check the configured path and try again',\n  });\n\nexport const conflictingConfigurationBuildError = (conflicts: string[]) =>\n  `gt-next Error: Conflicting configuration${\n    conflicts.length > 1 ? 's' : ''\n  } detected. Resolve the following conflicts before building your app:\\n${conflicts.join(\n    '\\n'\n  )}`;\n\nexport const typesFileError = createGtNextDiagnostic({\n  severity: 'Error',\n  whatHappened: 'A types-only entry point was executed at runtime',\n  fix: 'Import from the appropriate gt-next runtime entry point instead',\n});\n\nexport const getTranslationsSnapshotRscError = createGtNextDiagnostic({\n  severity: 'Error',\n  whatHappened:\n    'getTranslationsSnapshot() is not available for React Server Components',\n  fix: 'Use gt-next build-time translation helpers in the App Router, or call getTranslationsSnapshot() from a Pages Router entry point',\n});\n\nexport const withGTStaticPropsRscError = createGtNextDiagnostic({\n  severity: 'Error',\n  whatHappened:\n    'withGTStaticProps() is not available for React Server Components',\n  why: 'this helper supports the Pages Router, not the App Router',\n  fix: 'Use gt-next build-time translation helpers in the App Router, or export withGTStaticProps() from a Pages Router page module',\n});\n\nexport const invalidLocalesError = (locales: string[]) =>\n  createGtNextDiagnostic({\n    severity: 'Error',\n    whatHappened: 'Invalid locale codes in your configuration',\n    fix: 'Specify a list of valid locales or use \"customMapping\" to define aliases for the invalid locales',\n    details: locales,\n  });\n\nexport const invalidCanonicalLocalesError = (locales: string[]) =>\n  createGtNextDiagnostic({\n    severity: 'Error',\n    whatHappened: 'Invalid canonical locale codes in your configuration',\n    fix: 'Use valid BCP 47 locale codes before starting translation',\n    details: locales,\n  });\n\n// ---- WARNINGS ---- //\n\nexport const createBadFilepathWarning = (filename: string, dir: string[]) =>\n  createGtNextDiagnostic({\n    whatHappened: `${filename} was found in ${dir.join(' or ')}, which is not supported`,\n    fix: 'Move it to your project root so gt-next can load it',\n  });\n\nexport const projectIdMissingWarn = createGtNextDiagnostic({\n  whatHappened: 'Runtime translation needs a project ID',\n  fix: 'Set GT_PROJECT_ID in your environment or pass projectId to withGTConfig()',\n  docsUrl: 'https://generaltranslation.com/dashboard',\n});\n\nexport const APIKeyMissingWarn = createGtNextPluginDiagnostic({\n  whatHappened: 'Runtime translation needs an API key',\n  fix: 'Set GT_API_KEY in your environment (run `npx gt init` to create one), or set runtimeUrl to an empty string to disable runtime translation',\n});\n\nexport const standardizedCanonicalLocalesWarning = (locales: string[]) =>\n  `gt-next: The following canonical locales were standardized: ${locales.join(', ')}. Use the standardized codes in your config to avoid this warning.`;\n\nexport const createNextI18nConfigMismatchWarning = (details: string[]) =>\n  createGtNextPluginDiagnostic({\n    severity: 'Warning',\n    whatHappened:\n      'Next.js internationalized routing does not match the GT config file',\n    why: 'Next.js may select a locale that GT is not configured to translate',\n    fix: 'Use the same defaultLocale and locales values in both configurations',\n    details,\n  });\n\nexport const createGTCompilerUnresolvedWarning = (type: 'babel' | 'swc') =>\n  createGtNextPluginDiagnostic({\n    whatHappened: `The GT ${type} compiler could not be resolved`,\n    wayOut: 'Skipping compiler optimizations',\n  });\n\nexport const autoJsxInjectionCompilerWarning = createGtNextPluginDiagnostic({\n  severity: 'Warning',\n  whatHappened: 'Automatic JSX injection requires the GT webpack compiler',\n  wayOut: 'Automatic JSX injection will be skipped',\n  fix: \"Set experimentalCompilerOptions.type to 'babel' in withGTConfig() and build with webpack\",\n});\n\nexport const customGetLocaleUnresolvedWarning = createGtNextDiagnostic({\n  whatHappened: 'Custom getLocale() could not be resolved',\n  wayOut: 'gt-next will fall back to default locale detection',\n  fix: 'Export a getLocale() function from the configured request file',\n});\n\nexport const customGetRegionUnresolvedWarning = createGtNextDiagnostic({\n  whatHappened: 'Custom getRegion() could not be resolved',\n  wayOut: 'gt-next will fall back to default region detection',\n  fix: 'Export a getRegion() function from the configured request file',\n});\n\nexport const createGTCompilerUnavailableWarning = (type: 'babel' | 'swc') =>\n  type === 'swc'\n    ? `gt-next (plugin): The GT swc compiler is compatible with < next@${SWC_PLUGIN_SUPPORT}. Skipping compiler optimizations.`\n    : `gt-next (plugin): The GT babel compiler requires react@${BABEL_PLUGIN_SUPPORT} or newer. Skipping compiler optimizations.`;\n\nexport const babelCompilerTurbopackUnavailableWarning =\n  `gt-next (plugin): The GT babel compiler is not compatible with Turbopack. ` +\n  `To use compiler optimizations with Turbopack, set experimentalCompilerOptions: { type: 'swc' }.`;\n\nexport const disablingCompileTimeHashWarning = `gt-next (plugin): Compile-time hash is disabled. Compiler optimizations are inactive.`;\n\nexport const swcPluginCompatibilityChangeWarning = `gt-next (plugin): As of gt-next@6.12.4, SWC plugin support is disabled for Next.js versions prior to ${SWC_PLUGIN_SUPPORT}. Update to the latest version of Next.js.`;\n"],"mappings":";;;AAQA,MAAa,0BAA0B,uBAAuB;CAC5D,UAAU;CACV,cAAc;CACd,KAAK;CACL,QAAQ;CACT,CAAC;AAEF,MAAa,+BAA+B,SAAiB,OAC3D,uBAAuB;CACrB,UAAU;CACV,cAAc,kDAAkD,SAAS,SAAS,OAAO,KAAK;CAC9F,KAAK;CACN,CAAC;AAEJ,MAAa,+BAA+B,SAAiB,OAC3D,uBAAuB;CACrB,UAAU;CACV,cAAc,2CAA2C,SAAS,SAAS,OAAO,KAAK;CACvF,KAAK;CACN,CAAC;AAEJ,MAAa,oCAAoC,UAC/C,uBAAuB;CACrB,UAAU;CACV,cAAc;CACd,KAAK;CACL,SAAS,MAAM;CAChB,CAAC;AAEJ,MAAa,qCAAqC,UAChD,uBAAuB;CACrB,UAAU;CACV,cAAc;CACd,KAAK;CACL,SAAS,MAAM;CAChB,CAAC;AAEJ,MAAa,+BAA+B,IAAY,iBACtD,uBAAuB;CACrB,UAAU;CACV,cAAc,GAAG,aAAa,YAAY,GAAG;CAC7C,KAAK;CACN,CAAC;AAEJ,MAAa,sCAAsC,SACjD,uBAAuB;CACrB,UAAU;CACV,cAAc,+DAA+D;CAC7E,KAAK;CACN,CAAC;AAEJ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