@using BTCPayServer
@using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Data
@using BTCPayServer.Plugins.SideShift
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model BTCPayServer.Plugins.SideShift.SideShiftSettings
@inject SideShiftService SideShiftService
@{
    ViewData.SetActivePage("SideShift", "SideShift", "SideShift");
    var store = Context.GetStoreData();
    var allowedPaymentMethods = store.GetEnabledPaymentIds()
        .Where(id => !id.ToString().EndsWith("LN") && !id.ToString().EndsWith("LNURL"))
        .Select(pmi => new SelectListItem(pmi.ToString(), pmi.ToString()))
        
        .Prepend(new SelectListItem("Any", ""));
    var coins = await SideShiftService.GetDepositOptions();
    var allowedCoins = coins.OrderBy(coin => coin.ToString()).Select(c => new SelectListItem(c.ToString(), $"{c.CryptoCode}_{c.Network}"));
}


<form method="post">

    <div class="sticky-header-setup"></div>
    <div class="sticky-header d-sm-flex align-items-center justify-content-between">
        <h2 class="mb-0">@ViewData["Title"]</h2>
        <div class="d-flex gap-3 mt-3 mt-sm-0">

            <button name="command" type="submit" value="save" class="btn btn-primary">Save</button>
        </div>
    </div>


    <partial name="_StatusMessage"/>
    <div class="alert alert-warning mb-4" role="alert">
        If you are enabling SideShift support, we advise that you configure the invoice expiration to a minimum of 30 minutes as it may take longer than the default 15 minutes to convert the funds.
    </div>

    <div class="row">
        <div class="col-xl-8 col-xxl-constrain">
            <div class="form-group">
                <div class="d-flex align-items-center">
                    <input asp-for="Enabled" type="checkbox" class="btcpay-toggle me-2"/>
                    <label asp-for="Enabled" class="form-label mb-0 me-1"></label>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="PreferredTargetPaymentMethodId" class="form-label" data-required>Convert always to this payment method, if possible</label>
                <select asp-for="PreferredTargetPaymentMethodId" asp-items="allowedPaymentMethods" class="form-select"></select>
            </div>
            <div class="form-group">
                <label asp-for="ExplicitMethods" class="form-label" data-required>Show these conversion options as individual payment methods</label>
                <select style="min-height: 300px;" multiple asp-for="ExplicitMethods" asp-items="@allowedCoins" class="form-select"></select>
            </div>

            <div class="form-group">
                <div class="d-flex align-items-center">
                    <input asp-for="OnlyShowExplicitMethods" type="checkbox" class="btcpay-toggle me-2"/>
                    <label asp-for="OnlyShowExplicitMethods" class="form-label mb-0 me-1">Only show explicit methods</label>
                </div>
            </div>

        </div>
    </div>
</form>