<header class="main-header" ng-controller="topNavController as topNav">
    <a ui-sref="backend.user.vault" class="logo">
        <span class="logo-mini"><i class="fa fa-shield"></i></span>
        <span class="logo-lg"><i class="fa fa-shield"></i> <b>bit</b>warden</span>
    </a>
    <nav class="navbar navbar-static-top" role="navigation">
        <a class="sidebar-toggle" data-toggle="offcanvas" role="button">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </a>
        <div class="navbar-custom-menu">
            <ul class="nav navbar-nav">
                <li><a ui-sref="frontend.logout">Log Out</a></li>
                <li class="control-sidebar-show">
                    <a href="#" stop-click ng-click="toggleControlSidebar()"><i class="fa fa-bars"></i></a>
                </li>
            </ul>
        </div>
    </nav>
</header>

<aside class="main-sidebar" ng-controller="sideNavController as sideNav">
    <section class="sidebar">
        <div class="user-panel">
            <div class="pull-left image">
                <letter-avatar data="{{name}}" avclass="img-responsive"></letter-avatar>
            </div>
            <div class="pull-left info">
                <p>{{name}}</p>
                <a ui-sref="frontend.logout">Log Out</a>
            </div>
        </div>
        <ul class="sidebar-menu">
            <li class="header">WEB VAULT</li>
            <li class="treeview" ng-class="{active: $state.includes('backend.user.vault')}">
                <a ui-sref="backend.user.vault"><i class="fa fa-lock fa-fw"></i> <span>My Vault</span></a>
                <ul class="treeview-menu" ng-class="{'menu-open': $state.includes('backend.user.vault')}">
                    <li>
                        <a href="#" stop-click ng-click="addCipher()">
                            <i class="fa fa-plus-circle fa-fw"></i> New Item
                        </a>
                    </li>
                    <li>
                        <a href="#" stop-click ng-click="addFolder()">
                            <i class="fa fa-folder fa-fw"></i> New Folder
                        </a>
                    </li>
                </ul>
            </li>
            <li class="treeview" ng-class="{active: $state.is('backend.user.tools') ||
                $state.is('backend.user.reportsBreach')}">
                <a ui-sref="backend.user.tools"><i class="fa fa-wrench fa-fw"></i> <span>Tools</span></a>
                <ul class="treeview-menu" ng-class="{'menu-open': $state.is('backend.user.tools') ||
                    $state.is('backend.user.reportsBreach')}">
                    <li ng-class="{active: $state.is('backend.user.reportsBreach')}">
                        <a ui-sref="backend.user.reportsBreach">
                            <i class="fa fa-circle-o fa-fw"></i> Data Breach Report
                        </a>
                    </li>
                </ul>
            </li>
            <li class="treeview"
                ng-class="{active: $state.is('backend.user.settings') || $state.is('backend.user.settingsDomains') ||
                    $state.is('backend.user.settingsCreateOrg') || $state.is('backend.user.settingsTwoStep') ||
                    $state.is('backend.user.settingsPremium') || $state.is('backend.user.settingsBilling')}">
                <a ui-sref="backend.user.settings"><i class="fa fa-cogs fa-fw"></i> <span>Settings</span></a>
                <ul class="treeview-menu" ng-class="{'menu-open': $state.is('backend.user.settings') ||
                        $state.is('backend.user.settingsDomains') || $state.is('backend.user.settingsCreateOrg')}">
                    <li ng-class="{active: $state.is('backend.user.settingsPremium')}">
                        <a ui-sref="backend.user.settingsPremium" ng-if="!main.userProfile || !main.userProfile.premium">
                            <i class="fa fa-star fa-fw"></i> Go Premium!
                        </a>
                    </li>
                    <li ng-class="{active: $state.is('backend.user.settingsCreateOrg')}">
                        <a ui-sref="backend.user.settingsCreateOrg">
                            <i class="fa fa-plus-circle fa-fw"></i> New Organization
                        </a>
                    </li>
                    <li ng-class="{active: $state.is('backend.user.settingsBilling')}">
                        <a ui-sref="backend.user.settingsBilling" ng-if="main.userProfile && main.userProfile.premium">
                            <i class="fa fa-circle-o fa-fw"></i> Billing &amp; Licensing
                        </a>
                    </li>
                    <li ng-class="{active: $state.is('backend.user.settingsTwoStep')}">
                        <a ui-sref="backend.user.settingsTwoStep">
                            <i class="fa fa-fw fa-circle-o"></i> Two-step Login
                        </a>
                    </li>
                    <li ng-class="{active: $state.is('backend.user.settingsDomains')}">
                        <a ui-sref="backend.user.settingsDomains">
                            <i class="fa fa-fw fa-circle-o"></i> Domain Rules
                        </a>
                    </li>
                </ul>
            </li>
            <li ng-class="{active: $state.is('backend.user.apps')}">
                <a href="https://bitwarden.com/#download" target="_blank">
                    <small class="label pull-right bg-green">FREE</small>
                    <i class="fa fa-download fa-fw"></i> <span>Get the Apps</span>
                </a>
            </li>
            <li>
                <a href="https://help.bitwarden.com/" target="_blank"
                   analytics-on="click" analytics-event="Clicked Get Help">
                    <i class="fa fa-info-circle fa-fw"></i> <span>Get Help</span>
                </a>
            </li>
            <li class="header">
                ORGANIZATIONS
            </li>
        </ul>
        <div class="subsection">
            <div ng-if="!orgs.length" class="hidden-collapsed">
                <p>You do not belong to any organizations.</p>
                <a ui-sref="backend.user.settingsCreateOrg" class="btn btn-default btn-flat btn-block">
                    Create an Organization
                </a>
            </div>
            <ul class="list-inline" ng-if="orgs.length">
                <li ng-repeat="org in orgs | orderBy: ['name'] track by org.id">
                    <a href="#" stop-click ng-click="viewOrganization(org)">
                        <letter-avatar data="{{org.name}}" avclass="img-responsive img-rounded" round="false"
                                       avheight="40" avwidth="40" bgcolor="{{orgIconBgColor}}" avborder="true"
                                       borderstyle="{{orgIconBorder}}" textcolor="{{orgIconTextColor}}"></letter-avatar>
                    </a>
                </li>
            </ul>
        </div>
    </section>
