{"version":3,"file":"middleware.mjs","names":[],"sources":["../../src/errors/middleware.ts"],"sourcesContent":["import { getLocaleProperties } from '@generaltranslation/format';\nimport {\n  createGtNextDiagnostic,\n  formatDiagnosticErrorDetails,\n} from './diagnostics';\n\nexport const createUnsupportedLocalesWarning = (locales: string[]) =>\n  `gt-next: The following locales are currently unsupported by our service: ${locales\n    .map((locale) => {\n      const { name } = getLocaleProperties(locale);\n      return `${locale} (${name})`;\n    })\n    .join(', ')}`;\n\nexport const createInvalidMiddlewareEnvConfigError = (\n  envName: string,\n  error: unknown\n) =>\n  createGtNextDiagnostic({\n    severity: 'Error',\n    whatHappened: `${envName} is not valid JSON`,\n    reassurance:\n      'gt-next ignores this variable; options passed to createNextMiddleware() still apply',\n    fix: 'Configure gt-next through withGTConfig() instead of setting this variable manually',\n    details: formatDiagnosticErrorDetails(error),\n  });\n\nexport const createLinkRoutingConfigMismatchWarning = (options: string[]) =>\n  createGtNextDiagnostic({\n    severity: 'Warning',\n    whatHappened: `createNextMiddleware() and withGTConfig() set different values for ${options.join(', ')}`,\n    why: 'gt-next/link reads these options from withGTConfig(), so its links may redirect',\n    fix: 'Set these options in withGTConfig() instead of createNextMiddleware()',\n  });\n"],"mappings":";;;AAMA,MAAa,mCAAmC,YAC9C,4EAA4E,QACzE,KAAK,WAAW;CACf,MAAM,EAAE,SAAS,oBAAoB,OAAO;AAC5C,QAAO,GAAG,OAAO,IAAI,KAAK;EAC1B,CACD,KAAK,KAAK;AAEf,MAAa,yCACX,SACA,UAEA,uBAAuB;CACrB,UAAU;CACV,cAAc,GAAG,QAAQ;CACzB,aACE;CACF,KAAK;CACL,SAAS,6BAA6B,MAAM;CAC7C,CAAC;AAEJ,MAAa,0CAA0C,YACrD,uBAAuB;CACrB,UAAU;CACV,cAAc,sEAAsE,QAAQ,KAAK,KAAK;CACtG,KAAK;CACL,KAAK;CACN,CAAC"}