File: /www/wwwroot//www.qoifhk.com/cc/static/js/countDown.min.js
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_createClass=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}();function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var Countdown=function(){function t(e){_classCallCheck(this,t),this.options={cont:null,countdown:!0,date:{year:0,month:0,day:0,hour:0,minute:0,second:0},endCallback:null,outputFormat:"year|week|day|hour|minute|second",outputTranslation:{year:"Years",week:"Weeks",day:"Days",hour:"Hours",minute:"Minutes",second:"Seconds"}},this.lastTick=null,this.intervalsBySize=["year","week","day","hour","minute","second"],this.elementClassPrefix="countDown_",this.interval=null,this.digitConts={},this._assignOptions(this.options,e)}return _createClass(t,[{key:"TIMESTAMP_SECOND",get:function(){return 1e3}},{key:"TIMESTAMP_MINUTE",get:function(){return 60*this.TIMESTAMP_SECOND}},{key:"TIMESTAMP_HOUR",get:function(){return 60*this.TIMESTAMP_MINUTE}},{key:"TIMESTAMP_DAY",get:function(){return 24*this.TIMESTAMP_HOUR}},{key:"TIMESTAMP_WEEK",get:function(){return 7*this.TIMESTAMP_DAY}},{key:"TIMESTAMP_YEAR",get:function(){return 365*this.TIMESTAMP_DAY}}]),_createClass(t,[{key:"start",value:function(){var t,e=this,n=void 0;this._fixCompatibility(),n=this._getDate(this.options.date),t=this._prepareTimeByOutputFormat(n),this._writeData(t),this.lastTick=t,this.options.countdown&&n.getTime()<=Date.now()?"function"==typeof this.options.endCallback&&(this.stop(),this.options.endCallback()):this.interval=setInterval(function(){e._updateView(e._prepareTimeByOutputFormat(n))},this.TIMESTAMP_SECOND)}},{key:"stop",value:function(){null!==this.interval&&clearInterval(this.interval)}},{key:"_getDate",value:function(t){if("object"===(void 0===t?"undefined":_typeof(t))){if(t instanceof Date)return t;var e={day:0,month:0,year:0,hour:0,minute:0,second:0};for(var n in e)e.hasOwnProperty(n)&&t.hasOwnProperty(n)&&(e[n]=t[n]);return new Date(e.year,e.month>0?e.month-1:e.month,e.day,e.hour,e.minute,e.second)}return"number"==typeof t||"string"==typeof t?new Date(t):new Date}},{key:"_prepareTimeByOutputFormat",value:function(t){var e=this,n=void 0,i={},s=void 0;return n=this.intervalsBySize.filter(function(t){return-1!==e.options.outputFormat.split("|").indexOf(t)}),s=this.options.countdown?t.getTime()-Date.now():Date.now()-t.getTime(),n.forEach(function(t){var n=void 0;if(s>0)switch(t){case"year":n=Math.trunc(s/e.TIMESTAMP_YEAR),s-=n*e.TIMESTAMP_YEAR;break;case"week":n=Math.trunc(s/e.TIMESTAMP_WEEK),s-=n*e.TIMESTAMP_WEEK;break;case"day":n=Math.trunc(s/e.TIMESTAMP_DAY),s-=n*e.TIMESTAMP_DAY;break;case"hour":n=Math.trunc(s/e.TIMESTAMP_HOUR),s-=n*e.TIMESTAMP_HOUR;break;case"minute":n=Math.trunc(s/e.TIMESTAMP_MINUTE),s-=n*e.TIMESTAMP_MINUTE;break;case"second":n=Math.trunc(s/e.TIMESTAMP_SECOND),s-=n*e.TIMESTAMP_SECOND}else n="00";i[t]=((""+n).length<2?"0"+n:""+n).split("")}),i}},{key:"_fixCompatibility",value:function(){Math.trunc=Math.trunc||function(t){return isNaN(t)?NaN:t>0?Math.floor(t):Math.ceil(t)}}},{key:"_writeData",value:function(t){var e=this,n='<div class="'+this.elementClassPrefix+'cont">',i=void 0;for(i in t)if(t.hasOwnProperty(i)){var s='<div class="'+this.elementClassPrefix+'_interval_basic_cont">\n <div class="'+this._getIntervalContCommonClassName()+" "+this._getIntervalContClassName(i)+'">',a='<div class="'+this.elementClassPrefix+'interval_basic_cont_description">\n '+this.options.outputTranslation[i]+"\n </div>";t[i].forEach(function(t,n){s+='<div class="'+e._getDigitContCommonClassName()+" "+e._getDigitContClassName(n)+'">\n '+e._getDigitElementString(t,0)+"\n </div>"}),n+=s+"</div>"+a+"</div>"}this.options.cont.innerHTML=n+"</div>",this.lastTick=t}},{key:"_getDigitElementString",value:function(t,e){return'<div class="'+this.elementClassPrefix+'digit_last_placeholder">\n <div class="'+this.elementClassPrefix+'digit_last_placeholder_inner">\n '+e+'\n </div>\n </div>\n <div class="'+this.elementClassPrefix+'digit_new_placeholder">'+t+'</div>\n <div class="'+this.elementClassPrefix+'digit_last_rotate">'+e+'</div>\n <div class="'+this.elementClassPrefix+'digit_new_rotate">\n <div class="'+this.elementClassPrefix+'digit_new_rotated">\n <div class="'+this.elementClassPrefix+'digit_new_rotated_inner">\n '+t+"\n </div>\n </div>\n </div>"}},{key:"_updateView",value:function(t){var e=this,n=function(n){t.hasOwnProperty(n)&&t[n].forEach(function(i,s){null!==e.lastTick&&e.lastTick[n][s]!==t[n][s]&&(e._getDigitCont(n,s).innerHTML=e._getDigitElementString(t[n][s],e.lastTick[n][s]))})};for(var i in t)n(i);this.lastTick=t}},{key:"_getDigitCont",value:function(t,e){return this.digitConts[t+"_"+e]||(this.digitConts[t+"_"+e]=this.options.cont.querySelector("."+this._getIntervalContClassName(t)+" ."+this._getDigitContClassName(e))),this.digitConts[t+"_"+e]}},{key:"_getIntervalContClassName",value:function(t){return this.elementClassPrefix+"interval_cont_"+t}},{key:"_getIntervalContCommonClassName",value:function(){return this.elementClassPrefix+"interval_cont"}},{key:"_getDigitContClassName",value:function(t){return this.elementClassPrefix+"digit_cont_"+t}},{key:"_getDigitContCommonClassName",value:function(){return this.elementClassPrefix+"digit_cont"}},{key:"_assignOptions",value:function(t,e){for(var n in t)t.hasOwnProperty(n)&&e.hasOwnProperty(n)&&(null!==t[n]&&"object"===_typeof(t[n])&&"object"===_typeof(e[n])?this._assignOptions(t[n],e[n]):t[n]=e[n])}}]),t}();