(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
'use strict';

var _passwordValidator = require('./password-validator');

// initialize all elements
var componentsList = document.querySelectorAll(_passwordValidator.PasswordValidator.getSelector()); // Import all components

for (var i = 0; i < componentsList.length; i++) {
	new _passwordValidator.PasswordValidator(componentsList[i]);
}
},{"./password-validator":2}],2:[function(require,module,exports){
'use strict';

Object.defineProperty(exports, "__esModule", {
	value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

/**
 * password-validator.js
 * Script validates password and shows checklist
 */

/**
* Declare constants
*/
var attributeBase = 'data-rs-password-validator';

var PasswordValidator = exports.PasswordValidator = function () {
	function PasswordValidator(element) {
		_classCallCheck(this, PasswordValidator);

		this.element = element;
		this.input = this.element.querySelector('input[type="password"]');
		this.checklist = this.getChecklist;
		this.addEventHandlers();
	}

	/**
 * Declare attribute constants
 */


	_createClass(PasswordValidator, [{
		key: 'addEventHandlers',


		/**
  * Add event handlers
  */
		value: function addEventHandlers() {
			var _this = this;

			this.input.addEventListener('keyup', function () {
				_this.validateInput();
			});
			this.input.addEventListener('blur', function () {
				_this.validateInput();
			});
			this.input.addEventListener('focus', function () {
				_this.showChecklist();
			});
		}

		/**
  * Validate input
  */

	}, {
		key: 'validateInput',
		value: function validateInput() {
			var _iteratorNormalCompletion = true;
			var _didIteratorError = false;
			var _iteratorError = undefined;

			try {
				for (var _iterator = this.checklist[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
					var check = _step.value;

					var isValid = this.input.value.match(this.validators[check.name]);
					if (isValid) {
						check.element.classList.add(this.classes.valid);
					} else {
						check.element.classList.remove(this.classes.valid);
					}
				}
			} catch (err) {
				_didIteratorError = true;
				_iteratorError = err;
			} finally {
				try {
					if (!_iteratorNormalCompletion && _iterator.return) {
						_iterator.return();
					}
				} finally {
					if (_didIteratorError) {
						throw _iteratorError;
					}
				}
			}
		}

		/**
  * Show checklist
  */

	}, {
		key: 'showChecklist',
		value: function showChecklist() {
			var checklistElement = this.element.parentNode.querySelector('[' + this.attributes.checklist + ']');
			checklistElement.removeAttribute('hidden');
		}

		/**
   * Get selector
   */

	}, {
		key: 'attributes',
		get: function get() {
			return {
				validate: attributeBase + '-validate',
				checklist: attributeBase + '-checklist'
			};
		}

		/**
  * Declare classes
  */

	}, {
		key: 'classes',
		get: function get() {
			return {
				valid: 'valid'
			};
		}

		/**
  * Declare validator
  */

	}, {
		key: 'validators',
		get: function get() {
			return {
				minSign: /.{8,}/,
				useUpper: /[A-Z]/,
				useDigit: /[0-9]/,
				useChar: /[a-z]/,
				noSymbol: /^([^ /\\,#&<>:';"?=%]+)$/
			};
		}

		/**
  * Get checklist
  */

	}, {
		key: 'getChecklist',
		get: function get() {
			var checklist = [];
			var elements = this.element.parentNode.querySelectorAll('[' + this.attributes.validate + ']');

			var _iteratorNormalCompletion2 = true;
			var _didIteratorError2 = false;
			var _iteratorError2 = undefined;

			try {
				for (var _iterator2 = elements[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
					var item = _step2.value;

					checklist.push({
						'name': item.dataset.rsPasswordValidatorValidate,
						'element': item
					});
				}
			} catch (err) {
				_didIteratorError2 = true;
				_iteratorError2 = err;
			} finally {
				try {
					if (!_iteratorNormalCompletion2 && _iterator2.return) {
						_iterator2.return();
					}
				} finally {
					if (_didIteratorError2) {
						throw _iteratorError2;
					}
				}
			}

			return checklist;
		}
	}], [{
		key: 'getSelector',
		value: function getSelector() {
			return '[' + attributeBase + ']';
		}
	}]);

	return PasswordValidator;
}();
},{}]},{},[1]);
