package com.ym.library.utils

import android.text.TextUtils
import com.ym.commen.module.VideoEntity
import com.ym.library.module.NewsEntity
import com.ym.library.module.NovelEntity

/**
 * @author (wangXuewei)
 * @datetime 2020-12-11 15:41 GMT+8
 * @detail :
 */
object MyPhoneUtils {


    fun replaceUrl(url: String, entity: NewsEntity): String {

        var data: String = url
            .replace(
                "__SLOT_WIDTH__",
                if (TextUtils.isEmpty(entity.ad_width)) "-999" else entity.ad_width
                    ?: "-999"
            )
            .replace(
                "__SLOT_HEIGHT__",
                if (TextUtils.isEmpty(entity.ad_width)) "-999" else entity.ad_width
                    ?: "-999"
            )

            .replace(
                "__RE_DOWN_X__",
                if (TextUtils.isEmpty(entity.clickViewDownX)) "-999" else entity.clickViewDownX
                    ?: "-999"
            )
            .replace(
                "__RE_DOWN_Y__",
                if (TextUtils.isEmpty(entity.clickViewDownY)) "-999" else entity.clickViewDownY
                    ?: "-999"
            )

            .replace(
                "__RE_UP_X__",
                if (TextUtils.isEmpty(entity.clickViewUpX)) "-999" else entity.clickViewUpX
                    ?: "-999"
            )
            .replace(
                "__RE_UP_Y__",
                if (TextUtils.isEmpty(entity.clickViewUpY)) "-999" else entity.clickViewUpY
                    ?: "-999"
            )

            .replace(
                "__DOWN_X__",
                if (TextUtils.isEmpty(entity.clickDownX)) "-999" else entity.clickDownX
                    ?: "-999"
            )
            .replace(
                "__DOWN_Y__",
                if (TextUtils.isEmpty(entity.clickDownY)) "-999" else entity.clickDownY
                    ?: "-999"
            )

            .replace(
                "__UP_X__", if (TextUtils.isEmpty(entity.clickUpX)) "-999" else entity.clickUpX
                    ?: "-999"
            )
            .replace(
                "__UP_Y__", if (TextUtils.isEmpty(entity.clickUpY)) "-999" else entity.clickUpY
                    ?: "-999"
            )

            .replace(
                "__LAT__", "-999"
                    ?: "-999"
            )
            .replace(
                "__LON__", "-999"
                    ?: "-999"
            )

            .replace(
                "__SLOT_HEIGHT__",
                if (TextUtils.isEmpty(entity.ad_height)) "-999" else entity.ad_height
                    ?: "-999"
            )
            .replace("__UTC_TS__", System.currentTimeMillis().toString())
            .replace(
                "__CLICK_ID__", if (TextUtils.isEmpty(entity.clickId)) "-999" else entity.clickId
                    ?: "-999"
            )

        return data
    }

