(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 _passwordVisibility = require('./password-visibility');

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

for (var i = 0; i < componentsList.length; i++) {
	new _passwordVisibility.PasswordVisibility(componentsList[i]);
}
},{"./password-visibility":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-visibility.js
 * Script toggles between text and password 'bullets' on input field
 */

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

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

		this.element = element;
		this.triggerElement = this.element.querySelector('[' + this.attributes.trigger + ']');
		this.input = this.element.querySelector('input[type=password]');
		this.addEventHandlers();
	}

	/**
 * Declare attribute constants
 */


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


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

			this.triggerElement.addEventListener('keyup', function () {
				_this.toggleVisibility();
			});
			this.triggerElement.addEventListener('click', function () {
				_this.toggleVisibility();
			});
		}

		/**
  * Toggle visibility
  */

	}, {
		key: 'toggleVisibility',
		value: function toggleVisibility() {
			var currentType = this.input.getAttribute('type');
			if ([this.types.password, this.types.text].indexOf(currentType.toLowerCase()) > -1) {
				var newType = currentType.toLowerCase() === this.types.password ? this.types.text : this.types.password;
				this.input.setAttribute('type', newType);
				this.triggerElement.classList.toggle(this.classes.isPasswordVisible);
			}
		}

		/**
   * Get selector
   */

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

		/**
  * Declare classes
  */

	}, {
		key: 'classes',
		get: function get() {
			return {
				isPasswordVisible: 'is-password-visible'
			};
		}

		/**
  * Declare types
  */

	}, {
		key: 'types',
		get: function get() {
			return {
				text: 'text',
				password: 'password'
			};
		}
	}], [{
		key: 'getSelector',
		value: function getSelector() {
			return '[' + attributeBase + ']';
		}
	}]);

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