#pragma checksum "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e0a2642c7baa3781ff8bc4211e652dc9a95f8ceb"
// <auto-generated/>
#pragma warning disable 1591
namespace spanreed.Client.Shared
{
    #line hidden
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Components;
#nullable restore
#line 1 "/home/skins/projects/spanreed/Client/_Imports.razor"
using System.Net.Http;

#line default
#line hidden
#nullable disable
#nullable restore
#line 2 "/home/skins/projects/spanreed/Client/_Imports.razor"
using System.Net.Http.Json;

#line default
#line hidden
#nullable disable
#nullable restore
#line 3 "/home/skins/projects/spanreed/Client/_Imports.razor"
using Microsoft.AspNetCore.Components.Forms;

#line default
#line hidden
#nullable disable
#nullable restore
#line 4 "/home/skins/projects/spanreed/Client/_Imports.razor"
using Microsoft.AspNetCore.Components.Routing;

#line default
#line hidden
#nullable disable
#nullable restore
#line 5 "/home/skins/projects/spanreed/Client/_Imports.razor"
using Microsoft.AspNetCore.Components.Web;

#line default
#line hidden
#nullable disable
#nullable restore
#line 6 "/home/skins/projects/spanreed/Client/_Imports.razor"
using Microsoft.AspNetCore.Components.Web.Virtualization;

#line default
#line hidden
#nullable disable
#nullable restore
#line 7 "/home/skins/projects/spanreed/Client/_Imports.razor"
using Microsoft.AspNetCore.Components.WebAssembly.Http;

#line default
#line hidden
#nullable disable
#nullable restore
#line 8 "/home/skins/projects/spanreed/Client/_Imports.razor"
using Microsoft.JSInterop;

#line default
#line hidden
#nullable disable
#nullable restore
#line 9 "/home/skins/projects/spanreed/Client/_Imports.razor"
using spanreed.Client;

#line default
#line hidden
#nullable disable
#nullable restore
#line 10 "/home/skins/projects/spanreed/Client/_Imports.razor"
using spanreed.Client.Shared;

#line default
#line hidden
#nullable disable
#nullable restore
#line 1 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
using Microsoft.AspNetCore.SignalR.Client;

#line default
#line hidden
#nullable disable
#nullable restore
#line 2 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
using spanreed.Shared;

#line default
#line hidden
#nullable disable
    public partial class NavMenu : Microsoft.AspNetCore.Components.ComponentBase, IDisposable
    {
        #pragma warning disable 1998
        protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
        {
            __builder.OpenElement(0, "div");
            __builder.AddAttribute(1, "class", "top-row pl-4 navbar navbar-dark");
            __builder.AddAttribute(2, "b-9ym6xv191f");
            __builder.AddMarkupContent(3, "<a class=\"navbar-brand\" href b-9ym6xv191f>spanreed</a>\r\n    ");
            __builder.OpenElement(4, "button");
            __builder.AddAttribute(5, "class", "navbar-toggler");
            __builder.AddAttribute(6, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create<Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this, 
#nullable restore
#line 9 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
                                             ToggleNavMenu

#line default
#line hidden
#nullable disable
            ));
            __builder.AddAttribute(7, "b-9ym6xv191f");
            __builder.AddMarkupContent(8, "<span class=\"navbar-toggler-icon\" b-9ym6xv191f></span>");
            __builder.CloseElement();
            __builder.CloseElement();
            __builder.AddMarkupContent(9, "\r\n\r\n");
            __builder.OpenElement(10, "div");
            __builder.AddAttribute(11, "class", 
#nullable restore
#line 14 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
             NavMenuCssClass

#line default
#line hidden
#nullable disable
            );
            __builder.AddAttribute(12, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create<Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this, 
#nullable restore
#line 14 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
                                        ToggleNavMenu

#line default
#line hidden
#nullable disable
            ));
            __builder.AddAttribute(13, "b-9ym6xv191f");
            __builder.OpenElement(14, "ul");
            __builder.AddAttribute(15, "class", "nav flex-column");
            __builder.AddAttribute(16, "b-9ym6xv191f");
#nullable restore
#line 16 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
         foreach (var room in rooms) {

#line default
#line hidden
#nullable disable
            __builder.OpenElement(17, "li");
            __builder.AddAttribute(18, "class", "nav-item px-3");
            __builder.AddAttribute(19, "b-9ym6xv191f");
            __builder.OpenComponent<Microsoft.AspNetCore.Components.Routing.NavLink>(20);
            __builder.AddAttribute(21, "class", "nav-link");
            __builder.AddAttribute(22, "href", 
#nullable restore
#line 18 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
                                                room

#line default
#line hidden
#nullable disable
            );
            __builder.AddAttribute(23, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => {
                __builder2.AddMarkupContent(24, "<span class=\"oi oi-list-rich\" aria-hidden=\"true\" b-9ym6xv191f></span> ");
                __builder2.AddContent(25, 
#nullable restore
#line 19 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
                                                                              room

#line default
#line hidden
#nullable disable
                );
            }
            ));
            __builder.CloseComponent();
            __builder.CloseElement();
#nullable restore
#line 22 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
        }