    fun replaceUrl(url: String, entity: NovelEntity): String {

        var data: String = url
            .replace(
                "__SLOT_WIDTH__",
                if (TextUtils.isEmpty(entity.ad_width)) "-999" else entity.ad_width
                    ?: "-999"
            )
            .replace(
                "__SLOT_HEIGHT__",
                if (TextUtils.isEmpty(entity.ad_width)) "-999" else entity.ad_width
                    ?: "-999"
            )

            .replace(
                "__RE_DOWN_X__",
                if (TextUtils.isEmpty(entity.clickViewDownX)) "-999" else entity.clickViewDownX
                    ?: "-999"
            )
            .replace(
                "__RE_DOWN_Y__",
                if (TextUtils.isEmpty(entity.clickViewDownY)) "-999" else entity.clickViewDownY
                    ?: "-999"
            )

            .replace(
                "__RE_UP_X__",
                if (TextUtils.isEmpty(entity.clickViewUpX)) "-999" else entity.clickViewUpX
                    ?: "-999"
            )
            .replace(
                "__RE_UP_Y__",
                if (TextUtils.isEmpty(entity.clickViewUpY)) "-999" else entity.clickViewUpY
                    ?: "-999"
            )

            .replace(
                "__DOWN_X__",
                if (TextUtils.isEmpty(entity.clickDownX)) "-999" else entity.clickDownX
                    ?: "-999"
            )
            .replace(
                "__DOWN_Y__",
                if (TextUtils.isEmpty(entity.clickDownY)) "-999" else entity.clickDownY
                    ?: "-999"
            )

            .replace(
                "__UP_X__", if (TextUtils.isEmpty(entity.clickUpX)) "-999" else entity.clickUpX
                    ?: "-999"
            )
            .replace(
                "__UP_Y__", if (TextUtils.isEmpty(entity.clickUpY)) "-999" else entity.clickUpY
                    ?: "-999"
            )

            .replace(
                "__LAT__", "-999"
                    ?: "-999"
            )
            .replace(
                "__LON__", "-999"
                    ?: "-999"
            )

            .replace(
                "__SLOT_HEIGHT__",
                if (TextUtils.isEmpty(entity.ad_height)) "-999" else entity.ad_height
                    ?: "-999"
            )
            .replace("__UTC_TS__", System.currentTimeMillis().toString())
            .replace(
                "__CLICK_ID__", if (TextUtils.isEmpty(entity.clickId)) "-999" else entity.clickId
                    ?: "-999"
            )

        return data
    }

    fun replaceUrl(url: String, entity: VideoEntity): String {

        var data: String = url
            .replace(
                "__SLOT_WIDTH__",
                if (TextUtils.isEmpty(entity.ad_width)) "-999" else entity.ad_width
                    ?: "-999"
            )
            .replace(
                "__SLOT_HEIGHT__",
                if (TextUtils.isEmpty(entity.ad_width)) "-999" else entity.ad_width
                    ?: "-999"
            )

            .replace(
                "__RE_DOWN_X__",
                if (TextUtils.isEmpty(entity.clickViewDownX)) "-999" else entity.clickViewDownX
                    ?: "-999"
            )
            .replace(
                "__RE_DOWN_Y__",
                if (TextUtils.isEmpty(entity.clickViewDownY)) "-999" else entity.clickViewDownY
                    ?: "-999"
            )

            .replace(
                "__RE_UP_X__",
                if (TextUtils.isEmpty(entity.clickViewUpX)) "-999" else entity.clickViewUpX
                    ?: "-999"
            )
            .replace(
                "__RE_UP_Y__",
                if (TextUtils.isEmpty(entity.clickViewUpY)) "-999" else entity.clickViewUpY
                    ?: "-999"
            )

            .replace(
                "__DOWN_X__",
                if (TextUtils.isEmpty(entity.clickDownX)) "-999" else entity.clickDownX
                    ?: "-999"
            )
            .replace(
                "__DOWN_Y__",
                if (TextUtils.isEmpty(entity.clickDownY)) "-999" else entity.clickDownY
                    ?: "-999"
            )

            .replace(
                "__UP_X__", if (TextUtils.isEmpty(entity.clickUpX)) "-999" else entity.clickUpX
                    ?: "-999"
            )
            .replace(
                "__UP_Y__", if (TextUtils.isEmpty(entity.clickUpY)) "-999" else entity.clickUpY
                    ?: "-999"
            )

            .replace(
                "__LAT__", "-999"
                    ?: "-999"
            )
            .replace(
                "__LON__", "-999"
                    ?: "-999"
            )

            .replace(
                "__SLOT_HEIGHT__",
                if (TextUtils.isEmpty(entity.ad_height)) "-999" else entity.ad_height
                    ?: "-999"
            )
            .replace("__UTC_TS__", System.currentTimeMillis().toString())
            .replace(
                "__CLICK_ID__", if (TextUtils.isEmpty(entity.clickId)) "-999" else entity.clickId
                    ?: "-999"
            )

        return data
    }


}