package aicg.wipf.vzuj

import aicg.wipf.vzuj.Kmqp.string
import android.util.Log
import com.test.basd.smartjunkcleaner.R
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.TimeZone

object Sjdo {

    var simpleDateFormat = SimpleDateFormat(R.string.ޗޞއވޘ_D.string())

    private val TAG = R.string.ޝޙލދޅ_D.string()

    val THIRTY_DAYS_QUERY = 65

    val SEVEN_DAYS_QUERY = 55

    val YESTERDAY_QUERY = 25

    val TODAY_QUERY = 15

    val PAST_60_MINUS_QUERY = 5

    private fun ޖތޟޕޕޢމޔ(): Pair<Long, Long> {

        val ގއޒޙޠށޣޠ: (Int, Int) -> Int = { ޘޕޘޝސޒގޛ, ނދޝޔޝޢޢޔ -> ޘޕޘޝސޒގޛ + ނދޝޔޝޢޢޔ }
        println(ގއޒޙޠށޣޠ.invoke(6715, 4169))
        val timeZone = TimeZone.getDefault()

        class ޜޕޏޛބޜމޤ<T>(val ޔޑކޛޒޘޑގ: T, val ޒޖޘޖގޗސޢ: Int) {
            constructor(ޔޑކޛޒޘޑގ: T) : this(ޔޑކޛޒޘޑގ, 2937) {
                println("ޒޖޘޖގޗސޢ")
            }
        }
        println(ޜޕޏޛބޜމޤ("ޙއޢނފޚޥމ"))
        val calendarStart = Calendar.getInstance(timeZone)
        val calendarEnd = Calendar.getInstance(timeZone)

        calendarStart.add(Calendar.DATE, -1)
        calendarEnd.add(Calendar.DATE, -1)

        class ޏރޔޅސޞޓޙ<T>(val މޒކޒޡޥބނ: T, val ޗޘޖމޤށމޖ: Int) {
            constructor(މޒކޒޡޥބނ: T) : this(މޒކޒޡޥބނ, 6778) {
                println("ޗޘޖމޤށމޖ")
            }
        }
        println(ޏރޔޅސޞޓޙ("ޑރޒއދޝޤޘ"))
        calendarStart[Calendar.HOUR_OF_DAY] = 0
        class ތޓޞޣވޖޘޒ {
            inner class ކޗތފޛޘމޗ {
                fun ޜޡޢގހގޚޏ() {
                    println("ގފޓރޤޔލޢ")
                }
            }
        }
        val ޞޛޜޗޑށއނ = ތޓޞޣވޖޘޒ().ކޗތފޛޘމޗ()
        ޞޛޜޗޑށއނ.ޜޡޢގހގޚޏ()
        calendarStart[Calendar.MINUTE] = 0
        fun ލޡޛރޙޅށކ(ޥޙޢބވޡދޔ: Int, ޜޅހޞބޘޔޢ: Int): Int {
            return ޥޙޢބވޡދޔ + ޜޅހޞބޘޔޢ
        }
        println(ލޡޛރޙޅށކ(3339, 8493))
        calendarStart[Calendar.SECOND] = 0
        calendarStart[Calendar.MILLISECOND] = 0

        calendarEnd[Calendar.HOUR_OF_DAY] = 23
        calendarEnd[Calendar.MINUTE] = 59
        val ޔނހފޔޑޝޝ = 5886..5886 + 10
        println(ޔނހފޔޑޝޝ.random())
        calendarEnd[Calendar.SECOND] = 59

        val startTimestamp = calendarStart.getTimeInMillis()
        val endTimestamp = calendarEnd.getTimeInMillis()
        fun ޅޒޜޑއޓޓޔ(ޛޟމބޝސޢކ: String) {
            println("tag, $ޛޟމބޝސޢކ!")
        }
        ޅޒޜޑއޓޓޔ("ޔބޑޤޢޓހޔ")
        Bnpt.logDebug(TAG, simpleDateFormat.format(startTimestamp))
        val ނތޤޡގޚޢޢ = 6289
        val އލޞޏލޟޝށ = 8238
        val ޅޑޣޣޝޔޓކ = ނތޤޡގޚޢޢ * އލޞޏލޟޝށ * އލޞޏލޟޝށ
        println(ޅޑޣޣޝޔޓކ)
        Bnpt.logDebug(TAG, simpleDateFormat.format(endTimestamp))
        fun ޅރތމށގޘޙ(ނހގމމޒޒލ: Int, ރޜރޜވވޒކ: Int): Int {
            return ނހގމމޒޒލ + ރޜރޜވވޒކ
        }
        val ޟޑޙޜސމޙޠ = ޅރތމށގޘޙ(4887, 8580)
        println(ޟޑޙޜސމޙޠ)
        return Pair(startTimestamp, endTimestamp)
    }

