Decompiled source of Days of the Week v1.4.4

BepInEx/plugins/DaysOfTheWeek/DaysOfTheWeek.dll

Decompiled 16 hours 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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DaysOfTheWeek.Ui;
using HarmonyLib;
using I2.Loc;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Days of the Week")]
[assembly: AssemblyDescription("A weekly calendar and additive customer traffic.")]
[assembly: AssemblyCompany("Dimwit's")]
[assembly: AssemblyProduct("Days of the Week")]
[assembly: AssemblyCopyright("Copyright (c) 2026 Dimwit's")]
[assembly: AssemblyVersion("1.0.3.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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;
		}
	}
}
namespace DaysOfTheWeek
{
	internal static class Art
	{
		private static readonly Dictionary<string, Sprite?> Cache = new Dictionary<string, Sprite>();

		private static readonly string[] TierFiles = new string[4] { "tier_1_hole_in_the_wall", "tier_2_neighborhood_shop", "tier_3_destination_store", "tier_4_collectors_paradise" };

		public static Sprite? Tier(int tier)
		{
			return Get(TierFiles[Math.Max(0, Math.Min(tier, TierFiles.Length - 1))]);
		}

		public static Sprite? Get(string name)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_00ac: 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)
			if (Cache.TryGetValue(name, out Sprite value))
			{
				return value;
			}
			Sprite val = null;
			try
			{
				string path = Path.Combine(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location) ?? "", "art"), name + ".png");
				if (File.Exists(path))
				{
					Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, true)
					{
						filterMode = (FilterMode)2,
						wrapMode = (TextureWrapMode)1,
						name = "DaysOfTheWeek_" + name
					};
					if (ImageConversion.LoadImage(val2, File.ReadAllBytes(path)))
					{
						Object.DontDestroyOnLoad((Object)(object)val2);
						val = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f);
						((Object)val).name = "DaysOfTheWeek_" + name;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Couldn't load art/" + name + ".png: " + ex.Message));
			}
			Cache[name] = val;
			return val;
		}
	}
	public static class CalendarRules
	{
		public static readonly string[] Names = new string[7] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };

		private static readonly double[] Baseline = new double[7] { 4.0, 1.5, 2.0, 2.5, 3.0, 3.1, 4.5 };

		public static readonly string[] CrowdIcons = new string[4] { "crowd_quiet", "crowd_steady", "crowd_busy", "crowd_packed" };

		public static readonly string[] CrowdNames = new string[4] { "Quiet", "Steady", "Busy", "Packed" };

		public static int DisplayDay(int savedDay)
		{
			return (int)Math.Min(2147483647L, Math.Max(0L, savedDay) + 1);
		}

		public static int Weekday(int gameDay, int firstDay)
		{
			return (int)(((Math.Max(1L, gameDay) - 1) % 7 + Math.Max(0, Math.Min(6, firstDay))) % 7);
		}

		public static int Week(int gameDay, int firstDay = 0)
		{
			return (int)((Math.Max(1L, gameDay) - 1 + Math.Max(0, Math.Min(6, firstDay))) / 7 + 1);
		}

		public static double Multiplier(int day, double hour, double strength)
		{
			day = Math.Max(0, Math.Min(6, day));
			if (double.IsNaN(hour) || double.IsInfinity(hour))
			{
				hour = 8.0;
			}
			if (double.IsNaN(strength) || double.IsInfinity(strength))
			{
				strength = 1.0;
			}
			double num = Baseline[day] - 1.0;
			if (day == 0 || day == 6)
			{
				num += 2.0 * Math.Max(0.0, 1.0 - Math.Abs(hour - 15.0) / 3.0);
			}
			if (day == 5)
			{
				num += 1.4 * Math.Max(0.0, Math.Min(1.0, (hour - 16.0) / 3.0));
			}
			return 1.0 + num * Math.Max(0.0, Math.Min(3.0, strength));
		}

		public static int Capacity(int baseline, double multiplier, int ceiling)
		{
			return Math.Max(baseline, (int)Math.Min(Math.Max(baseline, ceiling), Math.Ceiling((double)Math.Max(0, baseline) * Math.Max(1.0, multiplier))));
		}

		public static float Interval(float baseline, double multiplier)
		{
			if (!(baseline <= 0f))
			{
				return Math.Min(baseline, Math.Max(0.15f, baseline / (float)Math.Max(1.0, multiplier)));
			}
			return baseline;
		}

		public static bool Busy(int day, double hour)
		{
			if (day != 6 && (day != 5 || !(hour >= 16.0)))
			{
				if (day == 0)
				{
					return hour < 18.0;
				}
				return false;
			}
			return true;
		}

		public static string BusyWindow(int day)
		{
			return day switch
			{
				0 => "Until 6pm", 
				5 => "From 4pm", 
				6 => "All day", 
				_ => "", 
			};
		}

		public static bool TournamentWeekend(int day)
		{
			if (day != 5 && day != 6)
			{
				return day == 0;
			}
			return true;
		}

		public static double WithTournament(double multiplier, bool weekendTournament, double percent)
		{
			if (!weekendTournament || !(percent > 0.0))
			{
				return multiplier;
			}
			return multiplier * (1.0 + Math.Min(100.0, percent) / 100.0);
		}

		public static int CrowdLevel(double multiplier)
		{
			if (!double.IsNaN(multiplier))
			{
				if (!(multiplier < 2.0))
				{
					if (!(multiplier < 3.0))
					{
						if (!(multiplier < 5.0))
						{
							return 3;
						}
						return 2;
					}
					return 1;
				}
				return 0;
			}
			return 0;
		}

		public static double Peak(int day, double strength)
		{
			return Multiplier(day, (day == 5) ? 20 : 15, strength);
		}

		public static bool LateFriday(int day, double hour)
		{
			if (day == 5 && hour >= 18.0)
			{
				return hour < 21.0;
			}
			return false;
		}
	}
	internal static class DayCard
	{
		private static readonly Color Red = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)74, (byte)61, byte.MaxValue));

		private const float PictureHeight = 9.6f;

		private const float Width = 32f;

		private const float Height = 6.4f;

		private const float PixelsPerUnit = 17f;

		private const float FadeIn = 0.4f;

		private const float FadeOut = 0.8f;

		private static GameObject? canvas;

		private static RectTransform? root;

		private static CanvasGroup? group;

		private static IUiKit? kit;

		private static bool pending;

		private static bool fromLoad;

		private static bool failed;

		private static float showAt;

		private static float giveUpAt;

		private static float shownAt;

		private static float hideAt;

		private static int shownDay = -1;

		private static string last = "";

		internal static void Apply(Harmony harmony)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			try
			{
				harmony.Patch((MethodBase)(AccessTools.Method(typeof(GameUIScreen), "OnDayStarted", (Type[])null, (Type[])null) ?? throw new MissingMethodException("GameUIScreen.OnDayStarted")), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(DayCard), "DayStarted", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				harmony.Patch((MethodBase)(AccessTools.Method(typeof(GameUIScreen), "Init", (Type[])null, (Type[])null) ?? throw new MissingMethodException("GameUIScreen.Init")), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(DayCard), "Loaded", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Morning card unavailable: " + ex.Message));
				failed = true;
			}
		}

		private static void DayStarted()
		{
			Request(load: false);
		}

		private static void Loaded()
		{
			shownDay = -1;
			Request(load: true);
		}

		private static void Request(bool load)
		{
			pending = true;
			fromLoad = load;
			showAt = Time.unscaledTime + (load ? 3f : 1.5f);
			giveUpAt = showAt + 15f;
		}

		internal static void ResetLook()
		{
			if ((Object)(object)canvas != (Object)null)
			{
				Object.Destroy((Object)(object)canvas);
			}
			canvas = null;
			kit = null;
		}

		internal static void Update()
		{
			if (failed)
			{
				return;
			}
			try
			{
				if ((Object)(object)canvas != (Object)null && canvas.activeSelf && (Object)(object)group != (Object)null)
				{
					float unscaledTime = Time.unscaledTime;
					if (unscaledTime >= hideAt)
					{
						canvas.SetActive(false);
					}
					else
					{
						group.alpha = Mathf.Min(new float[3]
						{
							1f,
							(unscaledTime - shownAt) / 0.4f,
							(hideAt - unscaledTime) / 0.8f
						});
					}
				}
				if (!pending || Time.unscaledTime < showAt)
				{
					return;
				}
				if (!Plugin.DayCardEnabled.Value)
				{
					pending = false;
					return;
				}
				if (!Traffic.ShopOpen)
				{
					if (Time.unscaledTime >= giveUpAt)
					{
						pending = false;
					}
					return;
				}
				pending = false;
				if (shownDay != Links.GameDay || fromLoad)
				{
					shownDay = Links.GameDay;
					Show();
				}
			}
			catch (Exception ex)
			{
				failed = true;
				Plugin.Log.LogWarning((object)("Morning card turned off: " + ex.Message));
			}
		}

		private static void Show()
		{
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: 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)
			//IL_01ee: 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_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			int dayOfWeek = Links.DayOfWeek;
			bool flag = Links.ControlsTraffic && Plugin.Strength.Value > 0f;
			int roll = Random.Range(0, int.MaxValue);
			string text = (Others.TournamentToday ? DayLines.PickFrom(CalendarRules.TournamentWeekend(dayOfWeek) ? DayLines.TournamentWeekend : DayLines.Tournament, roll, ref last) : DayLines.Pick(dayOfWeek, flag, roll, ref last));
			bool flag2 = flag && CalendarRules.BusyWindow(dayOfWeek) != "";
			Plugin.Log.LogInfo((object)$"Morning card: {Links.DayName}, day {Links.GameDay}. \"{text}\"");
			Palette palette = Looks.Palette();
			if (kit == null)
			{
				kit = new BuiltInUiKit(palette);
			}
			if ((Object)(object)canvas == (Object)null)
			{
				canvas = new GameObject("DaysOfTheWeekMorningCard", new Type[1] { typeof(RectTransform) });
				Object.DontDestroyOnLoad((Object)(object)canvas);
				Canvas obj = canvas.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 440;
				CanvasScaler obj2 = canvas.AddComponent<CanvasScaler>();
				obj2.uiScaleMode = (ScaleMode)1;
				obj2.referenceResolution = new Vector2(1920f, 1080f);
				obj2.matchWidthOrHeight = 1f;
				group = canvas.AddComponent<CanvasGroup>();
				group.blocksRaycasts = false;
				group.interactable = false;
				root = kit.Node(canvas.transform, "Root");
				RectTransform? obj3 = root;
				RectTransform? obj4 = root;
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(0.5f, 1f);
				obj4.anchorMax = val;
				obj3.anchorMin = val;
				root.pivot = new Vector2(0.5f, 1f);
				root.anchoredPosition = new Vector2(0f, -170f);
				root.sizeDelta = new Vector2(32f, 6.4f);
				((Transform)root).localScale = Vector3.one * 17f;
			}
			for (int num = ((Transform)root).childCount - 1; num >= 0; num--)
			{
				Object.Destroy((Object)(object)((Component)((Transform)root).GetChild(num)).gameObject);
			}
			Sprite val2 = (Others.TournamentToday ? (Art.Get("morning_tournament") ?? Art.Get("morning_" + Links.DayName.ToLowerInvariant())) : Art.Get("morning_" + Links.DayName.ToLowerInvariant()));
			float num2 = (((Object)(object)val2 != (Object)null) ? 10.1f : 0f);
			root.sizeDelta = new Vector2(32f, 6.4f + num2);
			Image val3 = kit.Panel((Transform)(object)root, "Card", palette.Bg, 1f, raycast: false);
			kit.Place(((Graphic)val3).rectTransform, 0f, 0f, 32f, 6.4f + num2);
			if ((Object)(object)val2 != (Object)null)
			{
				Image val4 = ((Component)kit.Node((Transform)(object)((Graphic)val3).rectTransform, "Picture")).gameObject.AddComponent<Image>();
				val4.sprite = val2;
				val4.preserveAspect = true;
				((Graphic)val4).raycastTarget = false;
				kit.Place(((Graphic)val4).rectTransform, 0.5f, 0.5f, 31f, 9.6f);
			}
			kit.Border(((Component)val3).transform, flag2 ? Red : palette.Line, 1f);
			float num3 = 0.9f;
			Sprite val5 = (Others.TournamentToday ? Art.Get(CalendarRules.TournamentWeekend(dayOfWeek) ? "trophy_sponsored" : "trophy") : (flag ? Art.Get(CalendarRules.CrowdIcons[CalendarRules.CrowdLevel(CalendarRules.Peak(dayOfWeek, Plugin.Strength.Value))]) : null));
			if (val5 == null)
			{
				val5 = Art.Get("calendar_app");
			}
			if ((Object)(object)val5 != (Object)null)
			{
				Image val6 = ((Component)kit.Node((Transform)(object)((Graphic)val3).rectTransform, "Icon")).gameObject.AddComponent<Image>();
				val6.sprite = val5;
				val6.preserveAspect = true;
				((Graphic)val6).raycastTarget = false;
				kit.Place(((Graphic)val6).rectTransform, num3, num2 + 1.3f, 3.8f, 3.8f);
				num3 += 4.5f;
			}
			TextMeshProUGUI val7 = kit.Label((Transform)(object)((Graphic)val3).rectTransform, "Weekday", Links.DayName, 1.7f, flag2 ? Red : palette.Accent, (TextAlignmentOptions)4097);
			kit.Place(((TMP_Text)val7).rectTransform, num3, num2 + 0.4f, 16f, 2.8f);
			TextMeshProUGUI val8 = kit.Label((Transform)(object)((Graphic)val3).rectTransform, "Day", $"Day {Links.GameDay} · Week {CalendarRules.Week(Links.GameDay, Plugin.FirstDay.Value)}", 0.85f, palette.Muted, (TextAlignmentOptions)4100);
			kit.Place(((TMP_Text)val8).rectTransform, 19.1f, num2 + 0.6f, 12f, 2.4f);
			TextMeshProUGUI val9 = kit.Label((Transform)(object)((Graphic)val3).rectTransform, "Hint", text, 1f, palette.Text, (TextAlignmentOptions)4097);
			((TMP_Text)val9).fontStyle = (FontStyles)2;
			((TMP_Text)val9).enableWordWrapping = true;
			kit.Place(((TMP_Text)val9).rectTransform, num3, num2 + 3.2f, 32f - num3 - 0.9f, 2.8f);
			shownAt = Time.unscaledTime;
			hideAt = shownAt + Mathf.Clamp(Plugin.DayCardSeconds.Value, 3f, 20f);
			group.alpha = 0f;
			canvas.SetActive(true);
		}
	}
	internal static class DayLabel
	{
		private static GameUIScreen? screen;

		private static bool shownBusy;

		private static float nextTick;

		internal const string BusyColor = "#FF4A3D";

		internal static void Apply(Harmony harmony)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			try
			{
				MethodInfo[] array = new string[3] { "Init", "OnDayStarted", "OnLanguageChanged" }.Select((string n) => AccessTools.Method(typeof(GameUIScreen), n, (Type[])null, (Type[])null) ?? throw new MissingMethodException("GameUIScreen." + n)).ToArray();
				foreach (MethodInfo methodInfo in array)
				{
					harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(DayLabel), "Updated", (Type[])null, (Type[])null))
					{
						priority = 0
					}, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Weekday label unavailable: " + ex.Message));
			}
		}

		private static void Updated(GameUIScreen __instance)
		{
			screen = __instance;
			Refresh();
		}

		internal static void Tick()
		{
			if (!((Object)(object)screen == (Object)null) && !(Time.unscaledTime < nextTick))
			{
				nextTick = Time.unscaledTime + 1f;
				if (Links.BusyNow != shownBusy)
				{
					Refresh();
				}
				else if ((Object)(object)screen.m_DayText != (Object)null)
				{
					WeekStrip.Refresh(screen.m_DayText);
				}
			}
		}

		internal static void Refresh()
		{
			//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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)screen == (Object)null || (Object)(object)screen.m_DayText == (Object)null)
			{
				return;
			}
			try
			{
				TextMeshProUGUI dayText = screen.m_DayText;
				string text = LocalizationManager.GetTranslation("Day XXX", true, 0, true, false, (GameObject)null, (string)null, true).Replace("XXX", Links.GameDay.ToString());
				((TMP_Text)dayText).richText = true;
				shownBusy = Links.BusyNow;
				string text2 = (shownBusy ? ("<color=#FF4A3D>" + Links.DayName + "</color>") : Links.DayName);
				((TMP_Text)dayText).text = text + "\n<size=65%>" + text2 + "</size>";
				((TMP_Text)dayText).enableWordWrapping = false;
				((TMP_Text)dayText).verticalAlignment = (VerticalAlignmentOptions)256;
				((TMP_Text)dayText).overflowMode = (TextOverflowModes)0;
				RectTransform rectTransform = ((TMP_Text)dayText).rectTransform;
				Rect rect = rectTransform.rect;
				float num = Mathf.Max(((Rect)(ref rect)).height, ((TMP_Text)dayText).preferredHeight + 4f);
				rect = rectTransform.rect;
				float num2 = num - ((Rect)(ref rect)).height;
				if (num2 > 0f)
				{
					rectTransform.SetSizeWithCurrentAnchors((Axis)1, num);
					rectTransform.anchoredPosition -= new Vector2(0f, num2 * (1f - rectTransform.pivot.y));
				}
				WeekStrip.Refresh(dayText, force: true);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not refresh weekday label: " + ex.Message));
			}
		}
	}
	public static class DayLines
	{
		public static readonly string[][] ByDay = new string[7][]
		{
			new string[5] { "Sunday crowds. Busy right through the afternoon.", "Families are out today. The afternoon will be hectic.", "One more big day before the week resets.", "Busy until evening, then the town winds down.", "The weekend's last rush peaks after lunch." },
			new string[5] { "The street's still waking up from the weekend.", "A slow start to the week. A good day to restock.", "Most folks are back at work today.", "Expect a quiet one. The regulars will trickle in.", "Mondays are for pricing, sorting and coffee." },
			new string[5] { "A few more faces than yesterday, probably.", "Business is picking up, slowly but surely.", "Not busy yet, but the week is warming up.", "A steady trickle of shoppers today.", "Word gets around. A bit livelier than Monday." },
			new string[5] { "Midweek. The crowd is starting to build.", "Halfway to the weekend, and people know it.", "A steady day. Keep the shelves topped up.", "Packs are moving. More shoppers than earlier in the week.", "The midweek crowd is here to browse." },
			new string[5] { "The weekend's close. Shoppers are getting restless.", "A busy one. Make sure the registers are staffed.", "Thursday crowds are no joke. Stock up.", "People are building their weekend decks today.", "Expect a full shop by the afternoon." },
			new string[5] { "Payday energy. The evening will be packed.", "Steady all day, then the doors won't stop opening after four.", "Friday night is card night. Brace for the evening rush.", "Stock up before the after-work crowd arrives.", "The evening crowd lingers. They'll browse longer tonight." },
			new string[5] { "Saturday. The whole town is coming.", "Clear your schedule. It's going to be packed all day.", "Expect a line out the door by mid-afternoon.", "Every collector in the city has the day off.", "The biggest day of the week. Fill every shelf." }
		};

		public static readonly string[] Tournament = new string[3] { "Tournament today. Get the tables ready.", "Players will be in early for today's tournament.", "Tournament day. Expect decks out on every table." };

		public static readonly string[] TournamentWeekend = new string[3] { "Weekend tournament. The crowd will pay a premium today.", "Big weekend event. Sponsors will be watching.", "Tournament weekend. Prices at the till run a little higher." };

		public static readonly string[] Neutral = new string[3] { "Open the doors and see who walks in.", "Another day at the shop.", "Fresh day, fresh packs." };

		public static string Pick(int day, bool hints, int roll, ref string last)
		{
			return PickFrom(hints ? ByDay[Math.Max(0, Math.Min(6, day))] : Neutral, roll, ref last);
		}

		public static string PickFrom(string[] pool, int roll, ref string last)
		{
			string text = pool[(uint)roll % (uint)pool.Length];
			if (text == last && pool.Length > 1)
			{
				text = pool[(uint)(roll + 1) % (uint)pool.Length];
			}
			last = text;
			return text;
		}
	}
	internal static class Others
	{
		private const BindingFlags Flags = BindingFlags.Static | BindingFlags.Public;

		private const string TournamentsId = "dimwits.tournamentformats";

		private static Func<bool>? tournamentDay;

		private static Func<bool>? tournamentToday;

		private static Func<int>? scheduled;

		internal static bool TournamentToday
		{
			get
			{
				if (!Ask(ref tournamentToday))
				{
					return Ask(ref tournamentDay);
				}
				return true;
			}
		}

		internal static int ScheduledWeekday
		{
			get
			{
				try
				{
					return scheduled?.Invoke() ?? (-1);
				}
				catch (Exception ex)
				{
					scheduled = null;
					Plugin.Log.LogWarning((object)("Tournament day link off: " + ex.Message));
					return -1;
				}
			}
		}

		internal static void Resolve()
		{
			try
			{
				if (!Chainloader.PluginInfos.TryGetValue("dimwits.tournamentformats", out var value) || (Object)(object)value.Instance == (Object)null)
				{
					return;
				}
				Type type = ((object)value.Instance).GetType().Assembly.GetType("TournamentFormats.Links");
				if (!(type == null))
				{
					tournamentDay = Getter<bool>(type, "TournamentDay");
					tournamentToday = Getter<bool>(type, "TournamentToday");
					scheduled = Getter<int>(type, "ScheduledWeekday");
					if (tournamentToday != null)
					{
						Plugin.Log.LogInfo((object)"Linked to Tournament Formats: Friday to Sunday tournament days bring extra shoppers; the calendar shows the tournament's day.");
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Tournament Formats link off: " + ex.Message));
			}
		}

		private static Func<T>? Getter<T>(Type type, string name)
		{
			MethodInfo methodInfo = type.GetProperty(name, BindingFlags.Static | BindingFlags.Public)?.GetGetMethod();
			if (methodInfo == null)
			{
				return null;
			}
			try
			{
				return (Func<T>)Delegate.CreateDelegate(typeof(Func<T>), methodInfo);
			}
			catch (ArgumentException)
			{
				return null;
			}
		}

		private static bool Ask(ref Func<bool>? link)
		{
			try
			{
				return link?.Invoke() ?? false;
			}
			catch (Exception ex)
			{
				link = null;
				Plugin.Log.LogWarning((object)("Tournament link off: " + ex.Message));
				return false;
			}
		}
	}
	internal sealed class Panel
	{
		private const float W = 782f;

		private const float H = 986f;

		private const float U = 17f;

		private static readonly Color Busy = new Color(1f, 0.29f, 0.24f);

		private GameObject? canvas;

		private RectTransform? root;

		private RectTransform? content;

		private IUiKit? kit;

		private Palette pal = Palette.Phone;

		private bool hosted;

		private bool holding;

		private float nextRefresh;

		private int view;

		private string snapshot = "";

		public bool IsOpen
		{
			get
			{
				if ((Object)(object)canvas != (Object)null)
				{
					return canvas.activeSelf;
				}
				return false;
			}
		}

		public void Update()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				KeyboardShortcut value = Plugin.PanelKey.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					if (IsOpen)
					{
						Close();
					}
					else
					{
						Open();
					}
				}
				else
				{
					if (!IsOpen)
					{
						return;
					}
					if (!hosted && Input.GetKeyDown((KeyCode)27))
					{
						Close();
						return;
					}
					if ((Object)(object)root != (Object)null)
					{
						((Transform)root).localScale = Vector3.one * 17f * Math.Min(1f, (float)Screen.width * 1080f / (float)Math.Max(1, Screen.height) / 830f);
					}
					Cursor.visible = true;
					Cursor.lockState = (CursorLockMode)0;
					if (!(Time.unscaledTime < nextRefresh))
					{
						nextRefresh = Time.unscaledTime + 1f;
						if ((Object)(object)Object.FindObjectOfType<InteractionPlayerController>() == (Object)null)
						{
							Close();
						}
						else if (Snapshot() != snapshot)
						{
							Build();
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Calendar panel: " + ex.Message));
				Close();
			}
		}

		private string Snapshot()
		{
			return Plugin.ShowNumbers.Value + ":" + Links.GameDay + ":" + Traffic.Hour + ":" + Links.ControlsTraffic + ":" + Plugin.Strength.Value + ":" + Plugin.FirstDay.Value + ":" + Others.ScheduledWeekday + ":" + Others.TournamentToday;
		}

		public void Open()
		{
			if ((Object)(object)Object.FindObjectOfType<InteractionPlayerController>() == (Object)null)
			{
				return;
			}
			try
			{
				EnsureCanvas();
				Build();
				canvas.SetActive(true);
				if (!hosted && !holding)
				{
					PlayerHold.Begin();
					holding = true;
				}
				nextRefresh = Time.unscaledTime + 1f;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not open calendar: " + ex.Message));
				Close();
			}
		}

		public bool OpenHosted()
		{
			if (IsOpen)
			{
				Close();
			}
			hosted = true;
			Open();
			if (!IsOpen)
			{
				hosted = false;
			}
			return IsOpen;
		}

		public void HostClosed()
		{
			if (hosted)
			{
				hosted = false;
				if ((Object)(object)canvas != (Object)null)
				{
					canvas.SetActive(false);
				}
			}
		}

		public void Close()
		{
			if ((Object)(object)canvas != (Object)null)
			{
				canvas.SetActive(false);
			}
			if (holding)
			{
				PlayerHold.End();
				holding = false;
			}
			if (hosted)
			{
				hosted = false;
				ShopOSApp.CloseScreen();
			}
		}

		public void Destroy()
		{
			Close();
			if ((Object)(object)canvas != (Object)null)
			{
				Object.Destroy((Object)(object)canvas);
			}
			canvas = null;
			root = null;
			kit = null;
		}

		public void ResetLook()
		{
			Destroy();
		}

		private void EnsureCanvas()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0092: 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_0156: 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_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: 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_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)canvas != (Object)null))
			{
				pal = Looks.Palette();
				kit = new BuiltInUiKit(pal);
				canvas = new GameObject("DaysOfTheWeekPanel", new Type[1] { typeof(RectTransform) });
				Object.DontDestroyOnLoad((Object)(object)canvas);
				Canvas obj = canvas.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 506;
				CanvasScaler obj2 = canvas.AddComponent<CanvasScaler>();
				obj2.uiScaleMode = (ScaleMode)1;
				obj2.referenceResolution = new Vector2(1920f, 1080f);
				obj2.matchWidthOrHeight = 1f;
				canvas.AddComponent<GraphicRaycaster>();
				Image val = kit.Panel(canvas.transform, "Dim", new Color(0f, 0f, 0f, 0.6f), 0f, raycast: true);
				kit.Stretch(((Graphic)val).rectTransform, 0f, 0f, 0f, 0f);
				root = kit.Node(canvas.transform, "Root");
				RectTransform? obj3 = root;
				RectTransform? obj4 = root;
				RectTransform? obj5 = root;
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor(0.5f, 0.5f);
				obj5.pivot = val2;
				Vector2 anchorMin = (obj4.anchorMax = val2);
				obj3.anchorMin = anchorMin;
				root.sizeDelta = new Vector2(46f, 58f);
				((Transform)root).localScale = Vector3.one * 17f * Math.Min(1f, (float)Screen.width * 1080f / (float)Math.Max(1, Screen.height) / 830f);
				canvas.SetActive(false);
			}
		}

		private void Go(int target)
		{
			view = target;
			Build();
		}

		private void Build()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)root == (Object)null || kit == null)
			{
				return;
			}
			foreach (Transform item in (Transform)root)
			{
				((Component)item).gameObject.SetActive(false);
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			Image val2 = kit.Panel((Transform)(object)root, "Frame", pal.Bg, 1.6f, raycast: true);
			kit.Place(((Graphic)val2).rectTransform, 0f, 0f, 46f, 58f);
			kit.Border(((Component)val2).transform, pal.Line, 1.6f);
			content = kit.Node(((Component)val2).transform, "Content");
			kit.Stretch(content, 0f, 0f, 0f, 0f);
			Icon("calendar_app", 28f, 24f, 46f);
			Text("Days of the Week", 88f, 24f, 560f, 48f, 28f, pal.Text);
			Button("X", 710f, 26f, 44f, 44f, Close);
			Button("Weekly calendar", 28f, 90f, 351f, 52f, delegate
			{
				Go(0);
			}, view == 0);
			Button("Traffic outlook", 403f, 90f, 351f, 52f, delegate
			{
				Go(1);
			}, view == 1);
			if (view == 0)
			{
				Calendar();
			}
			else
			{
				Outlook();
			}
			Text("More visitors. A rhythm to your week.", 28f, 922f, 590f, 36f, 17f, pal.Muted);
			Button("Close", 646f, 920f, 108f, 40f, Close);
			snapshot = Snapshot();
		}

		private void Calendar()
		{
			//IL_003f: 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_00d0: 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)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: 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_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			int dayOfWeek = Links.DayOfWeek;
			Text($"{Links.DayName} · Day {Links.GameDay}", 28f, 170f, 726f, 54f, 32f, pal.Text);
			Text($"Week {CalendarRules.Week(Links.GameDay, Plugin.FirstDay.Value)}", 28f, 228f, 726f, 36f, 22f, pal.Muted);
			for (int i = 0; i < 7; i++)
			{
				float num = 28 + i * 104;
				Box(num, 290f, 98f, 136f, (i == dayOfWeek) ? pal.Raised : pal.Surface);
				Text(CalendarRules.Names[i].Substring(0, 3), num + 14f, 306f, 80f, 32f, 22f, (CalendarRules.BusyWindow(i) != "" && Links.ControlsTraffic) ? Busy : ((i == dayOfWeek) ? pal.Accent : pal.Text));
				long num2 = (long)Links.GameDay - (long)dayOfWeek + i;
				Text((num2 < 1) ? "—" : num2.ToString(), num + 16f, 350f, 76f, 44f, 28f, pal.Text);
				if (Links.ControlsTraffic)
				{
					Icon(CalendarRules.CrowdIcons[CalendarRules.CrowdLevel(Peak(i))], num + 60f, 392f, 30f);
				}
				if (i == Others.ScheduledWeekday || (i == dayOfWeek && Others.TournamentToday))
				{
					if ((Object)(object)Art.Get("trophy") != (Object)null)
					{
						Icon(CalendarRules.TournamentWeekend(i) ? "trophy_sponsored" : "trophy", num + 14f, 392f, 30f);
					}
					else
					{
						Text("Tourney", num + 8f, 394f, 88f, 26f, 15f, CalendarRules.TournamentWeekend(i) ? Busy : pal.Accent);
					}
				}
			}
			double trafficMultiplier = Links.TrafficMultiplier;
			Tile(28f, 456f, 351f, "Traffic now", Amount(trafficMultiplier), Plugin.ShowNumbers.Value ? (CalendarRules.CrowdNames[CalendarRules.CrowdLevel(trafficMultiplier)] + " · arrival rate target") : "how busy the shop is now", CalendarRules.CrowdIcons[CalendarRules.CrowdLevel(trafficMultiplier)]);
			Tile(403f, 456f, 351f, "Today's peak", Amount(Peak(dayOfWeek)), Plugin.ShowNumbers.Value ? "at current bonus strength" : "at today's busiest", CalendarRules.CrowdIcons[CalendarRules.CrowdLevel(Peak(dayOfWeek))]);
			Box(28f, 682f, 726f, 194f, pal.Surface);
			Text(Status(), 50f, 702f, 680f, 64f, 22f, Links.BusyNow ? Busy : pal.Accent, wrap: true);
			object value;
			switch (dayOfWeek)
			{
			default:
				value = "Weekday traffic builds toward Friday. Plan your stock and staffing ahead.";
				break;
			case 1:
				value = "The quietest day of the week. A good day to restock.";
				break;
			case 0:
			case 6:
				value = ((dayOfWeek == 6) ? "Busy all day. The afternoon rush builds from noon, peaks at 3pm and eases by 6pm." : "Busy until 6pm. The afternoon rush builds from noon and peaks at 3pm.");
				break;
			case 5:
				value = "Friday turns busy from 4pm, peaking around 7pm. Customers browse longer after 6pm.";
				break;
			}
			Text((string)value, 50f, 776f, 680f, 80f, 21f, pal.Text, wrap: true);
		}

		private static double Peak(int day)
		{
			return CalendarRules.Peak(day, Plugin.Strength.Value);
		}

		private static string Amount(double multiplier)
		{
			if (!Plugin.ShowNumbers.Value)
			{
				return CalendarRules.CrowdNames[CalendarRules.CrowdLevel(multiplier)];
			}
			return $"{multiplier:0.0}x";
		}

		private static string Status()
		{
			if (!Plugin.OtherTraffic)
			{
				if (Traffic.Ready)
				{
					if (Plugin.Enabled.Value)
					{
						if (!Links.TournamentBoostNow)
						{
							if (!Links.BusyNow)
							{
								return "Weekly traffic bonuses are active.";
							}
							return "Busy now. Weekly traffic bonuses are active.";
						}
						return "Weekend tournament today: extra shoppers.";
					}
					return "Traffic bonuses are switched off.";
				}
				return "Traffic hooks unavailable; calendar only.";
			}
			return "Weekly Traffic controls traffic (ReplaceWeeklyTraffic is off); our traffic bonuses are paused.";
		}

		private void Outlook()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_02be: 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_0122: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			Text("Plan the week ahead", 28f, 170f, 726f, 48f, 28f, pal.Text);
			Text("Day", 88f, 230f, 160f, 36f, 22f, pal.Muted);
			Text("Daytime", 280f, 230f, 130f, 36f, 22f, pal.Muted);
			Text("Peak", 420f, 230f, 130f, 36f, 22f, pal.Muted);
			Text("Busy", 560f, 230f, 180f, 36f, 22f, pal.Muted);
			for (int i = 0; i < 7; i++)
			{
				float num = 280 + i * 68;
				Box(28f, num, 726f, 58f, (i == Links.DayOfWeek) ? pal.Raised : pal.Surface);
				Icon(CalendarRules.CrowdIcons[CalendarRules.CrowdLevel(Peak(i))], 40f, num + 9f, 40f);
				if (i == Others.ScheduledWeekday)
				{
					Icon(CalendarRules.TournamentWeekend(i) ? "trophy_sponsored" : "trophy", 230f, num + 11f, 36f);
				}
				Text(CalendarRules.Names[i], 88f, num + 6f, 200f, 42f, 23f, (i == Links.DayOfWeek) ? pal.Accent : pal.Text);
				Text(Amount(CalendarRules.Multiplier(i, 10.0, Plugin.Strength.Value)), 280f, num + 6f, 130f, 42f, 23f, pal.Text);
				Text(Amount(Peak(i)), 420f, num + 6f, 130f, 42f, 23f, pal.Accent);
				Text(CalendarRules.BusyWindow(i), 560f, num + 6f, 180f, 42f, 23f, Busy);
			}
			Text("Targets increase arrival frequency and shopper capacity. Stock, queues, space and the safety ceiling affect actual visitors. No day drops below your normal crowd. Busy times show the weekday in red.", 40f, 788f, 704f, 104f, 21f, pal.Muted, wrap: true);
		}

		private void Tile(float x, float y, float width, string label, string value, string help, string icon)
		{
			//IL_000f: 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_008f: 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)
			Box(x, y, width, 200f, pal.Raised);
			Icon(icon, x + 20f, y + 18f, 44f);
			Text(label, x + 78f, y + 20f, width - 96f, 40f, 21f, pal.Muted);
			Text(value, x + 22f, y + 70f, width - 44f, 72f, 48f, pal.Accent);
			Text(help, x + 22f, y + 150f, width - 44f, 38f, 18f, pal.Text);
		}

		private void Box(float x, float y, float w, float h, Color color)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Image val = kit.Panel((Transform)(object)content, "Card", color, 1.0588236f, raycast: false);
			kit.Place(((Graphic)val).rectTransform, x / 17f, y / 17f, w / 17f, h / 17f);
		}

		private void Text(string value, float x, float y, float w, float h, float size, Color color, bool wrap = false)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI val = kit.Label((Transform)(object)content, "Text", value, size / 17f, color, (TextAlignmentOptions)4097);
			((TMP_Text)val).richText = false;
			((TMP_Text)val).enableWordWrapping = wrap;
			kit.Place(((TMP_Text)val).rectTransform, x / 17f, y / 17f, w / 17f, Math.Max(h, size * 1.5f) / 17f);
		}

		private void Button(string label, float x, float y, float w, float h, Action click, bool primary = false)
		{
			RectTransform rt = kit.Button((Transform)(object)content, label, primary, 1.0588236f, click);
			kit.Place(rt, x / 17f, y / 17f, w / 17f, h / 17f);
		}

		private void Icon(string name, float x, float y, float size)
		{
			Sprite val = Art.Get(name);
			if (!((Object)(object)val == (Object)null))
			{
				Image val2 = ((Component)kit.Node((Transform)(object)content, "Icon")).gameObject.AddComponent<Image>();
				val2.sprite = val;
				val2.preserveAspect = true;
				((Graphic)val2).raycastTarget = false;
				kit.Place(((Graphic)val2).rectTransform, x / 17f, y / 17f, size / 17f, size / 17f);
			}
		}
	}
	internal static class PlayerHold
	{
		private static InteractionPlayerController? _player;

		public static void Begin()
		{
			if ((Object)(object)_player != (Object)null)
			{
				return;
			}
			try
			{
				_player = Object.FindObjectOfType<InteractionPlayerController>();
				if ((Object)(object)_player != (Object)null)
				{
					_player.EnterUIMode();
					_player.EnterLockMoveMode();
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not hold the player still: " + ex.Message));
			}
		}

		public static void End()
		{
			try
			{
				if ((Object)(object)_player != (Object)null)
				{
					_player.ExitLockMoveMode();
					_player.ExitUIMode();
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not give control back to the player: " + ex.Message));
			}
			_player = null;
		}
	}
	[BepInPlugin("dimwits.daysoftheweek", "Days of the Week", "1.4.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Id = "dimwits.daysoftheweek";

		public const string Version = "1.4.4";

		internal static Plugin Instance;

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<bool> FridayBrowsing;

		internal static ConfigEntry<bool> ReplaceWeeklyTraffic;

		internal static ConfigEntry<bool> ReplaceWeekdaysPlus;

		internal static ConfigEntry<bool> DayCardEnabled;

		internal static ConfigEntry<bool> WeekStripEnabled;

		internal static ConfigEntry<bool> ShowNumbers;

		internal static ConfigEntry<float> Strength;

		internal static ConfigEntry<float> DayCardSeconds;

		internal static ConfigEntry<float> TournamentBoost;

		internal static ConfigEntry<int> FirstDay;

		internal static ConfigEntry<int> MaxShoppers;

		internal static ConfigEntry<string> PanelLook;

		internal static ConfigEntry<KeyboardShortcut> PanelKey;

		internal static bool OtherTraffic;

		private readonly Panel panel = new Panel();

		private Harmony? harmony;

		private float nextApp;

		private bool appReady;

		private void Awake()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Expected O, but got Unknown
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Expected O, but got Unknown
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Calendar", "Enabled", true, "Enable the weekly traffic bonuses. The calendar remains available when disabled.");
			FirstDay = ((BaseUnityPlugin)this).Config.Bind<int>("1. Calendar", "FirstDayOfWeek", 0, new ConfigDescription("Weekday of game day 1: 0 Sunday, 1 Monday, through 6 Saturday. Calendar columns always run Sunday to Saturday. Changing this shifts every save's calendar.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 6), Array.Empty<object>()));
			Strength = ((BaseUnityPlugin)this).Config.Bind<float>("2. Traffic", "BonusStrength", 1f, new ConfigDescription("Scale only the extra traffic. 1 gives Monday 1.5x and Saturday afternoon 6.5x; 0 is normal traffic; 2 doubles the bonus, giving Monday 2x and a Saturday peak of 12x.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>()));
			MaxShoppers = ((BaseUnityPlugin)this).Config.Bind<int>("2. Traffic", "MaximumShoppingCustomers", 250, new ConfigDescription("Ceiling for our added simultaneous shoppers, excluding table and tournament players. Never lowers a higher existing limit. Arrival frequency also increases, so this is not a daily visitor total.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(30, 1000), Array.Empty<object>()));
			ReplaceWeeklyTraffic = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Traffic", "ReplaceWeeklyTraffic", true, "Weekly Traffic is not compatible with Days of the Week. With both installed, Weekly Traffic is switched off for the session; its files and settings are not changed. Set to false to keep Weekly Traffic running instead (Days of the Week's traffic then pauses; the calendar stays). Restart the game after changing.");
			ReplaceWeekdaysPlus = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Interface", "ReplaceWeekdaysPlus", true, "Weekdays Plus is not compatible with Days of the Week. With both installed, Weekdays Plus is switched off for the session; its files and settings are not changed. Set to false to keep it running. Restart the game after changing.");
			TournamentBoost = ((BaseUnityPlugin)this).Config.Bind<float>("2. Traffic", "WeekendTournamentBoostPercent", 10f, new ConfigDescription("With Tournament Formats: extra shoppers on a Friday, Saturday or Sunday tournament day, on top of the day's traffic (percent).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>()));
			FridayBrowsing = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Traffic", "FridayLateBrowsing", true, "From 6pm Friday, customers take three extra real-time seconds to browse after a shelf pickup. Normal checkout and closing rules still apply.");
			PanelKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("3. Interface", "PanelKey", new KeyboardShortcut((KeyCode)107, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), "Open the weekly calendar.");
			PanelLook = ((BaseUnityPlugin)this).Config.Bind<string>("3. Interface", "PanelLook", "Auto", new ConfigDescription("Vanilla uses blue panels, yellow actions and the game font. ShopOS uses navy, gold and its rounded font. Phone uses dark teal and orange. Auto selects ShopOS when installed, then Phone - Overhaul, otherwise Vanilla.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[4] { "Auto", "Vanilla", "ShopOS", "Phone" }), Array.Empty<object>()));
			ShowNumbers = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Interface", "ShowNumbers", false, "Show the exact traffic multipliers (like 4.5x) in the calendar and outlook. Off: crowd words (Quiet, Steady, Busy, Packed).");
			WeekStripEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Interface", "WeekStrip", true, "Seven small dots under the day label, Sunday to Saturday: today is larger, days with busy times are red, a tournament's day shows a trophy.");
			DayCardEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Interface", "MorningCard", true, "When a day starts, show a card with the weekday and a hint of how busy it will be.");
			DayCardSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("3. Interface", "MorningCardSeconds", 7f, new ConfigDescription("How long the morning card stays on screen.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 20f), Array.Empty<object>()));
			PanelLook.SettingChanged += delegate
			{
				panel.ResetLook();
				DayCard.ResetLook();
			};
			OtherTraffic = Takeover.Installed;
			harmony = new Harmony("dimwits.daysoftheweek");
			Traffic.Apply(harmony);
			DayLabel.Apply(harmony);
			DayCard.Apply(harmony);
			Takeover.Apply(harmony);
			FirstDay.SettingChanged += delegate
			{
				DayLabel.Refresh();
			};
			Log.LogInfo((object)"Days of the Week 1.4.4 by Dimwit's loaded.");
		}

		private void Start()
		{
			if (harmony != null)
			{
				Takeover.Run(harmony);
			}
			Others.Resolve();
			OtherTraffic = Takeover.Installed && !Takeover.Replaced;
		}

		private void Update()
		{
			panel.Update();
			DayLabel.Tick();
			DayCard.Update();
			if (!appReady && Time.unscaledTime >= nextApp)
			{
				nextApp = Time.unscaledTime + 2f;
				appReady = ShopOSApp.TryRegister(this);
			}
		}

		public void OpenPanel()
		{
			panel.Open();
		}

		public bool OpenPanelHosted()
		{
			return panel.OpenHosted();
		}

		public void HostedPanelClosed()
		{
			panel.HostClosed();
		}

		private void OnDestroy()
		{
			panel.Destroy();
			Harmony? obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}
	}
	public static class Links
	{
		public const int Version = 3;

		public static int GameDay => CalendarRules.DisplayDay(CPlayerData.m_CurrentDay);

		public static int DayOfWeek => CalendarRules.Weekday(GameDay, Plugin.FirstDay.Value);

		public static string DayName => CalendarRules.Names[DayOfWeek];

		public static bool ControlsTraffic
		{
			get
			{
				if (Plugin.Enabled.Value && !Plugin.OtherTraffic)
				{
					return Traffic.Ready;
				}
				return false;
			}
		}

		public static bool BusyNow
		{
			get
			{
				if (ControlsTraffic && Plugin.Strength.Value > 0f && Traffic.ShopOpen)
				{
					return CalendarRules.Busy(DayOfWeek, Traffic.Hour);
				}
				return false;
			}
		}

		public static bool ReplacedWeeklyTraffic => Takeover.Replaced;

		public static bool ReplacedWeekdaysPlus => Takeover.ReplacedWeekdaysPlus;

		public static double TrafficMultiplier
		{
			get
			{
				if (!ControlsTraffic)
				{
					return 1.0;
				}
				return CalendarRules.WithTournament(CalendarRules.Multiplier(DayOfWeek, Traffic.Hour, Plugin.Strength.Value), TournamentBoostNow, Plugin.TournamentBoost.Value);
			}
		}

		public static bool TournamentWeekend => CalendarRules.TournamentWeekend(DayOfWeek);

		public static bool TournamentBoostNow
		{
			get
			{
				if (TournamentWeekend)
				{
					return Others.TournamentToday;
				}
				return false;
			}
		}
	}
	internal static class ShopOSApp
	{
		internal sealed class CalendarScreen : UIScreenBase
		{
			protected override void OnOpenScreen()
			{
				((UIScreenBase)this).OnOpenScreen();
				bool flag = false;
				try
				{
					flag = (Object)(object)_plugin != (Object)null && _plugin.OpenPanelHosted();
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("The Calendar app couldn't open: " + ex.Message));
				}
				if (!flag)
				{
					((UIScreenBase)this).OnCloseScreen();
				}
			}

			protected override void OnCloseScreen()
			{
				((UIScreenBase)this).OnCloseScreen();
				try
				{
					_plugin?.HostedPanelClosed();
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("The Calendar app didn't close cleanly: " + ex.Message));
				}
			}
		}

		public const string ShopOSGuid = "com.qolmods.shopos";

		private static CalendarScreen? _screen;

		private static Plugin? _plugin;

		public static bool TryRegister(Plugin plugin)
		{
			if (!Chainloader.PluginInfos.TryGetValue("com.qolmods.shopos", out var value))
			{
				return true;
			}
			if ((Object)(object)value.Instance == (Object)null)
			{
				return false;
			}
			_plugin = plugin;
			try
			{
				Type type = ((object)value.Instance).GetType().Assembly.GetType("ShopOS.ShopOSApi", throwOnError: false);
				if (type == null)
				{
					Plugin.Log.LogWarning((object)"This version of QOL ShopOS has no app API; use the panel key instead.");
					return true;
				}
				object obj = type.GetProperty("IsReady")?.GetValue(null);
				if (obj is bool && !(bool)obj)
				{
					return false;
				}
				Sprite val = Art.Get("calendar_app");
				MethodInfo method = type.GetMethod("RegisterApp", BindingFlags.Static | BindingFlags.Public, null, new Type[5]
				{
					typeof(string),
					typeof(string),
					typeof(string),
					typeof(Sprite),
					typeof(Func<UIScreenBase>)
				}, null);
				if (method != null)
				{
					Func<UIScreenBase> func = Screen;
					obj = method.Invoke(null, new object[5] { "dimwits.daysoftheweek", "calendar", "Calendar", val, func });
					bool flag = obj is bool && (bool)obj;
					Plugin.Log.LogInfo((object)(flag ? "QOL ShopOS app added (opens full screen in the tablet)." : "QOL ShopOS refused the app."));
					return true;
				}
				MethodInfo method2 = type.GetMethod("RegisterApp", BindingFlags.Static | BindingFlags.Public, null, new Type[5]
				{
					typeof(string),
					typeof(string),
					typeof(string),
					typeof(Sprite),
					typeof(Action)
				}, null);
				if (method2 == null)
				{
					Plugin.Log.LogWarning((object)"This version of QOL ShopOS has no app API; use the panel key instead.");
					return true;
				}
				Action action = plugin.OpenPanel;
				obj = method2.Invoke(null, new object[5] { "dimwits.daysoftheweek", "calendar", "Calendar", val, action });
				bool flag2 = obj is bool && (bool)obj;
				Plugin.Log.LogInfo((object)(flag2 ? "QOL ShopOS app added." : "QOL ShopOS refused the app."));
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not add the QOL ShopOS app: " + (ex.InnerException ?? ex).Message));
			}
			return true;
		}

		private static UIScreenBase Screen()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			if ((Object)(object)_screen == (Object)null)
			{
				GameObject val = new GameObject("DaysOfTheWeekShopOSScreen");
				Object.DontDestroyOnLoad((Object)(object)val);
				GameObject val2 = new GameObject("Group");
				val2.transform.SetParent(val.transform, false);
				_screen = val.AddComponent<CalendarScreen>();
				((UIScreenBase)_screen).m_ScreenGroup = val2;
			}
			return (UIScreenBase)(object)_screen;
		}

		public static void CloseScreen()
		{
			try
			{
				if ((Object)(object)_screen != (Object)null && ((UIScreenBase)_screen).IsScreenOpened())
				{
					((UIScreenBase)_screen).CloseScreen();
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not go back to the ShopOS tablet: " + ex.Message));
			}
		}
	}
	internal static class Takeover
	{
		internal const string WeeklyTrafficId = "yaka.weeklytraffic";

		private static Harmony? harmony;

		internal static bool Installed => Find(WeeklyTraffic) != null;

		internal static bool Replaced { get; private set; }

		internal static bool ReplacedWeekdaysPlus { get; private set; }

		private static bool WeeklyTraffic(PluginInfo p)
		{
			return p.Metadata.GUID == "yaka.weeklytraffic";
		}

		private static bool WeekdaysPlus(PluginInfo p)
		{
			if (!p.Metadata.GUID.Equals("jordy.WeekdaysPlus", StringComparison.OrdinalIgnoreCase))
			{
				return p.Metadata.Name.Replace(" ", "").Equals("WeekdaysPlus", StringComparison.OrdinalIgnoreCase);
			}
			return true;
		}

		private static PluginInfo? Find(Func<PluginInfo, bool> match)
		{
			return ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo p) => ((p != null) ? p.Metadata : null) != null && match(p)));
		}

		internal static void Apply(Harmony ours)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(GameUIScreen), "Init", (Type[])null, (Type[])null);
				if (methodInfo != null)
				{
					ours.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Takeover), "ShopLoaded", (Type[])null, (Type[])null))
					{
						priority = 800
					}, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Late takeover check unavailable: " + ex.Message));
			}
		}

		private static void ShopLoaded()
		{
			Run(null, quiet: true);
		}

		internal static void Run(Harmony? ours, bool quiet = false)
		{
			if (ours != null)
			{
				harmony = ours;
			}
			if (harmony == null)
			{
				return;
			}
			PluginInfo val = Find(WeeklyTraffic);
			if ((Object)(object)((val != null) ? val.Instance : null) != (Object)null)
			{
				if (Plugin.ReplaceWeeklyTraffic.Value)
				{
					Replaced = Sweep(val, "Weekly Traffic", quiet) || Replaced;
				}
				else if (!quiet)
				{
					Plugin.Log.LogInfo((object)"Weekly Traffic is installed and ReplaceWeeklyTraffic is off: Weekly Traffic keeps control of traffic; the calendar stays available.");
				}
			}
			PluginInfo val2 = Find(WeekdaysPlus);
			if ((Object)(object)((val2 != null) ? val2.Instance : null) != (Object)null)
			{
				if (Plugin.ReplaceWeekdaysPlus.Value)
				{
					ReplacedWeekdaysPlus = Sweep(val2, "Weekdays Plus", quiet) || ReplacedWeekdaysPlus;
				}
				else if (!quiet)
				{
					Plugin.Log.LogInfo((object)"Weekdays Plus is installed and ReplaceWeekdaysPlus is off: both mods will write the day label.");
				}
			}
		}

		private static bool Sweep(PluginInfo info, string name, bool quiet)
		{
			try
			{
				Assembly theirs = ((object)info.Instance).GetType().Assembly;
				int num = 0;
				foreach (MethodBase item in Harmony.GetAllPatchedMethods().ToList())
				{
					Patches patchInfo = Harmony.GetPatchInfo(item);
					if (patchInfo == null)
					{
						continue;
					}
					foreach (MethodInfo item2 in (from p in patchInfo.Prefixes.Concat(patchInfo.Postfixes).Concat(patchInfo.Transpilers).Concat(patchInfo.Finalizers)
						select p.PatchMethod into m
						where m?.DeclaringType?.Assembly == theirs
						select m).Distinct().ToList())
					{
						harmony.Unpatch(item, item2);
						num++;
					}
				}
				((Behaviour)info.Instance).enabled = false;
				if (!quiet || num > 0)
				{
					Plugin.Log.LogInfo((object)$"{name} is installed and not compatible with Days of the Week: switched off for this session ({num} game hooks; its files and settings are unchanged).");
				}
				if (num > 0)
				{
					DayLabel.Refresh();
				}
				return true;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not switch off " + name + ": " + ex.Message));
				return false;
			}
		}
	}
	internal static class Traffic
	{
		internal struct Change
		{
			public bool Applied;

			public float Interval;

			public float ChangedInterval;

			public int Cap;

			public int ChangedCap;
		}

		internal static bool Ready;

		private static LightManager? light;

		private static FieldRef<LightManager, int>? hour;

		private static FieldRef<LightManager, int>? minute;

		private static FieldRef<LightManager, bool>? ended;

		private static FieldRef<CustomerManager, bool>? loaded;

		private static float nextFind;

		private static int loggedDay = -1;

		internal static double Hour
		{
			get
			{
				LightManager val = Light();
				if (val == null || hour == null)
				{
					return 8.0;
				}
				return (double)hour.Invoke(val) + (double)minute.Invoke(val) / 60.0;
			}
		}

		internal static bool ShopOpen
		{
			get
			{
				LightManager val = Light();
				if (val != null && ended != null)
				{
					return !ended.Invoke(val);
				}
				return false;
			}
		}

		private static LightManager? Light()
		{
			if ((Object)(object)light == (Object)null && Time.unscaledTime >= nextFind)
			{
				nextFind = Time.unscaledTime + 1f;
				light = Object.FindObjectOfType<LightManager>();
			}
			return light;
		}

		private static bool InShop(CustomerManager manager)
		{
			if (loaded.Invoke(manager))
			{
				return ShopOpen;
			}
			return false;
		}

		internal static void Apply(Harmony h)
		{
			try
			{
				hour = AccessTools.FieldRefAccess<LightManager, int>("m_TimeHour");
				minute = AccessTools.FieldRefAccess<LightManager, int>("m_TimeMin");
				ended = AccessTools.FieldRefAccess<LightManager, bool>("m_HasDayEnded");
				loaded = AccessTools.FieldRefAccess<CustomerManager, bool>("m_FinishLoading");
				MethodInfo methodInfo = AccessTools.Method(typeof(CustomerManager), "Update", (Type[])null, (Type[])null) ?? throw new MissingMethodException("CustomerManager.Update");
				MethodInfo methodInfo2 = AccessTools.Method(typeof(CustomerManager), "CustomerEnterShop", (Type[])null, (Type[])null) ?? throw new MissingMethodException("CustomerEnterShop");
				MethodInfo methodInfo3 = AccessTools.Method(typeof(Customer), "DecideIfFinishShopping", (Type[])null, (Type[])null) ?? throw new MissingMethodException("DecideIfFinishShopping");
				h.Patch((MethodBase)methodInfo, Hook("BeforeUpdate"), (HarmonyMethod)null, (HarmonyMethod)null, Hook("AfterUpdate"), (HarmonyMethod)null);
				h.Patch((MethodBase)methodInfo2, Hook("BeforeEnter"), (HarmonyMethod)null, (HarmonyMethod)null, Hook("AfterEnter"), (HarmonyMethod)null);
				h.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, Hook("Browse"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Ready = true;
				Plugin.Log.LogInfo((object)"Base-game traffic hooks ready: arrival frequency, shopper capacity and Friday browsing.");
			}
			catch (Exception ex)
			{
				h.UnpatchSelf();
				Plugin.Log.LogError((object)("Traffic hooks unavailable; calendar only: " + ex.Message));
			}
		}

		private static HarmonyMethod Hook(string name)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			return new HarmonyMethod(AccessTools.Method(typeof(Traffic), name, (Type[])null, (Type[])null))
			{
				priority = 0
			};
		}

		private static void BeforeUpdate(CustomerManager __instance, out Change __state)
		{
			__state = default(Change);
			if (Links.ControlsTraffic && InShop(__instance))
			{
				if (loggedDay != Links.GameDay)
				{
					loggedDay = Links.GameDay;
					Plugin.Log.LogInfo((object)$"Day {loggedDay} ({Links.DayName}): baseline {__instance.m_CustomerCountMax} shoppers, {__instance.m_TimePerCustomer:0.00}s arrival interval; current traffic target {Links.TrafficMultiplier:0.0}x.");
				}
				__state.Interval = __instance.m_TimePerCustomer;
				__state.ChangedInterval = CalendarRules.Interval(__state.Interval, Links.TrafficMultiplier);
				__state.Applied = true;
				__instance.m_TimePerCustomer = __state.ChangedInterval;
			}
		}

		private static void AfterUpdate(CustomerManager __instance, Change __state)
		{
			if (__state.Applied && __instance.m_TimePerCustomer == __state.ChangedInterval)
			{
				__instance.m_TimePerCustomer = __state.Interval;
			}
		}

		private static void BeforeEnter(CustomerManager __instance, out Change __state)
		{
			__state = default(Change);
			if (Links.ControlsTraffic && InShop(__instance))
			{
				__state.Cap = __instance.m_CustomerCountMax;
				__state.ChangedCap = CalendarRules.Capacity(__state.Cap, Links.TrafficMultiplier, Plugin.MaxShoppers.Value);
				__state.Applied = true;
				__instance.m_CustomerCountMax = __state.ChangedCap;
			}
		}

		private static void AfterEnter(CustomerManager __instance, Change __state)
		{
			if (__state.Applied && __instance.m_CustomerCountMax == __state.ChangedCap)
			{
				__instance.m_CustomerCountMax = __state.Cap;
			}
		}

		private static void Browse(ref IEnumerator __result)
		{
			if (__result != null && Links.ControlsTraffic && Plugin.FridayBrowsing.Value && (Object)(object)light != (Object)null && !ended.Invoke(light) && CalendarRules.LateFriday(Links.DayOfWeek, Hour))
			{
				__result = LongerBrowse(__result);
			}
		}

		private static IEnumerator LongerBrowse(IEnumerator original)
		{
			try
			{
				yield return (object)new WaitForSeconds(3f);
				while (original.MoveNext())
				{
					yield return original.Current;
				}
			}
			finally
			{
				(original as IDisposable)?.Dispose();
			}
		}
	}
	internal static class WeekStrip
	{
		private static readonly Color Busy = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)74, (byte)61, byte.MaxValue));

		private static readonly Color Calm = new Color(1f, 1f, 1f, 0.75f);

		private static readonly Color Today = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)213, (byte)66, byte.MaxValue));

		private static RectTransform? strip;

		private static Sprite? dot;

		private static string shown = "";

		internal static void Refresh(TextMeshProUGUI label, bool force = false)
		{
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: 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_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: 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_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: 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_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!Plugin.WeekStripEnabled.Value)
				{
					if ((Object)(object)strip != (Object)null)
					{
						((Component)strip).gameObject.SetActive(false);
					}
					return;
				}
				string text = $"{Links.DayOfWeek}:{Links.ControlsTraffic}:{Others.ScheduledWeekday}:{Others.TournamentToday}:{((TMP_Text)label).fontSize:0.0}";
				if (!force && (Object)(object)strip != (Object)null && ((Component)strip).gameObject.activeSelf && text == shown)
				{
					return;
				}
				shown = text;
				if ((Object)(object)strip == (Object)null || (Object)(object)((Transform)strip).parent != (Object)(object)((TMP_Text)label).transform)
				{
					if ((Object)(object)strip != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)strip).gameObject);
					}
					strip = (RectTransform)new GameObject("DaysOfTheWeekStrip", new Type[1] { typeof(RectTransform) }).transform;
					((Transform)strip).SetParent(((TMP_Text)label).transform, false);
					strip.pivot = new Vector2(0f, 1f);
				}
				((TMP_Text)label).ForceMeshUpdate(false, false);
				Bounds textBounds = ((TMP_Text)label).textBounds;
				RectTransform? obj = strip;
				Vector2 anchorMin = (strip.anchorMax = ((TMP_Text)label).rectTransform.pivot);
				obj.anchorMin = anchorMin;
				((Component)strip).gameObject.SetActive(true);
				for (int num = ((Transform)strip).childCount - 1; num >= 0; num--)
				{
					Object.Destroy((Object)(object)((Component)((Transform)strip).GetChild(num)).gameObject);
				}
				float num2 = Mathf.Max(6f, ((TMP_Text)label).fontSize * 0.42f);
				float num3 = num2 * 1.45f;
				Rect rect;
				float num4;
				if (!(((Bounds)(ref textBounds)).size.x > 0f))
				{
					rect = ((TMP_Text)label).rectTransform.rect;
					num4 = (0f - ((Rect)(ref rect)).width) * ((TMP_Text)label).rectTransform.pivot.x;
				}
				else
				{
					num4 = ((Bounds)(ref textBounds)).min.x;
				}
				float num5 = num4;
				float num6;
				if (!(((Bounds)(ref textBounds)).size.y > 0f))
				{
					rect = ((TMP_Text)label).rectTransform.rect;
					num6 = (0f - ((Rect)(ref rect)).height) * ((TMP_Text)label).rectTransform.pivot.y;
				}
				else
				{
					num6 = ((Bounds)(ref textBounds)).min.y;
				}
				float num7 = num6;
				strip.anchoredPosition = new Vector2(num5 + num2 * 0.1f, num7 - num2 * 0.35f);
				strip.sizeDelta = new Vector2(num3 * 7f, num2 * 1.6f);
				int dayOfWeek = Links.DayOfWeek;
				int num8 = 0;
				while (num8 < 7)
				{
					int num9;
					float num10;
					if (num8 != Others.ScheduledWeekday)
					{
						if (num8 == dayOfWeek)
						{
							num9 = (Others.TournamentToday ? 1 : 0);
							if (num9 != 0)
							{
								goto IL_02f3;
							}
						}
						else
						{
							num9 = 0;
						}
						num10 = ((num8 == dayOfWeek) ? (num2 * 1.3f) : num2);
						goto IL_02fa;
					}
					num9 = 1;
					goto IL_02f3;
					IL_02fa:
					float num11 = num10;
					Sprite val = ((num9 != 0) ? Art.Get(CalendarRules.TournamentWeekend(num8) ? "trophy_sponsored" : "trophy") : null);
					Image val2 = new GameObject("Day" + num8, new Type[1] { typeof(RectTransform) }).AddComponent<Image>();
					((Graphic)val2).raycastTarget = false;
					((Transform)((Graphic)val2).rectTransform).SetParent((Transform)(object)strip, false);
					RectTransform rectTransform = ((Graphic)val2).rectTransform;
					anchorMin = (((Graphic)val2).rectTransform.anchorMax = new Vector2(0f, 0.5f));
					rectTransform.anchorMin = anchorMin;
					((Graphic)val2).rectTransform.pivot = new Vector2(0.5f, 0.5f);
					((Graphic)val2).rectTransform.sizeDelta = new Vector2(num11, num11);
					((Graphic)val2).rectTransform.anchoredPosition = new Vector2(num3 * (float)num8 + num2 * 0.75f, 0f);
					if ((Object)(object)val != (Object)null)
					{
						val2.sprite = val;
						val2.preserveAspect = true;
						((Graphic)val2).color = Color.white;
					}
					else
					{
						val2.sprite = Dot();
						bool flag = Links.ControlsTraffic && CalendarRules.BusyWindow(num8) != "";
						((Graphic)val2).color = (flag ? Busy : ((num8 == dayOfWeek) ? Today : Calm));
						if (num8 == dayOfWeek && flag)
						{
							((Graphic)val2).rectTransform.sizeDelta = new Vector2(num11 * 1.1f, num11 * 1.1f);
						}
					}
					num8++;
					continue;
					IL_02f3:
					num10 = num2 * 1.5f;
					goto IL_02fa;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Week strip: " + ex.Message));
			}
		}

		internal static void Hide()
		{
			if ((Object)(object)strip != (Object)null)
			{
				((Component)strip).gameObject.SetActive(false);
			}
		}

		private static Sprite Dot()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)dot != (Object)null)
			{
				return dot;
			}
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1,
				name = "DaysOfTheWeek_Dot"
			};
			Color32[] array = (Color32[])(object)new Color32[4096];
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num = (float)j - 31.5f;
					float num2 = (float)i - 31.5f;
					float num3 = 32f - Mathf.Sqrt(num * num + num2 * num2);
					array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(Mathf.Clamp01(num3) * 255f));
				}
			}
			val.SetPixels32(array);
			val.Apply();
			Object.DontDestroyOnLoad((Object)(object)val);
			dot = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f);
			return dot;
		}
	}
}
namespace DaysOfTheWeek.Ui
{
	internal sealed class Palette
	{
		public string Name = "";

