(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('@angular/core'), require('@angular/forms'), require('@angular/common')) :
    typeof define === 'function' && define.amd ? define('@sd-angular/core/common', ['exports', 'rxjs', '@angular/core', '@angular/forms', '@angular/common'], 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.common = {}), global.rxjs, global.ng.core, global.ng.forms, global.ng.common));
}(this, (function (exports, rxjs, i0, forms, common) { 'use strict';

    /*! *****************************************************************************
    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;
    }

    Array.prototype.search = function (searchText, fields) {
        var items = this;
        if (!(searchText === null || searchText === void 0 ? void 0 : searchText.toString())) {
            return items;
        }
        if (Array.isArray(fields)) {
            var fs_1 = fields.filter(function (e) { return e !== undefined && e !== null && e !== ''; });
            if (!fs_1.length) {
                return items.filter(function (item) { return item !== undefined && item !== null && String.aliasIncludes(item, searchText); });
            }
            return items.filter(function (item) { return item !== undefined && item !== null && fs_1.some(function (field) { return String.aliasIncludes(item[field], searchText); }); });
        }
        if (!fields) {
            return items.filter(function (item) { return item !== undefined && item !== null && String.aliasIncludes(item, searchText); });
        }
        return items.filter(function (item) { return item !== undefined && item !== null && String.aliasIncludes(item[fields], searchText); });
    };
    Array.prototype.paging = function (pageSize, page) {
        if (page === void 0) { page = 0; }
        var items = this;
        return items.filter(function (item, index) {
            return index >= page * pageSize
                && index < (page + 1) * pageSize;
        });
    };
    Array.prototype.toObject = function (key) {
        var items = this;
        if (!key) {
            return items.filter(function (item) { return item !== undefined && item !== null; }).reduce(function (obj, item) { obj[item === null || item === void 0 ? void 0 : item.toString()] = item; return obj; }, {});
        }
        return items.filter(function (item) { return item !== undefined && item !== null; }).reduce(function (obj, item) { var _a; obj[(_a = item[key]) === null || _a === void 0 ? void 0 : _a.toString()] = item; return obj; }, {});
    };
    Array.prototype.union = function (key) {
        var e_1, _b;
        var args = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            args[_i - 1] = arguments[_i];
        }
        var results = this;
        var filterUnion = function (val, index, self) { return val !== undefined && val !== null && self.findIndex(function (e) { return !!key ? e[key] === val[key] : e === val; }) === index; };
        if (!(args === null || args === void 0 ? void 0 : args.length)) {
            return results.filter(filterUnion);
        }
        try {
            for (var args_1 = __values(args), args_1_1 = args_1.next(); !args_1_1.done; args_1_1 = args_1.next()) {
                var arg = args_1_1.value;
                if (Array.isArray(arg)) {
                    results = __spread(results, arg).filter(filterUnion);
                }
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (args_1_1 && !args_1_1.done && (_b = args_1.return)) _b.call(args_1);
            }
            finally { if (e_1) throw e_1.error; }
        }
        return results;
    };
    Array.prototype.asObservable = function () {
        var items = this;
        return rxjs.of(items);
    };
    Array.search = function (items, searchText, fields) {
        if (!Array.isArray(items)) {
            return [];
        }
        return items.search(searchText, fields);
    };
    Array.union = function (key) {
        var args = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            args[_i - 1] = arguments[_i];
        }
        return [].union.apply([], __spread([key], args));
    };
    Array.toObject = function (items, key) {
        if (!Array.isArray(items)) {
            return {};
        }
        return items.toObject(key);
    };

    Date.equal = function (date1, date2) {
        if (!Date.isDate(date1) && !Date.isDate(date2)) {
            return true;
        }
        if (!Date.isDate(date1) || !Date.isDate(date2)) {
            return false;
        }
        return new Date(date1).getTime() === new Date(date2).getTime();
    };
    Date.parseFrom = function (value, format) {
        if (!value) {
            return null;
        }
        if (!format) {
            return null;
        }
        value = value.toString();
        var dmy = format.indexOf('dd') > -1 && format.indexOf('MM') > -1 && format.indexOf('yyyy') > -1;
        var hms = format.indexOf('HH') > -1 || format.indexOf('mm') > -1 || format.indexOf('ss') > -1;
        var strDate = '';
        if (dmy) {
            var dd = value.substr(format.indexOf('dd'), 'dd'.length);
            var MM = value.substr(format.indexOf('MM'), 'MM'.length);
            var yyyy = value.substr(format.indexOf('yyyy'), 'yyyy'.length);
            if (+yyyy > 0 && +MM > 0 && +dd > 0) {
                strDate += MM + "/" + dd + "/" + yyyy;
            }
            else {
                return null;
            }
        }
        else {
            var today = new Date();
            var yyyy = today.getFullYear().toString();
            var MM = (today.getMonth() + 1).toString().padStart(2, '0');
            var dd = today.getDate().toString().padStart(2, '0');
            strDate += MM + "/" + dd + "/" + yyyy;
        }
        if (hms) {
            var HH = format.indexOf('HH') > -1 ? value.substr(format.indexOf('HH'), 'HH'.length) : '00';
            var mm = format.indexOf('mm') > -1 ? value.substr(format.indexOf('mm'), 'mm'.length) : '00';
            var ss = format.indexOf('ss') > -1 ? value.substr(format.indexOf('ss'), 'ss'.length) : '00';
            strDate += " " + (HH || '00') + ":" + (mm || '00') + ":" + (ss || '00');
        }
        if (!Date.isDate(strDate)) {
            return null;
        }
        return new Date(strDate);
    };
    Date.isDate = function (value) {
        if (!value) {
            return false;
        }
        var date = new Date(value);
        return !isNaN(date.getTime());
    };
    Date.toFormat = function (value, format) {
        if (!Date.isDate(value)) {
            return '';
        }
        var date = new Date(value);
        return date.toFormat(format);
    };
    Date.addMiliseconds = function (value, miliseconds) {
        if (!Date.isDate(value)) {
            return null;
        }
        var date = new Date(value);
        return date.addMiliseconds(miliseconds);
    };
    Date.addHours = function (value, hours) {
        if (!Date.isDate(value)) {
            return null;
        }
        var date = new Date(value);
        return date.addHours(hours);
    };
    Date.addDays = function (value, days) {
        if (!Date.isDate(value)) {
            return null;
        }
        var date = new Date(value);
        return date.addDays(days);
    };
    Date.addMonths = function (value, months) {
        if (!Date.isDate(value)) {
            return null;
        }
        var date = new Date(value);
        return date.addMonths(months);
    };
    Date.begin = function (value) {
        if (!Date.isDate(value)) {
            return null;
        }
        return new Date(Date.toFormat(value, 'MM/dd/yyyy'));
    };
    Date.end = function (value) {
        if (!Date.isDate(value)) {
            return null;
        }
        return new Date(value).addDays(1).begin().addMiliseconds(-1);
    };
    Date.diffDays = function (from, to) {
        if (!Date.isDate(from) || !Date.isDate(to)) {
            return undefined;
        }
        var diffTime = new Date(to).getTime() - new Date(from).getTime();
        var diffDays = Math.round((diffTime / (1000 * 60 * 60 * 24)) * 100) / 100;
        return diffDays;
    };
    Date.prototype.begin = function () {
        return new Date(this.toFormat('MM/dd/yyyy'));
    };
    Date.prototype.end = function () {
        var date = this;
        return date.addDays(1).begin().addMiliseconds(-1);
    };
    Date.prototype.addMiliseconds = function (miliseconds) {
        var date = this;
        date.setMilliseconds(date.getMilliseconds() + miliseconds);
        return date;
    };
    Date.prototype.addHours = function (hours) {
        var date = this;
        date.setHours(date.getHours() + hours);
        return date;
    };
    Date.prototype.addDays = function (days) {
        var date = this;
        date.setDate(date.getDate() + days);
        return date;
    };
    Date.prototype.addMonths = function (months) {
        var date = this;
        date.setMonth(date.getMonth() + months);
        return date;
    };
    Date.prototype.toFormat = function (format) {
        var date = this;
        var result = format;
        result = result.replace('yyyy', date.getFullYear().toString());
        result = result.replace('MM', (date.getMonth() + 1).toString().padStart(2, '0'));
        result = result.replace('dd', date.getDate().toString().padStart(2, '0'));
        result = result.replace('HH', date.getHours().toString().padStart(2, '0'));
        result = result.replace('mm', date.getMinutes().toString().padStart(2, '0'));
        result = result.replace('ss', date.getSeconds().toString().padStart(2, '0'));
        return result;
    };

    Number.toVNCurrency = function (value, digits) {
        value = (value !== null && value !== void 0 ? value : '').toString().replace(/,/g, '');
        if (!value) {
            return null;
        }
        var val = +value;
        if (!Number.isNaN(val)) {
            if (!digits && digits !== 0) {
                return val.toLocaleString('vi-VN', { maximumFractionDigits: 10 });
            }
            return val.toLocaleString('vi-VN', { maximumFractionDigits: digits });
        }
        return null;
    };
    Number.isPositiveInteger = function (value) {
        if (!value) {
            return false;
        }
        var regex = /^([0-9]*)$/;
        return regex.test(value) && +value > 0;
    };
    Number.isPositiveNumber = function (value) {
        if (!value) {
            return false;
        }
        var regex = /^([0-9]*)(\.[0-9]+$){0,1}$/;
        return regex.test(value) && +value > 0;
    };
    Number.isNumber = function (value) {
        if (value === undefined || value === null || value === '') {
            return false;
        }
        return !Number.isNaN(+value);
    };
    Number.round = function (value, digits) {
        digits = digits !== null && digits !== void 0 ? digits : 2;
        if (!Number.isNumber(value)) {
            return null;
        }
        var val = Math.pow(10, digits);
        return Math.round(value * val) / val;
    };

    String.isValidEmail = function (value) {
        if (!value) {
            return false;
        }
        var re = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
        return re.test(value);
    };
    String.isValidPhone = function (value) {
        if (!value) {
            return false;
        }
        var re = /^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*$/;
        return re.test(value);
    };
    String.isValidCode = function (value) {
        if (!value) {
            return false;
        }
        var re = /^[a-zA-Z0-9\@\_\-]{2,20}$/;
        return re.test(value);
    };
    String.isNullOrEmpty = function (value) {
        return value === undefined || value === null || value === '';
    };
    String.isNullOrWhiteSpace = function (value) {
        return value === undefined || value === null || typeof value !== 'string' || value.match(/^ *$/) !== null;
    };
    String.changeAliasLowerCase = function (alias) {
        var _a;
        var str = (_a = alias === null || alias === void 0 ? void 0 : alias.toString()) !== null && _a !== void 0 ? _a : '';
        str = str.toString().toLowerCase();
        str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, 'a');
        str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, 'e');
        str = str.replace(/ì|í|ị|ỉ|ĩ/g, 'i');
        str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, 'o');
        str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, 'u');
        str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, 'y');
        str = str.replace(/đ/g, 'd');
        str = str.replace(/!|@|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\;|\'|\"|\&|\#|\[|\]|~|\$|_|`|-|{|}|\||\\/g, ' ');
        str = str.replace(/ + /g, ' ');
        str = str.trim();
        return str;
    };
    String.aliasIncludes = function (alias, searchText) {
        return String.changeAliasLowerCase(alias).includes(String.changeAliasLowerCase(searchText));
    };
    String.format = function (template) {
        var arr = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            arr[_i - 1] = arguments[_i];
        }
        for (var i = 0; i < arr.length; i++) {
            var regexp = new RegExp("\\{" + i + "\\}", 'gi');
            template = template.replace(regexp, arr[i]);
        }
        return template;
    };
    String.templateToDisplay = function (template, entity) {
        var e_1, _b;
        if (!template) {
            return template;
        }
        var regex = /\$\{([A-Za-z._\-]*)\}/g;
        var matches = template.match(regex) || [];
        try {
            for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
                var match = matches_1_1.value;
                var key = match.slice(2, match.length - 1);
                if (key) {
                    template = template.replace(match, (entity === null || entity === void 0 ? void 0 : entity[key]) || '');
                }
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (matches_1_1 && !matches_1_1.done && (_b = matches_1.return)) _b.call(matches_1);
            }
            finally { if (e_1) throw e_1.error; }
        }
        return template;
    };
    var SALT = 'cb9f4b2a-d26c-4787-a66e-e7130ee00f95';
    String.encrypt = function (obj) {
        obj = JSON.stringify(obj).split('');
        for (var i = 0, l = obj.length; i < l; i++)
            if (obj[i] == '{')
                obj[i] = '}';
            else if (obj[i] == '}')
                obj[i] = '{';
        return encodeURI(SALT + obj.join(''));
    };
    String.decrypt = function (encripted) {
        encripted = decodeURI(encripted);
        if (SALT && encripted.indexOf(SALT) != 0)
            throw new Error('object cannot be decrypted');
        var strs = encripted.substring(SALT.length).split('');
        for (var i = 0, l = strs.length; i < l; i++)
            if (strs[i] == '{')
                strs[i] = '}';
            else if (encripted[i] == '}')
                strs[i] = '{';
        return JSON.parse(strs.join(''));
    };

    /**
     *
     * detectIncognito v1.3.0 - (c) 2022 Joe Rutkowski <Joe@dreggle.com> (https://github.com/Joe12387/detectIncognito)
     *
     **/
    var detectIncognito = function () {
        return new Promise(function (resolve, reject) {
            var browserName = 'Unknown';
            function __callback(isPrivate) {
                resolve({
                    isPrivate: isPrivate,
                    browserName: browserName,
                });
            }
            function identifyChromium() {
                var ua = navigator.userAgent;
                if (ua.match(/Chrome/)) {
                    if (navigator.brave !== undefined) {
                        return 'Brave';
                    }
                    else if (ua.match(/Edg/)) {
                        return 'Edge';
                    }
                    else if (ua.match(/OPR/)) {
                        return 'Opera';
                    }
                    return 'Chrome';
                }
                else {
                    return 'Chromium';
                }
            }
            function assertEvalToString(value) {
                return value === eval.toString().length;
            }
            function isSafari() {
                var v = navigator.vendor;
                return (v !== undefined && v.indexOf('Apple') === 0 && assertEvalToString(37));
            }
            function isChrome() {
                var v = navigator.vendor;
                return (v !== undefined && v.indexOf('Google') === 0 && assertEvalToString(33));
            }
            function isFirefox() {
                return (document.documentElement !== undefined &&
                    document.documentElement.style.MozAppearance !== undefined &&
                    assertEvalToString(37));
            }
            function isMSIE() {
                return (navigator.msSaveBlob !== undefined && assertEvalToString(39));
            }
            /**
             * Safari (Safari for iOS & macOS)
             **/
            function newSafariTest() {
                // tslint:disable-next-line:variable-name
                var tmp_name = String(Math.random());
                try {
                    var db = window.indexedDB.open(tmp_name, 1);
                    db.onupgradeneeded = function (i) {
                        var _a, _b;
                        // @ts-ignore
                        var res = (_a = i.target) === null || _a === void 0 ? void 0 : _a.result;
                        try {
                            res.createObjectStore('test', {
                                autoIncrement: true,
                            }).put(new Blob);
                            __callback(false);
                        }
                        catch (e) {
                            var message = e;
                            if (e instanceof Error) {
                                message = (_b = e.message) !== null && _b !== void 0 ? _b : e;
                            }
                            if (typeof message !== 'string') {
                                return __callback(false);
                            }
                            var matchesExpectedError = /BlobURLs are not yet supported/.test(message);
                            return __callback(matchesExpectedError);
                        }
                        finally {
                            res.close();
                            window.indexedDB.deleteDatabase(tmp_name);
                        }
                    };
                }
                catch (e) {
                    return __callback(false);
                }
            }
            function oldSafariTest() {
                var openDB = window.openDatabase;
                var storage = window.localStorage;
                try {
                    openDB(null, null, null, null);
                }
                catch (e) {
                    return __callback(true);
                }
                try {
                    storage.setItem('test', '1');
                    storage.removeItem('test');
                }
                catch (e) {
                    return __callback(true);
                }
                return __callback(false);
            }
            function safariPrivateTest() {
                if (navigator.maxTouchPoints !== undefined) {
                    newSafariTest();
                }
                else {
                    oldSafariTest();
                }
            }
            /**
             * Chrome
             **/
            function getQuotaLimit() {
                var w = window;
                if (w.performance !== undefined &&
                    w.performance.memory !== undefined &&
                    w.performance.memory.jsHeapSizeLimit !== undefined) {
                    return performance.memory.jsHeapSizeLimit;
                }
                return 1073741824;
            }
            // >= 76
            function storageQuotaChromePrivateTest() {
                navigator.webkitTemporaryStorage.queryUsageAndQuota(function (_, quota) {
                    var quotaInMib = Math.round(quota / (1024 * 1024));
                    var quotaLimitInMib = Math.round(getQuotaLimit() / (1024 * 1024)) * 2;
                    __callback(quotaInMib < quotaLimitInMib);
                }, function (e) {
                    reject(new Error('detectIncognito somehow failed to query storage quota: ' +
                        e.message));
                });
            }
            // 50 to 75
            function oldChromePrivateTest() {
                var fs = window.webkitRequestFileSystem;
                var success = function () {
                    __callback(false);
                };
                var error = function () {
                    __callback(true);
                };
                fs(0, 1, success, error);
            }
            function chromePrivateTest() {
                if (self.Promise !== undefined && self.Promise.allSettled !== undefined) {
                    storageQuotaChromePrivateTest();
                }
                else {
                    oldChromePrivateTest();
                }
            }
            /**
             * Firefox
             **/
            function firefoxPrivateTest() {
                __callback(navigator.serviceWorker === undefined);
            }
            /**
             * MSIE
             **/
            function msiePrivateTest() {
                __callback(window.indexedDB === undefined);
            }
            function main() {
                if (isSafari()) {
                    browserName = 'Safari';
                    safariPrivateTest();
                }
                else if (isChrome()) {
                    browserName = identifyChromium();
                    chromePrivateTest();
                }
                else if (isFirefox()) {
                    browserName = 'Firefox';
                    firefoxPrivateTest();
                }
                else if (isMSIE()) {
                    browserName = 'Internet Explorer';
                    msiePrivateTest();
                }
                else {
                    reject(new Error('detectIncognito cannot determine the browser'));
                }
            }
            main();
        });
    };

    var upload = function (option) {
        var uploadId = 'U1e09c1c0-b647-437e-995e-d7a1a1b60550';
        var promise = new Promise(function (resolve, reject) {
            var _a;
            var body = (_a = document.getElementsByTagName('body')) === null || _a === void 0 ? void 0 : _a[0];
            if (!body) {
                resolve(null);
                return;
            }
            var existedElement = document.getElementById(uploadId);
            if (existedElement) {
                existedElement.remove();
            }
            var element = document.createElement('input');
            element.setAttribute('id', uploadId);
            element.setAttribute('type', 'file');
            element.style.display = 'none';
            body.appendChild(element);
            element.addEventListener('change', function (evt) {
                var _a;
                try {
                    var target = evt.target;
                    var file = target.files.item(0);
                    if (file) {
                        var lastDot = file.name.lastIndexOf('.');
                        if (lastDot === -1) {
                            throw new Error("File kh\u00F4ng \u0111\u00FAng \u0111\u1ECBnh d\u1EA1ng");
                        }
                        var extension_1 = file.name.substring(lastDot + 1);
                        if (option) {
                            if (((_a = option.extensions) === null || _a === void 0 ? void 0 : _a.length) && !option.extensions.some(function (e) { return e.toUpperCase() === extension_1.toUpperCase(); })) {
                                throw new Error("File kh\u00F4ng \u0111\u00FAng \u0111\u1ECBnh d\u1EA1ng");
                            }
                            if (option.maxSizeInMb && option.maxSizeInMb > 0 && option.maxSizeInMb * 1024 * 1024 < file.size) {
                                var message = "[" + file.name + "] Dung l\u01B0\u1EE3ng t\u1ED1i \u0111a " + option.maxSizeInMb + " Mbs";
                                throw new Error(message);
                            }
                            if (option.validator && option.validator(file.name)) {
                                var message = option.validator(file.name);
                                throw new Error(message);
                            }
                        }
                        resolve(file);
                    }
                }
                catch (error) {
                    reject(error);
                }
            });
            element.click();
        });
        return promise;
    };
    var ɵ0 = upload;
    var generateFileName = function (fileName) {
        if (!fileName) {
            return "File_" + new Date().toFormat('yyyy_MM_dd_HH_mm');
        }
        var strs = fileName.split('.');
        if (strs.length > 1) {
            var ext = strs.splice(strs.length - 1, 1)[0];
            return strs.join('.') + "_" + new Date().toFormat('yyyy_MM_dd_HH_mm') + "." + ext;
        }
        return fileName + "_" + new Date().toFormat('yyyy_MM_dd_HH_mm');
    };
    var ɵ1 = generateFileName;
    var download = function (filePath, fileName) {
        var link = document.createElement('a');
        link.download = generateFileName(fileName);
        link.href = filePath;
        link.style.visibility = 'hidden';
        document.body.appendChild(link);
        link.click();
        link.remove();
    };
    var ɵ2 = download;
    var downloadBlob = function (blob, fileName) {
        try {
            var url = window.URL.createObjectURL(blob);
            var link = document.createElement('a');
            if (link.download !== undefined) { // feature detection
                link.download = generateFileName(fileName);
                link.href = url;
                link.style.visibility = 'hidden';
                document.body.appendChild(link);
                link.click();
                window.URL.revokeObjectURL(url);
                link.remove();
            }
        }
        catch (e) {
            console.error('BlobToSaveAs error', e);
        }
    };
    var ɵ3 = downloadBlob;
    var changeAliasLowerCase = function (alias) {
        var _a;
        var str = (_a = alias === null || alias === void 0 ? void 0 : alias.toString()) !== null && _a !== void 0 ? _a : '';
        str = str.toString().toLowerCase();
        str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, 'a');
        str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, 'e');
        str = str.replace(/ì|í|ị|ỉ|ĩ/g, 'i');
        str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, 'o');
        str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, 'u');
        str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, 'y');
        str = str.replace(/đ/g, 'd');
        str = str.replace(/!|@|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\;|\'|\"|\&|\#|\[|\]|~|\$|_|`|-|{|}|\||\\/g, ' ');
        str = str.replace(/ + /g, ' ');
        str = str.trim();
        return str;
    };
    var ɵ4 = changeAliasLowerCase;
    var copyToClipboard = function (text) {
        navigator.clipboard.writeText(text);
    };
    var ɵ5 = copyToClipboard;
    var allWithPaging = function (func, defaultPageSize) { return __awaiter(void 0, void 0, void 0, function () {
        var _a, pageSize, pageNumber, count, items, res;
        return __generator(this, function (_b) {
            switch (_b.label) {
                case 0:
                    pageSize = defaultPageSize || 1000;
                    pageNumber = 0;
                    count = 0;
                    items = [];
                    _b.label = 1;
                case 1:
                    if (!true) return [3 /*break*/, 3];
                    return [4 /*yield*/, func(pageSize, pageNumber)];
                case 2:
                    res = _b.sent();
                    if (Array(res === null || res === void 0 ? void 0 : res.items) && (res === null || res === void 0 ? void 0 : res.total) > 0) {
                        items = __spread(items, res.items);
                        count += res.items.length;
                        pageNumber++;
                        if (count >= res.total || !((_a = res.items) === null || _a === void 0 ? void 0 : _a.length)) {
                            return [2 /*return*/, items];
                        }
                    }
                    else {
                        return [2 /*return*/, []];
                    }
                    return [3 /*break*/, 1];
                case 3: return [2 /*return*/];
            }
        });
    }); };
    var ɵ6 = allWithPaging;
    var isPrivateMode = function () { return __awaiter(void 0, void 0, void 0, function () {
        var check;
        return __generator(this, function (_b) {
            switch (_b.label) {
                case 0: return [4 /*yield*/, detectIncognito()];
                case 1:
                    check = _b.sent();
                    return [2 /*return*/, check.isPrivate];
            }
        });
    }); };
    var ɵ7 = isPrivateMode;
    var SdUtility = {
        upload: upload,
        download: download,
        downloadBlob: downloadBlob,
        changeAliasLowerCase: changeAliasLowerCase,
        copyToClipboard: copyToClipboard,
        allWithPaging: allWithPaging,
        isPrivateMode: isPrivateMode,
    };
    globalThis.SdUtility = SdUtility;

    var FIREBASE_CONFIG = new i0.InjectionToken('sd.firebase.configuration');

    var FORM_CONFIG = new i0.InjectionToken('sd.form.configuration');

    var SdFormControl = /** @class */ (function (_super) {
        __extends(SdFormControl, _super);
        function SdFormControl(formState, validator, asyncValidator) {
            if (validator === void 0) { validator = null; }
            if (asyncValidator === void 0) { asyncValidator = null; }
            var _this = _super.call(this, formState, validator, asyncValidator) || this;
            _this.sdChanges = new rxjs.Subject();
            _this.untouchChanges = new rxjs.Subject();
            _this.touchChanges = new rxjs.Subject();
            _this.pristineChanges = new rxjs.Subject();
            return _this;
        }
        SdFormControl.prototype.markAsUntouched = function (_a) {
            var onlySelf = (_a === void 0 ? {} : _a).onlySelf;
            _super.prototype.markAsUntouched.call(this, { onlySelf: onlySelf });
            this.untouchChanges.next(true);
            this.sdChanges.next(true);
        };
        SdFormControl.prototype.markAsTouched = function (_a) {
            var onlySelf = (_a === void 0 ? {} : _a).onlySelf;
            _super.prototype.markAsTouched.call(this, { onlySelf: onlySelf });
            this.touchChanges.next(true);
            this.sdChanges.next(true);
        };
        SdFormControl.prototype.markAsPristine = function (opts) {
            _super.prototype.markAsPristine.call(this, opts);
            this.pristineChanges.next(true);
            this.sdChanges.next(true);
        };
        return SdFormControl;
    }(forms.FormControl));

    var _getBrowserNameAndVersion;
    var SdBrowserService = /** @class */ (function () {
        function SdBrowserService() {
            _getBrowserNameAndVersion.set(this, function () {
                var ua = navigator.userAgent;
                var M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
                var tem;
                if (/trident/i.test(M[1])) {
                    tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
                    return { name: 'IE', version: (tem[1] || '') };
                }
                if (M[1] === 'Chrome') {
                    tem = ua.match(/\bEdg\/(\d+)/);
                    if (tem != null) {
                        return { name: 'Edge(Chromium)', version: tem[1] };
                    }
                    tem = ua.match(/\bOPR\/(\d+)/);
                    if (tem != null) {
                        return { name: 'Opera', version: tem[1] };
                    }
                }
                M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
                tem = ua.match(/version\/(\d+)/i);
                if (tem != null) {
                    M.splice(1, 1, tem[1]);
                }
                return {
                    name: M[0],
                    version: M[1]
                };
            });
            var browserNameAndVersion = __classPrivateFieldGet(this, _getBrowserNameAndVersion).call(this);
            this.browerName = browserNameAndVersion.name;
            this.browserVersion = browserNameAndVersion.version;
        }
        Object.defineProperty(SdBrowserService.prototype, "isChrome", {
            get: function () { return this.browerName === 'Chrome'; },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(SdBrowserService.prototype, "isFirefox", {
            get: function () { return this.browerName === 'Firefox'; },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(SdBrowserService.prototype, "isSafari", {
            get: function () { return this.browerName === 'Safari'; },
            enumerable: false,
            configurable: true
        });
        return SdBrowserService;
    }());
    _getBrowserNameAndVersion = new WeakMap();
    SdBrowserService.ɵprov = i0.ɵɵdefineInjectable({ factory: function SdBrowserService_Factory() { return new SdBrowserService(); }, token: SdBrowserService, providedIn: "root" });
    SdBrowserService.decorators = [
        { type: i0.Injectable, args: [{
                    providedIn: 'root'
                },] }
    ];
    SdBrowserService.ctorParameters = function () { return []; };

    var SdViewDefDirective = /** @class */ (function () {
        // @Input() sdViewDef: string;
        function SdViewDefDirective(templateRef) {
            this.templateRef = templateRef;
        }
        return SdViewDefDirective;
    }());
    SdViewDefDirective.decorators = [
        { type: i0.Directive, args: [{
                    selector: '[sdViewDef]'
                },] }
    ];
    SdViewDefDirective.ctorParameters = function () { return [
        { type: i0.TemplateRef }
    ]; };

    var _updateView;
    var SdLetDirective = /** @class */ (function () {
        function SdLetDirective(vcRef, templateRef) {
            var _this = this;
            this.vcRef = vcRef;
            this.templateRef = templateRef;
            this.context = {};
            _updateView.set(this, function () {
                _this.vcRef.clear();
                _this.vcRef.createEmbeddedView(_this.templateRef, _this.context);
            });
        }
        Object.defineProperty(SdLetDirective.prototype, "sdLet", {
            set: function (context) {
                this.context.$implicit = this.context.sdLet = context;
                __classPrivateFieldGet(this, _updateView).call(this);
            },
            enumerable: false,
            configurable: true
        });
        return SdLetDirective;
    }());
    _updateView = new WeakMap();
    SdLetDirective.decorators = [
        { type: i0.Directive, args: [{
                    selector: '[sdLet]',
                },] }
    ];
    SdLetDirective.ctorParameters = function () { return [
        { type: i0.ViewContainerRef },
        { type: i0.TemplateRef }
    ]; };
    SdLetDirective.propDecorators = {
        sdLet: [{ type: i0.Input }]
    };

    var _overflow;
    var SdScrollDirective = /** @class */ (function () {
        function SdScrollDirective(elementRef, renderer, browserService) {
            var _this = this;
            this.elementRef = elementRef;
            this.renderer = renderer;
            this.browserService = browserService;
            _overflow.set(this, 'hidden');
            this.scrollTop = function () {
                setTimeout(function () {
                    var _a;
                    if ((_a = _this.elementRef) === null || _a === void 0 ? void 0 : _a.nativeElement) {
                        _this.elementRef.nativeElement.scrollTop = 0;
                    }
                }, 1);
            };
        }
        SdScrollDirective.prototype.onMouseOver = function () {
            __classPrivateFieldSet(this, _overflow, this.browserService.isFirefox ? 'auto' : 'overlay');
            this.renderer.setStyle(this.elementRef.nativeElement, 'overflow', __classPrivateFieldGet(this, _overflow));
        };
        SdScrollDirective.prototype.onMouseOut = function () {
            __classPrivateFieldSet(this, _overflow, 'hidden');
            this.renderer.setStyle(this.elementRef.nativeElement, 'overflow', __classPrivateFieldGet(this, _overflow));
        };
        SdScrollDirective.prototype.ngOnInit = function () {
            this.renderer.setStyle(this.elementRef.nativeElement, '-webkit-transform', 'translate3d(0, 0, 0)');
            this.renderer.setStyle(this.elementRef.nativeElement, 'overflow', __classPrivateFieldGet(this, _overflow));
        };
        return SdScrollDirective;
    }());
    _overflow = new WeakMap();
    SdScrollDirective.decorators = [
        { type: i0.Directive, args: [{
                    selector: "[sdScroll]",
                },] }
    ];
    SdScrollDirective.ctorParameters = function () { return [
        { type: i0.ElementRef },
        { type: i0.Renderer2 },
        { type: SdBrowserService }
    ]; };
    SdScrollDirective.propDecorators = {
        onMouseOver: [{ type: i0.HostListener, args: ['mouseover',] }],
        onMouseOut: [{ type: i0.HostListener, args: ['mouseout',] }]
    };

    var SdSuffixDirective = /** @class */ (function () {
        function SdSuffixDirective(templateRef) {
            this.templateRef = templateRef;
        }
        return SdSuffixDirective;
    }());
    SdSuffixDirective.decorators = [
        { type: i0.Directive, args: [{
                    selector: '[sdSuffix]'
                },] }
    ];
    SdSuffixDirective.ctorParameters = function () { return [
        { type: i0.TemplateRef }
    ]; };

    var SdLabelDefDirective = /** @class */ (function () {
        // @Input() sdLableDef: string;
        function SdLabelDefDirective(templateRef) {
            this.templateRef = templateRef;
        }
        return SdLabelDefDirective;
    }());
    SdLabelDefDirective.decorators = [
        { type: i0.Directive, args: [{
                    selector: '[sdLabelDef]'
                },] }
    ];
    SdLabelDefDirective.ctorParameters = function () { return [
        { type: i0.TemplateRef }
    ]; };

    var SdForDirective = /** @class */ (function () {
        function SdForDirective(templateRef, viewContainer, differs) {
            this.templateRef = templateRef;
            this.viewContainer = viewContainer;
            this.differs = differs;
            this.items = [];
            this.viewRefsMap = new Map();
            this.itemsAtOnce = 20;
            this.intervalLength = 50;
        }
        Object.defineProperty(SdForDirective.prototype, "ngxtForOf", {
            set: function (items) {
                this.items = items;
                if (items) {
                    this._diffrence = this.differs.find(items).create();
                }
                //Clear any existing items
                this.viewContainer.clear();
            },
            enumerable: false,
            configurable: true
        });
        SdForDirective.prototype.ngDoCheck = function () {
            var _this = this;
            if (this._diffrence) {
                var changes = this._diffrence.diff(this.items);
                if (changes) {
                    var itemsAdded_1 = [];
                    changes.forEachAddedItem(function (item) {
                        itemsAdded_1.push(item);
                    });
                    this.progressiveRender(itemsAdded_1);
                    changes.forEachRemovedItem(function (item) {
                        var mapView = _this.viewRefsMap.get(item.item);
                        var viewIndex = _this.viewContainer.indexOf(mapView);
                        _this.viewContainer.remove(viewIndex);
                        _this.viewRefsMap.delete(item.item);
                    });
                }
            }
        };
        SdForDirective.prototype.progressiveRender = function (items) {
            var _this = this;
            var interval;
            var start = 0;
            var end = start + this.itemsAtOnce;
            if (end > items.length) {
                end = items.length;
            }
            this.renderItems(items, start, end);
            interval = setInterval(function () {
                start = end;
                end = start + _this.itemsAtOnce;
                if (end > items.length) {
                    end = items.length;
                }
                _this.renderItems(items, start, end);
                if (start >= items.length) {
                    clearInterval(interval);
                }
            }, this.intervalLength);
        };
        SdForDirective.prototype.renderItems = function (items, start, end) {
            var _this = this;
            items.slice(start, end).forEach(function (item) {
                var embeddedView = _this.viewContainer.createEmbeddedView(_this.templateRef, {
                    $implicit: item.item
                }, item.currentIndex || 0);
                _this.viewRefsMap.set(item.item, embeddedView);
            });
        };
        return SdForDirective;
    }());
    SdForDirective.decorators = [
        { type: i0.Directive, args: [{
                    selector: '[sdFor]'
                },] }
    ];
    SdForDirective.ctorParameters = function () { return [
        { type: i0.TemplateRef },
        { type: i0.ViewContainerRef },
        { type: i0.IterableDiffers }
    ]; };
    SdForDirective.propDecorators = {
        ngxtForOf: [{ type: i0.Input, args: ['ngxtForOf',] }],
        itemsAtOnce: [{ type: i0.Input, args: ['ngxtForItemsAtOnce',] }],
        intervalLength: [{ type: i0.Input, args: ['ngxtForIntervalLength',] }]
    };

    // import './typings';
    var SdCommonModule = /** @class */ (function () {
        function SdCommonModule() {
        }
        return SdCommonModule;
    }());
    SdCommonModule.decorators = [
        { type: i0.NgModule, args: [{
                    imports: [
                        common.CommonModule
                    ],
                    declarations: [
                        SdForDirective,
                        SdViewDefDirective,
                        SdLetDirective,
                        SdScrollDirective,
                        SdSuffixDirective,
                        SdLabelDefDirective
                    ],
                    exports: [
                        SdForDirective,
                        SdViewDefDirective,
                        SdLetDirective,
                        SdScrollDirective,
                        SdSuffixDirective,
                        SdLabelDefDirective
                    ],
                    providers: []
                },] }
    ];

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

    exports.FIREBASE_CONFIG = FIREBASE_CONFIG;
    exports.FORM_CONFIG = FORM_CONFIG;
    exports.SdBrowserService = SdBrowserService;
    exports.SdCommonModule = SdCommonModule;
    exports.SdFormControl = SdFormControl;
    exports.SdLabelDefDirective = SdLabelDefDirective;
    exports.SdLetDirective = SdLetDirective;
    exports.SdScrollDirective = SdScrollDirective;
    exports.SdSuffixDirective = SdSuffixDirective;
    exports.SdViewDefDirective = SdViewDefDirective;
    exports.ɵa = SdForDirective;

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

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