using System;
using System.Collections.Generic;
using System.Globalization;
using Jellyfin.Plugin.SRFPlay.Configuration;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Serialization;

namespace Jellyfin.Plugin.SRFPlay;

/// <summary>
/// The main plugin.
/// </summary>
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
{
    /// <summary>
    /// Initializes a new instance of the <see cref="Plugin"/> class.
    /// </summary>
    /// <param name="applicationPaths">Instance of the <see cref="IApplicationPaths"/> interface.</param>
    /// <param name="xmlSerializer">Instance of the <see cref="IXmlSerializer"/> interface.</param>
    public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
        : base(applicationPaths, xmlSerializer)
    {
        Instance = this;
    }

    /// <inheritdoc />
    public override string Name => "SRF Play";

    /// <inheritdoc />
    public override Guid Id => Guid.Parse("a4b12f86-8c3d-4e9a-b7f2-1d5e6c8a9b4f");

    /// <summary>
    /// Gets the current plugin instance.
    /// </summary>
    public static Plugin? Instance { get; private set; }

    /// <inheritdoc />
    public IEnumerable<PluginPageInfo> GetPages()
    {
        return
        [
            new PluginPageInfo
            {
                Name = Name,
                EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Configuration.configPage.html", GetType().Namespace)
            }

            // Note: the recordings manager is intentionally NOT registered as a plugin
            // page. Plugin pages live under the admin Dashboard and are admin-gated, which
            // both caused a redirect to the recordings page and made it inaccessible to
            // normal users. Recordings are served as a standalone, user-accessible page at
            // GET /Plugins/SRFPlay/Recording/Page (see RecordingController).
        ];
    }
}
