using System;
using UnityEngine;

namespace Wizard;

public class GuildInputViewerIdDialog : MonoBehaviour
{
	[SerializeField]
	private UIInput _inputId;

	public int InputValue => int.Parse(_inputId.value);

	public void InitInput(Action onChangeInputLength)
	{
		_inputId.value = string.Empty;
		_inputId.onChange.Clear();
		_inputId.onChange.Add(new EventDelegate(delegate
		{
			onChangeInputLength();
		}));
	}

	public void InitializeDialog(DialogBase dialog)
	{
		UIManager.SetObjectToGrey(dialog.button1.gameObject, b: true);
		InitInput(delegate
		{
			if (UIUtil.IsValidViewerId(_inputId.value))
			{
				UIManager.SetObjectToGrey(dialog.button1.gameObject, b: false);
			}
			else
			{
				UIManager.SetObjectToGrey(dialog.button1.gameObject, b: true);
			}
		});
	}
}
