import type { PwaLang } from "@/lib/pwaConfig";
import {
  DEFAULT_LANGUAGE,
  isAppLanguage,
  type AppLanguage,
} from "@/lib/i18n/registry";
import { resolveLanguageFromSingleTag } from "@/lib/i18n/resolveLanguage";

export function resolvePwaLang(input?: string | null): PwaLang {
  if (isAppLanguage(input)) return input;
  return (resolveLanguageFromSingleTag(input) ?? DEFAULT_LANGUAGE) as PwaLang;
}

export function toPwaLang(lang: AppLanguage): PwaLang {
  return lang as PwaLang;
}
