!function(e,t){"function"==typeof define&&define.amd?define("priorityNav",t(e)):"object"==typeof exports?module.exports=t(e):e.priorityNav=t(e)}(window||this,function(e){"use strict";var t,i,n,s,o,a,r,l={},d=[],h=!!document.querySelector&&!!e.addEventListener,m={},c=0,p=0,u={initClass:"js-priorityNav",mainNavWrapper:"nav",mainNav:"ul",navDropdownClassName:"nav__dropdown",navDropdownToggleClassName:"nav__dropdown-toggle",navDropdownLabel:"more",navDropdownBreakpointLabel:"menu",breakPoint:500,throttleDelay:50,offsetPixels:0,count:!0,moved:function(){},movedBack:function(){}},f=function(e,t,i){if("[object Object]"===Object.prototype.toString.call(e))for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.call(i,e[n],n,e);else for(var s=0,o=e.length;sl.innerWidth&&(h=l.innerWidth,c=l.innerHeight),{width:h,height:c}).width};l.doesItFit=function(e){var t,a,r,h,c=0===e.getAttribute("instance")?c:m.throttleDelay;(t=function(){var t=e.getAttribute("instance");for(y(e);i<=n&&0=d[t][d[t].length-1]&&p>m.breakPoint;)l.toMenu(e,t),p>m.breakPoint&&_(e,t,m.navDropdownLabel);d[t].length<1&&(e.querySelector(o).classList.remove("show"),_(e,t,m.navDropdownLabel)),e.querySelector(s).children.length<1?(e.classList.add("is-empty"),_(e,t,m.navDropdownBreakpointLabel)):e.classList.remove("is-empty"),w(e,t)},a=c,function(){var e=this,i=arguments,n=r&&!h;clearTimeout(h),h=setTimeout(function(){h=null,r||t.apply(e,i)},a),n&&t.apply(e,i)})()};var w=function(e,t){d[t].length<1?(e.querySelector(a).classList.add("priority-nav-is-hidden"),e.querySelector(a).classList.remove("priority-nav-is-visible"),e.classList.remove("priority-nav-has-dropdown"),e.querySelector(".priority-nav__wrapper").setAttribute("aria-haspopup","false")):(e.querySelector(a).classList.add("priority-nav-is-visible"),e.querySelector(a).classList.remove("priority-nav-is-hidden"),e.classList.add("priority-nav-has-dropdown"),e.querySelector(".priority-nav__wrapper").setAttribute("aria-haspopup","true"))},g=function(e,t){e.querySelector(a).setAttribute("priorityNav-count",d[t].length)},_=function(e,t,i){e.querySelector(a).innerHTML=i};l.toDropdown=function(e,t){e.querySelector(o).firstChild&&0"),this.element.html(this.timeElement)),this.markup(),this.setTimeoutDelay=this.sToMs(1),this.daysVisible=!0,this.timeElement.on("time.elapsed",this.options.onTimeElapsed),this.timeElement.on("time.tick",this.options.onTick),this.doCountDown()))},parseEndDate:function(e){var t;return t=this.parseDuration(e),t instanceof Date?t:(t=this.parseDateTime(e),t instanceof Date?t:(t=this.parseHumanReadableDuration(e),t instanceof Date?t:(t=Date.parse(e),isNaN(t)?void 0:new Date(t))))},parseDuration:function(e){var t=e.match(/^P(?:(\d+)D)?T?(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)(?:\.(\d{1,3}))?S)?$/);if(t){var i,n,s,o,a,r;return n=t[1]?this.dToMs(t[1]):0,s=t[2]?this.hToMs(t[2]):0,o=t[3]?this.mToMs(t[3]):0,a=t[4]?this.sToMs(t[4]):0,r=t[5]?parseInt(t[5],10):0,i=new Date,i.setTime(i.getTime()+n+s+o+a+r),i}},parseDateTime:function(e){var t=e.match(/^(\d{4,})-(\d{2})-(\d{2})[T\s](\d{2}):(\d{2})(?:\:(\d{2}))?(?:\.(\d{1,3}))?([Z\+\-\:\d]+)?$/);if(t){var i=t[8]?t[8].match(/^([\+\-])?(\d{2}):?(\d{2})$/):n,s=0;i&&(s=this.hToMs(i[2])+this.mToMs(i[3]),s="-"===i[1]?s:-s);var o,a,r,l,d,h,m,c;return a=t[1],r=t[2]-1,l=t[3],d=t[4]||0,h=t[5]||0,m=t[6]||0,c=t[7]||0,o=new Date(Date.UTC(a,r,l,d,h,m,c)),o.setTime(o.getTime()+s),o}},parseHumanReadableDuration:function(e){var t=e.match(/^(?:(\d+).+\s)?(\d+)[h:]\s?(\d+)[m:]?\s?(\d+)?[s]?(?:\.(\d{1,3}))?$/);if(t){var i,n,s,o,a,r;return i=new Date,n=t[1]?this.dToMs(t[1]):0,s=t[2]?this.hToMs(t[2]):0,o=t[3]?this.mToMs(t[3]):0,a=t[4]?this.sToMs(t[4]):0,r=t[5]?parseInt(t[5],10):0,i.setTime(i.getTime()+n+s+o+a+r),i}},sToMs:function(e){return 1e3*parseInt(e,10)},mToMs:function(e){return 60*parseInt(e,10)*1e3},hToMs:function(e){return 60*parseInt(e,10)*60*1e3},dToMs:function(e){return 24*parseInt(e,10)*60*60*1e3},msToS:function(e){return parseInt(e/1e3%60,10)},msToM:function(e){return parseInt(e/1e3/60%60,10)},msToH:function(e){return parseInt(e/1e3/60/60%24,10)},msToD:function(e){return parseInt(e/1e3/60/60/24,10)},markup:function(){var e=['','','',this.options.label_dd,"","",'',this.options.separator_days,"",'','','','',this.options.label_hh,"","",'',this.options.separator,"",'','','','',this.options.label_mm,"","",'',this.options.separator,"",'','','','',this.options.label_ss,"",""];this.timeElement.html(e.join("")),this.options.with_labels||this.timeElement.find(".label").remove(),this.options.with_separators||this.timeElement.find(".separator").remove(),this.options.with_seconds||(this.timeElement.find(".item-ss").remove(),this.timeElement.find(".separator").last().remove()),this.item_dd=this.timeElement.find(".item-dd"),this.separator_dd=this.timeElement.find(".separator-dd"),this.remaining_dd=this.timeElement.find(".dd"),this.remaining_hh1=this.timeElement.find(".hh-1"),this.remaining_hh2=this.timeElement.find(".hh-2"),this.remaining_mm1=this.timeElement.find(".mm-1"),this.remaining_mm2=this.timeElement.find(".mm-2"),this.remaining_ss1=this.timeElement.find(".ss-1"),this.remaining_ss2=this.timeElement.find(".ss-2"),this.timeElement.addClass(this.options.css_class)},doCountDown:function(){var e=this.endDate.getTime()-(new Date).getTime(),i=this.msToS(e),n=this.msToM(e),s=this.msToH(e),o=this.msToD(e);if(e<=0&&(i=n=s=o=0),this.displayRemainingTime({ss:i<10?(this.options.with_ss_leading_zero?"0":" ")+i.toString():i.toString(),mm:n<10?(this.options.with_mm_leading_zero?"0":" ")+n.toString():n.toString(),hh:s<10?(this.options.with_hh_leading_zero?"0":" ")+s.toString():s.toString(),dd:o.toString()}),this.options.with_seconds||0!==o||0!==n||0!==s||(i=0),0===o&&0===n&&0===s&&0===i)return this.timeElement.trigger("time.elapsed");var a=this;return t.setTimeout(function(){a.doCountDown()},a.setTimeoutDelay),this.timeElement.trigger("time.tick",e)},displayRemainingTime:function(e){var t=[];t.push("P"),"0"!==e.dd&&t.push(e.dd,"D"),t.push("T",e.hh,"H",e.mm,"M"),this.options.with_seconds&&t.push(e.ss,"S"),this.timeElement.attr("datetime",t.join("")),this.daysVisible&&!this.options.always_show_days&&"0"===e.dd&&(this.item_dd.remove(),this.separator_dd.remove(),this.daysVisible=!1),this.remaining_dd.text(e.dd),this.remaining_hh1.text(e.hh[0].trim()),this.remaining_hh2.text(e.hh[1]),this.remaining_mm1.text(e.mm[0].trim()),this.remaining_mm2.text(e.mm[1]),this.remaining_ss1.text(e.ss[0].trim()),this.remaining_ss2.text(e.ss[1])}}),e.fn[o]=function(t){var i=arguments;if(t===n||"object"==typeof t)return this.each(function(){e.data(this,"plugin_"+o)||e.data(this,"plugin_"+o,new s(this,t))});if("string"==typeof t&&"_"!==t[0]&&"init"!==t){var a;return this.each(function(){var n=e.data(this,"plugin_"+o);n instanceof s&&"function"==typeof n[t]&&(a=n[t].apply(n,Array.prototype.slice.call(i,1))),"destroy"===t&&e.data(this,"plugin_"+o,null)}),a!==n?a:this}}}(window.jQuery,window,document);