package types

import "time"

type EntryType string

const (
	EntryFood     EntryType = "food"
	EntryExercise EntryType = "exercise"
)

type Entry struct {
	ID          int64     `json:"id"`
	Date        string    `json:"date"`
	Time        string    `json:"time"`
	Type        EntryType `json:"type"`
	Description string    `json:"description"`
	Kcal        int       `json:"kcal"`
	CreatedAt   time.Time `json:"created_at"`
}

type DailySummary struct {
	Date          string `json:"date"`
	TotalConsumed int    `json:"total_consumed"`
	TotalBurned   int    `json:"total_burned"`
	TargetKcal    int    `json:"target_kcal"`
	NetKcal       int    `json:"net_kcal"`
}

type WeighIn struct {
	ID        int64     `json:"id"`
	Date      string    `json:"date"`
	WeightKg  float64   `json:"weight_kg"`
	CreatedAt time.Time `json:"created_at"`
}

type Product struct {
	ID             int64     `json:"id"`
	Name           string    `json:"name"`
	Brand          string    `json:"brand"`
	ServingSize    float64   `json:"serving_size"`
	ServingUnit    string    `json:"serving_unit"`
	KcalPerServing int       `json:"kcal_per_serving"`
	Source         string    `json:"source"`
	CreatedAt      time.Time `json:"created_at"`
	LastUsed       time.Time `json:"last_used"`
}

type Config struct {
	AnthropicAPIKey string  `toml:"anthropic_api_key" json:"-"`
	CurrentWeightKg float64 `toml:"current_weight_kg" json:"current_weight_kg"`
	TargetWeightKg  float64 `toml:"target_weight_kg" json:"target_weight_kg"`
	HeightCm        int     `toml:"height_cm" json:"height_cm"`
	Age             int     `toml:"age" json:"age"`
	Sex             string  `toml:"sex" json:"sex"`
	ActivityLevel   string  `toml:"activity_level" json:"activity_level"`
	WeeklyLossKg    float64 `toml:"weekly_loss_kg" json:"weekly_loss_kg"`
	ListenAddr      string  `toml:"listen_addr" json:"listen_addr"`
	HasAPIKey       bool    `toml:"-" json:"has_api_key"`
}

type TodayResponse struct {
	Date       string       `json:"date"`
	Entries    []Entry      `json:"entries"`
	Summary    DailySummary `json:"summary"`
	TargetKcal int          `json:"target_kcal"`
	Deficit    int          `json:"deficit"`
	Weight     float64      `json:"weight"`
	Config     Config       `json:"config"`
}

type AddEntryRequest struct {
	Type        EntryType `json:"type"`
	Description string    `json:"description"`
}

type AddEntryResponse struct {
	Entries []Entry `json:"entries"`
}

type WeighInRequest struct {
	WeightKg float64 `json:"weight_kg"`
}

type SettingsRequest struct {
	CurrentWeightKg *float64 `json:"current_weight_kg,omitempty"`
	TargetWeightKg  *float64 `json:"target_weight_kg,omitempty"`
	HeightCm        *int     `json:"height_cm,omitempty"`
	Age             *int     `json:"age,omitempty"`
	Sex             *string  `json:"sex,omitempty"`
	ActivityLevel   *string  `json:"activity_level,omitempty"`
	WeeklyLossKg    *float64 `json:"weekly_loss_kg,omitempty"`
	AnthropicAPIKey *string  `json:"anthropic_api_key,omitempty"`
}

type AutocompleteResult struct {
	Name           string `json:"name"`
	Brand          string `json:"brand"`
	KcalPerServing int    `json:"kcal_per_serving"`
	ServingSize    float64 `json:"serving_size"`
	ServingUnit    string `json:"serving_unit"`
}

type AIEstimation struct {
	Items []AIEstimationItem `json:"items"`
}

type AIEstimationItem struct {
	Name        string  `json:"name"`
	Brand       string  `json:"brand"`
	Kcal        int     `json:"kcal"`
	ServingSize float64 `json:"serving_size"`
	ServingUnit string  `json:"serving_unit"`
}
