package server

import (
	// "log"
	"speakeasy/utils/env"
	"time"
)

var (
	VERSION = "dev"
	BUILD_TIME = time.Now()
)

// ServerConfig is a configuration model for the backend
type ServerConfig struct {
	PG_HOST string
	PG_USER string
	PG_PASSWORD string
	RABBITMQ_HOST string
	RABBITMQ_USER string
	RABBITMQ_PASSWORD string
	OLLAMA_HOST string
	OLLAMA_MODEL_ACCURACY string
	SERVER_HOST string
	SERVER_PORT int
	CLIENT_HOST string
	CLIENT_PORT int
	VERSION string
	BUILD_TIME time.Time
}

// ModelAccuracy is a configuration option for the Ollama Model Manager
type ModelAccuracy string

const (
	FAST ModelAccuracy = "FAST" // gemma:2b
	BALANCED ModelAccuracy = "BALANCED" // phi3:mini
	ACCURATE ModelAccuracy = "ACCURATE" // llama3.1:8b
)

// CreateNewConfig returns an empty server config
func CreateNewConfig() ServerConfig {
	return ServerConfig{}
}

// LoadConfig loads config from environment variables
func (c *ServerConfig) LoadConfig() {
	c.PG_HOST = env.GetString("PG_HOST", "localhost:8888")
	c.PG_USER = env.GetString("PG_USER", "speakeasy")
	c.PG_PASSWORD = env.GetString("PG_PASSWORD", "speakeasy")
	c.RABBITMQ_HOST = env.GetString("RABBITMQ_HOST", "localhost:5672")
	c.RABBITMQ_PASSWORD = env.GetString("RABBITMQ_PASSWORD", "speakeasy")
	c.RABBITMQ_USER = env.GetString("RABBITMQ_USER", "speakeasy")
	c.OLLAMA_HOST = env.GetString("OLLAMA_HOST", "localhost:11434")
	c.OLLAMA_MODEL_ACCURACY = env.GetString("OLLAMA_MODEL_ACCURACY", "BALANCED")
	c.SERVER_HOST = env.GetString("SERVER_HOST", "localhost")
	c.SERVER_PORT = env.GetInt("SERVER_PORT", 3456)
	c.CLIENT_HOST = env.GetString("CLIENT_HOST", "localhost")
	c.CLIENT_PORT = env.GetInt("CLIENT_PORT", 3457)
	c.VERSION = VERSION
	c.BUILD_TIME = BUILD_TIME
}
