package collector

import (
	"context"

	"git.mchus.pro/mchus/logpile/internal/models"
)

type Request struct {
	Host             string
	Protocol         string
	Port             int
	Username         string
	AuthType         string
	Password         string
	Token            string
	TLSMode          string
	DebugPayloads bool
	SkipHungCh    <-chan struct{}
}

type Progress struct {
	Status        string
	Progress      int
	Message       string
	CurrentPhase  string
	ETASeconds    int
	ActiveModules []ModuleActivation
	ModuleScores  []ModuleScore
	DebugInfo     *CollectDebugInfo
}

type ProgressFn func(Progress)

type ModuleActivation struct {
	Name  string
	Score int
}

type ModuleScore struct {
	Name     string
	Score    int
	Active   bool
	Priority int
}

type CollectDebugInfo struct {
	AdaptiveThrottled bool
	SnapshotWorkers   int
	PrefetchWorkers   int
	PrefetchEnabled   *bool
	PhaseTelemetry    []PhaseTelemetry
}

type PhaseTelemetry struct {
	Phase     string
	Requests  int
	Errors    int
	ErrorRate float64
	AvgMS     int64
	P95MS     int64
}

type ProbeResult struct {
	Reachable             bool
	Protocol              string
	HostPowerState string
	HostPoweredOn  bool
	SystemPath     string
}

type Connector interface {
	Protocol() string
	Collect(ctx context.Context, req Request, emit ProgressFn) (*models.AnalysisResult, error)
}

type Prober interface {
	Probe(ctx context.Context, req Request) (*ProbeResult, error)
}
