using System.Collections.Generic;
using UniWebViewExternal;
///
/// Represents the back-forward navigation history list of a UniWebView instance.
/// This class manages the browsing history and provides access to previous and next pages.
///
/// You do not create an instance of this class directly. Instead, you get an instance of this class to represent the
/// back-forward list of a UniWebView instance by calling the `CopyBackForwardList` method of the `UniWebView` class.
///
/// The content of this class is read-only and fixed when the instance is created. It does not get updated with the
/// web view's navigation history automatically. If you need the latest navigation history, you should call the method
/// `CopyBackForwardList` again to get a new instance of this class.
///
public class UniWebViewBackForwardList {
private readonly List items;
private readonly int currentIndex;
public UniWebViewBackForwardList(string json) {
var dict = Json.Deserialize(json) as Dictionary;
if (dict.TryGetValue("currentIndex", out object currentIndexObj) &&
int.TryParse(currentIndexObj.ToString(), out int parsedIndex))
{
currentIndex = parsedIndex;
}
items = new List();
if (!(dict["items"] is List