var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; (function(a){function b(a){return document.createElementNS("http://www.w3.org/2000/svg",a)}function c(a){return (10>a?"0":"")+a}function d(a){var b=++r+"";return a?a+b:b}function e(e,l){function m(a,b){var c=r.offset(),d=/^touch/.test(a.type),f=c.left+100,g=c.top+100,i=(d?a.originalEvent.touches[0]:a).pageX-f,m=(d?a.originalEvent.touches[0]:a).pageY-g,e=Math.sqrt(i*i+m*m),n=!1;if(!(b&&(67>e||93AM").on("click",function(){B.amOrPm="AM",a(this).removeClass("text-white-50"),a(".btn-pm").addClass("text-white-50"),l.ampmSubmit&&setTimeout(function(){B.done();},duration/2);}).appendTo(this.buttonsAmPm),a("PM").on("click",function(){B.amOrPm="PM",a(this).removeClass("text-white-50"),a(".btn-am").addClass("text-white-50"),l.ampmSubmit&&setTimeout(function(){B.done();},duration/2);}).appendTo(this.buttonsAmPm)),l.autoclose||(A.append("").on("click",".cancel",function(){B.hide();}),A.css("display","flex").append("").on("click",".done",a.proxy(this.done,this))),/^(top|bottom)/.test(l.placement)&&("top"===l.align||"bottom"===l.align)&&(l.align="left"),("left"===l.placement||"right"===l.placement)&&("left"===l.align||"right"===l.align)&&(l.align="top"),q.addClass(l.placement),q.addClass("clockpicker-align-"+l.align),this.spanHours.click(a.proxy(this.toggleView,this,"hours")),this.spanMinutes.click(a.proxy(this.toggleView,this,"minutes")),l.addonOnly||w.on("focus.clockpicker click.clockpicker",a.proxy(this.show,this)),y.on("click.clockpicker",a.proxy(this.toggle,this));var C,D,E,F,G=a("
");if(l.twelvehour)for(C=0;12>C;C+=l.hourstep)D=G.clone(),E=C/6*Math.PI,F=80,D.css("font-size","120%"),D.css({left:100+Math.sin(E)*F-13,top:100-Math.cos(E)*F-13}),D.html(0===C?12:C),t.append(D),D.on(n,m);else for(C=0;24>C;C+=l.hourstep){var H=!1;if(l.disabledhours&&-1!=a.inArray(C,l.disabledhours))var H=!0;D=G.clone(),E=C/6*Math.PI;var I=0C;F=I?54:80,D.css({left:100+Math.sin(E)*F-13,top:100-Math.cos(E)*F-13}),I&&D.css("font-size","120%"),H&&D.addClass("disabled"),D.html(0===C?"00":C),t.append(D),H||D.on(n,m);}var J=Math.max(l.minutestep,5);for(C=0;60>C;C+=J)D=G.clone(),E=C/30*Math.PI,D.css({left:100+80*Math.sin(E)-13,top:100-80*Math.cos(E)-13}),D.css("font-size","120%"),D.html(c(C)),u.append(D),D.on(n,m);if(r.on(n,function(b){0===a(b.target).closest(".clockpicker-tick").length&&m(b,!0);}),k){var K=q.find(".clockpicker-canvas"),L=b("svg");L.setAttribute("class","clockpicker-svg"),L.setAttribute("width",diameter),L.setAttribute("height",diameter);var M=b("g");M.setAttribute("transform","translate(100,100)");var g=b("circle");g.setAttribute("class","clockpicker-canvas-bearing"),g.setAttribute("cx",0),g.setAttribute("cy",0),g.setAttribute("r",3);var N=b("line");N.setAttribute("x1",0),N.setAttribute("y1",0);var O=b("circle");O.setAttribute("class","clockpicker-canvas-bg"),O.setAttribute("r",13);var P=b("circle");P.setAttribute("class","clockpicker-canvas-fg"),P.setAttribute("r",3.5),M.appendChild(N),M.appendChild(O),M.appendChild(P),M.appendChild(g),L.appendChild(M),K.append(L),this.hand=N,this.bg=O,this.fg=P,this.bearing=g,this.g=M,this.canvas=K;}this.raiseCallback(this.options.init,"init");}function f(a,b){if(a&&"function"==typeof a&&this.element){var c=this.getTime()||null;a.call(this.element,c);}b&&this.element.trigger("clockpicker."+b||"NoName");}function g(a,b,c){var d=b.outerHeight(),e=a.outerHeight(),f=a.offset().top,g=a.offset().top+e,h=f-a[0].getBoundingClientRect().top,i=h+document.documentElement.clientHeight,j=f-d>=h,k=g+d<=i;if("top"===c){if(j)return "top";if(k)return "bottom"}else {if(k)return "bottom";if(j)return "top"}return "viewport-top"}var h,i=a(window),j=a(document),k="SVGAngle"in window&&function(){var a,b=document.createElement("div");return b.innerHTML="",a="http://www.w3.org/2000/svg"==(b.firstChild&&b.firstChild.namespaceURI),b.innerHTML="",a}(),l=function(){var a=document.createElement("div").style;return "transition"in a||"WebkitTransition"in a||"MozTransition"in a||"msTransition"in a||"OTransition"in a}(),m="ontouchstart"in window,n="mousedown"+(m?" touchstart":""),o="mousemove.clockpicker"+(m?" touchmove.clockpicker":""),p="mouseup.clockpicker"+(m?" touchend.clockpicker":""),q=navigator.vibrate?"vibrate":navigator.webkitVibrate?"webkitVibrate":null,r=0;diameter=200,duration=l?350:1;var s="
:
";e.prototype.parseStep=function(a,b){return 0==b%a?a:1},e.DEFAULTS={default:"",fromnow:0,placement:"bottom",align:"left",donetext:"OK",canceltext:"Cancel",autoclose:!1,twelvehour:!1,vibrate:!0,hourstep:1,minutestep:1,ampmSubmit:!1,addonOnly:!1,disabledhours:null},e.prototype.toggle=function(){this[this.isShown?"hide":"show"]();},e.prototype.updatePlacementClass=function(a){this.currentPlacementClass&&this.popover.removeClass(this.currentPlacementClass),a&&this.popover.addClass(a),this.currentPlacementClass=a;},e.prototype.locate=function(){var a=this.element,b=this.popover,c=a.offset(),d=a.outerWidth(),e=a.outerHeight(),f=this.options.placement,h=this.options.align,j=i.height(),k=i.width(),l=b.height(),m=b.width(),n={};if("top-adaptive"===f||"bottom-adaptive"===f){var p=f.substr(0,f.indexOf("-"));f=g(a,b,p),this.updatePlacementClass("viewport-top"===f?"":f);}b.show();"bottom"===f?n.top=c.top+e:"right"===f?n.left=c.left+d:"top"===f?n.top=c.top-b.outerHeight():"left"===f?n.left=c.left-b.outerWidth():"viewport-top"===f?n.top=c.top-a[0].getBoundingClientRect().top:void 0;"left"===h?n.left=c.left:"right"===h?n.left=c.left+d-b.outerWidth():"top"===h?n.top=c.top:"bottom"===h?n.top=c.top+e-b.outerHeight():void 0;l+n.top>j&&(n.top=j-l),m+n.left>k&&(n.left=k-m),b.css(n);},e.prototype.parseInputValue=function(){var a=this.input.prop("value")||this.options["default"]||"";if("now"===a&&(a=new Date(+new Date+this.options.fromnow)),a instanceof Date&&(a=a.getHours()+":"+a.getMinutes()),a=a.split(":"),this.hours=+a[0]||0,this.minutes=+(a[1]+"").replace(/\D/g,"")||0,this.hours=Math.round(this.hours/this.options.hourstep)*this.options.hourstep,this.minutes=Math.round(this.minutes/this.options.minutestep)*this.options.minutestep,this.options.twelvehour){var b=(a[1]+"").replace(/\d+/g,"").toLowerCase();this.amOrPm=12>this.hours||"am"===b?"AM":"PM";}},e.prototype.show=function(){if(!this.isShown){this.raiseCallback(this.options.beforeShow,"beforeShow");var b=this;this.isAppended||(h=a(document.body).append(this.popover),i.on("resize.clockpicker"+this.id,function(){b.isShown&&b.locate();}),this.isAppended=!0),this.parseInputValue(),this.spanHours.html(c(this.hours)),this.spanMinutes.html(c(this.minutes)),this.toggleView("hours"),this.locate(),this.isShown=!0,j.on("click.clockpicker."+this.id+" focusin.clockpicker."+this.id,function(c){var d=a(c.target);0===d.closest(b.popover).length&&0===d.closest(b.addon).length&&0===d.closest(b.input).length&&b.hide();}),j.on("keyup.clockpicker."+this.id,function(a){27===a.keyCode&&b.hide();}),this.raiseCallback(this.options.afterShow,"afterShow");}},e.prototype.hide=function(){this.raiseCallback(this.options.beforeHide,"beforeHide"),this.isShown=!1,j.off("click.clockpicker."+this.id+" focusin.clockpicker."+this.id),j.off("keyup.clockpicker."+this.id),this.popover.hide(),this.raiseCallback(this.options.afterHide,"afterHide");},e.prototype.toggleView=function(b,c){var d=!1;"minutes"===b&&"visible"===a(this.hoursView).css("visibility")&&(this.raiseCallback(this.options.beforeHourSelect,"beforeHourSelect"),d=!0);var e="hours"===b,f=e?this.hoursView:this.minutesView,g=e?this.minutesView:this.hoursView;this.currentView=b,this.spanHours.toggleClass("text-white-50",!e),this.spanMinutes.toggleClass("text-white-50",e),g.addClass("clockpicker-dial-out"),f.css("visibility","visible").removeClass("clockpicker-dial-out"),this.resetClock(c),clearTimeout(this.toggleViewTimer),this.toggleViewTimer=setTimeout(function(){g.css("visibility","hidden");},duration),d&&this.raiseCallback(this.options.afterHourSelect,"afterHourSelect");},e.prototype.resetClock=function(a){var b=this.currentView,c=this[b],d="hours"===b,e=Math.PI/(d?6:30),f=c*e,g=d&&0c?54:80,h=Math.sin(f)*g,i=-Math.cos(f)*g,j=this;k&&a?(j.canvas.addClass("clockpicker-canvas-out"),setTimeout(function(){j.canvas.removeClass("clockpicker-canvas-out"),j.setHand(h,i);},a)):this.setHand(h,i);},e.prototype.setHand=function(b,d,e){var f,g,h=Math.atan2(b,-d),i="hours"===this.currentView,j=Math.sqrt(b*b+d*d),l=this.options,m=i&&67>j,n=m?54:80;if(f=i?l.hourstep/6*Math.PI:l.minutestep/30*Math.PI,l.twelvehour&&(n=80),0>h&&(h=2*Math.PI+h),g=Math.round(h/f),h=g*f,!i)g*=l.minutestep,60===g&&(g=0);else if(g*=l.hourstep,l.twelvehour||!m!=0b&&"PM"===this.amOrPm&&(b+=12);var c=new Date;return c.setMinutes(this.minutes),c.setHours(b),c.setSeconds(0),a&&a.apply(this.element,c)||c},e.prototype.done=function(){this.raiseCallback(this.options.beforeDone,"beforeDone"),this.hide();var a=this.input.prop("value"),b=this.hours,d=":"+c(this.minutes);this.isHTML5&&this.options.twelvehour&&(12>this.hours&&"PM"===this.amOrPm&&(b+=12),12===this.hours&&"AM"===this.amOrPm&&(b=0)),d=c(b)+d,!this.isHTML5&&this.options.twelvehour&&(d+=this.amOrPm),this.input.prop("value",d),d!==a&&(this.input.trigger("change"),!this.isInput&&this.element.trigger("change")),this.options.autoclose&&this.input.trigger("blur"),this.raiseCallback(this.options.afterDone,"afterDone");},e.prototype.remove=function(){this.element.removeData("clockpicker"),this.input.off("focus.clockpicker click.clockpicker"),this.addon.off("click.clockpicker"),this.isShown&&this.hide(),this.isAppended&&(i.off("resize.clockpicker"+this.id),this.popover.remove());},a.fn.clockpicker=function(b){function c(){var c=a(this),f=c.data("clockpicker");if(!f){var g=a.extend({},e.DEFAULTS,c.data(),"object"==("undefined"==typeof b?"undefined":_typeof(b))&&b);c.data("clockpicker",new e(c,g));}else if("function"==typeof f[b])return f[b].apply(f,d)}var d=Array.prototype.slice.call(arguments,1);if(1==this.length){var f=c.apply(this[0]);return f===void 0?this:f}return this.each(c)};})(jQuery);