#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UIElements;
using UVC.UIToolkit.List;
namespace UVC.UIToolkit.Window
{
///
/// UTKComponentList와 탭 기능을 결합하여 윈도우 형태로 제공하는 컴포넌트입니다.
///
/// 개요:
///
/// UTKComponentTabListWindow는 UTKComponentList를 내부에 포함하고 헤더(타이틀, 닫기 버튼)와
/// 탭 버튼들을 추가한 윈도우 형태의 컴포넌트입니다. 탭을 통해 카테고리별 필터링이 가능합니다.
///
///
/// UXML에서 사용:
///
///
///
///
/// 코드에서 사용:
///
/// var window = root.Q();
/// window.OnItemSelected += (items) => Debug.Log($"선택: {items[0].name}");
/// window.SetData(treeItems);
/// window.SelectTab(0); // 첫 번째 카테고리 탭 선택
///
///
[UxmlElement]
public partial class UTKComponentTabListWindow : VisualElement, IDisposable
{
#region IDisposable
private bool _disposed = false;
#endregion
#region 상수 (Constants)
/// 메인 UXML 파일 경로 (Resources 폴더 기준)
private const string UXML_PATH = "UIToolkit/Window/UTKComponentTabListWindow";
/// "전체" 탭을 나타내는 인덱스
private const int ALL_TAB_INDEX = -1;
#endregion
#region UI 컴포넌트 참조 (UI Component References)
/// 내부 UTKComponentList 컴포넌트
private UTKComponentList? _componentList;
/// 탭 버튼 컨테이너
private VisualElement? _tabContainer;
/// 트리 리스트 닫기 버튼
private Button? _closeButton;
#endregion
#region 탭 관련 데이터 (Tab Data)
/// 원본 전체 데이터
private List _originalRoots = new();
/// 현재 선택된 탭 인덱스 (-1: 전체)
private int _selectedTabIndex = ALL_TAB_INDEX;
/// 탭 버튼들
private List