package routing

// Templates holds factory functions for pre-configured routing rules.
// Each function accepts a tenantID and returns a ready-to-use RoutingRule
// that can be passed directly to RuleStore.Create().
var Templates = map[string]func(tenantID string) RoutingRule{
	// hr: sensitivity ≥ medium AND department=rh → ollama (on-prem), fallback openai
	"hr": func(tenantID string) RoutingRule {
		return RoutingRule{
			TenantID:    tenantID,
			Name:        "RH — données sensibles",
			Description: "Requêtes RH avec sensibilité moyenne ou supérieure routées vers le modèle on-prem",
			Priority:    10,
			IsEnabled:   true,
			Conditions: []Condition{
				{Field: "request.sensitivity", Operator: "gte", Value: "medium"},
				{Field: "user.department", Operator: "eq", Value: "rh"},
			},
			Action: Action{
				Provider:          "ollama",
				FallbackProviders: []string{"openai"},
			},
		}
	},

	// finance: sensitivity ≥ high → ollama (on-prem), fallback openai
	"finance": func(tenantID string) RoutingRule {
		return RoutingRule{
			TenantID:    tenantID,
			Name:        "Finance — données hautement sensibles",
			Description: "Requêtes Finance avec haute sensibilité routées vers le modèle on-prem",
			Priority:    20,
			IsEnabled:   true,
			Conditions: []Condition{
				{Field: "request.sensitivity", Operator: "gte", Value: "high"},
				{Field: "user.department", Operator: "eq", Value: "finance"},
			},
			Action: Action{
				Provider:          "ollama",
				FallbackProviders: []string{"openai"},
			},
		}
	},

	// engineering: department=engineering → anthropic
	"engineering": func(tenantID string) RoutingRule {
		return RoutingRule{
			TenantID:    tenantID,
			Name:        "Engineering — modèle avancé",
			Description: "Requêtes Engineering routées vers Anthropic pour les tâches de code complexes",
			Priority:    30,
			IsEnabled:   true,
			Conditions: []Condition{
				{Field: "user.department", Operator: "eq", Value: "engineering"},
			},
			Action: Action{
				Provider:          "anthropic",
				FallbackProviders: []string{"openai"},
			},
		}
	},

	// catchall: no conditions → openai (lowest priority, always matches)
	"catchall": func(tenantID string) RoutingRule {
		return RoutingRule{
			TenantID:    tenantID,
			Name:        "Catch-all — OpenAI",
			Description: "Règle par défaut : toutes les requêtes non routées vont vers OpenAI",
			Priority:    9999,
			IsEnabled:   true,
			Conditions:  []Condition{},
			Action: Action{
				Provider: "openai",
			},
		}
	},
}
