{"version":3,"file":"enquire.js-B8qsBZnP.js","sources":["../../node_modules/enquire.js/src/QueryHandler.js","../../node_modules/enquire.js/src/Util.js","../../node_modules/enquire.js/src/MediaQuery.js","../../node_modules/enquire.js/src/MediaQueryDispatch.js","../../node_modules/enquire.js/src/index.js"],"sourcesContent":["/**\n * Delegate to handle a media query being matched and unmatched.\n *\n * @param {object} options\n * @param {function} options.match callback for when the media query is matched\n * @param {function} [options.unmatch] callback for when the media query is unmatched\n * @param {function} [options.setup] one-time callback triggered the first time a query is matched\n * @param {boolean} [options.deferSetup=false] should the setup callback be run immediately, rather than first time query is matched?\n * @constructor\n */\nfunction QueryHandler(options) {\n this.options = options;\n !options.deferSetup && this.setup();\n}\n\nQueryHandler.prototype = {\n\n constructor : QueryHandler,\n\n /**\n * coordinates setup of the handler\n *\n * @function\n */\n setup : function() {\n if(this.options.setup) {\n this.options.setup();\n }\n this.initialised = true;\n },\n\n /**\n * coordinates setup and triggering of the handler\n *\n * @function\n */\n on : function() {\n !this.initialised && this.setup();\n this.options.match && this.options.match();\n },\n\n /**\n * coordinates the unmatch event for the handler\n *\n * @function\n */\n off : function() {\n this.options.unmatch && this.options.unmatch();\n },\n\n /**\n * called when a handler is to be destroyed.\n * delegates to the destroy or unmatch callbacks, depending on availability.\n *\n * @function\n */\n destroy : function() {\n this.options.destroy ? this.options.destroy() : this.off();\n },\n\n /**\n * determines equality by reference.\n * if object is supplied compare options, if function, compare match callback\n *\n * @function\n * @param {object || function} [target] the target for comparison\n */\n equals : function(target) {\n return this.options === target || this.options.match === target;\n }\n\n};\n\nmodule.exports = QueryHandler;\n","/**\n * Helper function for iterating over a collection\n *\n * @param collection\n * @param fn\n */\nfunction each(collection, fn) {\n var i = 0,\n length = collection.length,\n cont;\n\n for(i; i < length; i++) {\n cont = fn(collection[i], i);\n if(cont === false) {\n break; //allow early exit\n }\n }\n}\n\n/**\n * Helper function for determining whether target object is an array\n *\n * @param target the object under test\n * @return {Boolean} true if array, false otherwise\n */\nfunction isArray(target) {\n return Object.prototype.toString.apply(target) === '[object Array]';\n}\n\n/**\n * Helper function for determining whether target object is a function\n *\n * @param target the object under test\n * @return {Boolean} true if function, false otherwise\n */\nfunction isFunction(target) {\n return typeof target === 'function';\n}\n\nmodule.exports = {\n isFunction : isFunction,\n isArray : isArray,\n each : each\n};\n","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","var MediaQuery = require('./MediaQuery');\nvar Util = require('./Util');\nvar each = Util.each;\nvar isFunction = Util.isFunction;\nvar isArray = Util.isArray;\n\n/**\n * Allows for registration of query handlers.\n * Manages the query handler's state and is responsible for wiring up browser events\n *\n * @constructor\n */\nfunction MediaQueryDispatch () {\n if(!window.matchMedia) {\n throw new Error('matchMedia not present, legacy browsers require a polyfill');\n }\n\n this.queries = {};\n this.browserIsIncapable = !window.matchMedia('only all').matches;\n}\n\nMediaQueryDispatch.prototype = {\n\n constructor : MediaQueryDispatch,\n\n /**\n * Registers a handler for the given media query\n *\n * @param {string} q the media query\n * @param {object || Array || Function} options either a single query handler object, a function, or an array of query handlers\n * @param {function} options.match fired when query matched\n * @param {function} [options.unmatch] fired when a query is no longer matched\n * @param {function} [options.setup] fired when handler first triggered\n * @param {boolean} [options.deferSetup=false] whether setup should be run immediately or deferred until query is first matched\n * @param {boolean} [shouldDegrade=false] whether this particular media query should always run on incapable browsers\n */\n register : function(q, options, shouldDegrade) {\n var queries = this.queries,\n isUnconditional = shouldDegrade && this.browserIsIncapable;\n\n if(!queries[q]) {\n queries[q] = new MediaQuery(q, isUnconditional);\n }\n\n //normalise to object in an array\n if(isFunction(options)) {\n options = { match : options };\n }\n if(!isArray(options)) {\n options = [options];\n }\n each(options, function(handler) {\n if (isFunction(handler)) {\n handler = { match : handler };\n }\n queries[q].addHandler(handler);\n });\n\n return this;\n },\n\n /**\n * unregisters a query and all it's handlers, or a specific handler for a query\n *\n * @param {string} q the media query to target\n * @param {object || function} [handler] specific handler to unregister\n */\n unregister : function(q, handler) {\n var query = this.queries[q];\n\n if(query) {\n if(handler) {\n query.removeHandler(handler);\n }\n else {\n query.clear();\n delete this.queries[q];\n }\n }\n\n return this;\n }\n};\n\nmodule.exports = MediaQueryDispatch;\n","var MediaQueryDispatch = require('./MediaQueryDispatch');\nmodule.exports = new MediaQueryDispatch();\n"],"names":["QueryHandler","options","target","QueryHandler_1","each","collection","fn","length","cont","isArray","isFunction","Util","require$$0","require$$1","MediaQuery","query","isUnconditional","self","mql","handler","qh","handlers","h","i","action","MediaQuery_1","MediaQueryDispatch","q","shouldDegrade","queries","MediaQueryDispatch_1","src"],"mappings":"uCAUA,SAASA,EAAaC,EAAS,CAC3B,KAAK,QAAUA,EACf,CAACA,EAAQ,YAAc,KAAK,MAAO,EAGvC,OAAAD,EAAa,UAAY,CAErB,YAAcA,EAOd,MAAQ,UAAW,CACZ,KAAK,QAAQ,OACZ,KAAK,QAAQ,MAAO,EAExB,KAAK,YAAc,EACtB,EAOD,GAAK,UAAW,CACZ,CAAC,KAAK,aAAe,KAAK,MAAO,EACjC,KAAK,QAAQ,OAAS,KAAK,QAAQ,MAAO,CAC7C,EAOD,IAAM,UAAW,CACb,KAAK,QAAQ,SAAW,KAAK,QAAQ,QAAS,CACjD,EAQD,QAAU,UAAW,CACjB,KAAK,QAAQ,QAAU,KAAK,QAAQ,QAAS,EAAG,KAAK,IAAK,CAC7D,EASD,OAAS,SAASE,EAAQ,CACtB,OAAO,KAAK,UAAYA,GAAU,KAAK,QAAQ,QAAUA,EAGhE,EAEDC,EAAiBH,2CCnEjB,SAASI,EAAKC,EAAYC,EAAI,CAC1B,IAAI,EAAS,EACTC,EAASF,EAAW,OACpBG,EAEJ,IAAI,EAAG,EAAID,IACPC,EAAOF,EAAGD,EAAW,CAAC,EAAG,CAAC,EACvBG,IAAS,IAFG,IAEf,EAYR,SAASC,EAAQP,EAAQ,CACrB,OAAO,OAAO,UAAU,SAAS,MAAMA,CAAM,IAAM,iBASvD,SAASQ,EAAWR,EAAQ,CACxB,OAAO,OAAOA,GAAW,W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