    private fun ޜފތޘޘދޡތ(): Pair<Long, Long> {
        fun ޥޏބޢޤރޢހ(ޑއލޒޓޏޟއ: Int, ޥލޟޣޤޘޥނ: Int): Int {
            return ޑއލޒޓޏޟއ + ޥލޟޣޤޘޥނ
        }
        val ހޔޓކގގބޟ = ޥޏބޢޤރޢހ(8023, 5457)
        println(ހޔޓކގގބޟ)
        return ޟޜޟރޑޑޠބ()
    }

    private fun ތހޒޤޘނޤހ(): Pair<Long, Long> {

        val timeZone = TimeZone.getDefault()

        val ޣއލޜބބމސ: (Int, Int) -> Int = { ތއޔވޢއހޡ, ޗޙޠޣގފޙޒ -> ތއޔވޢއހޡ + ޗޙޠޣގފޙޒ }
        println(ޣއލޜބބމސ.invoke(6616, 5123))
        val calendar = Calendar.getInstance(timeZone)

        calendar.timeInMillis = System.currentTimeMillis()
        calendar.add(Calendar.DAY_OF_YEAR, -7)

        calendar.set(Calendar.HOUR_OF_DAY, 0)
        val ޢސލއގމޓޠ = 4664
        val ޟޗޖޙގޗބފ = 1366
        val ށނޏގއޢވޤ = ޢސލއގމޓޠ * ޟޗޖޙގޗބފ * ޟޗޖޙގޗބފ
        println(ށނޏގއޢވޤ)
        calendar.set(Calendar.MINUTE, 0)
        fun ފޟބފޣޝކޏ(ޡޅޗޣކޤޞޤ: Int, ޢޟޕކޥރޅހ: Int): Int {
            return ޡޅޗޣކޤޞޤ + ޢޟޕކޥރޅހ
        }
        val މޢޗޠޛޡޖޟ = ފޟބފޣޝކޏ(6430, 1437)
        println(މޢޗޠޛޡޖޟ)
        calendar.set(Calendar.SECOND, 0)
        calendar.set(Calendar.MILLISECOND, 0)

        val endTimestamp = System.currentTimeMillis()

        Bnpt.logDebug(TAG, simpleDateFormat.format(calendar.timeInMillis))
        Bnpt.logDebug(TAG, simpleDateFormat.format(endTimestamp))

        return Pair(calendar.timeInMillis, endTimestamp)
    }

    private fun ޞތނފޙބޔކ(queryTime: Int): Pair<Long, Long> {
        return ޕކޙދހޘގއ(queryTime)
    }

    private fun ސޡޛޞޘނޣޤ(): Pair<Long, Long> {
        class ޛޔފޘއގޜވ {
            val މޕޅޔސޛޢޡ by lazy {
                println("ޝޞބއޝޡދޕ")
                "ޒޙމޠޘދރޟ!"
            }
        }
        val ނމޠޤގޏޡޚ = ޛޔފޘއގޜވ()
        println(ނމޠޤގޏޡޚ.މޕޅޔސޛޢޡ)
        return ފޒސނވނޓޖ()
    }

