(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/material/icon'), require('@angular/material/tooltip'), require('@angular/material/input'), require('@angular/material/form-field'), require('@sd-angular/core/translate'), require('@sd-angular/core/common'), require('rxjs'), require('rxjs/operators'), require('uuid'), require('ngx-device-detector'), require('object-hash'), require('@sd-angular/core/setting'), require('@sd-angular/core/form'), require('@angular/material/button')) :
    typeof define === 'function' && define.amd ? define('@sd-angular/core/filter', ['exports', '@angular/core', '@angular/common', '@angular/material/icon', '@angular/material/tooltip', '@angular/material/input', '@angular/material/form-field', '@sd-angular/core/translate', '@sd-angular/core/common', 'rxjs', 'rxjs/operators', 'uuid', 'ngx-device-detector', 'object-hash', '@sd-angular/core/setting', '@sd-angular/core/form', '@angular/material/button'], factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['sd-angular'] = global['sd-angular'] || {}, global['sd-angular'].core = global['sd-angular'].core || {}, global['sd-angular'].core.filter = {}), global.ng.core, global.ng.common, global.ng.material.icon, global.ng.material.tooltip, global.ng.material.input, global.ng.material.formField, global['sd-angular'].core.translate, global['sd-angular'].core.common, global.rxjs, global.rxjs.operators, global.uuid, global['ngx-device-detector'], global['object-hash'], global['sd-angular'].core.setting, global['sd-angular'].core.form, global.ng.material.button));
}(this, (function (exports, core, common, icon, tooltip, input, formField, translate, common$1, rxjs, operators, uuid, ngxDeviceDetector, hash, setting, form, button) { 'use strict';

    function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

    var hash__default = /*#__PURE__*/_interopDefaultLegacy(hash);

    var SdFilterDefDirective = /** @class */ (function () {
        function SdFilterDefDirective(templateRef) {
            this.templateRef = templateRef;
        }
        Object.defineProperty(SdFilterDefDirective.prototype, "_defaultShowing", {
            set: function (val) {
                this.defaultShowing = (val === '') || val;
            },
            enumerable: false,
            configurable: true
        });
        return SdFilterDefDirective;
    }());
    SdFilterDefDirective.decorators = [
        { type: core.Directive, args: [{
                    selector: '[sdFilterDef]'
                },] }
    ];
    SdFilterDefDirective.ctorParameters = function () { return [
        { type: core.TemplateRef }
    ]; };
    SdFilterDefDirective.propDecorators = {
        sdFilterDef: [{ type: core.Input }],
        _defaultShowing: [{ type: core.Input, args: ['defaultShowing',] }]
    };

    /*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */
    /* global Reflect, Promise */
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b)
                if (Object.prototype.hasOwnProperty.call(b, p))
                    d[p] = b[p]; };
        return extendStatics(d, b);
    };
    function __extends(d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    }
    var __assign = function () {
        __assign = Object.assign || function __assign(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s)
                    if (Object.prototype.hasOwnProperty.call(s, p))
                        t[p] = s[p];
            }
            return t;
        };
        return __assign.apply(this, arguments);
    };
    function __rest(s, e) {
        var t = {};
        for (var p in s)
            if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
                t[p] = s[p];
        if (s != null && typeof Object.getOwnPropertySymbols === "function")
            for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
                if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                    t[p[i]] = s[p[i]];
            }
        return t;
    }
    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 __param(paramIndex, decorator) {
        return function (target, key) { decorator(target, key, paramIndex); };
    }
    function __metadata(metadataKey, metadataValue) {
        if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
            return Reflect.metadata(metadataKey, metadataValue);
    }
    function __awaiter(thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try {
                step(generator.next(value));
            }
            catch (e) {
                reject(e);
            } }
            function rejected(value) { try {
                step(generator["throw"](value));
            }
            catch (e) {
                reject(e);
            } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    }
    function __generator(thisArg, body) {
        var _ = { label: 0, sent: function () { if (t[0] & 1)
                throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f)
                throw new TypeError("Generator is already executing.");
            while (_)
                try {
                    if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
                        return t;
                    if (y = 0, t)
                        op = [op[0] & 2, t.value];
                    switch (op[0]) {
                        case 0:
                        case 1:
                            t = op;
                            break;
                        case 4:
                            _.label++;
                            return { value: op[1], done: false };
                        case 5:
                            _.label++;
                            y = op[1];
                            op = [0];
                            continue;
                        case 7:
                            op = _.ops.pop();
                            _.trys.pop();
                            continue;
                        default:
                            if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
                                _ = 0;
                                continue;
                            }
                            if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
                                _.label = op[1];
                                break;
                            }
                            if (op[0] === 6 && _.label < t[1]) {
                                _.label = t[1];
                                t = op;
                                break;
                            }
                            if (t && _.label < t[2]) {
                                _.label = t[2];
                                _.ops.push(op);
                                break;
                            }
                            if (t[2])
                                _.ops.pop();
                            _.trys.pop();
                            continue;
                    }
                    op = body.call(thisArg, _);
                }
                catch (e) {
                    op = [6, e];
                    y = 0;
                }
                finally {
                    f = t = 0;
                }
            if (op[0] & 5)
                throw op[1];
            return { value: op[0] ? op[1] : void 0, done: true };
        }
    }
    var __createBinding = Object.create ? (function (o, m, k, k2) {
        if (k2 === undefined)
            k2 = k;
        Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
    }) : (function (o, m, k, k2) {
        if (k2 === undefined)
            k2 = k;
        o[k2] = m[k];
    });
    function __exportStar(m, o) {
        for (var p in m)
            if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
                __createBinding(o, m, p);
    }
    function __values(o) {
        var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
        if (m)
            return m.call(o);
        if (o && typeof o.length === "number")
            return {
                next: function () {
                    if (o && i >= o.length)
                        o = void 0;
                    return { value: o && o[i++], done: !o };
                }
            };
        throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
    }
    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;
    }
    /** @deprecated */
    function __spread() {
        for (var ar = [], i = 0; i < arguments.length; i++)
            ar = ar.concat(__read(arguments[i]));
        return ar;
    }
    /** @deprecated */
    function __spreadArrays() {
        for (var s = 0, i = 0, il = arguments.length; i < il; i++)
            s += arguments[i].length;
        for (var r = Array(s), k = 0, i = 0; i < il; i++)
            for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
                r[k] = a[j];
        return r;
    }
    function __spreadArray(to, from, pack) {
        if (pack || arguments.length === 2)
            for (var i = 0, l = from.length, ar; i < l; i++) {
                if (ar || !(i in from)) {
                    if (!ar)
                        ar = Array.prototype.slice.call(from, 0, i);
                    ar[i] = from[i];
                }
            }
        return to.concat(ar || Array.prototype.slice.call(from));
    }
    function __await(v) {
        return this instanceof __await ? (this.v = v, this) : new __await(v);
    }
    function __asyncGenerator(thisArg, _arguments, generator) {
        if (!Symbol.asyncIterator)
            throw new TypeError("Symbol.asyncIterator is not defined.");
        var g = generator.apply(thisArg, _arguments || []), i, q = [];
        return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
        function verb(n) { if (g[n])
            i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
        function resume(n, v) { try {
            step(g[n](v));
        }
        catch (e) {
            settle(q[0][3], e);
        } }
        function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
        function fulfill(value) { resume("next", value); }
        function reject(value) { resume("throw", value); }
        function settle(f, v) { if (f(v), q.shift(), q.length)
            resume(q[0][0], q[0][1]); }
    }
    function __asyncDelegator(o) {
        var i, p;
        return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
        function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
    }
    function __asyncValues(o) {
        if (!Symbol.asyncIterator)
            throw new TypeError("Symbol.asyncIterator is not defined.");
        var m = o[Symbol.asyncIterator], i;
        return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
        function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
        function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
    }
    function __makeTemplateObject(cooked, raw) {
        if (Object.defineProperty) {
            Object.defineProperty(cooked, "raw", { value: raw });
        }
        else {
            cooked.raw = raw;
        }
        return cooked;
    }
    ;
    var __setModuleDefault = Object.create ? (function (o, v) {
        Object.defineProperty(o, "default", { enumerable: true, value: v });
    }) : function (o, v) {
        o["default"] = v;
    };
    function __importStar(mod) {
        if (mod && mod.__esModule)
            return mod;
        var result = {};
        if (mod != null)
            for (var k in mod)
                if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
                    __createBinding(result, mod, k);
        __setModuleDefault(result, mod);
        return result;
    }
    function __importDefault(mod) {
        return (mod && mod.__esModule) ? mod : { default: mod };
    }
    function __classPrivateFieldGet(receiver, state, kind, f) {
        if (kind === "a" && !f)
            throw new TypeError("Private accessor was defined without a getter");
        if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
            throw new TypeError("Cannot read private member from an object whose class did not declare it");
        return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
    }
    function __classPrivateFieldSet(receiver, state, value, kind, f) {
        if (kind === "m")
            throw new TypeError("Private method is not writable");
        if (kind === "a" && !f)
            throw new TypeError("Private accessor was defined without a setter");
        if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
            throw new TypeError("Cannot write private member to an object whose class did not declare it");
        return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
    }

    var _prefix;
    var SdFilterService = /** @class */ (function () {
        function SdFilterService(settingService) {
            var _this = this;
            this.settingService = settingService;
            _prefix.set(this, '61d22e8e-eee8-4aad-8e1c-044a532fea91');
            this.get = function (key) { return __awaiter(_this, void 0, void 0, function () {
                var _a, get, configuration;
                return __generator(this, function (_c) {
                    switch (_c.label) {
                        case 0:
                            if (!key) {
                                return [2 /*return*/, {
                                        selectedQuickFilter: null,
                                        quickFilters: [],
                                        filter: {}
                                    }];
                            }
                            get = this.settingService.create({
                                prefix: __classPrivateFieldGet(this, _prefix),
                                key: key
                            }).get;
                            return [4 /*yield*/, get()];
                        case 1:
                            configuration = _c.sent();
                            return [2 /*return*/, {
                                    selectedQuickFilter: (_a = configuration === null || configuration === void 0 ? void 0 : configuration.selectedQuickFilter) !== null && _a !== void 0 ? _a : null,
                                    quickFilters: (configuration === null || configuration === void 0 ? void 0 : configuration.quickFilters) || [],
                                    filter: (configuration === null || configuration === void 0 ? void 0 : configuration.filter) || {}
                                }];
                    }
                });
            }); };
            this.set = function (key, configuration) { return __awaiter(_this, void 0, void 0, function () {
                var _b, set;
                return __generator(this, function (_c) {
                    switch (_c.label) {
                        case 0:
                            configuration = {
                                selectedQuickFilter: (_b = configuration === null || configuration === void 0 ? void 0 : configuration.selectedQuickFilter) !== null && _b !== void 0 ? _b : null,
                                quickFilters: (configuration === null || configuration === void 0 ? void 0 : configuration.quickFilters) || [],
                                filter: (configuration === null || configuration === void 0 ? void 0 : configuration.filter) || {}
                            };
                            if (!key) {
                                return [2 /*return*/, configuration];
                            }
                            set = this.settingService.create({
                                prefix: __classPrivateFieldGet(this, _prefix),
                                key: key
                            }).set;
                            key = hash__default['default']({
                                prefix: __classPrivateFieldGet(this, _prefix),
                                key: key
                            });
                            return [4 /*yield*/, set(configuration)];
                        case 1:
                            _c.sent();
                            return [2 /*return*/, configuration];
                    }
                });
            }); };
        }
        return SdFilterService;
    }());
    _prefix = new WeakMap();
    SdFilterService.decorators = [
        { type: core.Injectable }
    ];
    SdFilterService.ctorParameters = function () { return [
        { type: setting.SdSettingService }
    ]; };

    var _prefix$1, _filterOptionChanges, _subscription, _format, _firstLoad;
    var SdFilter = /** @class */ (function () {
        function SdFilter(deviceService, settingService, filterService) {
            var _this = this;
            this.deviceService = deviceService;
            this.settingService = settingService;
            this.filterService = filterService;
            _prefix$1.set(this, '61d22e8e-eee8-4aad-8e1c-044a532fea91');
            _filterOptionChanges.set(this, new rxjs.BehaviorSubject(null));
            _subscription.set(this, new rxjs.Subscription());
            this.sdFilterDefs = new core.QueryList();
            this.isMobileOrTablet = false;
            this.filterChanges = new rxjs.BehaviorSubject({});
            this.onFilter = function (filter) {
                _this.filterChanges.next({
                    filter: Object.assign({}, _this.information.filter),
                    filterDef: Object.assign({}, _this.information.filterDef),
                });
                _this.setting.set(_this.information);
            };
            this.onClear = function () {
                _this.information.filter = {};
                _this.information.filterDef = {};
                _this.onFilter();
            };
            _format.set(this, function (filters, information) {
                var e_1, _l;
                var _a, _b, _c, _d, _e;
                try {
                    for (var filters_1 = __values(filters), filters_1_1 = filters_1.next(); !filters_1_1.done; filters_1_1 = filters_1.next()) {
                        var filter = filters_1_1.value;
                        if (filter.type === 'daterange') {
                            information.filter[filter.field] = {
                                from: (_b = (_a = information.filter[filter.field]) === null || _a === void 0 ? void 0 : _a.from) !== null && _b !== void 0 ? _b : undefined,
                                to: (_d = (_c = information.filter[filter.field]) === null || _c === void 0 ? void 0 : _c.to) !== null && _d !== void 0 ? _d : undefined
                            };
                        }
                        else {
                            information.filter[filter.field] = (_e = information.filter[filter.field]) !== null && _e !== void 0 ? _e : undefined;
                        }
                    }
                }
                catch (e_1_1) { e_1 = { error: e_1_1 }; }
                finally {
                    try {
                        if (filters_1_1 && !filters_1_1.done && (_l = filters_1.return)) _l.call(filters_1);
                    }
                    finally { if (e_1) throw e_1.error; }
                }
            });
            _firstLoad.set(this, function (filters, information) {
                var e_2, _l;
                var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
                if (information.selectedQuickFilter && information.quickFilters.some(function (e) { return e.code === information.selectedQuickFilter; })) {
                    var selected = information.quickFilters.find(function (e) { return e.code === information.selectedQuickFilter; });
                    information.filter = Object.assign({}, selected.filter);
                    information.filterDef = Object.assign({}, selected.filterDef);
                    __classPrivateFieldGet(_this, _format).call(_this, filters, information);
                }
                else {
                    try {
                        for (var filters_2 = __values(filters), filters_2_1 = filters_2.next(); !filters_2_1.done; filters_2_1 = filters_2.next()) {
                            var filter = filters_2_1.value;
                            if (filter.type === 'daterange') {
                                information.filter[filter.field] = {
                                    from: (_d = (_b = (_a = information.filter[filter.field]) === null || _a === void 0 ? void 0 : _a.from) !== null && _b !== void 0 ? _b : (_c = filter.default) === null || _c === void 0 ? void 0 : _c.from) !== null && _d !== void 0 ? _d : undefined,
                                    to: (_h = (_f = (_e = information.filter[filter.field]) === null || _e === void 0 ? void 0 : _e.to) !== null && _f !== void 0 ? _f : (_g = filter.default) === null || _g === void 0 ? void 0 : _g.to) !== null && _h !== void 0 ? _h : undefined
                                };
                            }
                            else {
                                information.filter[filter.field] = (_k = (_j = information.filter[filter.field]) !== null && _j !== void 0 ? _j : filter.default) !== null && _k !== void 0 ? _k : undefined;
                            }
                        }
                    }
                    catch (e_2_1) { e_2 = { error: e_2_1 }; }
                    finally {
                        try {
                            if (filters_2_1 && !filters_2_1.done && (_l = filters_2.return)) _l.call(filters_2);
                        }
                        finally { if (e_2) throw e_2.error; }
                    }
                }
            });
            this.setFilter = function (args) {
                var filter = args.filter, filterDef = args.filterDef;
                _this.information = Object.assign(Object.assign({}, _this.information), { filter: Object.assign({}, filter), filterDef: Object.assign({}, filterDef) });
            };
            this.isMobileOrTablet = !this.deviceService.isDesktop();
        }
        Object.defineProperty(SdFilter.prototype, "_filterOption", {
            set: function (option) {
                console.log(option);
                if (option) {
                    this.filterOption = option;
                    __classPrivateFieldGet(this, _filterOptionChanges).next(option);
                }
            },
            enumerable: false,
            configurable: true
        });
        SdFilter.prototype.ngOnInit = function () {
            // if (!this.#key) {
            //   this.setting = this.settingService.create<SdFilterInformation>(uuid.v4(), {
            //     type: 'session',
            //     default: {
            //       filter: {},
            //       visible: {},
            //       quickFilters: [],
            //       selectedQuickFilter: null
            //     }
            //   });
            // } else {
            //   this.setting = this.settingService.create<SdFilterInformation>(this.#key, {
            //     default: {
            //       filter: {},
            //       visible: {},
            //       quickFilters: [],
            //       selectedQuickFilter: null
            //     }
            //   });
            // }
        };
        SdFilter.prototype.ngAfterViewInit = function () {
            var _this = this;
            __classPrivateFieldGet(this, _subscription).add(__classPrivateFieldGet(this, _filterOptionChanges).pipe(operators.startWith(this.filterOption)).subscribe(function (filterOption) {
                var _a, _b;
                console.log(filterOption);
                if (!filterOption) {
                    return;
                }
                var defaultInformation = {
                    filter: {},
                    visible: {},
                    quickFilters: ((_a = filterOption === null || filterOption === void 0 ? void 0 : filterOption.quickFilter) === null || _a === void 0 ? void 0 : _a.defaults) || [],
                    selectedQuickFilter: (_b = filterOption === null || filterOption === void 0 ? void 0 : filterOption.quickFilter) === null || _b === void 0 ? void 0 : _b.selectedDefault
                };
                if (!filterOption.key) {
                    _this.setting = _this.settingService.create(uuid.v4(), {
                        type: 'session',
                        default: defaultInformation
                    });
                }
                else {
                    _this.setting = _this.settingService.create({
                        prefix: __classPrivateFieldGet(_this, _prefix$1),
                        key: filterOption.key
                    }, {
                        default: defaultInformation
                    });
                }
                _this.information = _this.setting.get();
                console.log(_this.information);
                __classPrivateFieldGet(_this, _subscription).add(_this.setting.observer.subscribe(function (filterInformation) {
                    _this.information = filterInformation;
                    __classPrivateFieldGet(_this, _format).call(_this, filterOption === null || filterOption === void 0 ? void 0 : filterOption.filters, _this.information);
                }));
            }));
        };
        SdFilter.prototype.ngOnDestroy = function () {
            __classPrivateFieldGet(this, _subscription).unsubscribe();
        };
        return SdFilter;
    }());
    _prefix$1 = new WeakMap(), _filterOptionChanges = new WeakMap(), _subscription = new WeakMap(), _format = new WeakMap(), _firstLoad = new WeakMap();
    SdFilter.decorators = [
        { type: core.Component, args: [{
                    selector: 'sd-filter',
                    template: "<div *ngIf=\"information\" class=\"c-container\">\r\n  <div class=\"c-header\">\r\n    <div class=\"d-flex align-items-center\">\r\n      <button class=\"mx-2\" aria-hidden=\"true\" mat-icon-button>\r\n        <mat-icon class=\"c-icon\">filter_alt</mat-icon>\r\n      </button>\r\n      <span>Hi\u1EC3n th\u1ECB</span>\r\n    </div>\r\n    <div class=\"d-flex align-items-center\">\r\n      <button class=\"mx-2\" aria-hidden=\"true\" mat-icon-button>\r\n        <mat-icon class=\"c-icon\">add</mat-icon>\r\n      </button>\r\n      <button class=\"mx-2\" aria-hidden=\"true\" mat-icon-button>\r\n        <mat-icon class=\"c-icon\">settings</mat-icon>\r\n      </button>\r\n      <button class=\"mx-2\" aria-hidden=\"true\" mat-icon-button>\r\n        <mat-icon class=\"c-icon\">download</mat-icon>\r\n      </button>\r\n      <button class=\"mx-2\" aria-hidden=\"true\" mat-icon-button>\r\n        <mat-icon class=\"c-icon\">close</mat-icon>\r\n      </button>\r\n    </div>\r\n  </div>\r\n  <div class=\"c-body row mx-0\">\r\n    <ng-container *ngFor=\"let item of filterOption?.filters\">\r\n      <div *ngIf=\"information.visible[item.field] !== false\" class=\"col-lg-2 col-md-3 col-sm-6 px-8\">\r\n        <sd-input *ngIf=\"item.type === 'string'\" [label]=\"item.title\" type=\"text\"\r\n          [(model)]=\"information.filter[item.field]\" (keyupEnter)=\"onFilter(item)\">\r\n        </sd-input>\r\n        <sd-input-number *ngIf=\"item.type === 'number'\" [label]=\"item.title\" [(model)]=\"information.filter[item.field]\"\r\n          (keyupEnter)=\"onFilter(item)\">\r\n        </sd-input-number>\r\n        <sd-select *ngIf=\"item.type === 'bool'\" [label]=\"item.title\" [items]=\"[{value:true,display:item.option?.displayOnTrue || 'True' },\r\n          {value:false,display:item.option?.displayOnFalse || 'False' }]\" valueField=\"value\" displayField=\"display\"\r\n          [(model)]=\"information.filter[item.field]\" (sdChange)=\"onFilter(item)\">\r\n        </sd-select>\r\n        <ng-container *ngIf=\"item.type === 'values-local'\">\r\n          <sd-select *ngIf=\"item.option?.selection === 'MULTIPLE'\" [label]=\"item.title\"\r\n            [items]=\"item | sdValuesLocal | async\" [valueField]=\"item.option.valueField\"\r\n            [displayField]=\"item.option.displayField\" [(model)]=\"information.filter[item.field]\"\r\n            (sdChange)=\"onFilter(item)\" [selectAll]=\"item.option.selectAll\" multiple=\"true\">\r\n          </sd-select>\r\n          <sd-autocomplete *ngIf=\"item.option?.selection === 'AUTOCOMPLETE'\" [label]=\"item.title\"\r\n            [items]=\"item | sdValuesLocal | async\" [valueField]=\"item.option.valueField\"\r\n            [displayField]=\"item.option.displayField\" [(model)]=\"information.filter[item.field]\"\r\n            (sdChange)=\"onFilter(item)\">\r\n          </sd-autocomplete>\r\n          <sd-select *ngIf=\"item.option?.selection === 'MULTIPLEAUTOCOMPLETE'\" [label]=\"item.title\"\r\n            [items]=\"item | sdValuesLocal | async\" [valueField]=\"item.option.valueField\"\r\n            [displayField]=\"item.option.displayField\" [(model)]=\"information.filter[item.field]\"\r\n            (sdChange)=\"onFilter(item)\" filtered multiple>\r\n          </sd-select>\r\n          <sd-select *ngIf=\"!item.option?.selection\" [label]=\"item.title\" [items]=\"item | sdValuesLocal | async\"\r\n            [valueField]=\"item.option.valueField\" [displayField]=\"item.option.displayField\"\r\n            [(model)]=\"information.filter[item.field]\" (sdChange)=\"onFilter(item)\">\r\n          </sd-select>\r\n        </ng-container>\r\n        <ng-container *ngIf=\"item.type === 'values-server'\">\r\n          <sd-select *ngIf=\"item.option?.selection === 'MULTIPLE'\" [label]=\"item.title\"\r\n            [items]=\"item | sdValuesLocal | async\" [valueField]=\"item.option.valueField\"\r\n            [displayField]=\"item.option.displayField\" [(model)]=\"information.filter[item.field]\"\r\n            (sdChange)=\"onFilter(item)\" filtered multiple>\r\n          </sd-select>\r\n          <sd-autocomplete *ngIf=\"!item.option?.selection\" [label]=\"item.title\" [items]=\"item | sdValuesLocal | async\"\r\n            [valueField]=\"item.option.valueField\" [displayField]=\"item.option.displayField\"\r\n            [(model)]=\"information.filter[item.field]\" (sdChange)=\"onFilter(item)\">\r\n          </sd-autocomplete>\r\n        </ng-container>\r\n        <sd-date-time *ngIf=\"item.type ==='date' || item.type ==='datetime'\" [label]=\"item.title\"\r\n          [(model)]=\"information.filter[item.field]\" [type]=\"item.type\" [min]=\"item?.option?.min\"\r\n          [max]=\"item?.option?.max\" (sdChange)=\"onFilter(item)\">\r\n        </sd-date-time>\r\n        <sd-date-range *ngIf=\"item.type ==='daterange'\" [label]=\"item.title\"\r\n          [(from)]=\"information.filter[item.field].from\" [(to)]=\"information.filter[item.field].to\"\r\n          [min]=\"item?.option?.min\" [max]=\"item?.option?.max\" (sdChange)=\"onFilter(item)\">\r\n        </sd-date-range>\r\n      </div>\r\n    </ng-container>\r\n  </div>\r\n</div>\r\n<!-- <sd-popup-filter [columns]=\"columns\" [externalFilters]=\"externalFilters\" (changeFilter)=\"onChangeFilter($event)\"\r\n    (clearFilter)=\"onReset()\" [filterDefs]=\"filterDefs\">\r\n  </sd-popup-filter> -->",
                    styles: [".c-container .c-header{align-items:center;display:flex;height:48px;justify-content:space-between;padding:0 20px}.c-container mat-icon.c-icon{color:rgba(0,0,0,.54)!important}.c-container button:focus{outline:none}:host ::ng-deep .mat-form-field-wrapper{padding-bottom:0}"]
                },] }
    ];
    SdFilter.ctorParameters = function () { return [
        { type: ngxDeviceDetector.DeviceDetectorService },
        { type: setting.SdSettingService },
        { type: SdFilterService }
    ]; };
    SdFilter.propDecorators = {
        _filterOption: [{ type: core.Input, args: ['option',] }],
        sdFilterDefs: [{ type: core.ContentChildren, args: [SdFilterDefDirective,] }]
    };

    var SdValuesLocalPipe = /** @class */ (function () {
        function SdValuesLocalPipe() {
            var _this = this;
            this.transform = function (filterValues) { return __awaiter(_this, void 0, void 0, function () {
                var _a, _b, _c;
                return __generator(this, function (_d) {
                    switch (_d.label) {
                        case 0:
                            if (!(typeof ((_a = filterValues === null || filterValues === void 0 ? void 0 : filterValues.option) === null || _a === void 0 ? void 0 : _a.items) === 'function')) return [3 /*break*/, 2];
                            return [4 /*yield*/, ((_b = filterValues === null || filterValues === void 0 ? void 0 : filterValues.option) === null || _b === void 0 ? void 0 : _b.items())];
                        case 1: return [2 /*return*/, _d.sent()];
                        case 2: return [2 /*return*/, ((_c = filterValues === null || filterValues === void 0 ? void 0 : filterValues.option) === null || _c === void 0 ? void 0 : _c.items) || []];
                    }
                });
            }); };
        }
        return SdValuesLocalPipe;
    }());
    SdValuesLocalPipe.decorators = [
        { type: core.Pipe, args: [{
                    name: 'sdValuesLocal'
                },] }
    ];

    var SdValuesServerPipe = /** @class */ (function () {
        function SdValuesServerPipe() {
            this.transform = function (filterValues) {
                var _a, _b, _c;
                if (typeof ((_a = filterValues === null || filterValues === void 0 ? void 0 : filterValues.option) === null || _a === void 0 ? void 0 : _a.items) === 'function') {
                    return (_b = filterValues === null || filterValues === void 0 ? void 0 : filterValues.option) === null || _b === void 0 ? void 0 : _b.items;
                }
                return ((_c = filterValues === null || filterValues === void 0 ? void 0 : filterValues.option) === null || _c === void 0 ? void 0 : _c.items) || [];
            };
        }
        return SdValuesServerPipe;
    }());
    SdValuesServerPipe.decorators = [
        { type: core.Pipe, args: [{
                    name: 'sdValuesServer'
                },] }
    ];

    var SdFilterModule = /** @class */ (function () {
        function SdFilterModule() {
        }
        return SdFilterModule;
    }());
    SdFilterModule.decorators = [
        { type: core.NgModule, args: [{
                    imports: [
                        common.CommonModule,
                        formField.MatFormFieldModule,
                        input.MatInputModule,
                        icon.MatIconModule,
                        tooltip.MatTooltipModule,
                        button.MatButtonModule,
                        translate.SdTranslateModule,
                        common$1.SdCommonModule,
                        form.SdFormModule
                    ],
                    declarations: [
                        SdFilter,
                        SdFilterDefDirective,
                        SdValuesLocalPipe,
                        SdValuesServerPipe
                    ],
                    providers: [
                        SdFilterService
                    ],
                    exports: [
                        common$1.SdCommonModule,
                        SdFilterDefDirective,
                        SdFilter
                    ]
                },] }
    ];

    /*
     * Public API Surface of superdev-angular-core
     */

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

    exports.SdFilter = SdFilter;
    exports.SdFilterDefDirective = SdFilterDefDirective;
    exports.SdFilterModule = SdFilterModule;
    exports.ɵa = SdFilterService;
    exports.ɵb = SdValuesLocalPipe;
    exports.ɵc = SdValuesServerPipe;

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

})));
//# sourceMappingURL=sd-angular-core-filter.umd.js.map
