(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular-ru/cdk/coercion'), require('@angular-ru/cdk/utils')) :
    typeof define === 'function' && define.amd ? define('@angular-ru/cdk/decorators', ['exports', '@angular-ru/cdk/coercion', '@angular-ru/cdk/utils'], factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["angular-ru"] = global["angular-ru"] || {}, global["angular-ru"].cdk = global["angular-ru"].cdk || {}, global["angular-ru"].cdk.decorators = {}), global["angular-ru"].cdk.coercion, global["angular-ru"].cdk.utils));
})(this, (function (exports, coercion, utils) { 'use strict';

    function AttributeBoolean() {
        return function (prototype, key) {
            var descriptor = Object.getOwnPropertyDescriptor(prototype, key);
            var uniqueRefKey = Symbol("It's boolean attribute");
            return {
                set: function (value) {
                    var _a;
                    this[uniqueRefKey] = coercion.coerceBoolean(value);
                    (_a = descriptor === null || descriptor === void 0 ? void 0 : descriptor.set) === null || _a === void 0 ? void 0 : _a.call(this, this[uniqueRefKey]);
                },
                get: function () {
                    var _a;
                    // eslint-disable-next-line @typescript-eslint/unbound-method
                    return utils.isNotNil(descriptor === null || descriptor === void 0 ? void 0 : descriptor.get) ? descriptor === null || descriptor === void 0 ? void 0 : descriptor.get.call(this) : (_a = this[uniqueRefKey]) !== null && _a !== void 0 ? _a : false;
                }
            };
        };
    }

    /**
     * @internal
     */
    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type,max-lines-per-function
    function boundMethod(target, key, descriptor) {
        var fn = descriptor.value;
        if (typeof fn !== 'function') {
            throw new TypeError("@boundMethod decorator can only be applied to methods not: " + typeof fn);
        }
        // In IE11 calling Object.defineProperty has a side-effect of evaluating the
        // getter for the property which is being replaced. This causes infinite
        // recursion and an "Out of stack space" error.
        var definingProperty = false;
        return {
            configurable: true,
            // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
            get: function () {
                // eslint-disable-next-line no-prototype-builtins
                if (definingProperty || this === target.prototype || this.hasOwnProperty(key) || typeof fn !== 'function') {
                    return fn;
                }
                var boundFn = fn.bind(this);
                definingProperty = true;
                Object.defineProperty(this, key, {
                    configurable: true,
                    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
                    get: function () {
                        return boundFn;
                    },
                    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
                    set: function (value) {
                        fn = value;
                        delete this[key];
                    }
                });
                definingProperty = false;
                return boundFn;
            },
            // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
            set: function (value) {
                fn = value;
            }
        };
    }
    // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/explicit-function-return-type,max-lines-per-function
    function BoundClass(target) {
        // (Using reflect to get all keys including symbols)
        var keys;
        // Use Reflect if exists
        if (typeof Reflect !== 'undefined' && typeof Reflect.ownKeys === 'function') {
            keys = Reflect.ownKeys(target.prototype);
        }
        else {
            keys = Object.getOwnPropertyNames(target.prototype);
            // Use symbols if support is provided
            if (typeof Object.getOwnPropertySymbols === 'function') {
                keys = keys.concat(Object.getOwnPropertySymbols(target.prototype));
            }
        }
        keys.forEach(function (key) {
            // Ignore special case target method
            if (key === 'constructor') {
                return;
            }
            var descriptor = Object.getOwnPropertyDescriptor(target.prototype, key);
            // Only methods need binding
            if (typeof (descriptor === null || descriptor === void 0 ? void 0 : descriptor.value) === 'function') {
                Object.defineProperty(target.prototype, key, boundMethod(target, key, descriptor));
            }
        });
        return target;
    }

    /**
     * Generated bundle index. Do not edit.
     */

    exports.AttributeBoolean = AttributeBoolean;
    exports.BoundClass = BoundClass;

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

}));
//# sourceMappingURL=angular-ru-cdk-decorators.umd.js.map
