package usecase

import (
	"context"
	"fmt"
	"html/template"

	"source.toby3d.me/toby3d/home/internal/theme"
)

type themeUseCase struct {
	themes theme.Repository
}

func NewThemeUseCase(themes theme.Repository) theme.UseCase {
	return &themeUseCase{
		themes: themes,
	}
}

func (ucase *themeUseCase) Do(ctx context.Context) (*template.Template, error) {
	out, err := ucase.themes.Get(ctx)
	if err != nil {
		return nil, fmt.Errorf("cannot find theme: %w", err)
	}

	return out.Lookup("baseof"), nil
}
