const trimMessage = (message) => message?.trim();
const createDefaultDescriptor = (t, overrides = {}) => ({
  title: t("AssistantTimeline_Error_Title_Default"),
  subtitle: t("AssistantTimeline_Error_Subtitle_Default"),
  isRetriable: true,
  hiddenMessage: "<HIDDEN>Request failed. Please try again later.</HIDDEN>",
  shouldOpenPaywall: false,
  ...overrides
});
const getAssistantErrorDescriptor = ({
  applicationErrorCode,
  message,
  t
}) => {
  const trimmedMessage = trimMessage(message);
  switch (applicationErrorCode) {
    case "ALREADY_EXECUTED":
      return createDefaultDescriptor(t, {
        title: t("AssistantTimeline_Error_Title_AlreadyExecuted"),
        subtitle: t("AssistantTimeline_Error_Subtitle_AlreadyExecuted"),
        hiddenMessage: "<HIDDEN>Request cancelled by user</HIDDEN>"
      });
    case "USER_CANCELLED":
      return createDefaultDescriptor(t, {
        hiddenMessage: "<HIDDEN>Request cancelled by user</HIDDEN>"
      });
    case "AI_BUDGET_EXCEEDED":
      return createDefaultDescriptor(t, {
        title: t("AssistantTimeline_Error_Title_BudgetExceeded"),
        subtitle: t("AssistantTimeline_Error_Subtitle_BudgetExceeded"),
        hiddenMessage: "<HIDDEN>User is out of credit, he can upgrade his plan to continue using AI editing.</HIDDEN>",
        shouldOpenPaywall: true
      });
    case "UNSUPPORTED_MIME_TYPE":
      return createDefaultDescriptor(t, {
        title: t("AssistantTimeline_Error_Title_UnsupportedFileType"),
        subtitle: t("AssistantTimeline_Error_Subtitle_UnsupportedFileType"),
        isRetriable: false,
        hiddenMessage: trimmedMessage ? `<HIDDEN>File type is not supported. ${trimmedMessage}</HIDDEN>` : "<HIDDEN>File type is not supported.</HIDDEN>"
      });
    case "AI_GENERATED_ERROR":
      return createDefaultDescriptor(t, {
        subtitle: trimmedMessage || t("AssistantTimeline_Error_Subtitle_Default"),
        hiddenMessage: trimmedMessage ? `<HIDDEN>Request failed with error: ${trimmedMessage}</HIDDEN>` : "<HIDDEN>Request failed. Please try again later.</HIDDEN>"
      });
    default:
      return createDefaultDescriptor(t);
  }
};
export {
  getAssistantErrorDescriptor
};
//# sourceMappingURL=assistant-error-descriptor.js.map
