'use strict';

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

var vue = require('vue');

function offset(el) {
    if (el === window) {
        return { top: 0, left: 0 };
    }
    const { top, left } = el.getBoundingClientRect();
    return { top, left };
}
function style(el, property) {
    return window.getComputedStyle(el).getPropertyValue(property);
}
function height(el) {
    return el === window ? window.innerHeight : el.getBoundingClientRect().height;
}
function width(el) {
    return el === window ? window.innerWidth : el.getBoundingClientRect().width;
}
function css(element, css) {
    const style = element.style;
    Object.keys(css).forEach(prop => {
        style[prop] = css[prop];
    });
}
function cssBatch(elements, style) {
    elements.forEach(el => css(el, style));
}
function ready(fn) {
    if (typeof fn !== 'function') {
        return;
    }
    if (document.readyState !== 'loading') {
        return fn();
    }
    document.addEventListener('DOMContentLoaded', fn, false);
}
function getElement(el) {
    if (el === void 0 || el === null) {
        return void 0;
    }
    if (typeof el === 'string') {
        try {
            return document.querySelector(el) || void 0;
        }
        catch (err) {
            return void 0;
        }
    }
    const target = vue.isRef(el) === true ? el.value : el;
    if (target) {
        return target.$el || target;
    }
}
function childHasFocus(el, focusedEl) {
    if (el === void 0 || el.contains(focusedEl) === true) {
        return true;
    }
    for (let next = el.nextElementSibling; next !== null; next = next.nextElementSibling) {
        if (next.contains(focusedEl)) {
            return true;
        }
    }
    return false;
}
var dom = {
    offset,
    style,
    height,
    width,
    css,
    cssBatch,
    ready
};

exports.childHasFocus = childHasFocus;
exports.css = css;
exports.cssBatch = cssBatch;
exports.default = dom;
exports.getElement = getElement;
exports.height = height;
exports.offset = offset;
exports.ready = ready;
exports.style = style;
exports.width = width;
