using UnityEngine;

namespace EngineSdkConverter.Unity.Plugins.WebGL
{

    [System.Serializable]
    public class TuyooParam
    {
        public string appId;
        public string gameId;
        public string projectId;
        public string clientId;
        public string cloudId;
        public string serverUrl;
        public string channelType;
    }

    [System.Serializable]
    public class Login
    {
        public Aliminigame aliminigame;
        public Tywx tywx;
        public Zijieminigame zijieminigame;
        public JingdongMinigame jingdongminigame;
        public OppoMinigame oppominigame;
        public MeituanMinigame meituanminigame;
        public KuaishouMinigame kuaishouminigame;
        public Xiaomiminigame xiaomiminigame;
    }

    [System.Serializable]
    public class Aliminigame
    {
        public string ali_appId;
        public string sdkVersion;
    }

    [System.Serializable]
    public class Tywx
    {
        public string wx_appId;
        public string sdkVersion;
        public string shareManagerUrl;
        public int txAdSetId = 0;
        public string txAdSetKey;
        public bool openFeatureFilter = false;
        public bool wxShareEnable = true;
        public bool pullShareConfig = false;
        public bool adManagerMode = false;
        public bool txAdEventReportMode = true;
        public bool errorLogMode = false;
    }
    [System.Serializable]
    public class Zijieminigame
    {
        public string bytedanceAppId;
        public string sdkVersion;
        public string shareManagerUrl;
        public bool pullShareConfig = false;
    }
    [System.Serializable]
    public class JingdongMinigame
    {
        public string jingdongAppId;
        public string sdkVersion;
        public string packageType = "wasmsplit";
    }
    [System.Serializable]
    public class OppoMinigame
    {
        public string oppoAppId;
        public string sdkVersion;
        public string packageType = "wasmsplit";
    }
    [System.Serializable]
    public class MeituanMinigame
    {
        public string meituanAppId;
        public string sdkVersion;
    }
    [System.Serializable]
    public class KuaishouMinigame
    {
        public string kuaishouAppId;
        public string sdkVersion;
    }
    [System.Serializable]
    public class Xiaomiminigame
    {
        public string xiaomiAppId;
        public string sdkVersion;
    }

    [System.Serializable]
    public class ConfigData
    {
        public string package;
        public string debug;
        public TuyooParam tuyooParam;
        public Login login;
    }


    public class TYConfigManager
    {

        public static ConfigData configData;

        public static string configJsonString;

        public static void LoadConfig()
        {
            TextAsset jsonText = UnityEngine.Resources.Load<TextAsset>("tygameconfig");

            if (jsonText != null)
            {
                // 反序列化 JSON 内容
                configData = JsonUtility.FromJson<ConfigData>(jsonText.text);
                configJsonString = jsonText.text;
            }
            else
            {
                Debug.LogError("Failed to load config.json from Resources.");
            }
        }

        public static string GetChannelType()
        {
            return configData.tuyooParam.channelType;
        }

    }

}