(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('ng-zorro-antd/core'), require('rxjs'), require('@angular/cdk/layout'), require('@angular/cdk/platform'), require('rxjs/operators')) :
    typeof define === 'function' && define.amd ? define('ng-zorro-antd/descriptions', ['exports', '@angular/common', '@angular/core', 'ng-zorro-antd/core', 'rxjs', '@angular/cdk/layout', '@angular/cdk/platform', 'rxjs/operators'], factory) :
    (global = global || self, factory((global['ng-zorro-antd'] = global['ng-zorro-antd'] || {}, global['ng-zorro-antd'].descriptions = {}), global.ng.common, global.ng.core, global['ng-zorro-antd'].core, global.rxjs, global.ng.cdk.layout, global.ng.cdk.platform, global.rxjs.operators));
}(this, function (exports, common, core, core$1, rxjs, layout, platform, operators) { 'use strict';

    /*! *****************************************************************************
    Copyright (c) Microsoft Corporation. All rights reserved.
    Licensed under the Apache License, Version 2.0 (the "License"); you may not use
    this file except in compliance with the License. You may obtain a copy of the
    License at http://www.apache.org/licenses/LICENSE-2.0

    THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
    WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
    MERCHANTABLITY OR NON-INFRINGEMENT.

    See the Apache Version 2.0 License for specific language governing permissions
    and limitations under the License.
    ***************************************************************************** */

    function __decorate(decorators, target, key, desc) {
        var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
        if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
        else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
        return c > 3 && r && Object.defineProperty(target, key, r), r;
    }

    function __metadata(metadataKey, metadataValue) {
        if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
    }

    function __read(o, n) {
        var m = typeof Symbol === "function" && o[Symbol.iterator];
        if (!m) return o;
        var i = m.call(o), r, ar = [], e;
        try {
            while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
        }
        catch (error) { e = { error: error }; }
        finally {
            try {
                if (r && !r.done && (m = i["return"])) m.call(i);
            }
            finally { if (e) throw e.error; }
        }
        return ar;
    }

    function __spread() {
        for (var ar = [], i = 0; i < arguments.length; i++)
            ar = ar.concat(__read(arguments[i]));
        return ar;
    }

    /**
     * @fileoverview added by tsickle
     * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
     */
    var NzDescriptionsItemComponent = /** @class */ (function () {
        function NzDescriptionsItemComponent() {
            this.nzSpan = 1;
            this.nzTitle = '';
            this.inputChange$ = new rxjs.Subject();
        }
        /**
         * @return {?}
         */
        NzDescriptionsItemComponent.prototype.ngOnChanges = /**
         * @return {?}
         */
        function () {
            this.inputChange$.next();
        };
        /**
         * @return {?}
         */
        NzDescriptionsItemComponent.prototype.ngOnDestroy = /**
         * @return {?}
         */
        function () {
            this.inputChange$.complete();
        };
        NzDescriptionsItemComponent.decorators = [
            { type: core.Component, args: [{
                        changeDetection: core.ChangeDetectionStrategy.OnPush,
                        encapsulation: core.ViewEncapsulation.None,
                        selector: 'nz-descriptions-item',
                        template: "<!-- Use a template to wrap contents so contents wouldn't be displayed. -->\n<ng-template>\n  <ng-content></ng-content>\n</ng-template>\n",
                        exportAs: 'nzDescriptionsItem',
                        preserveWhitespaces: false
                    }] }
        ];
        NzDescriptionsItemComponent.propDecorators = {
            content: [{ type: core.ViewChild, args: [core.TemplateRef, { static: true },] }],
            nzSpan: [{ type: core.Input }],
            nzTitle: [{ type: core.Input }]
        };
        __decorate([
            core$1.InputNumber(),
            __metadata("design:type", Object)
        ], NzDescriptionsItemComponent.prototype, "nzSpan", void 0);
        return NzDescriptionsItemComponent;
    }());

    /**
     * @fileoverview added by tsickle
     * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
     */
    /** @type {?} */
    var defaultColumnMap = {
        xxl: 3,
        xl: 3,
        lg: 3,
        md: 3,
        sm: 2,
        xs: 1
    };
    var NzDescriptionsComponent = /** @class */ (function () {
        function NzDescriptionsComponent(cdr, mediaMatcher, platform, nzDomEventService) {
            this.cdr = cdr;
            this.mediaMatcher = mediaMatcher;
            this.platform = platform;
            this.nzDomEventService = nzDomEventService;
            this.nzBordered = false;
            this.nzLayout = 'horizontal';
            this.nzColumn = defaultColumnMap;
            this.nzSize = 'default';
            this.nzTitle = '';
            this.itemMatrix = [];
            this.realColumn = 3;
            this.destroy$ = new rxjs.Subject();
            this.resize$ = new rxjs.Subject();
        }
        /**
         * @param {?} changes
         * @return {?}
         */
        NzDescriptionsComponent.prototype.ngOnChanges = /**
         * @param {?} changes
         * @return {?}
         */
        function (changes) {
            if (changes.nzColumn) {
                this.resize$.next();
            }
        };
        /**
         * @return {?}
         */
        NzDescriptionsComponent.prototype.ngAfterContentInit = /**
         * @return {?}
         */
        function () {
            var _this = this;
            /** @type {?} */
            var contentChange$ = this.items.changes.pipe(operators.startWith(this.items), operators.takeUntil(this.destroy$));
            rxjs.merge(contentChange$, contentChange$.pipe(operators.switchMap((/**
             * @return {?}
             */
            function () { return rxjs.merge.apply(void 0, __spread(_this.items.map((/**
             * @param {?} i
             * @return {?}
             */
            function (i) { return i.inputChange$; })))).pipe(operators.auditTime(16)); }))), this.resize$)
                .pipe(operators.takeUntil(this.destroy$))
                .subscribe((/**
             * @return {?}
             */
            function () {
                _this.prepareMatrix();
                _this.cdr.markForCheck();
            }));
            if (this.platform.isBrowser) {
                this.nzDomEventService
                    .registerResizeListener()
                    .pipe(operators.takeUntil(this.destroy$), operators.finalize((/**
                 * @return {?}
                 */
                function () { return _this.nzDomEventService.unregisterResizeListener(); })))
                    .subscribe((/**
                 * @return {?}
                 */
                function () { return _this.resize$.next(); }));
            }
        };
        /**
         * @return {?}
         */
        NzDescriptionsComponent.prototype.ngOnDestroy = /**
         * @return {?}
         */
        function () {
            this.destroy$.next();
            this.destroy$.complete();
            this.resize$.complete();
        };
        /**
         * Prepare the render matrix according to description items' spans.
         */
        /**
         * Prepare the render matrix according to description items' spans.
         * @private
         * @return {?}
         */
        NzDescriptionsComponent.prototype.prepareMatrix = /**
         * Prepare the render matrix according to description items' spans.
         * @private
         * @return {?}
         */
        function () {
            /** @type {?} */
            var currentRow = [];
            /** @type {?} */
            var width = 0;
            /** @type {?} */
            var column = (this.realColumn = this.getColumn());
            /** @type {?} */
            var items = this.items.toArray();
            /** @type {?} */
            var length = items.length;
            /** @type {?} */
            var matrix = [];
            /** @type {?} */
            var flushRow = (/**
             * @return {?}
             */
            function () {
                matrix.push(currentRow);
                currentRow = [];
                width = 0;
            });
            for (var i = 0; i < length; i++) {
                /** @type {?} */
                var item = items[i];
                var title = item.nzTitle, content = item.content, span = item.nzSpan;
                width += span;
                // If the last item make the row's length exceeds `nzColumn`, the last
                // item should take all the space left. This logic is implemented in the template.
                // Warn user about that.
                if (width >= column) {
                    if (width > column) {
                        core$1.warn("\"nzColumn\" is " + column + " but we have row length " + width);
                    }
                    currentRow.push({ title: title, content: content, span: column - (width - span) });
                    flushRow();
                }
                else if (i === length - 1) {
                    currentRow.push({ title: title, content: content, span: column - (width - span) });
                    flushRow();
                }
                else {
                    currentRow.push({ title: title, content: content, span: span });
                }
            }
            this.itemMatrix = matrix;
        };
        /**
         * @private
         * @return {?}
         */
        NzDescriptionsComponent.prototype.matchMedia = /**
         * @private
         * @return {?}
         */
        function () {
            var _this = this;
            /** @type {?} */
            var bp = core$1.Breakpoint.md;
            Object.keys(core$1.responsiveMap).map((/**
             * @param {?} breakpoint
             * @return {?}
             */
            function (breakpoint) {
                /** @type {?} */
                var castBP = (/** @type {?} */ (breakpoint));
                /** @type {?} */
                var matchBelow = _this.mediaMatcher.matchMedia(core$1.responsiveMap[castBP]).matches;
                if (matchBelow) {
                    bp = castBP;
                }
            }));
            return bp;
        };
        /**
         * @private
         * @return {?}
         */
        NzDescriptionsComponent.prototype.getColumn = /**
         * @private
         * @return {?}
         */
        function () {
            if (typeof this.nzColumn !== 'number') {
                return this.nzColumn[this.matchMedia()];
            }
            return this.nzColumn;
        };
        NzDescriptionsComponent.decorators = [
            { type: core.Component, args: [{
                        changeDetection: core.ChangeDetectionStrategy.OnPush,
                        encapsulation: core.ViewEncapsulation.None,
                        selector: 'nz-descriptions',
                        template: "<div *ngIf=\"nzTitle\"\n     class=\"ant-descriptions-title\">\n  <ng-container *nzStringTemplateOutlet=\"nzTitle\">{{ nzTitle }}</ng-container>\n</div>\n<div class=\"ant-descriptions-view\">\n  <table>\n    <tbody>\n      <ng-container *ngIf=\"nzLayout === 'horizontal'\">\n        <tr class=\"ant-descriptions-row\" *ngFor=\"let row of itemMatrix; let i = index\">\n          <ng-container *ngFor=\"let item of row; let isLast = last\">\n            <!-- Horizontal & NOT Bordered -->\n            <ng-container *ngIf=\"!nzBordered\">\n              <td class=\"ant-descriptions-item\" [colSpan]=\"item.span\">\n                <span class=\"ant-descriptions-item-label\">{{ item.title }}</span>\n                <span class=\"ant-descriptions-item-content\">\n                  <ng-template [ngTemplateOutlet]=\"item.content\"></ng-template>\n                </span>\n              </td>\n            </ng-container>\n            <!-- Horizontal & Bordered -->\n            <ng-container *ngIf=\"nzBordered\">\n              <td class=\"ant-descriptions-item-label\" *nzStringTemplateOutlet=\"item.title\">{{ item.title }}</td>\n              <td class=\"ant-descriptions-item-content\" [colSpan]=\"isLast ? item.span * 2 - 1 : item.span\">\n                <ng-template [ngTemplateOutlet]=\"item.content\"></ng-template>\n              </td>\n            </ng-container>\n          </ng-container>\n        </tr>\n      </ng-container>\n\n      <ng-container *ngIf=\"nzLayout === 'vertical'\">\n        <!-- Vertical & NOT Bordered -->\n        <ng-container *ngIf=\"!nzBordered\">\n          <ng-container *ngFor=\"let row of itemMatrix; let i = index\">\n            <tr class=\"ant-descriptions-row\">\n              <ng-container *ngFor=\"let item of row; let isLast = last\">\n                <td class=\"ant-descriptions-item\" [colSpan]=\"item.span\">\n                  <span class=\"ant-descriptions-item-label\">{{ item.title }}</span>\n                </td>\n              </ng-container>\n            </tr>\n            <tr class=\"ant-descriptions-row\">\n              <ng-container *ngFor=\"let item of row; let isLast = last\">\n                <td class=\"ant-descriptions-item\" [colSpan]=\"item.span\">\n                  <span class=\"ant-descriptions-item-content\">\n                    <ng-template [ngTemplateOutlet]=\"item.content\"></ng-template>\n                  </span>\n                </td>\n              </ng-container>\n            </tr>\n          </ng-container>\n        </ng-container>\n        <!-- Vertical & Bordered -->\n        <ng-container *ngIf=\"nzBordered\">\n          <ng-container *ngFor=\"let row of itemMatrix; let i = index\">\n            <tr class=\"ant-descriptions-row\">\n              <ng-container *ngFor=\"let item of row; let isLast = last\">\n                <td class=\"ant-descriptions-item-label\" [colSpan]=\"item.span\">\n                  {{ item.title }}\n                </td>\n              </ng-container>\n            </tr>\n            <tr class=\"ant-descriptions-row\">\n              <ng-container *ngFor=\"let item of row; let isLast = last\">\n                <td class=\"ant-descriptions-item-content\" [colSpan]=\"item.span\">\n                  <ng-template [ngTemplateOutlet]=\"item.content\"></ng-template>\n                </td>\n              </ng-container>\n            </tr>\n          </ng-container>\n        </ng-container>\n      </ng-container>\n    </tbody>\n  </table>\n</div>\n",
                        exportAs: 'nzDescriptions',
                        preserveWhitespaces: false,
                        host: {
                            class: 'ant-descriptions',
                            '[class.ant-descriptions-bordered]': 'nzBordered',
                            '[class.ant-descriptions-middle]': 'nzSize === "middle"',
                            '[class.ant-descriptions-small]': 'nzSize === "small"'
                        },
                        styles: ["\n      nz-descriptions {\n        display: block;\n      }\n    "]
                    }] }
        ];
        /** @nocollapse */
        NzDescriptionsComponent.ctorParameters = function () { return [
            { type: core.ChangeDetectorRef },
            { type: layout.MediaMatcher },
            { type: platform.Platform },
            { type: core$1.NzDomEventService }
        ]; };
        NzDescriptionsComponent.propDecorators = {
            items: [{ type: core.ContentChildren, args: [NzDescriptionsItemComponent,] }],
            nzBordered: [{ type: core.Input }],
            nzLayout: [{ type: core.Input }],
            nzColumn: [{ type: core.Input }],
            nzSize: [{ type: core.Input }],
            nzTitle: [{ type: core.Input }]
        };
        __decorate([
            core$1.InputBoolean(),
            __metadata("design:type", Object)
        ], NzDescriptionsComponent.prototype, "nzBordered", void 0);
        return NzDescriptionsComponent;
    }());

    /**
     * @fileoverview added by tsickle
     * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
     */
    var NzDescriptionsModule = /** @class */ (function () {
        function NzDescriptionsModule() {
        }
        NzDescriptionsModule.decorators = [
            { type: core.NgModule, args: [{
                        imports: [common.CommonModule, core$1.NzAddOnModule],
                        declarations: [NzDescriptionsComponent, NzDescriptionsItemComponent],
                        exports: [NzDescriptionsComponent, NzDescriptionsItemComponent]
                    },] }
        ];
        return NzDescriptionsModule;
    }());

    exports.NzDescriptionsComponent = NzDescriptionsComponent;
    exports.NzDescriptionsItemComponent = NzDescriptionsItemComponent;
    exports.NzDescriptionsModule = NzDescriptionsModule;

    Object.defineProperty(exports, '__esModule', { value: true });

}));
//# sourceMappingURL=ng-zorro-antd-descriptions.umd.js.map
