import { ContactLabel, LabelContact } from "./contacts";

export interface DailyAnalysis {
    date: string;
    new_contacts: number;
    incoming_messages: number;
    outgoing_messages: number;
    failed_messages: number;
}

export interface DailyBranchStat {
    date: string;
    total: number;
    branches: Record<string, number>;
}

export interface BranchAnalysisData {
    branches: string[];
    stats: DailyBranchStat[];
}

export interface AnalysisContact {
    id: number;
    name: string;
    first_message: string | null;
    first_message_time: string | null;
    last_message_time: string | null;
    phone_number: string;
    branch_name: string;
    branch_id: string;
    branch_bg_color: string;
    city: string | null;
    province: string | null;
    created_at: string;
    labels:ContactLabel[];
    is_available:boolean;
    is_customer: boolean;
    deal: boolean;
    template_count: number;
    template_value_count: number;
    template_sp_count: number;
    template_security_count: number;
    template_free_survey_count: number;
    template_cabang_count: number;
    template_garansi_count: number;
    incoming_messages_count: number;
    outgoing_messages_count: number;
}

export interface AnalysisFailedMessage {
    id: number;
    contact_name: string;
    contact_phone: string | null;
    message_text: string;
    type: string;
    direction: string;
    content:string;
    created_at: string;
    sent_by: string;
    branch_name: string;
    labels:ContactLabel[];
    is_available:boolean;
}

export interface AnalysisFilter {
    month: number;
    year: number;
}

export interface UserAnalysis {
    user_name: string;
    sent_messages: number;
    failed_messages: number;
}

export interface MonthlyContactAnalysis {
    id: number;
    name: string;
    phone_number: string;
    branch_name: string;
    branch_id: string;
    branch_bg_color: string;
    address: string;
    labels:ContactLabel[],
    is_customer?: boolean;
    deal?: boolean;
    first_message: string | null;
    first_message_time: string | null;
    last_message_time: string | null;
    template_count: number;
    template_value_count: number;
    template_sp_count: number;
    template_free_survey_count:number;
    template_garansi_count:number;
    template_cabang_count:number;
    template_security_count: number;
    incoming_messages_count:number;
    outgoing_messages_count:number;
}

export interface MonthlyContactAnalysisData {
    contacts: MonthlyContactAnalysis[];
    branches: string[];
}

export interface SlowResponseAnalysis {
    id: number;
    message_text: string;
    message_type: string;
    response_time: number;
    created_at: string;
    maded_by_json: any;
    message_json?: any;
    contact: {
        id: number;
        name: string;
        phone_number: string;
        branch_name: string;
        branch_id: string;
        branch_bg_color: string;
        labels: ContactLabel[];
    } | null;
}

export interface PaginatedSlowResponseAnalysis {
    current_page: number;
    data: SlowResponseAnalysis[];
    first_page_url: string;
    from: number | null;
    last_page: number;
    last_page_url: string;
    links: { url: string | null; label: string; active: boolean }[];
    next_page_url: string | null;
    path: string;
    per_page: number;
    prev_page_url: string | null;
    to: number | null;
    total: number;
}

export interface OutboundByTypeAnalysis {
    date: string;
    total: number;
    standar: number;
    marketing: number;
    template: number;
    bot: number;
}

export interface OutboundByCategoryAnalysis {
    date: string;
    total: number;
    umum: number;
    reels: number;
    sp: number;
    security: number;
    free_survey: number;
    cabang: number;
    garansi: number;
}

export interface OutboundListAnalysis {
    id: number;
    message_text: string;
    type: string | null;
    category: number | null;
    created_at: string;
    maded_by_json: any;
    contact: {
        id: number;
        name: string;
        phone_number: string;
        branch_name: string;
        branch_id: string;
        branch_bg_color: string;
        labels: ContactLabel[];
        city: string | null;
        province: string | null;
    } | null;
}

export interface PaginatedOutboundListAnalysis {
    current_page: number;
    data: OutboundListAnalysis[];
    first_page_url: string;
    from: number | null;
    last_page: number;
    last_page_url: string;
    links: { url: string | null; label: string; active: boolean }[];
    next_page_url: string | null;
    path: string;
    per_page: number;
    prev_page_url: string | null;
    to: number | null;
    total: number;
}
