import type {
  AiChatServiceContext,
  AiSseEmitter,
} from './ai-chat.types';
import type { AuthenticatedUser } from '../authorization';

export async function resolveFormConversationId(
  context: AiChatServiceContext,
  userId: number,
  formId: string,
): Promise<number> {
  const form = await context.formService.findOwnedPending(formId, userId);
  return form.conversationId;
}

export async function resolveReviewConversationId(
  context: AiChatServiceContext,
  userId: number,
  reviewId: string,
): Promise<number> {
  const review = await context.reviewService.findOwnedPending(reviewId, userId);
  return review.conversationId;
}

export {
  assertReviewImportPermissions,
  confirmReviewGroup,
  confirmReviewStep,
} from './ai-chat.review-confirm';
export { submitForm, submitReview } from './ai-chat.submissions.flow';
export {
  a2uiReviewSubmitInfo,
  a2uiSubmitInfo,
  buildFormSubmitModelContent,
  buildReviewSubmitModelContent,
  markFormSubmittedOnMessage,
  markReviewSubmittedOnMessage,
} from './ai-chat.submit-content';
export { persistExchange, runGenerationAndRelease } from './ai-chat.submissions.runtime';
