import type { Role } from './organization'
import type { UuidNameRef } from './common'

export type OnboardingField = {
    uuid: string
    key: string
    label: string
    field_type: 'text' | 'textarea' | 'select' | 'multiselect' | 'number' | 'boolean' | 'date'
    required: boolean
    help_text?: string
    placeholder?: string
    options?: string[]
    default_value?: unknown
    validation?: Record<string, unknown>
}

export type OnboardingPage = {
    uuid: string
    order: number
    title: string
    body?: string
    meta?: Record<string, unknown>
    fields: OnboardingField[]
}

export type OnboardingFlow = {
    uuid: string
    role: string | UuidNameRef
    agent?: string | null
    title: string
    description?: string
    status: 'draft' | 'published' | 'archived'
    pages?: OnboardingPage[]
}

export type OnboardingSession = {
    uuid: string
    flow: string
    agent_run?: string | null
    status: 'in_progress' | 'completed' | 'abandoned'
    current_page_order: number
    responses: Record<string, unknown>
}

export type OnboardingFeedback = {
    summary?: string
}

export type OnboardingSessionStatus = 'active' | 'completed' | 'paused'

export type OnboardingSessionSummary = {
    uuid: string
    status: string
    role?: string | UuidNameRef
}

export type OnboardingFlowSummary = {
    uuid: string
    role?: string | UuidNameRef
}

export type ProgressSessionApi = {
    uuid: string
    status: OnboardingSessionStatus
    role: UuidNameRef
    updated_at?: string
    state?: Record<string, unknown>
}

export type ProgressFlowApi = {
    uuid: string
    role: UuidNameRef
    title: string
}

export type RoleProgressItem = {
    role: Role
    latestStatus: string
    latestSessionUuid?: string
    flowTitle?: string
    feedback?: string
    loadingFeedback: boolean
}
