import { SessionStore } from '@/state/sessionStore';

const VALID_GEN_ENDPOINTS = [
  '/api/generate/v2/',
  '/api/generate/v2-web/',
] as const;
type GenEndpoint = (typeof VALID_GEN_ENDPOINTS)[number];

export const genEndpoint = (session: SessionStore): GenEndpoint => {
  const defaultEndpoint = VALID_GEN_ENDPOINTS[0];
  const overrideEndpoint = session?.configs?.['gen-endpoint']?.endpoint;
  return VALID_GEN_ENDPOINTS.includes(overrideEndpoint as GenEndpoint)
    ? (overrideEndpoint as GenEndpoint)
    : defaultEndpoint;
};
