package config

import (
	"cursor-api-proxy/internal/env"
)

type BridgeConfig struct {
	AgentBin          string
	Host              string
	Port              int
	RequiredKey       string
	DefaultModel      string
	Mode              string
	Force             bool
	ApproveMcps       bool
	StrictModel       bool
	Workspace         string
	TimeoutMs         int
	TLSCertPath       string
	TLSKeyPath        string
	SessionsLogPath   string
	ChatOnlyWorkspace bool
	Verbose           bool
	MaxMode           bool
	ConfigDirs        []string
	MultiPort         bool
	WinCmdlineMax     int
}

func LoadBridgeConfig(e env.EnvSource, cwd string) BridgeConfig {
	loaded := env.LoadEnvConfig(e, cwd)
	return BridgeConfig{
		AgentBin:          loaded.AgentBin,
		Host:              loaded.Host,
		Port:              loaded.Port,
		RequiredKey:       loaded.RequiredKey,
		DefaultModel:      loaded.DefaultModel,
		Mode:              "ask",
		Force:             loaded.Force,
		ApproveMcps:       loaded.ApproveMcps,
		StrictModel:       loaded.StrictModel,
		Workspace:         loaded.Workspace,
		TimeoutMs:         loaded.TimeoutMs,
		TLSCertPath:       loaded.TLSCertPath,
		TLSKeyPath:        loaded.TLSKeyPath,
		SessionsLogPath:   loaded.SessionsLogPath,
		ChatOnlyWorkspace: loaded.ChatOnlyWorkspace,
		Verbose:           loaded.Verbose,
		MaxMode:           loaded.MaxMode,
		ConfigDirs:        loaded.ConfigDirs,
		MultiPort:         loaded.MultiPort,
		WinCmdlineMax:     loaded.WinCmdlineMax,
	}
}
