package usecase

import (
	"context"

	"haixun-backend/internal/model/copy_mission/domain/entity"
)

type ResearchItemSummary struct {
	Title   string
	URL     string
	Snippet string
	Query   string
}

type SuggestedTagSummary struct {
	Tag          string
	Reason       string
	SearchIntent string
	SearchType   string
}

type SimilarAccountSummary struct {
	Username        string
	Reason          string
	Source          string
	MatchedSource   []string
	Confidence      string
	Status          string
	TopicRelevance  float64
	LastSeenAt      int64
	ProfileURL      string
	AuthorVerified  bool
	FollowerCount   int
	EngagementScore int
	LikeCount       int
	ReplyCount      int
	PostCount       int
}

type AudienceSampleSummary struct {
	Username       string
	SamplePostID   string
	SampleText     string
	ReplyLikeCount int
	Appearances    int
	FirstSeenAt    int64
	LastSeenAt     int64
	Status         string
}

type ResearchMapSummary struct {
	AudienceSummary        string
	ContentGoal            string
	Questions              []string
	Pillars                []string
	Exclusions             []string
	KnowledgeItems         []string
	SelectedKnowledgeItems []string
	ResearchItems          []ResearchItemSummary
	SuggestedTags          []SuggestedTagSummary
	SimilarAccounts        []SimilarAccountSummary
	AudienceSamples        []AudienceSampleSummary
	BenchmarkNotes         string
}

type MissionSummary struct {
	ID            string
	PersonaID     string
	Label         string
	SeedQuery     string
	Brief         string
	ResearchMap   ResearchMapSummary
	SelectedTags  []string
	LastScanJobID string
	Status        string
	CreateAt      int64
	UpdateAt      int64
}

type CreateRequest struct {
	TenantID            string
	OwnerUID            string
	PersonaID           string
	Label               string
	SeedQuery           string
	Brief               string
	InitialResearchMap  *entity.ResearchMap
	InitialSelectedTags []string
}

type MissionPatch struct {
	Label                     *string
	SeedQuery                 *string
	Brief                     *string
	AudienceSummary           *string
	ContentGoal               *string
	QuestionsSet              bool
	Questions                 []string
	PillarsSet                bool
	Pillars                   []string
	ExclusionsSet             bool
	Exclusions                []string
	KnowledgeItemsSet         bool
	KnowledgeItems            []string
	SelectedKnowledgeItemsSet bool
	SelectedKnowledgeItems    []string
	BenchmarkNotes            *string
	SelectedTagsSet           bool
	SelectedTags              []string
	ResearchMap               *entity.ResearchMap
	LastScanJobID             *string
	Status                    *entity.Status
}

type UpdateRequest struct {
	TenantID  string
	OwnerUID  string
	PersonaID string
	MissionID string
	Patch     MissionPatch
}

type ListResult struct {
	List []MissionSummary
}

type PatchSimilarAccountRequest struct {
	TenantID  string
	OwnerUID  string
	PersonaID string
	MissionID string
	Username  string
	Status    string
}

type PatchAudienceSampleRequest struct {
	TenantID  string
	OwnerUID  string
	PersonaID string
	MissionID string
	Username  string
	Status    string
}

type UseCase interface {
	List(ctx context.Context, tenantID, ownerUID, personaID string) (*ListResult, error)
	Create(ctx context.Context, req CreateRequest) (*MissionSummary, error)
	Get(ctx context.Context, tenantID, ownerUID, personaID, missionID string) (*MissionSummary, error)
	Update(ctx context.Context, req UpdateRequest) (*MissionSummary, error)
	PatchSimilarAccount(ctx context.Context, req PatchSimilarAccountRequest) (*MissionSummary, error)
	PatchAudienceSample(ctx context.Context, req PatchAudienceSampleRequest) (*MissionSummary, error)
	Delete(ctx context.Context, tenantID, ownerUID, personaID, missionID string) error
}
