using System;
using System.Collections.Generic;
using UnityEngine;

namespace Wizard;

public class DeckIntroductionPeriodSelectDialog : MonoBehaviour
{
	public DeckIntroductionTask DeckIntroductionDeta { get; private set; }

	private Action<int> OnSelectEvent { get; set; }

	public static DialogBase Create(int defaultSelectId, DeckIntroductionTask task, Action<int> onSelect)
	{
		List<string> resultDeckSeriesNameList = task.ResultDeckSeriesNameList;
		int defaultIndex = 0;
		for (int i = 0; i < task.ResultDeckSeriesIdList.Count; i++)
		{
			if (task.ResultDeckSeriesIdList[i] == defaultSelectId)
			{
				defaultIndex = i;
			}
		}
		GameObject obj = UnityEngine.Object.Instantiate(Resources.Load("UI/layoutParts/MyPage/DeckIntroductionPeriodSelectDialog")) as GameObject;
		DeckIntroductionPeriodSelectDialog componentInChildren = obj.GetComponentInChildren<DeckIntroductionPeriodSelectDialog>();
		componentInChildren.DeckIntroductionDeta = task;
		componentInChildren.OnSelectEvent = onSelect;
		return DrumrollDialog.Create(obj.GetComponent<DrumrollDialog>(), resultDeckSeriesNameList, defaultIndex, componentInChildren.OnSelect);
	}

	private void OnSelect(int index)
	{
		OnSelectEvent(DeckIntroductionDeta.ResultDeckSeriesIdList[index]);
	}
}