		public Color Bg;

		public Color Surface;

		public Color Raised;

		public Color Dashed;

		public Color Accent;

		public Color AccentLight;

		public Color Teal;

		public Color Sand;

		public Color Steel;

		public Color Text;

		public Color Muted;

		public Color Ink;

		public Color Line;

		public Color Negative;

		public bool ShopOSFont;

		public static readonly Palette Vanilla = new Palette
		{
			Name = "Vanilla",
			Bg = Color32.op_Implicit(new Color32((byte)22, (byte)70, (byte)112, byte.MaxValue)),
			Surface = Color32.op_Implicit(new Color32((byte)27, (byte)91, (byte)145, byte.MaxValue)),
			Raised = Color32.op_Implicit(new Color32((byte)40, (byte)115, (byte)175, byte.MaxValue)),
			Dashed = Color32.op_Implicit(new Color32((byte)74, (byte)139, (byte)190, byte.MaxValue)),
			Accent = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)213, (byte)66, byte.MaxValue)),
			AccentLight = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)235, (byte)153, byte.MaxValue)),
			Teal = Color32.op_Implicit(new Color32((byte)127, (byte)224, (byte)191, byte.MaxValue)),
			Sand = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)230, (byte)181, byte.MaxValue)),
			Steel = Color32.op_Implicit(new Color32((byte)182, (byte)211, (byte)239, byte.MaxValue)),
			Text = Color32.op_Implicit(new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue)),
			Muted = Color32.op_Implicit(new Color32((byte)203, (byte)225, (byte)244, byte.MaxValue)),
			Ink = Color32.op_Implicit(new Color32((byte)28, (byte)40, (byte)54, byte.MaxValue)),
			Line = Color32.op_Implicit(new Color32((byte)12, (byte)42, (byte)72, byte.MaxValue)),
			Negative = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)160, (byte)155, byte.MaxValue))
		};

		public static readonly Palette Phone = new Palette
		{
			Name = "Phone - Overhaul",
			Bg = Color32.op_Implicit(new Color32((byte)32, (byte)30, (byte)33, byte.MaxValue)),
			Surface = Color32.op_Implicit(new Color32((byte)13, (byte)39, (byte)39, byte.MaxValue)),
			Raised = Color32.op_Implicit(new Color32((byte)26, (byte)56, (byte)58, byte.MaxValue)),
			Dashed = Color32.op_Implicit(new Color32((byte)46, (byte)85, (byte)87, byte.MaxValue)),
			Accent = Color32.op_Implicit(new Color32((byte)248, (byte)135, (byte)20, byte.MaxValue)),
			AccentLight = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)176, (byte)47, byte.MaxValue)),
			Teal = Color32.op_Implicit(new Color32((byte)79, (byte)179, (byte)169, byte.MaxValue)),
			Sand = Color32.op_Implicit(new Color32((byte)232, (byte)217, (byte)181, byte.MaxValue)),
			Steel = Color32.op_Implicit(new Color32((byte)127, (byte)167, (byte)201, byte.MaxValue)),
			Text = Color32.op_Implicit(new Color32((byte)250, (byte)249, (byte)248, byte.MaxValue)),
			Muted = Color32.op_Implicit(new Color32((byte)154, (byte)165, (byte)166, byte.MaxValue)),
			Ink = Color32.op_Implicit(new Color32((byte)9, (byte)0, (byte)1, byte.MaxValue)),
			Line = Color32.op_Implicit(new Color32((byte)9, (byte)0, (byte)1, byte.MaxValue)),
			Negative = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)138, (byte)122, byte.MaxValue))
		};

		public static readonly Palette ShopOS = new Palette
		{
			Name = "ShopOS",
			ShopOSFont = true,
			Bg = Color32.op_Implicit(new Color32((byte)14, (byte)19, (byte)34, byte.MaxValue)),
			Surface = Color32.op_Implicit(new Color32((byte)22, (byte)29, (byte)50, byte.MaxValue)),
			Raised = Color32.op_Implicit(new Color32((byte)32, (byte)41, (byte)66, byte.MaxValue)),
			Dashed = Color32.op_Implicit(new Color32((byte)48, (byte)60, (byte)90, byte.MaxValue)),
			Accent = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)212, (byte)59, byte.MaxValue)),
			AccentLight = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)228, (byte)122, byte.MaxValue)),
			Teal = Color32.op_Implicit(new Color32((byte)32, (byte)217, byte.MaxValue, byte.MaxValue)),
			Sand = Color32.op_Implicit(new Color32((byte)232, (byte)217, (byte)181, byte.MaxValue)),
			Steel = Color32.op_Implicit(new Color32((byte)122, (byte)133, (byte)153, byte.MaxValue)),
			Text = Color32.op_Implicit(new Color32((byte)244, (byte)246, (byte)251, byte.MaxValue)),
			Muted = Color32.op_Implicit(new Color32((byte)184, (byte)196, (byte)212, byte.MaxValue)),
			Ink = Color32.op_Implicit(new Color32((byte)20, (byte)26, (byte)44, byte.MaxValue)),
			Line = Color32.op_Implicit(new Color32((byte)52, (byte)64, (byte)96, byte.MaxValue)),
			Negative = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)92, (byte)92, byte.MaxValue))
		};

		public Color[] Tiers => (Color[])(object)new Color[5] { Muted, Steel, Teal, Accent, AccentLight };
	}
	internal static class Looks
	{
		public const string Auto = "Auto";

		public const string ShopOSLook = "ShopOS";

		public const string PhoneLook = "Phone";

		public static Palette Palette()
		{
			switch (Plugin.PanelLook.Value)
			{
			case "Vanilla":
				return DaysOfTheWeek.Ui.Palette.Vanilla;
			case "ShopOS":
				return DaysOfTheWeek.Ui.Palette.ShopOS;
			case "Phone":
				return DaysOfTheWeek.Ui.Palette.Phone;
			default:
				if (Chainloader.PluginInfos.ContainsKey("com.qolmods.shopos"))
				{
					return DaysOfTheWeek.Ui.Palette.ShopOS;
				}
				if (Chainloader.PluginInfos.ContainsKey("munch.PhoneOverhaul"))
				{
					return DaysOfTheWeek.Ui.Palette.Phone;
				}
				return DaysOfTheWeek.Ui.Palette.Vanilla;
			}
		}

		public static IUiKit Kit(bool unused)
		{
			return new BuiltInUiKit(Palette());
		}
	}
	internal interface IUiKit
	{
		string Name { get; }

		Color Bg { get; }

		Color Outline { get; }

		Color Text { get; }

		Color TextMuted { get; }

		RectTransform Node(Transform parent, string name);

		void Place(RectTransform rt, float x, float y, float w, float h);

		void Stretch(RectTransform rt, float left, float top, float right, float bottom);

		Image Panel(Transform parent, string name, Color color, float radius, bool raycast);

		void Border(Transform panel, Color color, float radius);

		TextMeshProUGUI Label(Transform parent, string name, string value, float size, Color color, TextAlignmentOptions align);

		TextMeshProUGUI Title(Transform parent, string name, string value, float size);

		RectTransform Button(Transform parent, string label, bool primary, float size, Action click);

		void Dropdown(Transform parent, List<string> options, int value, Action<int> changed, float x, float y, float w, float h, RectTransform pageRoot);
	}
	internal sealed class BuiltInUiKit : IUiKit
	{
		private readonly Palette _palette;

		private const int SpriteSize = 64;

		private const int CornerPixels = 24;

		private static Sprite? _filled;

		private static Sprite? _ring;

		private static TMP_FontAsset? _font;

		private static TMP_FontAsset? _roundFont;

		private static bool _fontLooked;

		private static bool _roundFontLooked;

		private static float _nextRoundFontLook;

		private Color BgColour => _palette.Bg;

		private Color Surface => _palette.Surface;

		private Color SurfaceRaised => _palette.Raised;

		private Color Accent => _palette.Accent;

		private Color TextColour => _palette.Text;

		private Color Muted => _palette.Muted;

		public string Name => _palette.Name + " (drawn by Customer Loyalty)";

		public Color Bg => BgColour;

		public Color Outline => _palette.Line;

		public Color Text => TextColour;

		public Color TextMuted => Muted;

		public BuiltInUiKit(Palette? palette = null)
		{
			_palette = palette ?? Looks.Palette();
		}

		public RectTransform Node(Transform parent, string name)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			return (RectTransform)val.transform;
		}

		public void Place(RectTransform rt, float x, float y, float w, float h)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0f, 1f);
			rt.anchorMax = val;
			rt.anchorMin = val;
			rt.pivot = new Vector2(0f, 1f);
			rt.anchoredPosition = new Vector2(x, 0f - y);
			rt.sizeDelta = new Vector2(w, h);
		}

		public void Stretch(RectTransform rt, float left, float top, float right, float bottom)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = Vector2.zero;
			rt.anchorMax = Vector2.one;
			rt.pivot = new Vector2(0.5f, 0.5f);
			rt.offsetMin = new Vector2(left, bottom);
			rt.offsetMax = new Vector2(0f - right, 0f - top);
		}

		public Image Panel(Transform parent, string name, Color color, float radius, bool raycast)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			Image obj = ((Component)Node(parent, name)).gameObject.AddComponent<Image>();
			obj.sprite = Rounded(ring: false);
			obj.type = (Type)1;
			obj.pixelsPerUnitMultiplier = 24f / Math.Max(0.05f, (_palette == Palette.Vanilla) ? Math.Min(radius, 0.25f) : radius);
			((Graphic)obj).color = color;
			((Graphic)obj).raycastTarget = raycast;
			return obj;
		}

		public void Border(Transform panel, Color color, float radius)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			Image val = ((Component)Node(panel, "Border")).gameObject.AddComponent<Image>();
			val.sprite = Rounded(ring: true);
			val.type = (Type)1;
			val.pixelsPerUnitMultiplier = 24f / Math.Max(0.05f, (_palette == Palette.Vanilla) ? Math.Min(radius, 0.25f) : radius);
			((Graphic)val).color = color;
			((Graphic)val).raycastTarget = false;
			Stretch(((Graphic)val).rectTransform, 0f, 0f, 0f, 0f);
		}

		public TextMeshProUGUI Label(Transform parent, string name, string value, float size, Color color, TextAlignmentOptions align)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI val = ((Component)Node(parent, name)).gameObject.AddComponent<TextMeshProUGUI>();
			TMP_FontAsset val2 = (_palette.ShopOSFont ? (RoundFont() ?? Font()) : Font());
			if ((Object)(object)val2 != (Object)null)
			{
				((TMP_Text)val).font = val2;
			}
			((TMP_Text)val).text = value;
			((TMP_Text)val).fontSize = size;
			((Graphic)val).color = color;
			((TMP_Text)val).alignment = align;
			((TMP_Text)val).enableWordWrapping = true;
			((TMP_Text)val).overflowMode = (TextOverflowModes)1;
			((Graphic)val).raycastTarget = false;
			return val;
		}

		public TextMeshProUGUI Title(Transform parent, string name, string value, float size)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI obj = Label(parent, name, value, size, TextColour, (TextAlignmentOptions)4097);
			((TMP_Text)obj).fontStyle = (FontStyles)(!_palette.ShopOSFont);
			return obj;
		}

		public RectTransform Button(Transform parent, string label, bool primary, float size, Action click)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00bc: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			Image val = Panel(parent, label, primary ? Accent : SurfaceRaised, 1.3f, raycast: true);
			Button obj = ((Component)val).gameObject.AddComponent<Button>();
			((Selectable)obj).targetGraphic = (Graphic)(object)val;
			ColorBlock colors = ((Selectable)obj).colors;
			((ColorBlock)(ref colors)).normalColor = Color.white;
			((ColorBlock)(ref colors)).highlightedColor = new Color(0.86f, 0.86f, 0.86f, 1f);
			((ColorBlock)(ref colors)).pressedColor = new Color(0.7f, 0.7f, 0.7f, 1f);
			((ColorBlock)(ref colors)).selectedColor = Color.white;
			((Selectable)obj).colors = colors;
			((UnityEvent)obj.onClick).AddListener((UnityAction)delegate
			{
				click();
			});
			TextMeshProUGUI val2 = Label(((Component)val).transform, "Label", label, size, primary ? _palette.Ink : TextColour, (TextAlignmentOptions)514);
			((TMP_Text)val2).fontStyle = (FontStyles)((primary && !_palette.ShopOSFont) ? 1 : 0);
			((TMP_Text)val2).enableWordWrapping = false;
			Stretch(((TMP_Text)val2).rectTransform, 0.6f, 0f, 0.6f, 0f);
			return ((Graphic)val).rectTransform;
		}

		public void Dropdown(Transform parent, List<string> options, int value, Action<int> changed, float x, float y, float w, float h, RectTransform pageRoot)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_011f: Expected O, but got Unknown
			int count = Math.Max(1, options.Count);
			int current = Math.Max(0, Math.Min(value, count - 1));
			Image val = Panel(parent, "Picker", Surface, 1f, raycast: true);
			Place(((Graphic)val).rectTransform, x, y, w, h);
			TextMeshProUGUI text = Label(((Component)val).transform, "Value", (options.Count > 0) ? options[current] : "", 0.85f, TextColour, (TextAlignmentOptions)514);
			((TMP_Text)text).enableWordWrapping = false;
			Stretch(((TMP_Text)text).rectTransform, h + 0.2f, 0f, h + 0.2f, 0f);
			Button obj = ((Component)val).gameObject.AddComponent<Button>();
			((Selectable)obj).targetGraphic = (Graphic)(object)val;
			((UnityEvent)obj.onClick).AddListener((UnityAction)delegate
			{
				Step(1);
			});
			RectTransform rt = Button(((Component)val).transform, "<", primary: false, 0.95f, delegate
			{
				Step(-1);
			});
			Place(rt, 0f, 0f, h, h);
			RectTransform rt2 = Button(((Component)val).transform, ">", primary: false, 0.95f, delegate
			{
				Step(1);
			});
			Place(rt2, w - h, 0f, h, h);
			void Step(int delta)
			{
				if (options.Count != 0)
				{
					current = (current + delta + count) % count;
					((TMP_Text)text).text = options[current];
					changed(current);
				}
			}
		}

		private static TMP_FontAsset? Font()
		{
			//IL_0064: 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)
			if (_fontLooked)
			{
				return _font;
			}
			_fontLooked = true;
			try
			{
				FontLocalizationQuickPatcher val = Object.FindObjectOfType<FontLocalizationQuickPatcher>();
				if ((Object)(object)val != (Object)null && (Object)(object)val.m_MainFont != (Object)null)
				{
					return _font = val.m_MainFont;
				}
				TextMeshProUGUI[] array = Resources.FindObjectsOfTypeAll<TextMeshProUGUI>();
				foreach (TextMeshProUGUI val2 in array)
				{
					if ((Object)(object)((TMP_Text)val2).font != (Object)null)
					{
						Scene scene = ((Component)val2).gameObject.scene;
						if (((Scene)(ref scene)).IsValid())
						{
							return _font = ((TMP_Text)val2).font;
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not find the game's font: " + ex.Message));
			}
			return _font = TMP_Settings.defaultFontAsset;
		}

		private static TMP_FontAsset? RoundFont()
		{
			if (_roundFontLooked)
			{
				return _roundFont;
			}
			if (Time.unscaledTime < _nextRoundFontLook)
			{
				return _roundFont;
			}
			_nextRoundFontLook = Time.unscaledTime + 5f;
			try
			{
				TMP_FontAsset val = null;
				TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
				foreach (TMP_FontAsset val2 in array)
				{
					if (!((Object)(object)val2 == (Object)null) && ((Object)val2).name.IndexOf("Fredoka", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						string text = ((Object)val2).name.ToLowerInvariant();
						if (!text.Contains("border") && !text.Contains("shadow") && !text.Contains("outline"))
						{
							_roundFontLooked = true;
							return _roundFont = val2;
						}
						if (val == null)
						{
							val = val2;
						}
					}
				}
				_roundFont = val;
				_roundFontLooked = (Object)(object)val != (Object)null;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not find ShopOS's font: " + ex.Message));
			}
			return _roundFont;
		}

		private static Sprite Rounded(bool ring)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			if (ring ? ((Object)(object)_ring != (Object)null) : ((Object)(object)_filled != (Object)null))
			{
				if (!ring)
				{
					return _filled;
				}
				return _ring;
			}
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			Color32[] array = (Color32[])(object)new Color32[4096];
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num = (float)j + 0.5f;
					float num2 = (float)i + 0.5f;
					float num3 = Mathf.Clamp(num, 24f, 40f);
					float num4 = Mathf.Clamp(num2, 24f, 40f);
					float num5 = Mathf.Sqrt((num - num3) * (num - num3) + (num2 - num4) * (num2 - num4));
					float num6 = Mathf.Clamp01(24f - num5 + 0.5f);
					if (ring)
					{
						float num7 = Mathf.Min(Mathf.Min(num, 64f - num), Mathf.Min(num2, 64f - num2));
						float num8 = ((num5 > 0f) ? (24f - num5) : num7);
						num6 *= Mathf.Clamp01(3f - num8 + 0.5f);
					}
					array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num6 * 255f));
				}
			}
			val.SetPixels32(array);
			val.Apply();
			Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(24f, 24f, 24f, 24f));
			((Object)val2).name = (ring ? "DaysOfTheWeekRing" : "DaysOfTheWeekRounded");
			Object.DontDestroyOnLoad((Object)(object)val);
			if (!ring)
			{
				return _filled = val2;
			}
			return _ring = val2;
		}
	}
}