export enum WalletType {
    PAYTM_BUSINESS = 'paytm business',
    PHONEPE_BUSINESS = 'phonepe business',
    GOOGLEPAY_BUSINESS = 'googlepay business',
    BHARATPE_BUSINESS = 'bharatpe business',
    PAYTM_PERSONAL = 'paytm',
    PHONEPE_PERSONAL = 'phonepe',
    GOOGLEPAY_PERSONAL = 'googlepay',
    BHARATPE_PERSONAL = 'bharatpe',
    FREECHARGE_PERSONAL = 'freecharge',
    MOBIKWIK_PERSONAL = 'mobikwik',
}

export interface BaseBindResult {
    success: boolean;
    type: WalletType;
}

export interface PaytmBusinessBindResult extends BaseBindResult {
    type: WalletType.PAYTM_BUSINESS;
    cookie: string;
    xCsrfToken: string;
    contextData?: string;
    qrData?: Array<{
        vpa: string;
        mappingId: string;
        createTimestamp: string;
        qrType: string;
        posId: string;
        expiryDate: string | null;
        deeplink: string;
        amount: string | null;
        status: number;
        bankName: string;
        displayName: string | null;
        qrCodeId: string | null;
        secondaryPhoneNumber: string | null;
        notificationPreference: string | null;
        tagLine: string | null;
    }>;
}

export interface PhonePeBusinessBindResult extends BaseBindResult {
    type: WalletType.PHONEPE_BUSINESS;
    cookie: string;
    xCsrfToken: string;
    fingerprint: string;
    userAToken: string;
    userRToken: string;
    userInfo?: string;
    qrData?: string;
}

export interface GooglePayMerchantInfo {
    channelUid: string;
    merchantName: string;
    merchantDisplayName: string;
    phone: string;
    upiIds: Array<{
        id: string;
        accountId: string;
        type: 'Primary' | 'Pocket' | 'Stock';
    }>;
    categoryCode: string;
    categoryDescription: string;
    gstin: string;
    ownerName: string;
}

export interface GooglePayBusinessBindResult extends BaseBindResult {
    type: WalletType.GOOGLEPAY_BUSINESS;
    url: string;
    body: string;
    cookie: string;
    channelUid: string;
    openUrl: string;
    merchantInfo?: GooglePayMerchantInfo;
}

export interface BharatPeBusinessBindResult extends BaseBindResult {
    type: WalletType.BHARATPE_BUSINESS;
    cookie: string;
    accessToken: string;
    merchantId: string;
    userName: string;
    email?: string;
    mobile?: string;
    qrUrl?: string;
}

export interface ProfileDetail {
    lrnDetails?: {
        liteOnboardEligible: boolean;
    };
    mobileMapperStatus?: string;
    pspToOnboard?: string[];
    primaryVpa: string;
    mobile: number;
    accountDetails: Array<{
        bank: string;
        ifsc: string;
        accRefId: string;
        maskedAccountNumber: string;
        accountType: string;
        name: string;
        mpinSet: string;
        last4digits: string;
    }>;
}
export interface PaytmPersonalBindResult extends BaseBindResult {
    type: WalletType.PAYTM_PERSONAL;
    mobile: string;
    token: string;
    userId: string;
    profileDetail: ProfileDetail;
}

export interface PhonepePersonalBindResult extends BaseBindResult {
    type: WalletType.PHONEPE_PERSONAL;
    mobile: string;
    token: string;
    userId: string;
    profileDetail: ProfileDetail;
}

export interface MobikwikPersonalBindResult extends BaseBindResult {
    type: WalletType.MOBIKWIK_PERSONAL;
    mobile: string;
    token: string;
    hashId: string;
    deviceId: string;
    tuneUserId?: string;
    otpToken?: string;
}

export interface FreechargeVPA {
    vpa: string;
    status: 'PRIMARY' | 'SECONDARY';
}

export interface FreechargePersonalBindResult extends BaseBindResult {
    type: WalletType.FREECHARGE_PERSONAL;
    mobile: string;
    token: string;
    imsId: string;
    userId: string;
    deviceId: string;
    vpas?: FreechargeVPA[];
    csrfId?: string;
}

export type BindResult =
    | PaytmBusinessBindResult
    | PhonePeBusinessBindResult
    | GooglePayBusinessBindResult
    | BharatPeBusinessBindResult
    | PaytmPersonalBindResult
    | MobikwikPersonalBindResult
    | FreechargePersonalBindResult;

export interface SmsMessage {
    id: string;
    address: string;
    body: string;
    timestamp: number;
    type: number; // 1=收到, 2=发送
    read: boolean;
}

export interface NotificationMessage {
    id: string;
    packageName: string;
    tag: string | null;
    postTime: number;
    title: string;
    text: string;
    bigText: string;
}