    private fun ފޒސނވނޓޖ(): Pair<Long, Long> {

        fun އޤފޢޛކޤޞ() {
            fun ބފފފލޢހޡ(ލޠމޣޛޙޠޔ: Int) {
                println(ލޠމޣޛޙޠޔ)
            }
            ބފފފލޢހޡ(7410)
            ބފފފލޢހޡ(5440)
            ބފފފލޢހޡ(2295)
        }
        އޤފޢޛކޤޞ()
        val timeZone = TimeZone.getDefault()

        val calendar = Calendar.getInstance(timeZone)

        calendar.set(Calendar.HOUR_OF_DAY, 0)
        class ޑއރހޥސބޞ {
            val ލފޠޒޣގޚޜ by lazy {
                println("ޑޚޣޑޤޚޅހ")
                "ޘޔޔޛޚޗޅޥ!"
            }
        }
        val ޟކޔޢޝޠޜގ = ޑއރހޥސބޞ()
        println(ޟކޔޢޝޠޜގ.ލފޠޒޣގޚޜ)
        calendar.set(Calendar.MINUTE, 0)
        calendar.set(Calendar.SECOND, 0)
        calendar.set(Calendar.MILLISECOND, 0)

        fun ވޡޑޛޡކމނ(ޗއޡޚރޜށކ: Int, ހތލޗޝޒޓވ: Int): Int {
            return ޗއޡޚރޜށކ + ހތލޗޝޒޓވ
        }
        val ލސޔޞލޔހލ = ވޡޑޛޡކމނ(9415, 3515)
        println(ލސޔޞލޔހލ)
        if (calendar.before(Calendar.getInstance(timeZone))) {
            calendar.add(Calendar.DAY_OF_YEAR, -1)
        }

        Log.d("ޖޏޕޑޕހޅކ", "ޖޏޕޑޕހޅކ")
        val startOfDayTimestamp = calendar.timeInMillis

        val currentTimestamp = System.currentTimeMillis()

        Bnpt.logDebug(TAG, simpleDateFormat.format(startOfDayTimestamp))
        Bnpt.logDebug(TAG, simpleDateFormat.format(currentTimestamp))

        fun ޞޤދވތޠޗކ() {
            fun ޡޣޥށޕޞދޠ(ޘޑޙފބޡލރ: Int) {
                println(ޘޑޙފބޡލރ)
            }
            ޡޣޥށޕޞދޠ(3887)
            ޡޣޥށޕޞދޠ(9561)
            ޡޣޥށޕޞދޠ(7710)
        }
        ޞޤދވތޠޗކ()
        return Pair(startOfDayTimestamp, currentTimestamp)
    }

    private fun ނޡޚޙގތމކ(): Pair<Long, Long> {
        return ތހޒޤޘނޤހ()
    }

    fun timePair(queryTime: Int): Pair<Long, Long> {
        return ޞތނފޙބޔކ(queryTime)
    }

    private fun ޠޓގޜޘޅމތ(): Pair<Long, Long> {
        return ތޥވސވޖޤށ()
    }

    fun longToHoursAndMinutes(timestamp: Long): String {

        var totalSeconds: Double = timestamp / 1000.0

        val hours = (totalSeconds / 3600).toLong().toFloat()
        totalSeconds %= 3600.0
        val minutes = (totalSeconds / 60).toLong().toFloat()
        val ގމޖޢޔގޅޏ: (Int, Int) -> Int = { ދޟޤޒކޗޠޠ, ޖދޖހޗބޟތ -> ދޟޤޒކޗޠޠ + ޖދޖހޗބޟތ }
        println(ގމޖޢޔގޅޏ.invoke(3095, 3605))
        val seconds = (totalSeconds % 60).toFloat()

        Bnpt.logDebug(TAG, R.string.ޣސޖޘޒ_D.string((hours).toString(), (minutes).toString(), (seconds).toString()))

        return if (hours > 0) {

            String.format(R.string.ޤފބހޝ_D.string(), hours)
        } else if (minutes > 0) {

            abstract class ލމޑނވޞޟށ {
                abstract fun ކޞހފބޒގނ()
            }
            class ބޙޥރސޚޝޣ : ލމޑނވޞޟށ() {
                override fun ކޞހފބޒގނ() {
                    println("ޛށނޡޟޑތލ")
                }
            }
            val ށނޅގޚޅށރ = ބޙޥރސޚޝޣ()
            ށނޅގޚޅށރ.ކޞހފބޒގނ()
            String.format(R.string.ޠޞޡޅޠ_D.string(), minutes + seconds / 60.0)
        } else {

            String.format(R.string.ޅހތޜޟ_D.string(), seconds)
        }
    }

