<div class="modal-header">
    <button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <h4 class="modal-title">
        <i class="fa fa-key"></i> Two-step Login <small>yubikey</small>
    </h4>
</div>
<form name="authTwoStepForm" ng-submit="authTwoStepForm.$valid && auth(authModel)" api-form="authPromise"
      ng-if="!authed">
    <div class="modal-body">
        <p>Enter your master password to modify two-step login settings.</p>
        <div class="callout callout-danger validation-errors" ng-show="authTwoStepForm.$errors">
            <h4>Errors have occurred</h4>
            <ul>
                <li ng-repeat="e in authTwoStepForm.$errors">{{e}}</li>
            </ul>
        </div>
        <div class="form-group" show-errors>
            <label for="masterPassword">Master Password</label>
            <input type="password" id="masterPassword" name="MasterPasswordHash" ng-model="authModel.masterPassword"
                   class="form-control" required api-field />
        </div>
    </div>
    <div class="modal-footer">
        <button type="submit" class="btn btn-primary btn-flat" ng-disabled="authTwoStepForm.$loading">
            <i class="fa fa-refresh fa-spin loading-icon" ng-show="authTwoStepForm.$loading"></i>Continue
        </button>
        <button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
    </div>
</form>
<form name="submitTwoStepForm" ng-submit="submitTwoStepForm.$valid && submit(updateModel)" api-form="submitPromise"
      ng-if="authed" autocomplete="off">
    <div class="modal-body">
        <div class="callout callout-warning">
            <h4><i class="fa fa-warning"></i> Warning <i class="fa fa-warning"></i></h4>
            <p>
                Due to platform limitations, YubiKeys cannot be used on all Bitwarden applications. You should enable
                another two-step login provider so that you can access your account when YubiKeys cannot be used.
            </p>
            <p>Supported platforms:</p>
            <ul>
                <li>Web vault on a device with a USB port that can accept your YubiKey.</li>
                <li>Browser extensions.</li>
                <li>
                    Android on a device with
                    <a href="https://en.wikipedia.org/wiki/List_of_NFC-enabled_mobile_devices" target="_blank">
                        NFC capabilities
                    </a>. Read more <a href="https://forum.yubico.com/viewtopic.php?f=26&t=1302" target="_blank">here</a>.
                </li>
            </ul>
        </div>
        <div ng-if="enabled">
            <div class="callout callout-success">
                <h4><i class="fa fa-check-circle"></i> Enabled</h4>
                <p>Two-step log via YubiKey is enabled on your account.</p>
            </div>
        </div>
        <div class="callout callout-danger validation-errors" ng-show="submitTwoStepForm.$errors">
            <h4>Errors have occurred</h4>
            <ul>
                <li ng-repeat="e in submitTwoStepForm.$errors">{{e}}</li>
            </ul>
        </div>
        <p>To add a new YubiKey to your account:</p>
        <ol>
            <li>Plug the YubiKey (NEO or 4 series) into your computer's USB port.</li>
            <li>Select in the first empty <b>Key</b> field below.</li>
            <li>Touch the YubiKey's button.</li>
            <li>Save the form.</li>
        </ol>
        <hr />
        <div class="form-group" show-errors>
            <label for="key1">YubiKey #1</label>
            <span ng-if="updateModel.key1.existingKey">
                <a href="#" class="btn btn-link btn-xs" stop-click ng-click="remove(updateModel.key1)">[remove]</a>
            </span>
            <div ng-if="updateModel.key1.existingKey" class="monospaced">
                {{updateModel.key1.existingKey}}
            </div>
            <input type="password" id="key1" name="Key1" ng-model="updateModel.key1.key" class="form-control" api-field
                   ng-show="!updateModel.key1.existingKey" autocomplete="new-password" />
        </div>
        <div class="form-group" show-errors>
            <label for="key2">YubiKey #2</label>
            <span ng-if="updateModel.key2.existingKey">
                <a href="#" class="btn btn-link btn-xs" stop-click ng-click="remove(updateModel.key2)">[remove]</a>
            </span>
            <div ng-if="updateModel.key2.existingKey" class="monospaced">
                {{updateModel.key2.existingKey}}
            </div>
            <input type="password" id="key2" name="Key2" ng-model="updateModel.key2.key" class="form-control" api-field
                   ng-show="!updateModel.key2.existingKey" autocomplete="new-password" />
        </div>
        <div class="form-group" show-errors>
            <label for="key3">YubiKey #3</label>
            <span ng-if="updateModel.key3.existingKey">
                <a href="#" class="btn btn-link btn-xs" stop-click ng-click="remove(updateModel.key3)">[remove]</a>
            </span>
            <div ng-if="updateModel.key3.existingKey" class="monospaced">
                {{updateModel.key3.existingKey}}
            </div>
            <input type="password" id="key3" name="Key3" ng-model="updateModel.key3.key" class="form-control" api-field
                   ng-show="!updateModel.key3.existingKey" autocomplete="new-password" />
        </div>
        <strong>NFC Support</strong>
        <div class="checkbox">
            <label>
                <input type="checkbox" name="Nfc" id="nfc" ng-model="updateModel.nfc" /> One of my keys supports NFC.
            </label>
        </div>
        <p class="help-block">
            If one of your YubiKeys supports NFC (such as a YubiKey NEO), you will be prompted on mobile devices whenever NFC
            availability is detected.
        </p>
    </div>
    <div class="modal-footer">
        <button type="submit" class="btn btn-primary btn-flat" ng-disabled="submitTwoStepForm.$loading || disableLoading">
            <i class="fa fa-refresh fa-spin loading-icon" ng-show="submitTwoStepForm.$loading"></i>
            Save
        </button>
        <button type="button" class="btn btn-default btn-flat" ng-click="disable()" ng-disabled="disableLoading"
                ng-if="enabled">
            <i class="fa fa-refresh fa-spin loading-icon" ng-show="disableLoading"></i>
            Disable All Keys
        </button>
        <button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
    </div>
</form>
