package persona

import (
	"time"
)

// PersonaSpec is the top-level container for a fully generated persona.
// It wraps all DNA, psychology, lifestyle, image matrix, and video specs
// produced by the personagen pipeline.
type PersonaSpec struct {
	// ID is the unique identifier for this persona.
	ID string `json:"id" yaml:"id"`

	// CreatedAt is when the spec was generated.
	CreatedAt time.Time `json:"created_at" yaml:"created_at"`

	// DNA contains the immutable biological characteristics.
	DNA *DNA `json:"dna" yaml:"dna"`

	// Name contains the persona's name.
	Name NameSpec `json:"name" yaml:"name"`

	// Psychology contains the HEXACO personality profile.
	Psychology Psychology `json:"psychology" yaml:"psychology"`

	// Lifestyle contains interests, fashion contexts, and vacation style.
	Lifestyle Lifestyle `json:"lifestyle" yaml:"lifestyle"`

	// ImageMatrix is the 20-position image generation spec.
	ImageMatrix []ImageSpec `json:"image_matrix" yaml:"image_matrix"`

	// Videos is the 4-motion-type video spec set.
	Videos []VideoSpec `json:"videos" yaml:"videos"`

	// AnchorImage is the PNG bytes for position 1 (the identity anchor).
	// Not persisted inline — stored separately in object storage.
	AnchorImage []byte `json:"-" yaml:"-"`

	// Attractiveness describes the visual attractiveness tier.
	Attractiveness AttractivenessTier `json:"attractiveness" yaml:"attractiveness"`

	// GenerationTier describes the content generation tier.
	GenerationTier GenerationTier `json:"generation_tier" yaml:"generation_tier"`

	// DiversityProfile contains optional diversity metadata.
	DiversityProfile *DiversityProfile `json:"diversity_profile,omitempty" yaml:"diversity_profile,omitempty"`
}

// AttractivenessTier describes the visual attractiveness level of a persona.
type AttractivenessTier string

const (
	AttractivenessTierAverage      AttractivenessTier = "average"
	AttractivenessTierAboveAverage AttractivenessTier = "above_average"
	AttractivenessTierAttractive   AttractivenessTier = "attractive"
	AttractivenessTierVery         AttractivenessTier = "very_attractive"
	AttractivenessTierStunning     AttractivenessTier = "stunning"
)

// IsValid returns true if the tier is a recognized value.
func (t AttractivenessTier) IsValid() bool {
	switch t {
	case AttractivenessTierAverage, AttractivenessTierAboveAverage,
		AttractivenessTierAttractive, AttractivenessTierVery, AttractivenessTierStunning:
		return true
	default:
		return false
	}
}

// GenerationTier controls the intended generation quality and persona profile depth.
type GenerationTier string

const (
	GenerationTierEveryday   GenerationTier = "everyday"
	GenerationTierInfluencer GenerationTier = "influencer"
	GenerationTierSupermodel GenerationTier = "supermodel"
)

// IsValid returns true if the tier is a recognized value.
func (t GenerationTier) IsValid() bool {
	switch t {
	case GenerationTierEveryday, GenerationTierInfluencer, GenerationTierSupermodel:
		return true
	default:
		return false
	}
}

// DiversityProfile contains optional diversity and representation metadata.
type DiversityProfile struct {
	// RepresentationNotes describes diversity considerations for this persona.
	RepresentationNotes string `json:"representation_notes,omitempty" yaml:"representation_notes,omitempty"`

	// CulturalBackground describes cultural heritage highlights.
	CulturalBackground string `json:"cultural_background,omitempty" yaml:"cultural_background,omitempty"`
}

// CoreIdentity contains the essential demographic identity data generated
// in Stage 1 of the specgen pipeline.
type CoreIdentity struct {
	// Name is the persona's full name.
	Name NameSpec `json:"name" yaml:"name"`

	// Age in years.
	Age int `json:"age" yaml:"age"`

	// Gender is the gender identity.
	Gender GenderIdentity `json:"gender" yaml:"gender"`

	// Ethnicity is the primary ethnic background.
	Ethnicity EthnicityCode `json:"ethnicity" yaml:"ethnicity"`

	// Nationality is the country/cultural background.
	Nationality string `json:"nationality" yaml:"nationality"`

	// Sexuality describes the persona's sexuality (for backstory context only).
	Sexuality string `json:"sexuality,omitempty" yaml:"sexuality,omitempty"`

	// Occupation is the current job or role.
	Occupation string `json:"occupation,omitempty" yaml:"occupation,omitempty"`

	// BirthCity is where the persona was born.
	BirthCity string `json:"birth_city,omitempty" yaml:"birth_city,omitempty"`

	// CurrentCity is where the persona currently lives.
	CurrentCity string `json:"current_city,omitempty" yaml:"current_city,omitempty"`
}
