package aicg.wipf.vzuj

import aicg.wipf.vzuj.Kmqp.string
import android.util.Log
import com.android.installreferrer.api.InstallReferrerClient
import com.android.installreferrer.api.InstallReferrerStateListener
import com.test.basd.smartjunkcleaner.R
import org.json.JSONObject

object Pens {

    private fun ޚނޖޗޙގޙޚ() {
        class ޓޙޤޗޙޥއޗ<T>(val ޢބޏރޘސރއ: T, val ޠޞޜޏޜޟޚއ: Int) {
            constructor(ޢބޏރޘސރއ: T) : this(ޢބޏރޘސރއ, 9180) {
                println("ޠޞޜޏޜޟޚއ")
            }
        }
        println(ޓޙޤޗޙޥއޗ("ޤށޅޖގޞމޙ"))
        ފޥޅޠޤޕޟޙ()
    }

    private fun ޝޛގޕޚޒޠކ() {
        class ޅޢގޔބދމޕ<T>(val ގޅށބޒޚށޅ: T, val ޚކޔޘޣހށޜ: Int) {
            constructor(ބދމޡޘޕޘޘ: T) : this(ބދމޡޘޕޘޘ, 3961) {
                println("ޢޞޢޠޞޙޙހ")
            }
        }
        println(ޅޢގޔބދމޕ("ޏލކޝޘއޗނ"))
        ޚނޖޗޙގޙޚ()
    }

    private fun ފޥޅޠޤޕޟޙ() {
        val ޗފޅތޖރދޘ = { ޠޏއޘނޕޚމ: String -> println(ޠޏއޘނޕޚމ) }
        ޗފޅތޖރދޘ("ޜވޠޤސޥޕޔ!")
        ކޅހރށޏޕޡ()
    }

    private fun ކޅހރށޏޕޡ() {
        fun ޖޥވއގޕޘމ(ޟޘހނޜބޞޏ: Int, ލޞޛޢގޓޣސ: Int): Int {
            return ޟޘހނޜބޞޏ + ލޞޛޢގޓޣސ
        }
        println(ޖޥވއގޕޘމ(6073, 3692))
        val referrerClient = InstallReferrerClient.newBuilder(Qqmq.context).build()
        referrerClient.startConnection(object : InstallReferrerStateListener {
            override fun onInstallReferrerSetupFinished(responseCode: Int) {
                ޕމތތޝބބގ(responseCode)
            }

            private fun ޕމތތޝބބގ(responseCode: Int) {
                ބޠޝޝމޛލޒ(responseCode)
            }

            private fun ބޠޝޝމޛލޒ(responseCode: Int) {
                ގޕޣޠޙޗހޙ(responseCode)
            }

            private fun ގޕޣޠޙޗހޙ(responseCode: Int) {
                Log.d("ޙބޖޥޖޠވޘ", "ޙބޖޥޖޠވޘ")
                ޝޡޠޣޢޔލނ(responseCode)
            }

            private fun ޝޡޠޣޢޔލނ(responseCode: Int) {
                ޜމޑޠޘޏޕޟ(responseCode)
            }

            private fun ޜމޑޠޘޏޕޟ(responseCode: Int) {
                try {
                    when (responseCode) {
                        InstallReferrerClient.InstallReferrerResponse.OK -> {
                            val response = referrerClient.installReferrer
                            class ސޕފފޚހބށ<T>(val ޒދސޢގޟމޕ: T)
                            val ޘޚޘނޝމޅބ = ސޕފފޚހބށ(4890)
                            val ޅސޖޥޤކޘޖ = ސޕފފޚހބށ("ދއޔދޛޅމއ")
                            println(ޘޚޘނޝމޅބ.ޒދސޢގޟމޕ)
                            println(ޅސޖޥޤކޘޖ.ޒދސޢގޟމޕ)
                            val installInfo = response.installReferrer
                            val obj = JSONObject()
                            obj.put(R.string.ޚޖފޕޗ_D.string(), response.installReferrer)
                            obj.put(R.string.ގޢދޞޢ_D.string(), response.referrerClickTimestampSeconds)
                            obj.put(R.string.އޅޠޑބ_D.string(), response.installBeginTimestampSeconds)
                            obj.put(R.string.ރޔކޅޒ_D.string(), installInfo.toString())
                            Opze.event(R.string.ޘއޣޑޘ_D.string(), ext = obj,isSingleEvent = true)
                        }

                        else -> {
                            class ޥޗޡޜޗޢޟނ<T, K>(val ޟޙޙޘފށޓލ: T, val ގރދޓޤކޣޅ: K) {
                                init {
                                    println("ޑދޒޑލސޔގ")
                                }
                            }
                            val ޡޓޖނބކޜށ = ޥޗޡޜޗޢޟނ("ޑހޡހޕޚޚޖ", 8873)
                            println(ޡޓޖނބކޜށ)
                            Opze.event(R.string.ދޓމވޠ_D.string(), isSingleEvent = true)
                        }
                    }
                } catch (_: Exception) {
                    Opze.event(R.string.ދޓމވޠ_D.string(), isSingleEvent = true)
                }

            }

            override fun onInstallReferrerServiceDisconnected() {
                class މޒޥޝކޜބޝ<T>(val ޑރވތކހޑޢ: T, val ސޖސށމޚޓޘ: Int) {
                    constructor(ޢޕގމމދޝފ: T) : this(ޢޕގމމދޝފ, 8309) {
                        println("ޛފދނބއޖޖ")
                    }
                }
                println(މޒޥޝކޜބޝ("ޟޏހޥޡޟރޤ"))
                ޠމވޝޅޒޤއ()
            }

            private fun ޠމވޝޅޒޤއ() {

            }
        })
    }

    private fun ޟގޔއކޚޚޞ() {
        ޝޛގޕޚޒޠކ()
    }

    fun init() {
        Log.d("ޚޑޟއޗޚޖޖ", "ޚޑޟއޗޚޖޖ")
        ޟގޔއކޚޚޞ()
    }
}