import Foundation

// MARK: - FrameCallback

/// 采集 + 自动上报回调，供 `collectFrame*` 系列方法使用
///
/// 所有回调均在**主线程**派发，可安全访问 UI。
///
/// ObjC 实现示例：
/// ```objc
/// @interface MyVC : UIViewController <FrameCallback>
/// @end
/// ```
@objc public protocol FrameCallback: AnyObject {

    /// 截图成功并落盘，已自动入队上报
    /// - Thread: main thread
    func onCollectSuccess(_ record: FrameRecord)

    /// 截图或入队失败
    /// - Thread: main thread
    func onCollectFailure(errorCode: Int, errorName: String, message: String)

    /// 上报成功（服务端返回 code=0）
    /// - Thread: main thread
    func onReportSuccess(_ record: FrameRecord)

    /// 重复上报被跳过（`show_id` 已在内存集合中）
    /// - Thread: main thread
    func onReportSkip(_ record: FrameRecord, reason: String)

    /// 上报终态失败（不可重试 或 重试已耗尽）
    /// - Thread: main thread
    func onReportFailure(errorCode: Int, errorName: String, message: String, record: FrameRecord?)
}

// MARK: - ReportCallback

/// 仅上报回调，供 `reportFrameRecord(_:adInfo:callback:)` 使用
///
/// 所有回调均在**主线程**派发。
@objc public protocol ReportCallback: AnyObject {

    /// 上报成功
    /// - Thread: main thread
    func onReportSuccess(_ record: FrameRecord)

    /// 重复上报被跳过
    /// - Thread: main thread
    func onReportSkip(_ record: FrameRecord, reason: String)

    /// 上报终态失败
    /// - Thread: main thread
    func onReportFailure(errorCode: Int, errorName: String, message: String, record: FrameRecord?)
}
