@implements IDisposable
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <base href="/" />
    <meta name="description" content="KeyMotive's Summer Best Customer Program Enrollment" />
    <meta name="author" content="KeyMotive LLC" />
    <meta name="Charset" content="US-ASCII" />
    <meta name="Distribution" content="Global" />
    <meta name="Rating" content="General" />
    <meta name="Robots" content="INDEX,FOLLOW" />
    <meta name="Revisit-after" content="14 Days" />
    <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin />
    <link href='https://fonts.googleapis.com/css?family=Roboto|Handlee|Candal|Exo 2|Armata|Poppins|Kalam:wght@300&display=swap' rel='stylesheet' type='text/css' />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css" integrity="sha512-jnSuA4Ss2PkkikSOLtYs8BlYIeeIK1h99ty4YfvRPAlzr377vr3CXDb7sb7eEEBYjDtcYj+AjBH3FLv5uSJuXg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    <link rel="stylesheet" href="app.css" />
    <link rel="stylesheet" href="WinterBestCustomerWebForm.styles.css" />
    <link rel="icon" type="image/png" sizes="512x512" href="/img/favico-512.png">
    <link rel="icon" type="image/png" sizes="256x256" href="/img/favico-256.png">
    <link rel="icon" type="image/png" sizes="128x128" href="/img/favico-128.png">
    <link rel="icon" type="image/png" sizes="64x64" href="/img/favico-64.png">
    <link rel="icon" type="image/png" sizes="32x32" href="/img/favico-32.png">
    <style type="text/css">
        div.container {
        background-color: #fff;
        min-height: 100vh;
        }
    </style>
    @* <HeadOutlet @rendermode="@(new InteractiveServerRenderMode(false))" /> *@
    <HeadOutlet @rendermode="InteractiveServer" />
    <link rel="stylesheet" href="https://blazor.cdn.telerik.com/blazor/6.2.0/kendo-theme-bootstrap/swatches/bootstrap-main.css" />
    <script src="https://blazor.cdn.telerik.com/blazor/6.2.0/telerik-blazor.min.js" defer></script>
</head>

<body>
    <!-- Turn off pre-rendering -->
    @* <Routes @rendermode="@(new InteractiveServerRenderMode(false))" /> *@
    <Routes @rendermode="InteractiveServer" />
    <script src="_framework/blazor.web.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/js/bootstrap.bundle.min.js" integrity="sha512-7Pi/otdlbbCR+LnW+F7PwFcSDJOuUJB3OxtEHbg4vSMvzvJjde4Po1v4BR9Gdc9aXNUNFVUY+SK51wWT8WF0Gg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/js/all.min.js" integrity="sha512-u3fPA7V8qQmhBPNT5quvaXVa1mnnLSXUep5PS1qo5NRzHwG19aHmNJnj1Q8hpA/nBWZtZD4r4AX6YOt5ynLN2g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script>
        window.WriteCookie = {
        WriteCookie: function (name, value, days) {
        var expires;
        if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        expires = "; expires=" + date.toGMTString();
        }
        else {
        expires = "";
        }
        document.cookie = name + "=" + value + expires + "; path=/";
        }
        }
        window.ReadCookie = {
        ReadCookie: function (cname) {
        var name = cname + "=";
        var decodedCookie = decodeURIComponent(document.cookie);
        var ca = decodedCookie.split(';');
        for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
        c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
        return c.substring(name.length, c.length);
        }
        }
        return "";
        }
        }
    </script>
    <pre>@errMsg</pre>
@*     @if (appState != null)
    {
        <pre style="font-size:.8em">
            SessionId: @appState.SessionId
            DateCreated: @appState.DateCreated
            DateExpires: @appState.DateExpires
            IPAddress: @appState.myIpAddress
        </pre>
    } *@
</body>

</html>
@code {
    [CascadingParameter]
    public CascadingAppState appState { get; set; }

    #region "IPADDR"
    [CascadingParameter] HttpContext? HttpContext { get; set; }
    [Inject] public PersistentComponentState ApplicationState { get; set; } = default!;

    private PersistingComponentStateSubscription? _persistingSubscription;
    //private bool _subsequentRender;
    private string RemoteIpAddress = "Not Set";

    protected override void OnInitialized()
    {
        this.RemoteIpAddress = this.HttpContext?.Connection.RemoteIpAddress?.ToString() ?? "Not Set";
        _persistingSubscription = ApplicationState.RegisterOnPersisting(this.PersistData);
    }

    public Task PersistData()
    {
        this.ApplicationState.PersistAsJson<string>(ClassObj.IPAddressService.TokenName, this.RemoteIpAddress);
        return Task.CompletedTask;
    }

    void IDisposable.Dispose()
    {
        _persistingSubscription?.Dispose();
    }
#endregion

    private string errMsg = string.Empty;
}
