!function($,e,n,t){var s="timer";function i(e,n){this.element=e,this._name=s,this._defaults=$.fn.timer.defaults,this.options=$.extend({},this._defaults,n),this.init(),this.setMessages(),this.setTime()}$.extend(i.prototype,{init:function(){this.buildCache(),this.bindEvents()},destroy:function(){this.unbindEvents()},buildCache:function(){this.$element=$(this.element),this.totalSeconds=parseInt(this.$element.data("total")),this.remainingSeconds=parseInt(this.$element.data("remaining")),isNaN(this.totalSeconds)&&(this.totalSeconds=0),isNaN(this.remainingSeconds)&&(this.remainingSeconds=0),this.totalSeconds<this.remainingSeconds&&(this.remainingSeconds=this.totalSeconds),this.elapsedSeconds=this.totalSeconds-this.remainingSeconds,this.$timerMessageContainer=$(this.options.timerMessageContainerId),this.$timerAnnounce=$(this.options.timerAnnounceId),this.$mainCell=$(this.options.mainCellId),this.$secondaryCell=$(this.options.secondaryCellId),this.$progressBar=$(this.options.progressBarId),this.refreshIntervalId=null},bindEvents:function(){var e=this;!1!==e.options.timerRunning&&(e.refreshIntervalId=setInterval((function(){e.tick()}),1e3))},unbindEvents:function(){clearInterval(this.refreshIntervalId)},setTime:function(){var e=this,n="00",t="00";if(e.remainingSeconds>0){var s=new Date(null);s.setSeconds(e.remainingSeconds),e.$element.html(s.toISOString().substr(11,8)),e.$element.html("Time left to complete this form: "+s.toISOString().substr(11,8)),(n=Math.floor(e.remainingSeconds/60))<10&&(n="0"+n),(t=Math.floor(e.remainingSeconds%60))<10&&(t="0"+t)}e.$mainCell.text(n),e.$secondaryCell.text(t)},setMessages:function(){var e=this;if(0===e.elapsedSeconds)return e.$timerAnnounce.html(e.options.startAnnouncement),void e.$timerMessageContainer.html(e.options.startMessage);if(e.remainingSeconds<=0)return e.$timerAnnounce.html(e.options.overrunAnnouncement),e.$timerMessageContainer.html(e.options.overrunMessage),e.$timerMessageContainer.parent().addClass("alert"),void e.$progressBar.addClass("alert");e.$timerAnnounce.html(e.options.inProgressAnnouncement);var n=e.options.inProgressMessage,t="";if(e.remainingSeconds<61)t="Under a minute";else if(e.remainingSeconds<121)t="1 minute";else{t=Math.floor(e.remainingSeconds/60)+" minutes"}n=n.replace("[TimeRemaining]",t),e.$timerMessageContainer.html(n)},tick:function(){var e=this;if(e.remainingSeconds=e.remainingSeconds-1,e.elapsedSeconds=e.totalSeconds-e.remainingSeconds,e.setMessages(),e.setTime(),e.remainingSeconds<=0)return e.$element.html(e.options.timerEndedText),e.$progressBar.attr("aria-valuenow",0).attr("aria-valuetext","0 percent"),e.$progressBar.find(".progress-meter").css("width","0%"),!1===e.options.overrunAllowed?(clearInterval(e.refreshIntervalId),void setInterval((function(){e.options.onTimerReached()}),3e3)):void 0;var n=Math.floor(e.elapsedSeconds/e.totalSeconds*100);e.$progressBar.attr("aria-valuenow",n).attr("aria-valuetext",n+" percent"),e.$progressBar.find(".progress-meter").css("width",n+"%")}}),$.fn.timer=function(e){return this.each((function(){$.data(this,"plugin_timer")||$.data(this,"plugin_timer",new i(this,e))})),this},$.fn.timer.defaults={timerContainerId:"#timerProgress",timerMessageContainerId:"#tpMessage",timerAnnounceId:"#tpAnnounce",mainCellId:"#minutes_text",secondaryCellId:"#seconds_text",progressBarId:"#tpProgress",hoursText:"hours",minutesText:"minutes",secondsText:"seconds",startAnnouncement:"Time allowed",inProgressAnnouncement:"Time remaining",overrunAnnouncement:"No time remaining",timerEndedText:"Timer ended",startMessage:"",inProgressMessage:"",overrunMessage:"",timerRunning:!1,overrunAllowed:!1,hideTimerWhenTimedOut:!1,countTimeAfterTimedOut:!1,onTimerReached:function(){}}}(jQuery,window,document);