export interface Package {
    id: number;
    name_en: string;
    name_ar: string;
    reports: string;
    trial_price?: string;
    annual_price: string;
    semi_annual_price: string;
    monthly_price: string;
    trial_days: number;
    is_active: number;
    deleted_at: string | null;
    created_at: string;
    updated_at: string;
    name: 'standard' | 'advanced' | 'unlimited' | 'e-invoicing' | 'advanced-package' | 'unlimted-package' | 'pay-as-you-go';
    metadata: string | null;
}

export interface ActiveSubscription {
    id: number;
    website_id: number;
    company_id: number;
    email: string;
    name: string;
    is_paid: number;
    start_date: string;
    end_date: string;
    plan: 'trial' | 'monthly' | 'annual' | 'semi_annual';
    trial_days: number;
    promo_code_id: number | null;
    promo_code_discount: string | null;
    paid_amount: string;
    package_id: number;
    payment_transaction_id: string | null;
    grace_days: number;
    created_at: string;
    updated_at: string;
    auto_renew: number;
    status: 'trial' | 'active' | 'expired' | 'grace_period' | 'overdue';
    charge_count?: number;
    /** True when in LastChance phase (end_date + 90). */
    in_last_chance_phase?: boolean;
    /** Whole days until archival (end_date + 120); set during LastChance. */
    days_until_cold_archive?: number | null;
    /** Calendar date (Y-m-d) of planned archival; set during LastChance. */
    cold_archive_at?: string | null;
    saved_card_id: number | null;
    is_on_trial: boolean;
    trail_end_date: string | null;
    days_remaining: number;
    total_due?: number;
    total_due_without_vat?: number;
    pay_as_you_go_maximum_threshold?: number;
    is_pay_as_you_go?: boolean;
    effective_price?: number;
    payment_transaction?: {
        amount?: number;
        created_at?: string;
    };
    package?: Package;
    addons?: {
        addon_id: number;
        status: number;
    }[];
}

export interface ArchivedSubscription {
    id: number;
    website_id: number;
    company_id: number;
    email: string;
    name: string;
    start_date: string;
    end_date: string;
    plan: 'trial' | 'monthly' | 'annual' | 'semi_annual';
    promo_code_id: number | null;
    promo_code_discount: string | null;
    paid_amount: string;
    package_id: number;
    payment_transaction_id: string | null;
    archived_at: string;
    created_at: string;
    updated_at: string;
    package?: Package;
}

export interface BillingSummary {
    next_payment: string;
    next_payment_date: string;
    payment_method: any | null;
    last_payment: string;
}

export type AlertSeverity = 1 | 2 | 3;

export type AlertType =
    | 'payment_method_expiring'
    | 'payment_method_expired'
    | 'package_suggestion'
    | 'subscription_expiring'
    | 'usage_limit'
    | 'trial_ending'
    | 'grace_period'
    | string;

export interface Alert {
    /** Set for persisted dashboard notifications, null for computed ones. */
    id?: number | null;
    severity: AlertSeverity;
    type: AlertType;
    /** Iconify name supplied by the backend; falls back to a per-type default. */
    icon?: string;
    title: string;
    description?: string;
    action?: string;
    action_url?: string;
    /** Only persisted, non-critical alerts can be dismissed for good. */
    dismissible?: boolean;
}

export interface UsageData {
    label: string;
    usage: number;
    limit: number;
    usage_percentage: number;
    is_unlimited: boolean;
}

export interface UsageSummary {
    resets_in: string;
    usage_data: UsageData[];
}
