package persona

// Psychology contains the complete psychological profile.
type Psychology struct {
	// HEXACO personality model
	HEXACO HEXACOProfile `json:"hexaco" yaml:"hexaco"`

	// Attachment style and patterns
	Attachment AttachmentStyle `json:"attachment" yaml:"attachment"`

	// Values core beliefs and principles
	Values Values `json:"values" yaml:"values"`
}

// HEXACOProfile represents the six-factor personality model.
// Each dimension is scored 1-10 with facets and behavioral implications.
type HEXACOProfile struct {
	// HonestyHumility: sincerity, fairness, greed-avoidance, modesty
	HonestyHumility TraitScore `json:"honesty_humility" yaml:"honesty_humility"`

	// Emotionality: fearfulness, anxiety, dependence, sentimentality
	Emotionality TraitScore `json:"emotionality" yaml:"emotionality"`

	// Extraversion: social self-esteem, boldness, sociability, liveliness
	Extraversion TraitScore `json:"extraversion" yaml:"extraversion"`

	// Agreeableness: forgivingness, gentleness, flexibility, patience
	Agreeableness TraitScore `json:"agreeableness" yaml:"agreeableness"`

	// Conscientiousness: organization, diligence, perfectionism, prudence
	Conscientiousness TraitScore `json:"conscientiousness" yaml:"conscientiousness"`

	// Openness: aesthetic appreciation, inquisitiveness, creativity, unconventionality
	Openness TraitScore `json:"openness" yaml:"openness"`
}

// TraitScore represents a single HEXACO dimension.
type TraitScore struct {
	// Score from 1 (very low) to 10 (very high)
	Score int `json:"score" yaml:"score"`

	// Facets map facet names to levels (high/mid/low)
	Facets map[string]string `json:"facets,omitempty" yaml:"facets,omitempty"`

	// BehavioralImplications describes how this shows in behavior
	BehavioralImplications string `json:"behavioral_implications,omitempty" yaml:"behavioral_implications,omitempty"`
}

// Level returns a descriptive level for the score.
func (t TraitScore) Level() string {
	switch {
	case t.Score <= 3:
		return "low"
	case t.Score <= 7:
		return "moderate"
	default:
		return "high"
	}
}

// AttachmentStyle represents relationship attachment patterns.
type AttachmentStyle struct {
	// Primary attachment style (secure, anxious, avoidant, disorganized)
	Primary string `json:"primary" yaml:"primary"`

	// Pattern detailed description of the pattern
	Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"`

	// Triggers what activates attachment behaviors
	Triggers []string `json:"triggers,omitempty" yaml:"triggers,omitempty"`

	// GrowthEdge area of potential development
	GrowthEdge string `json:"growth_edge,omitempty" yaml:"growth_edge,omitempty"`
}

// Values contains core beliefs and principles.
type Values struct {
	// Core top 5 values
	Core []string `json:"core,omitempty" yaml:"core,omitempty"`

	// LifePhilosophy guiding principle
	LifePhilosophy string `json:"life_philosophy,omitempty" yaml:"life_philosophy,omitempty"`

	// Spirituality relationship with spirituality/religion
	Spirituality string `json:"spirituality,omitempty" yaml:"spirituality,omitempty"`

	// Political general political stance (if any)
	Political string `json:"political,omitempty" yaml:"political,omitempty"`
}

// ValidAttachmentStyles are the valid primary attachment styles.
var ValidAttachmentStyles = []string{"secure", "anxious", "avoidant", "disorganized"}

// IsValidAttachmentStyle returns true if the style is valid.
func IsValidAttachmentStyle(style string) bool {
	for _, v := range ValidAttachmentStyles {
		if v == style {
			return true
		}
	}
	return false
}

// HEXACOFacets defines the facets for each HEXACO dimension.
var HEXACOFacets = map[string][]string{
	"honesty_humility":  {"sincerity", "fairness", "greed_avoidance", "modesty"},
	"emotionality":      {"fearfulness", "anxiety", "dependence", "sentimentality"},
	"extraversion":      {"social_self_esteem", "boldness", "sociability", "liveliness"},
	"agreeableness":     {"forgivingness", "gentleness", "flexibility", "patience"},
	"conscientiousness": {"organization", "diligence", "perfectionism", "prudence"},
	"openness":          {"aesthetic_appreciation", "inquisitiveness", "creativity", "unconventionality"},
}
