package response

import "time"

// ApprovalWorkflowsResponse - Basic workflow response
type ApprovalWorkflowsResponse struct {
	ID          uint          `json:"id"`
	Name        string        `json:"name"`
	Description *string       `json:"description"`
	IsActive    bool          `json:"isActive"`
	CreatedBy   uint          `json:"createdBy"`
	CreatedAt   time.Time     `json:"createdAt"`
	UpdatedAt   time.Time     `json:"updatedAt"`
	Steps       []interface{} `json:"steps"`
}

// ApprovalWorkflowsWithStepsResponse - Workflow response with steps
type ApprovalWorkflowsWithStepsResponse struct {
	ID          uint          `json:"id"`
	Name        string        `json:"name"`
	Description *string       `json:"description"`
	IsActive    bool          `json:"isActive"`
	CreatedBy   uint          `json:"createdBy"`
	CreatedAt   time.Time     `json:"createdAt"`
	UpdatedAt   time.Time     `json:"updatedAt"`
	Steps       []interface{} `json:"steps"`
}

// ApprovalWorkflowsSummaryResponse - Summary workflow response
type ApprovalWorkflowsSummaryResponse struct {
	ID          uint    `json:"id"`
	Name        string  `json:"name"`
	Description *string `json:"description"`
	IsActive    bool    `json:"isActive"`
	StepCount   int     `json:"stepCount"`
}

// ComprehensiveWorkflowDetailResponse - Comprehensive response for workflow details
type ComprehensiveWorkflowDetailResponse struct {
	Workflow       WorkflowDetailInfo           `json:"workflow"`
	Steps          []WorkflowStepDetailInfo     `json:"steps"`
	ClientSettings ClientApprovalSettingsDetail `json:"clientSettings"`
	RelatedData    RelatedDataInfo              `json:"relatedData"`
	Statistics     WorkflowStatisticsInfo       `json:"statistics"`
	LastUpdated    time.Time                    `json:"lastUpdated"`
}

// WorkflowDetailInfo - Detailed workflow information
type WorkflowDetailInfo struct {
	ID               uint      `json:"id"`
	Name             string    `json:"name"`
	Description      *string   `json:"description"`
	IsDefault        *bool     `json:"isDefault"`
	IsActive         *bool     `json:"isActive"`
	RequiresApproval *bool     `json:"requiresApproval"`
	AutoPublish      *bool     `json:"autoPublish"`
	ClientId         *string   `json:"clientId"`
	CreatedAt        time.Time `json:"createdAt"`
	UpdatedAt        time.Time `json:"updatedAt"`

	// Additional workflow info
	TotalSteps   int  `json:"totalSteps"`
	ActiveSteps  int  `json:"activeSteps"`
	HasBranches  bool `json:"hasBranches"`
	MaxStepOrder int  `json:"maxStepOrder"`
}

// WorkflowStepDetailInfo - Detailed step information
type WorkflowStepDetailInfo struct {
	ID                    uint   `json:"id"`
	WorkflowId            uint   `json:"workflowId"`
	StepOrder             int    `json:"stepOrder"`
	StepName              string `json:"stepName"`
	RequiredUserLevelId   uint   `json:"requiredUserLevelId"`
	RequiredUserLevelName string `json:"requiredUserLevelName"`
	CanSkip               *bool  `json:"canSkip"`
	AutoApproveAfterHours *int   `json:"autoApproveAfterHours"`
	IsActive              *bool  `json:"isActive"`

	// Multi-branch support fields
	ParentStepId   *uint   `json:"parentStepId"`
	ParentStepName *string `json:"parentStepName"`
	ConditionType  *string `json:"conditionType"`
	ConditionValue *string `json:"conditionValue"`
	IsParallel     *bool   `json:"isParallel"`
	BranchName     *string `json:"branchName"`
	BranchOrder    *int    `json:"branchOrder"`

	// Additional step info
	HasChildren bool `json:"hasChildren"`
	IsFirstStep bool `json:"isFirstStep"`
	IsLastStep  bool `json:"isLastStep"`
}

// ClientApprovalSettingsDetail - Detailed client approval settings
type ClientApprovalSettingsDetail struct {
	ID                       uint      `json:"id"`
	ClientId                 string    `json:"clientId"`
	RequiresApproval         *bool     `json:"requiresApproval"`
	DefaultWorkflowId        *uint     `json:"defaultWorkflowId"`
	DefaultWorkflowName      *string   `json:"defaultWorkflowName"`
	AutoPublishArticles      *bool     `json:"autoPublishArticles"`
	ApprovalExemptUsers      []uint    `json:"approvalExemptUsers"`
	ApprovalExemptRoles      []uint    `json:"approvalExemptRoles"`
	ApprovalExemptCategories []uint    `json:"approvalExemptCategories"`
	RequireApprovalFor       []string  `json:"requireApprovalFor"`
	SkipApprovalFor          []string  `json:"skipApprovalFor"`
	IsActive                 *bool     `json:"isActive"`
	CreatedAt                time.Time `json:"createdAt"`
	UpdatedAt                time.Time `json:"updatedAt"`

	// Additional client settings info
	ExemptUsersDetails      []UserDetailInfo     `json:"exemptUsersDetails"`
	ExemptRolesDetails      []UserRoleDetailInfo `json:"exemptRolesDetails"`
	ExemptCategoriesDetails []CategoryDetailInfo `json:"exemptCategoriesDetails"`
}

// RelatedDataInfo - Related data information
type RelatedDataInfo struct {
	UserLevels []UserLevelDetailInfo `json:"userLevels"`
}

// WorkflowStatisticsInfo - Workflow statistics
type WorkflowStatisticsInfo struct {
	TotalArticlesProcessed int     `json:"totalArticlesProcessed"`
	PendingArticles        int     `json:"pendingArticles"`
	ApprovedArticles       int     `json:"approvedArticles"`
	RejectedArticles       int     `json:"rejectedArticles"`
	AverageProcessingTime  int     `json:"averageProcessingTime"` // in hours
	MostActiveStep         string  `json:"mostActiveStep"`
	LastUsedAt             *string `json:"lastUsedAt"`
}

// UserLevelDetailInfo - User level detail information
type UserLevelDetailInfo struct {
	ID               uint   `json:"id"`
	Name             string `json:"name"`
	AliasName        string `json:"aliasName"`
	LevelNumber      int    `json:"levelNumber"`
	IsApprovalActive *bool  `json:"isApprovalActive"`
	IsActive         *bool  `json:"isActive"`
}

// UserDetailInfo - User detail information
type UserDetailInfo struct {
	ID            uint   `json:"id"`
	Username      string `json:"username"`
	Fullname      string `json:"fullname"`
	Email         string `json:"email"`
	UserLevelId   uint   `json:"userLevelId"`
	UserLevelName string `json:"userLevelName"`
	IsActive      *bool  `json:"isActive"`
}

// UserRoleDetailInfo - User role detail information
type UserRoleDetailInfo struct {
	ID       uint   `json:"id"`
	RoleName string `json:"roleName"`
	IsActive *bool  `json:"isActive"`
}

// CategoryDetailInfo - Category detail information
type CategoryDetailInfo struct {
	ID           uint   `json:"id"`
	CategoryName string `json:"categoryName"`
	IsActive     *bool  `json:"isActive"`
}
