Decompiled source of ItemBrowser v0.2.1

plugins/com.github.cherrycove.ItemBrowser.dll

Decompiled 29 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using PEAKLib.UI;
using PEAKLib.UI.Elements;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using Zorro.Core;
using Zorro.Settings;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.cherrycove.ItemBrowser")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.1.0")]
[assembly: AssemblyInformationalVersion("0.2.1+baeacdb91a9fa44c9de5683c95191bd0c826cb90")]
[assembly: AssemblyProduct("com.github.cherrycove.ItemBrowser")]
[assembly: AssemblyTitle("ItemBrowser")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace ItemBrowser
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.github.cherrycove.ItemBrowser", "ItemBrowser", "0.2.1")]
	public class Plugin : BaseUnityPlugin
	{
		private enum MajorCategory
		{
			All,
			Food,
			Weapon
		}

		private enum ItemCategory
		{
			NaturalFood,
			MysticalFood,
			PackagedFood,
			Mushroom,
			Consumable,
			Deployable,
			MiscEquipment,
			MysticalItem
		}

		private sealed class ItemEntry
		{
			public Item Prefab { get; }

			public string PrefabName { get; }

			public string DisplayName { get; private set; } = string.Empty;


			public ItemCategory Category { get; }

			public Sprite? Icon { get; private set; }

			public string SearchText { get; private set; } = string.Empty;


			public ItemEntry(Item prefab, string displayName, ItemCategory category, Sprite? icon)
			{
				Prefab = prefab;
				PrefabName = ((Object)prefab).name ?? string.Empty;
				Category = category;
				Icon = icon;
				UpdateDisplayName(displayName);
			}

			public void UpdateIcon(Sprite? icon)
			{
				Icon = icon;
			}

			public void UpdateDisplayName(string displayName)
			{
				string text2 = (DisplayName = (string.IsNullOrWhiteSpace(displayName) ? PrefabName : displayName.Trim()));
				SearchText = (text2 + " " + PrefabName).ToLowerInvariant();
			}
		}

		private sealed class PooledItemButton
		{
			public PeakMenuButton Button { get; }

			public RectTransform ButtonRect { get; }

			public Image IconImage { get; }

			public ItemButtonBinder Binder { get; }

			public int PoolIndex { get; }

			public int BoundDataIndex { get; set; }

			public PooledItemButton(PeakMenuButton button, RectTransform buttonRect, Image iconImage, ItemButtonBinder binder, int poolIndex)
			{
				Button = button;
				ButtonRect = buttonRect;
				IconImage = iconImage;
				Binder = binder;
				PoolIndex = poolIndex;
				BoundDataIndex = -1;
			}
		}

		private sealed class ItemButtonBinder : MonoBehaviour
		{
			public Item? Prefab;

			public void HandleClick()
			{
				if ((Object)(object)Prefab != (Object)null)
				{
					SpawnItem(Prefab);
				}
			}
		}

		private sealed class CategoryTab
		{
			public ItemCategory? Category { get; }

			public GameObject Root { get; }

			public Button Button { get; }

			public Image Background { get; }

			public Image Selected { get; }

			public PeakText Label { get; }

			public CategoryTab(ItemCategory? category, GameObject root, Button button, Image background, Image selected, PeakText label)
			{
				Category = category;
				Root = root;
				Button = button;
				Background = background;
				Selected = selected;
				Label = label;
			}
		}

		private sealed class MajorCategoryTab
		{
			public MajorCategory Category { get; }

			public GameObject Root { get; }

			public Button Button { get; }

			public Image Background { get; }

			public Image Selected { get; }

			public PeakText Label { get; }

			public MajorCategoryTab(MajorCategory category, GameObject root, Button button, Image background, Image selected, PeakText label)
			{
				Category = category;
				Root = root;
				Button = button;
				Background = background;
				Selected = selected;
				Label = label;
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__ClosePage;

			public static UnityAction<string> <1>__OnSearchChanged;

			public static Func<char, bool> <2>__IsLetterOrDigit;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<GameObject, bool> <>9__115_0;

			public static Func<GameObject, bool> <>9__115_1;

			public static UnityAction <>9__123_0;

			public static UnityAction <>9__123_1;

			public static UnityAction<Vector2> <>9__123_2;

			public static Func<ItemEntry, bool> <>9__132_1;

			public static Func<ItemEntry, bool> <>9__132_2;

			public static Func<ItemEntry, string> <>9__132_3;

			public static UnityAction <>9__146_0;

			public static Func<ItemEntry, ItemCategory> <>9__165_0;

			public static Func<IGrouping<ItemCategory, ItemEntry>, int> <>9__165_1;

			public static Func<IGrouping<ItemCategory, ItemEntry>, string> <>9__165_2;

			public static Func<string, bool> <>9__197_0;

			public static Func<MethodInfo, bool> <>9__233_0;

			public static Func<MethodInfo, bool> <>9__233_1;

			public static Func<string, bool> <>9__246_0;

			internal bool <TryRecoverButtonTemplate>b__115_0(GameObject obj)
			{
				if ((Object)(object)obj != (Object)null)
				{
					return ((Object)obj).name == "UI_MainMenuButton_LeaveGame (2)";
				}
				return false;
			}

			internal bool <TryRecoverButtonTemplate>b__115_1(GameObject obj)
			{
				if ((Object)(object)obj != (Object)null)
				{
					return ((Object)obj).name.StartsWith("UI_MainMenuButton_LeaveGame", StringComparison.Ordinal);
				}
				return false;
			}

			internal void <BuildUI>b__123_0()
			{
				pageOpen = true;
				RefreshLanguageDependentContent();
				EnsureItemList();
				RefreshListIfNeeded();
			}

			internal void <BuildUI>b__123_1()
			{
				pageOpen = false;
			}

			internal void <BuildUI>b__123_2(Vector2 _)
			{
				OnVirtualizedScrollChanged();
			}

			internal bool <RefreshList>b__132_1(ItemEntry entry)
			{
				return IsEntryInMajorCategory(entry, currentMajorFilter);
			}

			internal bool <RefreshList>b__132_2(ItemEntry entry)
			{
				return entry.Category == currentSubCategoryFilter.Value;
			}

			internal string <RefreshList>b__132_3(ItemEntry entry)
			{
				return entry.DisplayName;
			}

			internal void <EnsurePooledItemButton>b__146_0()
			{
			}

			internal ItemCategory <BuildItemListGradually>b__165_0(ItemEntry entry)
			{
				return entry.Category;
			}

			internal int <BuildItemListGradually>b__165_1(IGrouping<ItemCategory, ItemEntry> group)
			{
				return GetCategoryOrder(group.Key);
			}

			internal string <BuildItemListGradually>b__165_2(IGrouping<ItemCategory, ItemEntry> group)
			{
				return $"{GetCategoryLabel(group.Key)}={group.Count()}";
			}

			internal bool <TryGetCategoryOverride>b__197_0(string x)
			{
				return !string.IsNullOrWhiteSpace(x);
			}

			internal bool <ClosePage>b__233_0(MethodInfo m)
			{
				if (m.Name == "Close")
				{
					return m.GetParameters().Length == 0;
				}
				return false;
			}

			internal bool <ClosePage>b__233_1(MethodInfo m)
			{
				if (m.Name == "Close")
				{
					return m.GetParameters().Length == 1;
				}
				return false;
			}

			internal bool <LoadLocalizedText>b__246_0(string x)
			{
				return !string.IsNullOrWhiteSpace(x);
			}
		}

		[CompilerGenerated]
		private sealed class <BuildItemListGradually>d__165 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ItemDatabase db;

			public int dbId;

			private int <budget>5__2;

			private List<Item>.Enumerator <>7__wrap2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <BuildItemListGradually>d__165(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 2)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>7__wrap2 = default(List<Item>.Enumerator);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<budget>5__2 = 4;
						<>2__current = null;
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						<>7__wrap2 = ((DatabaseAsset<ItemDatabase, Item>)(object)db).Objects.GetEnumerator();
						<>1__state = -3;
						break;
					case 2:
						<>1__state = -3;
						break;
					}
					while (<>7__wrap2.MoveNext())
					{
						Item current = <>7__wrap2.Current;
						itemPreloadProcessedCount++;
						try
						{
							if ((Object)(object)current != (Object)null)
							{
								string localizedItemName = GetLocalizedItemName(current);
								string displayName = (string.IsNullOrWhiteSpace(localizedItemName) ? ((Object)current).name : localizedItemName);
								displayName = GetDisplayNameOverride(current, displayName);
								if (!ShouldHideItemFromBrowser(current, displayName))
								{
									ItemCategory category = GetCategory(current, displayName);
									Sprite itemIcon = GetItemIcon(current, allowHeavyFallback: false);
									itemEntries.Add(new ItemEntry(current, displayName, category, itemIcon));
									itemPreloadAddedCount++;
								}
								else
								{
									VerboseLog("Item hidden: prefab='" + ((Object)current).name + "', display='" + displayName + "'");
								}
							}
						}
						catch (Exception ex)
						{
							Log.LogWarning((object)("[ItemBrowser] Preload item failed: " + ((current != null) ? ((Object)current).name : null) + " (" + ex.GetType().Name + " " + ex.Message + ")"));
						}
						<budget>5__2--;
						if (<budget>5__2 <= 0)
						{
							<budget>5__2 = 4;
							<>2__current = null;
							<>1__state = 2;
							return true;
						}
					}
					<>m__Finally1();
					<>7__wrap2 = default(List<Item>.Enumerator);
					itemPreloadRunning = false;
					itemPreloadCoroutine = null;
					itemListInitialized = true;
					loadedDatabaseId = ((preloadingDatabaseId != 0) ? preloadingDatabaseId : dbId);
					preloadingDatabaseId = 0;
					if (configVerboseLogs != null && configVerboseLogs.Value)
					{
						IEnumerable<string> values = from entry in itemEntries
							group entry by entry.Category into @group
							orderby GetCategoryOrder(@group.Key)
							select $"{GetCategoryLabel(@group.Key)}={@group.Count()}";
						Log.LogInfo((object)string.Format("[ItemBrowser] Item list built in background. Total={0}, Added={1}, Categories: {2}", itemEntries.Count, itemPreloadAddedCount, string.Join(", ", values)));
					}
					MarkListDirty("Item preload completed");
					TryStartBackgroundIconPrewarm("PostPreload");
					TryStartBackgroundButtonPoolWarmup("PostPreload", CalculateButtonPoolWarmupTarget(itemEntries.Count));
					if (pageOpen)
					{
						RefreshListIfNeeded();
					}
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>7__wrap2).Dispose();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <GetCategoryCandidateKeys>d__200 : IEnumerable<string>, IEnumerable, IEnumerator<string>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private string <>2__current;

			private int <>l__initialThreadId;

			private Item item;

			public Item <>3__item;

			private string displayName;

			public string <>3__displayName;

			private string <prefabName>5__2;

			string IEnumerator<string>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GetCategoryCandidateKeys>d__200(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<prefabName>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<prefabName>5__2 = ((Object)item).name ?? string.Empty;
					if (!string.IsNullOrWhiteSpace(<prefabName>5__2))
					{
						<>2__current = NormalizeCategoryKey(<prefabName>5__2);
						<>1__state = 1;
						return true;
					}
					goto IL_00ac;
				case 1:
				{
					<>1__state = -1;
					int num = <prefabName>5__2.IndexOf(" Variant", StringComparison.OrdinalIgnoreCase);
					if (num > 0)
					{
						<>2__current = NormalizeCategoryKey(<prefabName>5__2.Substring(0, num));
						<>1__state = 2;
						return true;
					}
					goto IL_00ac;
				}
				case 2:
					<>1__state = -1;
					goto IL_00ac;
				case 3:
					{
						<>1__state = -1;
						break;
					}
					IL_00ac:
					if (!string.IsNullOrWhiteSpace(displayName))
					{
						<>2__current = NormalizeCategoryKey(displayName);
						<>1__state = 3;
						return true;
					}
					break;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			IEnumerator<string> IEnumerable<string>.GetEnumerator()
			{
				<GetCategoryCandidateKeys>d__200 <GetCategoryCandidateKeys>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<GetCategoryCandidateKeys>d__ = this;
				}
				else
				{
					<GetCategoryCandidateKeys>d__ = new <GetCategoryCandidateKeys>d__200(0);
				}
				<GetCategoryCandidateKeys>d__.item = <>3__item;
				<GetCategoryCandidateKeys>d__.displayName = <>3__displayName;
				return <GetCategoryCandidateKeys>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<string>)this).GetEnumerator();
			}
		}

		[CompilerGenerated]
		private sealed class <RenderListGradually>d__134 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public List<ItemEntry> entries;

			public int generation;

			private int <renderCount>5__2;

			private int <budget>5__3;

			private int <initialBurst>5__4;

			private int <i>5__5;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <RenderListGradually>d__134(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					int val = CalculateVirtualizedVisiblePoolTarget();
					<renderCount>5__2 = Math.Min(entries.Count, val);
					<budget>5__3 = 6;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				case 1:
				{
					<>1__state = -1;
					<initialBurst>5__4 = Math.Min(<renderCount>5__2, 2);
					for (int i = 0; i < <initialBurst>5__4; i++)
					{
						if (generation != listRenderGeneration)
						{
							return false;
						}
						RenderVirtualizedSlot(i, i, entries[i]);
					}
					if (<initialBurst>5__4 > 0)
					{
						<>2__current = null;
						<>1__state = 2;
						return true;
					}
					goto IL_00c6;
				}
				case 2:
					<>1__state = -1;
					goto IL_00c6;
				case 3:
					{
						<>1__state = -1;
						goto IL_013c;
					}
					IL_013c:
					<i>5__5++;
					goto IL_014c;
					IL_00c6:
					<i>5__5 = <initialBurst>5__4;
					goto IL_014c;
					IL_014c:
					if (<i>5__5 < <renderCount>5__2)
					{
						if (generation != listRenderGeneration)
						{
							return false;
						}
						RenderVirtualizedSlot(<i>5__5, <i>5__5, entries[<i>5__5]);
						<budget>5__3--;
						if (<budget>5__3 <= 0)
						{
							<budget>5__3 = 6;
							<>2__current = null;
							<>1__state = 3;
							return true;
						}
						goto IL_013c;
					}
					if (generation == listRenderGeneration)
					{
						virtualizedFirstDataIndex = 0;
						UpdateVirtualizedVisibleWindow(force: true);
						listRenderRunning = false;
						listRenderCoroutine = null;
					}
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WarmupButtonPoolGradually>d__170 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RectTransform listContent;

			public string reason;

			private int <budget>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WarmupButtonPoolGradually>d__170(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<budget>5__2 = 2;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				while (itemButtonPool.Count < buttonPoolWarmupTargetCount)
				{
					EnsurePooledItemButton(itemButtonPool.Count, listContent);
					<budget>5__2--;
					if (<budget>5__2 <= 0)
					{
						<budget>5__2 = 2;
						<>2__current = null;
						<>1__state = 2;
						return true;
					}
				}
				buttonPoolWarmupRunning = false;
				buttonPoolWarmupCoroutine = null;
				VerboseLog($"Button pool warmup completed ({reason}). Count={itemButtonPool.Count}");
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WarmupMissingIconsGradually>d__167 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string reason;

			private int <budget>5__2;

			private int <i>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WarmupMissingIconsGradually>d__167(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<budget>5__2 = 1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<i>5__3 = 0;
					goto IL_00e7;
				case 2:
					{
						<>1__state = -1;
						goto IL_00d7;
					}
					IL_00e7:
					if (<i>5__3 < itemEntries.Count)
					{
						ItemEntry itemEntry = itemEntries[<i>5__3];
						iconPrewarmProcessedCount++;
						if ((Object)(object)itemEntry.Icon == (Object)null)
						{
							Sprite itemIcon = GetItemIcon(itemEntry.Prefab);
							if ((Object)(object)itemIcon != (Object)null)
							{
								itemEntry.UpdateIcon(itemIcon);
								iconPrewarmResolvedCount++;
							}
						}
						<budget>5__2--;
						if (<budget>5__2 <= 0)
						{
							<budget>5__2 = 1;
							<>2__current = null;
							<>1__state = 2;
							return true;
						}
						goto IL_00d7;
					}
					iconPrewarmRunning = false;
					iconPrewarmCoroutine = null;
					iconPrewarmCompleted = true;
					VerboseLog($"Icon prewarm completed ({reason}). Processed={iconPrewarmProcessedCount}, Resolved={iconPrewarmResolvedCount}");
					return false;
					IL_00d7:
					<i>5__3++;
					goto IL_00e7;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static ConfigEntry<KeyCode> configToggleKey;

		private static ConfigEntry<float> configSpawnDistance;

		private static ConfigEntry<bool> configAllowOnline;

		private static ConfigEntry<bool> configVerboseLogs;

		private static PeakCustomPage? page;

		private static PeakText? headerTitleText;

		private static PeakMenuButton? closeMenuButton;

		private static PeakTextInput? searchInput;

		private static PeakScrollableContent? scrollContent;

		private static Plugin? instance;

		private static Coroutine? itemPreloadCoroutine;

		private static bool itemPreloadRunning;

		private static int itemPreloadTotalCount;

		private static int itemPreloadProcessedCount;

		private static int itemPreloadAddedCount;

		private static Coroutine? iconPrewarmCoroutine;

		private static bool iconPrewarmRunning;

		private static bool iconPrewarmCompleted;

		private static int iconPrewarmProcessedCount;

		private static int iconPrewarmResolvedCount;

		private static float nextIconPrewarmCheckTime;

		private static float nextPreloadCheckTime;

		private static float nextUIWarmupCheckTime;

		private static int preloadingDatabaseId;

		private static int loadedDatabaseId;

		private static int itemNamesLanguageIndex = -1;

		private static string itemNamesLanguageMarker = string.Empty;

		private static string lastLanguageMarker = string.Empty;

		private static bool uiBuilt;

		private static bool pageOpen;

		private static bool listNeedsRefresh = true;

		private static bool listRenderRunning;

		private static bool firstOpenPrimed;

		private static bool hiddenMenuWindowPrimed;

		private static bool postSpawnPrimeLocked;

		private static float nextHiddenPrimeCheckTime;

		private static float nextPostSpawnPrimeCheckTime;

		private static string currentSearch = string.Empty;

		private static MajorCategory currentMajorFilter = MajorCategory.All;

		private static ItemCategory? currentSubCategoryFilter;

		private static bool templatesLogged;

		private static PeakHorizontalTabs? majorTabs;

		private static PeakHorizontalTabs? subCategoryTabs;

		private static GameObject? subCategoryTabsRoot;

		private static RectTransform? topControlsRect;

		private static RectTransform? listContainerRect;

		private static ScrollRect? listScrollRect;

		private static Scrollbar? listScrollbar;

		private static readonly List<MajorCategoryTab> majorTabEntries = new List<MajorCategoryTab>();

		private static readonly List<CategoryTab> subCategoryTabEntries = new List<CategoryTab>();

		private static readonly List<ItemEntry> itemEntries = new List<ItemEntry>();

		private static readonly Dictionary<string, Sprite?> itemIconCache = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase);

		private static readonly Dictionary<int, Sprite> generatedTextureSpriteCache = new Dictionary<int, Sprite>();

		private static readonly Dictionary<string, List<Texture2D>> textureNameIndex = new Dictionary<string, List<Texture2D>>(StringComparer.OrdinalIgnoreCase);

		private static bool textureNameIndexBuilt;

		private static GridLayoutGroup? itemGridLayout;

		private static bool itemListInitialized;

		private static Coroutine? listRenderCoroutine;

		private static int listRenderGeneration;

		private static readonly List<PooledItemButton> itemButtonPool = new List<PooledItemButton>();

		private static readonly List<ItemEntry> activeRenderEntries = new List<ItemEntry>();

		private static readonly List<int> virtualizedPendingDataIndices = new List<int>();

		private static readonly List<PooledItemButton> virtualizedFreePoolButtons = new List<PooledItemButton>();

		private static int virtualizedFirstDataIndex = -1;

		private static float virtualizedCellWidth = 320f;

		private static bool suppressScrollUpdate;

		private static bool virtualizedScrollDirty;

		private static float nextVirtualizedScrollApplyTime;

		private static Coroutine? buttonPoolWarmupCoroutine;

		private static bool buttonPoolWarmupRunning;

		private static int buttonPoolWarmupTargetCount;

		private static float nextButtonPoolWarmupCheckTime;

		private const int VirtualizedColumnCount = 2;

		private const float VirtualizedCellHeight = 72f;

		private const float VirtualizedHorizontalSpacing = 12f;

		private const float VirtualizedVerticalSpacing = 8f;

		private const float VirtualizedPadding = 4f;

		private const int VirtualizedOverscanRows = 2;

		private const float VirtualizedScrollApplyInterval = 0.02f;

		private static readonly Dictionary<string, string> itemNameKeyMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

		private static bool itemNameKeyMapInitialized;

		private static readonly Dictionary<string, ItemCategory> wikiCategoryOverrides = BuildWikiCategoryOverrides();

		private static readonly HashSet<string> hiddenPrefabNames = BuildHiddenPrefabNameSet();

		private static bool buttonTemplateRecovered;

		private static readonly Dictionary<string, List<string>> localizedTextTable = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);

		private static bool inputSystemChecked;

		private static bool inputSystemAvailable;

		private static int lastRenderedLanguageIndex = -1;

		private static PropertyInfo? inputSystemKeyboardCurrentProp;

		private static PropertyInfo? inputSystemKeyboardItemProp;

		private static PropertyInfo? inputSystemKeyControlPressedProp;

		private static Type? inputSystemKeyType;

		private static bool legacyInputAvailable = true;

		private static MethodInfo? menuWindowOpenMethod;

		private static MethodInfo? menuWindowCloseMethod;

		public const string Id = "com.github.cherrycove.ItemBrowser";

		internal static ManualLogSource Log { get; private set; } = null;


		public static string Name => "ItemBrowser";

		public static string Version => "0.2.1";

		private void Awake()
		{
			instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			configToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("ItemBrowser", "Toggle Key", (KeyCode)286, "Press to open/close the item browser.");
			configSpawnDistance = ((BaseUnityPlugin)this).Config.Bind<float>("ItemBrowser", "Spawn Distance", 1.5f, "Distance in front of the player to spawn items.");
			configAllowOnline = ((BaseUnityPlugin)this).Config.Bind<bool>("ItemBrowser", "Allow Online Spawn", true, "Allow spawning items while online.");
			configVerboseLogs = ((BaseUnityPlugin)this).Config.Bind<bool>("ItemBrowser", "Verbose Logs", false, "Enable detailed category/UI/spawn logs.");
			LoadLocalizedText();
		}

		private void OnDestroy()
		{
			if ((Object)(object)instance == (Object)(object)this)
			{
				instance = null;
			}
			if (itemPreloadCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(itemPreloadCoroutine);
				itemPreloadCoroutine = null;
			}
			itemPreloadRunning = false;
			if (iconPrewarmCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(iconPrewarmCoroutine);
				iconPrewarmCoroutine = null;
			}
			iconPrewarmRunning = false;
			iconPrewarmCompleted = false;
			if (listRenderCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(listRenderCoroutine);
				listRenderCoroutine = null;
			}
			listRenderRunning = false;
			if (buttonPoolWarmupCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(buttonPoolWarmupCoroutine);
				buttonPoolWarmupCoroutine = null;
			}
			buttonPoolWarmupRunning = false;
		}

		private void Update()
		{
			ValidateRuntimeState();
			TickVirtualizedScrollApply();
			TickBackgroundUIWarmup();
			TickBackgroundItemPreload();
			TickBackgroundIconPrewarm();
			TickBackgroundButtonPoolWarmup();
			TickHiddenFirstOpenPrime();
			TickPostSpawnPrimeLock();
			if (IsTogglePressed())
			{
				ToggleUI();
			}
		}

		private static void TickVirtualizedScrollApply()
		{
			if (virtualizedScrollDirty && !listRenderRunning && !(Time.unscaledTime < nextVirtualizedScrollApplyTime))
			{
				nextVirtualizedScrollApplyTime = Time.unscaledTime + 0.02f;
				UpdateVirtualizedVisibleWindow(force: false);
			}
		}

		private static void ValidateRuntimeState()
		{
			if (uiBuilt && (Object)(object)page == (Object)null)
			{
				ResetUIRuntimeState("Cached UI page was destroyed.");
			}
			ItemDatabase val = SingletonAsset<ItemDatabase>.Instance;
			if (!((Object)(object)val == (Object)null) && ((DatabaseAsset<ItemDatabase, Item>)(object)val).Objects != null && ((DatabaseAsset<ItemDatabase, Item>)(object)val).Objects.Count != 0)
			{
				int instanceID = ((Object)val).GetInstanceID();
				if (itemPreloadRunning && preloadingDatabaseId != 0 && preloadingDatabaseId != instanceID)
				{
					InvalidateItemListState($"ItemDatabase changed while preloading ({preloadingDatabaseId}->{instanceID}).");
				}
				else if (!itemPreloadRunning && itemListInitialized && loadedDatabaseId != 0 && loadedDatabaseId != instanceID)
				{
					InvalidateItemListState($"ItemDatabase changed ({loadedDatabaseId}->{instanceID}). Re-preloading.");
				}
			}
		}

		private static void TickBackgroundUIWarmup()
		{
			if (!uiBuilt && !(Time.unscaledTime < nextUIWarmupCheckTime))
			{
				nextUIWarmupCheckTime = Time.unscaledTime + 0.1f;
				if (IsUIReady(out string _))
				{
					BuildUI();
					uiBuilt = true;
					LogAvailableTemplates();
					VerboseLog("UI warmup build completed.");
				}
			}
		}

		private static void ResetUIRuntimeState(string reason)
		{
			page = null;
			headerTitleText = null;
			closeMenuButton = null;
			searchInput = null;
			scrollContent = null;
			majorTabs = null;
			subCategoryTabs = null;
			subCategoryTabsRoot = null;
			topControlsRect = null;
			listContainerRect = null;
			listScrollRect = null;
			listScrollbar = null;
			itemGridLayout = null;
			itemButtonPool.Clear();
			activeRenderEntries.Clear();
			virtualizedPendingDataIndices.Clear();
			virtualizedFreePoolButtons.Clear();
			virtualizedFirstDataIndex = -1;
			virtualizedCellWidth = 320f;
			suppressScrollUpdate = false;
			virtualizedScrollDirty = false;
			nextVirtualizedScrollApplyTime = 0f;
			buttonPoolWarmupCoroutine = null;
			buttonPoolWarmupRunning = false;
			buttonPoolWarmupTargetCount = 0;
			nextButtonPoolWarmupCheckTime = 0f;
			majorTabEntries.Clear();
			subCategoryTabEntries.Clear();
			uiBuilt = false;
			pageOpen = false;
			listNeedsRefresh = true;
			listRenderRunning = false;
			listRenderGeneration++;
			firstOpenPrimed = false;
			hiddenMenuWindowPrimed = false;
			postSpawnPrimeLocked = false;
			nextHiddenPrimeCheckTime = 0f;
			nextPostSpawnPrimeCheckTime = 0f;
			nextIconPrewarmCheckTime = 0f;
			iconPrewarmProcessedCount = 0;
			iconPrewarmResolvedCount = 0;
			VerboseLog(reason);
		}

		private static void InvalidateItemListState(string reason)
		{
			if (itemPreloadCoroutine != null && (Object)(object)instance != (Object)null)
			{
				((MonoBehaviour)instance).StopCoroutine(itemPreloadCoroutine);
			}
			if (iconPrewarmCoroutine != null && (Object)(object)instance != (Object)null)
			{
				((MonoBehaviour)instance).StopCoroutine(iconPrewarmCoroutine);
			}
			itemPreloadCoroutine = null;
			itemPreloadRunning = false;
			iconPrewarmCoroutine = null;
			iconPrewarmRunning = false;
			iconPrewarmCompleted = false;
			iconPrewarmProcessedCount = 0;
			iconPrewarmResolvedCount = 0;
			nextIconPrewarmCheckTime = 0f;
			itemListInitialized = false;
			itemPreloadTotalCount = 0;
			itemPreloadProcessedCount = 0;
			itemPreloadAddedCount = 0;
			preloadingDatabaseId = 0;
			loadedDatabaseId = 0;
			itemNamesLanguageIndex = -1;
			itemNamesLanguageMarker = string.Empty;
			listNeedsRefresh = true;
			listRenderRunning = false;
			listRenderGeneration++;
			firstOpenPrimed = false;
			hiddenMenuWindowPrimed = false;
			postSpawnPrimeLocked = false;
			nextHiddenPrimeCheckTime = 0f;
			nextPostSpawnPrimeCheckTime = 0f;
			itemEntries.Clear();
			itemIconCache.Clear();
			generatedTextureSpriteCache.Clear();
			textureNameIndex.Clear();
			textureNameIndexBuilt = false;
			itemButtonPool.Clear();
			activeRenderEntries.Clear();
			virtualizedPendingDataIndices.Clear();
			virtualizedFreePoolButtons.Clear();
			virtualizedFirstDataIndex = -1;
			virtualizedCellWidth = 320f;
			suppressScrollUpdate = false;
			virtualizedScrollDirty = false;
			nextVirtualizedScrollApplyTime = 0f;
			buttonPoolWarmupTargetCount = 0;
			nextButtonPoolWarmupCheckTime = 0f;
			if (buttonPoolWarmupCoroutine != null && (Object)(object)instance != (Object)null)
			{
				((MonoBehaviour)instance).StopCoroutine(buttonPoolWarmupCoroutine);
			}
			buttonPoolWarmupCoroutine = null;
			buttonPoolWarmupRunning = false;
			VerboseLog(reason);
			MarkListDirty(reason);
			if (pageOpen)
			{
				RefreshListIfNeeded(force: true);
			}
		}

		private static void ToggleUI()
		{
			if (EnsureUIBuilt())
			{
				if (pageOpen)
				{
					ClosePage();
				}
				else
				{
					OpenPage();
				}
			}
		}

		private static bool EnsureUIBuilt()
		{
			if (uiBuilt)
			{
				if ((Object)(object)page != (Object)null)
				{
					return true;
				}
				ResetUIRuntimeState("Cached UI page was destroyed.");
			}
			if (!IsUIReady(out string reason))
			{
				if (!string.IsNullOrWhiteSpace(reason))
				{
					Log.LogWarning((object)("[ItemBrowser] UI not ready yet (" + reason + "). Try again after fully entering a match."));
				}
				else
				{
					Log.LogWarning((object)"[ItemBrowser] UI not ready yet. Try again after fully entering a match.");
				}
				return false;
			}
			BuildUI();
			uiBuilt = true;
			LogAvailableTemplates();
			VerboseLog("UI build completed.");
			return true;
		}

		private static bool IsUIReady(out string reason)
		{
			List<string> list = new List<string>(3);
			InputCellMapper val = SingletonAsset<InputCellMapper>.Instance;
			if ((Object)(object)val == (Object)null)
			{
				list.Add("InputCellMapper.Instance == null");
			}
			else if ((Object)(object)val.FloatSettingCell == (Object)null)
			{
				list.Add("InputCellMapper.FloatSettingCell == null");
			}
			if ((Object)(object)Templates.ButtonTemplate == (Object)null && !TryRecoverButtonTemplate(out string reason2))
			{
				if (string.IsNullOrWhiteSpace(reason2))
				{
					list.Add("Templates.ButtonTemplate == null");
				}
				else
				{
					list.Add("Templates.ButtonTemplate == null (" + reason2 + ")");
				}
			}
			if (list.Count == 0)
			{
				reason = string.Empty;
				return true;
			}
			reason = string.Join(", ", list);
			return false;
		}

		private static bool TryRecoverButtonTemplate(out string reason)
		{
			reason = string.Empty;
			if ((Object)(object)Templates.ButtonTemplate != (Object)null)
			{
				return true;
			}
			try
			{
				GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
				if (array == null || array.Length == 0)
				{
					reason = "Resources empty";
					return false;
				}
				GameObject val = ((IEnumerable<GameObject>)array).FirstOrDefault((Func<GameObject, bool>)((GameObject obj) => (Object)(object)obj != (Object)null && ((Object)obj).name == "UI_MainMenuButton_LeaveGame (2)"));
				if ((Object)(object)val == (Object)null)
				{
					val = ((IEnumerable<GameObject>)array).FirstOrDefault((Func<GameObject, bool>)((GameObject obj) => (Object)(object)obj != (Object)null && ((Object)obj).name.StartsWith("UI_MainMenuButton_LeaveGame", StringComparison.Ordinal)));
				}
				if ((Object)(object)val == (Object)null)
				{
					reason = "MainMenu button prefab not found";
					return false;
				}
				GameObject val2 = Object.Instantiate<GameObject>(val);
				((Object)val2).name = "PeakUIButton";
				RemoveLocalizedTextComponent(val2);
				Object.DontDestroyOnLoad((Object)(object)val2);
				if (!TrySetTemplatesProperty("ButtonTemplate", val2, out string reason2))
				{
					reason = reason2;
					return false;
				}
				if (!buttonTemplateRecovered)
				{
					Log.LogInfo((object)"[ItemBrowser] Recovered Templates.ButtonTemplate from Resources.");
					buttonTemplateRecovered = true;
				}
				return true;
			}
			catch (Exception ex)
			{
				reason = ex.GetType().Name + ": " + ex.Message;
				return false;
			}
		}

		private static void RemoveLocalizedTextComponent(GameObject target)
		{
			if ((Object)(object)target == (Object)null)
			{
				return;
			}
			Component[] componentsInChildren = target.GetComponentsInChildren<Component>(true);
			foreach (Component val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && string.Equals(((object)val).GetType().Name, "LocalizedText", StringComparison.Ordinal))
				{
					Object.DestroyImmediate((Object)(object)val);
				}
			}
		}

		private static bool TrySetTemplatesProperty(string propertyName, object value, out string reason)
		{
			reason = string.Empty;
			PropertyInfo property = typeof(Templates).GetProperty(propertyName, BindingFlags.Static | BindingFlags.Public);
			if (property == null)
			{
				reason = "Templates." + propertyName + " property not found";
				return false;
			}
			MethodInfo setMethod = property.GetSetMethod(nonPublic: true);
			if (setMethod == null)
			{
				reason = "Templates." + propertyName + " setter not accessible";
				return false;
			}
			setMethod.Invoke(null, new object[1] { value });
			return true;
		}

		private static void LogAvailableTemplates()
		{
			if (templatesLogged)
			{
				return;
			}
			templatesLogged = true;
			try
			{
				Type typeFromHandle = typeof(Templates);
				PropertyInfo[] properties = typeFromHandle.GetProperties(BindingFlags.Static | BindingFlags.Public);
				if (properties.Length == 0)
				{
					Log.LogInfo((object)"[ItemBrowser] Templates has no public static properties.");
					return;
				}
				PropertyInfo[] array = properties;
				foreach (PropertyInfo propertyInfo in array)
				{
					object obj = null;
					try
					{
						obj = propertyInfo.GetValue(null);
					}
					catch
					{
					}
					string text = ((obj == null) ? "null" : "ok");
					Log.LogInfo((object)("[ItemBrowser] Template " + propertyInfo.Name + " (" + propertyInfo.PropertyType.Name + ") = " + text));
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("[ItemBrowser] Failed to enumerate Templates: " + ex.GetType().Name + " " + ex.Message));
			}
		}

		private static void VerboseLog(string message)
		{
			if (configVerboseLogs != null && configVerboseLogs.Value)
			{
				Log.LogInfo((object)("[ItemBrowser] " + message));
			}
		}

		private static void WarnFallbackCategory(Item item, string displayName)
		{
			if (configVerboseLogs != null && configVerboseLogs.Value)
			{
				string text = ((item != null) ? ((Object)item).name : null) ?? "<null>";
				Log.LogWarning((object)("[ItemBrowser] Category fallback -> MiscEquipment. Prefab='" + text + "', Display='" + displayName + "'"));
			}
		}

		private static void BuildUI()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Expected O, but got Unknown
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_050e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0536: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0596: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05da: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0604: Unknown result type (might be due to invalid IL or missing references)
			//IL_0618: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0640: Unknown result type (might be due to invalid IL or missing references)
			//IL_0568: Unknown result type (might be due to invalid IL or missing references)
			//IL_0699: Unknown result type (might be due to invalid IL or missing references)
			//IL_066b: Unknown result type (might be due to invalid IL or missing references)
			//IL_084b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0852: Expected O, but got Unknown
			//IL_088b: Unknown result type (might be due to invalid IL or missing references)
			//IL_072e: Unknown result type (might be due to invalid IL or missing references)
			//IL_076c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0935: Unknown result type (might be due to invalid IL or missing references)
			//IL_0971: Unknown result type (might be due to invalid IL or missing references)
			//IL_0978: Expected O, but got Unknown
			//IL_09b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_090c: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0801: Unknown result type (might be due to invalid IL or missing references)
			//IL_080f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a62: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aeb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aff: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a23: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a39: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b21: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bcb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bdf: Unknown result type (might be due to invalid IL or missing references)
			page = MenuAPI.CreatePageWithBackground("ItemBrowserPage");
			page.OpenOnStart = false;
			page.CloseOnUICancel = true;
			page.AutoHideOnClose = true;
			PeakCustomPage? obj = page;
			object obj2 = <>c.<>9__123_0;
			if (obj2 == null)
			{
				UnityAction val = delegate
				{
					pageOpen = true;
					RefreshLanguageDependentContent();
					EnsureItemList();
					RefreshListIfNeeded();
				};
				<>c.<>9__123_0 = val;
				obj2 = (object)val;
			}
			obj.SetOnOpen((UnityAction)obj2);
			PeakCustomPage? obj3 = page;
			object obj4 = <>c.<>9__123_1;
			if (obj4 == null)
			{
				UnityAction val2 = delegate
				{
					pageOpen = false;
				};
				<>c.<>9__123_1 = val2;
				obj4 = (object)val2;
			}
			obj3.SetOnClose((UnityAction)obj4);
			PeakElement val3 = ElementExtensions.SetSize<PeakElement>(ElementExtensions.SetPosition<PeakElement>(ElementExtensions.SetAnchorMax<PeakElement>(ElementExtensions.SetAnchorMin<PeakElement>(ElementExtensions.ParentTo<PeakElement>(new GameObject("Panel").AddComponent<PeakElement>(), (Component)(object)page), new Vector2(0.5f, 0.5f)), new Vector2(0.5f, 0.5f)), Vector2.zero), new Vector2(760f, 760f));
			RectTransform component = ((Component)val3).GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				component.pivot = new Vector2(0.5f, 0.5f);
				component.anchoredPosition = Vector2.zero;
				component.sizeDelta = new Vector2(760f, 760f);
			}
			Image val4 = ((Component)val3).gameObject.AddComponent<Image>();
			((Graphic)val4).color = new Color(0.05f, 0.04f, 0.03f, 0.9f);
			Outline val5 = ((Component)val3).gameObject.AddComponent<Outline>();
			((Shadow)val5).effectColor = new Color(1f, 1f, 1f, 0.3f);
			((Shadow)val5).effectDistance = new Vector2(2f, -2f);
			((Component)val3).transform.SetAsLastSibling();
			PeakElement val6 = ElementExtensions.SetSize<PeakElement>(ElementExtensions.SetPosition<PeakElement>(ElementExtensions.SetAnchorMax<PeakElement>(ElementExtensions.SetAnchorMin<PeakElement>(ElementExtensions.ParentTo<PeakElement>(new GameObject("Header").AddComponent<PeakElement>(), (Component)(object)val3), new Vector2(0.5f, 1f)), new Vector2(0.5f, 1f)), new Vector2(0f, -16f)), new Vector2(360f, 34f));
			RectTransform component2 = ((Component)val6).GetComponent<RectTransform>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.pivot = new Vector2(0.5f, 1f);
			}
			headerTitleText = ElementExtensions.ExpandToParent<PeakText>(ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText(GetText("TITLE"), "HeaderText").SetFontSize(26f), (Component)(object)val6));
			((TMP_Text)headerTitleText.TextMesh).alignment = (TextAlignmentOptions)4098;
			lastLanguageMarker = BuildLanguageMarker();
			PeakMenuButton obj5 = ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton(GetTextOrFallback("CLOSE_BUTTON", "Close")), (Component)(object)val3);
			object obj6 = <>O.<0>__ClosePage;
			if (obj6 == null)
			{
				UnityAction val7 = ClosePage;
				<>O.<0>__ClosePage = val7;
				obj6 = (object)val7;
			}
			closeMenuButton = obj5.OnClick((UnityAction)obj6);
			RemoveLocalizedTextComponent(((Component)closeMenuButton).gameObject);
			RectTransform component3 = ((Component)closeMenuButton).GetComponent<RectTransform>();
			if ((Object)(object)component3 != (Object)null)
			{
				component3.anchorMin = new Vector2(1f, 1f);
				component3.anchorMax = new Vector2(1f, 1f);
				component3.pivot = new Vector2(1f, 1f);
				component3.anchoredPosition = new Vector2(-24f, -10f);
				component3.sizeDelta = new Vector2(82f, 32f);
			}
			closeMenuButton.SetColor(new Color(0.22f, 0.16f, 0.12f, 0.95f), false);
			closeMenuButton.SetBorderColor(new Color(0.62f, 0.54f, 0.44f, 0.55f));
			if ((Object)(object)((PeakLocalizableElement)closeMenuButton).Text != (Object)null)
			{
				((PeakLocalizableElement)closeMenuButton).Text.fontSize = 16f;
				((PeakLocalizableElement)closeMenuButton).Text.alignment = (TextAlignmentOptions)514;
				((PeakLocalizableElement)closeMenuButton).Text.textWrappingMode = (TextWrappingModes)0;
				((PeakLocalizableElement)closeMenuButton).Text.overflowMode = (TextOverflowModes)3;
				((PeakLocalizableElement)closeMenuButton).Text.margin = Vector4.zero;
				((Graphic)((PeakLocalizableElement)closeMenuButton).Text).color = new Color(0.95f, 0.92f, 0.86f, 1f);
				((Graphic)((PeakLocalizableElement)closeMenuButton).Text).raycastTarget = false;
			}
			NormalizeButtonLayout((PeakElement)(object)closeMenuButton, (Vector2?)new Vector2(82f, 32f));
			if ((Object)(object)component3 != (Object)null)
			{
				component3.anchorMin = new Vector2(1f, 1f);
				component3.anchorMax = new Vector2(1f, 1f);
				component3.pivot = new Vector2(1f, 1f);
				component3.anchoredPosition = new Vector2(-12f, -10f);
				component3.sizeDelta = new Vector2(82f, 32f);
			}
			PeakElement val8 = ElementExtensions.SetSize<PeakElement>(ElementExtensions.SetPosition<PeakElement>(ElementExtensions.SetAnchorMax<PeakElement>(ElementExtensions.SetAnchorMin<PeakElement>(ElementExtensions.ParentTo<PeakElement>(new GameObject("TopControls").AddComponent<PeakElement>(), (Component)(object)val3), new Vector2(0.5f, 1f)), new Vector2(0.5f, 1f)), new Vector2(0f, -58f)), new Vector2(720f, 166f));
			RectTransform val9 = (topControlsRect = ((Component)val8).GetComponent<RectTransform>());
			if ((Object)(object)val9 != (Object)null)
			{
				val9.pivot = new Vector2(0.5f, 1f);
			}
			Image val10 = ((Component)val8).gameObject.AddComponent<Image>();
			((Graphic)val10).color = new Color(0.11f, 0.09f, 0.07f, 0.97f);
			Outline val11 = ((Component)val8).gameObject.AddComponent<Outline>();
			((Shadow)val11).effectColor = new Color(1f, 1f, 1f, 0.2f);
			((Shadow)val11).effectDistance = new Vector2(1f, -1f);
			PeakElement val12 = ElementExtensions.SetSize<PeakElement>(ElementExtensions.SetPosition<PeakElement>(ElementExtensions.SetAnchorMax<PeakElement>(ElementExtensions.SetAnchorMin<PeakElement>(ElementExtensions.ParentTo<PeakElement>(new GameObject("SearchContainer").AddComponent<PeakElement>(), (Component)(object)val8), new Vector2(0.5f, 1f)), new Vector2(0.5f, 1f)), new Vector2(0f, -8f)), new Vector2(680f, 48f));
			RectTransform component4 = ((Component)val12).GetComponent<RectTransform>();
			if ((Object)(object)component4 != (Object)null)
			{
				component4.pivot = new Vector2(0.5f, 1f);
			}
			Image val13 = ((Component)val12).gameObject.AddComponent<Image>();
			((Graphic)val13).color = new Color(0.16f, 0.13f, 0.1f, 0.95f);
			searchInput = ElementExtensions.ExpandToParent<PeakTextInput>(ElementExtensions.ParentTo<PeakTextInput>(MenuAPI.CreateTextInput("SearchInput"), (Component)(object)val12)).SetPlaceholder(GetText("SEARCH_PLACEHOLDER")).OnValueChanged((UnityAction<string>)OnSearchChanged);
			if ((Object)(object)searchInput.InputField != (Object)null)
			{
				TMP_InputField inputField = searchInput.InputField;
				((Graphic)inputField.textComponent).color = new Color(0.42f, 0.36f, 0.3f, 1f);
				inputField.textComponent.fontSize = 30f;
				inputField.textComponent.enableAutoSizing = false;
				inputField.caretColor = new Color(0.42f, 0.36f, 0.3f, 1f);
				Graphic placeholder = inputField.placeholder;
				TMP_Text val14 = (TMP_Text)(object)((placeholder is TMP_Text) ? placeholder : null);
				if (val14 != null)
				{
					((Graphic)val14).color = new Color(0.42f, 0.36f, 0.3f, 1f);
					val14.fontSize = 30f;
					val14.enableAutoSizing = false;
					((Graphic)inputField.textComponent).color = ((Graphic)val14).color;
					inputField.textComponent.fontSize = val14.fontSize;
					inputField.textComponent.fontStyle = val14.fontStyle;
					inputField.textComponent.alignment = val14.alignment;
					inputField.caretColor = ((Graphic)val14).color;
				}
			}
			GameObject val15 = new GameObject("MajorTabs", new Type[3]
			{
				typeof(RectTransform),
				typeof(ScrollRect),
				typeof(RectMask2D)
			});
			val15.transform.SetParent(((Component)val8).transform, false);
			majorTabs = val15.AddComponent<PeakHorizontalTabs>();
			majorTabs.SetBackgroundColor(new Color(0.18f, 0.14f, 0.1f, 0.95f));
			RectTransform component5 = val15.GetComponent<RectTransform>();
			if ((Object)(object)component5 != (Object)null)
			{
				component5.anchorMin = new Vector2(0.5f, 1f);
				component5.anchorMax = new Vector2(0.5f, 1f);
				component5.pivot = new Vector2(0.5f, 1f);
				component5.anchoredPosition = new Vector2(0f, -56f);
				component5.sizeDelta = new Vector2(680f, 44f);
			}
			Image val16 = val15.AddComponent<Image>();
			((Graphic)val16).color = new Color(0.16f, 0.13f, 0.1f, 0.95f);
			GameObject val17 = new GameObject("SubCategoryTabs", new Type[3]
			{
				typeof(RectTransform),
				typeof(ScrollRect),
				typeof(RectMask2D)
			});
			val17.transform.SetParent(((Component)val8).transform, false);
			subCategoryTabsRoot = val17;
			subCategoryTabs = val17.AddComponent<PeakHorizontalTabs>();
			subCategoryTabs.SetBackgroundColor(new Color(0.18f, 0.14f, 0.1f, 0.95f));
			RectTransform component6 = val17.GetComponent<RectTransform>();
			if ((Object)(object)component6 != (Object)null)
			{
				component6.anchorMin = new Vector2(0.5f, 1f);
				component6.anchorMax = new Vector2(0.5f, 1f);
				component6.pivot = new Vector2(0.5f, 1f);
				component6.anchoredPosition = new Vector2(0f, -100f);
				component6.sizeDelta = new Vector2(680f, 44f);
			}
			Image val18 = val17.AddComponent<Image>();
			((Graphic)val18).color = new Color(0.16f, 0.13f, 0.1f, 0.95f);
			BuildMajorTabs(majorTabs);
			RebuildSubCategoryTabs();
			UpdateSubCategoryVisibility();
			ConfigureTabsContentLayout(val15.transform.Find("Content"), 0f, forceExpandWidth: true);
			ConfigureTabsContentLayout(val17.transform.Find("Content"), 0f, forceExpandWidth: false);
			PeakElement val19 = ElementExtensions.SetOffsetMax<PeakElement>(ElementExtensions.SetOffsetMin<PeakElement>(ElementExtensions.SetAnchorMax<PeakElement>(ElementExtensions.SetAnchorMin<PeakElement>(ElementExtensions.ParentTo<PeakElement>(new GameObject("ListContainer").AddComponent<PeakElement>(), (Component)(object)val3), new Vector2(0f, 0f)), new Vector2(1f, 1f)), new Vector2(20f, 20f)), new Vector2(-20f, (currentMajorFilter == MajorCategory.All) ? (-192f) : (-236f)));
			listContainerRect = ((Component)val19).GetComponent<RectTransform>();
			Image val20 = ((Component)val19).gameObject.AddComponent<Image>();
			((Graphic)val20).color = new Color(0.11f, 0.09f, 0.07f, 0.95f);
			Outline val21 = ((Component)val19).gameObject.AddComponent<Outline>();
			((Shadow)val21).effectColor = new Color(1f, 1f, 1f, 0.14f);
			((Shadow)val21).effectDistance = new Vector2(1f, -1f);
			scrollContent = ElementExtensions.SetOffsetMax<PeakScrollableContent>(ElementExtensions.SetOffsetMin<PeakScrollableContent>(ElementExtensions.ExpandToParent<PeakScrollableContent>(ElementExtensions.ParentTo<PeakScrollableContent>(MenuAPI.CreateScrollableContent("ItemList"), (Component)(object)val19)), new Vector2(12f, 12f)), new Vector2(-26f, -12f));
			listScrollRect = ((Component)scrollContent).GetComponent<ScrollRect>();
			if ((Object)(object)listScrollRect != (Object)null)
			{
				((UnityEvent<Vector2>)(object)listScrollRect.onValueChanged).AddListener((UnityAction<Vector2>)delegate
				{
					OnVirtualizedScrollChanged();
				});
			}
			SetupListScrollbar(val19);
			EnsureListLayoutReady();
			UpdateItemGridCellSize();
			((Component)page).gameObject.SetActive(false);
			MarkListDirty("UI built");
		}

		private static RectTransform? GetListContent()
		{
			if ((Object)(object)scrollContent == (Object)null)
			{
				return null;
			}
			if ((Object)(object)scrollContent.Content != (Object)null)
			{
				return scrollContent.Content;
			}
			Transform obj = ((Component)scrollContent).transform.Find("Content");
			return (RectTransform?)(object)((obj is RectTransform) ? obj : null);
		}

		private static void EnsureListLayoutReady()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			RectTransform listContent = GetListContent();
			if ((Object)(object)listContent == (Object)null)
			{
				return;
			}
			VerticalLayoutGroup component = ((Component)listContent).GetComponent<VerticalLayoutGroup>();
			if ((Object)(object)component != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component);
			}
			ContentSizeFitter component2 = ((Component)listContent).GetComponent<ContentSizeFitter>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component2);
			}
			listContent.anchorMin = new Vector2(0f, 1f);
			listContent.anchorMax = new Vector2(1f, 1f);
			listContent.pivot = new Vector2(0.5f, 1f);
			Vector2 anchoredPosition = listContent.anchoredPosition;
			anchoredPosition.x = 0f;
			if (!suppressScrollUpdate)
			{
				anchoredPosition.y = Mathf.Max(0f, anchoredPosition.y);
			}
			listContent.anchoredPosition = anchoredPosition;
			itemGridLayout = ((Component)listContent).GetComponent<GridLayoutGroup>();
			if ((Object)(object)itemGridLayout == (Object)null)
			{
				try
				{
					itemGridLayout = ((Component)listContent).gameObject.AddComponent<GridLayoutGroup>();
				}
				catch (Exception ex)
				{
					Log.LogError((object)("[ItemBrowser] Failed to add GridLayoutGroup: " + ex.GetType().Name + " " + ex.Message));
					return;
				}
			}
			if (!((Object)(object)itemGridLayout == (Object)null))
			{
				itemGridLayout.constraint = (Constraint)1;
				itemGridLayout.constraintCount = 2;
				itemGridLayout.spacing = new Vector2(12f, 8f);
				itemGridLayout.startAxis = (Axis)0;
				itemGridLayout.startCorner = (Corner)0;
				((LayoutGroup)itemGridLayout).childAlignment = (TextAnchor)0;
			}
		}

		private static void ConfigureTabsContentLayout(Transform? tabsContent, float spacing, bool forceExpandWidth)
		{
			if (!((Object)(object)tabsContent == (Object)null))
			{
				HorizontalLayoutGroup component = ((Component)tabsContent).GetComponent<HorizontalLayoutGroup>();
				if ((Object)(object)component != (Object)null)
				{
					((HorizontalOrVerticalLayoutGroup)component).spacing = spacing;
					((LayoutGroup)component).childAlignment = (TextAnchor)4;
					((HorizontalOrVerticalLayoutGroup)component).childControlWidth = true;
					((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth = forceExpandWidth;
					((HorizontalOrVerticalLayoutGroup)component).childControlHeight = true;
					((HorizontalOrVerticalLayoutGroup)component).childForceExpandHeight = true;
				}
				ContentSizeFitter component2 = ((Component)tabsContent).GetComponent<ContentSizeFitter>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.horizontalFit = (FitMode)2;
				}
			}
		}

		private static void UpdateItemGridCellSize()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			EnsureListLayoutReady();
			RectTransform listContent = GetListContent();
			if (!((Object)(object)itemGridLayout == (Object)null) && !((Object)(object)listContent == (Object)null))
			{
				Rect rect = listContent.rect;
				float num = ((Rect)(ref rect)).width;
				if (num <= 0f)
				{
					num = 680f;
				}
				int num2 = Math.Max(1, itemGridLayout.constraintCount);
				float num3 = ((LayoutGroup)itemGridLayout).padding.left + ((LayoutGroup)itemGridLayout).padding.right;
				float num4 = itemGridLayout.spacing.x * (float)(num2 - 1);
				float num5 = (num - num3 - num4) / (float)num2;
				num5 = Mathf.Clamp(num5, 320f, 420f);
				itemGridLayout.cellSize = new Vector2(num5, 72f);
				((LayoutGroup)itemGridLayout).padding = new RectOffset(4, 4, 4, 4);
			}
		}

		private static void SetupListScrollbar(PeakElement listContainer)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Expected O, but got Unknown
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)scrollContent == (Object)null) && !((Object)(object)listContainer == (Object)null))
			{
				ScrollRect component = ((Component)scrollContent).GetComponent<ScrollRect>();
				if (!((Object)(object)component == (Object)null))
				{
					GameObject val = new GameObject("ListScrollbar", new Type[3]
					{
						typeof(RectTransform),
						typeof(Image),
						typeof(Scrollbar)
					});
					val.transform.SetParent(((Component)listContainer).transform, false);
					RectTransform component2 = val.GetComponent<RectTransform>();
					component2.anchorMin = new Vector2(1f, 0f);
					component2.anchorMax = new Vector2(1f, 1f);
					component2.pivot = new Vector2(1f, 1f);
					component2.offsetMin = new Vector2(-12f, 12f);
					component2.offsetMax = new Vector2(-4f, -12f);
					Image component3 = val.GetComponent<Image>();
					((Graphic)component3).color = new Color(0.18f, 0.14f, 0.1f, 0.95f);
					((Graphic)component3).raycastTarget = true;
					GameObject val2 = new GameObject("Sliding Area", new Type[1] { typeof(RectTransform) });
					val2.transform.SetParent(val.transform, false);
					RectTransform component4 = val2.GetComponent<RectTransform>();
					component4.anchorMin = Vector2.zero;
					component4.anchorMax = Vector2.one;
					component4.offsetMin = new Vector2(1f, 1f);
					component4.offsetMax = new Vector2(-1f, -1f);
					GameObject val3 = new GameObject("Handle", new Type[2]
					{
						typeof(RectTransform),
						typeof(Image)
					});
					val3.transform.SetParent(val2.transform, false);
					RectTransform component5 = val3.GetComponent<RectTransform>();
					component5.anchorMin = new Vector2(0f, 0f);
					component5.anchorMax = new Vector2(1f, 1f);
					component5.offsetMin = Vector2.zero;
					component5.offsetMax = Vector2.zero;
					Image component6 = val3.GetComponent<Image>();
					((Graphic)component6).color = new Color(0.92f, 0.88f, 0.8f, 0.95f);
					((Graphic)component6).raycastTarget = true;
					listScrollbar = val.GetComponent<Scrollbar>();
					listScrollbar.direction = (Direction)2;
					listScrollbar.handleRect = component5;
					((Selectable)listScrollbar).targetGraphic = (Graphic)(object)component6;
					listScrollbar.size = 0.2f;
					component.verticalScrollbar = listScrollbar;
					component.verticalScrollbarVisibility = (ScrollbarVisibility)0;
					component.verticalScrollbarSpacing = 2f;
					component.movementType = (MovementType)2;
					component.elasticity = 0f;
					component.inertia = true;
				}
			}
		}

		private static void OnSearchChanged(string query)
		{
			currentSearch = query ?? string.Empty;
			MarkListDirty();
			RefreshList();
		}

		private static void MarkListDirty(string? reason = null)
		{
			listNeedsRefresh = true;
			listRenderRunning = false;
			listRenderGeneration++;
			if (listRenderCoroutine != null && (Object)(object)instance != (Object)null)
			{
				((MonoBehaviour)instance).StopCoroutine(listRenderCoroutine);
				listRenderCoroutine = null;
			}
			firstOpenPrimed = false;
			postSpawnPrimeLocked = false;
			if (!string.IsNullOrWhiteSpace(reason))
			{
				VerboseLog("List marked dirty: " + reason);
			}
		}

		private static void RefreshListIfNeeded(bool force = false)
		{
			if (force || listNeedsRefresh)
			{
				RefreshList();
			}
		}

		private static void RefreshList()
		{
			if ((Object)(object)scrollContent == (Object)null)
			{
				return;
			}
			UpdateItemGridCellSize();
			RectTransform listContent = GetListContent();
			if ((Object)(object)listContent == (Object)null)
			{
				Log.LogWarning((object)"[ItemBrowser] Scroll content not ready yet.");
				return;
			}
			CancelListRender();
			HideAllPooledItemButtons();
			ClearStatusTextOverlay();
			if (!itemListInitialized)
			{
				EnsureItemList();
				AddStatusText(GetPreloadStatusText());
				return;
			}
			IEnumerable<ItemEntry> source = itemEntries;
			string search = currentSearch.Trim().ToLowerInvariant();
			if (!string.IsNullOrEmpty(search))
			{
				source = source.Where((ItemEntry entry) => entry.SearchText.Contains(search));
			}
			source = source.Where((ItemEntry entry) => IsEntryInMajorCategory(entry, currentMajorFilter));
			if (currentSubCategoryFilter.HasValue)
			{
				source = source.Where((ItemEntry entry) => entry.Category == currentSubCategoryFilter.Value);
			}
			List<ItemEntry> list = source.ToList();
			if (list.Count == 0)
			{
				activeRenderEntries.Clear();
				virtualizedFirstDataIndex = -1;
				ResetVirtualizedContentHeight(0);
				HideAllPooledItemButtons();
				AddStatusText(GetText("STATUS_EMPTY"));
				listNeedsRefresh = false;
				listRenderRunning = false;
				return;
			}
			if (currentSubCategoryFilter.HasValue)
			{
				list = list.OrderBy((ItemEntry entry) => entry.DisplayName).ToList();
			}
			activeRenderEntries.Clear();
			activeRenderEntries.AddRange(list);
			listNeedsRefresh = false;
			StartListRender(listContent, list);
		}

		private static void StartListRender(RectTransform listContent, List<ItemEntry> entries)
		{
			if ((Object)(object)listContent == (Object)null)
			{
				return;
			}
			int val = CalculateVirtualizedVisiblePoolTarget();
			buttonPoolWarmupTargetCount = Math.Max(buttonPoolWarmupTargetCount, val);
			ResetVirtualizedContentHeight(entries.Count);
			ResetVirtualizedScrollTop();
			int generation = ++listRenderGeneration;
			if ((Object)(object)instance == (Object)null)
			{
				int num = Math.Min(entries.Count, val);
				for (int i = 0; i < num; i++)
				{
					RenderVirtualizedSlot(i, i, entries[i]);
				}
				UpdateVirtualizedVisibleWindow(force: true);
				listRenderRunning = false;
			}
			else
			{
				listRenderRunning = true;
				listRenderCoroutine = ((MonoBehaviour)instance).StartCoroutine(RenderListGradually(generation, entries));
			}
		}

		[IteratorStateMachine(typeof(<RenderListGradually>d__134))]
		private static IEnumerator RenderListGradually(int generation, List<ItemEntry> entries)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <RenderListGradually>d__134(0)
			{
				generation = generation,
				entries = entries
			};
		}

		private static int CalculateVirtualizedVisiblePoolTarget()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			float num = 560f;
			Rect rect;
			if ((Object)(object)listScrollRect != (Object)null && (Object)(object)listScrollRect.viewport != (Object)null)
			{
				rect = listScrollRect.viewport.rect;
				num = Mathf.Max(((Rect)(ref rect)).height, 72f);
			}
			else if ((Object)(object)listContainerRect != (Object)null)
			{
				rect = listContainerRect.rect;
				num = Mathf.Max(((Rect)(ref rect)).height - 24f, 72f);
			}
			float num2 = 80f;
			int num3 = Mathf.Max(1, Mathf.CeilToInt((num + 8f) / num2));
			int num4 = num3 + 4;
			return Mathf.Max(4, num4 * 2);
		}

		private static void ResetVirtualizedContentHeight(int itemCount)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			RectTransform listContent = GetListContent();
			if (!((Object)(object)listContent == (Object)null))
			{
				int num = ((itemCount > 0) ? ((itemCount + 2 - 1) / 2) : 0);
				Rect rect = listContent.rect;
				float num2 = ((Rect)(ref rect)).width;
				if (num2 <= 0f && (Object)(object)listScrollRect != (Object)null && (Object)(object)listScrollRect.viewport != (Object)null)
				{
					rect = listScrollRect.viewport.rect;
					num2 = ((Rect)(ref rect)).width;
				}
				if (num2 <= 0f)
				{
					num2 = 680f;
				}
				float num3 = num2 - 8f - 12f;
				virtualizedCellWidth = Mathf.Clamp(num3 / 2f, 320f, 420f);
				float num4 = 8f;
				if (num > 0)
				{
					num4 += (float)num * 72f + (float)(num - 1) * 8f;
				}
				if ((Object)(object)listScrollRect != (Object)null && (Object)(object)listScrollRect.viewport != (Object)null)
				{
					float num5 = num4;
					rect = listScrollRect.viewport.rect;
					num4 = Mathf.Max(num5, ((Rect)(ref rect)).height + 1f);
				}
				Vector2 sizeDelta = listContent.sizeDelta;
				sizeDelta.y = num4;
				listContent.sizeDelta = sizeDelta;
				if ((Object)(object)itemGridLayout != (Object)null)
				{
					((Behaviour)itemGridLayout).enabled = false;
				}
				ClampVirtualizedContentPosition(listContent, num4);
			}
		}

		private static void ResetVirtualizedScrollTop()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)listScrollRect == (Object)null)
			{
				virtualizedFirstDataIndex = -1;
				return;
			}
			suppressScrollUpdate = true;
			listScrollRect.StopMovement();
			listScrollRect.verticalNormalizedPosition = 1f;
			RectTransform listContent = GetListContent();
			if ((Object)(object)listContent != (Object)null)
			{
				Vector2 anchoredPosition = listContent.anchoredPosition;
				if (anchoredPosition.y != 0f)
				{
					anchoredPosition.y = 0f;
					listContent.anchoredPosition = anchoredPosition;
				}
			}
			suppressScrollUpdate = false;
			virtualizedFirstDataIndex = -1;
		}

		private static void OnVirtualizedScrollChanged()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (!suppressScrollUpdate && !listRenderRunning)
			{
				virtualizedScrollDirty = true;
				float unscaledTime = Time.unscaledTime;
				if (Mathf.Abs(Input.mouseScrollDelta.y) > 0.001f && unscaledTime >= nextVirtualizedScrollApplyTime)
				{
					nextVirtualizedScrollApplyTime = unscaledTime + 0.02f;
					UpdateVirtualizedVisibleWindow(force: false);
				}
			}
		}

		private static void UpdateVirtualizedVisibleWindow(bool force)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			if (activeRenderEntries.Count == 0 || (Object)(object)scrollContent == (Object)null)
			{
				HideAllPooledItemButtons();
				virtualizedFirstDataIndex = -1;
				virtualizedScrollDirty = false;
				nextVirtualizedScrollApplyTime = Time.unscaledTime + 0.02f;
				return;
			}
			RectTransform listContent = GetListContent();
			if ((Object)(object)listContent == (Object)null)
			{
				return;
			}
			int num = CalculateVirtualizedVisiblePoolTarget();
			int num2 = Mathf.Max(0, activeRenderEntries.Count - num);
			float num3 = Mathf.Max(0f, listContent.anchoredPosition.y - 4f);
			float num4 = 80f;
			int num5 = Mathf.Max(0, Mathf.FloorToInt(num3 / num4) - 2);
			int num6 = Mathf.Clamp(num5 * 2, 0, num2);
			if (num6 % 2 != 0)
			{
				num6--;
			}
			if (!force && num6 == virtualizedFirstDataIndex && itemButtonPool.Count >= num)
			{
				return;
			}
			int num7 = Mathf.Min(num, activeRenderEntries.Count - num6);
			int num8 = virtualizedFirstDataIndex;
			int num9 = ((num8 >= 0) ? (num8 + Mathf.Min(num, activeRenderEntries.Count - num8) - 1) : (-1));
			int num10 = ((num7 > 0) ? (num6 + num7 - 1) : (-1));
			if (!force && num8 >= 0 && num10 >= 0 && num6 != num8 && num10 >= num8 && num6 <= num9 && BindVirtualizedWindowIncremental(num8, num9, num6, num10, num7))
			{
				virtualizedFirstDataIndex = num6;
				return;
			}
			for (int i = 0; i < num7; i++)
			{
				int num11 = num6 + i;
				RenderVirtualizedSlot(i, num11, activeRenderEntries[num11]);
			}
			for (int j = num7; j < itemButtonPool.Count; j++)
			{
				((Component)itemButtonPool[j].Button).gameObject.SetActive(false);
			}
			virtualizedFirstDataIndex = num6;
			virtualizedScrollDirty = false;
			float y = listContent.sizeDelta.y;
			ClampVirtualizedContentPosition(listContent, y);
		}

		private static void ClampVirtualizedContentPosition(RectTransform listContent, float contentHeight)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)listScrollRect == (Object)null) && !((Object)(object)listScrollRect.viewport == (Object)null))
			{
				Rect rect = listScrollRect.viewport.rect;
				float num = Mathf.Max(1f, ((Rect)(ref rect)).height);
				float num2 = Mathf.Max(0f, contentHeight - num);
				Vector2 anchoredPosition = listContent.anchoredPosition;
				float num3 = Mathf.Clamp(anchoredPosition.y, 0f, num2);
				if (!Mathf.Approximately(num3, anchoredPosition.y))
				{
					anchoredPosition.y = num3;
					listContent.anchoredPosition = anchoredPosition;
				}
			}
		}

		private static bool BindVirtualizedWindowIncremental(int previousFirstIndex, int previousLastIndex, int currentFirstIndex, int currentLastIndex, int renderCount)
		{
			virtualizedPendingDataIndices.Clear();
			virtualizedFreePoolButtons.Clear();
			for (int i = currentFirstIndex; i <= currentLastIndex; i++)
			{
				if (i < previousFirstIndex || i > previousLastIndex)
				{
					virtualizedPendingDataIndices.Add(i);
				}
			}
			if (virtualizedPendingDataIndices.Count == 0)
			{
				return true;
			}
			int num = Mathf.Min(itemButtonPool.Count, renderCount);
			for (int j = 0; j < num; j++)
			{
				PooledItemButton pooledItemButton = itemButtonPool[j];
				int boundDataIndex = pooledItemButton.BoundDataIndex;
				if (boundDataIndex < currentFirstIndex || boundDataIndex > currentLastIndex)
				{
					virtualizedFreePoolButtons.Add(pooledItemButton);
				}
			}
			int num2 = Mathf.Min(virtualizedPendingDataIndices.Count, virtualizedFreePoolButtons.Count);
			if (num2 < virtualizedPendingDataIndices.Count)
			{
				return false;
			}
			for (int k = 0; k < num2; k++)
			{
				int num3 = virtualizedPendingDataIndices[k];
				PooledItemButton pooledItemButton2 = virtualizedFreePoolButtons[k];
				pooledItemButton2.BoundDataIndex = -1;
				RenderVirtualizedSlotByButton(pooledItemButton2, num3, activeRenderEntries[num3]);
			}
			return true;
		}

		private static void RenderVirtualizedSlotByButton(PooledItemButton pooled, int dataIndex, ItemEntry entry)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			if (pooled != null)
			{
				if (!((Component)pooled.Button).gameObject.activeSelf)
				{
					((Component)pooled.Button).gameObject.SetActive(true);
				}
				if ((Object)(object)((PeakLocalizableElement)pooled.Button).Text != (Object)null)
				{
					((PeakLocalizableElement)pooled.Button).Text.text = entry.DisplayName;
				}
				pooled.Binder.Prefab = entry.Prefab;
				Sprite val = ResolveEntryIcon(entry);
				pooled.IconImage.sprite = val;
				((Graphic)pooled.IconImage).color = (Color)(((Object)(object)val != (Object)null) ? Color.white : new Color(0.48f, 0.42f, 0.35f, 0.45f));
				pooled.BoundDataIndex = dataIndex;
				if (pooled.PoolIndex >= 0)
				{
					PositionVirtualizedButton(pooled.PoolIndex, dataIndex);
				}
			}
		}

		private static void RenderVirtualizedSlot(int poolIndex, int dataIndex, ItemEntry entry)
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			if (poolIndex < 0)
			{
				return;
			}
			RectTransform listContent = GetListContent();
			if ((Object)(object)listContent == (Object)null)
			{
				return;
			}
			PooledItemButton pooledItemButton = EnsurePooledItemButton(poolIndex, listContent);
			if (!((Component)pooledItemButton.Button).gameObject.activeSelf)
			{
				((Component)pooledItemButton.Button).gameObject.SetActive(true);
			}
			if (pooledItemButton.BoundDataIndex != dataIndex)
			{
				if ((Object)(object)((PeakLocalizableElement)pooledItemButton.Button).Text != (Object)null)
				{
					((PeakLocalizableElement)pooledItemButton.Button).Text.text = entry.DisplayName;
				}
				pooledItemButton.Binder.Prefab = entry.Prefab;
				Sprite val = ResolveEntryIcon(entry);
				pooledItemButton.IconImage.sprite = val;
				((Graphic)pooledItemButton.IconImage).color = (Color)(((Object)(object)val != (Object)null) ? Color.white : new Color(0.48f, 0.42f, 0.35f, 0.45f));
				pooledItemButton.BoundDataIndex = dataIndex;
			}
			PositionVirtualizedButton(poolIndex, dataIndex);
		}

		private static void PositionVirtualizedButton(int poolIndex, int dataIndex)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			if (poolIndex < 0 || poolIndex >= itemButtonPool.Count)
			{
				return;
			}
			RectTransform buttonRect = itemButtonPool[poolIndex].ButtonRect;
			if (!((Object)(object)buttonRect == (Object)null))
			{
				int num = dataIndex / 2;
				int num2 = dataIndex % 2;
				float num3 = 4f + (float)num2 * (virtualizedCellWidth + 12f);
				float num4 = 4f + (float)num * 80f;
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(0f, 1f);
				if (buttonRect.anchorMin != val)
				{
					buttonRect.anchorMin = val;
				}
				if (buttonRect.anchorMax != val)
				{
					buttonRect.anchorMax = val;
				}
				if (buttonRect.pivot != val)
				{
					buttonRect.pivot = val;
				}
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor(virtualizedCellWidth, 72f);
				if (buttonRect.sizeDelta != val2)
				{
					buttonRect.sizeDelta = val2;
				}
				Vector2 val3 = default(Vector2);
				((Vector2)(ref val3))..ctor(num3, 0f - num4);
				if (buttonRect.anchoredPosition != val3)
				{
					buttonRect.anchoredPosition = val3;
				}
				if (((Transform)buttonRect).localScale != Vector3.one)
				{
					((Transform)buttonRect).localScale = Vector3.one;
				}
			}
		}

		private static void CancelListRender()
		{
			listRenderGeneration++;
			if (listRenderCoroutine != null && (Object)(object)instance != (Object)null)
			{
				((MonoBehaviour)instance).StopCoroutine(listRenderCoroutine);
				listRenderCoroutine = null;
			}
			listRenderRunning = false;
		}

		private static PooledItemButton EnsurePooledItemButton(int index, RectTransform listContent)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			while (itemButtonPool.Count <= index)
			{
				PeakMenuButton obj = ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton(string.Empty), (Transform)(object)listContent);
				object obj2 = <>c.<>9__146_0;
				if (obj2 == null)
				{
					UnityAction val = delegate
					{
					};
					<>c.<>9__146_0 = val;
					obj2 = (object)val;
				}
				PeakMenuButton val2 = obj.OnClick((UnityAction)obj2);
				RectTransform component = ((Component)val2).GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					component.anchorMin = new Vector2(0f, 1f);
					component.anchorMax = new Vector2(1f, 1f);
					component.pivot = new Vector2(0.5f, 0.5f);
					component.sizeDelta = new Vector2(0f, 72f);
					((Transform)component).localScale = Vector3.one;
				}
				LayoutElement val3 = ((Component)val2).gameObject.GetComponent<LayoutElement>();
				if ((Object)(object)val3 == (Object)null)
				{
					val3 = ((Component)val2).gameObject.AddComponent<LayoutElement>();
				}
				val3.preferredHeight = 72f;
				val3.minHeight = 72f;
				val3.flexibleHeight = 0f;
				val3.preferredWidth = 0f;
				val3.minWidth = 0f;
				val3.flexibleWidth = 0f;
				Image iconImage = CreateItemIconImage(val2);
				ApplyItemButtonStyle(val2);
				NormalizeButtonLayout((PeakElement)(object)val2);
				ItemButtonBinder itemButtonBinder = ((Component)val2).gameObject.GetComponent<ItemButtonBinder>();
				if ((Object)(object)itemButtonBinder == (Object)null)
				{
					itemButtonBinder = ((Component)val2).gameObject.AddComponent<ItemButtonBinder>();
				}
				if ((Object)(object)val2.Button != (Object)null)
				{
					((UnityEventBase)val2.Button.onClick).RemoveAllListeners();
					((UnityEvent)val2.Button.onClick).AddListener(new UnityAction(itemButtonBinder.HandleClick));
				}
				((Component)val2).gameObject.SetActive(false);
				RectTransform buttonRect = component ?? ((Component)val2).GetComponent<RectTransform>();
				itemButtonPool.Add(new PooledItemButton(val2, buttonRect, iconImage, itemButtonBinder, itemButtonPool.Count));
			}
			return itemButtonPool[index];
		}

		private static void HideAllPooledItemButtons()
		{
			for (int i = 0; i < itemButtonPool.Count; i++)
			{
				((Component)itemButtonPool[i].Button).gameObject.SetActive(false);
				itemButtonPool[i].BoundDataIndex = -1;
			}
		}

		private static void AddCategoryHeader(ItemCategory category)
		{
			if (!((Object)(object)scrollContent == (Object)null))
			{
				RectTransform listContent = GetListContent();
				if (!((Object)(object)listContent == (Object)null))
				{
					string categoryLabel = GetCategoryLabel(category);
					ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText(categoryLabel).SetFontSize(22f), (Transform)(object)listContent);
				}
			}
		}

		private static void RenderOrReuseItemButton(int index, ItemEntry entry)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)scrollContent == (Object)null)
			{
				return;
			}
			RectTransform listContent = GetListContent();
			if (!((Object)(object)listContent == (Object)null))
			{
				PooledItemButton pooledItemButton = EnsurePooledItemButton(index, listContent);
				PeakMenuButton button = pooledItemButton.Button;
				((Component)button).gameObject.SetActive(true);
				RectTransform component = ((Component)button).GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					component.anchorMin = new Vector2(0f, 1f);
					component.anchorMax = new Vector2(1f, 1f);
					component.pivot = new Vector2(0.5f, 0.5f);
					component.sizeDelta = new Vector2(0f, 72f);
					((Transform)component).localScale = Vector3.one;
				}
				if ((Object)(object)((PeakLocalizableElement)button).Text != (Object)null)
				{
					((PeakLocalizableElement)button).Text.text = entry.DisplayName;
				}
				pooledItemButton.Binder.Prefab = entry.Prefab;
				Sprite val = ResolveEntryIcon(entry);
				pooledItemButton.IconImage.sprite = val;
				((Graphic)pooledItemButton.IconImage).color = (Color)(((Object)(object)val != (Object)null) ? Color.white : new Color(0.48f, 0.42f, 0.35f, 0.45f));
			}
		}

		private static Sprite? ResolveEntryIcon(ItemEntry entry)
		{
			if ((Object)(object)entry.Icon != (Object)null)
			{
				return entry.Icon;
			}
			TryStartBackgroundIconPrewarm("VisibleEntryFallback");
			return null;
		}

		private static void ApplyItemButtonStyle(PeakMenuButton button)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)button == (Object)null))
			{
				Color val = default(Color);
				((Color)(ref val))..ctor(0.18f, 0.14f, 0.1f, 0.96f);
				Color borderColor = default(Color);
				((Color)(ref borderColor))..ctor(0.6f, 0.52f, 0.42f, 0.6f);
				Color color = default(Color);
				((Color)(ref color))..ctor(0.95f, 0.92f, 0.86f, 1f);
				button.SetColor(val, false);
				button.SetBorderColor(borderColor);
				if ((Object)(object)button.Button != (Object)null && (Object)(object)button.Panel != (Object)null)
				{
					((Selectable)button.Button).targetGraphic = (Graphic)(object)button.Panel;
					ColorBlock colors = ((Selectable)button.Button).colors;
					((ColorBlock)(ref colors)).normalColor = Color.white;
					((ColorBlock)(ref colors)).highlightedColor = Color.white;
					((ColorBlock)(ref colors)).pressedColor = new Color(0.92f, 0.88f, 0.8f, 1f);
					((ColorBlock)(ref colors)).selectedColor = Color.white;
					((ColorBlock)(ref colors)).disabledColor = new Color(1f, 1f, 1f, 0.35f);
					((Selectable)button.Button).colors = colors;
				}
				if ((Object)(object)((PeakLocalizableElement)button).Text != (Object)null)
				{
					((Graphic)((PeakLocalizableElement)button).Text).color = color;
					((PeakLocalizableElement)button).Text.fontSize = 20f;
					((PeakLocalizableElement)button).Text.enableAutoSizing = false;
					((PeakLocalizableElement)button).Text.alignment = (TextAlignmentOptions)4097;
					((PeakLocalizableElement)button).Text.margin = new Vector4(78f, 0f, 12f, 0f);
					((Graphic)((PeakLocalizableElement)button).Text).raycastTarget = false;
				}
			}
		}

		private static Image CreateItemIconImage(PeakMenuButton button)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)button == (Object)null)
			{
				throw new ArgumentNullException("button");
			}
			GameObject val = new GameObject("ItemIcon", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val.transform.SetParent(((Component)button).transform, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0.5f);
			component.anchorMax = new Vector2(0f, 0.5f);
			component.pivot = new Vector2(0f, 0.5f);
			component.anchoredPosition = new Vector2(14f, 0f);
			component.sizeDelta = new Vector2(48f, 48f);
			Image component2 = val.GetComponent<Image>();
			component2.preserveAspect = true;
			((Graphic)component2).raycastTarget = false;
			return component2;
		}

		private static void ClearStatusTextOverlay()
		{
			if (!((Object)(object)scrollContent == (Object)null))
			{
				Transform val = ((Component)scrollContent).transform.Find("StatusOverlay");
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
		}

		private static void AddStatusText(string text)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)scrollContent == (Object)null))
			{
				ClearStatusTextOverlay();
				GameObject val = new GameObject("StatusOverlay", new Type[1] { typeof(RectTransform) });
				val.transform.SetParent(((Component)scrollContent).transform, false);
				RectTransform component = val.GetComponent<RectTransform>();
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
				PeakText val2 = ElementExtensions.ExpandToParent<PeakText>(ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText(text).SetFontSize(30f), val.transform));
				((TMP_Text)val2.TextMesh).alignment = (TextAlignmentOptions)514;
				((Graphic)val2.TextMesh).color = new Color(0.9f, 0.86f, 0.78f, 1f);
				((TMP_Text)val2.TextMesh).enableAutoSizing = false;
				((Graphic)val2.TextMesh).raycastTarget = false;
			}
		}

		private static void AddSpacer(float height)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			if (!((Object)(object)scrollContent == (Object)null))
			{
				RectTransform listContent = GetListContent();
				if (!((Object)(object)listContent == (Object)null))
				{
					GameObject val = new GameObject("Spacer", new Type[2]
					{
						typeof(RectTransform),
						typeof(LayoutElement)
					});
					LayoutElement component = val.GetComponent<LayoutElement>();
					component.minHeight = height;
					component.preferredHeight = height;
					val.transform.SetParent((Transform)(object)listContent, false);
				}
			}
		}

		private static void ClearContent(Transform content)
		{
			for (int num = content.childCount - 1; num >= 0; num--)
			{
				Object.Destroy((Object)(object)((Component)content.GetChild(num)).gameObject);
			}
		}

		private static void EnsureItemList()
		{
			if (!itemListInitialized && !itemP