!function(a,b,c,d){a.visit=a.fn.visit=function(c){var e,f=a(a.isFunction(this)?b:this),g=f.selector||"",h=(new Date).getTime(),i=[],j=arguments[0],k="string"==typeof j,l=[].slice.call(arguments,1);return f.each(function(){var m,n=a.extend(!0,{},a.fn.visit.settings,c),o=n.error,p=n.namespace,q=p+"-module",r=a(this),s=a(),t=this,u=r.data(q);m={initialize:function(){n.count?m.store(n.key.count,n.count):n.id?m.add.id(n.id):n.increment&&"increment"!==k&&m.increment(),m.add.display(r),m.instantiate()},instantiate:function(){m.verbose("Storing instance of visit module",m),u=m,r.data(q,m)},destroy:function(){m.verbose("Destroying instance"),r.removeData(q)},increment:function(a){var b=m.get.count(),c=+b+1;a?m.add.id(a):(c>n.limit&&!n.surpass&&(c=n.limit),m.debug("Incrementing visits",c),m.store(n.key.count,c))},decrement:function(a){var b=m.get.count(),c=+b-1;a?m.remove.id(a):(m.debug("Removing visit"),m.store(n.key.count,c))},get:{count:function(){return+m.retrieve(n.key.count)||0},idCount:function(a){return a=a||m.get.ids(),a.length},ids:function(a){var b=[];return a=a||m.retrieve(n.key.ids),"string"==typeof a&&(b=a.split(n.delimiter)),m.verbose("Found visited ID list",b),b},storageOptions:function(){var a={};return n.expires&&(a.expires=n.expires),n.domain&&(a.domain=n.domain),n.path&&(a.path=n.path),a}},has:{visited:function(b,c){var e=!1;return c=c||m.get.ids(),b!==d&&c&&a.each(c,function(a,c){c==b&&(e=!0)}),e}},set:{count:function(a){m.store(n.key.count,a)},ids:function(a){m.store(n.key.ids,a)}},reset:function(){m.store(n.key.count,0),m.store(n.key.ids,null)},add:{id:function(a){var b=m.retrieve(n.key.ids),c=b===d||""===b?a:b+n.delimiter+a;m.has.visited(a)?m.debug("Unique content already visited, not adding visit",a,b):a===d?m.debug("ID is not defined"):(m.debug("Adding visit to unique content",a),m.store(n.key.ids,c)),m.set.count(m.get.idCount())},display:function(b){var c=a(b);c.size()>0&&!a.isWindow(c[0])&&(m.debug("Updating visit count for element",c),s=s.size()>0?s.add(c):c)}},remove:{id:function(b){var c=m.get.ids(),e=[];b!==d&&c!==d&&(m.debug("Removing visit to unique content",b,c),a.each(c,function(a,c){c!==b&&e.push(c)}),e=e.join(n.delimiter),m.store(n.key.ids,e)),m.set.count(m.get.idCount())}},check:{limit:function(b){b=b||m.get.count(),n.limit&&(b>=n.limit&&(m.debug("Pages viewed exceeded limit, firing callback",b,n.limit),a.proxy(n.onLimit,this)(b)),m.debug("Limit not reached",b,n.limit),a.proxy(n.onChange,this)(b)),m.update.display(b)}},update:{display:function(a){a=a||m.get.count(),s.size()>0&&(m.debug("Updating displayed view count",s),s.html(a))}},store:function(c,e){var f=m.get.storageOptions(e);if("localstorage"==n.storageMethod&&b.localStorage!==d)b.localStorage.setItem(c,e),m.debug("Value stored using local storage",c,e);else{if(a.cookie===d)return void m.error(o.noCookieStorage);a.cookie(c,e,f),m.debug("Value stored using cookie",c,e,f)}c==n.key.count&&m.check.limit(e)},retrieve:function(c){var e;return"localstorage"==n.storageMethod&&b.localStorage!==d?e=b.localStorage.getItem(c):a.cookie!==d?e=a.cookie(c):m.error(o.noCookieStorage),("undefined"==e||"null"==e||e===d||null===e)&&(e=d),e},setting:function(b,c){if(a.isPlainObject(b))a.extend(!0,n,b);else{if(c===d)return n[b];n[b]=c}},internal:function(b,c){return m.debug("Changing internal",b,c),c===d?m[b]:void(a.isPlainObject(b)?a.extend(!0,m,b):m[b]=c)},debug:function(){n.debug&&(n.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,n.name+":"),m.debug.apply(console,arguments)))},verbose:function(){n.verbose&&n.debug&&(n.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,n.name+":"),m.verbose.apply(console,arguments)))},error:function(){m.error=Function.prototype.bind.call(console.error,console,n.name+":"),m.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;n.performance&&(b=(new Date).getTime(),d=h||b,c=b-d,h=b,i.push({Name:a[0],Arguments:[].slice.call(a,1)||"",Element:t,"Execution Time":c})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,100)},display:function(){var b=n.name+":",c=0;h=!1,clearTimeout(m.performance.timer),a.each(i,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",g&&(b+=" '"+g+"'"),f.size()>1&&(b+=" ("+f.size()+")"),(console.group!==d||console.table!==d)&&i.length>0&&(console.groupCollapsed(b),console.table?console.table(i):a.each(i,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),i=[]}},invoke:function(b,c,f){var g,h,i,j=u;return c=c||l,f=t||f,"string"==typeof b&&j!==d&&(b=b.split(/[\. ]/),g=b.length-1,a.each(b,function(c,e){var f=c!=g?e+b[c+1].charAt(0).toUpperCase()+b[c+1].slice(1):b;if(a.isPlainObject(j[f])&&c!=g)j=j[f];else{if(j[f]!==d)return h=j[f],!1;if(!a.isPlainObject(j[e])||c==g)return j[e]!==d?(h=j[e],!1):!1;j=j[e]}})),a.isFunction(h)?i=h.apply(f,c):h!==d&&(i=h),a.isArray(e)?e.push(i):e!==d?e=[e,i]:i!==d&&(e=i),h}},k?(u===d&&m.initialize(),m.invoke(j)):(u!==d&&m.destroy(),m.initialize())}),e!==d?e:this},a.fn.visit.settings={name:"Visit",debug:!1,verbose:!0,performance:!0,namespace:"visit",increment:!1,surpass:!1,count:!1,limit:!1,delimiter:"&",storageMethod:"localstorage",key:{count:"visit-count",ids:"visit-ids"},expires:30,domain:!1,path:"/",onLimit:function(){},onChange:function(){},error:{method:"The method you called is not defined",missingPersist:"Using the persist setting requires the inclusion of PersistJS",noCookieStorage:"The default storage cookie requires $.cookie to be included."}}}(jQuery,window,document),!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){function b(a){return h.raw?a:encodeURIComponent(a)}function c(a){return h.raw?a:decodeURIComponent(a)}function d(a){return b(h.json?JSON.stringify(a):String(a))}function e(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return a=decodeURIComponent(a.replace(g," ")),h.json?JSON.parse(a):a}catch(b){}}function f(b,c){var d=h.raw?b:e(b);return a.isFunction(c)?c(d):d}var g=/\+/g,h=a.cookie=function(e,g,i){if(void 0!==g&&!a.isFunction(g)){if(i=a.extend({},h.defaults,i),"number"==typeof i.expires){var j=i.expires,k=i.expires=new Date;k.setTime(+k+864e5*j)}return document.cookie=[b(e),"=",d(g),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}for(var l=e?void 0:{},m=document.cookie?document.cookie.split("; "):[],n=0,o=m.length;o>n;n++){var p=m[n].split("="),q=c(p.shift()),r=p.join("=");if(e&&e===q){l=f(r,g);break}e||void 0===(r=f(r))||(l[q]=r)}return l};h.defaults={},a.removeCookie=function(b,c){return void 0===a.cookie(b)?!1:(a.cookie(b,"",a.extend({},c,{expires:-1})),!a.cookie(b))}});