{"ast":null,"code":"var QueryHandler = require('./QueryHandler');\nvar each = require('./Util').each;\n\n/**\n * Represents a single media query, manages it's state and registered handlers for this query\n *\n * @constructor\n * @param {string} query the media query string\n * @param {boolean} [isUnconditional=false] whether the media query should run regardless of whether the conditions are met. Primarily for helping older browsers deal with mobile-first design\n */\nfunction MediaQuery(query, isUnconditional) {\n  this.query = query;\n  this.isUnconditional = isUnconditional;\n  this.handlers = [];\n  this.mql = window.matchMedia(query);\n  var self = this;\n  this.listener = function (mql) {\n    // Chrome passes an MediaQueryListEvent object, while other browsers pass MediaQueryList directly\n    self.mql = mql.currentTarget || mql;\n    self.assess();\n  };\n  this.mql.addListener(this.listener);\n}\nMediaQuery.prototype = {\n  constuctor: MediaQuery,\n  /**\n   * add a handler for this query, triggering if already active\n   *\n   * @param {object} handler\n   * @param {function} handler.match callback for when query is activated\n   * @param {function} [handler.unmatch] callback for when query is deactivated\n   * @param {function} [handler.setup] callback for immediate execution when a query handler is registered\n   * @param {boolean} [handler.deferSetup=false] should the setup callback be deferred until the first time the handler is matched?\n   */\n  addHandler: function addHandler(handler) {\n    var qh = new QueryHandler(handler);\n    this.handlers.push(qh);\n    this.matches() && qh.on();\n  },\n  /**\n   * removes the given handler from the collection, and calls it's destroy methods\n   *\n   * @param {object || function} handler the handler to remove\n   */\n  removeHandler: function removeHandler(handler) {\n    var handlers = this.handlers;\n    each(handlers, function (h, i) {\n      if (h.equals(handler)) {\n        h.destroy();\n        return !handlers.splice(i, 1); //remove from array and exit each early\n      }\n    });\n  },\n\n  /**\n   * Determine whether the media query should be considered a match\n   *\n   * @return {Boolean} true if media query can be considered a match, false otherwise\n   */\n  matches: function matches() {\n    return this.mql.matches || this.isUnconditional;\n  },\n  /**\n   * Clears all handlers and unbinds events\n   */\n  clear: function clear() {\n    each(this.handlers, function (handler) {\n      handler.destroy();\n    });\n    this.mql.removeListener(this.listener);\n    this.handlers.length = 0; //clear array\n  },\n\n  /*\n      * Assesses the query, turning on all handlers if it matches, turning them off if it doesn't match\n      */\n  assess: function assess() {\n    var action = this.matches() ? 'on' : 'off';\n    each(this.handlers, function (handler) {\n      handler[action]();\n    });\n  }\n};\nmodule.exports = MediaQuery;","map":{"version":3,"names":["QueryHandler","require","each","MediaQuery","query","isUnconditional","handlers","mql","window","matchMedia","self","listener","currentTarget","assess","addListener","prototype","constuctor","addHandler","handler","qh","push","matches","on","removeHandler","h","i","equals","destroy","splice","clear","removeListener","length","action","module","exports"],"sources":["C:/Users/user/Desktop/portreact/node_modules/enquire.js/src/MediaQuery.js"],"sourcesContent":["var QueryHandler = require('./QueryHandler');\nvar each = require('./Util').each;\n\n/**\n * Represents a single media query, manages it's state and registered handlers for this query\n *\n * @constructor\n * @param {string} query the media query string\n * @param {boolean} [isUnconditional=false] whether the media query should run regardless of whether the conditions are met. Primarily for helping older browsers deal with mobile-first design\n */\nfunction MediaQuery(query, isUnconditional) {\n    this.query = query;\n    this.isUnconditional = isUnconditional;\n    this.handlers = [];\n    this.mql = window.matchMedia(query);\n\n    var self = this;\n    this.listener = function(mql) {\n        // Chrome passes an MediaQueryListEvent object, while other browsers pass MediaQueryList directly\n        self.mql = mql.currentTarget || mql;\n        self.assess();\n    };\n    this.mql.addListener(this.listener);\n}\n\nMediaQuery.prototype = {\n\n    constuctor : MediaQuery,\n\n    /**\n     * add a handler for this query, triggering if already active\n     *\n     * @param {object} handler\n     * @param {function} handler.match callback for when query is activated\n     * @param {function} [handler.unmatch] callback for when query is deactivated\n     * @param {function} [handler.setup] callback for immediate execution when a query handler is registered\n     * @param {boolean} [handler.deferSetup=false] should the setup callback be deferred until the first time the handler is matched?\n     */\n    addHandler : function(handler) {\n        var qh = new QueryHandler(handler);\n        this.handlers.push(qh);\n\n        this.matches() && qh.on();\n    },\n\n    /**\n     * removes the given handler from the collection, and calls it's destroy methods\n     *\n     * @param {object || function} handler the handler to remove\n     */\n    removeHandler : function(handler) {\n        var handlers = this.handlers;\n        each(handlers, function(h, i) {\n            if(h.equals(handler)) {\n                h.destroy();\n                return !handlers.splice(i,1); //remove from array and exit each early\n            }\n        });\n    },\n\n    /**\n     * Determine whether the media query should be considered a match\n     *\n     * @return {Boolean} true if media query can be considered a match, false otherwise\n     */\n    matches : function() {\n        return this.mql.matches || this.isUnconditional;\n    },\n\n    /**\n     * Clears all handlers and unbinds events\n     */\n    clear : function() {\n        each(this.handlers, function(handler) {\n            handler.destroy();\n        });\n        this.mql.removeListener(this.listener);\n        this.handlers.length = 0; //clear array\n    },\n\n    /*\n        * Assesses the query, turning on all handlers if it matches, turning them off if it doesn't match\n        */\n    assess : function() {\n        var action = this.matches() ? 'on' : 'off';\n\n        each(this.handlers, function(handler) {\n            handler[action]();\n        });\n    }\n};\n\nmodule.exports = MediaQuery;\n"],"mappings":"AAAA,IAAIA,YAAY,GAAGC,OAAO,CAAC,gBAAgB,CAAC;AAC5C,IAAIC,IAAI,GAAGD,OAAO,CAAC,QAAQ,CAAC,CAACC,IAAI;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAUA,CAACC,KAAK,EAAEC,eAAe,EAAE;EACxC,IAAI,CAACD,KAAK,GAAGA,KAAK;EAClB,IAAI,CAACC,eAAe,GAAGA,eAAe;EACtC,IAAI,CAACC,QAAQ,GAAG,EAAE;EAClB,IAAI,CAACC,GAAG,GAAGC,MAAM,CAACC,UAAU,CAACL,KAAK,CAAC;EAEnC,IAAIM,IAAI,GAAG,IAAI;EACf,IAAI,CAACC,QAAQ,GAAG,UAASJ,GAAG,EAAE;IAC1B;IACAG,IAAI,CAACH,GAAG,GAAGA,GAAG,CAACK,aAAa,IAAIL,GAAG;IACnCG,IAAI,CAACG,MAAM,CAAC,CAAC;EACjB,CAAC;EACD,IAAI,CAACN,GAAG,CAACO,WAAW,CAAC,IAAI,CAACH,QAAQ,CAAC;AACvC;AAEAR,UAAU,CAACY,SAAS,GAAG;EAEnBC,UAAU,EAAGb,UAAU;EAEvB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;E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