import { z } from "zod";

import { siteSettingsSchema } from "../../entities/models/site-settings";
import type { ISiteSettingsRepository } from "../repositories/site-settings.repository.interface";

// ── Input ────────────────────────────────────────────────────────────────
export const getSiteSettingsInputSchema = z.object({}).strict();
export type GetSiteSettingsInput = z.infer<typeof getSiteSettingsInputSchema>;

// ── Output ───────────────────────────────────────────────────────────────
export const getSiteSettingsOutputSchema = siteSettingsSchema;
export type GetSiteSettingsOutput = z.infer<typeof getSiteSettingsOutputSchema>;

// ── Use case ─────────────────────────────────────────────────────────────
export type IGetSiteSettingsUseCase = ReturnType<typeof getSiteSettingsUseCase>;

export const getSiteSettingsUseCase =
  (siteSettingsRepository: ISiteSettingsRepository) =>
  async (_input: GetSiteSettingsInput): Promise<GetSiteSettingsOutput> => {
    const result = await siteSettingsRepository.getSiteSettings();
    return getSiteSettingsOutputSchema.parse(result);
  };
