import { NgModule, ComponentFactoryResolver, Inject, Optional, Injector, APP_INITIALIZER } from '@angular/core';
import { CommonModule, DOCUMENT } from '@angular/common';
import { NzRootComponent } from './nz-root.component';
import { NzRootStyleComponent } from './nz-root-style.component';
import { NZ_ROOT_CONFIG, createNzRootInitializer } from './nz-root-config';
var NzRootModule = (function () {
    function NzRootModule(_document, injector, resolver) {
        var componentFactory = resolver.resolveComponentFactory(NzRootStyleComponent);
        var div = _document.createElement('div');
        this.styleHostComponent = componentFactory.create(injector, null, div);
    }
    NzRootModule.prototype.ngOnDestroy = function () {
        this.styleHostComponent.destroy();
    };
    return NzRootModule;
}());
export { NzRootModule };
NzRootModule.decorators = [
    { type: NgModule, args: [{
                exports: [NzRootComponent],
                declarations: [NzRootComponent, NzRootStyleComponent],
                imports: [CommonModule],
                entryComponents: [NzRootStyleComponent],
                providers: [
                    { provide: APP_INITIALIZER, multi: true, useFactory: createNzRootInitializer, deps: [DOCUMENT, [new Optional(), NZ_ROOT_CONFIG]] },
                ],
            },] },
];
/** @nocollapse */
NzRootModule.ctorParameters = function () { return [
    { type: Document, decorators: [{ type: Inject, args: [DOCUMENT,] },] },
    { type: Injector, },
    { type: ComponentFactoryResolver, },
]; };
