 with CdkColumnResize.
     * When using this module, columns are not resizable by default.
     */
    var CdkColumnResizeModule = /** @class */ (function () {
        function CdkColumnResizeModule() {
        }
        CdkColumnResizeModule.decorators = [
            { type: core.NgModule, args: [{
                        declarations: [CdkColumnResize, CdkColumnResizeFlex],
                        exports: [CdkColumnResize, CdkColumnResizeFlex],
                    },] }
        ];
        return CdkColumnResizeModule;
    }());

    /**
     * @license
     * Copyright Google LLC 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
     */
    /**
     * Can be provided by the host application to enable persistence of column resize state.
     */
    var ColumnSizeStore = /** @class */ (function () {
        function ColumnSizeStore() {
        }
        ColumnSizeStore.decorators = [
            { type: core.Injectable }
        ];
        return ColumnSizeStore;
    }());

    /**
     * @license
     * Copyright Google LLC 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
     */
    /** Tracks state of resize events in progress. */
    var ResizeRef = /** @class */ (function () {
        function ResizeRef(origin, overlayRef, minWidthPx, maxWidthPx) {
            this.origin = origin;
            this.overlayRef = overlayRef;
            this.minWidthPx = minWidthPx;
            this.maxWidthPx = maxWidthPx;
        }
        return ResizeRef;
    }());

    /**
     * @license
     * Copyright Google LLC 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
     */
    var OVERLAY_ACTIVE_CLASS = 'cdk-resizable-overlay-thumb-active';
    /**
     * Base class for Resizable directives which are applied to column headers to make those columns
     * resizable.
     */
    var Resizable = /** @class */ (function () {
        function Resizable() {
            this.minWidthPxInternal = 0;
            this.maxWidthPxInternal = Number.MAX_SAFE_INTEGER;
            this.destroyed = new rxjs.ReplaySubject();
        }
        Object.defineProperty(Resizable.prototype, "minWidthPx", {
            /** The minimum width to allow the column to be sized to. */
            get: function () {
                return this.minWidthPxInternal;
            },
            set: function (value) {
                this.minWidthPxInternal = value;
                if (this.elementRef.nativeElement) {
                    this.columnResize.setResized();
                    this._applyMinWidthPx();
                }
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(Resizable.prototype, "maxWidthPx", {
            /** The maximum width to allow the column to be sized to. */
            get: function () {
                return this.maxWidthPxInternal;
            },
            set: function (value) {
                this.maxWidthPxInternal = value;
                if (this.elementRef.nativeElement) {
                    this.columnResize.setResized();
                    this._applyMaxWidthPx();
                }
            },
            enumerable: true,
            configurable: true
        });
        Resizable.prototype.ngAfterViewInit = function () {
            this._listenForRowHoverEvents();
            this._listenForResizeEvents();
            this._appendInlineHandle();
            this._applyMinWidthPx();
            this._applyMaxWidthPx();
        };
        Resizable.prototype.ngOnDestroy = function () {
            this.destroyed.next();
            this.destroyed.complete();
            if (this.inlineHandle) {
                this.elementRef.nativeElement.removeChild(this.inlineHandle);
            }
            if (this.overlayRef) {
                this.overlayRef.dispose();
            }
        };
        Resizable.prototype._createOverlayForHandle = function () {
            // Use of overlays allows us to properly capture click events spanning parts
            // of two table cells and is also useful for displaying a resize thumb
            // over both cells and extending it down the table as needed.
            var isRtl = this.directionality.value === 'rtl';
            var positionStrategy = this.overlay.position()
               .flexibleConnectedTo(this.elementRef.nativeElement)
               .withFlexibleDimensions(false)
               .withGrowAfterOpen(false)
               .withPush(false)
               .withDefaultOffsetX(isRtl? 1 : 0)
               .withPositions([{
                    originX: isRtl?'start' : 'end',
                    originY: 'top',
                    overlayX: 'center',
                    overlayY: 'top',
                }]);
            return this.overlay.create({
                // Always position the overlay based on left-indexed coordinates.
                direction: 'ltr',
                disposeOnNavigation: true,
                positionStrategy: positionStrategy,
                scrollStrategy: this.overlay.scrollStrategies.reposition(),
                width: '16px',
            });
        };
        Resizable.prototype._listenForRowHoverEvents = function () {
            var _this = this;
            var element = this.elementRef.nativeElement;
            var takeUntilDestroyed = operators.takeUntil(this.destroyed);
            this.eventDispatcher.resizeOverlayVisibleForHeaderRow(popoverEdit._closest(element, HEADER_ROW_SELECTOR))
               .pipe(takeUntilDestroyed).subscribe(function (hoveringRow) {
                if (hoveringRow) {
                    if (!_this.overlayRef) {
                        _this.overlayRef = _this._createOverlayForHandle();
                    }
                    _this._showHandleOverlay();
                }
                else if (_this.overlayRef) {
                    // todo - can't detach during an active resize - need to work that out
                    _this.overlayRef.detach();
                }
            });
        };
        Resizable.prototype._listenForResizeEvents = function () {
            var _this = this;
            var takeUntilDestroyed = operators.takeUntil(this.destroyed);
            rxjs.merge(this.resizeNotifier.resizeCanceled, this.resizeNotifier.triggerResize).pipe(takeUntilDestroyed, operators.filter(function (columnSize) { return columnSize.columnId === _this.columnDef.name; })).subscribe(function (_a) {
                var size = _a.size, previousSize = _a.previousSize, completeImmediately = _a.completeImmediately;
                _this.elementRef.nativeElement.classList.add(OVERLAY_ACTIVE_CLASS);
                _this._applySize(size, previousSize);
                if (completeImmediately) {
                    _this._completeResizeOperation();
                }
            });
            rxjs.merge(this.resizeNotifier.resizeCanceled, this.resizeNotifier.resizeCompleted).pipe(takeUntilDestroyed).subscribe(function (columnSize) {
                _this._cleanUpAfterResize(columnSize);
            });
        };
        Resizable.prototype._completeResizeOperation = function () {
            var _this = this;
            this.ngZone.run(function () {
                _this.resizeNotifier.resizeCompleted.next({
                    columnId: _this.columnDef.name,
                    size: _this.elementRef.nativeElement.offsetWidth,
                });
            });
        };
        Resizable.prototype._cleanUpAfterResize = function (columnSize) {
            this.elementRef.nativeElement.classList.remove(OVERLAY_ACTIVE_CLASS);
            if (this.overlayRef && this.overlayRef.hasAttached()) {
                this._updateOverlayHandleHeight();
                this.overlayRef.updatePosition();
                if (columnSize.columnId === this.columnDef.name) {
                    this.inlineHandle.focus();
                }
            }
        };
        Resizable.prototype._createHandlePortal = function () {