</aside>

<div class="content-wrapper">
    <div class="alert alert-danger alert-notification" ng-if="main.outdatedBrowser" ng-click="updateBrowser()">
        <h4><i class="fa fa-warning fa-fw"></i> Update Your Browser</h4>
        You are using an unsupported web browser. The web vault may not function properly.
        <u>Update your browser now</u>.
    </div>
    <div class="alert alert-warning alert-notification" ng-click="updateKey()" ng-if="!main.usingEncKey">
        <h4><i class="fa fa-key fa-fw"></i> Update Your Encryption Key</h4>
        You are currently using an outdated encryption scheme.
        <a href="#" stop-click>Learn more and update now</a>.
    </div>
    <div class="alert alert-warning alert-notification" ng-click="verifyEmail()"
         ng-if="main.usingEncKey && main.userProfile && !main.userProfile.emailVerified">
        <h4><i class="fa fa-envelope fa-fw"></i> Verify Your Email</h4>
        <div ng-if="!verifyEmailSent">
            Verify your account's email address to unlock access to all features.
            <a href="#" stop-click>Send verification email now</a>.
            <i class="fa fa-spin fa-refresh" ng-if="sendingVerify"></i>
        </div>
        <div ng-if="verifyEmailSent">
            Check your email inbox for a verification link.
            <a href="#" stop-click>Send verification email again</a>.
            <i class="fa fa-spin fa-refresh" ng-if="sendingVerify"></i>
        </div>
    </div>
    <div ui-view></div>
</div>