#line default
#line hidden
#nullable disable
            __builder.OpenElement(26, "li");
            __builder.AddAttribute(27, "class", "nav-item px-3");
            __builder.AddAttribute(28, "b-9ym6xv191f");
            __builder.AddMarkupContent(29, "<span class=\"oi\" aria-hidden=\"true\" b-9ym6xv191f></span> ");
            __builder.OpenElement(30, "input");
            __builder.AddAttribute(31, "id", "nav-text");
            __builder.AddAttribute(32, "class", "nav");
            __builder.AddAttribute(33, "type", "text");
            __builder.AddAttribute(34, "onkeypress", Microsoft.AspNetCore.Components.EventCallback.Factory.Create<Microsoft.AspNetCore.Components.Web.KeyboardEventArgs>(this, 
#nullable restore
#line 24 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
                                                                                                                                  EnterBar

#line default
#line hidden
#nullable disable
            ));
            __builder.AddAttribute(35, "placeholder", "Create Room");
            __builder.AddAttribute(36, "value", Microsoft.AspNetCore.Components.BindConverter.FormatValue(
#nullable restore
#line 24 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
                                                                                                           NewRoomBox

#line default
#line hidden
#nullable disable
            ));
            __builder.AddAttribute(37, "onchange", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => NewRoomBox = __value, NewRoomBox));
            __builder.SetUpdatesAttributeName("value");
            __builder.AddAttribute(38, "b-9ym6xv191f");
            __builder.CloseElement();
            __builder.CloseElement();
            __builder.CloseElement();
            __builder.CloseElement();
        }
        #pragma warning restore 1998
#nullable restore
#line 29 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
       
    private string NewRoom;
    private string NewRoomBox;
    private bool collapseNavMenu = true;

    private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;

    private void ToggleNavMenu()
    {
        collapseNavMenu = !collapseNavMenu;
    }

    private HubConnection hubConnection;
    private List<string> rooms = new List<string>();

    protected override async Task OnInitializedAsync() {
        hubConnection = new HubConnectionBuilder().WithUrl(NavigationManager.ToAbsoluteUri("/addroom")).Build();
        hubConnection.On<string>("NewRoom", name => {
            rooms.Add(name);
            rooms.Sort();
            StateHasChanged();
        });
        var existing_rooms = await Http.GetFromJsonAsync<string[]>("Room");

        if (existing_rooms != null) {
            foreach (var room in existing_rooms)
            {
                rooms.Add(room);
                rooms.Sort();
            }
        }
        await hubConnection.StartAsync();
        var roomName = NavigationManager.Uri.Split("/").LastOrDefault();
        if (roomName.Length > 0) {
            await hubConnection.SendAsync("AddRoom", NavigationManager.Uri.Split("/").LastOrDefault());
        }
    }

    async Task EnterBar(KeyboardEventArgs e) {
        if (e.Key.Equals("Enter")) {
            Console.WriteLine(NewRoom);
            await hubConnection.SendAsync("AddRoom", NewRoom);
            NavigationManager.NavigateTo(NewRoom);
            NewRoom = "";
            NewRoomBox = "";
        } else if (e.Key.Length == 1) {
            NewRoom = NewRoom + e.Key;
        }
    }

    public bool IsConnected =>
        hubConnection.State == HubConnectionState.Connected;

    public void Dispose() {
        _ = hubConnection.DisposeAsync();
    }

#line default
#line hidden
#nullable disable
        [global::Microsoft.AspNetCore.Components.InjectAttribute] private HttpClient Http { get; set; }
        [global::Microsoft.AspNetCore.Components.InjectAttribute] private NavigationManager NavigationManager { get; set; }
    }
}
#pragma warning restore 1591
