{"version":3,"file":"useParseErrorMessage.mjs","sources":["../../../../../../../../../web/src/ui/b2b/screens/useParseErrorMessage.ts"],"sourcesContent":["import { useLingui } from '@lingui/react/macro';\nimport { StytchAPIError } from '@stytch/core/public';\n\nimport { getTranslatedError } from '../../../utils/getTranslatedError';\n\nconst JIT_PROVISIONING_ERRORS = ['email_jit_provisioning_not_allowed', 'invalid_email_for_jit_provisioning'];\n\n/**\n * Translates error message to user friendlier format including handling for JIT errors\n */\nexport const useParseErrorMessage = () => {\n  const { t } = useLingui();\n  return (error: StytchAPIError, { email, org: organizationName }: { email: string; org: string }) => {\n    if (JIT_PROVISIONING_ERRORS.includes(error.error_type)) {\n      return t({\n        id: 'error.jitIneligible',\n        message: `${email} does not have access to ${organizationName}. If you think this is a mistake, contact your admin`,\n      });\n    }\n    return getTranslatedError(error, t);\n  };\n};\n"],"names":["JIT_PROVISIONING_ERRORS","useParseErrorMessage","useLingui","error","email","org","organizationName","includes","error_type","getTranslatedError"],"mappings":";;;AAKA,MAAMA,uBAAAA,GAA0B;AAAC,IAAA,oCAAA;AAAsC,IAAA;AAAqC,CAAA;AAE5G;;UAGaC,oBAAAA,GAAuB,IAAA;AAClC,IAAA,MAAM,EAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,GAAA,EAAA,GAAQC,SAAAA,EAAAA;AACd,IAAA,OAAO,CAACC,KAAAA,EAAuB,EAAEC,KAAK,EAAEC,GAAAA,EAAKC,gBAAgB,EAAkC,GAAA;AAC7F,QAAA,IAAIN,uBAAAA,CAAwBO,QAAQ,CAACJ,KAAAA,CAAMK,UAAU,CAAA,EAAG;AACtD,YAAA,OAAA,OAAA,CAAA,CAAA,CAAA;;;;AAEcJ,oBAAAA,KAAAA,EAAAA,KAAAA;AAAiCE,oBAAAA,gBAAAA,EAAAA;;;AAEjD,QAAA;AACA,QAAA,OAAOG,kBAAAA,CAAmBN,KAAAA,EAAAA,GAAAA,CAAAA;AAC5B,IAAA,CAAA;AACF;;;;"}