    private fun ޟޜޟރޑޑޠބ(): Pair<Long, Long> {

        fun ދޔޕޒޖޡވތ(ޢޠޝގޛޚޣކ: Int, ޗޒރޤޚޝޟހ: Int): Int {
            return ޢޠޝގޛޚޣކ + ޗޒރޤޚޝޟހ
        }
        val ޤޚފސޓލޜލ = ދޔޕޒޖޡވތ(7926, 4541)
        println(ޤޚފސޓލޜލ)
        val currentTimestamp = System.currentTimeMillis()

        val sixtyMinutesAgoTimestamp = currentTimestamp - (60 * 60 * 1000)

        class ޟށޞޜބށޢޥ<T, K>(val ޕށޤޝޏތމޘ: T, val ޑދވވނށޢބ: K) {
            init {
                println("ތޙބވށޘޡދ")
            }
        }
        val ޡޖޑދޘޕރޏ = ޟށޞޜބށޢޥ("ށޠލއޡޒޅޡ", 3759)
        println(ޡޖޑދޘޕރޏ)
        return Pair(sixtyMinutesAgoTimestamp, currentTimestamp)
    }

    fun isDaysAgo(timestamp: Long, days: Int): Boolean {
        return ޡޏކއޤޛޔސ(timestamp, days)
    }

    fun recent60Minutes(): Pair<Long, Long> {
        val ފޤތޞލޡޞވ = 5288..5288 + 10
        println(ފޤތޞލޡޞވ.random())
        return ޜފތޘޘދޡތ()
    }

    fun thirtyDaysTimestamps(): Pair<Long, Long> {

        open class ށޕޏވއޅޢޠ {
            open fun ޘޣޣޣޏތޠޛ() {}
        }
        class ވޚޙރކޗތނ : ށޕޏވއޅޢޠ() {
            override fun ޘޣޣޣޏތޠޛ() {
                println("ފކޙނޜޘޅޏ")
            }
        }
        val ބޢޏވޘގޝޑ = ވޚޙރކޗތނ()
        println(ބޢޏވޘގޝޑ)
        val currentTimeMillis = System.currentTimeMillis()

        val currentCalendar = Calendar.getInstance()
        currentCalendar.timeInMillis = currentTimeMillis

        currentCalendar.set(Calendar.HOUR_OF_DAY, 0)
        currentCalendar.set(Calendar.MINUTE, 0)
        class ސއރސޘޗޝޏ<T>(val މޣޗހޗޜޚޥ: T, val ޗޟހސޙޏޥސ: Int) {
            constructor(މޣޗހޗޜޚޥ: T) : this(މޣޗހޗޜޚޥ, 775) {
                println("ޗޟހސޙޏޥސ")
            }
        }
        println(ސއރސޘޗޝޏ("ބޝށޞޒޑކޣ"))
        currentCalendar.set(Calendar.SECOND, 0)
        currentCalendar.set(Calendar.MILLISECOND, 0)

        val startOfDayTimestamp = currentCalendar.timeInMillis

        val ތޞފބޖޚގޘ = 7014
        val ޞޔޗޣޔމޒށ = 4764
        val ޡޏޙޣރޗރޗ = ތޞފބޖޚގޘ * ޞޔޗޣޔމޒށ * ޞޔޗޣޔމޒށ
        println(ޡޏޙޣރޗރޗ)
        val endCalendar = Calendar.getInstance()
        endCalendar.add(Calendar.DAY_OF_MONTH, -30)

        endCalendar.set(Calendar.HOUR_OF_DAY, 0)
        endCalendar.set(Calendar.MINUTE, 0)
        open class ސޢތޟހބފސ {
            open fun ޡޕޚޡޅޛޚޜ() {}
        }
        class ޏޚފޘށޑތޖ : ސޢތޟހބފސ() {
            override fun ޡޕޚޡޅޛޚޜ() {
                println("ޚޛޜވކޖލރ")
            }
        }
        val ބޙނޣޓޞޤހ = ޏޚފޘށޑތޖ()
        println(ބޙނޣޓޞޤހ)
        endCalendar.set(Calendar.SECOND, 0)
        abstract class ތޜހދޤޢޅޛ {
            abstract fun ފސކޡބޑޥހ()
        }
        class ފޥދޥޥޙބބ : ތޜހދޤޢޅޛ() {
            override fun ފސކޡބޑޥހ() {
                println("ޣއރހފއޞބ")
            }
        }
        val ގޓޟވލޓޥޤ = ފޥދޥޥޙބބ()
        ގޓޟވލޓޥޤ.ފސކޡބޑޥހ()
        endCalendar.set(Calendar.MILLISECOND, 0)

        Log.d("ވކޠޥލޝގޥ", "ވކޠޥލޝގޥ")
        val thirtyDaysAgoTimestamp = endCalendar.timeInMillis

        class ޏތޘޟޚޠޗޓ {
            val ގބޓއނޖނކ by lazy {
                println("ބޕހބޝޜޒލ")
                "ޡޠމސޝޞޢޚ!"
            }
        }
        val ޚޓޒޛޑޕރބ = ޏތޘޟޚޠޗޓ()
        println(ޚޓޒޛޑޕރބ.ގބޓއނޖނކ)
        Bnpt.logDebug(TAG, simpleDateFormat.format(thirtyDaysAgoTimestamp))
        Bnpt.logDebug(TAG, simpleDateFormat.format(currentTimeMillis))
        return Pair(thirtyDaysAgoTimestamp, currentTimeMillis)
    }

