using Cute;
using UnityEngine;

namespace Wizard;

public class TransitionPublishDialog : MonoBehaviour
{
	[SerializeField]
	private UILabel _idLabel;

	[SerializeField]
	private UILabel _passwardLabel;

	[SerializeField]
	private UIButton _idCopyButton;

	[SerializeField]
	private UIButton _passwardButton;

	public static void Create(string pass)
	{
		GameObject gameObject = Object.Instantiate(Resources.Load("UI/layoutParts/TransitionToTwo/TransitionPublishDialog")) as GameObject;
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		dialogBase.SetTitleLabel(Data.SystemText.Get("BeyondHandover_0001"));
		dialogBase.SetSize(DialogBase.Size.M);
		dialogBase.SetObj(gameObject);
		TransitionPublishDialog component = gameObject.GetComponent<TransitionPublishDialog>();
		component.SetIdText(pass);
		component.SetCopyButtonEvent(pass);
	}

	private void SetIdText(string pass)
	{
		_idLabel.text = $"{PlayerStaticData.UserViewerID:#,0}".Replace(",", " ");
		_passwardLabel.text = pass;
	}

	private void SetCopyButtonEvent(string pass)
	{
		_idCopyButton.onClick.Add(new EventDelegate(delegate
		{
			NativePluginWrapper.SetStringToClipboard(PlayerStaticData.UserViewerID.ToString());
			DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
			dialogBase.SetPanelDepth(100);
			dialogBase.SetSize(DialogBase.Size.S);
			dialogBase.SetText(Data.SystemText.Get("BeyondHandover_0014"));
			dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		}));
		_passwardButton.onClick.Add(new EventDelegate(delegate
		{
			NativePluginWrapper.SetStringToClipboard(pass);
			DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
			dialogBase.SetPanelDepth(100);
			dialogBase.SetSize(DialogBase.Size.S);
			dialogBase.SetText(Data.SystemText.Get("BeyondHandover_0015"));
			dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		}));
	}
}
