<%
var title = gettext("Draft (Never published)");
if (visibilityState === 'staff_only') {
    title = gettext("Visible to Staff Only");
} else if (visibilityState === 'live') {
    title = gettext("Published and Live");
} else if (published && !hasChanges) {
    title = gettext("Published (not yet released)");
} else if (published && hasChanges) {
    title = gettext("Draft (Unpublished changes)");
}

var releaseLabel = gettext("Release:");
if (visibilityState === 'live') {
    releaseLabel = gettext("Released:");
} else if (visibilityState === 'ready') {
    releaseLabel = gettext("Scheduled:");
}

var visibleToStaffOnly = visibilityState === 'staff_only';
%>
<div class="bit-publishing <%- visibilityClass %> <% if (releaseDate) { %>is-scheduled<% } %>">
    <h3 class="bar-mod-title pub-status"><span class="sr"><%- gettext("Publishing Status") %></span>
        <%- title %>
    </h3>

    <div class="wrapper-last-draft bar-mod-content">
        <p class="copy meta">
            <% if (hasChanges && editedOn && editedBy) { %>
                <%= HtmlUtils.interpolateHtml(
                        gettext("Draft saved on {lastSavedStart}{editedOn}{lastSavedEnd} by {editedByStart}{editedBy}{editedByEnd}"),
                        {
                            lastSavedStart: HtmlUtils.HTML('<span class="date">'),
                            editedOn: editedOn,
                            lastSavedEnd: HtmlUtils.HTML('</span>'),
                            editedByStart: HtmlUtils.HTML('<span class="user">'),
                            editedBy: editedBy,
                            editedByEnd: HtmlUtils.HTML('</span>')
                        }
                    ) %>
            <% } else if (publishedOn && publishedBy) { %>
                <%= HtmlUtils.interpolateHtml(
                        gettext("Last published {lastPublishedStart}{publishedOn}{lastPublishedEnd} by {publishedByStart}{publishedBy}{publishedByEnd}"),
                        {
                            lastPublishedStart: HtmlUtils.HTML('<span class="date">'),
                            publishedOn: publishedOn,
                            lastPublishedEnd: HtmlUtils.HTML('</span>'),
                            publishedByStart: HtmlUtils.HTML('<span class="user">'),
                            publishedBy: publishedBy,
                            publishedByEnd: HtmlUtils.HTML('</span>')
                        }
                    ) %>
            <% } else { %>
                <%- gettext("Previously published") %>
            <% } %>
        </p>
    </div>

    <% if (!course.get('self_paced')) { %>
        <div class="wrapper-release bar-mod-content">
            <h5 class="title"><%- releaseLabel %></h5>
            <p class="copy">
                <% if (releaseDate) { %>
                    <span class="release-date"><%- releaseDate %></span>
                    <span class="release-with">
                        <%- interpolate(
                            gettext('with %(release_date_from)s'), { release_date_from: releaseDateFrom }, true
                        ) %>
                    </span>

                <% } else { %>
                    <%- gettext("Unscheduled") %>
                <% } %>
            </p>
        </div>
    <% } %>

    <div class="wrapper-visibility bar-mod-content">
        <h5 class="title">
            <% if (released && published && !hasChanges) { %>
                <%- gettext("Is Visible To:") %>
            <% } else { %>
                <%- gettext("Will Be Visible To:") %>
            <% } %>
        </h5>
        <% if (visibleToStaffOnly) { %>
            <p class="visbility-copy copy">
                <%- gettext("Staff Only") %>
                <% if (!hasExplicitStaffLock) { %>
                    <span class="inherited-from">
                        <%- interpolate(
                            gettext("with %(section_or_subsection)s"),{ section_or_subsection: staffLockFrom }, true
                        ) %>
                    </span>
                <% } %>
            </p>
        <% } else { %>
            <p class="visbility-copy copy"><%- gettext("Staff and Learners") %></p>
        <% } %>
            <% if (hasPartitionGroupComponents) { %>
                <p class="note-visibility">
                    <span class="icon fa fa-eye" aria-hidden="true"></span>
                    <span class="note-copy"><%- gettext("Access to some content in this unit is restricted to specific groups of learners.") %></span>
                </p>
            <% } %>
        <ul class="actions-inline">
            <li class="action-inline">
                <a href="" class="action-staff-lock" role="button" aria-pressed="<%- hasExplicitStaffLock %>">
                <% if (hasExplicitStaffLock) { %>
                    <span class="icon fa fa-check-square-o" aria-hidden="true"></span>
                <% } else { %>
                    <span class="icon fa fa-square-o" aria-hidden="true"></span>
                <% } %>
                <%- gettext('Hide from learners') %>
            </a>
            </li>
        </ul>
        <p>
            <%- gettext("Note: Do not hide graded assignments after they have been released.") %>
        </p>
    </div>

    <div class="wrapper-pub-actions bar-mod-actions">
        <ul class="action-list">
            <li class="action-item">
                <a class="action-publish action-primary <% if (published && !hasChanges) { %>is-disabled<% } %>"
                   href="" aria-disabled="<% if (published && !hasChanges) { %>true<% } else { %>false<% } %>" ><%- gettext("Publish") %>
                </a>
            </li>
            <li class="action-item">
                <a class="action-discard action-secondary <% if (!published || !hasChanges) { %>is-disabled<% } %>"
                   href="" aria-disabled="<% if (!published || !hasChanges) { %>true<% } else { %>false<% } %>"><%- gettext("Discard Changes") %>
                </a>
            </li>
        </ul>
    </div>
</div>