// using Unity.VisualScripting;
using UnityEngine;

#if UNITY_ANDROID
namespace EngineSdkConverter.Unity.SDK
{
    public class UnityPlayerUtils
    {
        private static AndroidJavaClass sdkMidLayer;
        private static string sdkMidLayerPath = "com.tuyoo.sdk.sdk_inter_layer_unity.UnityInterface";

        static UnityPlayerUtils()
        {
            sdkMidLayer = new AndroidJavaClass(sdkMidLayerPath);
        }

        public static void invokeWithAll(string sdkType, string args, string callbackId)
        {
            Debug.Log($"invokeWithAll: {sdkType}: {args}: {callbackId}");
            sdkMidLayer.CallStatic(sdkType, args, callbackId);
        }

        public static object invokeWithAllReturn(string sdkType, string args, string callbackId)
        {
            Debug.Log($"invokeWithAll: {sdkType}: {args}: {callbackId}");
            return sdkMidLayer.CallStatic<object>(sdkType, args, callbackId);
        }

        public static void invokeWithCallback(string sdkType, string callbackId)
        {
            Debug.Log($"invokeWithCallback: {sdkType}: {callbackId}");
            sdkMidLayer.CallStatic(sdkType, callbackId);
        }

        public static void invokeWithTwoCallback(string sdkType, string callbackIdF, string callbackIdS)
        {
            Debug.Log($"invokeWithTwoCallback: {sdkType}: {callbackIdF}: {callbackIdS}");
            sdkMidLayer.CallStatic(sdkType, callbackIdF, callbackIdS);
        }

        public static void invokeWithTwoParamOneCallback(string sdkType, string argsOne, string argsTwo, string callbackId)
        {
            Debug.Log($"invokeWithTwoParamOneCallback: {sdkType}: {argsOne}: {argsTwo}: {callbackId}");
            sdkMidLayer.CallStatic(sdkType, argsOne, argsTwo, callbackId);
        }

        public static void invokeWithAllFourCallback(string sdkType, string args, string callbackIdF, string callbackIdS, string callbackIdT, string callbackIdFo)
        {
            Debug.Log($"invokeWithAllFourCallback: {sdkType}: {args}: {callbackIdF}: {callbackIdS}: {callbackIdT}: {callbackIdFo}");
            sdkMidLayer.CallStatic(sdkType, args, callbackIdF, callbackIdS, callbackIdT, callbackIdFo);
        }

        public static void invokeWithParams(string sdkType, string args)
        {
            Debug.Log($"invokeWithParams: {sdkType}: {args}");
            sdkMidLayer.CallStatic(sdkType, args);
        }

        public static void invokeWithTwoParams(string sdkType, string argsOne, string argsTwo)
        {
            Debug.Log($"invokeWithParams: {sdkType}: {argsOne}: {argsTwo}");
            sdkMidLayer.CallStatic(sdkType, argsOne, argsTwo);
        }

        public static void invokeWithThreeParams(string sdkType, string argsOne, string argsTwo, string argsThree)
        {
            Debug.Log($"invokeWithParams: {sdkType}: {argsOne}: {argsTwo}: {argsThree}");
            sdkMidLayer.CallStatic(sdkType, argsOne, argsTwo, argsThree);
        }

        public static void invokeWithNone(string sdkType)
        {
            Debug.Log($"invokeWithNone: {sdkType}");
            sdkMidLayer.CallStatic(sdkType);
        }

        public static string invokeWithNoneReturn(string sdkType)
        {
            Debug.Log($"invokeWithNoneReturn: {sdkType}");
            return sdkMidLayer.CallStatic<string>(sdkType);
        }

        public static string invokeWithTwoReturn(string sdkType, string argsOne, string argsTwo)
        {
            Debug.Log($"invokeWithOneReturn: {sdkType}: {argsOne}: {argsTwo}");
            return sdkMidLayer.CallStatic<string>(sdkType, argsOne, argsTwo);
        }

        public static void invokeWithJavaObject(string sdkType, object callback)
        {
            Debug.Log($"invokeWithJavaObject: {sdkType}");
            sdkMidLayer.CallStatic(sdkType, callback);
        }

        public static void invokeWithJavaObject(string sdkType, string args, object callback)
        {
            Debug.Log($"invokeWithParamsAndJavaObject: {sdkType}");
            sdkMidLayer.CallStatic(sdkType, args, callback);
        }

    }
}
#endif