using System;
using Wizard.ErrorDialog;

namespace Wizard;

public static class OutOfService
{
	private static readonly DateTime RefundEndTime = new DateTime(2026, 10, 31, 14, 59, 59, DateTimeKind.Utc);

	public const int ERROR_CODE_OUT_OF_SERVICE = 9999;

	public static void ShowRefundDialog(string refundUrl)
	{
		SystemText systemText = Data.SystemText;
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose(isSystem: true);
		dialogBase.SetSize(DialogBase.Size.M);
		dialogBase.SetTitleLabel(systemText.Get("System_0070"));
		dialogBase.SetText(systemText.Get("System_0071"));
		dialogBase.SetRefund(refundUrl, systemText.Get("System_0072"));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.CloseBtn);
		dialogBase.SetFadeButtonEnabled(flag: false);
		dialogBase.SetPanelDepth(6000);
		dialogBase.SetPanelSortingOrder(2);
		UIManager.GetInstance().WebViewHelper.CloseWebViewDialog();
	}

	public static bool IsServiceEnded()
	{
		return DateTime.UtcNow > RefundEndTime;
	}

	public static bool ShowServiceEndedDialogIfNeeded()
	{
		if (IsServiceEnded())
		{
			ShowServiceEndedDialog();
			return true;
		}
		return false;
	}

	private static void ShowServiceEndedDialog()
	{
		Wizard.ErrorDialog.Dialog.Create(9999);
	}
}
