You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by sc...@apache.org on 2018/04/30 19:31:59 UTC

[18/51] [partial] nifi-fds git commit: update gh-pages

http://git-wip-us.apache.org/repos/asf/nifi-fds/blob/4a326208/node_modules/@angular/cdk/esm2015/a11y.js
----------------------------------------------------------------------
diff --git a/node_modules/@angular/cdk/esm2015/a11y.js b/node_modules/@angular/cdk/esm2015/a11y.js
new file mode 100644
index 0000000..0c63404
--- /dev/null
+++ b/node_modules/@angular/cdk/esm2015/a11y.js
@@ -0,0 +1,1618 @@
+/**
+ * @license
+ * Copyright Google Inc. All Rights Reserved.
+ *
+ * Use of this source code is governed by an MIT-style license that can be
+ * found in the LICENSE file at https://angular.io/license
+ */
+import { Subject } from 'rxjs/Subject';
+import { Subscription } from 'rxjs/Subscription';
+import { A, DOWN_ARROW, NINE, TAB, UP_ARROW, Z, ZERO } from '@angular/cdk/keycodes';
+import { RxChain, debounceTime, doOperator, filter, first, map } from '@angular/cdk/rxjs';
+import { Directive, ElementRef, EventEmitter, Inject, Injectable, InjectionToken, Input, NgModule, NgZone, Optional, Output, Renderer2, SkipSelf } from '@angular/core';
+import { Platform, PlatformModule } from '@angular/cdk/platform';
+import { coerceBooleanProperty } from '@angular/cdk/coercion';
+import { of } from 'rxjs/observable/of';
+import { CommonModule } from '@angular/common';
+
+/**
+ * This class manages keyboard events for selectable lists. If you pass it a query list
+ * of items, it will set the active item correctly when arrow events occur.
+ */
+class ListKeyManager {
+    /**
+     * @param {?} _items
+     */
+    constructor(_items) {
+        this._items = _items;
+        this._activeItemIndex = -1;
+        this._wrap = false;
+        this._letterKeyStream = new Subject();
+        this._typeaheadSubscription = Subscription.EMPTY;
+        this._pressedLetters = [];
+        /**
+         * Stream that emits any time the TAB key is pressed, so components can react
+         * when focus is shifted off of the list.
+         */
+        this.tabOut = new Subject();
+    }
+    /**
+     * Turns on wrapping mode, which ensures that the active item will wrap to
+     * the other end of list when there are no more items in the given direction.
+     * @return {?}
+     */
+    withWrap() {
+        this._wrap = true;
+        return this;
+    }
+    /**
+     * Turns on typeahead mode which allows users to set the active item by typing.
+     * @param {?=} debounceInterval Time to wait after the last keystroke before setting the active item.
+     * @return {?}
+     */
+    withTypeAhead(debounceInterval = 200) {
+        if (this._items.length && this._items.some(item => typeof item.getLabel !== 'function')) {
+            throw Error('ListKeyManager items in typeahead mode must implement the `getLabel` method.');
+        }
+        this._typeaheadSubscription.unsubscribe();
+        // Debounce the presses of non-navigational keys, collect the ones that correspond to letters
+        // and convert those letters back into a string. Afterwards find the first item that starts
+        // with that string and select it.
+        this._typeaheadSubscription = RxChain.from(this._letterKeyStream)
+            .call(doOperator, keyCode => this._pressedLetters.push(keyCode))
+            .call(debounceTime, debounceInterval)
+            .call(filter, () => this._pressedLetters.length > 0)
+            .call(map, () => this._pressedLetters.join(''))
+            .subscribe(inputString => {
+            const /** @type {?} */ items = this._items.toArray();
+            // Start at 1 because we want to start searching at the item immediately
+            // following the current active item.
+            for (let /** @type {?} */ i = 1; i < items.length + 1; i++) {
+                const /** @type {?} */ index = (this._activeItemIndex + i) % items.length;
+                const /** @type {?} */ item = items[index];
+                if (!item.disabled && ((item.getLabel))().toUpperCase().trim().indexOf(inputString) === 0) {
+                    this.setActiveItem(index);
+                    break;
+                }
+            }
+            this._pressedLetters = [];
+        });
+        return this;
+    }
+    /**
+     * Sets the active item to the item at the index specified.
+     * @param {?} index The index of the item to be set as active.
+     * @return {?}
+     */
+    setActiveItem(index) {
+        this._activeItemIndex = index;
+        this._activeItem = this._items.toArray()[index];
+    }
+    /**
+     * Sets the active item depending on the key event passed in.
+     * @param {?} event Keyboard event to be used for determining which element should be active.
+     * @return {?}
+     */
+    onKeydown(event) {
+        switch (event.keyCode) {
+            case DOWN_ARROW:
+                this.setNextItemActive();
+                break;
+            case UP_ARROW:
+                this.setPreviousItemActive();
+                break;
+            case TAB:
+                this.tabOut.next();
+                return;
+            default:
+                const /** @type {?} */ keyCode = event.keyCode;
+                // Attempt to use the `event.key` which also maps it to the user's keyboard language,
+                // otherwise fall back to resolving alphanumeric characters via the keyCode.
+                if (event.key && event.key.length === 1) {
+                    this._letterKeyStream.next(event.key.toLocaleUpperCase());
+                }
+                else if ((keyCode >= A && keyCode <= Z) || (keyCode >= ZERO && keyCode <= NINE)) {
+                    this._letterKeyStream.next(String.fromCharCode(keyCode));
+                }
+                // Note that we return here, in order to avoid preventing
+                // the default action of non-navigational keys.
+                return;
+        }
+        this._pressedLetters = [];
+        event.preventDefault();
+    }
+    /**
+     * Index of the currently active item.
+     * @return {?}
+     */
+    get activeItemIndex() {
+        return this._activeItemIndex;
+    }
+    /**
+     * The active item.
+     * @return {?}
+     */
+    get activeItem() {
+        return this._activeItem;
+    }
+    /**
+     * Sets the active item to the first enabled item in the list.
+     * @return {?}
+     */
+    setFirstItemActive() {
+        this._setActiveItemByIndex(0, 1);
+    }
+    /**
+     * Sets the active item to the last enabled item in the list.
+     * @return {?}
+     */
+    setLastItemActive() {
+        this._setActiveItemByIndex(this._items.length - 1, -1);
+    }
+    /**
+     * Sets the active item to the next enabled item in the list.
+     * @return {?}
+     */
+    setNextItemActive() {
+        this._activeItemIndex < 0 ? this.setFirstItemActive() : this._setActiveItemByDelta(1);
+    }
+    /**
+     * Sets the active item to a previous enabled item in the list.
+     * @return {?}
+     */
+    setPreviousItemActive() {
+        this._activeItemIndex < 0 && this._wrap ? this.setLastItemActive()
+            : this._setActiveItemByDelta(-1);
+    }
+    /**
+     * Allows setting of the activeItemIndex without any other effects.
+     * @param {?} index The new activeItemIndex.
+     * @return {?}
+     */
+    updateActiveItemIndex(index) {
+        this._activeItemIndex = index;
+    }
+    /**
+     * This method sets the active item, given a list of items and the delta between the
+     * currently active item and the new active item. It will calculate differently
+     * depending on whether wrap mode is turned on.
+     * @param {?} delta
+     * @param {?=} items
+     * @return {?}
+     */
+    _setActiveItemByDelta(delta, items = this._items.toArray()) {
+        this._wrap ? this._setActiveInWrapMode(delta, items)
+            : this._setActiveInDefaultMode(delta, items);
+    }
+    /**
+     * Sets the active item properly given "wrap" mode. In other words, it will continue to move
+     * down the list until it finds an item that is not disabled, and it will wrap if it
+     * encounters either end of the list.
+     * @param {?} delta
+     * @param {?} items
+     * @return {?}
+     */
+    _setActiveInWrapMode(delta, items) {
+        // when active item would leave menu, wrap to beginning or end
+        this._activeItemIndex =
+            (this._activeItemIndex + delta + items.length) % items.length;
+        // skip all disabled menu items recursively until an enabled one is reached
+        if (items[this._activeItemIndex].disabled) {
+            this._setActiveInWrapMode(delta, items);
+        }
+        else {
+            this.setActiveItem(this._activeItemIndex);
+        }
+    }
+    /**
+     * Sets the active item properly given the default mode. In other words, it will
+     * continue to move down the list until it finds an item that is not disabled. If
+     * it encounters either end of the list, it will stop and not wrap.
+     * @param {?} delta
+     * @param {?} items
+     * @return {?}
+     */
+    _setActiveInDefaultMode(delta, items) {
+        this._setActiveItemByIndex(this._activeItemIndex + delta, delta, items);
+    }
+    /**
+     * Sets the active item to the first enabled item starting at the index specified. If the
+     * item is disabled, it will move in the fallbackDelta direction until it either
+     * finds an enabled item or encounters the end of the list.
+     * @param {?} index
+     * @param {?} fallbackDelta
+     * @param {?=} items
+     * @return {?}
+     */
+    _setActiveItemByIndex(index, fallbackDelta, items = this._items.toArray()) {
+        if (!items[index]) {
+            return;
+        }
+        while (items[index].disabled) {
+            index += fallbackDelta;
+            if (!items[index]) {
+                return;
+            }
+        }
+        this.setActiveItem(index);
+    }
+}
+
+class ActiveDescendantKeyManager extends ListKeyManager {
+    /**
+     * This method sets the active item to the item at the specified index.
+     * It also adds active styles to the newly active item and removes active
+     * styles from the previously active item.
+     * @param {?} index
+     * @return {?}
+     */
+    setActiveItem(index) {
+        if (this.activeItem) {
+            this.activeItem.setInactiveStyles();
+        }
+        super.setActiveItem(index);
+        if (this.activeItem) {
+            this.activeItem.setActiveStyles();
+        }
+    }
+}
+
+/**
+ * IDs are deliminated by an empty space, as per the spec.
+ */
+const ID_DELIMINATOR = ' ';
+/**
+ * Adds the given ID to the specified ARIA attribute on an element.
+ * Used for attributes such as aria-labelledby, aria-owns, etc.
+ * @param {?} el
+ * @param {?} attr
+ * @param {?} id
+ * @return {?}
+ */
+function addAriaReferencedId(el, attr, id) {
+    const /** @type {?} */ ids = getAriaReferenceIds(el, attr);
+    if (ids.some(existingId => existingId.trim() == id.trim())) {
+        return;
+    }
+    ids.push(id.trim());
+    el.setAttribute(attr, ids.join(ID_DELIMINATOR));
+}
+/**
+ * Removes the given ID from the specified ARIA attribute on an element.
+ * Used for attributes such as aria-labelledby, aria-owns, etc.
+ * @param {?} el
+ * @param {?} attr
+ * @param {?} id
+ * @return {?}
+ */
+function removeAriaReferencedId(el, attr, id) {
+    const /** @type {?} */ ids = getAriaReferenceIds(el, attr);
+    const /** @type {?} */ filteredIds = ids.filter(val => val != id.trim());
+    el.setAttribute(attr, filteredIds.join(ID_DELIMINATOR));
+}
+/**
+ * Gets the list of IDs referenced by the given ARIA attribute on an element.
+ * Used for attributes such as aria-labelledby, aria-owns, etc.
+ * @param {?} el
+ * @param {?} attr
+ * @return {?}
+ */
+function getAriaReferenceIds(el, attr) {
+    // Get string array of all individual ids (whitespace deliminated) in the attribute value
+    return (el.getAttribute(attr) || '').match(/\S+/g) || [];
+}
+
+/**
+ * ID used for the body container where all messages are appended.
+ */
+const MESSAGES_CONTAINER_ID = 'cdk-describedby-message-container';
+/**
+ * ID prefix used for each created message element.
+ */
+const CDK_DESCRIBEDBY_ID_PREFIX = 'cdk-describedby-message';
+/**
+ * Attribute given to each host element that is described by a message element.
+ */
+const CDK_DESCRIBEDBY_HOST_ATTRIBUTE = 'cdk-describedby-host';
+/**
+ * Global incremental identifier for each registered message element.
+ */
+let nextId = 0;
+/**
+ * Global map of all registered message elements that have been placed into the document.
+ */
+const messageRegistry = new Map();
+/**
+ * Container for all registered messages.
+ */
+let messagesContainer = null;
+/**
+ * Utility that creates visually hidden elements with a message content. Useful for elements that
+ * want to use aria-describedby to further describe themselves without adding additional visual
+ * content.
+ * \@docs-private
+ */
+class AriaDescriber {
+    /**
+     * @param {?} _platform
+     */
+    constructor(_platform) {
+        this._platform = _platform;
+    }
+    /**
+     * Adds to the host element an aria-describedby reference to a hidden element that contains
+     * the message. If the same message has already been registered, then it will reuse the created
+     * message element.
+     * @param {?} hostElement
+     * @param {?} message
+     * @return {?}
+     */
+    describe(hostElement, message) {
+        if (!this._platform.isBrowser || !message.trim()) {
+            return;
+        }
+        if (!messageRegistry.has(message)) {
+            createMessageElement(message);
+        }
+        if (!isElementDescribedByMessage(hostElement, message)) {
+            addMessageReference(hostElement, message);
+        }
+    }
+    /**
+     * Removes the host element's aria-describedby reference to the message element.
+     * @param {?} hostElement
+     * @param {?} message
+     * @return {?}
+     */
+    removeDescription(hostElement, message) {
+        if (!this._platform.isBrowser || !message.trim()) {
+            return;
+        }
+        if (isElementDescribedByMessage(hostElement, message)) {
+            removeMessageReference(hostElement, message);
+        }
+        const /** @type {?} */ registeredMessage = messageRegistry.get(message);
+        if (registeredMessage && registeredMessage.referenceCount === 0) {
+            deleteMessageElement(message);
+        }
+        if (messagesContainer && messagesContainer.childNodes.length === 0) {
+            deleteMessagesContainer();
+        }
+    }
+    /**
+     * Unregisters all created message elements and removes the message container.
+     * @return {?}
+     */
+    ngOnDestroy() {
+        if (!this._platform.isBrowser) {
+            return;
+        }
+        const /** @type {?} */ describedElements = document.querySelectorAll(`[${CDK_DESCRIBEDBY_HOST_ATTRIBUTE}]`);
+        for (let /** @type {?} */ i = 0; i < describedElements.length; i++) {
+            removeCdkDescribedByReferenceIds(describedElements[i]);
+            describedElements[i].removeAttribute(CDK_DESCRIBEDBY_HOST_ATTRIBUTE);
+        }
+        if (messagesContainer) {
+            deleteMessagesContainer();
+        }
+        messageRegistry.clear();
+    }
+}
+AriaDescriber.decorators = [
+    { type: Injectable },
+];
+/**
+ * @nocollapse
+ */
+AriaDescriber.ctorParameters = () => [
+    { type: Platform, },
+];
+/**
+ * Creates a new element in the visually hidden message container element with the message
+ * as its content and adds it to the message registry.
+ * @param {?} message
+ * @return {?}
+ */
+function createMessageElement(message) {
+    const /** @type {?} */ messageElement = document.createElement('div');
+    messageElement.setAttribute('id', `${CDK_DESCRIBEDBY_ID_PREFIX}-${nextId++}`);
+    messageElement.appendChild(/** @type {?} */ ((document.createTextNode(message))));
+    if (!messagesContainer) {
+        createMessagesContainer();
+    } /** @type {?} */
+    ((messagesContainer)).appendChild(messageElement);
+    messageRegistry.set(message, { messageElement, referenceCount: 0 });
+}
+/**
+ * Deletes the message element from the global messages container.
+ * @param {?} message
+ * @return {?}
+ */
+function deleteMessageElement(message) {
+    const /** @type {?} */ registeredMessage = messageRegistry.get(message);
+    const /** @type {?} */ messageElement = registeredMessage && registeredMessage.messageElement;
+    if (messagesContainer && messageElement) {
+        messagesContainer.removeChild(messageElement);
+    }
+    messageRegistry.delete(message);
+}
+/**
+ * Creates the global container for all aria-describedby messages.
+ * @return {?}
+ */
+function createMessagesContainer() {
+    messagesContainer = document.createElement('div');
+    messagesContainer.setAttribute('id', MESSAGES_CONTAINER_ID);
+    messagesContainer.setAttribute('aria-hidden', 'true');
+    messagesContainer.style.display = 'none';
+    document.body.appendChild(messagesContainer);
+}
+/**
+ * Deletes the global messages container.
+ * @return {?}
+ */
+function deleteMessagesContainer() {
+    document.body.removeChild(/** @type {?} */ ((messagesContainer)));
+    messagesContainer = null;
+}
+/**
+ * Removes all cdk-describedby messages that are hosted through the element.
+ * @param {?} element
+ * @return {?}
+ */
+function removeCdkDescribedByReferenceIds(element) {
+    // Remove all aria-describedby reference IDs that are prefixed by CDK_DESCRIBEDBY_ID_PREFIX
+    const /** @type {?} */ originalReferenceIds = getAriaReferenceIds(element, 'aria-describedby')
+        .filter(id => id.indexOf(CDK_DESCRIBEDBY_ID_PREFIX) != 0);
+    element.setAttribute('aria-describedby', originalReferenceIds.join(' '));
+}
+/**
+ * Adds a message reference to the element using aria-describedby and increments the registered
+ * message's reference count.
+ * @param {?} element
+ * @param {?} message
+ * @return {?}
+ */
+function addMessageReference(element, message) {
+    const /** @type {?} */ registeredMessage = ((messageRegistry.get(message)));
+    // Add the aria-describedby reference and set the describedby_host attribute to mark the element.
+    addAriaReferencedId(element, 'aria-describedby', registeredMessage.messageElement.id);
+    element.setAttribute(CDK_DESCRIBEDBY_HOST_ATTRIBUTE, '');
+    registeredMessage.referenceCount++;
+}
+/**
+ * Removes a message reference from the element using aria-describedby and decrements the registered
+ * message's reference count.
+ * @param {?} element
+ * @param {?} message
+ * @return {?}
+ */
+function removeMessageReference(element, message) {
+    const /** @type {?} */ registeredMessage = ((messageRegistry.get(message)));
+    registeredMessage.referenceCount--;
+    removeAriaReferencedId(element, 'aria-describedby', registeredMessage.messageElement.id);
+    element.removeAttribute(CDK_DESCRIBEDBY_HOST_ATTRIBUTE);
+}
+/**
+ * Returns true if the element has been described by the provided message ID.
+ * @param {?} element
+ * @param {?} message
+ * @return {?}
+ */
+function isElementDescribedByMessage(element, message) {
+    const /** @type {?} */ referenceIds = getAriaReferenceIds(element, 'aria-describedby');
+    const /** @type {?} */ registeredMessage = messageRegistry.get(message);
+    const /** @type {?} */ messageId = registeredMessage && registeredMessage.messageElement.id;
+    return !!messageId && referenceIds.indexOf(messageId) != -1;
+}
+/**
+ * \@docs-private
+ * @param {?} parentDispatcher
+ * @param {?} platform
+ * @return {?}
+ */
+function ARIA_DESCRIBER_PROVIDER_FACTORY(parentDispatcher, platform) {
+    return parentDispatcher || new AriaDescriber(platform);
+}
+/**
+ * \@docs-private
+ */
+const ARIA_DESCRIBER_PROVIDER = {
+    // If there is already an AriaDescriber available, use that. Otherwise, provide a new one.
+    provide: AriaDescriber,
+    deps: [
+        [new Optional(), new SkipSelf(), AriaDescriber],
+        Platform
+    ],
+    useFactory: ARIA_DESCRIBER_PROVIDER_FACTORY
+};
+
+/**
+ * Screenreaders will often fire fake mousedown events when a focusable element
+ * is activated using the keyboard. We can typically distinguish between these faked
+ * mousedown events and real mousedown events using the "buttons" property. While
+ * real mousedowns will indicate the mouse button that was pressed (e.g. "1" for
+ * the left mouse button), faked mousedowns will usually set the property value to 0.
+ * @param {?} event
+ * @return {?}
+ */
+function isFakeMousedownFromScreenReader(event) {
+    return event.buttons === 0;
+}
+
+class FocusKeyManager extends ListKeyManager {
+    /**
+     * This method sets the active item to the item at the specified index.
+     * It also adds focuses the newly active item.
+     * @param {?} index
+     * @return {?}
+     */
+    setActiveItem(index) {
+        super.setActiveItem(index);
+        if (this.activeItem) {
+            this.activeItem.focus();
+        }
+    }
+}
+
+/**
+ * Utility for checking the interactivity of an element, such as whether is is focusable or
+ * tabbable.
+ */
+class InteractivityChecker {
+    /**
+     * @param {?} _platform
+     */
+    constructor(_platform) {
+        this._platform = _platform;
+    }
+    /**
+     * Gets whether an element is disabled.
+     *
+     * @param {?} element Element to be checked.
+     * @return {?} Whether the element is disabled.
+     */
+    isDisabled(element) {
+        // This does not capture some cases, such as a non-form control with a disabled attribute or
+        // a form control inside of a disabled form, but should capture the most common cases.
+        return element.hasAttribute('disabled');
+    }
+    /**
+     * Gets whether an element is visible for the purposes of interactivity.
+     *
+     * This will capture states like `display: none` and `visibility: hidden`, but not things like
+     * being clipped by an `overflow: hidden` parent or being outside the viewport.
+     *
+     * @param {?} element
+     * @return {?} Whether the element is visible.
+     */
+    isVisible(element) {
+        return hasGeometry(element) && getComputedStyle(element).visibility === 'visible';
+    }
+    /**
+     * Gets whether an element can be reached via Tab key.
+     * Assumes that the element has already been checked with isFocusable.
+     *
+     * @param {?} element Element to be checked.
+     * @return {?} Whether the element is tabbable.
+     */
+    isTabbable(element) {
+        // Nothing is tabbable on the the server 😎
+        if (!this._platform.isBrowser) {
+            return false;
+        }
+        let /** @type {?} */ frameElement = (getWindow(element).frameElement);
+        if (frameElement) {
+            let /** @type {?} */ frameType = frameElement && frameElement.nodeName.toLowerCase();
+            // Frame elements inherit their tabindex onto all child elements.
+            if (getTabIndexValue(frameElement) === -1) {
+                return false;
+            }
+            // Webkit and Blink consider anything inside of an <object> element as non-tabbable.
+            if ((this._platform.BLINK || this._platform.WEBKIT) && frameType === 'object') {
+                return false;
+            }
+            // Webkit and Blink disable tabbing to an element inside of an invisible frame.
+            if ((this._platform.BLINK || this._platform.WEBKIT) && !this.isVisible(frameElement)) {
+                return false;
+            }
+        }
+        let /** @type {?} */ nodeName = element.nodeName.toLowerCase();
+        let /** @type {?} */ tabIndexValue = getTabIndexValue(element);
+        if (element.hasAttribute('contenteditable')) {
+            return tabIndexValue !== -1;
+        }
+        if (nodeName === 'iframe') {
+            // The frames may be tabbable depending on content, but it's not possibly to reliably
+            // investigate the content of the frames.
+            return false;
+        }
+        if (nodeName === 'audio') {
+            if (!element.hasAttribute('controls')) {
+                // By default an <audio> element without the controls enabled is not tabbable.
+                return false;
+            }
+            else if (this._platform.BLINK) {
+                // In Blink <audio controls> elements are always tabbable.
+                return true;
+            }
+        }
+        if (nodeName === 'video') {
+            if (!element.hasAttribute('controls') && this._platform.TRIDENT) {
+                // In Trident a <video> element without the controls enabled is not tabbable.
+                return false;
+            }
+            else if (this._platform.BLINK || this._platform.FIREFOX) {
+                // In Chrome and Firefox <video controls> elements are always tabbable.
+                return true;
+            }
+        }
+        if (nodeName === 'object' && (this._platform.BLINK || this._platform.WEBKIT)) {
+            // In all Blink and WebKit based browsers <object> elements are never tabbable.
+            return false;
+        }
+        // In iOS the browser only considers some specific elements as tabbable.
+        if (this._platform.WEBKIT && this._platform.IOS && !isPotentiallyTabbableIOS(element)) {
+            return false;
+        }
+        return element.tabIndex >= 0;
+    }
+    /**
+     * Gets whether an element can be focused by the user.
+     *
+     * @param {?} element Element to be checked.
+     * @return {?} Whether the element is focusable.
+     */
+    isFocusable(element) {
+        // Perform checks in order of left to most expensive.
+        // Again, naive approach that does not capture many edge cases and browser quirks.
+        return isPotentiallyFocusable(element) && !this.isDisabled(element) && this.isVisible(element);
+    }
+}
+InteractivityChecker.decorators = [
+    { type: Injectable },
+];
+/**
+ * @nocollapse
+ */
+InteractivityChecker.ctorParameters = () => [
+    { type: Platform, },
+];
+/**
+ * Checks whether the specified element has any geometry / rectangles.
+ * @param {?} element
+ * @return {?}
+ */
+function hasGeometry(element) {
+    // Use logic from jQuery to check for an invisible element.
+    // See https://github.com/jquery/jquery/blob/master/src/css/hiddenVisibleSelectors.js#L12
+    return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);
+}
+/**
+ * Gets whether an element's
+ * @param {?} element
+ * @return {?}
+ */
+function isNativeFormElement(element) {
+    let /** @type {?} */ nodeName = element.nodeName.toLowerCase();
+    return nodeName === 'input' ||
+        nodeName === 'select' ||
+        nodeName === 'button' ||
+        nodeName === 'textarea';
+}
+/**
+ * Gets whether an element is an <input type="hidden">.
+ * @param {?} element
+ * @return {?}
+ */
+function isHiddenInput(element) {
+    return isInputElement(element) && element.type == 'hidden';
+}
+/**
+ * Gets whether an element is an anchor that has an href attribute.
+ * @param {?} element
+ * @return {?}
+ */
+function isAnchorWithHref(element) {
+    return isAnchorElement(element) && element.hasAttribute('href');
+}
+/**
+ * Gets whether an element is an input element.
+ * @param {?} element
+ * @return {?}
+ */
+function isInputElement(element) {
+    return element.nodeName.toLowerCase() == 'input';
+}
+/**
+ * Gets whether an element is an anchor element.
+ * @param {?} element
+ * @return {?}
+ */
+function isAnchorElement(element) {
+    return element.nodeName.toLowerCase() == 'a';
+}
+/**
+ * Gets whether an element has a valid tabindex.
+ * @param {?} element
+ * @return {?}
+ */
+function hasValidTabIndex(element) {
+    if (!element.hasAttribute('tabindex') || element.tabIndex === undefined) {
+        return false;
+    }
+    let /** @type {?} */ tabIndex = element.getAttribute('tabindex');
+    // IE11 parses tabindex="" as the value "-32768"
+    if (tabIndex == '-32768') {
+        return false;
+    }
+    return !!(tabIndex && !isNaN(parseInt(tabIndex, 10)));
+}
+/**
+ * Returns the parsed tabindex from the element attributes instead of returning the
+ * evaluated tabindex from the browsers defaults.
+ * @param {?} element
+ * @return {?}
+ */
+function getTabIndexValue(element) {
+    if (!hasValidTabIndex(element)) {
+        return null;
+    }
+    // See browser issue in Gecko https://bugzilla.mozilla.org/show_bug.cgi?id=1128054
+    const /** @type {?} */ tabIndex = parseInt(element.getAttribute('tabindex') || '', 10);
+    return isNaN(tabIndex) ? -1 : tabIndex;
+}
+/**
+ * Checks whether the specified element is potentially tabbable on iOS
+ * @param {?} element
+ * @return {?}
+ */
+function isPotentiallyTabbableIOS(element) {
+    let /** @type {?} */ nodeName = element.nodeName.toLowerCase();
+    let /** @type {?} */ inputType = nodeName === 'input' && ((element)).type;
+    return inputType === 'text'
+        || inputType === 'password'
+        || nodeName === 'select'
+        || nodeName === 'textarea';
+}
+/**
+ * Gets whether an element is potentially focusable without taking current visible/disabled state
+ * into account.
+ * @param {?} element
+ * @return {?}
+ */
+function isPotentiallyFocusable(element) {
+    // Inputs are potentially focusable *unless* they're type="hidden".
+    if (isHiddenInput(element)) {
+        return false;
+    }
+    return isNativeFormElement(element) ||
+        isAnchorWithHref(element) ||
+        element.hasAttribute('contenteditable') ||
+        hasValidTabIndex(element);
+}
+/**
+ * Gets the parent window of a DOM node with regards of being inside of an iframe.
+ * @param {?} node
+ * @return {?}
+ */
+function getWindow(node) {
+    return node.ownerDocument.defaultView || window;
+}
+
+/**
+ * Class that allows for trapping focus within a DOM element.
+ *
+ * NOTE: This class currently uses a very simple (naive) approach to focus trapping.
+ * It assumes that the tab order is the same as DOM order, which is not necessarily true.
+ * Things like tabIndex > 0, flex `order`, and shadow roots can cause to two to misalign.
+ * This will be replaced with a more intelligent solution before the library is considered stable.
+ */
+class FocusTrap {
+    /**
+     * @param {?} _element
+     * @param {?} _platform
+     * @param {?} _checker
+     * @param {?} _ngZone
+     * @param {?=} deferAnchors
+     */
+    constructor(_element, _platform, _checker, _ngZone, deferAnchors = false) {
+        this._element = _element;
+        this._platform = _platform;
+        this._checker = _checker;
+        this._ngZone = _ngZone;
+        this._enabled = true;
+        if (!deferAnchors) {
+            this.attachAnchors();
+        }
+    }
+    /**
+     * Whether the focus trap is active.
+     * @return {?}
+     */
+    get enabled() { return this._enabled; }
+    /**
+     * @param {?} val
+     * @return {?}
+     */
+    set enabled(val) {
+        this._enabled = val;
+        if (this._startAnchor && this._endAnchor) {
+            this._startAnchor.tabIndex = this._endAnchor.tabIndex = this._enabled ? 0 : -1;
+        }
+    }
+    /**
+     * Destroys the focus trap by cleaning up the anchors.
+     * @return {?}
+     */
+    destroy() {
+        if (this._startAnchor && this._startAnchor.parentNode) {
+            this._startAnchor.parentNode.removeChild(this._startAnchor);
+        }
+        if (this._endAnchor && this._endAnchor.parentNode) {
+            this._endAnchor.parentNode.removeChild(this._endAnchor);
+        }
+        this._startAnchor = this._endAnchor = null;
+    }
+    /**
+     * Inserts the anchors into the DOM. This is usually done automatically
+     * in the constructor, but can be deferred for cases like directives with `*ngIf`.
+     * @return {?}
+     */
+    attachAnchors() {
+        // If we're not on the browser, there can be no focus to trap.
+        if (!this._platform.isBrowser) {
+            return;
+        }
+        if (!this._startAnchor) {
+            this._startAnchor = this._createAnchor();
+        }
+        if (!this._endAnchor) {
+            this._endAnchor = this._createAnchor();
+        }
+        this._ngZone.runOutsideAngular(() => {
+            ((this._startAnchor)).addEventListener('focus', () => {
+                this.focusLastTabbableElement();
+            }); /** @type {?} */
+            ((this._endAnchor)).addEventListener('focus', () => {
+                this.focusFirstTabbableElement();
+            });
+            if (this._element.parentNode) {
+                this._element.parentNode.insertBefore(/** @type {?} */ ((this._startAnchor)), this._element);
+                this._element.parentNode.insertBefore(/** @type {?} */ ((this._endAnchor)), this._element.nextSibling);
+            }
+        });
+    }
+    /**
+     * Waits for the zone to stabilize, then either focuses the first element that the
+     * user specified, or the first tabbable element.
+     * @return {?} Returns a promise that resolves with a boolean, depending
+     * on whether focus was moved successfuly.
+     */
+    focusInitialElementWhenReady() {
+        return new Promise(resolve => {
+            this._executeOnStable(() => resolve(this.focusInitialElement()));
+        });
+    }
+    /**
+     * Waits for the zone to stabilize, then focuses
+     * the first tabbable element within the focus trap region.
+     * @return {?} Returns a promise that resolves with a boolean, depending
+     * on whether focus was moved successfuly.
+     */
+    focusFirstTabbableElementWhenReady() {
+        return new Promise(resolve => {
+            this._executeOnStable(() => resolve(this.focusFirstTabbableElement()));
+        });
+    }
+    /**
+     * Waits for the zone to stabilize, then focuses
+     * the last tabbable element within the focus trap region.
+     * @return {?} Returns a promise that resolves with a boolean, depending
+     * on whether focus was moved successfuly.
+     */
+    focusLastTabbableElementWhenReady() {
+        return new Promise(resolve => {
+            this._executeOnStable(() => resolve(this.focusLastTabbableElement()));
+        });
+    }
+    /**
+     * Get the specified boundary element of the trapped region.
+     * @param {?} bound The boundary to get (start or end of trapped region).
+     * @return {?} The boundary element.
+     */
+    _getRegionBoundary(bound) {
+        // Contains the deprecated version of selector, for temporary backwards comparability.
+        let /** @type {?} */ markers = (this._element.querySelectorAll(`[cdk-focus-region-${bound}], ` +
+            `[cdk-focus-${bound}]`));
+        for (let /** @type {?} */ i = 0; i < markers.length; i++) {
+            if (markers[i].hasAttribute(`cdk-focus-${bound}`)) {
+                console.warn(`Found use of deprecated attribute 'cdk-focus-${bound}',` +
+                    ` use 'cdk-focus-region-${bound}' instead.`, markers[i]);
+            }
+        }
+        if (bound == 'start') {
+            return markers.length ? markers[0] : this._getFirstTabbableElement(this._element);
+        }
+        return markers.length ?
+            markers[markers.length - 1] : this._getLastTabbableElement(this._element);
+    }
+    /**
+     * Focuses the element that should be focused when the focus trap is initialized.
+     * @return {?} Returns whether focus was moved successfuly.
+     */
+    focusInitialElement() {
+        const /** @type {?} */ redirectToElement = (this._element.querySelector('[cdk-focus-initial]'));
+        if (redirectToElement) {
+            redirectToElement.focus();
+            return true;
+        }
+        return this.focusFirstTabbableElement();
+    }
+    /**
+     * Focuses the first tabbable element within the focus trap region.
+     * @return {?} Returns whether focus was moved successfuly.
+     */
+    focusFirstTabbableElement() {
+        const /** @type {?} */ redirectToElement = this._getRegionBoundary('start');
+        if (redirectToElement) {
+            redirectToElement.focus();
+        }
+        return !!redirectToElement;
+    }
+    /**
+     * Focuses the last tabbable element within the focus trap region.
+     * @return {?} Returns whether focus was moved successfuly.
+     */
+    focusLastTabbableElement() {
+        const /** @type {?} */ redirectToElement = this._getRegionBoundary('end');
+        if (redirectToElement) {
+            redirectToElement.focus();
+        }
+        return !!redirectToElement;
+    }
+    /**
+     * Get the first tabbable element from a DOM subtree (inclusive).
+     * @param {?} root
+     * @return {?}
+     */
+    _getFirstTabbableElement(root) {
+        if (this._checker.isFocusable(root) && this._checker.isTabbable(root)) {
+            return root;
+        }
+        // Iterate in DOM order. Note that IE doesn't have `children` for SVG so we fall
+        // back to `childNodes` which includes text nodes, comments etc.
+        let /** @type {?} */ children = root.children || root.childNodes;
+        for (let /** @type {?} */ i = 0; i < children.length; i++) {
+            let /** @type {?} */ tabbableChild = children[i].nodeType === Node.ELEMENT_NODE ?
+                this._getFirstTabbableElement(/** @type {?} */ (children[i])) :
+                null;
+            if (tabbableChild) {
+                return tabbableChild;
+            }
+        }
+        return null;
+    }
+    /**
+     * Get the last tabbable element from a DOM subtree (inclusive).
+     * @param {?} root
+     * @return {?}
+     */
+    _getLastTabbableElement(root) {
+        if (this._checker.isFocusable(root) && this._checker.isTabbable(root)) {
+            return root;
+        }
+        // Iterate in reverse DOM order.
+        let /** @type {?} */ children = root.children || root.childNodes;
+        for (let /** @type {?} */ i = children.length - 1; i >= 0; i--) {
+            let /** @type {?} */ tabbableChild = children[i].nodeType === Node.ELEMENT_NODE ?
+                this._getLastTabbableElement(/** @type {?} */ (children[i])) :
+                null;
+            if (tabbableChild) {
+                return tabbableChild;
+            }
+        }
+        return null;
+    }
+    /**
+     * Creates an anchor element.
+     * @return {?}
+     */
+    _createAnchor() {
+        let /** @type {?} */ anchor = document.createElement('div');
+        anchor.tabIndex = this._enabled ? 0 : -1;
+        anchor.classList.add('cdk-visually-hidden');
+        anchor.classList.add('cdk-focus-trap-anchor');
+        return anchor;
+    }
+    /**
+     * Executes a function when the zone is stable.
+     * @param {?} fn
+     * @return {?}
+     */
+    _executeOnStable(fn) {
+        if (this._ngZone.isStable) {
+            fn();
+        }
+        else {
+            first.call(this._ngZone.onStable.asObservable()).subscribe(fn);
+        }
+    }
+}
+/**
+ * Factory that allows easy instantiation of focus traps.
+ */
+class FocusTrapFactory {
+    /**
+     * @param {?} _checker
+     * @param {?} _platform
+     * @param {?} _ngZone
+     */
+    constructor(_checker, _platform, _ngZone) {
+        this._checker = _checker;
+        this._platform = _platform;
+        this._ngZone = _ngZone;
+    }
+    /**
+     * @param {?} element
+     * @param {?=} deferAnchors
+     * @return {?}
+     */
+    create(element, deferAnchors = false) {
+        return new FocusTrap(element, this._platform, this._checker, this._ngZone, deferAnchors);
+    }
+}
+FocusTrapFactory.decorators = [
+    { type: Injectable },
+];
+/**
+ * @nocollapse
+ */
+FocusTrapFactory.ctorParameters = () => [
+    { type: InteractivityChecker, },
+    { type: Platform, },
+    { type: NgZone, },
+];
+/**
+ * Directive for trapping focus within a region.
+ * @deprecated
+ */
+class FocusTrapDeprecatedDirective {
+    /**
+     * @param {?} _elementRef
+     * @param {?} _focusTrapFactory
+     */
+    constructor(_elementRef, _focusTrapFactory) {
+        this._elementRef = _elementRef;
+        this._focusTrapFactory = _focusTrapFactory;
+        this.focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement, true);
+    }
+    /**
+     * Whether the focus trap is active.
+     * @return {?}
+     */
+    get disabled() { return !this.focusTrap.enabled; }
+    /**
+     * @param {?} val
+     * @return {?}
+     */
+    set disabled(val) {
+        this.focusTrap.enabled = !coerceBooleanProperty(val);
+    }
+    /**
+     * @return {?}
+     */
+    ngOnDestroy() {
+        this.focusTrap.destroy();
+    }
+    /**
+     * @return {?}
+     */
+    ngAfterContentInit() {
+        this.focusTrap.attachAnchors();
+    }
+}
+FocusTrapDeprecatedDirective.decorators = [
+    { type: Directive, args: [{
+                selector: 'cdk-focus-trap',
+            },] },
+];
+/**
+ * @nocollapse
+ */
+FocusTrapDeprecatedDirective.ctorParameters = () => [
+    { type: ElementRef, },
+    { type: FocusTrapFactory, },
+];
+FocusTrapDeprecatedDirective.propDecorators = {
+    'disabled': [{ type: Input },],
+};
+/**
+ * Directive for trapping focus within a region.
+ */
+class FocusTrapDirective {
+    /**
+     * @param {?} _elementRef
+     * @param {?} _focusTrapFactory
+     */
+    constructor(_elementRef, _focusTrapFactory) {
+        this._elementRef = _elementRef;
+        this._focusTrapFactory = _focusTrapFactory;
+        this.focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement, true);
+    }
+    /**
+     * Whether the focus trap is active.
+     * @return {?}
+     */
+    get enabled() { return this.focusTrap.enabled; }
+    /**
+     * @param {?} value
+     * @return {?}
+     */
+    set enabled(value) { this.focusTrap.enabled = coerceBooleanProperty(value); }
+    /**
+     * @return {?}
+     */
+    ngOnDestroy() {
+        this.focusTrap.destroy();
+    }
+    /**
+     * @return {?}
+     */
+    ngAfterContentInit() {
+        this.focusTrap.attachAnchors();
+    }
+}
+FocusTrapDirective.decorators = [
+    { type: Directive, args: [{
+                selector: '[cdkTrapFocus]',
+                exportAs: 'cdkTrapFocus',
+            },] },
+];
+/**
+ * @nocollapse
+ */
+FocusTrapDirective.ctorParameters = () => [
+    { type: ElementRef, },
+    { type: FocusTrapFactory, },
+];
+FocusTrapDirective.propDecorators = {
+    'enabled': [{ type: Input, args: ['cdkTrapFocus',] },],
+};
+
+const LIVE_ANNOUNCER_ELEMENT_TOKEN = new InjectionToken('liveAnnouncerElement');
+class LiveAnnouncer {
+    /**
+     * @param {?} elementToken
+     * @param {?} platform
+     */
+    constructor(elementToken, platform) {
+        // Only do anything if we're on the browser platform.
+        if (platform.isBrowser) {
+            // We inject the live element as `any` because the constructor signature cannot reference
+            // browser globals (HTMLElement) on non-browser environments, since having a class decorator
+            // causes TypeScript to preserve the constructor signature types.
+            this._liveElement = elementToken || this._createLiveElement();
+        }
+    }
+    /**
+     * Announces a message to screenreaders.
+     * @param {?} message Message to be announced to the screenreader
+     * @param {?=} politeness The politeness of the announcer element
+     * @return {?}
+     */
+    announce(message, politeness = 'polite') {
+        this._liveElement.textContent = '';
+        // TODO: ensure changing the politeness works on all environments we support.
+        this._liveElement.setAttribute('aria-live', politeness);
+        // This 100ms timeout is necessary for some browser + screen-reader combinations:
+        // - Both JAWS and NVDA over IE11 will not announce anything without a non-zero timeout.
+        // - With Chrome and IE11 with NVDA or JAWS, a repeated (identical) message won't be read a
+        //   second time without clearing and then using a non-zero delay.
+        // (using JAWS 17 at time of this writing).
+        setTimeout(() => this._liveElement.textContent = message, 100);
+    }
+    /**
+     * @return {?}
+     */
+    ngOnDestroy() {
+        if (this._liveElement && this._liveElement.parentNode) {
+            this._liveElement.parentNode.removeChild(this._liveElement);
+        }
+    }
+    /**
+     * @return {?}
+     */
+    _createLiveElement() {
+        let /** @type {?} */ liveEl = document.createElement('div');
+        liveEl.classList.add('cdk-visually-hidden');
+        liveEl.setAttribute('aria-atomic', 'true');
+        liveEl.setAttribute('aria-live', 'polite');
+        document.body.appendChild(liveEl);
+        return liveEl;
+    }
+}
+LiveAnnouncer.decorators = [
+    { type: Injectable },
+];
+/**
+ * @nocollapse
+ */
+LiveAnnouncer.ctorParameters = () => [
+    { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [LIVE_ANNOUNCER_ELEMENT_TOKEN,] },] },
+    { type: Platform, },
+];
+/**
+ * \@docs-private
+ * @param {?} parentDispatcher
+ * @param {?} liveElement
+ * @param {?} platform
+ * @return {?}
+ */
+function LIVE_ANNOUNCER_PROVIDER_FACTORY(parentDispatcher, liveElement, platform) {
+    return parentDispatcher || new LiveAnnouncer(liveElement, platform);
+}
+/**
+ * \@docs-private
+ */
+const LIVE_ANNOUNCER_PROVIDER = {
+    // If there is already a LiveAnnouncer available, use that. Otherwise, provide a new one.
+    provide: LiveAnnouncer,
+    deps: [
+        [new Optional(), new SkipSelf(), LiveAnnouncer],
+        [new Optional(), new Inject(LIVE_ANNOUNCER_ELEMENT_TOKEN)],
+        Platform,
+    ],
+    useFactory: LIVE_ANNOUNCER_PROVIDER_FACTORY
+};
+
+// This is the value used by AngularJS Material. Through trial and error (on iPhone 6S) they found
+// that a value of around 650ms seems appropriate.
+const TOUCH_BUFFER_MS = 650;
+/**
+ * Monitors mouse and keyboard events to determine the cause of focus events.
+ */
+class FocusMonitor {
+    /**
+     * @param {?} _ngZone
+     * @param {?} _platform
+     */
+    constructor(_ngZone, _platform) {
+        this._ngZone = _ngZone;
+        this._platform = _platform;
+        /**
+         * The focus origin that the next focus event is a result of.
+         */
+        this._origin = null;
+        /**
+         * Whether the window has just been focused.
+         */
+        this._windowFocused = false;
+        /**
+         * Weak map of elements being monitored to their info.
+         */
+        this._elementInfo = new WeakMap();
+        this._ngZone.runOutsideAngular(() => this._registerDocumentEvents());
+    }
+    /**
+     * Monitors focus on an element and applies appropriate CSS classes.
+     * @param {?} element The element to monitor
+     * @param {?} renderer The renderer to use to apply CSS classes to the element.
+     * @param {?} checkChildren Whether to count the element as focused when its children are focused.
+     * @return {?} An observable that emits when the focus state of the element changes.
+     *     When the element is blurred, null will be emitted.
+     */
+    monitor(element, renderer, checkChildren) {
+        // Do nothing if we're not on the browser platform.
+        if (!this._platform.isBrowser) {
+            return of(null);
+        }
+        // Check if we're already monitoring this element.
+        if (this._elementInfo.has(element)) {
+            let /** @type {?} */ cachedInfo = this._elementInfo.get(element); /** @type {?} */
+            ((cachedInfo)).checkChildren = checkChildren;
+            return ((cachedInfo)).subject.asObservable();
+        }
+        // Create monitored element info.
+        let /** @type {?} */ info = {
+            unlisten: () => { },
+            checkChildren: checkChildren,
+            renderer: renderer,
+            subject: new Subject()
+        };
+        this._elementInfo.set(element, info);
+        // Start listening. We need to listen in capture phase since focus events don't bubble.
+        let /** @type {?} */ focusListener = (event) => this._onFocus(event, element);
+        let /** @type {?} */ blurListener = (event) => this._onBlur(event, element);
+        this._ngZone.runOutsideAngular(() => {
+            element.addEventListener('focus', focusListener, true);
+            element.addEventListener('blur', blurListener, true);
+        });
+        // Create an unlisten function for later.
+        info.unlisten = () => {
+            element.removeEventListener('focus', focusListener, true);
+            element.removeEventListener('blur', blurListener, true);
+        };
+        return info.subject.asObservable();
+    }
+    /**
+     * Stops monitoring an element and removes all focus classes.
+     * @param {?} element The element to stop monitoring.
+     * @return {?}
+     */
+    stopMonitoring(element) {
+        let /** @type {?} */ elementInfo = this._elementInfo.get(element);
+        if (elementInfo) {
+            elementInfo.unlisten();
+            elementInfo.subject.complete();
+            this._setClasses(element);
+            this._elementInfo.delete(element);
+        }
+    }
+    /**
+     * Focuses the element via the specified focus origin.
+     * @param {?} element The element to focus.
+     * @param {?} origin The focus origin.
+     * @return {?}
+     */
+    focusVia(element, origin) {
+        this._setOriginForCurrentEventQueue(origin);
+        element.focus();
+    }
+    /**
+     * Register necessary event listeners on the document and window.
+     * @return {?}
+     */
+    _registerDocumentEvents() {
+        // Do nothing if we're not on the browser platform.
+        if (!this._platform.isBrowser) {
+            return;
+        }
+        // Note: we listen to events in the capture phase so we can detect them even if the user stops
+        // propagation.
+        // On keydown record the origin and clear any touch event that may be in progress.
+        document.addEventListener('keydown', () => {
+            this._lastTouchTarget = null;
+            this._setOriginForCurrentEventQueue('keyboard');
+        }, true);
+        // On mousedown record the origin only if there is not touch target, since a mousedown can
+        // happen as a result of a touch event.
+        document.addEventListener('mousedown', () => {
+            if (!this._lastTouchTarget) {
+                this._setOriginForCurrentEventQueue('mouse');
+            }
+        }, true);
+        // When the touchstart event fires the focus event is not yet in the event queue. This means
+        // we can't rely on the trick used above (setting timeout of 0ms). Instead we wait 650ms to
+        // see if a focus happens.
+        document.addEventListener('touchstart', (event) => {
+            if (this._touchTimeout != null) {
+                clearTimeout(this._touchTimeout);
+            }
+            this._lastTouchTarget = event.target;
+            this._touchTimeout = setTimeout(() => this._lastTouchTarget = null, TOUCH_BUFFER_MS);
+        }, true);
+        // Make a note of when the window regains focus, so we can restore the origin info for the
+        // focused element.
+        window.addEventListener('focus', () => {
+            this._windowFocused = true;
+            setTimeout(() => this._windowFocused = false, 0);
+        });
+    }
+    /**
+     * Sets the focus classes on the element based on the given focus origin.
+     * @param {?} element The element to update the classes on.
+     * @param {?=} origin The focus origin.
+     * @return {?}
+     */
+    _setClasses(element, origin) {
+        const /** @type {?} */ elementInfo = this._elementInfo.get(element);
+        if (elementInfo) {
+            const /** @type {?} */ toggleClass = (className, shouldSet) => {
+                shouldSet ? elementInfo.renderer.addClass(element, className) :
+                    elementInfo.renderer.removeClass(element, className);
+            };
+            toggleClass('cdk-focused', !!origin);
+            toggleClass('cdk-touch-focused', origin === 'touch');
+            toggleClass('cdk-keyboard-focused', origin === 'keyboard');
+            toggleClass('cdk-mouse-focused', origin === 'mouse');
+            toggleClass('cdk-program-focused', origin === 'program');
+        }
+    }
+    /**
+     * Sets the origin and schedules an async function to clear it at the end of the event queue.
+     * @param {?} origin The origin to set.
+     * @return {?}
+     */
+    _setOriginForCurrentEventQueue(origin) {
+        this._origin = origin;
+        setTimeout(() => this._origin = null, 0);
+    }
+    /**
+     * Checks whether the given focus event was caused by a touchstart event.
+     * @param {?} event The focus event to check.
+     * @return {?} Whether the event was caused by a touch.
+     */
+    _wasCausedByTouch(event) {
+        // Note(mmalerba): This implementation is not quite perfect, there is a small edge case.
+        // Consider the following dom structure:
+        //
+        // <div #parent tabindex="0" cdkFocusClasses>
+        //   <div #child (click)="#parent.focus()"></div>
+        // </div>
+        //
+        // If the user touches the #child element and the #parent is programmatically focused as a
+        // result, this code will still consider it to have been caused by the touch event and will
+        // apply the cdk-touch-focused class rather than the cdk-program-focused class. This is a
+        // relatively small edge-case that can be worked around by using
+        // focusVia(parentEl, renderer,  'program') to focus the parent element.
+        //
+        // If we decide that we absolutely must handle this case correctly, we can do so by listening
+        // for the first focus event after the touchstart, and then the first blur event after that
+        // focus event. When that blur event fires we know that whatever follows is not a result of the
+        // touchstart.
+        let /** @type {?} */ focusTarget = event.target;
+        return this._lastTouchTarget instanceof Node && focusTarget instanceof Node &&
+            (focusTarget === this._lastTouchTarget || focusTarget.contains(this._lastTouchTarget));
+    }
+    /**
+     * Handles focus events on a registered element.
+     * @param {?} event The focus event.
+     * @param {?} element The monitored element.
+     * @return {?}
+     */
+    _onFocus(event, element) {
+        // NOTE(mmalerba): We currently set the classes based on the focus origin of the most recent
+        // focus event affecting the monitored element. If we want to use the origin of the first event
+        // instead we should check for the cdk-focused class here and return if the element already has
+        // it. (This only matters for elements that have includesChildren = true).
+        // If we are not counting child-element-focus as focused, make sure that the event target is the
+        // monitored element itself.
+        const /** @type {?} */ elementInfo = this._elementInfo.get(element);
+        if (!elementInfo || (!elementInfo.checkChildren && element !== event.target)) {
+            return;
+        }
+        // If we couldn't detect a cause for the focus event, it's due to one of three reasons:
+        // 1) The window has just regained focus, in which case we want to restore the focused state of
+        //    the element from before the window blurred.
+        // 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
+        // 3) The element was programmatically focused, in which case we should mark the origin as
+        //    'program'.
+        if (!this._origin) {
+            if (this._windowFocused && this._lastFocusOrigin) {
+                this._origin = this._lastFocusOrigin;
+            }
+            else if (this._wasCausedByTouch(event)) {
+                this._origin = 'touch';
+            }
+            else {
+                this._origin = 'program';
+            }
+        }
+        this._setClasses(element, this._origin);
+        elementInfo.subject.next(this._origin);
+        this._lastFocusOrigin = this._origin;
+        this._origin = null;
+    }
+    /**
+     * Handles blur events on a registered element.
+     * @param {?} event The blur event.
+     * @param {?} element The monitored element.
+     * @return {?}
+     */
+    _onBlur(event, element) {
+        // If we are counting child-element-focus as focused, make sure that we aren't just blurring in
+        // order to focus another child of the monitored element.
+        const /** @type {?} */ elementInfo = this._elementInfo.get(element);
+        if (!elementInfo || (elementInfo.checkChildren && event.relatedTarget instanceof Node &&
+            element.contains(event.relatedTarget))) {
+            return;
+        }
+        this._setClasses(element);
+        elementInfo.subject.next(null);
+    }
+}
+FocusMonitor.decorators = [
+    { type: Injectable },
+];
+/**
+ * @nocollapse
+ */
+FocusMonitor.ctorParameters = () => [
+    { type: NgZone, },
+    { type: Platform, },
+];
+/**
+ * Directive that determines how a particular element was focused (via keyboard, mouse, touch, or
+ * programmatically) and adds corresponding classes to the element.
+ *
+ * There are two variants of this directive:
+ * 1) cdkMonitorElementFocus: does not consider an element to be focused if one of its children is
+ *    focused.
+ * 2) cdkMonitorSubtreeFocus: considers an element focused if it or any of its children are focused.
+ */
+class CdkMonitorFocus {
+    /**
+     * @param {?} _elementRef
+     * @param {?} _focusMonitor
+     * @param {?} renderer
+     */
+    constructor(_elementRef, _focusMonitor, renderer) {
+        this._elementRef = _elementRef;
+        this._focusMonitor = _focusMonitor;
+        this.cdkFocusChange = new EventEmitter();
+        this._monitorSubscription = this._focusMonitor.monitor(this._elementRef.nativeElement, renderer, this._elementRef.nativeElement.hasAttribute('cdkMonitorSubtreeFocus'))
+            .subscribe(origin => this.cdkFocusChange.emit(origin));
+    }
+    /**
+     * @return {?}
+     */
+    ngOnDestroy() {
+        this._focusMonitor.stopMonitoring(this._elementRef.nativeElement);
+        this._monitorSubscription.unsubscribe();
+    }
+}
+CdkMonitorFocus.decorators = [
+    { type: Directive, args: [{
+                selector: '[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]',
+            },] },
+];
+/**
+ * @nocollapse
+ */
+CdkMonitorFocus.ctorParameters = () => [
+    { type: ElementRef, },
+    { type: FocusMonitor, },
+    { type: Renderer2, },
+];
+CdkMonitorFocus.propDecorators = {
+    'cdkFocusChange': [{ type: Output },],
+};
+/**
+ * \@docs-private
+ * @param {?} parentDispatcher
+ * @param {?} ngZone
+ * @param {?} platform
+ * @return {?}
+ */
+function FOCUS_MONITOR_PROVIDER_FACTORY(parentDispatcher, ngZone, platform) {
+    return parentDispatcher || new FocusMonitor(ngZone, platform);
+}
+/**
+ * \@docs-private
+ */
+const FOCUS_MONITOR_PROVIDER = {
+    // If there is already a FocusMonitor available, use that. Otherwise, provide a new one.
+    provide: FocusMonitor,
+    deps: [[new Optional(), new SkipSelf(), FocusMonitor], NgZone, Platform],
+    useFactory: FOCUS_MONITOR_PROVIDER_FACTORY
+};
+
+class A11yModule {
+}
+A11yModule.decorators = [
+    { type: NgModule, args: [{
+                imports: [CommonModule, PlatformModule],
+                declarations: [FocusTrapDirective, FocusTrapDeprecatedDirective, CdkMonitorFocus],
+                exports: [FocusTrapDirective, FocusTrapDeprecatedDirective, CdkMonitorFocus],
+                providers: [
+                    InteractivityChecker,
+                    FocusTrapFactory,
+                    AriaDescriber,
+                    LIVE_ANNOUNCER_PROVIDER,
+                    ARIA_DESCRIBER_PROVIDER,
+                    FOCUS_MONITOR_PROVIDER,
+                ]
+            },] },
+];
+/**
+ * @nocollapse
+ */
+A11yModule.ctorParameters = () => [];
+
+/**
+ * Generated bundle index. Do not edit.
+ */
+
+export { ActiveDescendantKeyManager, MESSAGES_CONTAINER_ID, CDK_DESCRIBEDBY_ID_PREFIX, CDK_DESCRIBEDBY_HOST_ATTRIBUTE, AriaDescriber, ARIA_DESCRIBER_PROVIDER_FACTORY, ARIA_DESCRIBER_PROVIDER, isFakeMousedownFromScreenReader, FocusKeyManager, FocusTrap, FocusTrapFactory, FocusTrapDeprecatedDirective, FocusTrapDirective, InteractivityChecker, ListKeyManager, LIVE_ANNOUNCER_ELEMENT_TOKEN, LiveAnnouncer, LIVE_ANNOUNCER_PROVIDER_FACTORY, LIVE_ANNOUNCER_PROVIDER, TOUCH_BUFFER_MS, FocusMonitor, CdkMonitorFocus, FOCUS_MONITOR_PROVIDER_FACTORY, FOCUS_MONITOR_PROVIDER, A11yModule };
+//# sourceMappingURL=a11y.js.map