header
  #js-burger-toggle.hidden--desktop
    a.header__link href="#"
      i.fa.fa-bars
  a.header__logo.header__link href="/"
    i.icon--padded--right.favicon-home>
    span.hidden--mobile = site_name()
  a.header__link.hidden--mobile href="/images/new" title="Upload"
    i.fa.fa-upload
  = form_for @conn, ~p"/search", [method: "get", class: "header__search", enforce_utf8: false], fn f ->
    input.input.input--text.header__input.header__input--text#q name="q" title="For terms all required, separate with ',' or 'AND'; also supports 'OR' for optional terms and '-' or 'NOT' for negation. Search with a blank query for more options or click the ? for syntax help." value=@conn.params["q"] placeholder="Search" autocapitalize="none" data-ac="true" data-ac-min-length="3" data-ac-mode="search"

    = if present?(@conn.params["sf"]) do
      input type="hidden" name="sf" value=@conn.params["sf"]
    = if present?(@conn.params["sd"]) do
      input type="hidden" name="sd" value=@conn.params["sd"]
    = if present?(@conn.params["hidden"]) do
      input type="hidden" name="hidden" value=@conn.params["hidden"]

    = if hides_images?(@conn) do
      = select f, :del, [{"-D", ""}, {"+D", 1}, {"*D", "deleted"}, {"DO", "only"}], name: "del", class: "input header__input js-staff-action", autocomplete: "off"

    button.header__search__button type="submit" title="Search"
      i.fas.fa-search
    a.header__search__button href="/search/reverse" title="Search using an image"
      i.fa-search-button.fas.fa-camera
    a.header__search__button href="/pages/search_syntax" title="Search syntax help"
      i.fa-search-button.fas.fa-question
  .flex__grow
  = if @current_user do
    a.header__link href="/notifications" title="Notifications"
      i.fas.fa-bell>
      span.js-notification-ticker.fa__text.header__counter data-notification-count=@notification_count = @notification_count

    a.header__link href="/conversations" title="Conversations"
      = if @conversation_count > 0 do
        i.fa-unread-icon.fas.fa-envelope-open>
        span.header__counter
          = @conversation_count
      - else
        i.fas.fa-envelope
    a.header__link.hidden--mobile href="/filters" title="Filters"
      i.fa.fa-filter
      span.hidden--tablet< Filters

    .header__search
      = form_for @user_changeset, ~p"/filters/current", [class: "header__filter-form", id: "filter-quick-form"], fn f ->
        = select f, :current_filter_id, @available_filters, name: "id", id: "filter-quick-menu", class: "input header__input", data: [change_submit: "#filter-quick-form"], autocomplete: "off"

    .header__search
      = form_for @user_changeset, ~p"/filters/spoiler_type", [class: "header__filter-form hidden--mobile", id: "spoiler-quick-form"], fn f ->
        = select f, :spoiler_type, @spoiler_types, id: "spoiler-quick-menu", class: "input header__input", data: [change_submit: "#spoiler-quick-form"], autocomplete: "off"

    .dropdown
      a.header__link.header__link--user href=~p"/profiles/#{@current_user}"
        = render PhilomenaWeb.UserAttributionView, "_user_avatar.html", object: %{user: @current_user}, class: "avatar--navbar"
        i.fa.fa-chevron-down
      nav.dropdown__content.dropdown__content--right.hidden--mobile.js-burger-links
        a.dropdown__item href=~p"/profiles/#{@current_user}"
          .dropdown__icon
            i.fa.icon--fixed.fa-user
          .dropdown__text
            = @current_user.name
        hr.dropdown__separator
        a.dropdown__item href="/search?q=my:watched"
          .dropdown__icon
            i.fa.icon--fixed.fa-eye
          .dropdown__text Watched
        a.dropdown__item href="/search?q=my:faves"
          .dropdown__icon
            i.fa.icon--fixed.fa-star
          .dropdown__text Faves
        a.dropdown__item href="/search?q=my:upvotes"
          .dropdown__icon
            i.fa.icon--fixed.fa-arrow-up
          .dropdown__text Upvotes
        a.dropdown__item href=~p"/galleries?#{[gallery: [creator: @current_user.name]]}"
          .dropdown__icon
            i.fa.icon--fixed.fa-image
          .dropdown__text Galleries
        a.dropdown__item href="/search?q=my:uploads"
          .dropdown__icon
            i.fa.icon--fixed.fa-upload
          .dropdown__text Uploads
        a.dropdown__item href="/comments?cq=my:comments"
          .dropdown__icon
            i.fa.icon--fixed.fa-comments
          .dropdown__text Comments
        a.dropdown__item href="/posts?pq=my:posts"
          .dropdown__icon
            i.fa.icon--fixed.fa-pen-square
          .dropdown__text Posts
        a.dropdown__item href=~p"/profiles/#{@current_user}/artist_links"
          .dropdown__icon
            i.fa.icon--fixed.fa-link
          .dropdown__text Links
        a.dropdown__item href="/conversations"
          .dropdown__icon
            i.fa.icon--fixed.fa-envelope
          .dropdown__text Messages
        hr.dropdown__separator
        a.dropdown__item href="/settings/edit"
          .dropdown__icon
            i.fa.icon--fixed.fa-cogs
          .dropdown__text Settings
        a.dropdown__item href=~p"/registrations/edit"
          .dropdown__icon
            i.fa.icon--fixed.fa-user
          .dropdown__text Account
        hr.dropdown__separator
        a.dropdown__item href=~p"/sessions" data-method="delete"
          .dropdown__icon
            i.fa.icon--fixed.fa-sign-out-alt
          .dropdown__text Logout
  - else
    a.header__link.hidden--mobile href="/filters"
      | Filters (
      = @current_filter.name
      | )
    span.js-burger-links.hidden--mobile
      a.header__link href="/settings/edit"
        i.fa.icon--fixed.fa-cogs.hidden--desktop>
        | Settings
    a.header__link href=~p"/registrations/new"
      | Register
    a.header__link href=~p"/sessions/new"
      | Login

.nav-container
  nav.header__secondary
    = render PhilomenaWeb.LayoutView, "_header_navigation.html", assigns

  = if !is_nil(@current_user) and @current_user.role != "user" do
    nav.header__staff
      = render PhilomenaWeb.LayoutView, "_header_navigation_staff.html", assigns
