<?php

use auctionforge\inc\controllers\PolylangSupport;
use auctionforge\inc\helpers\LotHelper;
use auctionforge\inc\helpers\SettingsHelper;

if (SettingsHelper::getOption('enable_recently_viewed', 'off') === 'on') : ?>
<style>
.bp-recently-viewed-header { padding: 10px 15px; }
.bp-recently-viewed-header .bp-title { font-size: 1.1em; font-weight: 600; }
.bp-btn-sm { padding: 4px 12px; font-size: 0.85em; }
.bp-btn-outline { background: transparent; border: 1px solid #333; color: #333; text-decoration: none; border-radius: 3px; cursor: pointer; }
.bp-btn-outline:hover { background: #333; color: #fff; }
.bp-lot__auction-info { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.bp-lot__auction-info .bp-subtitle { font-size: 0.85em; color: #666; }
.bp-badge { display: inline-block; padding: 2px 8px; font-size: 0.75em; font-weight: 600; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.5px; }
.bp-badge-green { background-color: #e6f4ea; color: #1e7e34; }
.bp-badge-blue { background-color: #e3f2fd; color: #1565c0; }
.bp-lot__viewed-at { padding: 4px 10px; }
.bp-text-muted { color: #999; font-size: 0.8em; }
#profile-recently-viewed-section .bp-lots { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; padding: 0 15px; }
#profile-recently-viewed-section .bp-lot { display: flex; flex-direction: column; border: 1px solid #eee; border-radius: 6px; overflow: hidden; background: #fff; }
#profile-recently-viewed-section .bp-lot__wrp-image { display: block; width: 100%; aspect-ratio: 1; overflow: hidden; background-color: #f5f5f5; }
#profile-recently-viewed-section .bp-lot__image { width: 100%; height: 100%; background-size: contain; background-position: center; background-repeat: no-repeat; background-color: #f5f5f5; }
#profile-recently-viewed-section .bp-lot__content { padding: 10px; }
#profile-recently-viewed-section .bp-lot__content_inner .bp-title { font-size: 0.85em; color: #e67e22; }
#profile-recently-viewed-section .bp-lot__content_inner article { font-size: 0.85em; margin-top: 2px; }
#profile-recently-viewed-section .bp-lot__auction-info { margin-top: 4px; }
#profile-recently-viewed-section .bp-lot__auction-info .bp-subtitle { font-size: 0.78em; }
#profile-recently-viewed-section .bp-lot__tool_wrapper { padding: 0 10px 8px; }
#profile-recently-viewed-section .bp-lot__tool .bp-subtitle { font-size: 0.78em; margin: 0; }
#profile-recently-viewed-section .bp-lot__tool .bp-price { font-size: 1em; font-weight: 700; margin: 0; }
#profile-recently-viewed-section .bp-lot__viewed-at { padding: 0 10px 8px; }
@media (max-width: 480px) { #profile-recently-viewed-section .bp-lots { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
</style>
<?php endif; ?>
<?php

$pageAuctionListId = SettingsHelper::getOption('auction_list', 0);
$lang = SettingsHelper::getOption("lang", "en");
if (PolylangSupport::isPolylangActive()) {
    $lang = pll_current_language();
}

if (PolylangSupport::isPolylangActive()) {
    $langCode = pll_current_language();
    $profilePageId = SettingsHelper::getOption('profile', 0);
    $translate = pll_get_post_translations($profilePageId);
    if (!empty($translate[$langCode])) {
        $profileLink = get_permalink($translate[$langCode]);
    } else {
        $profileLink = get_permalink($profilePageId);
    }
} else {
    $profileLink = get_permalink(SettingsHelper::getOption('profile', 0));
}
?>
<script type="text/template" id="profile-page-template">
    <div class="bp-content bp-justify-between bp-row bp-no-margin bp-add-padding">
        <div class="bp-col bp-d-flex bp-md-f-wrap bp-f-center">
            <div class="bp-content__text bp-justify-between bp-mb-0">
                <div data-tab-id="profile-tabs" class="bp-tabs-block bp-col bp-hidden bp-d-flex bp-f-center">
                    <nav class="nav bp-tabs-link">
                        <a class="nav-link active" id="bp-profile-link" href="#bp-account"><?= __('My Account', 'auctionforge') ?></a>
                        <a class="nav-link" id="bp-wish-list-link" href="#bp-wish-list"><?= __('Wish List', 'auctionforge') ?></a>
                        <a class="nav-link" id="bp-bids-list-link" href="#bp-my-bids"><?= __('My Bids', 'auctionforge') ?></a>
                        <a class="nav-link" id="bp-payment-methods-link" href="#bp-payment-methods"><?= __('Payment methods', 'auctionforge') ?></a>
                        <a class="nav-link" id="bp-winnings-list-link" href="#bp-winnings"><?= __('Winnings', 'auctionforge') ?></a>
                        <?php if (SettingsHelper::getOption('enable_recently_viewed', 'off') === 'on') : ?>
                        <a class="nav-link" id="bp-recently-viewed-link" href="#bp-recently-viewed"><?= __('Recently Viewed', 'auctionforge') ?></a>
                        <?php endif; ?>
                        <a class="logoutLink nav-link" href="#logout"><?= __('Logout', 'auctionforge') ?></a>
                    </nav>
                </div>
            </div>
        </div>
    </div>
    <div class="bp-row bp-fix-width-lot">
        <div id="profile-section" class="bp-d-flex bp-f-wrap bp-f-center bp-md-f-around">
            <div id="profile-tabs" class="bp-tabs-content bp-col">
                <div id="bp-account" class="active bp-tabs__block">
                    <a href="#" class="bp-visible bp-spoiler-trigger"><span><?= __('My Account', 'auctionforge') ?></span></a>
                    <div id="profile-account-section"
                         data-confirm-email="<?= __('Please complete your registration to participate in our auctions. <a href=\'#\' id=\'resendEmailSection\'>Resend email</a>.', 'auctionforge') ?>"
                         data-incomplete-profile="<?= __('Please complete your details.', 'auctionforge') ?>"
                         data-pending="<?= __('You are not approved to bid yet.', 'auctionforge') ?>"
                         class="bp-spoiler-block"></div>
                </div>
                <div id="bp-wish-list" class="bp-tabs__block">
                    <a href="#" class="bp-visible bp-spoiler-trigger"><span><?= __('Wish List', 'auctionforge') ?></span></a>
                    <div id="profile-wishlist-section" class="bp-spoiler-block"></div>
                </div>
                <div id="bp-my-bids" class="bp-tabs__block">
                    <a href="#" class="bp-visible bp-spoiler-trigger"><span><?= __('My Bids', 'auctionforge') ?></span></a>
                    <div id="profile-bids-section" class="bp-spoiler-block"></div>
                </div>
                <div id="bp-payment-methods" class="bp-tabs__block">
                    <a href="#" class="bp-visible bp-spoiler-trigger"><span><?= __('Payment methods', 'auctionforge') ?></span></a>
                    <div id="profile-payment-methods-section" class="bp-spoiler-block"></div>
                </div>
                <div id="bp-winnings" class="bp-tabs__block">
                    <a href="#" class="bp-visible bp-spoiler-trigger"><span><?= __('Winnings', 'auctionforge') ?></span></a>
                    <div id="profile-winnings-section" class="bp-spoiler-block"></div>
                </div>
                <?php if (SettingsHelper::getOption('enable_recently_viewed', 'off') === 'on') : ?>
                <div id="bp-recently-viewed" class="bp-tabs__block">
                    <a href="#" class="bp-visible bp-spoiler-trigger"><span><?= __('Recently Viewed', 'auctionforge') ?></span></a>
                    <div id="profile-recently-viewed-section" class="bp-spoiler-block"></div>
                </div>
                <?php endif; ?>
                <div id="bp-logout">
                    <a href="#logout" class="bp-visible bp-spoiler-trigger logoutLink"><span><?= __('Logout', 'auctionforge') ?></span></a>
                </div>
            </div>
        </div>
    </div>
</script>
<script type="text/template" id="profile-account-template">
    <div class="bp-col bp-d-flex bp-f-center">
        <div class="bp-user-state">
            <p class="title"><%- user.successMessage %></p>
        </div>
    </div>
    <div class="bp-tabs-block bp-col bp-hidden bp-d-flex bp-f-center">
        <form id="updateDetailsSection" action="<?= LotHelper::getPolyLangPermalink($pageAuctionListId) ?>" class="bp-from">
            <% _.forEach(fields, function(field, index) { %>
            <% if (field.type == 'phone') { %>
            <div id="addressField<%- index %>" class="bp-form-group <%- (field.hidden !== undefined) ? 'hidden' : '' %>">
                <div class="bp-form-group__inner bp-form-group__inline bp-form-group__list bp-form-group__phone">
                    <select style="width: 100%" <%- (field.required) ? 'required' : '' %> class="phoneCodeSelect" name="<%- index %>CountryCode" id="details<%-
                    index %>CountryCode"></select>
                    <input type="text" <%- (field.required) ? 'required' : '' %> placeholder="<%- bp_t(field.label) %> <%-
                    (field.required) ? '*' : '' %>" value="<%- field.value %>" class="bp-form-control" name="<%- index %>" id="profile<%- index %>">
                    <span class="bp-form-error hidden"></span>
                </div>
            </div>
            <% } else if (field.type == 'password') { %>
            <div id="addressField<%- index %>" class="bp-form-group bp-form-group_svg bp_show_password-action <%- (field.hidden !== undefined) ? 'hidden' : '' %>">
                <div class="bp-form-group__inner">
                    <input type="<%- field.type %>" <%- (field.required) ? 'required' : '' %> placeholder="<%- bp_t(field.label) %> <%-
                    (field.required) ? '*' : '' %>" value="<%- field.value %>" class="bp-form-control bp-form-control_eye" name="<%- index %>" id="profile<%- index %>">
                    <i class="bp_show_password svg-icon svg-eye"></i>
                    <span class="bp-form-error hidden"></span>
                </div>
            </div>
            <% } else if (field.type == 'email') { %>
            <div id="addressField<%- index %>" class="bp-form-group  bp-form-group_svg <%- (field.hidden !== undefined) ? 'hidden' : '' %>">
                <div class="bp-form-group__inner">
                    <input type="<%- field.type %>" disabled placeholder="<%- bp_t(field.label) %> <%-
                    (field.required) ? '*' : '' %>" value="<%- field.value %>" class="bp-form-control bp-form-control_email" name="<%- index %>" id="profile<%-
                    index %>">
                    <svg class="icon">
                        <use xlink:href="#pencil"></use>
                    </svg>
                    <span class="bp-form-error hidden"></span>
                </div>
            </div>
            <% } else if (field.type == 'select') { %>
            <div id="addressField<%- index %>" class="bp-form-group <%- (field.hidden !== undefined) ? 'hidden' : '' %>">
                <div class="bp-form-group__inner">
                    <select style="width: 100%" <%- (field.required) ? 'required' : '' %> name="<%- index %>" id="profile<%- index
                    %>"></select>
                    <span class="bp-form-error hidden"></span>
                </div>
            </div>
            <% } else { %>
            <div id="addressField<%- index %>" class="bp-form-group <%- (field.hidden !== undefined) ? 'hidden' : '' %>">
                <div class="bp-form-group__inner">
                    <input type="<%- field.type %>" <%- (field.required) ? 'required' : '' %> placeholder="<%- bp_t(field.label) %> <%-
                    (field.required) ? '*' : '' %>" value="<%- field.value %>" class="bp-form-control" name="<%- index %>" id="profile<%- index %>">
                    <span class="bp-form-error hidden"></span>
                </div>
            </div>
            <% } %>
            <% }); %>
            <div id="invitationsEnabled" class="bp-form-group bp-form-check bp-form-jc-start bp-lh-28">
                <input class="bp-form-check-input" name="isEnabled" id="isEnabled-field" type="checkbox">
                <label class="bp-form-check-label" for="isEnabled-field">
                    <?= sprintf(__('Allow "%s" to send me invitation for new auctions', 'auctionforge'), get_option('blogname')) ?>
                </label>
            </div>
            <div class="bp-form-group">
                <button id="sendUpdate" type="submit" class="bp-btn bp-btn-black"><?= __('Update', 'auctionforge') ?></button>
            </div>
            <div class="bp-form-group bp-text-right">
                <a id="optOutUser" class="bp-text bp-text-small"
                   href="<?= apply_filters("bs_data_subject_request_link", "https://bidspirit.com/ui/dataSubjectRequest?lang={$lang}") ?>"
                   rel="nofollow">
                    <?= __("Remove account", "auctionforge") ?>
                </a>
            </div>
        </form>
    </div>
</script>
<script type="text/template" id="profile-account-v2-template">
    <div class="bp-col bp-d-flex bp-f-center">
        <div class="bp-user-state">
            <p class="title"><%- user.successMessage %></p>
        </div>
    </div>
    <div class="bp-tabs-block bp-col bp-hidden bp-d-flex bp-f-center">
        <form id="updateDetailsSection" action="<?= LotHelper::getPolyLangPermalink($pageAuctionListId) ?>" class="bp-from">
            <% _.forEach(fields, function(field, index) { %>
                <% if (field.type == 'phone') { %>
                <div id="addressField<%- index %>" class="bp-form-group <%- (field.hidden !== undefined) ? 'hidden' : '' %>">
                    <div class="bp-form-group__inner bp-form-group__inline bp-form-group__list bp-form-group__phone">
                        <select style="width: 100%" <%- (field.required) ? 'required' : '' %> class="phoneCodeSelect" name="<%- index %>CountryCode" id="details<%-
                        index %>CountryCode"></select>
                        <input type="text" <%- (field.required) ? 'required' : '' %> placeholder="<%- bp_t(field.label) %> <%-
                        (field.required) ? '*' : '' %>" value="<%- field.value %>" class="bp-form-control" name="<%- index %>" id="profile<%- index %>">
                        <span class="bp-form-error hidden"></span>
                    </div>
                </div>
                <% } else if (field.type == 'password') { %>
                <div id="addressField<%- index %>" class="bp-form-group bp-form-group_svg bp_show_password-action <%- (field.hidden !== undefined) ? 'hidden' : '' %>">
                    <div class="bp-form-group__inner">
                        <input type="<%- field.type %>" <%- (field.required) ? 'required' : '' %> placeholder="<%- bp_t(field.label) %> <%-
                        (field.required) ? '*' : '' %>" value="<%- field.value %>" class="bp-form-control bp-form-control_eye" name="<%- index %>" id="profile<%- index %>">
                        <i class="bp_show_password svg-icon svg-eye"></i>
                        <span class="bp-form-error hidden"></span>
                    </div>
                </div>
                <% } else if (field.type == 'email') { %>
                <div id="addressField<%- index %>" class="bp-form-group  bp-form-group_svg <%- (field.hidden !== undefined) ? 'hidden' : '' %>">
                    <div class="bp-form-group__inner">
                        <input type="<%- field.type %>" disabled placeholder="<%- bp_t(field.label) %> <%-
                        (field.required) ? '*' : '' %>" value="<%- field.value %>" class="bp-form-control bp-form-control_email" name="<%- index %>" id="profile<%-
                        index %>">
                        <svg class="icon">
                            <use xlink:href="#pencil"></use>
                        </svg>
                        <span class="bp-form-error hidden"></span>
                    </div>
                </div>
                <% } else if (field.type == 'select') { %>
                <div id="addressField<%- index %>" class="bp-form-group <%- (field.hidden !== undefined) ? 'hidden' : '' %>">
                    <div class="bp-form-group__inner">
                        <select style="width: 100%" <%- (field.required) ? 'required' : '' %> name="<%- index %>" id="profile<%- index
                        %>"></select>
                        <span class="bp-form-error hidden"></span>
                    </div>
                </div>
                <% } else if (index === 'id' && (field.requireIdPhoto)) { %>
                <div id="addressField<%- index %>" class="bp-form-group <%- (field.hidden !== undefined) ? 'hidden' : '' %>">
                    <div class="bp-form-group__inner bp-mb-20">
                        <input type="<%- field.type %>" <%- (field.required) ? 'required' : '' %> placeholder="<%- bp_t(field.label) %> <%-
                        (field.required) ? '*' : '' %>" value="<%- field.value %>" class="bp-form-control" name="<%- index %>" id="profile<%- index %>">
                        <span class="bp-form-error hidden"></span>
                    </div>
                    <div id="deleteIdPhotoSection" class="bp-form-group__inner bp-form-group__file bp-d-flex bp-f-wrap bp-gap-1">
                        <label><?= __("Id photo", "auctionforge") ?><span class="bp-required">*</span></label>
                        <div class="bp-d-flex bp-f-between bp-d-flex bp-gap-1 bp-f-align-center">
                            <svg class="bp-icon bp-icon-green bp-mr-auto">
                                <use xlink:href="#check"></use>
                            </svg>
                            <button type="button" id="showIdPhoto" class="bp-btn bp-btn-icon bp-btn-sm">
                                <i class="svg-icon svg-eye"></i>
                                <?= __("Display", "auctionforge") ?>
                            </button>
                            <button type="button" id="deleteIdPhoto" class="bp-btn bp-btn-alert bp-btn-stretch">
                                <?= __("Delete", "auctionforge") ?>
                            </button>
                        </div>
                    </div>
                    <div id="uploadIdPhotoSection" class="bp-form-group__inner bp-form-group__file bp-d-flex bp-f-wrap bp-gap-1">
                        <label><?= __("Document photo", "auctionforge") ?>
                            <span class="bp-required"><%- (field.idPhotoUploadRequired) ? '*' : '' %></span>
                        </label>
                        <div class="bp-d-flex bp-f-between">
                            <input type="file" name="filePhotoId" id="uploadIdPhotoInput" <%- (!field.hasIdPhoto && field.idPhotoUploadRequired) ? 'required' : '' %>>
                            <button type="button" id="uploadPhotoIdAction" class="bp-btn bp-btn-default bp-btn-sm"><?= __("Upload", "auctionforge") ?></button>
                        </div>
                    </div>
                </div>
                <% } else { %>
                <div id="addressField<%- index %>" class="bp-form-group <%- (field.hidden !== undefined) ? 'hidden' : '' %>">
                    <div class="bp-form-group__inner">
                        <input type="<%- field.type %>" <%- (field.required) ? 'required' : '' %> placeholder="<%- bp_t(field.label) %> <%-
                        (field.required) ? '*' : '' %>" value="<%- field.value %>" class="bp-form-control" name="<%- index %>" id="profile<%- index %>">
                        <span class="bp-form-error hidden"></span>
                    </div>
                </div>
                <% } %>
            <% }); %>
            <div id="shippingFields" class="bp-form-group">
                <div class="bp-form-group__inner">
                    <input type="checkbox" checked name="shippingCheckbox" id="profileShippingCheckbox" class="bp-form-check-input">
                    <label for="profileShippingCheckbox" class="bp-form-group bp-form-check bp-form-jc-start bp-lh-28 bp-mb-0">
                        <?= __("My residential address is the same as the shipping address", "auctionforge") ?>
                    </label>
                </div>
            </div>
            <% if (shippingFields !== undefined) { %>
            <div id="wrpShippingField" class="wrp-bp-form-group shippingFields hidden">
                <% _.forEach(shippingFields, function(field, index) { %>
                <% if (field.type == 'select') { %>
                <div id="shippingField<%- index %>" class="bp-form-group <%- (field.hidden !== undefined) ? 'hidden' : '' %>">
                    <div class="bp-form-group__inner">
                        <select class="bp-shippingField" disabled
                                style="width: 100%" <%- (field.required) ? 'required' : '' %>
                                name="shipping.<%- index %>" id="shipping<%- index %>"></select>
                        <span class="bp-form-error hidden"></span>
                    </div>
                </div>
                <% } else { %>
                <div id="shippingField<%- index %>" class="bp-form-group <%- (field.hidden !== undefined) ? 'hidden' : '' %>">
                    <div class="bp-form-group__inner">
                        <input disabled type="<%- field.type %>" <%- (field.required) ? 'required' : '' %> placeholder="<%- bp_t(field.label) %> <%-
                        (field.required) ? '*' : '' %>" value="<%- field.value %>" class="bp-shippingField bp-form-control" name="shipping.<%- index %>"
                        id="shipping<%- index %>">
                        <span class="bp-form-error hidden"></span>
                    </div>
                </div>
                <% } %>
                <% }); %>
            </div>
            <% } %>
            <div id="invitationsEnabled" class="bp-form-group bp-form-check bp-form-jc-start bp-lh-28">
                <input class="bp-form-check-input" name="isEnabled" id="isEnabled-field" type="checkbox">
                <label class="bp-form-check-label" for="isEnabled-field">
                    <?= sprintf(__('Allow "%s" to send me invitation for new auctions', 'auctionforge'), get_option('blogname')) ?>
                </label>
            </div>
            <div class="bp-form-group">
                <button id="sendUpdate" type="submit" class="bp-btn bp-btn-black"><?= __('Update', 'auctionforge') ?></button>
            </div>
            <div class="bp-form-group bp-text-right">
                <a id="optOutUser" class="bp-text bp-text-small"
                   href="<?= apply_filters("bs_data_subject_request_link", "https://bidspirit.com/ui/dataSubjectRequest?lang={$lang}") ?>"
                   rel="nofollow">
                    <?= __("Remove account", "auctionforge") ?>
                </a>
            </div>
        </form>
    </div>
</script>
<script type="text/template" id="account-items-template">
    <div class="bp-row bp-row_profile bp-fix-width-lot">
        <div class="bp-lots bp-d-flex bp-f-wrap bp-f-center bp-md-f-around">
            <% let date = ""; %>
            <% _.forEach(items, function(lot, index) { %>
                <% if (date !== lot.auction.date) { %>
                    <div class="bp-lot-0 bp-lots__head">
                        <p class="bp-lot__date"><%= lot.auction.date %></p>
                    </div>
                    <% date = lot.auction.date %>
                <% } %>
                <% if ((lot.soldBid !== undefined && lot.soldBid.price !== undefined && lot.soldBid.isSold === true)
                || (lot.leadingBid !== undefined && lot.leadingBid.price !== undefined && lot.leadingBid.isSold === true)
                || (lot.item.wasInLiveAuction === true)) { %>
                    <div class="bp-lot" data-lot-index="<%- lot.lotIndex %>" data-lot-id="<%- lot.item.id %>" data-auction-number="<%- lot.item.auctionId %>">
                <% } else { %>
                    <% console.log("unsold", lot) %>
                    <div class="bp-lot" data-lot-index="<%- lot.lotIndex %>" data-lot-id="<%- lot.item.id %>" data-auction-number="<%- lot.item.auctionId %>">
                <% } %>
                    <a href="#" class="bp-lot__wrp-image" style="background-color: <%- bgColor %>">
                        <% if (lot.thumbnail !== undefined) { %>
                            <div class="bp-lot__image" style="background-image:url(<%- lot.thumbnail %>);">
                        <% } else { %>
                            <div class="bp-lot__image" style="background-image:url(<%- imageBlank %>);">
                        <% } %>
                        </div>
                    </a>
                    <div class="bp-lot__content">
                        <% if (lot.isFavorite) {%>
                            <span class="bp__wishlist bp__wishlist-active"></span>
                        <% } else { %>
                            <span class="bp__wishlist"></span>
                        <% } %>
                        <div class="bp-lot__content_inner">
                            <div class="bp-lot__title">
                                <a href="#"><span class="bp-title"><?= __('Lot', 'auctionforge') ?>&nbsp;<%- lot.item.itemIndex %>:</span></a>
                                <article>
                                    <div><a href="#"><strong><%- lot.item.name %></strong></a></div>
                                    <%= smartCut(lot.item.description, 20) %>
                                </article>
                            </div>
                            <div class="bp-lot__message">
                                <% if (lot.leadingBid && !lot.leadingBid.isSelf && lot.selfAbsenteeBid) { %>
                                <p class="bp-lot__message-inner bp-text-red bp-lot__message-you_bid">
                                    <?= __ ('Your bid of', 'auctionforge') ?> <%- formattedPrice(lot.selfAbsenteeBid.price, currency) %> <?= __('has been outbid by a higher bid', 'auctionforge') ?>
                                </p>
                                <% } else if (lot.leadingBid && lot.leadingBid.isSelf && lot.selfAbsenteeBid) { %>
                                <p class="bp-lot__message-inner bp-text-green bp-lot__message-you_bid">
                                    <?= __('Your max bid', 'auctionforge') ?>: <%- formattedPrice(lot.selfAbsenteeBid.price, currency) %>
                                </p>
                                <% } %>
                            </div>
                        </div>
                        <div class="bp-lot__tool_wrapper">
                            <% if (!lot.item.removedFromAuction) { %>
                            <div class="bp-lot__bid_wrapper bp-form-group">
                                <?php //TODO: Next feature #H91 task ?>
                                <div class="bp-form-group__inner js-data-bid-list-dis">
                                    <!--<input type="text" value="" class="bp-form-control" name="" id="">
                                    <span class="bp-form-error hidden"></span>-->
                                </div>
                            </div>
                            <% } %>
                            <% if (lot.leadingBid !== undefined && !lot.leadingBid.isSold && !lot.item.removedFromAuction) { %>
                                <% if (lot.leadingBid.isSelf) { %>
                                    <div class="bp-lot__tool bp-lead bp-bg-green">
                                <% } else if (lot.leadingBid && !lot.leadingBid.isSelf && lot.selfAbsenteeBid) { %>
                                    <div class="bp-lot__tool bp-lead bp-bg-red">
                                <% } else { %>
                                    <div class="bp-lot__tool bp-lead">
                                <% } %>
                                <% if (lot.leadingBid.isSelf) { %>
                                    <p class="bp-subtitle"><?= __('Your leading bid', 'auctionforge') ?>:</p>
                                <% } else {%>
                                    <p class="bp-subtitle"><?= __('Leading bid', 'auctionforge') ?>:</p>
                                <% } %>
                                <p class="bp-price"><%- formattedPrice(lot.leadingBid.price, currency) %></p>
                            </div>
                            <% } else if (lot.leadingBid !== undefined && lot.leadingBid.isSold && lot.soldBid !== undefined && !lot.item.removedFromAuction) { %>
                                <% if (lot.soldBid.isSelf) { %>
                                    <div class="bp-lot__tool bp-lead bp-bg-green">
                                        <p class="bp-subtitle"><?= __('Sold to you for', 'auctionforge') ?>:</p>
                                        <p class="bp-price"><%- formattedPrice(lot.soldBid.price, currency) %></p>
                                <% } else if (!lot.soldBid.isSelf) { %>
                                    <div class="bp-lot__tool bp-lead bp-bg-blue">
                                        <p class="bp-subtitle"><?= __('Sold for', 'auctionforge') ?>:</p>
                                        <p class="bp-price"><%- formattedPrice(lot.soldBid.price, currency) %></p>
                                <% } %>
                                </div>
                            <% } else if (!!lot.item.removedFromAuction) { %>
                                <div class="bp-lot__tool">
                                    <div class="bp-alert bp-alert-small bp-alert-radius-0 alert bp-alert-danger alert-primary" role="alert">
                                        <p><?= __("Lot was removed from auction", "auctionforge") ?></p>
                                    </div>
                                </div>
                            <% } else { %>
                                <div class="bp-lot__tool">
                                    <p class="bp-subtitle"><?= __('Start price', 'auctionforge') ?>:</p>
                                    <p class="bp-price"><%- formattedPrice(lot.startPrice, currency) %></p>
                                </div>
                            <% } %>
                        </div>
                    </div>
                </div>
            <% }); %>
        </div>
    </div>
</script>
<script type="text/template" id="recently-viewed-items-template">
    <div class="bp-row bp-row_profile bp-fix-width-lot">
        <div class="bp-recently-viewed-header bp-d-flex bp-f-between bp-f-center bp-mb-15">
            <p class="bp-title bp-mb-0"><?= __('Recently Viewed Items', 'auctionforge') ?></p>
            <a href="#" id="bp-clear-view-history" class="bp-btn bp-btn-sm bp-btn-outline"><?= __('Clear History', 'auctionforge') ?></a>
        </div>
        <div class="bp-lots bp-d-flex bp-f-wrap bp-f-center bp-md-f-around">
            <% _.forEach(items, function(lot, index) { %>
                <div class="bp-lot" data-post-id="<%- lot.post_id %>" data-term-id="<%- lot.term_id %>">
                    <a href="<%- lot.permalink %>" class="bp-lot__wrp-image">
                        <% if (lot.thumbnail) { %>
                            <div class="bp-lot__image" style="background-image:url(<%- lot.thumbnail %>);"></div>
                        <% } else { %>
                            <div class="bp-lot__image" style="background-image:url(<%- imageBlank %>);"></div>
                        <% } %>
                    </a>
                    <div class="bp-lot__content">
                        <div class="bp-lot__content_inner">
                            <div class="bp-lot__title">
                                <a href="<%- lot.permalink %>">
                                    <span class="bp-title"><?= __('Lot', 'auctionforge') ?>&nbsp;<%- lot.lot_index %>:</span>
                                </a>
                                <article>
                                    <div><a href="<%- lot.permalink %>"><strong><%- lot.lot_name %></strong></a></div>
                                </article>
                            </div>
                            <% if (lot.auction_name) { %>
                            <div class="bp-lot__auction-info">
                                <p class="bp-subtitle bp-mb-0"><%- lot.auction_name %></p>
                            </div>
                            <% } %>
                        </div>
                        <div class="bp-lot__tool_wrapper">
                            <div class="bp-lot__tool">
                                <% if (lot.sold_bid > 0) { %>
                                    <p class="bp-subtitle"><?= __('Sold for', 'auctionforge') ?>:</p>
                                    <p class="bp-price"><%- formattedPrice(lot.sold_bid, currency) %></p>
                                <% } else if (lot.leading_bid > 0) { %>
                                    <p class="bp-subtitle"><?= __('Leading bid', 'auctionforge') ?>:</p>
                                    <p class="bp-price"><%- formattedPrice(lot.leading_bid, currency) %></p>
                                <% } else if (lot.start_price > 0) { %>
                                    <p class="bp-subtitle"><?= __('Start price', 'auctionforge') ?>:</p>
                                    <p class="bp-price"><%- formattedPrice(lot.start_price, currency) %></p>
                                <% } else if (lot.estimated_price) { %>
                                    <p class="bp-subtitle"><?= __('Estimated price', 'auctionforge') ?>:</p>
                                    <p class="bp-price"><%- lot.estimated_price %></p>
                                <% } %>
                            </div>
                            <div class="bp-lot__viewed-at">
                                <small class="bp-text-muted"><%- lot.viewed_at_formatted %></small>
                            </div>
                        </div>
                    </div>
                </div>
            <% }); %>
        </div>
    </div>
</script>
<script type="text/template" id="account-empty-template">
    <div class="bp-row bp-fix-width-lot">
        <div class="bp-d-flex bp-f-wrap bp-f-center bp-mb-30">
            <p><%- message %></p>
        </div>
    </div>
</script>
<script type="text/template" id="account-link-profile">
    <% if (login) {%>
    <a href="<?= $profileLink ?>" class="bp-login-link">
        <i class="icon-user"></i> <span><?= __('Profile', 'auctionforge') ?></span>
    </a>
    <% } else { %>
    <a href="#" class="bp-login-link" data-micromodal-trigger="modal-login">
        <i class="icon-user"></i> <span><?= __('Login', 'auctionforge') ?></span>
    </a>
    <% } %>
</script>
<script type="text/template" id="account-link-register">
    <% if (!login) {%>
    <a href="#" class="bp-login-link" data-micromodal-trigger="modal-register">
        <span><?= __('Register', 'auctionforge') ?></span>
    </a>
    <% } %>
</script>
<script type="text/template" id="main-notice-template">
    <div class="bp-container">
        <div class="bp-row">
            <% if (type === 'PENDING') { %>
            <div class="bp-col bp-alert alert bp-alert-danger alert-primary bp-text-center bp-mt-10" role="alert">
                <p><?= __('Your account is pending approval. You will receive an email when you are approved to bid.', 'auctionforge') ?></p>
            </div>
            <% } else if (type === 'INCOMPLETE_PROFILE') { %>
                <% if (emailConfirmed !== undefined && emailConfirmed === true) { %>
                    <div class="bp-col bp-alert alert bp-alert-danger alert-primary bp-text-center bp-mt-10" role="alert">
                        <p><?= __('Please complete your registration to participate in our auctions.', 'auctionforge') ?> <a href="<?= $profileLink ?>"><strong><?= __('Profile', 'auctionforge') ?></strong></a></p>
                    </div>
                <% } else if (emailConfirmed === false) { %>
                    <div class="bp-col bp-alert alert bp-alert-danger alert-primary bp-text-center bp-mt-10" role="alert">
                        <p><?= __('Please complete your registration to participate in our auctions. <a href=\'#\' id=\'resendEmailSection\'>Resend email</a>.', 'auctionforge') ?></p>
                    </div>
                <% } %>
            <% } %>
        </div>
    </div>
</script>