import { __require as y } from "./MediaQuery.js";
import { __require as m } from "./Util.js";
var c, h;
function w() {
  if (h) return c;
  h = 1;
  var o = y(), t = m(), f = t.each, n = t.isFunction, d = t.isArray;
  function u() {
    if (!window.matchMedia)
      throw new Error("matchMedia not present, legacy browsers require a polyfill");
    this.queries = {}, this.browserIsIncapable = !window.matchMedia("only all").matches;
  }
  return u.prototype = {
    constructor: u,
    /**
     * Registers a handler for the given media query
     *
     * @param {string} q the media query
     * @param {object || Array || Function} options either a single query handler object, a function, or an array of query handlers
     * @param {function} options.match fired when query matched
     * @param {function} [options.unmatch] fired when a query is no longer matched
     * @param {function} [options.setup] fired when handler first triggered
     * @param {boolean} [options.deferSetup=false] whether setup should be run immediately or deferred until query is first matched
     * @param {boolean} [shouldDegrade=false] whether this particular media query should always run on incapable browsers
     */
    register: function(r, e, i) {
      var s = this.queries, l = i && this.browserIsIncapable;
      return s[r] || (s[r] = new o(r, l)), n(e) && (e = { match: e }), d(e) || (e = [e]), f(e, function(a) {
        n(a) && (a = { match: a }), s[r].addHandler(a);
      }), this;
    },
    /**
     * unregisters a query and all it's handlers, or a specific handler for a query
     *
     * @param {string} q the media query to target
     * @param {object || function} [handler] specific handler to unregister
     */
    unregister: function(r, e) {
      var i = this.queries[r];
      return i && (e ? i.removeHandler(e) : (i.clear(), delete this.queries[r])), this;
    }
  }, c = u, c;
}
export {
  w as __require
};
//# sourceMappingURL=MediaQueryDispatch.js.map
