{"version":3,"file":"observers.js","sources":["../../packages/cdk/observers/observe-content.js","../../packages/cdk/observers/index.js"],"sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport { Directive, ElementRef, NgModule, Output, Input, EventEmitter, Injectable, NgZone, } from '@angular/core';\nimport { Subject } from 'rxjs/Subject';\nimport { RxChain, debounceTime } from '@angular/cdk/rxjs';\n/**\n * Factory that creates a new MutationObserver and allows us to stub it out in unit tests.\n * \\@docs-private\n */\nexport class MatMutationObserverFactory {\n /**\n * @param {?} callback\n * @return {?}\n */\n create(callback) {\n return typeof MutationObserver === 'undefined' ? null : new MutationObserver(callback);\n }\n}\nMatMutationObserverFactory.decorators = [\n { type: Injectable },\n];\n/**\n * @nocollapse\n */\nMatMutationObserverFactory.ctorParameters = () => [];\nfunction MatMutationObserverFactory_tsickle_Closure_declarations() {\n /** @type {?} */\n MatMutationObserverFactory.decorators;\n /**\n * @nocollapse\n * @type {?}\n */\n MatMutationObserverFactory.ctorParameters;\n}\n/**\n * Directive that triggers a callback whenever the content of\n * its associated element has changed.\n */\nexport class ObserveContent {\n /**\n * @param {?} _mutationObserverFactory\n * @param {?} _elementRef\n * @param {?} _ngZone\n */\n constructor(_mutationObserverFactory, _elementRef, _ngZone) {\n this._mutationObserverFactory = _mutationObserverFactory;\n this._elementRef = _elementRef;\n this._ngZone = _ngZone;\n /**\n * Event emitted for each change in the element's content.\n */\n this.event = new EventEmitter();\n /**\n * Used for debouncing the emitted values to the observeContent event.\n */\n this._debouncer = new Subject();\n }\n /**\n * @return {?}\n */\n ngAfterContentInit() {\n if (this.debounce > 0) {\n this._ngZone.runOutsideAngular(() => {\n RxChain.from(this._debouncer)\n .call(debounceTime, this.debounce)\n .subscribe((mutations) => this.event.emit(mutations));\n });\n }\n else {\n this._debouncer.subscribe(mutations => this.event.emit(mutations));\n }\n this._observer = this._ngZone.runOutsideAngular(() => {\n return this._mutationObserverFactory.create((mutations) => {\n this._debouncer.next(mutations);\n });\n });\n if (this._observer) {\n this._observer.observe(this._elementRef.nativeElement, {\n characterData: true,\n childList: true,\n subtree: true\n });\n }\n }\n /**\n * @return {?}\n */\n ngOnDestroy() {\n if (this._observer) {\n this._observer.disconnect();\n }\n this._debouncer.complete();\n }\n}\nObserveContent.decorators = [\n { type: Directive, args: [{\n selector: '[cdkObserveContent]',\n exportAs: 'cdkObserveContent',\n },] },\n];\n/**\n * @nocollapse\n */\nObserveContent.ctorParameters = () => [\n { type: MatMutationObserverFactory, },\n { type: ElementRef, },\n { type: NgZone, },\n];\nObserveContent.propDecorators = {\n 'event': [{ type: Output, args: ['cdkObserveContent',] },],\n 'debounce': [{ type: Input },],\n};\nfunction ObserveContent_tsickle_Closure_declarations() {\n /** @type {?} */\n ObserveContent.decorators;\n /**\n * @nocollapse\n * @type {?}\n */\n ObserveContent.ctorParameters;\n /** @type {?} */\n ObserveContent.propDecorators;\n /** @type {?} */\n ObserveContent.prototype._observer;\n /**\n * Event emitted for each change in the element's content.\n * @type {?}\n */\n ObserveContent.prototype.event;\n /**\n * Used for debouncing the emitted values to the observeContent event.\n * @type {?}\n */\n ObserveContent.prototype._debouncer;\n /**\n * Debounce interval for emitting the changes.\n * @type {?}\n */\n ObserveContent.prototype.debounce;\n /** @type {?} */\n ObserveContent.prototype._mutationObserverFactory;\n /** @type {?} */\n ObserveContent.prototype._elementRef;\n /** @type {?} */\n ObserveContent.prototype._ngZone;\n}\nexport class ObserversModule {\n}\nObserversModule.decorators = [\n { type: NgModule, args: [{\n exports: [ObserveContent],\n declarations: [ObserveContent],\n providers: [MatMutationObserverFactory]\n },] },\n];\n/**\n * @nocollapse\n */\nObserversModule.ctorParameters = () => [];\nfunction ObserversModule_tsickle_Closure_declarations() {\n /** @type {?} */\n ObserversModule.decorators;\n /**\n * @nocollapse\n * @type {?}\n */\n ObserversModule.ctorParameters;\n}\n//# sourceMappingURL=observe-content.js.map","/**\n * Generated bundle index. Do not edit.\n */\nexport { MatMutationObserverFactory, ObserveContent, ObserversModule } from './public-api';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;;;;;;;AAUA;;;;AAIA,AAAO,MAAM,0BAA0B,CAAC;;;;;IAKpC,MAAM,CAAC,QAAQ,EAAE;QACb,OAAO,OAAO,gBAAgB,KAAK,WAAW,GAAG,IAAI,GAAG,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;KAC1F;CACJ;AACD,0BAA0B,CAAC,UAAU,GAAG;IACpC,EAAE,IAAI,EAAE,UAAU,EAAE;CACvB,CAAC;;;;AAIF,0BAA0B,CAAC,cAAc,GAAG,MAAM,EAAE,CAAC;AACrD,AASA;;;;AAIA,AAAO,MAAM,cAAc,CAAC;;;;;;IAMxB,WAAW,CAAC,wBAAwB,EAAE,WAAW,EAAE,OAAO,EAAE;QACxD,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;QACzD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;;;;QAIvB,IAAI,CAAC,KAAK,GAAG,IAAI,YAAY,EAAE,CAAC;;;;QAIhC,IAAI,CAAC,UAAU,GAAG,IAAI,OAAO,EAAE,CAAC;KACnC;;;;IAID,kBAAkB,GAAG;QACjB,IAAI,IAAI,CAAC,QAAQ,GAAG,CAAC,EAAE;YACnB,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM;gBACjC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;qBACxB,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC;qBACjC,SAAS,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;aAC7D,CAAC,CAAC;SACN;aACI;YACD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,IAAI,IAAI,CAAC,KAAK,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