/**
 * Theme Name: errigal
 * Theme URI: https://projecterrigal.com/themes/errigal/
 * Author: Project errigal
 * Author URI: https://projecterrigal.com/
 * Version: 1.2.1
 */
( function() {
	'use strict';

	var ATTRIBUTE_TABINDEX = 'tabIndex';
	var ATTRIBUTE_VALUE_MINUS_ONE = '-1';
	var NULL_VALUE = null;

	function isFunction( value ) {
		return value instanceof Function;
	}

	var INDEX_FIRST = 0;

	function isHTMLCollection( elements ) {
		return elements instanceof HTMLCollection;
	}

	function isObjectType( value, expectedType ) {
		return Object.prototype.toString.call( value ) === '[object '.concat( expectedType, ']' );
	}

	function isNumber( value ) {
		return ! isNaN( value ) && isObjectType( value, 'Number' ) && isFinite( value );
	}

	function isPositiveNumber( value ) {
		return isNumber( value ) && value > 0;
	}

	function isIterable( items ) {
		return !! items && isPositiveNumber( items.length );
	}

	function isTrue( value ) {
		return value === true;
	}

	function forEach( items, callback ) {
		if ( ! isIterable( items ) || ! isFunction( callback ) ) {
			return false;
		}

		if ( isHTMLCollection( items ) ) {
			items = Array.prototype.slice.call( items );
		}

		for ( var i = INDEX_FIRST; i < items.length; i++ ) {
			if ( isTrue( callback( items[ i ], i, items ) ) ) {
				return true;
			}
		}

		return false;
	}

	function hasClassList( element ) {
		return !! element && element.classList instanceof DOMTokenList && isFunction( element.classList.contains );
	}

	function isHTMLElement( element ) {
		if ( ! ( element instanceof HTMLElement ) ) {
			return false;
		}

		for ( var _len = arguments.length, classNames = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			classNames[ _key - 1 ] = arguments[ _key ];
		}

		return hasClassList( element ) && ! forEach( classNames, function( className ) {
			return ! element.classList.contains( className );
		} );
	}

	function getAttribute( element, name ) {
		return isHTMLElement( element ) && isFunction( element.getAttribute ) ? element.getAttribute( name ) : NULL_VALUE;
	}

	function hasNegativeTabIndex( element ) {
		return getAttribute( element, ATTRIBUTE_TABINDEX ) === ATTRIBUTE_VALUE_MINUS_ONE;
	}

	function removeAttribute( element ) {
		if ( ! isHTMLElement( element ) || ! isFunction( element.removeAttribute ) ) {
			return;
		}

		for ( var _len = arguments.length, names = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			names[ _key - 1 ] = arguments[ _key ];
		}

		forEach( names, function( name ) {
			return element.removeAttribute( name );
		} );
	}

	function removeTabIndex( element ) {
		removeAttribute( element, ATTRIBUTE_TABINDEX );
	}

	var EVENT_FOCUSOUT = 'focusout';

	function isBoolean( value ) {
		return isObjectType( value, 'Boolean' );
	}

	var EMPTY_STRING = '';

	function isString( value ) {
		return isObjectType( value, 'String' );
	}

	function isNonEmptyString( value ) {
		return isString( value ) && isFunction( value.trim ) && value.trim() !== EMPTY_STRING;
	}

	function isObject( value ) {
		return value instanceof Object;
	}

	function isUndefined( value ) {
		return isObjectType( value, 'Undefined' );
	}

	function onDocumentEvent( eventType, callback, options ) {
		if ( ! isNonEmptyString( eventType ) || ! isFunction( callback ) || ! ( isUndefined( options ) || isObject( options ) || isBoolean( options ) ) ) {
			return;
		}

		document.addEventListener( eventType, callback, options || false );
	}

	function onDocumentFocusout( callback, options ) {
		onDocumentEvent( EVENT_FOCUSOUT, callback, options );
	}

	function isEvent( value ) {
		return value instanceof Event && isFunction( value.preventDefault ) && isFunction( value.stopPropagation );
	}

	function addTabIndexEvents() {
		onDocumentFocusout( function( event ) {
			if ( ! isEvent( event ) ) {
				return;
			}

			if ( hasNegativeTabIndex( event.target ) ) {
				removeTabIndex( event.target );
			}
		} );
	}

	function addAccessibilityEvents() {
		addTabIndexEvents();
	}

	var CLASS_SHARED_ACTIVE = 'active';
	var TAG_LABEL = 'label';
	var NULL_ELEMENT = null;

	function getFirstItem( items ) {
		return isIterable( items ) ? items[ INDEX_FIRST ] : NULL_VALUE;
	}

	function isDocument( element ) {
		return element instanceof Document;
	}

	function isisHTMLElementOrDocument( element ) {
		return isHTMLElement( element ) || isDocument( element );
	}

	function callElementMethod( methodName, nameOrSelectors, rootElement ) {
		return isNonEmptyString( methodName ) && isNonEmptyString( nameOrSelectors ) && isisHTMLElementOrDocument( rootElement ) && isFunction( rootElement[ methodName ] ) ? rootElement[ methodName ]( nameOrSelectors ) : NULL_ELEMENT;
	}

	function getElementsByTagName( tagName ) {
		var rootElement = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : document;
		var ELEMENTS = callElementMethod( 'getElementsByTagName', tagName, rootElement );

		return isHTMLCollection( ELEMENTS ) ? ELEMENTS : NULL_ELEMENT;
	}

	function getElementByTagName( tagName ) {
		var rootElement = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : document;

		return getFirstItem( getElementsByTagName( tagName, rootElement ) );
	}

	function getParentElement( element ) {
		return isHTMLElement( element ) ? element.parentElement : NULL_ELEMENT;
	}

	var CLASS_COMPONENT_INPUT_FIELD = 'input-field';
	var TAG_INPUT = 'input';
	var TAG_TEXTAREA = 'textarea';
	var SELECTOR_COMPONENT_INPUT_FIELD_INPUT_OR_TEXTAREA = '.'.concat( CLASS_COMPONENT_INPUT_FIELD, ' > ' ).concat( TAG_INPUT, ', .' ).concat( CLASS_COMPONENT_INPUT_FIELD, ' > ' ).concat( TAG_TEXTAREA );

	function matches( element, selectors ) {
		if ( ! isHTMLElement( element ) || ! isNonEmptyString( selectors ) ) {
			return false;
		}

		if ( isFunction( element.matches ) ) {
			return isTrue( element.matches( selectors ) );
		}

		if ( isFunction( element.msMatchesSelector ) ) {
			return isTrue( element.msMatchesSelector( selectors ) );
		}

		return false;
	}

	function isInputField( element ) {
		return matches( element, SELECTOR_COMPONENT_INPUT_FIELD_INPUT_OR_TEXTAREA );
	}

	function isInputFieldContainer( element ) {
		return isHTMLElement( element, CLASS_COMPONENT_INPUT_FIELD );
	}

	function getInputFieldLabel( inputField ) {
		if ( ! isInputField( inputField ) ) {
			return NULL_ELEMENT;
		}

		var INPUT_FIELD_CONTAINER = getParentElement( inputField );

		return isInputFieldContainer( INPUT_FIELD_CONTAINER ) ? getElementByTagName( TAG_LABEL, INPUT_FIELD_CONTAINER ) : NULL_ELEMENT;
	}

	function isNullOrEmpty( value ) {
		return ! value || value === EMPTY_STRING;
	}

	function isInputFieldEmpty( element ) {
		return isInputField( element ) && isNullOrEmpty( element.value );
	}

	function addClass( element, className ) {
		if ( ! isHTMLElement( element ) || ! hasClassList( element ) || ! isFunction( element.classList.add ) || ! isNonEmptyString( className ) ) {
			return;
		}

		element.classList.add( className );
	}

	function floatInputFieldLabel( inputField ) {
		addClass( getInputFieldLabel( inputField ), CLASS_SHARED_ACTIVE );
	}

	var SELECTOR_COMPONENT_INPUT_FIELD = '.'.concat( CLASS_COMPONENT_INPUT_FIELD, ' > ' ).concat( TAG_INPUT, ', .' ).concat( CLASS_COMPONENT_INPUT_FIELD, ' > ' ).concat( TAG_TEXTAREA );

	function isNodeList( element ) {
		return element instanceof NodeList;
	}

	function querySelectorAll( selectors ) {
		var rootElement = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : document;
		var ELEMENTS = callElementMethod( 'querySelectorAll', selectors, rootElement );

		return isNodeList( ELEMENTS ) ? ELEMENTS : NULL_ELEMENT;
	}

	function getInputFields() {
		return querySelectorAll( SELECTOR_COMPONENT_INPUT_FIELD );
	}

	function isInputFieldFilled( element ) {
		return isInputField( element ) && isNonEmptyString( element.value );
	}

	function initialiseFloatingInputFieldLabel( inputField ) {
		if ( isInputFieldFilled( inputField ) ) {
			floatInputFieldLabel( inputField );
		}
	}

	function initialiseFloatingInputFieldLabels() {
		forEach( getInputFields(), initialiseFloatingInputFieldLabel );
	}

	function removeClass( element, className ) {
		if ( ! isHTMLElement( element ) || ! hasClassList( element ) || ! isFunction( element.classList.remove ) || ! isNonEmptyString( className ) ) {
			return;
		}

		element.classList.remove( className );
	}

	var EVENT_FOCUSIN = 'focusin';

	function onDocumentFocusin( callback, options ) {
		onDocumentEvent( EVENT_FOCUSIN, callback, options );
	}

	var EVENT_LOAD = 'load';

	function onWindowEvent( eventType, callback, options ) {
		if ( ! isNonEmptyString( eventType ) || ! isFunction( callback ) || ! ( isUndefined( options ) || isObject( options ) || isBoolean( options ) ) ) {
			return;
		}

		window.addEventListener( eventType, callback, options || false );
	}

	function onWindowLoad( callback, options ) {
		onWindowEvent( EVENT_LOAD, callback, options );
	}

	function unfloatInputFieldLabel( inputField ) {
		removeClass( getInputFieldLabel( inputField ), CLASS_SHARED_ACTIVE );
	}

	function addInputFieldEvents() {
		onDocumentFocusin( function( event ) {
			if ( ! isEvent( event ) ) {
				return;
			}

			if ( isInputField( event.target ) ) {
				floatInputFieldLabel( event.target );
			}
		} );
		onDocumentFocusout( function( event ) {
			if ( ! isEvent( event ) ) {
				return;
			}

			if ( isInputFieldEmpty( event.target ) ) {
				unfloatInputFieldLabel( event.target );
			}
		} );
		onWindowLoad( initialiseFloatingInputFieldLabels );
	}

	function addComponentEvents() {
		addInputFieldEvents();
	}

	var CALLBACK_INITIAL_ATTEMPT_COUNT = 0;
	var CALLBACK_INTERVAL = 50;
	var CALLBACK_MAX_ATTEMPT_COUNT = 20;
	var SCROLL_DISTANCE_ZERO = 0;
	var CHARACTER_HASH = '#';
	var INDEX_SECOND = 1;

	function stringStartsWith( fullString, partialString ) {
		return isNonEmptyString( fullString ) && isNonEmptyString( partialString ) && fullString.indexOf( partialString ) === INDEX_FIRST;
	}

	function getElementById( id ) {
		var rootElement = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : document;

		return isNonEmptyString( id ) && callElementMethod( 'getElementById', stringStartsWith( id, CHARACTER_HASH ) ? id.slice( INDEX_SECOND ) : id, rootElement );
	}

	function hasHash( element ) {
		return !! element && isNonEmptyString( element.hash );
	}

	function getLastItem( items ) {
		return isIterable( items ) ? items[ items.length - 1 ] : NULL_VALUE;
	}

	var EMPTY_ARRAY = [];

	function toChars( value ) {
		return isNonEmptyString( value ) ? value.split( '' ) : EMPTY_ARRAY;
	}

	function isIe() {
		return !! window.MSInputMethodContext && !! document.documentMode;
	}

	function isLocationObject( obj ) {
		return isIe() && !! obj && isString( obj.hash ) && isFunction( obj.assign ) && isFunction( obj.replace ) && isFunction( obj.reload );
	}

	function isLocation( element ) {
		return element instanceof Location || isLocationObject( element );
	}

	function removeTrailingSlash( url ) {
		return isNonEmptyString( url ) ? url.replace( /\/+$/, '' ) : EMPTY_STRING;
	}

	function isEmptyHref( href ) {
		if ( ! isNonEmptyString( href ) || ! isLocation( window.location ) ) {
			return false;
		}

		var ORIGIN = window.location.origin;

		return isNonEmptyString( ORIGIN ) && removeTrailingSlash( href ) === removeTrailingSlash( ORIGIN );
	}

	function hasHref( element ) {
		return !! element && isNonEmptyString( element.href ) && ! isEmptyHref( element.href );
	}

	function hasEmptyAnchorLink( element ) {
		return hasHref( element ) && getLastItem( toChars( element.href ) ) === CHARACTER_HASH;
	}

	function hasSearch( element ) {
		return !! element && isNonEmptyString( element.search );
	}

	var TAG_A = 'a';

	function toLowerCase( value ) {
		return isNonEmptyString( value ) && isFunction( value.toLowerCase ) ? value.toLowerCase() : EMPTY_STRING;
	}

	function areStringsEqualIgnoreCase( str1, str2 ) {
		return toLowerCase( str1 ) === toLowerCase( str2 );
	}

	function hasTagName( element ) {
		return !! element && isNonEmptyString( element.tagName );
	}

	function isElementOfType( element, tagName ) {
		return hasTagName( element ) && isNonEmptyString( tagName ) && areStringsEqualIgnoreCase( element.tagName, tagName );
	}

	function isHTMLElementOfType( tagName, element ) {
		for ( var _len = arguments.length, classNames = new Array( _len > 2 ? _len - 2 : 0 ), _key = 2; _key < _len; _key++ ) {
			classNames[ _key - 2 ] = arguments[ _key ];
		}

		return isHTMLElement.apply( void 0, [ element ].concat( classNames ) ) && isElementOfType( element, tagName );
	}

	function isAnchorElement( element ) {
		for ( var _len = arguments.length, classNames = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			classNames[ _key - 1 ] = arguments[ _key ];
		}

		return isHTMLElementOfType.apply( void 0, [ TAG_A, element ].concat( classNames ) );
	}

	function hasValidUrlPart( elementUrlPart, locationUrlPart, element ) {
		if ( ! isString( elementUrlPart ) || ! isString( locationUrlPart ) || ! isAnchorElement( element ) ) {
			return false;
		}

		return elementUrlPart === locationUrlPart ? true : stringStartsWith( elementUrlPart, locationUrlPart ) && !! getElementById( element.hash );
	}

	function isInternalLink( element ) {
		return isAnchorElement( element ) && element.host === window.location.host;
	}

	function anchorDestinationElementExists( element ) {
		return hasHash( element ) && !! getElementById( element.hash );
	}

	function hasValidHash( element ) {
		return hasHash( element ) || hasEmptyAnchorLink( element );
	}

	function isAnchorElementOrLocationWithAnchorLink( element ) {
		if ( ! hasValidHash( element ) ) {
			return false;
		}

		if ( isLocation( element ) ) {
			return hasEmptyAnchorLink( element ) || anchorDestinationElementExists( element );
		}

		if ( ! isInternalLink( element ) ) {
			return false;
		}

		return hasSearch( element )
			? hasValidUrlPart( element.search, window.location.search, element ) : hasValidUrlPart( element.pathname, window.location.pathname, element );
	}

	function getAnchorDestinationElement( element ) {
		if ( ! isAnchorElementOrLocationWithAnchorLink( element ) ) {
			return NULL_ELEMENT;
		}

		return hasHash( element ) ? getElementById( element.hash ) : document.documentElement;
	}

	var TAG_TIME = 'time';

	function isTimeElement( element ) {
		for ( var _len = arguments.length, classNames = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			classNames[ _key - 1 ] = arguments[ _key ];
		}

		return isHTMLElementOfType.apply( void 0, [ TAG_TIME, element ].concat( classNames ) );
	}

	function getAnchorElement( element ) {
		var ANCHOR_ELEMENT = isTimeElement( element ) ? getParentElement( element ) : element;

		return isAnchorElement( ANCHOR_ELEMENT ) ? ANCHOR_ELEMENT : NULL_ELEMENT;
	}

	var CLASS_NAV_PAGE_NUMBERS = 'page-numbers';
	var SELECTOR_NAV_PAGINATION_NAV_LINK = ''.concat( TAG_A, '.' ).concat( CLASS_NAV_PAGE_NUMBERS );

	function isPaginationNavLink( element ) {
		return matches( element, SELECTOR_NAV_PAGINATION_NAV_LINK );
	}

	function isAnchorLink( element ) {
		var ANCHOR_ELEMENT = getAnchorElement( element );

		return isAnchorElementOrLocationWithAnchorLink( ANCHOR_ELEMENT ) && ! isPaginationNavLink( ANCHOR_ELEMENT );
	}

	function isKey( event, key, keyCode ) {
		return isEvent( event ) && isNonEmptyString( key ) && isNumber( keyCode ) ? areStringsEqualIgnoreCase( event.key, key ) || event.keyCode === keyCode : false;
	}

	function isEnterKey( event ) {
		return isKey( event, 'Enter', 13 );
	}

	var EVENT_CLICK = 'click';

	function onDocumentClick( callback, options ) {
		onDocumentEvent( EVENT_CLICK, callback, options );
	}

	var EVENT_KEYDOWN = 'keydown';

	function onDocumentKeydown( callback, options ) {
		onDocumentEvent( EVENT_KEYDOWN, callback, options );
	}

	function getScrollTop() {
		return isIe() ? window.pageYOffset : window.scrollY || document.documentElement.scrollTop;
	}

	var DISTANCE_REM_LG = 2;
	var POSITION_ZERO = 0;
	var RECT_TOP = 'top';
	var PIXEL_ZERO = 0;

	function getObjectValue( obj, key ) {
		return isObject( obj ) && key in obj ? obj[ key ] : NULL_VALUE;
	}

	function getRectProp( element, property ) {
		if ( ! isHTMLElement( element ) || ! isFunction( element.getBoundingClientRect ) ) {
			return PIXEL_ZERO;
		}

		var RECT_PROP = getObjectValue( element.getBoundingClientRect(), property );

		return isNumber( RECT_PROP ) ? RECT_PROP : PIXEL_ZERO;
	}

	function getViewportTop( element ) {
		return getRectProp( element, RECT_TOP );
	}

	function getPageTop( element ) {
		return getViewportTop( element ) + getScrollTop();
	}

	var CSS_FONT_SIZE = 'font-size';

	function getStyleProp( element, property ) {
		if ( ! isHTMLElement( element ) ) {
			return NULL_VALUE;
		}

		var STYLE_PROP = getObjectValue( window.getComputedStyle( element ), property );

		return isString( STYLE_PROP ) ? STYLE_PROP : NULL_VALUE;
	}

	function getStylePropFloat( element, property ) {
		var STYLE_PROP = parseFloat( getStyleProp( element, property ) );

		return isNumber( STYLE_PROP ) ? STYLE_PROP : PIXEL_ZERO;
	}

	function convertRemToPx( rem ) {
		return isNumber( rem ) ? getStylePropFloat( document.documentElement, CSS_FONT_SIZE ) * rem : PIXEL_ZERO;
	}

	var CLASS_SHARED_STICKY = 'sticky';
	var CLASS_SECTION_SITE_HEADER = 'site-header';

	function getElementsByClassName( className ) {
		var rootElement = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : document;
		var ELEMENTS = callElementMethod( 'getElementsByClassName', className, rootElement );

		return isHTMLCollection( ELEMENTS ) ? ELEMENTS : NULL_ELEMENT;
	}

	function getElementByClassName( className ) {
		var rootElement = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : document;

		return getFirstItem( getElementsByClassName( className, rootElement ) );
	}

	function getSiteHeader() {
		return getElementByClassName( CLASS_SECTION_SITE_HEADER );
	}

	function isSiteHeader( element ) {
		return isHTMLElement( element, CLASS_SECTION_SITE_HEADER );
	}

	var RECT_HEIGHT = 'height';

	function getHeight( element ) {
		return getRectProp( element, RECT_HEIGHT );
	}

	var RECT_BOTTOM = 'bottom';

	function getViewportBottom( element ) {
		return getRectProp( element, RECT_BOTTOM );
	}

	var CSS_POSITION = 'position';
	var CSS_VALUE_FIXED = 'fixed';

	function isFixedElement( element ) {
		return areStringsEqualIgnoreCase( getStyleProp( element, CSS_POSITION ), CSS_VALUE_FIXED );
	}

	function getSiteHeaderStickyElements( siteHeader ) {
		return isSiteHeader( siteHeader ) ? getElementsByClassName( CLASS_SHARED_STICKY, siteHeader ) : NULL_ELEMENT;
	}

	function getFixedElementHeight() {
		var SITE_HEADER = getSiteHeader();

		if ( ! SITE_HEADER ) {
			return PIXEL_ZERO;
		}

		return isFixedElement( SITE_HEADER ) ? getHeight( SITE_HEADER ) : getViewportBottom( getLastItem( getSiteHeaderStickyElements( SITE_HEADER ) ) );
	}

	function getClearTopOffset() {
		return convertRemToPx( DISTANCE_REM_LG );
	}

	function getAdjustedElementPageTop( element ) {
		var TARGET_ELEMENT_PAGE_TOP = getPageTop( element );

		return TARGET_ELEMENT_PAGE_TOP === POSITION_ZERO ? TARGET_ELEMENT_PAGE_TOP : TARGET_ELEMENT_PAGE_TOP - getFixedElementHeight() - getClearTopOffset();
	}

	function isAtScrollTop( anchorLinkDestinationElement ) {
		return getAdjustedElementPageTop( anchorLinkDestinationElement ) === getScrollTop();
	}

	var SCROLL_DISTANCE_LONG = 2000;
	var SCROLL_DISTANCE_MODERATE = 1000;
	var SCROLL_DISTANCE_SHORT = 200;
	var SCROLL_DURATION_MODERATE = 200;
	var SCROLL_DURATION_NORMAL = 300;
	var SCROLL_DURATION_SLOW = 400;
	var SCROLL_DURATION_SWIFT = 50;
	var CLASS_ACCESSIBILITY_SKIP_LINK = 'skip-link';

	function getSkipLink() {
		return getElementByClassName( CLASS_ACCESSIBILITY_SKIP_LINK );
	}

	function setAttribute( element, name, value ) {
		if ( ! isHTMLElement( element ) || ! isFunction( element.setAttribute ) || ! isNonEmptyString( name ) ) {
			return;
		}

		element.setAttribute( name, value );
	}

	function setTabIndex( element ) {
		setAttribute( element, ATTRIBUTE_TABINDEX, ATTRIBUTE_VALUE_MINUS_ONE );
	}

	function getPageHeight() {
		return Math.max( document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight );
	}

	function getScrollLeft() {
		return isIe() ? window.pageXOffset : window.scrollX || document.documentElement.scrollLeft;
	}

	function getViewportHeight() {
		return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	}

	var NUMBER_ZERO = 0;
	var RADIX_DECIMAL = 10;

	function parseDecimalInt( value ) {
		var PARSED_INT = parseInt( value, RADIX_DECIMAL );

		return isNumber( PARSED_INT ) ? PARSED_INT : NUMBER_ZERO;
	}

	var TAG_BUTTON = 'button';
	var TAG_SELECT = 'select';
	var TAGS_FOCUSABLE_ELEMENTS = [ TAG_A, TAG_BUTTON, TAG_INPUT, TAG_SELECT, TAG_TEXTAREA ];

	function isFocusableElement( element ) {
		if ( ! isHTMLElement( element ) || ! hasTagName( element ) ) {
			return false;
		}

		var TAG_NAME = element.tagName;

		return forEach( TAGS_FOCUSABLE_ELEMENTS, function( tagName ) {
			return areStringsEqualIgnoreCase( tagName, TAG_NAME );
		} );
	}

	var CALLBACK_INITIAL_INTERVAL = 0;

	function focusElement( element ) {
		var attemptCount = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : CALLBACK_INITIAL_ATTEMPT_COUNT;
		var interval = arguments.length > 2 && arguments[ 2 ] !== undefined ? arguments[ 2 ] : CALLBACK_INITIAL_INTERVAL;

		if ( ! isHTMLElement( element ) || ! isFunction( element.focus ) || ! isNumber( attemptCount ) || ! isNumber( interval ) || attemptCount === CALLBACK_MAX_ATTEMPT_COUNT ) {
			return;
		}

		element.focus();
		setTimeout( function() {
			if ( element === document.activeElement ) {
				return;
			}

			focusElement( element, ++attemptCount, CALLBACK_INTERVAL );
		}, interval );
	}

	function getStartTime() {
		return performance.now();
	}

	function focusScrollTargetElement( element ) {
		if ( ! isHTMLElement( element ) ) {
			return;
		}

		if ( ! isFocusableElement( element ) ) {
			setTabIndex( element );
		}

		var SCROLL_LEFT = getScrollLeft();
		var SCROLL_TOP = getScrollTop();

		focusElement( element );
		window.scrollTo( SCROLL_LEFT, SCROLL_TOP );
	}

	function isBackToTopDestinationElement( element ) {
		return isHTMLElement( element ) || isAnchorElement( element ) ? element === document.documentElement || element === getSkipLink() : false;
	}

	function isPageScrolledToBottom() {
		return getViewportHeight() + getScrollTop() >= getPageHeight();
	}

	function isAtDestination( element ) {
		return parseDecimalInt( getScrollTop() ) === parseDecimalInt( getAdjustedElementPageTop( element ) );
	}

	function shouldScroll( element ) {
		return isHTMLElement( element ) ? ! ( isAtDestination( element ) || isPageScrolledToBottom() ) || isBackToTopDestinationElement( element ) : false;
	}

	function scrollTo( element, duration ) {
		if ( ! isHTMLElement( element ) ) {
			return;
		}

		if ( ! shouldScroll( element ) ) {
			focusScrollTargetElement( element );

			return;
		}

		if ( ! isNumber( duration ) ) {
			var DISTANCE = Math.abs( getScrollTop() - getAdjustedElementPageTop( element ) );

			switch ( true ) {
				case DISTANCE < SCROLL_DISTANCE_SHORT:
					duration = SCROLL_DURATION_SWIFT;
					break;
				case DISTANCE < SCROLL_DISTANCE_MODERATE:
					duration = SCROLL_DURATION_MODERATE;
					break;
				case DISTANCE < SCROLL_DISTANCE_LONG:
					duration = SCROLL_DURATION_NORMAL;
					break;
				default:
					duration = SCROLL_DURATION_SLOW;
			}
		}

		var START_TIME = getStartTime();

		step( START_TIME, element, START_TIME, parseDecimalInt( duration ) );

		function step( timeStamp, element, startTime, duration ) {
			if ( isNullOrEmpty( timeStamp ) ) {
				timeStamp = startTime;
			}

			if ( ! isNumber( timeStamp ) || ! isHTMLElement( element ) || ! isNumber( startTime ) || ! isNumber( duration ) ) {
				return;
			}

			var DESTINATION_ELEMENT_PAGE_TOP = getAdjustedElementPageTop( element );
			var PROGRESSED_TIME = timeStamp - startTime;

			if ( PROGRESSED_TIME < duration && duration !== PIXEL_ZERO ) {
				var SCROLL_TOP = getScrollTop();
				var TIME = Math.min( 1, PROGRESSED_TIME / duration );
				var _DISTANCE = ( DESTINATION_ELEMENT_PAGE_TOP - SCROLL_TOP ) * TIME;

				window.scrollTo( POSITION_ZERO, SCROLL_TOP + _DISTANCE );
				requestAnimationFrame( function( currentTime ) {
					return step( currentTime, element, startTime, duration );
				} );

				return;
			}

			window.scrollTo( POSITION_ZERO, DESTINATION_ELEMENT_PAGE_TOP );
			focusScrollTargetElement( element );

			if ( ! isNonEmptyString( element.id ) ) {
				return;
			}

			history.pushState( null, '', '#'.concat( element.id ) );
		}
	}

	function ensureAnchorLinkDestinationElementIsVisible( anchorLinkDestinationElement ) {
		scrollTo( anchorLinkDestinationElement, SCROLL_DISTANCE_ZERO );
	}

	function ensureAnchorLinkDestinationElementIsVisibleIe( anchorLinkDestinationElement ) {
		var attemptCount = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : CALLBACK_INITIAL_ATTEMPT_COUNT;

		if ( ! isHTMLElement( anchorLinkDestinationElement ) || isNaN( attemptCount ) || attemptCount >= CALLBACK_MAX_ATTEMPT_COUNT || isAtScrollTop( anchorLinkDestinationElement ) ) {
			return;
		}

		scrollTo( anchorLinkDestinationElement, SCROLL_DISTANCE_ZERO );
		setTimeout( function() {
			return ensureAnchorLinkDestinationElementIsVisibleIe( anchorLinkDestinationElement, ++attemptCount );
		}, CALLBACK_INTERVAL );
	}

	function initialiseAnchorLinkDestinationElementPageTop() {
		if ( ! isNonEmptyString( window.location.hash ) ) {
			return;
		}

		var ANCHOR_LINK_DESTINATION_ELEMENT = getAnchorDestinationElement( window.location );

		if ( ! ANCHOR_LINK_DESTINATION_ELEMENT ) {
			return;
		}

		if ( isIe() ) {
			ensureAnchorLinkDestinationElementIsVisibleIe( ANCHOR_LINK_DESTINATION_ELEMENT );

			return;
		}

		ensureAnchorLinkDestinationElementIsVisible( ANCHOR_LINK_DESTINATION_ELEMENT );
	}

	function scrollToAnchorLinkDestinationElement( element ) {
		scrollTo( getAnchorDestinationElement( getAnchorElement( element ) ) );
	}

	function addAnchorLinkEvents() {
		onDocumentClick( function( event ) {
			if ( ! isEvent( event ) ) {
				return;
			}

			if ( isAnchorLink( event.target ) ) {
				event.preventDefault();
				scrollToAnchorLinkDestinationElement( event.target );
			}
		} );
		onDocumentKeydown( function( event ) {
			if ( ! isEvent( event ) ) {
				return;
			}

			if ( isEnterKey( event ) ) {
				if ( isAnchorLink( event.target ) ) {
					event.preventDefault();
					scrollToAnchorLinkDestinationElement( event.target );
				}
			}
		} );
		onWindowLoad( initialiseAnchorLinkDestinationElementPageTop );
	}

	var CSS_HEIGHT = 'height';
	var CSS_WIDTH = 'width';
	var CSS_VALUE_100PCT = '100%';
	var RATIO_ZERO = 0;
	var CLASS_WP_BLOCK_EMBED__WRAPPER = 'wp-block-embed__wrapper';
	var CLASS_WP_BLOCK_EMBED_YOUTUBE = 'wp-block-embed-youtube';
	var TAG_IFRAME = 'iframe';
	var SELECTOR_CONTENT_WP_BLOCK_EMBED_YOUTUBE_IFRAME = '.'.concat( CLASS_WP_BLOCK_EMBED_YOUTUBE, ' > .' ).concat( CLASS_WP_BLOCK_EMBED__WRAPPER, ' > ' ).concat( TAG_IFRAME );

	function isBlockYouTubeIframe( element ) {
		return matches( element, SELECTOR_CONTENT_WP_BLOCK_EMBED_YOUTUBE_IFRAME );
	}

	function getIframes() {
		return getElementsByTagName( TAG_IFRAME );
	}

	function isIframeElement( element ) {
		for ( var _len = arguments.length, classNames = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			classNames[ _key - 1 ] = arguments[ _key ];
		}

		return isHTMLElementOfType.apply( void 0, [ TAG_IFRAME, element ].concat( classNames ) );
	}

	function hasStyle( element ) {
		return !! element && element.style instanceof CSSStyleDeclaration && isFunction( element.style.setProperty );
	}

	function isStyleProperty( property ) {
		return isString( property ) && hasStyle( document.documentElement ) && property in document.documentElement.style;
	}

	function updateInlineStyle( element, property, value, isPriority ) {
		if ( ! element || ! hasStyle( element ) || ! isStyleProperty( property ) || ! ( isString( value ) || isNumber( value ) ) || ! isBoolean( isPriority ) ) {
			return;
		}

		if ( isTrue( isPriority ) ) {
			element.style.setProperty( property, value, 'important' );

			return;
		}

		element.style.setProperty( property, value );
	}

	function updateElementInlineStyle( element, property, value ) {
		var isPriority = arguments.length > 3 && arguments[ 3 ] !== undefined ? arguments[ 3 ] : false;

		if ( ! isHTMLElement( element ) ) {
			return;
		}

		updateInlineStyle( element, property, value, isPriority );
	}

	function toPx( value ) {
		return isNumber( value ) ? value + 'px' : EMPTY_STRING;
	}

	function calculateAspectRatio( width, height ) {
		var WIDTH = parseFloat( width );
		var HEIGHT = parseFloat( height );

		return isPositiveNumber( WIDTH ) && isPositiveNumber( HEIGHT ) ? WIDTH / HEIGHT : RATIO_ZERO;
	}

	function getParentElementWidth( element ) {
		return getStylePropFloat( getParentElement( element ), CSS_WIDTH );
	}

	function getIframeHeight( iframe ) {
		if ( ! shouldResizeIframe( iframe ) || ! isIframeSizeValid( iframe ) ) {
			return PIXEL_ZERO;
		}

		var PARENT_ELEMENT_WIDTH = getParentElementWidth( iframe );
		var ASPECT_RATIO = calculateAspectRatio( iframe.width, iframe.height );

		return isPositiveNumber( PARENT_ELEMENT_WIDTH ) && isPositiveNumber( ASPECT_RATIO ) ? Math.round( PARENT_ELEMENT_WIDTH / ASPECT_RATIO ) : PIXEL_ZERO;
	}

	function isIframeSizeValid( iframe ) {
		return isIframeElement( iframe ) && ! isNaN( iframe.width ) && ! isNaN( iframe.height );
	}

	function shouldResizeIframe( iframe ) {
		return isIframeElement( iframe ) && ! isBlockYouTubeIframe( iframe );
	}

	function setIframeSize( iframe ) {
		if ( ! shouldResizeIframe( iframe ) || ! isIframeSizeValid( iframe ) ) {
			return;
		}

		var IFRAME_HEIGHT = getIframeHeight( iframe );

		if ( ! isPositiveNumber( IFRAME_HEIGHT ) ) {
			return;
		}

		updateElementInlineStyle( iframe, CSS_WIDTH, CSS_VALUE_100PCT );
		updateElementInlineStyle( iframe, CSS_HEIGHT, toPx( IFRAME_HEIGHT ) );
	}

	function setIframeSizes() {
		forEach( getIframes(), setIframeSize );
	}

	var EVENT_DOMCONTENTLOADED = 'DOMContentLoaded';

	function onDocumentDomContentLoaded( callback, options ) {
		onDocumentEvent( EVENT_DOMCONTENTLOADED, callback, options );
	}

	var EVENT_RESIZE = 'resize';

	function onWindowResize( callback, options ) {
		onWindowEvent( EVENT_RESIZE, callback, options );
	}

	function addIframeEvents() {
		onDocumentDomContentLoaded( setIframeSizes );
		onWindowLoad( setIframeSizes );
		onWindowResize( setIframeSizes );
	}

	function addContentEvents() {
		addAnchorLinkEvents();
		addIframeEvents();
	}

	var CLASS_SHARED_BOTTOM = 'bottom';
	var CLASS_SHARED_SHOW = 'show';
	var CSS_BOTTOM = 'bottom';
	var DISTANCE_REM_MD = 1.5;
	var CLASS_NAV_BACK_TO_TOP_BUTTON = 'back-to-top';

	function getBackToTopButton() {
		return getElementByClassName( CLASS_NAV_BACK_TO_TOP_BUTTON );
	}

	var CLASS_NAV_BOTTOM_NAVBAR = 'bottom-navbar';

	function getBottomNavbar() {
		return getElementByClassName( CLASS_NAV_BOTTOM_NAVBAR );
	}

	function isBackToTopButton( element ) {
		return isHTMLElement( element, CLASS_NAV_BACK_TO_TOP_BUTTON );
	}

	var CLASS_SECTION_SITE_FOOTER = 'site-footer';

	function getSiteFooter() {
		return getElementByClassName( CLASS_SECTION_SITE_FOOTER );
	}

	function toggleClass( add, element, className ) {
		if ( ! isBoolean( add ) ) {
			return;
		}

		var TOGGLE_CLASS = isTrue( add ) ? addClass : removeClass;

		TOGGLE_CLASS( element, className );
	}

	var EVENT_SCROLL = 'scroll';

	function onWindowScroll( callback, options ) {
		onWindowEvent( EVENT_SCROLL, callback, options );
	}

	function adjustBackToTopBottom() {
		var BACK_TO_TOP_BUTTON = getBackToTopButton();

		if ( ! BACK_TO_TOP_BUTTON ) {
			return;
		}

		var BACK_TO_TOP_BOTTOM_MARGIN = convertRemToPx( DISTANCE_REM_MD );
		var BOTTOM_NAVBAR = getBottomNavbar();
		var BACK_TO_TOP_BUTTON_BOTTOM = BOTTOM_NAVBAR ? getHeight( BOTTOM_NAVBAR ) + BACK_TO_TOP_BOTTOM_MARGIN : BACK_TO_TOP_BOTTOM_MARGIN;

		updateElementInlineStyle( BACK_TO_TOP_BUTTON, CSS_BOTTOM, toPx( BACK_TO_TOP_BUTTON_BOTTOM ) );
	}

	function toggleBackToTopButtonPageBottom() {
		var BACK_TO_TOP_BUTTON = getBackToTopButton();

		if ( ! BACK_TO_TOP_BUTTON ) {
			return;
		}

		var SITE_FOOTER = getSiteFooter();

		if ( ! SITE_FOOTER ) {
			return;
		}

		var BOTTOM_NAVBAR = getBottomNavbar();
		var SITE_CONTENT_VIEWPORT_BOTTOM = BOTTOM_NAVBAR ? getViewportTop( BOTTOM_NAVBAR ) : getViewportHeight();
		var BACK_TO_TOP_BOTTOM_MARGIN = convertRemToPx( DISTANCE_REM_MD );
		var SITE_FOOTER_VIEWPORT_TOP = getViewportTop( SITE_FOOTER ) - BACK_TO_TOP_BOTTOM_MARGIN;

		toggleClass( SITE_CONTENT_VIEWPORT_BOTTOM > SITE_FOOTER_VIEWPORT_TOP, BACK_TO_TOP_BUTTON, CLASS_SHARED_BOTTOM );
		adjustBackToTopBottom();
	}

	function toggleBackToTopButtonVisibility() {
		var BACK_TO_TOP_BUTTON = getBackToTopButton();

		if ( ! BACK_TO_TOP_BUTTON ) {
			return;
		}

		var SCROLL_TOP = getScrollTop();
		var BACK_TO_TOP_BUTTON_SHOW_AT = convertRemToPx( DISTANCE_REM_MD );

		toggleClass( SCROLL_TOP > BACK_TO_TOP_BUTTON_SHOW_AT, BACK_TO_TOP_BUTTON, CLASS_SHARED_SHOW );
	}

	function toggleBackToTopButtonVisibilityAndPageBottom() {
		toggleBackToTopButtonVisibility();
		toggleBackToTopButtonPageBottom();
	}

	function backToSkipLink() {
		var SKIP_LINK = getSkipLink();

		if ( SKIP_LINK ) {
			scrollTo( SKIP_LINK );

			return;
		}

		backToTop();
	}

	function backToTop() {
		scrollTo( document.documentElement );
	}

	function addBackToTopEvents() {
		onDocumentClick( function( event ) {
			if ( ! isEvent( event ) ) {
				return;
			}

			if ( isBackToTopButton( event.target ) ) {
				backToTop();
			}
		} );
		onDocumentKeydown( function( event ) {
			if ( ! isEvent( event ) ) {
				return;
			}

			if ( isEnterKey( event ) ) {
				if ( isBackToTopButton( event.target ) ) {
					event.preventDefault();
					backToSkipLink();
				}
			}
		} );
		onWindowLoad( toggleBackToTopButtonVisibilityAndPageBottom );
		onWindowResize( toggleBackToTopButtonVisibilityAndPageBottom );
		onWindowScroll( toggleBackToTopButtonVisibilityAndPageBottom );
	}

	function addNavigationEvents() {
		addBackToTopEvents();
	}

	var CLASS_SHARED_NO_SCROLL = 'no-scroll';
	var TOGGLE_CLOSE = false;
	var TOGGLE_OPEN = true;
	var CLASS_MOBILE_SEARCH = 'mobile-search';

	function getMobileSearch() {
		return getElementByClassName( CLASS_MOBILE_SEARCH );
	}

	var CLASS_MOBILE_SEARCH_BUTTON = 'mobile-navigation__search-button';

	function getMobileSearchButton() {
		return getElementByClassName( CLASS_MOBILE_SEARCH_BUTTON );
	}

	var CLASS_MOBILE_SEARCH_CLOSE_BUTTON = 'mobile-search__close-search-button';

	function getMobileSearchCloseButton() {
		return getElementByClassName( CLASS_MOBILE_SEARCH_CLOSE_BUTTON );
	}

	var CLASS_SEARCH_FORM_SUBMIT = 'search-submit';
	var SELECTOR_MOBILE_SEARCH_OPENED = '.'.concat( CLASS_MOBILE_SEARCH, '.' ).concat( CLASS_SHARED_SHOW );
	var SELECTOR_MOBILE_SEARCH_SUBMIT_BUTTON = ''.concat( SELECTOR_MOBILE_SEARCH_OPENED, ' .' ).concat( CLASS_SEARCH_FORM_SUBMIT );

	function querySelector( selectors ) {
		var rootElement = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : document;

		return callElementMethod( 'querySelector', selectors, rootElement );
	}

	function getMobileSearchSubmitButton() {
		return querySelector( SELECTOR_MOBILE_SEARCH_SUBMIT_BUTTON );
	}

	var CLASS_MOBILE_SEARCH_CONTAINER = 'mobile-search__container';

	function isMobileSearchBackground( element ) {
		return isHTMLElement( element, CLASS_MOBILE_SEARCH_CONTAINER ) || isHTMLElement( element, CLASS_MOBILE_SEARCH, CLASS_SHARED_SHOW );
	}

	function isMobileSearchButton( element ) {
		return isHTMLElement( element, CLASS_MOBILE_SEARCH_BUTTON );
	}

	function isMobileSearchCloseButton( element ) {
		return isHTMLElement( element, CLASS_MOBILE_SEARCH_CLOSE_BUTTON );
	}

	var CLASS_SEARCH_FORM = 'search-form';
	var SELECTOR_MOBILE_SEARCH_FORM = '.'.concat( CLASS_MOBILE_SEARCH, ' .' ).concat( CLASS_SEARCH_FORM );

	function isMobileSearchForm( element ) {
		return matches( element, SELECTOR_MOBILE_SEARCH_FORM );
	}

	function isMobileSearchOpened() {
		return !! querySelector( SELECTOR_MOBILE_SEARCH_OPENED );
	}

	function isMobileSearchSubmitButton( element ) {
		return matches( element, SELECTOR_MOBILE_SEARCH_SUBMIT_BUTTON );
	}

	var ATTRIBUTE_ARIA_EXPANDED = 'aria-expanded';

	function toggleAriaExpanded( expanded ) {
		if ( ! isBoolean( expanded ) ) {
			return;
		}

		for ( var _len = arguments.length, elements = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			elements[ _key - 1 ] = arguments[ _key ];
		}

		forEach( elements, function( element ) {
			return setAttribute( element, ATTRIBUTE_ARIA_EXPANDED, isTrue( expanded ) );
		} );
	}

	var ATTRIBUTE_ARIA_HIDDEN = 'aria-hidden';

	function toggleAriaHidden( hidden ) {
		if ( ! isBoolean( hidden ) ) {
			return;
		}

		for ( var _len = arguments.length, elements = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			elements[ _key - 1 ] = arguments[ _key ];
		}

		forEach( elements, function( element ) {
			return setAttribute( element, ATTRIBUTE_ARIA_HIDDEN, isTrue( hidden ) );
		} );
	}

	function isEscapeKey( event ) {
		return isKey( event, 'Escape', 27 );
	}

	function isShiftKey( event ) {
		return isEvent( event ) && isTrue( event.shiftKey );
	}

	function isTabKey( event ) {
		return isKey( event, 'Tab', 9 );
	}

	function focusMobileSearchSubmitButton() {
		focusElement( getMobileSearchSubmitButton() );
	}

	function focusMobileSearchCloseButton() {
		focusElement( getMobileSearchCloseButton() );
	}

	function openMobileSearchAndFocusMobileSearchCloseButton() {
		toggleMobileSearch( TOGGLE_OPEN );
		focusMobileSearchCloseButton();
	}

	function focusMobileSearchButton() {
		focusElement( getMobileSearchButton() );
	}

	function toggleMobileSearch( open ) {
		if ( ! isBoolean( open ) ) {
			return;
		}

		var MOBILE_SEARCH = getMobileSearch();

		if ( ! MOBILE_SEARCH ) {
			return;
		}

		toggleAriaExpanded( open, getMobileSearchButton() );
		toggleAriaHidden( ! open, MOBILE_SEARCH );
		toggleClass( open, document.documentElement, CLASS_SHARED_NO_SCROLL );
		toggleClass( open, MOBILE_SEARCH, CLASS_SHARED_SHOW );
	}

	function closeMobileSearchAndFocusMobileSearchButton() {
		toggleMobileSearch( TOGGLE_CLOSE );
		focusMobileSearchButton();
	}

	function addMobileSearchEvents() {
		onDocumentClick( function( event ) {
			if ( ! isEvent( event ) ) {
				return;
			}

			if ( isMobileSearchBackground( event.target ) || isMobileSearchCloseButton( event.target ) ) {
				closeMobileSearchAndFocusMobileSearchButton();

				return;
			}

			if ( isMobileSearchButton( event.target ) ) {
				openMobileSearchAndFocusMobileSearchCloseButton();

				return;
			}

			if ( isMobileSearchForm( event.target ) ) {
				event.stopPropagation();
			}
		} );
		onDocumentKeydown( function( event ) {
			if ( ! isEvent( event ) ) {
				return;
			}

			if ( isEnterKey( event ) ) {
				if ( isMobileSearchCloseButton( event.target ) ) {
					event.preventDefault();
					closeMobileSearchAndFocusMobileSearchButton();

					return;
				}

				if ( isMobileSearchButton( event.target ) ) {
					event.preventDefault();
					openMobileSearchAndFocusMobileSearchCloseButton();
				}

				return;
			}

			if ( isEscapeKey( event ) ) {
				if ( isMobileSearchOpened() ) {
					event.preventDefault();
					closeMobileSearchAndFocusMobileSearchButton();
				}

				return;
			}

			if ( isTabKey( event ) ) {
				if ( isShiftKey( event ) && isMobileSearchCloseButton( event.target ) ) {
					event.preventDefault();
					focusMobileSearchSubmitButton();

					return;
				}

				if ( ! isShiftKey( event ) && isMobileSearchSubmitButton( event.target ) ) {
					event.preventDefault();
					focusMobileSearchCloseButton();
				}
			}
		} );
	}

	var CLASS_SEARCH_FORM_CLEAR_BUTTON = 'search-clear-button';
	var CLASS_SEARCH_FORM_FIELD = 'search-field';

	function isInputElement( element ) {
		for ( var _len = arguments.length, classNames = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			classNames[ _key - 1 ] = arguments[ _key ];
		}

		return isHTMLElementOfType.apply( void 0, [ TAG_INPUT, element ].concat( classNames ) );
	}

	function isSearchField( element ) {
		return isInputElement( element, CLASS_SEARCH_FORM_FIELD );
	}

	var CLASS_SEARCH_FORM_FIELD_CONTAINER = 'search-field-container';

	function isSearchFieldContainer( element ) {
		return isHTMLElement( element, CLASS_SEARCH_FORM_FIELD_CONTAINER );
	}

	function getSearchClearButton( searchField ) {
		if ( ! isSearchField( searchField ) ) {
			return NULL_ELEMENT;
		}

		var SEARCH_FIELD_CONTAINER = getParentElement( searchField );

		return isSearchFieldContainer( SEARCH_FIELD_CONTAINER ) ? getElementByClassName( CLASS_SEARCH_FORM_CLEAR_BUTTON, SEARCH_FIELD_CONTAINER ) : NULL_ELEMENT;
	}

	function isSearchClearButton( element ) {
		return isHTMLElement( element, CLASS_SEARCH_FORM_CLEAR_BUTTON, CLASS_SHARED_SHOW );
	}

	function getSearchField( searchClearButton ) {
		if ( ! isSearchClearButton( searchClearButton ) ) {
			return NULL_ELEMENT;
		}

		var SEARCH_FIELD_CONTAINER = getParentElement( searchClearButton );

		return isSearchFieldContainer( SEARCH_FIELD_CONTAINER ) ? getElementByClassName( CLASS_SEARCH_FORM_FIELD, SEARCH_FIELD_CONTAINER ) : NULL_ELEMENT;
	}

	function isTextAreaElement( element ) {
		for ( var _len = arguments.length, classNames = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			classNames[ _key - 1 ] = arguments[ _key ];
		}

		return isHTMLElementOfType.apply( void 0, [ TAG_TEXTAREA, element ].concat( classNames ) );
	}

	function setInputValue( element, value ) {
		if ( ! ( isInputElement( element ) || isTextAreaElement( element ) ) ) {
			return;
		}

		element.value = value;
	}

	var EVENT_INPUT = 'input';

	function onDocumentInput( callback, options ) {
		onDocumentEvent( EVENT_INPUT, callback, options );
	}

	function toggleSearchClearButton( searchField ) {
		if ( ! isSearchField( searchField ) ) {
			return;
		}

		toggleClass( ! isNullOrEmpty( searchField.value ), getSearchClearButton( searchField ), CLASS_SHARED_SHOW );
	}

	function clearSearchField( searchField ) {
		if ( ! isSearchField( searchField ) ) {
			return;
		}

		setInputValue( searchField, EMPTY_STRING );
		focusElement( searchField );
	}

	function clearSearchFieldAndHideSearchClearButton( searchClearButton ) {
		var SEARCH_FIELD = getSearchField( searchClearButton );

		if ( ! SEARCH_FIELD ) {
			return;
		}

		clearSearchField( SEARCH_FIELD );
		toggleSearchClearButton( SEARCH_FIELD );
	}

	function addSearchFormEvents() {
		onDocumentClick( function( event ) {
			if ( ! isEvent( event ) ) {
				return;
			}

			if ( isSearchClearButton( event.target ) ) {
				clearSearchFieldAndHideSearchClearButton( event.target );
			}
		}, true );
		onDocumentInput( function( event ) {
			if ( ! isEvent( event ) ) {
				return;
			}

			if ( isSearchField( event.target ) ) {
				toggleSearchClearButton( event.target );
			}
		} );
		onDocumentKeydown( function( event ) {
			if ( ! isEvent( event ) ) {
				return;
			}

			if ( isEnterKey( event ) ) {
				if ( isSearchClearButton( event.target ) ) {
					event.preventDefault();
					clearSearchFieldAndHideSearchClearButton( event.target );
				}
			}
		} );
	}

	function addSearchEvents() {
		addMobileSearchEvents();
		addSearchFormEvents();
	}

	addAccessibilityEvents();
	addContentEvents();
	addComponentEvents();
	addNavigationEvents();
	addSearchEvents();
}() );
