using System.Collections.Generic;
using UnityEngine;
using UVC.Data;
using UVC.Log;
using UVC.network;
using UVC.Network;
using UVC.Tests;
using UVC.UI.Modal;
using UVC.UI.Tooltip;

namespace SampleProject
{
    public class AppMain : MonoBehaviour
    {

        // Start is called once before the first execution of Update after the MonoBehaviour is created
        async void Start()
        {
            
            Canvas rootCanvas = GameObject.FindFirstObjectByType<Canvas>();

            if (rootCanvas != null && !TooltipManager.Instance.IsInitialized) TooltipManager.Instance.Initialize(rootCanvas.transform, rootCanvas);

            //Tester.RunAllTests();

            //URLList.Add("baseinfo", "http://localhost:8888/baseinfo/00:00");
            //URLList.Add("AGV", "http://localhost:8888/AGV/00:00");
            //URLList.Add("STOCKER_STACK", "http://localhost:8888/STOCKER_STACK/00:00");
            //URLList.Add("CARRIER", "http://localhost:8888/CARRIER/00:00");
            //URLList.Add("EQUIPMENT", "http://localhost:8888/EQUIPMENT/00:00");
            //URLList.Add("PORT", "http://localhost:8888/PORT/00:00");
            //URLList.Add("RACK", "http://localhost:8888/RACK/00:00");
            //URLList.Add("TWIN_FORK", "http://localhost:8888/TWIN_FORK/00:00");
            //URLList.Add("HVC_PLC", "http://localhost:8888/HVC_PLC/00:00");
            //URLList.Add("HVC_CRANE", "http://localhost:8888/HVC_CRANE/00:00");
            //URLList.Add("ALARM", "http://localhost:8888/ALARM/00:00");
            //URLList.Add("Dashboard", "http://localhost:8888/Dashboard/00:00");
            //URLList.Add("SIMULATION_RANK", "http://localhost:8888/SIMULATION_RANK/00:00");



            //Dictionary<string, string> headers = new Dictionary<string, string>();
            //headers.Add("Content-Encoding", "gzip");
            //string result = await HttpRequester.RequestPost<string>("http://localhost:8888/AGV/00:00", (string)null, headers);
            //ULog.Debug($"AGV Result: {result}");

            //MQTTService mqttService = new MQTTService("localhost", 1883);
            //mqttService.AddTopicHandler("AGV", (topic, message) =>
            //{
            //    ULog.Debug($"Received message on topic {topic}: {message}");
            //});
            //mqttService.Connect();
        }

        public async void ShowAlert()
        {   
            await Alert.Show("알림", "이것은 간단한 알림 메시지입니다.");
            await Alert.Show("경고", "데이터를 저장할 수 없습니다.", "알겠습니다");
            await Alert.Show("error", "error_network_not", "button_retry");
        }

        public async void ShowConfirm()
        {
            bool result = await Confirm.Show("확인", "이것은 간단한 알림 메시지입니다.");
            ULog.Debug($"사용자가 확인 버튼을 눌렀나요? {result}");
            result = await Confirm.Show("경고", "데이터를 저장할 수 없습니다.", "알겠습니다", "아니요");
            ULog.Debug($"사용자가 알림을 확인했나요? {result}");
            result = await Confirm.Show("error", "error_network_not", "button_retry", "button_cancel");
            ULog.Debug($"사용자가 네트워크 오류 알림을 확인했나요? {result}");
        }

    }
}
