!function(name,context,factory){var matchMedia=context.matchMedia;"undefined"!=typeof module&&module.exports?module.exports=factory(matchMedia):"function"==typeof define&&define.amd?define(function(){return context[name]=factory(matchMedia)}):context[name]=factory(matchMedia)}("enquire",this,function(matchMedia){"use strict";function each(collection,fn){var cont,i=0,length=collection.length;for(i;length>i&&(cont=fn(collection[i],i),cont!==!1);i++);}function isArray(target){return"[object Array]"===Object.prototype.toString.apply(target)}function isFunction(target){return"function"==typeof target}function QueryHandler(options){this.options=options,!options.deferSetup&&this.setup()}function MediaQuery(query,isUnconditional){this.query=query,this.isUnconditional=isUnconditional,this.handlers=[],this.mql=matchMedia(query);var self=this;this.listener=function(mql){self.mql=mql,self.assess()},this.mql.addListener(this.listener)}function MediaQueryDispatch(){if(!matchMedia)throw new Error("matchMedia not present, legacy browsers require a polyfill");this.queries={},this.browserIsIncapable=!matchMedia("only all").matches}return QueryHandler.prototype={setup:function(){this.options.setup&&this.options.setup(),this.initialised=!0},on:function(){!this.initialised&&this.setup(),this.options.match&&this.options.match()},off:function(){this.options.unmatch&&this.options.unmatch()},destroy:function(){this.options.destroy?this.options.destroy():this.off()},equals:function(target){return this.options===target||this.options.match===target}},MediaQuery.prototype={addHandler:function(handler){var qh=new QueryHandler(handler);this.handlers.push(qh),this.matches()&&qh.on()},removeHandler:function(handler){var handlers=this.handlers;each(handlers,function(h,i){return h.equals(handler)?(h.destroy(),!handlers.splice(i,1)):void 0})},matches:function(){return this.mql.matches||this.isUnconditional},clear:function(){each(this.handlers,function(handler){handler.destroy()}),this.mql.removeListener(this.listener),this.handlers.length=0},assess:function(){var action=this.matches()?"on":"off";each(this.handlers,function(handler){handler[action]()})}},MediaQueryDispatch.prototype={register:function(q,options,shouldDegrade){var queries=this.queries,isUnconditional=shouldDegrade&&this.browserIsIncapable;return queries[q]||(queries[q]=new MediaQuery(q,isUnconditional)),isFunction(options)&&(options={match:options}),isArray(options)||(options=[options]),each(options,function(handler){queries[q].addHandler(handler)}),this},unregister:function(q,handler){var query=this.queries[q];return query&&(handler?query.removeHandler(handler):(query.clear(),delete this.queries[q])),this}},new MediaQueryDispatch});