<div class='container'>
  {{custom-html "top"}}
  {{global-notice}}
</div>

<div class="container">
  <section class='user-main'>
    <section {{bind-attr class="collapsedInfo :about model.profileBackground:has-background:no-background"}}  style={{model.profileBackground}}>
    <div class='staff-counters'>
      {{#if model.number_of_flags_given}}
        <div><span class="helpful-flags">{{model.number_of_flags_given}}</span>&nbsp;{{i18n 'user.staff_counters.flags_given'}}</div>
      {{/if}}
      {{#if model.number_of_flagged_posts}}
        <div>
          {{#link-to 'user.flaggedPosts' model}}
            <span class="flagged-posts">{{model.number_of_flagged_posts}}</span>&nbsp;{{i18n 'user.staff_counters.flagged_posts'}}
          {{/link-to}}
        </div>
      {{/if}}
      {{#if model.number_of_deleted_posts}}
        <div>
          {{#link-to 'user.deletedPosts' model}}
            <span class="deleted-posts">{{model.number_of_deleted_posts}}</span>&nbsp;{{i18n 'user.staff_counters.deleted_posts'}}
          {{/link-to}}
        </div>
      {{/if}}
      {{#if model.number_of_suspensions}}
        <div><span class="suspensions">{{model.number_of_suspensions}}</span>&nbsp;{{i18n 'user.staff_counters.suspensions'}}</div>
      {{/if}}
      {{#if model.number_of_warnings}}
        <div><span class="warnings-received">{{model.number_of_warnings}}</span>&nbsp;{{i18n 'user.staff_counters.warnings_received'}}</div>
      {{/if}}
    </div>
      <div class='profile-image'></div>
      <div class='details'>
        <div class='primary'>
          {{bound-avatar model "huge"}}
          <section class='controls'>
            <ul>
              {{#if model.can_send_private_message_to_user}}
              <li>
                <a class='btn btn-primary right' {{action "composePrivateMessage" model}}>
                  {{fa-icon "envelope"}}
                  {{i18n 'user.private_message'}}
                </a>
              </li>
              {{/if}}
              {{#if viewingSelf}}
                <li><a {{action "logout"}} class='btn btn-danger right'>{{fa-icon "sign-out"}}{{i18n 'user.log_out'}}</a></li>
              {{/if}}
              {{#if currentUser.staff}}
                <li><a href={{model.adminPath}} class='btn right'>{{fa-icon "wrench"}}{{i18n 'admin.user.show_admin_profile'}}</a></li>
              {{/if}}
              {{#if model.can_edit}}
                <li>{{#link-to 'preferences' class="btn right"}}{{fa-icon "cog"}}{{i18n 'user.preferences'}}{{/link-to}}</li>
              {{/if}}
              {{#if canInviteToForum}}
                <li>{{#link-to 'user.invited' class="btn right"}}{{fa-icon "user-plus"}}{{i18n 'user.invited.title'}}{{/link-to}}</li>
              {{/if}}
            </ul>
          </section>

          <div class="primary-textual">
            <h1>{{model.username}} {{user-status model currentUser=currentUser}}</h1>
            <h2>{{model.name}}</h2>
            {{#if model.title}}
              <h3>{{model.title}}</h3>
            {{/if}}
            <h3>
            {{#if model.location}}{{fa-icon "map-marker"}} {{model.location}}{{/if}}
            {{#if websiteName}}
              {{fa-icon "globe"}}
              {{#if linkWebsite}}
                <a href={{model.website}} rel={{unless removeNoFollow 'nofollow'}} target="_blank">{{websiteName}}</a>
              {{else}}
                <span title={{model.website}}>{{websiteName}}</span>
              {{/if}}
            {{/if}}
            </h3>

            <div class='bio'>
              {{#if model.isSuspended}}
                <div class='suspended'>
                  {{fa-icon "ban"}}
                  <b>{{i18n 'user.suspended_notice' date=suspendedTillDate}}</b><br/>
                  <b>{{i18n 'user.suspended_reason'}}</b> {{suspend_reason}}
                </div>
              {{/if}}
              {{{model.bio_cooked}}}
            </div>

            {{#if publicUserFields}}
              <div class="public-user-fields">
                {{#each uf in publicUserFields}}
                  {{#if uf.value}}
                    <div class="public-user-field">
                      <span class="user-field-name">{{uf.field.name}}</span>:
                      <span class="user-field-value">{{uf.value}}</span>
                    </div>
                  {{/if}}
                {{/each}}
              </div>
            {{/if}}

            {{plugin-outlet "user-profile-primary"}}

          </div>
        </div>
        <div style='clear: both'></div>
      </div>

      <div class='secondary'>
        <dl>
          {{#if model.created_at}}
            <dt>{{i18n 'user.created'}}</dt><dd>{{bound-date model.created_at}}</dd>
          {{/if}}
          {{#if model.last_posted_at}}
            <dt>{{i18n 'user.last_posted'}}</dt><dd>{{bound-date model.last_posted_at}}</dd>
          {{/if}}
          {{#if model.last_seen_at}}
            <dt>{{i18n 'user.last_seen'}}</dt><dd>{{bound-date model.last_seen_at}}</dd>
          {{/if}}
          {{#if model.invited_by}}
            <dt>{{i18n 'user.invited_by'}}</dt><dd>{{#link-to 'user' model.invited_by}}{{model.invited_by.username}}{{/link-to}}</dd>
          {{/if}}
          <dt>{{i18n 'user.trust_level'}}</dt><dd>{{model.trustLevel.name}}</dd>
          {{#if canCheckEmails}}
            <dt>{{i18n 'user.email.title'}}</dt>
            <dd title={{model.email}}>
              {{#if model.email}}
                {{model.email}}
              {{else}}
                {{d-button action="checkEmail" actionParam=model icon="envelope-o" label="admin.users.check_email.text" class="btn-primary"}}
              {{/if}}
            </dd>
          {{/if}}
          {{#if model.custom_groups}}
            <dt>{{i18n 'groups.title' count=model.custom_groups.length}}</dt>
            <dd class='groups'>
              {{#each group in model.custom_groups}}
                <span>{{#link-to 'group' group class="group-link"}}{{group.name}}{{/link-to}}</span>
              {{/each}}
            </dd>
          {{/if}}
          {{#if canDeleteUser}}
            {{d-button action="adminDelete" icon="exclamation-triangle" label="user.admin_delete" class="btn-danger"}}
          {{/if}}
        </dl>
        {{plugin-outlet "user-profile-secondary"}}
      </div>
    </section>

    <section class='user-navigation'>
      <ul class='action-list nav-stacked'>
        {{activity-filter count=model.statsCountNonPM user=model userActionType=userActionType indexStream=indexStream}}
        {{#each stat in model.statsExcludingPms}}
          {{activity-filter content=stat user=model userActionType=userActionType indexStream=indexStream}}
        {{/each}}
        {{#if showBadges}}
          {{#link-to 'user.badges' tagName="li"}}
            {{#link-to 'user.badges'}}
              <i class='glyph fa fa-certificate'></i>
              {{i18n 'badges.title'}}
              <span class='count'>({{model.badge_count}})</span>
            {{/link-to}}
          {{/link-to}}
        {{/if}}
        {{#if canSeeNotificationHistory}}
          {{#link-to 'user.notifications' tagName="li"}}
            {{#link-to 'user.notifications'}}
              {{fa-icon "comment" class="glyph"}}
              {{i18n 'user.notifications'}}
              <span class='count'>({{model.notification_count}})</span>
            {{/link-to}}
          {{/link-to}}
        {{/if}}
      </ul>

      {{#if canSeePrivateMessages}}
        <h3>{{fa-icon "envelope"}} {{i18n 'user.private_messages'}}</h3>
        <ul class='action-list nav-stacked'>
          <li {{bind-attr class=":noGlyph privateMessagesActive:active"}}>
            {{#link-to 'userPrivateMessages.index' model}}
              {{i18n 'user.messages.all'}}
              {{#if model.hasPMs}}<span class='count'>({{model.private_messages_stats.all}})</span>{{/if}}
            {{/link-to}}
          </li>
          <li {{bind-attr class=":noGlyph privateMessagesMineActive:active"}}>
            {{#link-to 'userPrivateMessages.mine' model}}
              {{i18n 'user.messages.mine'}}
              {{#if model.hasStartedPMs}}<span class='count'>({{model.private_messages_stats.mine}})</span>{{/if}}
            {{/link-to}}
          </li>
          <li {{bind-attr class=":noGlyph privateMessagesUnreadActive:active"}}>
            {{#link-to 'userPrivateMessages.unread' model}}
              {{i18n 'user.messages.unread'}}
              {{#if model.hasUnreadPMs}}<span class='badge-notification unread-private-messages'>{{model.private_messages_stats.unread}}</span>{{/if}}
            {{/link-to}}
          </li>
        </ul>
      {{/if}}

      {{#if viewingSelf}}
        <div class='user-archive'>
          {{d-button action="exportUserArchive" label="user.download_archive" icon="download"}}
        </div>
      {{/if}}
    </section>

    <section class='user-right'>
      {{outlet}}
    </section>

  </section>
</div>