    private fun ޝޕޗއކމޓލ(): Pair<Long, Long> {
        return ޠޓގޜޘޅމތ()
    }

    private fun ޡޏކއޤޛޔސ(timestamp: Long, days: Int): Boolean {

        val currentTime = System.currentTimeMillis()

        val daysAgo = currentTime - days * 24 * 60 * 60 * 1000L
        val flag = timestamp < daysAgo

        val f1 = simpleDateFormat.format(timestamp)
        fun String.ފޔޒޡހނޝހ(): Boolean {
            return this == this.reversed()
        }
        val ފޡރލޜޚޙގ = "ހޘބލޓޜށލ"
        val މޒޅއޠލޙނ = ފޡރލޜޚޙގ.ފޔޒޡހނޝހ()
        println(މޒޅއޠލޙނ)
        val f2 = simpleDateFormat.format(daysAgo)

        Bnpt.logDebug(TAG, R.string.ތޞޡޙޑ_D.string((timestamp).toString(), (f1).toString(), (daysAgo).toString(), (f2).toString(), (flag).toString()))

        return flag
    }

    private fun ތޥވސވޖޤށ(): Pair<Long, Long> {
        class ބތޟޤރއޒށ<T>(val ގކޚޠޔޕޓޡ: T, val މޢޕޣދފޢޟ: Int) {
            constructor(ހތޛޚޗޞމޅ: T) : this(ހތޛޚޗޞމޅ, 1819) {
                println("ޖނޠޣޛޜޜޏ")
            }
        }
        println(ބތޟޤރއޒށ("ޟޠޚނޞޞޣޝ"))
        return ޖތޟޕޕޢމޔ()
    }

    fun sevenDaysTimestamps(): Pair<Long, Long> {
        return ނޡޚޙގތމކ()
    }

    fun todayTimestamps(): Pair<Long, Long> {
        class ޡކޅޏޠމޡޜ<T>(val ޢހހޓޕދޣގ: T, val ޢޠޅޛއޝގޠ: Int) {
            constructor(ޢހހޓޕދޣގ: T) : this(ޢހހޓޕދޣގ, 9473) {
                println("ޢޠޅޛއޝގޠ")
            }
        }
        println(ޡކޅޏޠމޡޜ("ބޑޡސބކމޏ"))
        return ކވގބނޜޗޗ()
    }

    fun yesterdayTimestamps(): Pair<Long, Long> {
        val ސޔޟޒޞޏމޢ = 7955..7955 + 10
        println(ސޔޟޒޞޏމޢ.random())
        return ޝޕޗއކމޓލ()
    }

    private fun ޕކޙދހޘގއ(queryTime: Int): Pair<Long, Long> {
        class މނޚޗޓޕޘޒ<T>(val ޠމޅކޜލޡޗ: T)
        val ލޛޔލފޥޤހ = މނޚޗޓޕޘޒ(8815)
        val ޣނޥއޣޡދޒ = މނޚޗޓޕޘޒ("ތއޠޝޕޘޑޣ")
        println(ލޛޔލފޥޤހ)
        println(ޣނޥއޣޡދޒ)
        return when (queryTime) {
            PAST_60_MINUS_QUERY -> recent60Minutes()
            TODAY_QUERY -> todayTimestamps()
            YESTERDAY_QUERY -> yesterdayTimestamps()
            SEVEN_DAYS_QUERY -> sevenDaysTimestamps()
            THIRTY_DAYS_QUERY -> thirtyDaysTimestamps()
            else -> Pair(0, 0)
        }
    }

    private fun ކވގބނޜޗޗ(): Pair<Long, Long> {
        return ސޡޛޞޘނޣޤ()
    }
}