using UnityEngine;

namespace Cute;

public class URLScheme
{
	private enum CPTYPE
	{
		IORI = 1,
		ALIVE
	}

	private static string process = "";

	private static string result = "";

	private static string scheme = "";

	private static int short_udid = 0;

	private static string udid = "";

	private static string error_code = "";

	private static string campaign_data = "";

	private static int app_type = 0;

	private const string COMBINE = "combine";

	private const string MIGRATION = "migration";

	private const string OK = "ok";

	private const string NG = "ng";

	private const string IORI = "cg";

	private const string ALIVE = "pc";

	public const string EC_MIGRATION_CANCEL = "3070";

	public const string EC_COMBINE_CANCEL = "3060";

	public const string EC_MIGRATION_ALREADY_RECORDED = "3061";

	public const string EC_COMBINE_NO_URL = "3054";

	public const string EC_MIGRATION_NO_URL = "3063";

	public const string EC_COMBINE_EXEC_HAVE_RECORD = "3057";

	public static string CampaignData => campaign_data;

	public static int AppType => app_type;

	public static void URLSchemeStartAndroid()
	{
		GetURLSchemeParamsAndroid();
		ProcessSetting();
	}

	public static void URLSchemeStartiOS(string message)
	{
		GetURLSchemeParamsiOS(message);
		ProcessSetting();
	}

	public static bool IsCombineOK()
	{
		if (process == "combine" && result == "ok")
		{
			return short_udid == Certification.ShortUdid;
		}
		return false;
	}

	public static bool IsCombineNG()
	{
		if (process == "combine" && result == "ng")
		{
			return error_code != "";
		}
		return false;
	}

	public static bool IsMigrationOK()
	{
		if (process == "migration" && result == "ok")
		{
			return udid == Certification.Udid;
		}
		return false;
	}

	public static bool IsMigrationNG()
	{
		if (process == "migration" && result == "ng")
		{
			return error_code != "";
		}
		return false;
	}

	public static bool IsMigrationFinished()
	{
		if (process == "migration" && result == "ng")
		{
			return error_code == "3061";
		}
		return false;
	}

	public static void Clear()
	{
		scheme = "";
		process = "";
		result = "";
		short_udid = 0;
		udid = "";
		error_code = "";
	}

	public static void ClearCampaignData()
	{
		campaign_data = "";
		app_type = 0;
	}

	private static void GetURLSchemeParamsAndroid()
	{
		Clear();
	}

	private static void GetURLSchemeParamsiOS(string url)
	{
		Clear();
		if (url == "")
		{
			url = PlayerPrefs.GetString("iOSUrlScheme", "");
			PlayerPrefs.DeleteKey("iOSUrlScheme");
		}
		if (url.IndexOf("://") >= 0)
		{
			scheme = url.Substring(0, url.IndexOf("://"));
			AnalysisResult(url.Substring(url.IndexOf("://") + 3));
		}
	}

	private static void ProcessSetting()
	{
		if (!(scheme == ""))
		{
			if (IsCombineOK())
			{
				DataMigration.CombineSucceed();
			}
			else if (IsCombineNG())
			{
				DataMigration.CombineFailed();
			}
			else if (IsMigrationOK())
			{
				DataMigration.MigrationSucceed();
			}
			else if (IsMigrationNG())
			{
				DataMigration.MigrationFailed();
			}
		}
	}

	private static void AnalysisResult(string host)
	{
		if (scheme == "shadowverse")
		{
			UIManager.GetInstance().AccountTransferHelper.GetAppleData(host);
		}
	}
}
