"use strict";
exports.__esModule = true;
exports.Mq = void 0;
var tslib_1 = require("tslib");
// @ts-nocheck
var react_1 = (0, tslib_1.__importStar)(require("react"));
var useMatchMedia_1 = require("./useMatchMedia");
var utils_1 = require("./utils");
var IS_BROWSER = typeof window !== 'undefined';
var SUPPORTS_TOUCH = IS_BROWSER && ((0, utils_1.isPointerEventsSupported)() || (0, utils_1.isTouchSupported)());
var Mq = function (_a) {
    var children = _a.children, _b = _a.query, query = _b === void 0 ? '' : _b, touch = _a.touch, onMatchChange = _a.onMatchChange;
    var _c = (0, tslib_1.__read)((0, useMatchMedia_1.useMatchMedia)(query), 1), queryMatches = _c[0];
    var touchPass = touch === undefined ? true : touch === SUPPORTS_TOUCH;
    var matches = touchPass && (!query || queryMatches);
    (0, react_1.useEffect)(function () {
        if (onMatchChange) {
            onMatchChange(matches);
        }
    }, [matches, onMatchChange]);
    return react_1["default"].createElement(react_1.Fragment, null, matches && IS_BROWSER ? children : null);
};
exports.Mq = Mq;
