var __spreadArrays = (this && this.__spreadArrays) || function () {
    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;
};
export { U as UUID, c as colorShade, g as getColorShade, s as setColorShade } from './color-6a39339f.js';
export { F as FileManager } from './file-manager-bb650eef.js';
export { B as BceFile, m as modulo, r as ripple, t as throttle } from './throttle-b815ddf5.js';
export { d as debounce, i as isEmail, v as validator } from './validator-a488c5eb.js';
var ScrollSpy = /** @class */ (function () {
    function ScrollSpy(selector, options) {
        var _this = this;
        if (options === void 0) { options = {}; }
        this.current = null;
        this.nodes = [];
        this.offset = 0;
        this.timeout = 0;
        this.handleScroll = function () {
            if (_this.timeout)
                window.cancelAnimationFrame(_this.timeout);
            _this.timeout = window.requestAnimationFrame(function () { return _this.detect(); });
        };
        this.selector = selector;
        this.options = Object.assign({ class: 'active' }, options);
        this.reload();
        window.addEventListener('resize', this.handleScroll);
        window.addEventListener('scroll', this.handleScroll);
    }
    Object.defineProperty(ScrollSpy.prototype, "active", {
        get: function () {
            var last = this.nodes[this.nodes.length - 1];
            if (last && this.bottom && this.isVisible(last.section))
                return last;
            for (var i = this.nodes.length - 1; i >= 0; i--)
                if (this.isVisible(this.nodes[i].section))
                    return this.nodes[i];
            return null;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScrollSpy.prototype, "bottom", {
        get: function () {
            var r = this.root;
            return r.scrollHeight - window.innerHeight <= r.scrollTop;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScrollSpy.prototype, "root", {
        get: function () {
            return (document.scrollingElement || document.documentElement);
        },
        enumerable: true,
        configurable: true
    });
    ScrollSpy.prototype.destroy = function () {
        if (this.current)
            this.deactivate(this.current);
        window.removeEventListener('resize', this.handleScroll);
        window.removeEventListener('scroll', this.handleScroll);
    };
    ScrollSpy.prototype.detect = function () {
        var active = this.active;
        var current = this.current;
        if (current) {
            if (current === active)
                return;
            else
                this.deactivate(current);
        }
        if (active)
            this.activate(active);
        this.current = active;
    };
    ScrollSpy.prototype.reload = function () {
        var r = this.root;
        var elements = r.querySelectorAll(this.selector);
        this.nodes = Array.from(elements).reduce(function (acc, el) {
            var hash = 'hash' in el ? el.hash : '';
            var id = decodeURIComponent(hash.slice(1));
            var section = document.getElementById(id);
            return section ? __spreadArrays(acc, [{ nav: el, section: section }]) : acc;
        }, []);
        this.offset = Math.min.apply(Math, this.nodes.map(function (node) { return node.section.offsetTop; }));
        this.detect();
    };
    ScrollSpy.prototype.activate = function (node) {
        node.nav.classList.add(this.options.class);
    };
    ScrollSpy.prototype.deactivate = function (node) {
        node.nav.classList.remove(this.options.class);
    };
    ScrollSpy.prototype.isVisible = function (el, bottom) {
        var rect = el.getBoundingClientRect();
        return bottom ? rect.bottom < window.innerHeight : rect.top <= this.offset;
    };
    return ScrollSpy;
}());
export { ScrollSpy };
