/*!
* Time picker for pickadate.js v3.2.2
* http://amsul.github.io/pickadate.js/time.htm
*/
!function(a){"function"==typeof define&&define.amd?define(["picker"],a):a(Picker)}(function(a){function b(a,b){var c=this,d=a.$node.data("value");c.settings=b,c.queue={interval:"i",min:"measure create",max:"measure create",now:"now create",select:"parse create validate",highlight:"create validate",view:"create validate",disable:"flipItem",enable:"flipItem"},c.item={},c.item.interval=b.interval||30,c.item.disable=(b.disable||[]).slice(0),c.item.enable=-function(a){return a[0]===!0?a.shift():-1}(c.item.disable),c.set("min",b.min).set("max",b.max).set("now").set("select",d||a.$node[0].value||c.item.min,{format:d?b.formatSubmit:b.format}),c.key={40:1,38:-1,39:1,37:-1,go:function(a){c.set("highlight",c.item.highlight.pick+a*c.item.interval,{interval:a*c.item.interval}),this.render()}},a.on("render",function(){var d=a.$root.children(),e=d.find("."+b.klass.viewset);e.length?d[0].scrollTop=~~(e.position().top-2*e[0].clientHeight):console.warn("Nothing to viewset with",c.item.view)}).on("open",function(){a.$root.find("button").attr("disable",!1)}).on("close",function(){a.$root.find("button").attr("disable",!0)})}var c=24,d=60,e=12,f=c*d;b.prototype.set=function(a,b,c){var d=this;return d.item["enable"==a?"disable":"flip"==a?"enable":a]=d.queue[a].split(" ").map(function(e){return b=d[e](a,b,c)}).pop(),"select"==a?d.set("highlight",d.item.select,c):"highlight"==a?d.set("view",d.item.highlight,c):"interval"==a?d.set("min",d.item.min,c).set("max",d.item.max,c):("flip"==a||"min"==a||"max"==a||"disable"==a||"enable"==a)&&d.item.select&&d.item.highlight&&("min"==a&&d.set("max",d.item.max,c),d.set("select",d.item.select,c).set("highlight",d.item.highlight,c)),d},b.prototype.get=function(a){return this.item[a]},b.prototype.create=function(b,e,g){var h=this;return e=void 0===e?b:e,a._.isObject(e)&&a._.isInteger(e.pick)?e=e.pick:$.isArray(e)?e=+e[0]*d+ +e[1]:a._.isInteger(e)||(e=h.now(b,e,g)),"max"==b&&e<h.item.min.pick&&(e+=f),e=h.normalize(e,g),{hour:~~(c+e/d)%c,mins:(d+e%d)%d,time:(f+e)%f,pick:e}},b.prototype.now=function(b,c){var e=new Date,f=e.getHours()*d+e.getMinutes();return a._.isInteger(c)?c+="min"==b&&0>c&&0===f?2:1:c=1,c*this.item.interval+f},b.prototype.normalize=function(a){return a-((0>a?this.item.interval:0)+a%this.item.interval)},b.prototype.measure=function(b,e,f){var g=this;return e?e===!0||a._.isInteger(e)?e=g.now(b,e,f):a._.isObject(e)&&a._.isInteger(e.pick)&&(e=g.normalize(e.pick,f)):e="min"==b?[0,0]:[c-1,d-1],e},b.prototype.validate=function(a,b,c){var d=this,e=c&&c.interval?c.interval:d.item.interval;return d.disabled(b)&&(b=d.shift(b,e)),b=d.scope(b),d.disabled(b)&&(b=d.shift(b,-1*e)),b},b.prototype.disabled=function(b){var c=this,d=c.item.disable.filter(function(d){return a._.isInteger(d)?b.hour==d:$.isArray(d)?b.pick==c.create(d).pick:void 0}).length;return-1===c.item.enable?!d:d},b.prototype.shift=function(a,b){for(var c=this;c.disabled(a)&&(a=c.create(a.pick+=b||c.item.interval),!(a.pick<=c.item.min.pick||a.pick>=c.item.max.pick)););return a},b.prototype.scope=function(a){var b=this.item.min.pick,c=this.item.max.pick;return this.create(a.pick>c?c:a.pick<b?b:a)},b.prototype.parse=function(b,c,e){var f=this,g={};if(!c||a._.isInteger(c)||$.isArray(c)||a._.isDate(c)||a._.isObject(c)&&a._.isInteger(c.pick))return c;if(!e||!e.format)throw"Need a formatting option to parse this..";return f.formats.toArray(e.format).map(function(b){var d=f.formats[b],e=d?a._.trigger(d,f,[c,g]):b.replace(/^!/,"").length;d&&(g[b]=c.substr(0,e)),c=c.substr(e)}),+g.i+d*(+(g.H||g.HH)||+(g.h||g.hh)%12+(/^p/i.test(g.A||g.a)?12:0))},b.prototype.formats={h:function(b,c){return b?a._.digits(b):c.hour%e||e},hh:function(b,c){return b?2:a._.lead(c.hour%e||e)},H:function(b,c){return b?a._.digits(b):""+c.hour%24},HH:function(b,c){return b?a._.digits(b):a._.lead(c.hour%24)},i:function(b,c){return b?2:a._.lead(c.mins)},a:function(a,b){return a?4:f/2>b.time%f?"a.m.":"p.m."},A:function(a,b){return a?2:f/2>b.time%f?"AM":"PM"},toArray:function(a){return a.split(/(h{1,2}|H{1,2}|i|a|A|!.)/g)},toString:function(b,c){var d=this;return d.formats.toArray(b).map(function(b){return a._.trigger(d.formats[b],d,[0,c])||b.replace(/^!/,"")}).join("")}},b.prototype.flipItem=function(a,b){var c=this,d=c.item.disable,e=-1===c.item.enable;return"flip"==b?c.item.enable=e?1:-1:!e&&"enable"==a||e&&"disable"==a?d=c.removeDisabled(d,b):(!e&&"disable"==a||e&&"enable"==a)&&(d=c.addDisabled(d,b)),d},b.prototype.addDisabled=function(a,b){var c=this;return b.map(function(b){c.filterDisabled(a,b).length||a.push(b)}),a},b.prototype.removeDisabled=function(a,b){var c=this;return b.map(function(b){a=c.filterDisabled(a,b,1)}),a},b.prototype.filterDisabled=function(a,b,c){var d=$.isArray(b);return a.filter(function(a){var e=!d&&b===a||d&&$.isArray(a)&&b.toString()===a.toString();return c?!e:e})},b.prototype.i=function(b,c){return a._.isInteger(c)&&c>0?c:this.item.interval},b.prototype.nodes=function(b){var c=this,d=c.settings,e=c.item.select,f=c.item.highlight,g=c.item.view,h=c.item.disable;return a._.node("ul",a._.group({min:c.item.min.pick,max:c.item.max.pick,i:c.item.interval,node:"li",item:function(b){return b=c.create(b),[a._.trigger(c.formats.toString,c,[a._.trigger(d.formatLabel,c,[b])||d.format,b]),function(a,i){return e&&e.pick==i&&a.push(d.klass.selected),f&&f.pick==i&&a.push(d.klass.highlighted),g&&g.pick==i&&a.push(d.klass.viewset),h&&c.disabled(b)&&a.push(d.klass.disabled),a.join(" ")}([d.klass.listItem],b.pick),"data-pick="+b.pick]}})+a._.node("li",a._.node("button",d.clear,d.klass.buttonClear,"data-clear=1"+(b?"":" disable"))),d.klass.list)},b.defaults=function(a){return{clear:"Clear",format:"h:i A",interval:30,klass:{picker:a+" "+a+"--time",holder:a+"__holder",list:a+"__list",listItem:a+"__list-item",disabled:a+"__list-item--disabled",selected:a+"__list-item--selected",highlighted:a+"__list-item--highlighted",viewset:a+"__list-item--viewset",now:a+"__list-item--now",buttonClear:a+"__button--clear"}}}(a.klasses().picker),a.extend("pickatime",b)});