!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(o){function i(t,e,s){this.el=t,this.$el=o(t),this.interval=null,this.offset={},this.options=o.extend({},a),this.instanceNumber=n.length,n.push(this),this.$el.data("countdown-instance",this.instanceNumber),s&&("function"==typeof s?(this.$el.on("update.countdown",s),this.$el.on("stoped.countdown",s),this.$el.on("finish.countdown",s)):this.options=o.extend({},a,s)),this.setFinalDate(e),!1===this.options.defer&&this.start()}var n=[],s=[],a={precision:100,elapse:!1,defer:!1},f=(s.push(/^[0-9]*$/.source),s.push(/([0-9]{1,2}\/){2}[0-9]{4}( [0-9]{1,2}(:[0-9]{2}){2})?/.source),s.push(/[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source),s=new RegExp(s.join("|")),{Y:"years",m:"months",n:"daysToMonth",d:"daysToWeek",w:"weeks",W:"weeksToMonth",H:"hours",M:"minutes",S:"seconds",D:"totalDays",I:"totalHours",N:"totalMinutes",T:"totalSeconds"});o.extend(i.prototype,{start:function(){null!==this.interval&&clearInterval(this.interval);var t=this;this.update(),this.interval=setInterval(function(){t.update.call(t)},this.options.precision)},stop:function(){clearInterval(this.interval),this.interval=null,this.dispatchEvent("stoped")},toggle:function(){this.interval?this.stop():this.start()},pause:function(){this.stop()},resume:function(){this.start()},remove:function(){this.stop.call(this),n[this.instanceNumber]=null,delete this.$el.data().countdownInstance},setFinalDate:function(t){var e=t;if(e instanceof Date)t=e;else{if(!String(e).match(s))throw Error("Couldn't cast `"+e+"` to a date object.");String(e).match(/^[0-9]*$/)&&(e=Number(e)),String(e).match(/\-/)&&(e=String(e).replace(/\-/g,"/")),t=new Date(e)}this.finalDate=t},update:function(){var t,e,s;0===this.$el.closest("html").length?this.remove():(t=void 0!==o._data(this.el,"events"),e=new Date,s=this.finalDate.getTime()-e.getTime(),s=Math.ceil(s/1e3),s=!this.options.elapse&&s<0?0:Math.abs(s),this.totalSecsLeft!==s&&t&&(this.totalSecsLeft=s,this.elapsed=e>=this.finalDate,this.offset={seconds:this.totalSecsLeft%60,minutes:Math.floor(this.totalSecsLeft/60)%60,hours:Math.floor(this.totalSecsLeft/60/60)%24,days:Math.floor(this.totalSecsLeft/60/60/24)%7,daysToWeek:Math.floor(this.totalSecsLeft/60/60/24)%7,daysToMonth:Math.floor(this.totalSecsLeft/60/60/24%30.4368),weeks:Math.floor(this.totalSecsLeft/60/60/24/7),weeksToMonth:Math.floor(this.totalSecsLeft/60/60/24/7)%4,months:Math.floor(this.totalSecsLeft/60/60/24/30.4368),years:Math.abs(this.finalDate.getFullYear()-e.getFullYear()),totalDays:Math.floor(this.totalSecsLeft/60/60/24),totalHours:Math.floor(this.totalSecsLeft/60/60),totalMinutes:Math.floor(this.totalSecsLeft/60),totalSeconds:this.totalSecsLeft},this.options.elapse||0!==this.totalSecsLeft?this.dispatchEvent("update"):(this.stop(),this.dispatchEvent("finish"))))},dispatchEvent:function(t){var c;(t=o.Event(t+".countdown")).finalDate=this.finalDate,t.elapsed=this.elapsed,t.offset=o.extend({},this.offset),t.strftime=(c=this.offset,function(t){var e=t.match(/%(-|!)?[A-Z]{1}(:[^;]+;)?/gi);if(e)for(var s=0,o=e.length;s