!function(e, t) {
	e.moment = t();
}(this, function() {
	"use strict";
	function e() {
		return Qe.apply(null, arguments)
	}
	function t(e) {
		return e instanceof Array || "[object Array]" === Object.prototype.toString.call(e)
	}
	function n(e) {
		return null != e && "[object Object]" === Object.prototype.toString.call(e)
	}
	function s(e) {
		return void 0 === e
	}
	function i(e) {
		return "number" == typeof e || "[object Number]" === Object.prototype.toString.call(e)
	}
	function r(e) {
		return e instanceof Date || "[object Date]" === Object.prototype.toString.call(e)
	}
	function a(e, t) {
		var n,
			s = [];
		for (n = 0; n < e.length; ++n) s.push(t(e[n], n));
		return s
	}
	function o(e, t) {
		return Object.prototype.hasOwnProperty.call(e, t)
	}
	function u(e, t) {
		for (var n in t) o(t, n) && (e[n] = t[n]);
		return o(t, "toString") && (e.toString = t.toString), o(t, "valueOf") && (e.valueOf = t.valueOf), e
	}
	function l(e, t, n, s) {
		return ge(e, t, n, s, !0).utc()
	}
	function d(e) {
		return null == e._pf && (e._pf = {
				empty : !1,
				unusedTokens : [],
				unusedInput : [],
				overflow : -2,
				charsLeftOver : 0,
				nullInput : !1,
				invalidMonth : null,
				invalidFormat : !1,
				userInvalidated : !1,
				iso : !1,
				parsedDateParts : [],
				meridiem : null,
				rfc2822 : !1,
				weekdayMismatch : !1
			}), e._pf
	}
	function h(e) {
		if (null == e._isValid) {
			var t = d(e),
				n = Xe.call(t.parsedDateParts, function(e) {
					return null != e
				}),
				s = !isNaN(e._d.getTime()) && t.overflow < 0 && !t.empty && !t.invalidMonth && !t.invalidWeekday && !t.weekdayMismatch && !t.nullInput && !t.invalidFormat && !t.userInvalidated && (!t.meridiem || t.meridiem && n);
			if (e._strict && (s = s && 0 === t.charsLeftOver && 0 === t.unusedTokens.length && void 0 === t.bigHour), null != Object.isFrozen && Object.isFrozen(e)) return s;
			e._isValid = s
		}
		return e._isValid
	}
	function c(e) {
		var t = l(NaN);
		return null != e ? u(d(t), e) : d(t).userInvalidated = !0, t
	}
	function f(e, t) {
		var n,
			i,
			r;
		if (s(t._isAMomentObject) || (e._isAMomentObject = t._isAMomentObject), s(t._i) || (e._i = t._i), s(t._f) || (e._f = t._f), s(t._l) || (e._l = t._l), s(t._strict) || (e._strict = t._strict), s(t._tzm) || (e._tzm = t._tzm), s(t._isUTC) || (e._isUTC = t._isUTC), s(t._offset) || (e._offset = t._offset), s(t._pf) || (e._pf = d(t)), s(t._locale) || (e._locale = t._locale), Ke.length > 0)
			for (n = 0; n < Ke.length; n++) s(r = t[i = Ke[n]]) || (e[i] = r);
		return e
	}
	function m(t) {
		f(this, t), this._d = new Date(null != t._d ? t._d.getTime() : NaN), this.isValid() || (this._d = new Date(NaN)), !1 === et && (et = !0, e.updateOffset(this), et = !1)
	}
	function _(e) {
		return e instanceof m || null != e && null != e._isAMomentObject
	}
	function y(e) {
		return e < 0 ? Math.ceil(e) || 0 : Math.floor(e)
	}
	function g(e) {
		var t = +e,
			n = 0;
		return 0 !== t && isFinite(t) && (n = y(t)), n
	}
	function p(e, t, n) {
		var s,
			i = Math.min(e.length, t.length),
			r = Math.abs(e.length - t.length),
			a = 0;
		for (s = 0; s < i; s++) (n && e[s] !== t[s] || !n && g(e[s]) !== g(t[s])) && a++;
		return a + r
	}
	function w(t) {
		!1 === e.suppressDeprecationWarnings && "undefined" != typeof console && console.warn && console.warn("Deprecation warning: " + t)
	}
	function v(t, n) {
		var s = !0;
		return u(function() {
			if (null != e.deprecationHandler && e.deprecationHandler(null, t), s) {
				for (var i, r = [], a = 0; a < arguments.length; a++) {
					if (i = "", "object" == typeof arguments[a]) {
						i += "\n[" + a + "] ";
						for (var o in arguments[0]) i += o + ": " + arguments[0][o] + ", ";
						i = i.slice(0, -2)
					} else
						i = arguments[a];
					r.push(i)
				}
				w(t + "\nArguments: " + Array.prototype.slice.call(r).join("") + "\n" + (new Error).stack), s = !1
			}
			return n.apply(this, arguments)
		}, n)
	}
	function M(t, n) {
		null != e.deprecationHandler && e.deprecationHandler(t, n), tt[t] || (w(n), tt[t] = !0)
	}
	function S(e) {
		return e instanceof Function || "[object Function]" === Object.prototype.toString.call(e)
	}
	function D(e, t) {
		var s,
			i = u({}, e);
		for (s in t) o(t, s) && (n(e[s]) && n(t[s]) ? (i[s] = {}, u(i[s], e[s]), u(i[s], t[s])) : null != t[s] ? i[s] = t[s] :
				delete i[s]
			);
		for (s in e) o(e, s) && !o(t, s) && n(e[s]) && (i[s] = u({}, i[s]));
		return i
	}
	function k(e) {
		null != e && this.set(e)
	}
	function Y(e, t) {
		var n = e.toLowerCase();
		st[n] = st[n + "s"] = st[t] = e
	}
	function O(e) {
		return "string" == typeof e ? st[e] || st[e.toLowerCase()] : void 0
	}
	function T(e) {
		var t,
			n,
			s = {};
		for (n in e) o(e, n) && (t = O(n)) && (s[t] = e[n]);
		return s
	}
	function x(e, t) {
		it[e] = t
	}
	function b(e, t, n) {
		var s = "" + Math.abs(e),
			i = t - s.length;
		return (e >= 0 ? n ? "+" : "" : "-") + Math.pow(10, Math.max(0, i)).toString().substr(1) + s
	}
	function P(e, t, n, s) {
		var i = s;
		"string" == typeof s && (i = function() {
			return this[s]()
		}), e && (ut[e] = i), t && (ut[t[0]] = function() {
			return b(i.apply(this, arguments), t[1], t[2])
		}), n && (ut[n] = function() {
			return this.localeData().ordinal(i.apply(this, arguments), e)
		})
	}
	function W(e) {
		return e.match(/\[[\s\S]/) ? e.replace(/^\[|\]$/g, "") : e.replace(/\\/g, "")
	}
	function H(e, t) {
		return e.isValid() ? (t = R(t, e.localeData()), ot[t] = ot[t] || function(e) {
			var t,
				n,
				s = e.match(rt);
			for (t = 0, n = s.length; t < n; t++) ut[s[t]] ? s[t] = ut[s[t]] : s[t] = W(s[t]);
			return function(t) {
				var i,
					r = "";
				for (i = 0; i < n; i++) r += S(s[i]) ? s[i].call(t, e) : s[i];
				return r
			}
		}(t), ot[t](e)) : e.localeData().invalidDate()
	}
	function R(e, t) {
		function n(e) {
			return t.longDateFormat(e) || e
		}
		var s = 5;
		for (at.lastIndex = 0; s >= 0 && at.test(e);) e = e.replace(at, n), at.lastIndex = 0, s -= 1;
		return e
	}
	function C(e, t, n) {
		Yt[e] = S(t) ? t : function(e, s) {
			return e && n ? n : t
		}
	}
	function F(e, t) {
		return o(Yt, e) ? Yt[e](t._strict, t._locale) : new RegExp(function(e) {
			return U(e.replace("\\", "").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function(e, t, n, s, i) {
				return t || n || s || i
			}))
		}(e))
	}
	function U(e) {
		return e.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&")
	}
	function L(e, t) {
		var n,
			s = t;
		for ("string" == typeof e && (e = [ e ]), i(t) && (s = function(e, n) {
				n[t] = g(e)
			}), n = 0; n < e.length; n++) Ot[e[n]] = s
	}
	function N(e, t) {
		L(e, function(e, n, s, i) {
			s._w = s._w || {}, t(e, s._w, s, i)
		})
	}
	function G(e, t, n) {
		null != t && o(Ot, e) && Ot[e](t, n._a, n, e)
	}
	function V(e) {
		return E(e) ? 366 : 365
	}
	function E(e) {
		return e % 4 == 0 && e % 100 != 0 || e % 400 == 0
	}
	function I(t, n) {
		return function(s) {
			return null != s ? (j(this, t, s), e.updateOffset(this, n), this) : A(this, t)
		}
	}
	function A(e, t) {
		return e.isValid() ? e._d["get" + (e._isUTC ? "UTC" : "") + t]() : NaN
	}
	function j(e, t, n) {
		e.isValid() && !isNaN(n) && ("FullYear" === t && E(e.year()) && 1 === e.month() && 29 === e.date() ? e._d["set" + (e._isUTC ? "UTC" : "") + t](n, e.month(), Z(n, e.month())) : e._d["set" + (e._isUTC ? "UTC" : "") + t](n))
	}
	function Z(e, t) {
		if (isNaN(e) || isNaN(t)) return NaN;
		var n = function(e, t) {
			return (e % t + t) % t
		}(t, 12);
		return e += (t - n) / 12, 1 === n ? E(e) ? 29 : 28 : 31 - n % 7 % 2
	}
	function z(e, t) {
		var n;
		if (!e.isValid()) return e;
		if ("string" == typeof t)
			if (/^\d+$/.test(t))
				t = g(t);
			else if (t = e.localeData().monthsParse(t), !i(t)) return e;
		return n = Math.min(e.date(), Z(e.year(), t)), e._d["set" + (e._isUTC ? "UTC" : "") + "Month"](t, n), e
	}
	function $(t) {
		return null != t ? (z(this, t), e.updateOffset(this, !0), this) : A(this, "Month")
	}
	function q() {
		function e(e, t) {
			return t.length - e.length
		}
		var t,
			n,
			s = [],
			i = [],
			r = [];
		for (t = 0; t < 12; t++) n = l([ 2e3, t ]), s.push(this.monthsShort(n, "")), i.push(this.months(n, "")), r.push(this.months(n, "")), r.push(this.monthsShort(n, ""));
		for (s.sort(e), i.sort(e), r.sort(e), t = 0; t < 12; t++) s[t] = U(s[t]), i[t] = U(i[t]);
		for (t = 0; t < 24; t++) r[t] = U(r[t]);
		this._monthsRegex = new RegExp("^(" + r.join("|") + ")", "i"), this._monthsShortRegex = this._monthsRegex, this._monthsStrictRegex = new RegExp("^(" + i.join("|") + ")", "i"), this._monthsShortStrictRegex = new RegExp("^(" + s.join("|") + ")", "i")
	}
	function J(e) {
		var t = new Date(Date.UTC.apply(null, arguments));
		return e < 100 && e >= 0 && isFinite(t.getUTCFullYear()) && t.setUTCFullYear(e), t
	}
	function B(e, t, n) {
		var s = 7 + t - n;
		return -((7 + J(e, 0, s).getUTCDay() - t) % 7) + s - 1
	}
	function Q(e, t, n, s, i) {
		var r,
			a,
			o = 1 + 7 * (t - 1) + (7 + n - s) % 7 + B(e, s, i);
		return o <= 0 ? a = V(r = e - 1) + o : o > V(e) ? (r = e + 1, a = o - V(e)) : (r = e, a = o), {
				year : r,
				dayOfYear : a
		}
	}
	function X(e, t, n) {
		var s,
			i,
			r = B(e.year(), t, n),
			a = Math.floor((e.dayOfYear() - r - 1) / 7) + 1;
		return a < 1 ? s = a + K(i = e.year() - 1, t, n) : a > K(e.year(), t, n) ? (s = a - K(e.year(), t, n), i = e.year() + 1) : (i = e.year(), s = a), {
				week : s,
				year : i
		}
	}
	function K(e, t, n) {
		var s = B(e, t, n),
			i = B(e + 1, t, n);
		return (V(e) - s + i) / 7
	}
	function ee() {
		function e(e, t) {
			return t.length - e.length
		}
		var t,
			n,
			s,
			i,
			r,
			a = [],
			o = [],
			u = [],
			d = [];
		for (t = 0; t < 7; t++) n = l([ 2e3, 1 ]).day(t), s = this.weekdaysMin(n, ""), i = this.weekdaysShort(n, ""), r = this.weekdays(n, ""), a.push(s), o.push(i), u.push(r), d.push(s), d.push(i), d.push(r);
		for (a.sort(e), o.sort(e), u.sort(e), d.sort(e), t = 0; t < 7; t++) o[t] = U(o[t]), u[t] = U(u[t]), d[t] = U(d[t]);
		this._weekdaysRegex = new RegExp("^(" + d.join("|") + ")", "i"), this._weekdaysShortRegex = this._weekdaysRegex, this._weekdaysMinRegex = this._weekdaysRegex, this._weekdaysStrictRegex = new RegExp("^(" + u.join("|") + ")", "i"), this._weekdaysShortStrictRegex = new RegExp("^(" + o.join("|") + ")", "i"), this._weekdaysMinStrictRegex = new RegExp("^(" + a.join("|") + ")", "i")
	}
	function te() {
		return this.hours() % 12 || 12
	}
	function ne(e, t) {
		P(e, 0, 0, function() {
			return this.localeData().meridiem(this.hours(), this.minutes(), t)
		})
	}
	function se(e, t) {
		return t._meridiemParse
	}
	function ie(e) {
		return e ? e.toLowerCase().replace("_", "-") : e
	}
	function re(e) {
		var t = null;
		if (!Xt[e] && "undefined" != typeof module && module && module.exports) try {
				t = Jt._abbr;require("./locale/" + e), ae(t)
			} catch (e) {} return Xt[e]
	}
	function ae(e, t) {
		var n;
		return e && (n = s(t) ? ue(e) : oe(e, t)) && (Jt = n), Jt._abbr
	}
	function oe(e, t) {
		if (null !== t) {
			var n = Qt;
			if (t.abbr = e, null != Xt[e]) M("defineLocaleOverride", "use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."), n = Xt[e]._config;
			else if (null != t.parentLocale) {
				if (null == Xt[t.parentLocale]) return Kt[t.parentLocale] || (Kt[t.parentLocale] = []), Kt[t.parentLocale].push({
							name : e,
							config : t
						}), null;
				n = Xt[t.parentLocale]._config
			}
			return Xt[e] = new k(D(n, t)), Kt[e] && Kt[e].forEach(function(e) {
					oe(e.name, e.config)
				}), ae(e), Xt[e]
		}
		return delete Xt[e]
			, null
	}
	function ue(e) {
		var n;
		if (e && e._locale && e._locale._abbr && (e = e._locale._abbr), !e) return Jt;
		if (!t(e)) {
			if (n = re(e)) return n;
			e = [ e ]
		}
		return function(e) {
			for (var t, n, s, i, r = 0; r < e.length;) {
				for (t = (i = ie(e[r]).split("-")).length, n = (n = ie(e[r + 1])) ? n.split("-") : null; t > 0;) {
					if (s = re(i.slice(0, t).join("-"))) return s;
					if (n && n.length >= t && p(i, n, !0) >= t - 1) break;
					t--
				}
				r++
			}
			return null
		}(e)
	}
	function le(e) {
		var t,
			n = e._a;
		return n && -2 === d(e).overflow && (t = n[xt] < 0 || n[xt] > 11 ? xt : n[bt] < 1 || n[bt] > Z(n[Tt], n[xt]) ? bt : n[Pt] < 0 || n[Pt] > 24 || 24 === n[Pt] && (0 !== n[Wt] || 0 !== n[Ht] || 0 !== n[Rt]) ? Pt : n[Wt] < 0 || n[Wt] > 59 ? Wt : n[Ht] < 0 || n[Ht] > 59 ? Ht : n[Rt] < 0 || n[Rt] > 999 ? Rt : -1, d(e)._overflowDayOfYear && (t < Tt || t > bt) && (t = bt), d(e)._overflowWeeks && -1 === t && (t = Ct), d(e)._overflowWeekday && -1 === t && (t = Ft), d(e).overflow = t), e
	}
	function de(e, t, n) {
		return null != e ? e : null != t ? t : n
	}
	function he(t) {
		var n,
			s,
			i,
			r,
			a,
			o = [];
		if (!t._d) {
			for (i = function(t) {
					var n = new Date(e.now());
					return t._useUTC ? [ n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate() ] : [ n.getFullYear(), n.getMonth(), n.getDate() ]
				}(t), t._w && null == t._a[bt] && null == t._a[xt] && function(e) {
					var t,
						n,
						s,
						i,
						r,
						a,
						o,
						u;
					if (null != (t = e._w).GG || null != t.W || null != t.E) r = 1, a = 4, n = de(t.GG, e._a[Tt], X(pe(), 1, 4).year), s = de(t.W, 1), ((i = de(t.E, 1)) < 1 || i > 7) && (u = !0);else {
						r = e._locale._week.dow, a = e._locale._week.doy;
						var l = X(pe(), r, a);
						n = de(t.gg, e._a[Tt], l.year), s = de(t.w, l.week), null != t.d ? ((i = t.d) < 0 || i > 6) && (u = !0) : null != t.e ? (i = t.e + r, (t.e < 0 || t.e > 6) && (u = !0)) : i = r
					}
					s < 1 || s > K(n, r, a) ? d(e)._overflowWeeks = !0 : null != u ? d(e)._overflowWeekday = !0 : (o = Q(n, s, i, r, a), e._a[Tt] = o.year, e._dayOfYear = o.dayOfYear)
				}(t), null != t._dayOfYear && (a = de(t._a[Tt], i[Tt]), (t._dayOfYear > V(a) || 0 === t._dayOfYear) && (d(t)._overflowDayOfYear = !0), s = J(a, 0, t._dayOfYear), t._a[xt] = s.getUTCMonth(), t._a[bt] = s.getUTCDate()), n = 0;n < 3 && null == t._a[n]; ++n) t._a[n] = o[n] = i[n];
			for (; n < 7; n++) t._a[n] = o[n] = null == t._a[n] ? 2 === n ? 1 : 0 : t._a[n];
			24 === t._a[Pt] && 0 === t._a[Wt] && 0 === t._a[Ht] && 0 === t._a[Rt] && (t._nextDay = !0, t._a[Pt] = 0), t._d = (t._useUTC ? J : function(e, t, n, s, i, r, a) {
				var o = new Date(e, t, n, s, i, r, a);
				return e < 100 && e >= 0 && isFinite(o.getFullYear()) && o.setFullYear(e), o
			}).apply(null, o), r = t._useUTC ? t._d.getUTCDay() : t._d.getDay(), null != t._tzm && t._d.setUTCMinutes(t._d.getUTCMinutes() - t._tzm), t._nextDay && (t._a[Pt] = 24), t._w && void 0 !== t._w.d && t._w.d !== r && (d(t).weekdayMismatch = !0)
		}
	}
	function ce(e) {
		var t,
			n,
			s,
			i,
			r,
			a,
			o = e._i,
			u = en.exec(o) || tn.exec(o);
		if (u) {
			for (d(e).iso = !0, t = 0, n = sn.length; t < n; t++)
				if (sn[t][1].exec(u[1])) {
					i = sn[t][0], s = !1 !== sn[t][2];break
			}
			if (null == i) return void (e._isValid = !1);
			if (u[3]) {
				for (t = 0, n = rn.length; t < n; t++)
					if (rn[t][1].exec(u[3])) {
						r = (u[2] || " ") + rn[t][0];break
				}
				if (null == r) return void (e._isValid = !1)
			}
			if (!s && null != r) return void (e._isValid = !1);
			if (u[4]) {
				if (!nn.exec(u[4])) return void (e._isValid = !1);
				a = "Z"
			}
			e._f = i + (r || "") + (a || ""), _e(e)
		} else
			e._isValid = !1
	}
	function fe(e, t, n, s, i, r) {
		var a = [ function(e) {
			var t = parseInt(e, 10);
			{
				if (t <= 49) return 2e3 + t;
				if (t <= 999) return 1900 + t
			}
			return t
		}(e), Vt.indexOf(t), parseInt(n, 10), parseInt(s, 10), parseInt(i, 10) ];
		return r && a.push(parseInt(r, 10)), a
	}
	function me(e) {
		var t = on.exec(function(e) {
			return e.replace(/\([^)]*\)|[\n\t]/g, " ").replace(/(\s\s+)/g, " ").trim()
		}(e._i));
		if (t) {
			var n = fe(t[4], t[3], t[2], t[5], t[6], t[7]);
			if (!function(e, t, n) {
					if (e && jt.indexOf(e) !== new Date(t[0], t[1], t[2]).getDay()) return d(n).weekdayMismatch = !0, n._isValid = !1, !1;
					return !0
				}(t[1], n, e)) return;
			e._a = n, e._tzm = function(e, t, n) {
				if (e) return un[e];
				if (t) return 0;
				var s = parseInt(n, 10),
					i = s % 100;
				return (s - i) / 100 * 60 + i
			}(t[8], t[9], t[10]), e._d = J.apply(null, e._a), e._d.setUTCMinutes(e._d.getUTCMinutes() - e._tzm), d(e).rfc2822 = !0
		} else
			e._isValid = !1
	}
	function _e(t) {
		if (t._f !== e.ISO_8601)
			if (t._f !== e.RFC_2822) {
				t._a = [], d(t).empty = !0;
				var n,
					s,
					i,
					r,
					a,
					o = "" + t._i,
					u = o.length,
					l = 0;
				for (i = R(t._f, t._locale).match(rt) || [], n = 0; n < i.length; n++) r = i[n], (s = (o.match(F(r, t)) || [])[0]) && ((a = o.substr(0, o.indexOf(s))).length > 0 && d(t).unusedInput.push(a), o = o.slice(o.indexOf(s) + s.length), l += s.length), ut[r] ? (s ? d(t).empty = !1 : d(t).unusedTokens.push(r), G(r, s, t)) : t._strict && !s && d(t).unusedTokens.push(r);
				d(t).charsLeftOver = u - l, o.length > 0 && d(t).unusedInput.push(o), t._a[Pt] <= 12 && !0 === d(t).bigHour && t._a[Pt] > 0 && (d(t).bigHour = void 0), d(t).parsedDateParts = t._a.slice(0), d(t).meridiem = t._meridiem, t._a[Pt] = function(e, t, n) {
					var s;
					if (null == n) return t;
					return null != e.meridiemHour ? e.meridiemHour(t, n) : null != e.isPM ? ((s = e.isPM(n)) && t < 12 && (t += 12), s || 12 !== t || (t = 0), t) : t
				}(t._locale, t._a[Pt], t._meridiem), he(t), le(t)
			} else me(t);
		else ce(t)
	}
	function ye(o) {
		var l = o._i,
			y = o._f;
		return o._locale = o._locale || ue(o._l), null === l || void 0 === y && "" === l ? c({
				nullInput : !0
			}) : ("string" == typeof l && (o._i = l = o._locale.preparse(l)), _(l) ? new m(le(l)) : (r(l) ? o._d = l : t(y) ? function(e) {
				var t,
					n,
					s,
					i,
					r;
				if (0 === e._f.length) return d(e).invalidFormat = !0, void (e._d = new Date(NaN));
				for (i = 0; i < e._f.length; i++) r = 0, t = f({}, e), null != e._useUTC && (t._useUTC = e._useUTC), t._f = e._f[i], _e(t), h(t) && (r += d(t).charsLeftOver, r += 10 * d(t).unusedTokens.length, d(t).score = r, (null == s || r < s) && (s = r, n = t));
				u(e, n || t)
			}(o) : y ? _e(o) : function(o) {
				var u = o._i;
				s(u) ? o._d = new Date(e.now()) : r(u) ? o._d = new Date(u.valueOf()) : "string" == typeof u ? function(t) {
					var n = an.exec(t._i);
					null === n ? (ce(t), !1 === t._isValid && (
					delete t._isValid
					, me(t), !1 === t._isValid && (
					delete t._isValid
					, e.createFromInputFallback(t)))) : t._d = new Date(+n[1])
				}(o) : t(u) ? (o._a = a(u.slice(0), function(e) {
					return parseInt(e, 10)
				}), he(o)) : n(u) ? function(e) {
					if (!e._d) {
						var t = T(e._i);
						e._a = a([ t.year, t.month, t.day || t.date, t.hour, t.minute, t.second, t.millisecond ], function(e) {
							return e && parseInt(e, 10)
						}), he(e)
					}
				}(o) : i(u) ? o._d = new Date(u) : e.createFromInputFallback(o)
			}(o), h(o) || (o._d = null), o))
	}
	function ge(e, s, i, r, a) {
		var o = {};
		return !0 !== i && !1 !== i || (r = i, i = void 0), (n(e) && function(e) {
				if (Object.getOwnPropertyNames) return 0 === Object.getOwnPropertyNames(e).length;
				var t;
				for (t in e)
					if (e.hasOwnProperty(t)) return !1;
				return !0
			}(e) || t(e) && 0 === e.length) && (e = void 0), o._isAMomentObject = !0, o._useUTC = o._isUTC = a, o._l = i, o._i = e, o._f = s, o._strict = r, function(e) {
				var t = new m(le(ye(e)));
				return t._nextDay && (t.add(1, "d"), t._nextDay = void 0), t
			}(o)
	}
	function pe(e, t, n, s) {
		return ge(e, t, n, s, !1)
	}
	function we(e, n) {
		var s,
			i;
		if (1 === n.length && t(n[0]) && (n = n[0]), !n.length) return pe();
		for (s = n[0], i = 1; i < n.length; ++i) n[i].isValid() && !n[i][e](s) || (s = n[i]);
		return s
	}
	function ve(e) {
		var t = T(e),
			n = t.year || 0,
			s = t.quarter || 0,
			i = t.month || 0,
			r = t.week || 0,
			a = t.day || 0,
			o = t.hour || 0,
			u = t.minute || 0,
			l = t.second || 0,
			d = t.millisecond || 0;
		this._isValid = function(e) {
			for (var t in e)
				if (-1 === Ut.call(hn, t) || null != e[t] && isNaN(e[t])) return !1;
			for (var n = !1, s = 0; s < hn.length; ++s)
				if (e[hn[s]]) {
					if (n) return !1;
					parseFloat(e[hn[s]]) !== g(e[hn[s]]) && (n = !0)
			}
			return !0
		}(t), this._milliseconds = +d + 1e3 * l + 6e4 * u + 1e3 * o * 60 * 60, this._days = +a + 7 * r, this._months = +i + 3 * s + 12 * n, this._data = {}, this._locale = ue(), this._bubble()
	}
	function Me(e) {
		return e instanceof ve
	}
	function Se(e) {
		return e < 0 ? -1 * Math.round(-1 * e) : Math.round(e)
	}
	function De(e, t) {
		P(e, 0, 0, function() {
			var e = this.utcOffset(),
				n = "+";
			return e < 0 && (e = -e, n = "-"), n + b(~~(e / 60), 2) + t + b(~~e % 60, 2)
		})
	}
	function ke(e, t) {
		var n = (t || "").match(e);
		if (null === n) return null;
		var s = ((n[n.length - 1] || []) + "").match(cn) || [ "-", 0, 0 ],
			i = 60 * s[1] + g(s[2]);
		return 0 === i ? 0 : "+" === s[0] ? i : -i
	}
	function Ye(t, n) {
		var s,
			i;
		return n._isUTC ? (s = n.clone(), i = (_(t) || r(t) ? t.valueOf() : pe(t).valueOf()) - s.valueOf(), s._d.setTime(s._d.valueOf() + i), e.updateOffset(s, !1), s) : pe(t).local()
	}
	function Oe(e) {
		return 15 * -Math.round(e._d.getTimezoneOffset() / 15)
	}
	function Te() {
		return !!this.isValid() && (this._isUTC && 0 === this._offset)
	}
	function xe(e, t) {
		var n,
			s,
			r,
			a = e,
			u = null;
		return Me(e) ? a = {
				ms : e._milliseconds,
				d : e._days,
				M : e._months
			} : i(e) ? (a = {}, t ? a[t] = e : a.milliseconds = e) : (u = fn.exec(e)) ? (n = "-" === u[1] ? -1 : 1, a = {
				y : 0,
				d : g(u[bt]) * n,
				h : g(u[Pt]) * n,
				m : g(u[Wt]) * n,
				s : g(u[Ht]) * n,
				ms : g(Se(1e3 * u[Rt])) * n
			}) : (u = mn.exec(e)) ? (n = "-" === u[1] ? -1 : (u[1], 1), a = {
				y : be(u[2], n),
				M : be(u[3], n),
				w : be(u[4], n),
				d : be(u[5], n),
				h : be(u[6], n),
				m : be(u[7], n),
				s : be(u[8], n)
			}) : null == a ? a = {} : "object" == typeof a && ("from" in a || "to" in a) && (r = function(e, t) {
				var n;
				if (!e.isValid() || !t.isValid()) return {
						milliseconds : 0,
						months : 0
					};
				t = Ye(t, e), e.isBefore(t) ? n = Pe(e, t) : ((n = Pe(t, e)).milliseconds = -n.milliseconds, n.months = -n.months);return n
			}(pe(a.from), pe(a.to)), (a = {}).ms = r.milliseconds, a.M = r.months), s = new ve(a), Me(e) && o(e, "_locale") && (s._locale = e._locale), s
	}
	function be(e, t) {
		var n = e && parseFloat(e.replace(",", "."));
		return (isNaN(n) ? 0 : n) * t
	}
	function Pe(e, t) {
		var n = {
			milliseconds : 0,
			months : 0
		};
		return n.months = t.month() - e.month() + 12 * (t.year() - e.year()), e.clone().add(n.months, "M").isAfter(t) && --n.months, n.milliseconds = +t - +e.clone().add(n.months, "M"), n
	}
	function We(e, t) {
		return function(n, s) {
			var i,
				r;
			return null === s || isNaN(+s) || (M(t, "moment()." + t + "(period, number) is deprecated. Please use moment()." + t + "(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."), r = n, n = s, s = r), n = "string" == typeof n ? +n : n, i = xe(n, s), He(this, i, e), this
		}
	}
	function He(t, n, s, i) {
		var r = n._milliseconds,
			a = Se(n._days),
			o = Se(n._months);
		t.isValid() && (i = null == i || i, o && z(t, A(t, "Month") + o * s), a && j(t, "Date", A(t, "Date") + a * s), r && t._d.setTime(t._d.valueOf() + r * s), i && e.updateOffset(t, a || o))
	}
	function Re(e, t) {
		var n,
			s = 12 * (t.year() - e.year()) + (t.month() - e.month()),
			i = e.clone().add(s, "months");
		return n = t - i < 0 ? (t - i) / (i - e.clone().add(s - 1, "months")) : (t - i) / (e.clone().add(s + 1, "months") - i), -(s + n) || 0
	}
	function Ce(e) {
		var t;
		return void 0 === e ? this._locale._abbr : (null != (t = ue(e)) && (this._locale = t), this)
	}
	function Fe() {
		return this._locale
	}
	function Ue(e, t) {
		P(0, [ e, e.length ], 0, t)
	}
	function Le(e, t, n, s, i) {
		var r;
		return null == e ? X(this, s, i).year : (r = K(e, s, i), t > r && (t = r), function(e, t, n, s, i) {
			var r = Q(e, t, n, s, i),
				a = J(r.year, 0, r.dayOfYear);
			return this.year(a.getUTCFullYear()), this.month(a.getUTCMonth()), this.date(a.getUTCDate()), this
		}.call(this, e, t, n, s, i))
	}
	function Ne(e, t) {
		t[Rt] = g(1e3 * ("0." + e))
	}
	function Ge(e) {
		return e
	}
	function Ve(e, t, n, s) {
		var i = ue(),
			r = l().set(s, t);
		return i[n](r, e)
	}
	function Ee(e, t, n) {
		if (i(e) && (t = e, e = void 0), e = e || "", null != t) return Ve(e, t, n, "month");
		var s,
			r = [];
		for (s = 0; s < 12; s++) r[s] = Ve(e, s, n, "month");
		return r
	}
	function Ie(e, t, n, s) {
		"boolean" == typeof e ? (i(t) && (n = t, t = void 0), t = t || "") : (n = t = e, e = !1, i(t) && (n = t, t = void 0), t = t || "");var r = ue(),
			a = e ? r._week.dow : 0;
		if (null != n) return Ve(t, (n + a) % 7, s, "day");
		var o,
			u = [];
		for (o = 0; o < 7; o++) u[o] = Ve(t, (o + a) % 7, s, "day");
		return u
	}
	function Ae(e, t, n, s) {
		var i = xe(t, n);
		return e._milliseconds += s * i._milliseconds, e._days += s * i._days, e._months += s * i._months, e._bubble()
	}
	function je(e) {
		return e < 0 ? Math.floor(e) : Math.ceil(e)
	}
	function Ze(e) {
		return 4800 * e / 146097
	}
	function ze(e) {
		return 146097 * e / 4800
	}
	function $e(e) {
		return function() {
			return this.as(e)
		}
	}
	function qe(e) {
		return function() {
			return this.isValid() ? this._data[e] : NaN
		}
	}
	function Je(e) {
		return (e > 0) - (e < 0) || +e
	}
	function Be() {
		if (!this.isValid()) return this.localeData().invalidDate();
		var e,
			t,
			n = An(this._milliseconds) / 1e3,
			s = An(this._days),
			i = An(this._months);
		t = y((e = y(n / 60)) / 60), n %= 60, e %= 60;var r = y(i / 12),
			a = i %= 12,
			o = s,
			u = t,
			l = e,
			d = n ? n.toFixed(3).replace(/\.?0+$/, "") : "",
			h = this.asSeconds();
		if (!h) return "P0D";
		var c = h < 0 ? "-" : "",
			f = Je(this._months) !== Je(h) ? "-" : "",
			m = Je(this._days) !== Je(h) ? "-" : "",
			_ = Je(this._milliseconds) !== Je(h) ? "-" : "";
		return c + "P" + (r ? f + r + "Y" : "") + (a ? f + a + "M" : "") + (o ? m + o + "D" : "") + (u || l || d ? "T" : "") + (u ? _ + u + "H" : "") + (l ? _ + l + "M" : "") + (d ? _ + d + "S" : "")
	}
	var Qe,
		Xe;
	Xe = Array.prototype.some ? Array.prototype.some : function(e) {
		for (var t = Object(this), n = t.length >>> 0, s = 0; s < n; s++)
			if (s in t && e.call(this, t[s], s, t)) return !0;
		return !1
	};
	var Ke = e.momentProperties = [],
		et = !1,
		tt = {};
	e.suppressDeprecationWarnings = !1, e.deprecationHandler = null;
	var nt;
	nt = Object.keys ? Object.keys : function(e) {
		var t,
			n = [];
		for (t in e) o(e, t) && n.push(t);
		return n
	};
	var st = {},
		it = {},
		rt = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,
		at = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
		ot = {},
		ut = {},
		lt = /\d/,
		dt = /\d\d/,
		ht = /\d{3}/,
		ct = /\d{4}/,
		ft = /[+-]?\d{6}/,
		mt = /\d\d?/,
		_t = /\d\d\d\d?/,
		yt = /\d\d\d\d\d\d?/,
		gt = /\d{1,3}/,
		pt = /\d{1,4}/,
		wt = /[+-]?\d{1,6}/,
		vt = /\d+/,
		Mt = /[+-]?\d+/,
		St = /Z|[+-]\d\d:?\d\d/gi,
		Dt = /Z|[+-]\d\d(?::?\d\d)?/gi,
		kt = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,
		Yt = {},
		Ot = {},
		Tt = 0,
		xt = 1,
		bt = 2,
		Pt = 3,
		Wt = 4,
		Ht = 5,
		Rt = 6,
		Ct = 7,
		Ft = 8;
	P("Y", 0, 0, function() {
		var e = this.year();
		return e <= 9999 ? "" + e : "+" + e
	}), P(0, [ "YY", 2 ], 0, function() {
		return this.year() % 100
	}), P(0, [ "YYYY", 4 ], 0, "year"), P(0, [ "YYYYY", 5 ], 0, "year"), P(0, [ "YYYYYY", 6, !0 ], 0, "year"), Y("year", "y"), x("year", 1), C("Y", Mt), C("YY", mt, dt), C("YYYY", pt, ct), C("YYYYY", wt, ft), C("YYYYYY", wt, ft), L([ "YYYYY", "YYYYYY" ], Tt), L("YYYY", function(t, n) {
		n[Tt] = 2 === t.length ? e.parseTwoDigitYear(t) : g(t)
	}), L("YY", function(t, n) {
		n[Tt] = e.parseTwoDigitYear(t)
	}), L("Y", function(e, t) {
		t[Tt] = parseInt(e, 10)
	}), e.parseTwoDigitYear = function(e) {
		return g(e) + (g(e) > 68 ? 1900 : 2e3)
	};
	var Ut,
		Lt = I("FullYear", !0);
	Ut = Array.prototype.indexOf ? Array.prototype.indexOf : function(e) {
		var t;
		for (t = 0; t < this.length; ++t)
			if (this[t] === e) return t;
		return -1
	}, P("M", [ "MM", 2 ], "Mo", function() {
		return this.month() + 1
	}), P("MMM", 0, 0, function(e) {
		return this.localeData().monthsShort(this, e)
	}), P("MMMM", 0, 0, function(e) {
		return this.localeData().months(this, e)
	}), Y("month", "M"), x("month", 8), C("M", mt), C("MM", mt, dt), C("MMM", function(e, t) {
		return t.monthsShortRegex(e)
	}), C("MMMM", function(e, t) {
		return t.monthsRegex(e)
	}), L([ "M", "MM" ], function(e, t) {
		t[xt] = g(e) - 1
	}), L([ "MMM", "MMMM" ], function(e, t, n, s) {
		var i = n._locale.monthsParse(e, s, n._strict);
		null != i ? t[xt] = i : d(n).invalidMonth = e
	});
	var Nt = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,
		Gt = "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
		Vt = "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),
		Et = kt,
		It = kt;
	P("w", [ "ww", 2 ], "wo", "week"), P("W", [ "WW", 2 ], "Wo", "isoWeek"), Y("week", "w"), Y("isoWeek", "W"), x("week", 5), x("isoWeek", 5), C("w", mt), C("ww", mt, dt), C("W", mt), C("WW", mt, dt), N([ "w", "ww", "W", "WW" ], function(e, t, n, s) {
		t[s.substr(0, 1)] = g(e)
	});P("d", 0, "do", "day"), P("dd", 0, 0, function(e) {
		return this.localeData().weekdaysMin(this, e)
	}), P("ddd", 0, 0, function(e) {
		return this.localeData().weekdaysShort(this, e)
	}), P("dddd", 0, 0, function(e) {
		return this.localeData().weekdays(this, e)
	}), P("e", 0, 0, "weekday"), P("E", 0, 0, "isoWeekday"), Y("day", "d"), Y("weekday", "e"), Y("isoWeekday", "E"), x("day", 11), x("weekday", 11), x("isoWeekday", 11), C("d", mt), C("e", mt), C("E", mt), C("dd", function(e, t) {
		return t.weekdaysMinRegex(e)
	}), C("ddd", function(e, t) {
		return t.weekdaysShortRegex(e)
	}), C("dddd", function(e, t) {
		return t.weekdaysRegex(e)
	}), N([ "dd", "ddd", "dddd" ], function(e, t, n, s) {
		var i = n._locale.weekdaysParse(e, s, n._strict);
		null != i ? t.d = i : d(n).invalidWeekday = e
	}), N([ "d", "e", "E" ], function(e, t, n, s) {
		t[s] = g(e)
	});
	var At = "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
		jt = "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),
		Zt = "Su_Mo_Tu_We_Th_Fr_Sa".split("_"),
		zt = kt,
		$t = kt,
		qt = kt;
	P("H", [ "HH", 2 ], 0, "hour"), P("h", [ "hh", 2 ], 0, te), P("k", [ "kk", 2 ], 0, function() {
		return this.hours() || 24
	}), P("hmm", 0, 0, function() {
		return "" + te.apply(this) + b(this.minutes(), 2)
	}), P("hmmss", 0, 0, function() {
		return "" + te.apply(this) + b(this.minutes(), 2) + b(this.seconds(), 2)
	}), P("Hmm", 0, 0, function() {
		return "" + this.hours() + b(this.minutes(), 2)
	}), P("Hmmss", 0, 0, function() {
		return "" + this.hours() + b(this.minutes(), 2) + b(this.seconds(), 2)
	}), ne("a", !0), ne("A", !1), Y("hour", "h"), x("hour", 13), C("a", se), C("A", se), C("H", mt), C("h", mt), C("k", mt), C("HH", mt, dt), C("hh", mt, dt), C("kk", mt, dt), C("hmm", _t), C("hmmss", yt), C("Hmm", _t), C("Hmmss", yt), L([ "H", "HH" ], Pt), L([ "k", "kk" ], function(e, t, n) {
		var s = g(e);
		t[Pt] = 24 === s ? 0 : s
	}), L([ "a", "A" ], function(e, t, n) {
		n._isPm = n._locale.isPM(e), n._meridiem = e
	}), L([ "h", "hh" ], function(e, t, n) {
		t[Pt] = g(e), d(n).bigHour = !0
	}), L("hmm", function(e, t, n) {
		var s = e.length - 2;
		t[Pt] = g(e.substr(0, s)), t[Wt] = g(e.substr(s)), d(n).bigHour = !0
	}), L("hmmss", function(e, t, n) {
		var s = e.length - 4,
			i = e.length - 2;
		t[Pt] = g(e.substr(0, s)), t[Wt] = g(e.substr(s, 2)), t[Ht] = g(e.substr(i)), d(n).bigHour = !0
	}), L("Hmm", function(e, t, n) {
		var s = e.length - 2;
		t[Pt] = g(e.substr(0, s)), t[Wt] = g(e.substr(s))
	}), L("Hmmss", function(e, t, n) {
		var s = e.length - 4,
			i = e.length - 2;
		t[Pt] = g(e.substr(0, s)), t[Wt] = g(e.substr(s, 2)), t[Ht] = g(e.substr(i))
	});
	var Jt,
		Bt = I("Hours", !0),
		Qt = {
			calendar : {
				sameDay : "[Today at] LT",
				nextDay : "[Tomorrow at] LT",
				nextWeek : "dddd [at] LT",
				lastDay : "[Yesterday at] LT",
				lastWeek : "[Last] dddd [at] LT",
				sameElse : "L"
			},
			longDateFormat : {
				LTS : "h:mm:ss A",
				LT : "h:mm A",
				L : "MM/DD/YYYY",
				LL : "MMMM D, YYYY",
				LLL : "MMMM D, YYYY h:mm A",
				LLLL : "dddd, MMMM D, YYYY h:mm A"
			},
			invalidDate : "Invalid date",
			ordinal : "%d",
			dayOfMonthOrdinalParse : /\d{1,2}/,
			relativeTime : {
				future : "in %s",
				past : "%s ago",
				s : "a few seconds",
				ss : "%d seconds",
				m : "a minute",
				mm : "%d minutes",
				h : "an hour",
				hh : "%d hours",
				d : "a day",
				dd : "%d days",
				M : "a month",
				MM : "%d months",
				y : "a year",
				yy : "%d years"
			},
			months : Gt,
			monthsShort : Vt,
			week : {
				dow : 0,
				doy : 6
			},
			weekdays : At,
			weekdaysMin : Zt,
			weekdaysShort : jt,
			meridiemParse : /[ap]\.?m?\.?/i
		},
		Xt = {},
		Kt = {},
		en = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
		tn = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
		nn = /Z|[+-]\d\d(?::?\d\d)?/,
		sn = [ [ "YYYYYY-MM-DD", /[+-]\d{6}-\d\d-\d\d/ ], [ "YYYY-MM-DD", /\d{4}-\d\d-\d\d/ ], [ "GGGG-[W]WW-E", /\d{4}-W\d\d-\d/ ], [ "GGGG-[W]WW", /\d{4}-W\d\d/, !1 ], [ "YYYY-DDD", /\d{4}-\d{3}/ ], [ "YYYY-MM", /\d{4}-\d\d/, !1 ], [ "YYYYYYMMDD", /[+-]\d{10}/ ], [ "YYYYMMDD", /\d{8}/ ], [ "GGGG[W]WWE", /\d{4}W\d{3}/ ], [ "GGGG[W]WW", /\d{4}W\d{2}/, !1 ], [ "YYYYDDD", /\d{7}/ ] ],
		rn = [ [ "HH:mm:ss.SSSS", /\d\d:\d\d:\d\d\.\d+/ ], [ "HH:mm:ss,SSSS", /\d\d:\d\d:\d\d,\d+/ ], [ "HH:mm:ss", /\d\d:\d\d:\d\d/ ], [ "HH:mm", /\d\d:\d\d/ ], [ "HHmmss.SSSS", /\d\d\d\d\d\d\.\d+/ ], [ "HHmmss,SSSS", /\d\d\d\d\d\d,\d+/ ], [ "HHmmss", /\d\d\d\d\d\d/ ], [ "HHmm", /\d\d\d\d/ ], [ "HH", /\d\d/ ] ],
		an = /^\/?Date\((\-?\d+)/i,
		on = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,
		un = {
			UT : 0,
			GMT : 0,
			EDT : -240,
			EST : -300,
			CDT : -300,
			CST : -360,
			MDT : -360,
			MST : -420,
			PDT : -420,
			PST : -480
		};
	e.createFromInputFallback = v("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.", function(e) {
		e._d = new Date(e._i + (e._useUTC ? " UTC" : ""))
	}), e.ISO_8601 = function() {}, e.RFC_2822 = function() {};
	var ln = v("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/", function() {
			var e = pe.apply(null, arguments);
			return this.isValid() && e.isValid() ? e < this ? this : e : c()
		}),
		dn = v("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/", function() {
			var e = pe.apply(null, arguments);
			return this.isValid() && e.isValid() ? e > this ? this : e : c()
		}),
		hn = [ "year", "quarter", "month", "week", "day", "hour", "minute", "second", "millisecond" ];
	De("Z", ":"), De("ZZ", ""), C("Z", Dt), C("ZZ", Dt), L([ "Z", "ZZ" ], function(e, t, n) {
		n._useUTC = !0, n._tzm = ke(Dt, e)
	});
	var cn = /([\+\-]|\d\d)/gi;
	e.updateOffset = function() {};
	var fn = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/,
		mn = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
	xe.fn = ve.prototype, xe.invalid = function() {
		return xe(NaN)
	};
	var _n = We(1, "add"),
		yn = We(-1, "subtract");
	e.defaultFormat = "YYYY-MM-DDTHH:mm:ssZ", e.defaultFormatUtc = "YYYY-MM-DDTHH:mm:ss[Z]";
	var gn = v("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.", function(e) {
		return void 0 === e ? this.localeData() : this.locale(e)
	});
	P(0, [ "gg", 2 ], 0, function() {
		return this.weekYear() % 100
	}), P(0, [ "GG", 2 ], 0, function() {
		return this.isoWeekYear() % 100
	}), Ue("gggg", "weekYear"), Ue("ggggg", "weekYear"), Ue("GGGG", "isoWeekYear"), Ue("GGGGG", "isoWeekYear"), Y("weekYear", "gg"), Y("isoWeekYear", "GG"), x("weekYear", 1), x("isoWeekYear", 1), C("G", Mt), C("g", Mt), C("GG", mt, dt), C("gg", mt, dt), C("GGGG", pt, ct), C("gggg", pt, ct), C("GGGGG", wt, ft), C("ggggg", wt, ft), N([ "gggg", "ggggg", "GGGG", "GGGGG" ], function(e, t, n, s) {
		t[s.substr(0, 2)] = g(e)
	}), N([ "gg", "GG" ], function(t, n, s, i) {
		n[i] = e.parseTwoDigitYear(t)
	}), P("Q", 0, "Qo", "quarter"), Y("quarter", "Q"), x("quarter", 7), C("Q", lt), L("Q", function(e, t) {
		t[xt] = 3 * (g(e) - 1)
	}), P("D", [ "DD", 2 ], "Do", "date"), Y("date", "D"), x("date", 9), C("D", mt), C("DD", mt, dt), C("Do", function(e, t) {
		return e ? t._dayOfMonthOrdinalParse || t._ordinalParse : t._dayOfMonthOrdinalParseLenient
	}), L([ "D", "DD" ], bt), L("Do", function(e, t) {
		t[bt] = g(e.match(mt)[0])
	});
	var pn = I("Date", !0);
	P("DDD", [ "DDDD", 3 ], "DDDo", "dayOfYear"), Y("dayOfYear", "DDD"), x("dayOfYear", 4), C("DDD", gt), C("DDDD", ht), L([ "DDD", "DDDD" ], function(e, t, n) {
		n._dayOfYear = g(e)
	}), P("m", [ "mm", 2 ], 0, "minute"), Y("minute", "m"), x("minute", 14), C("m", mt), C("mm", mt, dt), L([ "m", "mm" ], Wt);
	var wn = I("Minutes", !1);
	P("s", [ "ss", 2 ], 0, "second"), Y("second", "s"), x("second", 15), C("s", mt), C("ss", mt, dt), L([ "s", "ss" ], Ht);
	var vn = I("Seconds", !1);
	P("S", 0, 0, function() {
		return ~~(this.millisecond() / 100)
	}), P(0, [ "SS", 2 ], 0, function() {
		return ~~(this.millisecond() / 10)
	}), P(0, [ "SSS", 3 ], 0, "millisecond"), P(0, [ "SSSS", 4 ], 0, function() {
		return 10 * this.millisecond()
	}), P(0, [ "SSSSS", 5 ], 0, function() {
		return 100 * this.millisecond()
	}), P(0, [ "SSSSSS", 6 ], 0, function() {
		return 1e3 * this.millisecond()
	}), P(0, [ "SSSSSSS", 7 ], 0, function() {
		return 1e4 * this.millisecond()
	}), P(0, [ "SSSSSSSS", 8 ], 0, function() {
		return 1e5 * this.millisecond()
	}), P(0, [ "SSSSSSSSS", 9 ], 0, function() {
		return 1e6 * this.millisecond()
	}), Y("millisecond", "ms"), x("millisecond", 16), C("S", gt, lt), C("SS", gt, dt), C("SSS", gt, ht);
	var Mn;
	for (Mn = "SSSS"; Mn.length <= 9; Mn += "S") C(Mn, vt);
	for (Mn = "S"; Mn.length <= 9; Mn += "S") L(Mn, Ne);
	var Sn = I("Milliseconds", !1);
	P("z", 0, 0, "zoneAbbr"), P("zz", 0, 0, "zoneName");
	var Dn = m.prototype;
	Dn.add = _n, Dn.calendar = function(t, n) {
		var s = t || pe(),
			i = Ye(s, this).startOf("day"),
			r = e.calendarFormat(this, i) || "sameElse",
			a = n && (S(n[r]) ? n[r].call(this, s) : n[r]);
		return this.format(a || this.localeData().calendar(r, this, pe(s)))
	}, Dn.clone = function() {
		return new m(this)
	}, Dn.diff = function(e, t, n) {
		var s,
			i,
			r;
		if (!this.isValid()) return NaN;
		if (!(s = Ye(e, this)).isValid()) return NaN;
		switch (i = 6e4 * (s.utcOffset() - this.utcOffset()), t = O(t)) {
		case "year":
			r = Re(this, s) / 12;
			break;case "month":
			r = Re(this, s);
			break;case "quarter":
			r = Re(this, s) / 3;
			break;case "second":
			r = (this - s) / 1e3;
			break;case "minute":
			r = (this - s) / 6e4;
			break;case "hour":
			r = (this - s) / 36e5;
			break;case "day":
			r = (this - s - i) / 864e5;
			break;case "week":
			r = (this - s - i) / 6048e5;
			break;default:
			r = this - s
		}
		return n ? r : y(r)
	}, Dn.endOf = function(e) {
		return void 0 === (e = O(e)) || "millisecond" === e ? this : ("date" === e && (e = "day"), this.startOf(e).add(1, "isoWeek" === e ? "week" : e).subtract(1, "ms"))
	}, Dn.format = function(t) {
		t || (t = this.isUtc() ? e.defaultFormatUtc : e.defaultFormat);
		var n = H(this, t);
		return this.localeData().postformat(n)
	}, Dn.from = function(e, t) {
		return this.isValid() && (_(e) && e.isValid() || pe(e).isValid()) ? xe({
			to : this,
			from : e
		}).locale(this.locale()).humanize(!t) : this.localeData().invalidDate()
	}, Dn.fromNow = function(e) {
		return this.from(pe(), e)
	}, Dn.to = function(e, t) {
		return this.isValid() && (_(e) && e.isValid() || pe(e).isValid()) ? xe({
			from : this,
			to : e
		}).locale(this.locale()).humanize(!t) : this.localeData().invalidDate()
	}, Dn.toNow = function(e) {
		return this.to(pe(), e)
	}, Dn.get = function(e) {
		return e = O(e), S(this[e]) ? this[e]() : this
	}, Dn.invalidAt = function() {
		return d(this).overflow
	}, Dn.isAfter = function(e, t) {
		var n = _(e) ? e : pe(e);
		return !(!this.isValid() || !n.isValid()) && ("millisecond" === (t = O(s(t) ? "millisecond" : t)) ? this.valueOf() > n.valueOf() : n.valueOf() < this.clone().startOf(t).valueOf())
	}, Dn.isBefore = function(e, t) {
		var n = _(e) ? e : pe(e);
		return !(!this.isValid() || !n.isValid()) && ("millisecond" === (t = O(s(t) ? "millisecond" : t)) ? this.valueOf() < n.valueOf() : this.clone().endOf(t).valueOf() < n.valueOf())
	}, Dn.isBetween = function(e, t, n, s) {
		return ("(" === (s = s || "()")[0] ? this.isAfter(e, n) : !this.isBefore(e, n)) && (")" === s[1] ? this.isBefore(t, n) : !this.isAfter(t, n))
	}, Dn.isSame = function(e, t) {
		var n,
			s = _(e) ? e : pe(e);
		return !(!this.isValid() || !s.isValid()) && ("millisecond" === (t = O(t || "millisecond")) ? this.valueOf() === s.valueOf() : (n = s.valueOf(), this.clone().startOf(t).valueOf() <= n && n <= this.clone().endOf(t).valueOf()))
	}, Dn.isSameOrAfter = function(e, t) {
		return this.isSame(e, t) || this.isAfter(e, t)
	}, Dn.isSameOrBefore = function(e, t) {
		return this.isSame(e, t) || this.isBefore(e, t)
	}, Dn.isValid = function() {
		return h(this)
	}, Dn.lang = gn, Dn.locale = Ce, Dn.localeData = Fe, Dn.max = dn, Dn.min = ln, Dn.parsingFlags = function() {
		return u({}, d(this))
	}, Dn.set = function(e, t) {
		if ("object" == typeof e)
			for (var n = function(e) {
						var t = [];
						for (var n in e) t.push({
								unit : n,
								priority : it[n]
							});
						return t.sort(function(e, t) {
								return e.priority - t.priority
							}), t
					}(e = T(e)), s = 0;s < n.length; s++) this[n[s].unit](e[n[s].unit]);
		else if (e = O(e), S(this[e])) return this[e](t);
		return this
	}, Dn.startOf = function(e) {
		switch (
		e = O(e)) {
		case "year":
			this.month(0);case "quarter":
		case "month":
			this.date(1);case "week":
		case "isoWeek":
		case "day":
		case "date":
			this.hours(0);case "hour":
			this.minutes(0);case "minute":
			this.seconds(0);case "second":
			this.milliseconds(0)
		}
		return "week" === e && this.weekday(0), "isoWeek" === e && this.isoWeekday(1), "quarter" === e && this.month(3 * Math.floor(this.month() / 3)), this
	}, Dn.subtract = yn, Dn.toArray = function() {
		return [ this.year(), this.month(), this.date(), this.hour(), this.minute(), this.second(), this.millisecond() ]
	}, Dn.toObject = function() {
		return {
			years : this.year(),
			months : this.month(),
			date : this.date(),
			hours : this.hours(),
			minutes : this.minutes(),
			seconds : this.seconds(),
			milliseconds : this.milliseconds()
		}
	}, Dn.toDate = function() {
		return new Date(this.valueOf())
	}, Dn.toISOString = function(e) {
		if (!this.isValid()) return null;
		var t = !0 !== e,
			n = t ? this.clone().utc() : this;
		return n.year() < 0 || n.year() > 9999 ? H(n, t ? "YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]" : "YYYYYY-MM-DD[T]HH:mm:ss.SSSZ") : S(Date.prototype.toISOString) ? t ? this.toDate().toISOString() : new Date(this._d.valueOf()).toISOString().replace("Z", H(n, "Z")) : H(n, t ? "YYYY-MM-DD[T]HH:mm:ss.SSS[Z]" : "YYYY-MM-DD[T]HH:mm:ss.SSSZ")
	}, Dn.inspect = function() {
		if (!this.isValid()) return "moment.invalid(/* " + this._i + " */)";
		var e = "moment",
			t = "";
		this.isLocal() || (e = 0 === this.utcOffset() ? "moment.utc" : "moment.parseZone", t = "Z");
		var n = "[" + e + '("]',
			s = 0 <= this.year() && this.year() <= 9999 ? "YYYY" : "YYYYYY",
			i = t + '[")]';
		return this.format(n + s + "-MM-DD[T]HH:mm:ss.SSS" + i)
	}, Dn.toJSON = function() {
		return this.isValid() ? this.toISOString() : null
	}, Dn.toString = function() {
		return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")
	}, Dn.unix = function() {
		return Math.floor(this.valueOf() / 1e3)
	}, Dn.valueOf = function() {
		return this._d.valueOf() - 6e4 * (this._offset || 0)
	}, Dn.creationData = function() {
		return {
			input : this._i,
			format : this._f,
			locale : this._locale,
			isUTC : this._isUTC,
			strict : this._strict
		}
	}, Dn.year = Lt, Dn.isLeapYear = function() {
		return E(this.year())
	}, Dn.weekYear = function(e) {
		return Le.call(this, e, this.week(), this.weekday(), this.localeData()._week.dow, this.localeData()._week.doy)
	}, Dn.isoWeekYear = function(e) {
		return Le.call(this, e, this.isoWeek(), this.isoWeekday(), 1, 4)
	}, Dn.quarter = Dn.quarters = function(e) {
		return null == e ? Math.ceil((this.month() + 1) / 3) : this.month(3 * (e - 1) + this.month() % 3)
	}, Dn.month = $, Dn.daysInMonth = function() {
		return Z(this.year(), this.month())
	}, Dn.week = Dn.weeks = function(e) {
		var t = this.localeData().week(this);
		return null == e ? t : this.add(7 * (e - t), "d")
	}, Dn.isoWeek = Dn.isoWeeks = function(e) {
		var t = X(this, 1, 4).week;
		return null == e ? t : this.add(7 * (e - t), "d")
	}, Dn.weeksInYear = function() {
		var e = this.localeData()._week;
		return K(this.year(), e.dow, e.doy)
	}, Dn.isoWeeksInYear = function() {
		return K(this.year(), 1, 4)
	}, Dn.date = pn, Dn.day = Dn.days = function(e) {
		if (!this.isValid()) return null != e ? this : NaN;
		var t = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
		return null != e ? (e = function(e, t) {
			return "string" != typeof e ? e : isNaN(e) ? "number" == typeof (e = t.weekdaysParse(e)) ? e : null : parseInt(e, 10)
		}(e, this.localeData()), this.add(e - t, "d")) : t
	}, Dn.weekday = function(e) {
		if (!this.isValid()) return null != e ? this : NaN;
		var t = (this.day() + 7 - this.localeData()._week.dow) % 7;
		return null == e ? t : this.add(e - t, "d")
	}, Dn.isoWeekday = function(e) {
		if (!this.isValid()) return null != e ? this : NaN;
		if (null != e) {
			var t = function(e, t) {
				return "string" == typeof e ? t.weekdaysParse(e) % 7 || 7 : isNaN(e) ? null : e
			}(e, this.localeData());
			return this.day(this.day() % 7 ? t : t - 7)
		}
		return this.day() || 7
	}, Dn.dayOfYear = function(e) {
		var t = Math.round((this.clone().startOf("day") - this.clone().startOf("year")) / 864e5) + 1;
		return null == e ? t : this.add(e - t, "d")
	}, Dn.hour = Dn.hours = Bt, Dn.minute = Dn.minutes = wn, Dn.second = Dn.seconds = vn, Dn.millisecond = Dn.milliseconds = Sn, Dn.utcOffset = function(t, n, s) {
		var i,
			r = this._offset || 0;
		if (!this.isValid()) return null != t ? this : NaN;
		if (null != t) {
			if ("string" == typeof t) {
				if (null === (t = ke(Dt, t))) return this
			} else Math.abs(t) < 16 && !s && (t *= 60);
			return !this._isUTC && n && (i = Oe(this)), this._offset = t, this._isUTC = !0, null != i && this.add(i, "m"), r !== t && (!n || this._changeInProgress ? He(this, xe(t - r, "m"), 1, !1) : this._changeInProgress || (this._changeInProgress = !0, e.updateOffset(this, !0), this._changeInProgress = null)), this
		}
		return this._isUTC ? r : Oe(this)
	}, Dn.utc = function(e) {
		return this.utcOffset(0, e)
	}, Dn.local = function(e) {
		return this._isUTC && (this.utcOffset(0, e), this._isUTC = !1, e && this.subtract(Oe(this), "m")), this
	}, Dn.parseZone = function() {
		if (null != this._tzm) this.utcOffset(this._tzm, !1, !0);
		else if ("string" == typeof this._i) {
			var e = ke(St, this._i);
			null != e ? this.utcOffset(e) : this.utcOffset(0, !0)
		}
		return this
	}, Dn.hasAlignedHourOffset = function(e) {
		return !!this.isValid() && (e = e ? pe(e).utcOffset() : 0, (this.utcOffset() - e) % 60 == 0)
	}, Dn.isDST = function() {
		return this.utcOffset() > this.clone().month(0).utcOffset() || this.utcOffset() > this.clone().month(5).utcOffset()
	}, Dn.isLocal = function() {
		return !!this.isValid() && !this._isUTC
	}, Dn.isUtcOffset = function() {
		return !!this.isValid() && this._isUTC
	}, Dn.isUtc = Te, Dn.isUTC = Te, Dn.zoneAbbr = function() {
		return this._isUTC ? "UTC" : ""
	}, Dn.zoneName = function() {
		return this._isUTC ? "Coordinated Universal Time" : ""
	}, Dn.dates = v("dates accessor is deprecated. Use date instead.", pn), Dn.months = v("months accessor is deprecated. Use month instead", $), Dn.years = v("years accessor is deprecated. Use year instead", Lt), Dn.zone = v("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/", function(e, t) {
		return null != e ? ("string" != typeof e && (e = -e), this.utcOffset(e, t), this) : -this.utcOffset()
	}), Dn.isDSTShifted = v("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information", function() {
		if (!s(this._isDSTShifted)) return this._isDSTShifted;
		var e = {};
		if (f(e, this), (e = ye(e))._a) {
			var t = e._isUTC ? l(e._a) : pe(e._a);
			this._isDSTShifted = this.isValid() && p(e._a, t.toArray()) > 0
		} else
			this._isDSTShifted = !1;
		return this._isDSTShifted
	});
	var kn = k.prototype;
	kn.calendar = function(e, t, n) {
		var s = this._calendar[e] || this._calendar.sameElse;
		return S(s) ? s.call(t, n) : s
	}, kn.longDateFormat = function(e) {
		var t = this._longDateFormat[e],
			n = this._longDateFormat[e.toUpperCase()];
		return t || !n ? t : (this._longDateFormat[e] = n.replace(/MMMM|MM|DD|dddd/g, function(e) {
			return e.slice(1)
		}), this._longDateFormat[e])
	}, kn.invalidDate = function() {
		return this._invalidDate
	}, kn.ordinal = function(e) {
		return this._ordinal.replace("%d", e)
	}, kn.preparse = Ge, kn.postformat = Ge, kn.relativeTime = function(e, t, n, s) {
		var i = this._relativeTime[n];
		return S(i) ? i(e, t, n, s) : i.replace(/%d/i, e)
	}, kn.pastFuture = function(e, t) {
		var n = this._relativeTime[e > 0 ? "future" : "past"];
		return S(n) ? n(t) : n.replace(/%s/i, t)
	}, kn.set = function(e) {
		var t,
			n;
		for (n in e) S(t = e[n]) ? this[n] = t : this["_" + n] = t;
		this._config = e, this._dayOfMonthOrdinalParseLenient = new RegExp((this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + "|" + /\d{1,2}/.source)
	}, kn.months = function(e, n) {
		return e ? t(this._months) ? this._months[e.month()] : this._months[(this._months.isFormat || Nt).test(n) ? "format" : "standalone"][e.month()] : t(this._months) ? this._months : this._months.standalone
	}, kn.monthsShort = function(e, n) {
		return e ? t(this._monthsShort) ? this._monthsShort[e.month()] : this._monthsShort[Nt.test(n) ? "format" : "standalone"][e.month()] : t(this._monthsShort) ? this._monthsShort : this._monthsShort.standalone
	}, kn.monthsParse = function(e, t, n) {
		var s,
			i,
			r;
		if (this._monthsParseExact) return function(e, t, n) {
				var s,
					i,
					r,
					a = e.toLocaleLowerCase();
				if (!this._monthsParse)
					for (this._monthsParse = [], this._longMonthsParse = [], this._shortMonthsParse = [], s = 0; s < 12; ++s) r = l([ 2e3, s ]), this._shortMonthsParse[s] = this.monthsShort(r, "").toLocaleLowerCase(), this._longMonthsParse[s] = this.months(r, "").toLocaleLowerCase();
				return n ? "MMM" === t ? -1 !== (i = Ut.call(this._shortMonthsParse, a)) ? i : null : -1 !== (i = Ut.call(this._longMonthsParse, a)) ? i : null : "MMM" === t ? -1 !== (i = Ut.call(this._shortMonthsParse, a)) ? i : -1 !== (i = Ut.call(this._longMonthsParse, a)) ? i : null : -1 !== (i = Ut.call(this._longMonthsParse, a)) ? i : -1 !== (i = Ut.call(this._shortMonthsParse, a)) ? i : null
			}.call(this, e, t, n);
		for (this._monthsParse || (this._monthsParse = [], this._longMonthsParse = [], this._shortMonthsParse = []), s = 0; s < 12; s++) {
			if (i = l([ 2e3, s ]), n && !this._longMonthsParse[s] && (this._longMonthsParse[s] = new RegExp("^" + this.months(i, "").replace(".", "") + "$", "i"), this._shortMonthsParse[s] = new RegExp("^" + this.monthsShort(i, "").replace(".", "") + "$", "i")), n || this._monthsParse[s] || (r = "^" + this.months(i, "") + "|^" + this.monthsShort(i, ""), this._monthsParse[s] = new RegExp(r.replace(".", ""), "i")), n && "MMMM" === t && this._longMonthsParse[s].test(e)) return s;
			if (n && "MMM" === t && this._shortMonthsParse[s].test(e)) return s;
			if (!n && this._monthsParse[s].test(e)) return s
		}
	}, kn.monthsRegex = function(e) {
		return this._monthsParseExact ? (o(this, "_monthsRegex") || q.call(this), e ? this._monthsStrictRegex : this._monthsRegex) : (o(this, "_monthsRegex") || (this._monthsRegex = It), this._monthsStrictRegex && e ? this._monthsStrictRegex : this._monthsRegex)
	}, kn.monthsShortRegex = function(e) {
		return this._monthsParseExact ? (o(this, "_monthsRegex") || q.call(this), e ? this._monthsShortStrictRegex : this._monthsShortRegex) : (o(this, "_monthsShortRegex") || (this._monthsShortRegex = Et), this._monthsShortStrictRegex && e ? this._monthsShortStrictRegex : this._monthsShortRegex)
	}, kn.week = function(e) {
		return X(e, this._week.dow, this._week.doy).week
	}, kn.firstDayOfYear = function() {
		return this._week.doy
	}, kn.firstDayOfWeek = function() {
		return this._week.dow
	}, kn.weekdays = function(e, n) {
		return e ? t(this._weekdays) ? this._weekdays[e.day()] : this._weekdays[this._weekdays.isFormat.test(n) ? "format" : "standalone"][e.day()] : t(this._weekdays) ? this._weekdays : this._weekdays.standalone
	}, kn.weekdaysMin = function(e) {
		return e ? this._weekdaysMin[e.day()] : this._weekdaysMin
	}, kn.weekdaysShort = function(e) {
		return e ? this._weekdaysShort[e.day()] : this._weekdaysShort
	}, kn.weekdaysParse = function(e, t, n) {
		var s,
			i,
			r;
		if (this._weekdaysParseExact) return function(e, t, n) {
				var s,
					i,
					r,
					a = e.toLocaleLowerCase();
				if (!this._weekdaysParse)
					for (this._weekdaysParse = [], this._shortWeekdaysParse = [], this._minWeekdaysParse = [], s = 0; s < 7; ++s) r = l([ 2e3, 1 ]).day(s), this._minWeekdaysParse[s] = this.weekdaysMin(r, "").toLocaleLowerCase(), this._shortWeekdaysParse[s] = this.weekdaysShort(r, "").toLocaleLowerCase(), this._weekdaysParse[s] = this.weekdays(r, "").toLocaleLowerCase();
				return n ? "dddd" === t ? -1 !== (i = Ut.call(this._weekdaysParse, a)) ? i : null : "ddd" === t ? -1 !== (i = Ut.call(this._shortWeekdaysParse, a)) ? i : null : -1 !== (i = Ut.call(this._minWeekdaysParse, a)) ? i : null : "dddd" === t ? -1 !== (i = Ut.call(this._weekdaysParse, a)) ? i : -1 !== (i = Ut.call(this._shortWeekdaysParse, a)) ? i : -1 !== (i = Ut.call(this._minWeekdaysParse, a)) ? i : null : "ddd" === t ? -1 !== (i = Ut.call(this._shortWeekdaysParse, a)) ? i : -1 !== (i = Ut.call(this._weekdaysParse, a)) ? i : -1 !== (i = Ut.call(this._minWeekdaysParse, a)) ? i : null : -1 !== (i = Ut.call(this._minWeekdaysParse, a)) ? i : -1 !== (i = Ut.call(this._weekdaysParse, a)) ? i : -1 !== (i = Ut.call(this._shortWeekdaysParse, a)) ? i : null
			}.call(this, e, t, n);
		for (this._weekdaysParse || (this._weekdaysParse = [], this._minWeekdaysParse = [], this._shortWeekdaysParse = [], this._fullWeekdaysParse = []), s = 0; s < 7; s++) {
			if (i = l([ 2e3, 1 ]).day(s), n && !this._fullWeekdaysParse[s] && (this._fullWeekdaysParse[s] = new RegExp("^" + this.weekdays(i, "").replace(".", ".?") + "$", "i"), this._shortWeekdaysParse[s] = new RegExp("^" + this.weekdaysShort(i, "").replace(".", ".?") + "$", "i"), this._minWeekdaysParse[s] = new RegExp("^" + this.weekdaysMin(i, "").replace(".", ".?") + "$", "i")), this._weekdaysParse[s] || (r = "^" + this.weekdays(i, "") + "|^" + this.weekdaysShort(i, "") + "|^" + this.weekdaysMin(i, ""), this._weekdaysParse[s] = new RegExp(r.replace(".", ""), "i")), n && "dddd" === t && this._fullWeekdaysParse[s].test(e)) return s;
			if (n && "ddd" === t && this._shortWeekdaysParse[s].test(e)) return s;
			if (n && "dd" === t && this._minWeekdaysParse[s].test(e)) return s;
			if (!n && this._weekdaysParse[s].test(e)) return s
		}
	}, kn.weekdaysRegex = function(e) {
		return this._weekdaysParseExact ? (o(this, "_weekdaysRegex") || ee.call(this), e ? this._weekdaysStrictRegex : this._weekdaysRegex) : (o(this, "_weekdaysRegex") || (this._weekdaysRegex = zt), this._weekdaysStrictRegex && e ? this._weekdaysStrictRegex : this._weekdaysRegex)
	}, kn.weekdaysShortRegex = function(e) {
		return this._weekdaysParseExact ? (o(this, "_weekdaysRegex") || ee.call(this), e ? this._weekdaysShortStrictRegex : this._weekdaysShortRegex) : (o(this, "_weekdaysShortRegex") || (this._weekdaysShortRegex = $t), this._weekdaysShortStrictRegex && e ? this._weekdaysShortStrictRegex : this._weekdaysShortRegex)
	}, kn.weekdaysMinRegex = function(e) {
		return this._weekdaysParseExact ? (o(this, "_weekdaysRegex") || ee.call(this), e ? this._weekdaysMinStrictRegex : this._weekdaysMinRegex) : (o(this, "_weekdaysMinRegex") || (this._weekdaysMinRegex = qt), this._weekdaysMinStrictRegex && e ? this._weekdaysMinStrictRegex : this._weekdaysMinRegex)
	}, kn.isPM = function(e) {
		return "p" === (e + "").toLowerCase().charAt(0)
	}, kn.meridiem = function(e, t, n) {
		return e > 11 ? n ? "pm" : "PM" : n ? "am" : "AM"
	}, ae("en", {
		dayOfMonthOrdinalParse : /\d{1,2}(th|st|nd|rd)/,
		ordinal : function(e) {
			var t = e % 10;
			return e + (1 === g(e % 100 / 10) ? "th" : 1 === t ? "st" : 2 === t ? "nd" : 3 === t ? "rd" : "th")
		}
	}), e.lang = v("moment.lang is deprecated. Use moment.locale instead.", ae), e.langData = v("moment.langData is deprecated. Use moment.localeData instead.", ue);
	var Yn = Math.abs,
		On = $e("ms"),
		Tn = $e("s"),
		xn = $e("m"),
		bn = $e("h"),
		Pn = $e("d"),
		Wn = $e("w"),
		Hn = $e("M"),
		Rn = $e("y"),
		Cn = qe("milliseconds"),
		Fn = qe("seconds"),
		Un = qe("minutes"),
		Ln = qe("hours"),
		Nn = qe("days"),
		Gn = qe("months"),
		Vn = qe("years"),
		En = Math.round,
		In = {
			ss : 44,
			s : 45,
			m : 45,
			h : 22,
			d : 26,
			M : 11
		},
		An = Math.abs,
		jn = ve.prototype;
	return jn.isValid = function() {
			return this._isValid
		}, jn.abs = function() {
			var e = this._data;
			return this._milliseconds = Yn(this._milliseconds), this._days = Yn(this._days), this._months = Yn(this._months), e.milliseconds = Yn(e.milliseconds), e.seconds = Yn(e.seconds), e.minutes = Yn(e.minutes), e.hours = Yn(e.hours), e.months = Yn(e.months), e.years = Yn(e.years), this
		}, jn.add = function(e, t) {
			return Ae(this, e, t, 1)
		}, jn.subtract = function(e, t) {
			return Ae(this, e, t, -1)
		}, jn.as = function(e) {
			if (!this.isValid()) return NaN;
			var t,
				n,
				s = this._milliseconds;
			if ("month" === (e = O(e)) || "year" === e) return t = this._days + s / 864e5, n = this._months + Ze(t), "month" === e ? n : n / 12;
			switch (t = this._days + Math.round(ze(this._months)), e) {
			case "week":
				return t / 7 + s / 6048e5;case "day":
				return t + s / 864e5;case "hour":
				return 24 * t + s / 36e5;case "minute":
				return 1440 * t + s / 6e4;case "second":
				return 86400 * t + s / 1e3;case "millisecond":
				return Math.floor(864e5 * t) + s;default:
				throw new Error("Unknown unit " + e)
			}
		}, jn.asMilliseconds = On, jn.asSeconds = Tn, jn.asMinutes = xn, jn.asHours = bn, jn.asDays = Pn, jn.asWeeks = Wn, jn.asMonths = Hn, jn.asYears = Rn, jn.valueOf = function() {
			return this.isValid() ? this._milliseconds + 864e5 * this._days + this._months % 12 * 2592e6 + 31536e6 * g(this._months / 12) : NaN
		}, jn._bubble = function() {
			var e,
				t,
				n,
				s,
				i,
				r = this._milliseconds,
				a = this._days,
				o = this._months,
				u = this._data;
			return r >= 0 && a >= 0 && o >= 0 || r <= 0 && a <= 0 && o <= 0 || (r += 864e5 * je(ze(o) + a), a = 0, o = 0), u.milliseconds = r % 1e3, e = y(r / 1e3), u.seconds = e % 60, t = y(e / 60), u.minutes = t % 60, n = y(t / 60), u.hours = n % 24, a += y(n / 24), i = y(Ze(a)), o += i, a -= je(ze(i)), s = y(o / 12), o %= 12, u.days = a, u.months = o, u.years = s, this
		}, jn.clone = function() {
			return xe(this)
		}, jn.get = function(e) {
			return e = O(e), this.isValid() ? this[e + "s"]() : NaN
		}, jn.milliseconds = Cn, jn.seconds = Fn, jn.minutes = Un, jn.hours = Ln, jn.days = Nn, jn.weeks = function() {
			return y(this.days() / 7)
		}, jn.months = Gn, jn.years = Vn, jn.humanize = function(e) {
			if (!this.isValid()) return this.localeData().invalidDate();
			var t = this.localeData(),
				n = function(e, t, n) {
					var s = xe(e).abs(),
						i = En(s.as("s")),
						r = En(s.as("m")),
						a = En(s.as("h")),
						o = En(s.as("d")),
						u = En(s.as("M")),
						l = En(s.as("y")),
						d = i <= In.ss && [ "s", i ] || i < In.s && [ "ss", i ] || r <= 1 && [ "m" ] || r < In.m && [ "mm", r ] || a <= 1 && [ "h" ] || a < In.h && [ "hh", a ] || o <= 1 && [ "d" ] || o < In.d && [ "dd", o ] || u <= 1 && [ "M" ] || u < In.M && [ "MM", u ] || l <= 1 && [ "y" ] || [ "yy", l ];
					return d[2] = t, d[3] = +e > 0, d[4] = n, function(e, t, n, s, i) {
							return i.relativeTime(t || 1, !!n, e, s)
						}.apply(null, d)
				}(this, !e, t);
			return e && (n = t.pastFuture(+this, n)), t.postformat(n)
		}, jn.toISOString = Be, jn.toString = Be, jn.toJSON = Be, jn.locale = Ce, jn.localeData = Fe, jn.toIsoString = v("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)", Be), jn.lang = gn, P("X", 0, 0, "unix"), P("x", 0, 0, "valueOf"), C("x", Mt), C("X", /[+-]?\d+(\.\d{1,3})?/), L("X", function(e, t, n) {
			n._d = new Date(1e3 * parseFloat(e, 10))
		}), L("x", function(e, t, n) {
			n._d = new Date(g(e))
		}), e.version = "2.20.1", function(e) {
			Qe = e
		}(pe), e.fn = Dn, e.min = function() {
			return we("isBefore", [].slice.call(arguments, 0))
		}, e.max = function() {
			return we("isAfter", [].slice.call(arguments, 0))
		}, e.now = function() {
			return Date.now ? Date.now() : +new Date
		}, e.utc = l, e.unix = function(e) {
			return pe(1e3 * e)
		}, e.months = function(e, t) {
			return Ee(e, t, "months")
		}, e.isDate = r, e.locale = ae, e.invalid = c, e.duration = xe, e.isMoment = _, e.weekdays = function(e, t, n) {
			return Ie(e, t, n, "weekdays")
		}, e.parseZone = function() {
			return pe.apply(null, arguments).parseZone()
		}, e.localeData = ue, e.isDuration = Me, e.monthsShort = function(e, t) {
			return Ee(e, t, "monthsShort")
		}, e.weekdaysMin = function(e, t, n) {
			return Ie(e, t, n, "weekdaysMin")
		}, e.defineLocale = oe, e.updateLocale = function(e, t) {
			if (null != t) {
				var n,
					s,
					i = Qt;
				null != (s = re(e)) && (i = s._config), (n = new k(t = D(i, t))).parentLocale = Xt[e], Xt[e] = n, ae(e)
			} else null != Xt[e] && (null != Xt[e].parentLocale ? Xt[e] = Xt[e].parentLocale : null != Xt[e] &&
				delete Xt[e]
				);
			return Xt[e]
		}, e.locales = function() {
			return nt(Xt)
		}, e.weekdaysShort = function(e, t, n) {
			return Ie(e, t, n, "weekdaysShort")
		}, e.normalizeUnits = O, e.relativeTimeRounding = function(e) {
			return void 0 === e ? En : "function" == typeof e && (En = e, !0)
		}, e.relativeTimeThreshold = function(e, t) {
			return void 0 !== In[e] && (void 0 === t ? In[e] : (In[e] = t, "s" === e && (In.ss = t - 1), !0))
		}, e.calendarFormat = function(e, t) {
			var n = e.diff(t, "days", !0);
			return n < -6 ? "sameElse" : n < -1 ? "lastWeek" : n < 0 ? "lastDay" : n < 1 ? "sameDay" : n < 2 ? "nextDay" : n < 7 ? "nextWeek" : "sameElse"
		}, e.prototype = Dn, e.HTML5_FMT = {
			DATETIME_LOCAL : "YYYY-MM-DDTHH:mm",
			DATETIME_LOCAL_SECONDS : "YYYY-MM-DDTHH:mm:ss",
			DATETIME_LOCAL_MS : "YYYY-MM-DDTHH:mm:ss.SSS",
			DATE : "YYYY-MM-DD",
			TIME : "HH:mm",
			TIME_SECONDS : "HH:mm:ss",
			TIME_MS : "HH:mm:ss.SSS",
			WEEK : "YYYY-[W]WW",
			MONTH : "YYYY-MM"
		}, e
});
/*
 * jQuery Bootstrap Pagination v1.4.1
 * https://github.com/esimakin/twbs-pagination
 *
 * Copyright 2014-2016, Eugene Simakin <john-24@list.ru>
 * Released under Apache-2.0 license
 * http://apache.org/licenses/LICENSE-2.0.html
 */
!function(a,b,c,d){"use strict";var e=a.fn.twbsPagination,f=function(b,c){if(this.$element=a(b),this.options=a.extend({},a.fn.twbsPagination.defaults,c),this.options.startPage<1||this.options.startPage>this.options.totalPages)throw new Error("Start page option is incorrect");if(this.options.totalPages=parseInt(this.options.totalPages),isNaN(this.options.totalPages))throw new Error("Total pages option is not correct!");if(this.options.visiblePages=parseInt(this.options.visiblePages),isNaN(this.options.visiblePages))throw new Error("Visible pages option is not correct!");if(this.options.onPageClick instanceof Function&&this.$element.first().on("page",this.options.onPageClick),this.options.hideOnlyOnePage&&1==this.options.totalPages)return this.$element.trigger("page",1),this;this.options.totalPages<this.options.visiblePages&&(this.options.visiblePages=this.options.totalPages),this.options.href&&(this.options.startPage=this.getPageFromQueryString(),this.options.startPage||(this.options.startPage=1));var d="function"==typeof this.$element.prop?this.$element.prop("tagName"):this.$element.attr("tagName");return"UL"===d?this.$listContainer=this.$element:this.$listContainer=a("<ul></ul>"),this.$listContainer.addClass(this.options.paginationClass),"UL"!==d&&this.$element.append(this.$listContainer),this.options.initiateStartPageClick?this.show(this.options.startPage):(this.currentPage=this.options.startPage,this.render(this.getPages(this.options.startPage)),this.setupEvents()),this};f.prototype={constructor:f,destroy:function(){return this.$element.empty(),this.$element.removeData("twbs-pagination"),this.$element.off("page"),this},show:function(a){if(a<1||a>this.options.totalPages)throw new Error("Page is incorrect.");return this.currentPage=a,this.render(this.getPages(a)),this.setupEvents(),this.$element.trigger("page",a),this},enable:function(){this.show(this.currentPage)},disable:function(){var b=this;this.$listContainer.off("click").on("click","li",function(a){a.preventDefault()}),this.$listContainer.children().each(function(){var c=a(this);c.hasClass(b.options.activeClass)||a(this).addClass(b.options.disabledClass)})},buildListItems:function(a){var b=[];if(this.options.first&&b.push(this.buildItem("first",1)),this.options.prev){var c=a.currentPage>1?a.currentPage-1:this.options.loop?this.options.totalPages:1;b.push(this.buildItem("prev",c))}for(var d=0;d<a.numeric.length;d++)b.push(this.buildItem("page",a.numeric[d]));if(this.options.next){var e=a.currentPage<this.options.totalPages?a.currentPage+1:this.options.loop?1:this.options.totalPages;b.push(this.buildItem("next",e))}return this.options.last&&b.push(this.buildItem("last",this.options.totalPages)),b},buildItem:function(b,c){var d=a("<li></li>"),e=a("<a></a>"),f=this.options[b]?this.makeText(this.options[b],c):c;return d.addClass(this.options[b+"Class"]),d.data("page",c),d.data("page-type",b),d.append(e.attr("href",this.makeHref(c)).addClass(this.options.anchorClass).html(f)),d},getPages:function(a){var b=[],c=Math.floor(this.options.visiblePages/2),d=a-c+1-this.options.visiblePages%2,e=a+c;d<=0&&(d=1,e=this.options.visiblePages),e>this.options.totalPages&&(d=this.options.totalPages-this.options.visiblePages+1,e=this.options.totalPages);for(var f=d;f<=e;)b.push(f),f++;return{currentPage:a,numeric:b}},render:function(b){var c=this;this.$listContainer.children().remove();var d=this.buildListItems(b);a.each(d,function(a,b){c.$listContainer.append(b)}),this.$listContainer.children().each(function(){var d=a(this),e=d.data("page-type");switch(e){case"page":d.data("page")===b.currentPage&&d.addClass(c.options.activeClass);break;case"first":d.toggleClass(c.options.disabledClass,1===b.currentPage);break;case"last":d.toggleClass(c.options.disabledClass,b.currentPage===c.options.totalPages);break;case"prev":d.toggleClass(c.options.disabledClass,!c.options.loop&&1===b.currentPage);break;case"next":d.toggleClass(c.options.disabledClass,!c.options.loop&&b.currentPage===c.options.totalPages)}})},setupEvents:function(){var b=this;this.$listContainer.off("click").on("click","li",function(c){var d=a(this);return!d.hasClass(b.options.disabledClass)&&!d.hasClass(b.options.activeClass)&&(!b.options.href&&c.preventDefault(),void b.show(parseInt(d.data("page"))))})},makeHref:function(a){return this.options.href?this.generateQueryString(a):"#"},makeText:function(a,b){return a.replace(this.options.pageVariable,b).replace(this.options.totalPagesVariable,this.options.totalPages)},getPageFromQueryString:function(a){var b=this.getSearchString(a),c=new RegExp(this.options.pageVariable+"(=([^&#]*)|&|#|$)"),d=c.exec(b);return d&&d[2]?(d=decodeURIComponent(d[2]),d=parseInt(d),isNaN(d)?null:d):null},generateQueryString:function(a,b){var c=this.getSearchString(b),d=new RegExp(this.options.pageVariable+"=*[^&#]*");return c?"?"+c.replace(d,this.options.pageVariable+"="+a):""},getSearchString:function(a){var c=a||b.location.search;return""===c?null:(0===c.indexOf("?")&&(c=c.substr(1)),c)},getCurrentPage:function(){return this.currentPage}},a.fn.twbsPagination=function(b){var c,e=Array.prototype.slice.call(arguments,1),g=a(this),h=g.data("twbs-pagination"),i="object"==typeof b?b:{};return h||g.data("twbs-pagination",h=new f(this,i)),"string"==typeof b&&(c=h[b].apply(h,e)),c===d?g:c},a.fn.twbsPagination.defaults={totalPages:1,startPage:1,visiblePages:5,initiateStartPageClick:!0,hideOnlyOnePage:!1,href:!1,pageVariable:"{{page}}",totalPagesVariable:"{{total_pages}}",page:null,first:"First",prev:"Previous",next:"Next",last:"Last",loop:!1,onPageClick:null,paginationClass:"pagination",nextClass:"page-item next",prevClass:"page-item prev",lastClass:"page-item last",firstClass:"page-item first",pageClass:"page-item",activeClass:"active",disabledClass:"disabled",anchorClass:"page-link"},a.fn.twbsPagination.Constructor=f,a.fn.twbsPagination.noConflict=function(){return a.fn.twbsPagination=e,this},a.fn.twbsPagination.version="1.4.1"}(window.jQuery,window,document);
/**
* @version: 2.1.25
* @author: Dan Grossman http://www.dangrossman.info/
* @copyright: Copyright (c) 2012-2017 Dan Grossman. All rights reserved.
* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
* @website: https://www.daterangepicker.com/
*/
// Follow the UMD template https://github.com/umdjs/umd/blob/master/templates/returnExportsGlobal.js
(function (root, factory) {
    // Browser globals
    root.daterangepicker = factory(root.moment, root.jQuery);
}(this, function(moment, $) {
    var DateRangePicker = function(element, options, cb) {

        //default settings for options
        this.parentEl = 'body';
        this.element = $(element);
        this.startDate = moment().startOf('day');
        this.endDate = moment().endOf('day');
        this.minDate = false;
        this.maxDate = false;
        this.dateLimit = false;
        this.autoApply = false;
        this.singleDatePicker = false;
        this.showDropdowns = false;
        this.showWeekNumbers = false;
        this.showISOWeekNumbers = false;
        this.showCustomRangeLabel = true;
        this.timePicker = false;
        this.timePicker24Hour = false;
        this.timePickerIncrement = 1;
        this.timePickerSeconds = false;
        this.linkedCalendars = true;
        this.autoUpdateInput = true;
        this.alwaysShowCalendars = false;
        this.ranges = {};

        this.opens = 'right';
        if (this.element.hasClass('pull-right'))
            this.opens = 'left';

        this.drops = 'down';
        if (this.element.hasClass('dropup'))
            this.drops = 'up';

        this.buttonClasses = 'btn btn-sm';
        this.applyClass = 'btn-success';
        this.cancelClass = 'btn-default';

        this.locale = {
            direction: 'ltr',
            format: moment.localeData().longDateFormat('L'),
            separator: ' - ',
            applyLabel: 'Apply',
            cancelLabel: 'Cancel',
            weekLabel: 'W',
            customRangeLabel: 'Custom Range',
            daysOfWeek: moment.weekdaysMin(),
            monthNames: moment.monthsShort(),
            firstDay: moment.localeData().firstDayOfWeek()
        };

        this.callback = function() { };

        //some state information
        this.isShowing = false;
        this.leftCalendar = {};
        this.rightCalendar = {};

        //custom options from user
        if (typeof options !== 'object' || options === null)
            options = {};

        //allow setting options with data attributes
        //data-api options will be overwritten with custom javascript options
        options = $.extend(this.element.data(), options);

        //html template for the picker UI
        if (typeof options.template !== 'string' && !(options.template instanceof $))
            options.template = '<div class="daterangepicker dropdown-menu">' +
                '<div class="calendar left">' +
                    '<div class="daterangepicker_input">' +
                      '<input class="input-mini form-control" type="text" name="daterangepicker_start" value="" />' +
                      '<i class="icon-calendar icon-calendar"></i>' +
                      '<div class="calendar-time">' +
                        '<div></div>' +
                        '<i class="icon-clock-o icon-time"></i>' +
                      '</div>' +
                    '</div>' +
                    '<div class="calendar-table"></div>' +
                '</div>' +
                '<div class="calendar right">' +
                    '<div class="daterangepicker_input">' +
                      '<input class="input-mini form-control" type="text" name="daterangepicker_end" value="" />' +
                      '<i class="icon-calendar icon-calendar"></i>' +
                      '<div class="calendar-time">' +
                        '<div></div>' +
                        '<i class="icon-clock-o icon-time"></i>' +
                      '</div>' +
                    '</div>' +
                    '<div class="calendar-table"></div>' +
                '</div>' +
                '<div class="ranges">' +
                    '<div class="range_inputs">' +
                        '<button class="applyBtn" disabled="disabled" type="button"></button> ' +
                        '<button class="cancelBtn" type="button"></button>' +
                    '</div>' +
                '</div>' +
            '</div>';

        this.parentEl = (options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl);
        this.container = $(options.template).appendTo(this.parentEl);

        //
        // handle all the possible options overriding defaults
        //

        if (typeof options.locale === 'object') {

            if (typeof options.locale.direction === 'string')
                this.locale.direction = options.locale.direction;

            if (typeof options.locale.format === 'string')
                this.locale.format = options.locale.format;

            if (typeof options.locale.separator === 'string')
                this.locale.separator = options.locale.separator;

            if (typeof options.locale.daysOfWeek === 'object')
                this.locale.daysOfWeek = options.locale.daysOfWeek.slice();

            if (typeof options.locale.monthNames === 'object')
              this.locale.monthNames = options.locale.monthNames.slice();

            if (typeof options.locale.firstDay === 'number')
              this.locale.firstDay = options.locale.firstDay;

            if (typeof options.locale.applyLabel === 'string')
              this.locale.applyLabel = options.locale.applyLabel;

            if (typeof options.locale.cancelLabel === 'string')
              this.locale.cancelLabel = options.locale.cancelLabel;

            if (typeof options.locale.weekLabel === 'string')
              this.locale.weekLabel = options.locale.weekLabel;

            if (typeof options.locale.customRangeLabel === 'string'){
                //Support unicode chars in the custom range name.
                var elem = document.createElement('textarea');
                elem.innerHTML = options.locale.customRangeLabel;
                var rangeHtml = elem.value;
                this.locale.customRangeLabel = rangeHtml;
            }
        }
        this.container.addClass(this.locale.direction);

        if (typeof options.startDate === 'string')
            this.startDate = moment(options.startDate, this.locale.format);

        if (typeof options.endDate === 'string')
            this.endDate = moment(options.endDate, this.locale.format);

        if (typeof options.minDate === 'string')
            this.minDate = moment(options.minDate, this.locale.format);

        if (typeof options.maxDate === 'string')
            this.maxDate = moment(options.maxDate, this.locale.format);

        if (typeof options.startDate === 'object')
            this.startDate = moment(options.startDate);

        if (typeof options.endDate === 'object')
            this.endDate = moment(options.endDate);

        if (typeof options.minDate === 'object')
            this.minDate = moment(options.minDate);

        if (typeof options.maxDate === 'object')
            this.maxDate = moment(options.maxDate);

        // sanity check for bad options
        if (this.minDate && this.startDate.isBefore(this.minDate))
            this.startDate = this.minDate.clone();

        // sanity check for bad options
        if (this.maxDate && this.endDate.isAfter(this.maxDate))
            this.endDate = this.maxDate.clone();

        if (typeof options.applyClass === 'string')
            this.applyClass = options.applyClass;

        if (typeof options.cancelClass === 'string')
            this.cancelClass = options.cancelClass;

        if (typeof options.dateLimit === 'object')
            this.dateLimit = options.dateLimit;

        if (typeof options.opens === 'string')
            this.opens = options.opens;

        if (typeof options.drops === 'string')
            this.drops = options.drops;

        if (typeof options.showWeekNumbers === 'boolean')
            this.showWeekNumbers = options.showWeekNumbers;

        if (typeof options.showISOWeekNumbers === 'boolean')
            this.showISOWeekNumbers = options.showISOWeekNumbers;

        if (typeof options.buttonClasses === 'string')
            this.buttonClasses = options.buttonClasses;

        if (typeof options.buttonClasses === 'object')
            this.buttonClasses = options.buttonClasses.join(' ');

        if (typeof options.showDropdowns === 'boolean')
            this.showDropdowns = options.showDropdowns;

        if (typeof options.showCustomRangeLabel === 'boolean')
            this.showCustomRangeLabel = options.showCustomRangeLabel;

        if (typeof options.singleDatePicker === 'boolean') {
            this.singleDatePicker = options.singleDatePicker;
            if (this.singleDatePicker)
                this.endDate = this.startDate.clone();
        }

        if (typeof options.timePicker === 'boolean')
            this.timePicker = options.timePicker;

        if (typeof options.timePickerSeconds === 'boolean')
            this.timePickerSeconds = options.timePickerSeconds;

        if (typeof options.timePickerIncrement === 'number')
            this.timePickerIncrement = options.timePickerIncrement;

        if (typeof options.timePicker24Hour === 'boolean')
            this.timePicker24Hour = options.timePicker24Hour;

        if (typeof options.autoApply === 'boolean')
            this.autoApply = options.autoApply;

        if (typeof options.autoUpdateInput === 'boolean')
            this.autoUpdateInput = options.autoUpdateInput;

        if (typeof options.linkedCalendars === 'boolean')
            this.linkedCalendars = options.linkedCalendars;

        if (typeof options.isInvalidDate === 'function')
            this.isInvalidDate = options.isInvalidDate;

        if (typeof options.isCustomDate === 'function')
            this.isCustomDate = options.isCustomDate;

        if (typeof options.alwaysShowCalendars === 'boolean')
            this.alwaysShowCalendars = options.alwaysShowCalendars;

        // update day names order to firstDay
        if (this.locale.firstDay != 0) {
            var iterator = this.locale.firstDay;
            while (iterator > 0) {
                this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift());
                iterator--;
            }
        }

        var start, end, range;

        //if no start/end dates set, check if an input element contains initial values
        if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') {
            if ($(this.element).is('input[type=text]')) {
                var val = $(this.element).val(),
                    split = val.split(this.locale.separator);

                start = end = null;

                if (split.length == 2) {
                    start = moment(split[0], this.locale.format);
                    end = moment(split[1], this.locale.format);
                } else if (this.singleDatePicker && val !== "") {
                    start = moment(val, this.locale.format);
                    end = moment(val, this.locale.format);
                }
                if (start !== null && end !== null) {
                    this.setStartDate(start);
                    this.setEndDate(end);
                }
            }
        }

        if (typeof options.ranges === 'object') {
            for (range in options.ranges) {

                if (typeof options.ranges[range][0] === 'string')
                    start = moment(options.ranges[range][0], this.locale.format);
                else
                    start = moment(options.ranges[range][0]);

                if (typeof options.ranges[range][1] === 'string')
                    end = moment(options.ranges[range][1], this.locale.format);
                else
                    end = moment(options.ranges[range][1]);

                // If the start or end date exceed those allowed by the minDate or dateLimit
                // options, shorten the range to the allowable period.
                if (this.minDate && start.isBefore(this.minDate))
                    start = this.minDate.clone();

                var maxDate = this.maxDate;
                if (this.dateLimit && maxDate && start.clone().add(this.dateLimit).isAfter(maxDate))
                    maxDate = start.clone().add(this.dateLimit);
                if (maxDate && end.isAfter(maxDate))
                    end = maxDate.clone();

                // If the end of the range is before the minimum or the start of the range is
                // after the maximum, don't display this range option at all.
                if ((this.minDate && end.isBefore(this.minDate, this.timepicker ? 'minute' : 'day')) 
                  || (maxDate && start.isAfter(maxDate, this.timepicker ? 'minute' : 'day')))
                    continue;

                //Support unicode chars in the range names.
                var elem = document.createElement('textarea');
                elem.innerHTML = range;
                var rangeHtml = elem.value;

                this.ranges[rangeHtml] = [start, end];
            }

            var list = '<ul>';
            for (range in this.ranges) {
                list += '<li data-range-key="' + range + '">' + range + '</li>';
            }
            if (this.showCustomRangeLabel) {
                list += '<li data-range-key="' + this.locale.customRangeLabel + '">' + this.locale.customRangeLabel + '</li>';
            }
            list += '</ul>';
            this.container.find('.ranges').prepend(list);
        }

        if (typeof cb === 'function') {
            this.callback = cb;
        }

        if (!this.timePicker) {
            this.startDate = this.startDate.startOf('day');
            this.endDate = this.endDate.endOf('day');
            this.container.find('.calendar-time').hide();
        }

        //can't be used together for now
        if (this.timePicker && this.autoApply)
            this.autoApply = false;

        if (this.autoApply && typeof options.ranges !== 'object') {
            this.container.find('.ranges').hide();
        } else if (this.autoApply) {
            this.container.find('.applyBtn, .cancelBtn').addClass('hide');
        }

        if (this.singleDatePicker) {
            this.container.addClass('single');
            this.container.find('.calendar.left').addClass('single');
            this.container.find('.calendar.left').show();
            this.container.find('.calendar.right').hide();
            this.container.find('.daterangepicker_input input, .daterangepicker_input > i').hide();
            if (this.timePicker) {
                this.container.find('.ranges ul').hide();
            } else {
                this.container.find('.ranges').hide();
            }
        }

        if ((typeof options.ranges === 'undefined' && !this.singleDatePicker) || this.alwaysShowCalendars) {
            this.container.addClass('show-calendar');
        }

        this.container.addClass('opens' + this.opens);

        //swap the position of the predefined ranges if opens right
        if (typeof options.ranges !== 'undefined' && this.opens == 'right') {
            this.container.find('.ranges').prependTo( this.container.find('.calendar.left').parent() );
        }

        //apply CSS classes and labels to buttons
        this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses);
        if (this.applyClass.length)
            this.container.find('.applyBtn').addClass(this.applyClass);
        if (this.cancelClass.length)
            this.container.find('.cancelBtn').addClass(this.cancelClass);
        this.container.find('.applyBtn').html(this.locale.applyLabel);
        this.container.find('.cancelBtn').html(this.locale.cancelLabel);

        //
        // event listeners
        //

        this.container.find('.calendar')
            .on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this))
            .on('click.daterangepicker', '.next', $.proxy(this.clickNext, this))
            .on('mousedown.daterangepicker', 'td.available', $.proxy(this.clickDate, this))
            .on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this))
            .on('mouseleave.daterangepicker', 'td.available', $.proxy(this.updateFormInputs, this))
            .on('change.daterangepicker', 'select.yearselect', $.proxy(this.monthOrYearChanged, this))
            .on('change.daterangepicker', 'select.monthselect', $.proxy(this.monthOrYearChanged, this))
            .on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.timeChanged, this))
            .on('click.daterangepicker', '.daterangepicker_input input', $.proxy(this.showCalendars, this))
            .on('focus.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsFocused, this))
            .on('blur.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsBlurred, this))
            .on('change.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this));

        this.container.find('.ranges')
            .on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this))
            .on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this))
            .on('click.daterangepicker', 'li', $.proxy(this.clickRange, this))
            .on('mouseenter.daterangepicker', 'li', $.proxy(this.hoverRange, this))
            .on('mouseleave.daterangepicker', 'li', $.proxy(this.updateFormInputs, this));

        if (this.element.is('input') || this.element.is('button')) {
            this.element.on({
                'click.daterangepicker': $.proxy(this.show, this),
                'focus.daterangepicker': $.proxy(this.show, this),
                'keyup.daterangepicker': $.proxy(this.elementChanged, this),
                'keydown.daterangepicker': $.proxy(this.keydown, this)
            });
        } else {
            this.element.on('click.daterangepicker', $.proxy(this.toggle, this));
        }

        //
        // if attached to a text input, set the initial value
        //

        if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
            this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
            this.element.trigger('change');
        } else if (this.element.is('input') && this.autoUpdateInput) {
            this.element.val(this.startDate.format(this.locale.format));
            this.element.trigger('change');
        }

    };

    DateRangePicker.prototype = {

        constructor: DateRangePicker,

        setStartDate: function(startDate) {
            if (typeof startDate === 'string')
                this.startDate = moment(startDate, this.locale.format);

            if (typeof startDate === 'object')
                this.startDate = moment(startDate);

            if (!this.timePicker)
                this.startDate = this.startDate.startOf('day');

            if (this.timePicker && this.timePickerIncrement)
                this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);

            if (this.minDate && this.startDate.isBefore(this.minDate)) {
                this.startDate = this.minDate.clone();
                if (this.timePicker && this.timePickerIncrement)
                    this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
            }

            if (this.maxDate && this.startDate.isAfter(this.maxDate)) {
                this.startDate = this.maxDate.clone();
                if (this.timePicker && this.timePickerIncrement)
                    this.startDate.minute(Math.floor(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
            }

            if (!this.isShowing)
                this.updateElement();

            this.updateMonthsInView();
        },

        setEndDate: function(endDate) {
            if (typeof endDate === 'string')
                this.endDate = moment(endDate, this.locale.format);

            if (typeof endDate === 'object')
                this.endDate = moment(endDate);

            if (!this.timePicker)
                this.endDate = this.endDate.endOf('day');

            if (this.timePicker && this.timePickerIncrement)
                this.endDate.minute(Math.round(this.endDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);

            if (this.endDate.isBefore(this.startDate))
                this.endDate = this.startDate.clone();

            if (this.maxDate && this.endDate.isAfter(this.maxDate))
                this.endDate = this.maxDate.clone();

            if (this.dateLimit && this.startDate.clone().add(this.dateLimit).isBefore(this.endDate))
                this.endDate = this.startDate.clone().add(this.dateLimit);

            this.previousRightTime = this.endDate.clone();

            if (!this.isShowing)
                this.updateElement();

            this.updateMonthsInView();
        },

        isInvalidDate: function() {
            return false;
        },

        isCustomDate: function() {
            return false;
        },

        updateView: function() {
            if (this.timePicker) {
                this.renderTimePicker('left');
                this.renderTimePicker('right');
                if (!this.endDate) {
                    this.container.find('.right .calendar-time select').attr('disabled', 'disabled').addClass('disabled');
                } else {
                    this.container.find('.right .calendar-time select').removeAttr('disabled').removeClass('disabled');
                }
            }
            if (this.endDate) {
                this.container.find('input[name="daterangepicker_end"]').removeClass('active');
                this.container.find('input[name="daterangepicker_start"]').addClass('active');
            } else {
                this.container.find('input[name="daterangepicker_end"]').addClass('active');
                this.container.find('input[name="daterangepicker_start"]').removeClass('active');
            }
            this.updateMonthsInView();
            this.updateCalendars();
            this.updateFormInputs();
        },

        updateMonthsInView: function() {
            if (this.endDate) {

                //if both dates are visible already, do nothing
                if (!this.singleDatePicker && this.leftCalendar.month && this.rightCalendar.month &&
                    (this.startDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.startDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
                    &&
                    (this.endDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.endDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
                    ) {
                    return;
                }

                this.leftCalendar.month = this.startDate.clone().date(2);
                if (!this.linkedCalendars && (this.endDate.month() != this.startDate.month() || this.endDate.year() != this.startDate.year())) {
                    this.rightCalendar.month = this.endDate.clone().date(2);
                } else {
                    this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
                }

            } else {
                if (this.leftCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM') && this.rightCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM')) {
                    this.leftCalendar.month = this.startDate.clone().date(2);
                    this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
                }
            }
            if (this.maxDate && this.linkedCalendars && !this.singleDatePicker && this.rightCalendar.month > this.maxDate) {
              this.rightCalendar.month = this.maxDate.clone().date(2);
              this.leftCalendar.month = this.maxDate.clone().date(2).subtract(1, 'month');
            }
        },

        updateCalendars: function() {

            if (this.timePicker) {
                var hour, minute, second;
                if (this.endDate) {
                    hour = parseInt(this.container.find('.left .hourselect').val(), 10);
                    minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
                    second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
                    if (!this.timePicker24Hour) {
                        var ampm = this.container.find('.left .ampmselect').val();
                        if (ampm === 'PM' && hour < 12)
                            hour += 12;
                        if (ampm === 'AM' && hour === 12)
                            hour = 0;
                    }
                } else {
                    hour = parseInt(this.container.find('.right .hourselect').val(), 10);
                    minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
                    second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
                    if (!this.timePicker24Hour) {
                        var ampm = this.container.find('.right .ampmselect').val();
                        if (ampm === 'PM' && hour < 12)
                            hour += 12;
                        if (ampm === 'AM' && hour === 12)
                            hour = 0;
                    }
                }
                this.leftCalendar.month.hour(hour).minute(minute).second(second);
                this.rightCalendar.month.hour(hour).minute(minute).second(second);
            }

            this.renderCalendar('left');
            this.renderCalendar('right');

            //highlight any predefined range matching the current start and end dates
            this.container.find('.ranges li').removeClass('active');
            if (this.endDate == null) return;

            this.calculateChosenLabel();
        },

        renderCalendar: function(side) {

            //
            // Build the matrix of dates that will populate the calendar
            //

            var calendar = side == 'left' ? this.leftCalendar : this.rightCalendar;
            var month = calendar.month.month();
            var year = calendar.month.year();
            var hour = calendar.month.hour();
            var minute = calendar.month.minute();
            var second = calendar.month.second();
            var daysInMonth = moment([year, month]).daysInMonth();
            var firstDay = moment([year, month, 1]);
            var lastDay = moment([year, month, daysInMonth]);
            var lastMonth = moment(firstDay).subtract(1, 'month').month();
            var lastYear = moment(firstDay).subtract(1, 'month').year();
            var daysInLastMonth = moment([lastYear, lastMonth]).daysInMonth();
            var dayOfWeek = firstDay.day();

            //initialize a 6 rows x 7 columns array for the calendar
            var calendar = [];
            calendar.firstDay = firstDay;
            calendar.lastDay = lastDay;

            for (var i = 0; i < 6; i++) {
                calendar[i] = [];
            }

            //populate the calendar with date objects
            var startDay = daysInLastMonth - dayOfWeek + this.locale.firstDay + 1;
            if (startDay > daysInLastMonth)
                startDay -= 7;

            if (dayOfWeek == this.locale.firstDay)
                startDay = daysInLastMonth - 6;

            var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]);

            var col, row;
            for (var i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add(24, 'hour')) {
                if (i > 0 && col % 7 === 0) {
                    col = 0;
                    row++;
                }
                calendar[row][col] = curDate.clone().hour(hour).minute(minute).second(second);
                curDate.hour(12);

                if (this.minDate && calendar[row][col].format('YYYY-MM-DD') == this.minDate.format('YYYY-MM-DD') && calendar[row][col].isBefore(this.minDate) && side == 'left') {
                    calendar[row][col] = this.minDate.clone();
                }

                if (this.maxDate && calendar[row][col].format('YYYY-MM-DD') == this.maxDate.format('YYYY-MM-DD') && calendar[row][col].isAfter(this.maxDate) && side == 'right') {
                    calendar[row][col] = this.maxDate.clone();
                }

            }

            //make the calendar object available to hoverDate/clickDate
            if (side == 'left') {
                this.leftCalendar.calendar = calendar;
            } else {
                this.rightCalendar.calendar = calendar;
            }

            //
            // Display the calendar
            //

            var minDate = side == 'left' ? this.minDate : this.startDate;
            var maxDate = this.maxDate;
            var selected = side == 'left' ? this.startDate : this.endDate;
            var arrow = this.locale.direction == 'ltr' ? {left: 'angle-left', right: 'angle-right'} : {left: 'angle-right', right: 'angle-left'};

            var html = '<table class="table-condensed">';
            html += '<thead>';
            html += '<tr>';

            // add empty cell for week number
            if (this.showWeekNumbers || this.showISOWeekNumbers)
                html += '';

            if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) {
                html += '<th class="prev available"><i class="icon-' + arrow.left + ' icon-' + arrow.left + '"></i></th></tr><tr>';
            } else {
                html += '<tr>';
            }

            var dateHtml = this.locale.monthNames[calendar[1][1].month()] + calendar[1][1].format(" YYYY");

            if (this.showDropdowns) {
                var currentMonth = calendar[1][1].month();
                var currentYear = calendar[1][1].year();
                var maxYear = (maxDate && maxDate.year()) || (currentYear + 5);
                var minYear = (minDate && minDate.year()) || (currentYear - 50);
                var inMinYear = currentYear == minYear;
                var inMaxYear = currentYear == maxYear;

                var monthHtml = '<select class="monthselect">';
                for (var m = 0; m < 12; m++) {
                    if ((!inMinYear || m >= minDate.month()) && (!inMaxYear || m <= maxDate.month())) {
                        monthHtml += "<option value='" + m + "'" +
                            (m === currentMonth ? " selected='selected'" : "") +
                            ">" + this.locale.monthNames[m] + "</option>";
                    } else {
                        monthHtml += "<option value='" + m + "'" +
                            (m === currentMonth ? " selected='selected'" : "") +
                            " disabled='disabled'>" + this.locale.monthNames[m] + "</option>";
                    }
                }
                monthHtml += "</select>";

                var yearHtml = '<select class="yearselect">';
                for (var y = minYear; y <= maxYear; y++) {
                    yearHtml += '<option value="' + y + '"' +
                        (y === currentYear ? ' selected="selected"' : '') +
                        '>' + y + '</option>';
                }
                yearHtml += '</select>';

                dateHtml = '<th colspan="4" class="month">' + monthHtml + '</th><th colspan="3" class="month">' + yearHtml + '</th>';
            }

            html += dateHtml;
            if ((!maxDate || maxDate.isAfter(calendar.lastDay)) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker)) {
                html += '</tr><tr><th class="next available"><i class="icon-' + arrow.right + ' icon-' + arrow.right + '"></i></th></tr>';
            } else {
                html += '</tr>';
            }

            html += '<tr>';

            // add week number label
            if (this.showWeekNumbers || this.showISOWeekNumbers)
                html += '<th class="week">' + this.locale.weekLabel + '</th>';

            $.each(this.locale.daysOfWeek, function(index, dayOfWeek) {
                html += '<th>' + dayOfWeek + '</th>';
            });

            html += '</tr>';
            html += '</thead>';
            html += '<tbody>';

            //adjust maxDate to reflect the dateLimit setting in order to
            //grey out end dates beyond the dateLimit
            if (this.endDate == null && this.dateLimit) {
                var maxLimit = this.startDate.clone().add(this.dateLimit).endOf('day');
                if (!maxDate || maxLimit.isBefore(maxDate)) {
                    maxDate = maxLimit;
                }
            }

            for (var row = 0; row < 6; row++) {
                html += '<tr>';

                // add week number
                if (this.showWeekNumbers)
                    html += '<td class="week">' + calendar[row][0].week() + '</td>';
                else if (this.showISOWeekNumbers)
                    html += '<td class="week">' + calendar[row][0].isoWeek() + '</td>';

                for (var col = 0; col < 7; col++) {

                    var classes = [];

                    //highlight today's date
                    if (calendar[row][col].isSame(new Date(), "day"))
                        classes.push('today');

                    //highlight weekends
                    if (calendar[row][col].isoWeekday() > 5)
                        classes.push('weekend');

                    //grey out the dates in other months displayed at beginning and end of this calendar
                    if (calendar[row][col].month() != calendar[1][1].month())
                        classes.push('off');

                    //don't allow selection of dates before the minimum date
                    if (this.minDate && calendar[row][col].isBefore(this.minDate, 'day'))
                        classes.push('off', 'disabled');

                    //don't allow selection of dates after the maximum date
                    if (maxDate && calendar[row][col].isAfter(maxDate, 'day'))
                        classes.push('off', 'disabled');

                    //don't allow selection of date if a custom function decides it's invalid
                    if (this.isInvalidDate(calendar[row][col]))
                        classes.push('off', 'disabled');

                    //highlight the currently selected start date
                    if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD'))
                        classes.push('active', 'start-date');

                    //highlight the currently selected end date
                    if (this.endDate != null && calendar[row][col].format('YYYY-MM-DD') == this.endDate.format('YYYY-MM-DD'))
                        classes.push('active', 'end-date');

                    //highlight dates in-between the selected dates
                    if (this.endDate != null && calendar[row][col] > this.startDate && calendar[row][col] < this.endDate)
                        classes.push('in-range');

                    //apply custom classes for this date
                    var isCustom = this.isCustomDate(calendar[row][col]);
                    if (isCustom !== false) {
                        if (typeof isCustom === 'string')
                            classes.push(isCustom);
                        else
                            Array.prototype.push.apply(classes, isCustom);
                    }

                    var cname = '', disabled = false;
                    for (var i = 0; i < classes.length; i++) {
                        cname += classes[i] + ' ';
                        if (classes[i] == 'disabled')
                            disabled = true;
                    }
                    if (!disabled)
                        cname += 'available';

                    html += '<td class="' + cname.replace(/^\s+|\s+$/g, '') + '" data-title="' + 'r' + row + 'c' + col + '"><span>' + calendar[row][col].date() + '</span></td>';

                }
                html += '</tr>';
            }

            html += '</tbody>';
            html += '</table>';

            this.container.find('.calendar.' + side + ' .calendar-table').html(html);

        },

        renderTimePicker: function(side) {

            // Don't bother updating the time picker if it's currently disabled
            // because an end date hasn't been clicked yet
            if (side == 'right' && !this.endDate) return;

            var html, selected, minDate, maxDate = this.maxDate;

            if (this.dateLimit && (!this.maxDate || this.startDate.clone().add(this.dateLimit).isAfter(this.maxDate)))
                maxDate = this.startDate.clone().add(this.dateLimit);

            if (side == 'left') {
                selected = this.startDate.clone();
                minDate = this.minDate;
            } else if (side == 'right') {
                selected = this.endDate.clone();
                minDate = this.startDate;

                //Preserve the time already selected
                var timeSelector = this.container.find('.calendar.right .calendar-time div');
                if (timeSelector.html() != '') {

                    selected.hour(timeSelector.find('.hourselect option:selected').val() || selected.hour());
                    selected.minute(timeSelector.find('.minuteselect option:selected').val() || selected.minute());
                    selected.second(timeSelector.find('.secondselect option:selected').val() || selected.second());

                    if (!this.timePicker24Hour) {
                        var ampm = timeSelector.find('.ampmselect option:selected').val();
                        if (ampm === 'PM' && selected.hour() < 12)
                            selected.hour(selected.hour() + 12);
                        if (ampm === 'AM' && selected.hour() === 12)
                            selected.hour(0);
                    }

                }

                if (selected.isBefore(this.startDate))
                    selected = this.startDate.clone();

                if (maxDate && selected.isAfter(maxDate))
                    selected = maxDate.clone();

            }

            //
            // hours
            //

            html = '<select class="hourselect">';

            var start = this.timePicker24Hour ? 0 : 1;
            var end = this.timePicker24Hour ? 23 : 12;

            for (var i = start; i <= end; i++) {
                var i_in_24 = i;
                if (!this.timePicker24Hour)
                    i_in_24 = selected.hour() >= 12 ? (i == 12 ? 12 : i + 12) : (i == 12 ? 0 : i);

                var time = selected.clone().hour(i_in_24);
                var disabled = false;
                if (minDate && time.minute(59).isBefore(minDate))
                    disabled = true;
                if (maxDate && time.minute(0).isAfter(maxDate))
                    disabled = true;

                if (i_in_24 == selected.hour() && !disabled) {
                    html += '<option value="' + i + '" selected="selected">' + i + '</option>';
                } else if (disabled) {
                    html += '<option value="' + i + '" disabled="disabled" class="disabled">' + i + '</option>';
                } else {
                    html += '<option value="' + i + '">' + i + '</option>';
                }
            }

            html += '</select> ';

            //
            // minutes
            //

            html += ': <select class="minuteselect">';

            for (var i = 0; i < 60; i += this.timePickerIncrement) {
                var padded = i < 10 ? '0' + i : i;
                var time = selected.clone().minute(i);

                var disabled = false;
                if (minDate && time.second(59).isBefore(minDate))
                    disabled = true;
                if (maxDate && time.second(0).isAfter(maxDate))
                    disabled = true;

                if (selected.minute() == i && !disabled) {
                    html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
                } else if (disabled) {
                    html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
                } else {
                    html += '<option value="' + i + '">' + padded + '</option>';
                }
            }

            html += '</select> ';

            //
            // seconds
            //

            if (this.timePickerSeconds) {
                html += ': <select class="secondselect">';

                for (var i = 0; i < 60; i++) {
                    var padded = i < 10 ? '0' + i : i;
                    var time = selected.clone().second(i);

                    var disabled = false;
                    if (minDate && time.isBefore(minDate))
                        disabled = true;
                    if (maxDate && time.isAfter(maxDate))
                        disabled = true;

                    if (selected.second() == i && !disabled) {
                        html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
                    } else if (disabled) {
                        html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
                    } else {
                        html += '<option value="' + i + '">' + padded + '</option>';
                    }
                }

                html += '</select> ';
            }

            //
            // AM/PM
            //

            if (!this.timePicker24Hour) {
                html += '<select class="ampmselect">';

                var am_html = '';
                var pm_html = '';

                if (minDate && selected.clone().hour(12).minute(0).second(0).isBefore(minDate))
                    am_html = ' disabled="disabled" class="disabled"';

                if (maxDate && selected.clone().hour(0).minute(0).second(0).isAfter(maxDate))
                    pm_html = ' disabled="disabled" class="disabled"';

                if (selected.hour() >= 12) {
                    html += '<option value="AM"' + am_html + '>AM</option><option value="PM" selected="selected"' + pm_html + '>PM</option>';
                } else {
                    html += '<option value="AM" selected="selected"' + am_html + '>AM</option><option value="PM"' + pm_html + '>PM</option>';
                }

                html += '</select>';
            }

            this.container.find('.calendar.' + side + ' .calendar-time div').html(html);

        },

        updateFormInputs: function() {

            //ignore mouse movements while an above-calendar text input has focus
            if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
                return;

            this.container.find('input[name=daterangepicker_start]').val(this.startDate.format(this.locale.format));
            if (this.endDate)
                this.container.find('input[name=daterangepicker_end]').val(this.endDate.format(this.locale.format));

            if (this.singleDatePicker || (this.endDate && (this.startDate.isBefore(this.endDate) || this.startDate.isSame(this.endDate)))) {
                this.container.find('button.applyBtn').removeAttr('disabled');
            } else {
                this.container.find('button.applyBtn').attr('disabled', 'disabled');
            }

        },

        move: function() {
            var parentOffset = { top: 0, left: 0 },
                containerTop;
            var parentRightEdge = $(window).width();
            if (!this.parentEl.is('body')) {
                parentOffset = {
                    top: this.parentEl.offset().top - this.parentEl.scrollTop(),
                    left: this.parentEl.offset().left - this.parentEl.scrollLeft()
                };
                parentRightEdge = this.parentEl[0].clientWidth + this.parentEl.offset().left;
            }

            if (this.drops == 'up')
                containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top;
            else
                containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top;
            this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('dropup');

            if (this.opens == 'left') {
                this.container.css({
                    top: containerTop,
                    right: parentRightEdge - this.element.offset().left - this.element.outerWidth(),
                    left: 'auto'
                });
                if (this.container.offset().left < 0) {
                    this.container.css({
                        right: 'auto',
                        left: 9
                    });
                }
            } else if (this.opens == 'center') {
                this.container.css({
                    top: containerTop,
                    left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
                            - this.container.outerWidth() / 2,
                    right: 'auto'
                });
                if (this.container.offset().left < 0) {
                    this.container.css({
                        right: 'auto',
                        left: 9
                    });
                }
            } else {
                this.container.css({
                    top: containerTop,
                    left: this.element.offset().left - parentOffset.left,
                    right: 'auto'
                });
                if (this.container.offset().left + this.container.outerWidth() > $(window).width()) {
                    this.container.css({
                        left: 'auto',
                        right: 0
                    });
                }
            }
        },

        show: function(e) {
            if (this.isShowing) return;

            // Create a click proxy that is private to this instance of datepicker, for unbinding
            this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this);

            // Bind global datepicker mousedown for hiding and
            $(document)
              .on('mousedown.daterangepicker', this._outsideClickProxy)
              // also support mobile devices
              .on('touchend.daterangepicker', this._outsideClickProxy)
              // also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them
              .on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy)
              // and also close when focus changes to outside the picker (eg. tabbing between controls)
              .on('focusin.daterangepicker', this._outsideClickProxy);

            // Reposition the picker if the window is resized while it's open
            $(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this));

            this.oldStartDate = this.startDate.clone();
            this.oldEndDate = this.endDate.clone();
            this.previousRightTime = this.endDate.clone();

            this.updateView();
            this.container.show();
            this.move();
            this.element.trigger('show.daterangepicker', this);
            this.isShowing = true;
        },

        hide: function(e) {
            if (!this.isShowing) return;

            //incomplete date selection, revert to last values
            if (!this.endDate) {
                this.startDate = this.oldStartDate.clone();
                this.endDate = this.oldEndDate.clone();
            }

            //if a new date range was selected, invoke the user callback function
            if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate))
                this.callback(this.startDate, this.endDate, this.chosenLabel);

            //if picker is attached to a text input, update it
            this.updateElement();

            $(document).off('.daterangepicker');
            $(window).off('.daterangepicker');
            this.container.hide();
            this.element.trigger('hide.daterangepicker', this);
            this.isShowing = false;
        },

        toggle: function(e) {
            if (this.isShowing) {
                this.hide();
            } else {
                this.show();
            }
        },

        outsideClick: function(e) {
            var target = $(e.target);
            // if the page is clicked anywhere except within the daterangerpicker/button
            // itself then call this.hide()
            if (
                // ie modal dialog fix
                e.type == "focusin" ||
                target.closest(this.element).length ||
                target.closest(this.container).length ||
                target.closest('.calendar-table').length
                ) return;
            this.hide();
            this.element.trigger('outsideClick.daterangepicker', this);
        },

        showCalendars: function() {
            this.container.addClass('show-calendar');
            this.move();
            this.element.trigger('showCalendar.daterangepicker', this);
        },

        hideCalendars: function() {
            this.container.removeClass('show-calendar');
            this.element.trigger('hideCalendar.daterangepicker', this);
        },

        hoverRange: function(e) {

            //ignore mouse movements while an above-calendar text input has focus
            if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
                return;

            var label = e.target.getAttribute('data-range-key');

            if (label == this.locale.customRangeLabel) {
                this.updateView();
            } else {
                var dates = this.ranges[label];
                this.container.find('input[name=daterangepicker_start]').val(dates[0].format(this.locale.format));
                this.container.find('input[name=daterangepicker_end]').val(dates[1].format(this.locale.format));
            }

        },

        clickRange: function(e) {
            var label = e.target.getAttribute('data-range-key');
            this.chosenLabel = label;
            if (label == this.locale.customRangeLabel) {
                this.showCalendars();
            } else {
                var dates = this.ranges[label];
                this.startDate = dates[0];
                this.endDate = dates[1];

                if (!this.timePicker) {
                    this.startDate.startOf('day');
                    this.endDate.endOf('day');
                }

                if (!this.alwaysShowCalendars)
                    this.hideCalendars();
                this.clickApply();
            }
        },

        clickPrev: function(e) {
            var cal = $(e.target).parents('.calendar');
            if (cal.hasClass('left')) {
                this.leftCalendar.month.subtract(1, 'month');
                if (this.linkedCalendars)
                    this.rightCalendar.month.subtract(1, 'month');
            } else {
                this.rightCalendar.month.subtract(1, 'month');
            }
            this.updateCalendars();
        },

        clickNext: function(e) {
            var cal = $(e.target).parents('.calendar');
            if (cal.hasClass('left')) {
                this.leftCalendar.month.add(1, 'month');
            } else {
                this.rightCalendar.month.add(1, 'month');
                if (this.linkedCalendars)
                    this.leftCalendar.month.add(1, 'month');
            }
            this.updateCalendars();
        },

        hoverDate: function(e) {

            //ignore mouse movements while an above-calendar text input has focus
            //if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
            //    return;

            //ignore dates that can't be selected
            if (!$(e.target).hasClass('available')) return;

            //have the text inputs above calendars reflect the date being hovered over
            var title = $(e.target).attr('data-title');
            var row = title.substr(1, 1);
            var col = title.substr(3, 1);
            var cal = $(e.target).parents('.calendar');
            var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];

            if (this.endDate && !this.container.find('input[name=daterangepicker_start]').is(":focus")) {
                this.container.find('input[name=daterangepicker_start]').val(date.format(this.locale.format));
            } else if (!this.endDate && !this.container.find('input[name=daterangepicker_end]').is(":focus")) {
                this.container.find('input[name=daterangepicker_end]').val(date.format(this.locale.format));
            }

            //highlight the dates between the start date and the date being hovered as a potential end date
            var leftCalendar = this.leftCalendar;
            var rightCalendar = this.rightCalendar;
            var startDate = this.startDate;
            if (!this.endDate) {
                this.container.find('.calendar tbody td').each(function(index, el) {

                    //skip week numbers, only look at dates
                    if ($(el).hasClass('week')) return;

                    var title = $(el).attr('data-title');
                    var row = title.substr(1, 1);
                    var col = title.substr(3, 1);
                    var cal = $(el).parents('.calendar');
                    var dt = cal.hasClass('left') ? leftCalendar.calendar[row][col] : rightCalendar.calendar[row][col];

                    if ((dt.isAfter(startDate) && dt.isBefore(date)) || dt.isSame(date, 'day')) {
                        $(el).addClass('in-range');
                    } else {
                        $(el).removeClass('in-range');
                    }

                });
            }

        },

        clickDate: function(e) {

            if (!$(e.target).hasClass('available')) return;

            var title = $(e.target).attr('data-title');
            var row = title.substr(1, 1);
            var col = title.substr(3, 1);
            var cal = $(e.target).parents('.calendar');
            var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];

            //
            // this function needs to do a few things:
            // * alternate between selecting a start and end date for the range,
            // * if the time picker is enabled, apply the hour/minute/second from the select boxes to the clicked date
            // * if autoapply is enabled, and an end date was chosen, apply the selection
            // * if single date picker mode, and time picker isn't enabled, apply the selection immediately
            // * if one of the inputs above the calendars was focused, cancel that manual input
            //

            if (this.endDate || date.isBefore(this.startDate, 'day')) { //picking start
                if (this.timePicker) {
                    var hour = parseInt(this.container.find('.left .hourselect').val(), 10);
                    if (!this.timePicker24Hour) {
                        var ampm = this.container.find('.left .ampmselect').val();
                        if (ampm === 'PM' && hour < 12)
                            hour += 12;
                        if (ampm === 'AM' && hour === 12)
                            hour = 0;
                    }
                    var minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
                    var second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
                    date = date.clone().hour(hour).minute(minute).second(second);
                }
                this.endDate = null;
                this.setStartDate(date.clone());
            } else if (!this.endDate && date.isBefore(this.startDate)) {
                //special case: clicking the same date for start/end,
                //but the time of the end date is before the start date
                this.setEndDate(this.startDate.clone());
            } else { // picking end
                if (this.timePicker) {
                    var hour = parseInt(this.container.find('.right .hourselect').val(), 10);
                    if (!this.timePicker24Hour) {
                        var ampm = this.container.find('.right .ampmselect').val();
                        if (ampm === 'PM' && hour < 12)
                            hour += 12;
                        if (ampm === 'AM' && hour === 12)
                            hour = 0;
                    }
                    var minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
                    var second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
                    date = date.clone().hour(hour).minute(minute).second(second);
                }
                this.setEndDate(date.clone());
                if (this.autoApply) {
                  this.calculateChosenLabel();
                  this.clickApply();
                }
            }

            if (this.singleDatePicker) {
                this.setEndDate(this.startDate);
                if (!this.timePicker)
                    this.clickApply();
            }

            this.updateView();

            //This is to cancel the blur event handler if the mouse was in one of the inputs
            e.stopPropagation();

        },

        calculateChosenLabel: function () {
            var customRange = true;
            var i = 0;
            for (var range in this.ranges) {
                if (this.timePicker) {
                    if (this.startDate.isSame(this.ranges[range][0]) && this.endDate.isSame(this.ranges[range][1])) {
                        customRange = false;
                        this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html();
                        break;
                    }
                } else {
                    //ignore times when comparing dates if time picker is not enabled
                    if (this.startDate.format('YYYY-MM-DD') == this.ranges[range][0].format('YYYY-MM-DD') && this.endDate.format('YYYY-MM-DD') == this.ranges[range][1].format('YYYY-MM-DD')) {
                        customRange = false;
                        this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html();
                        break;
                    }
                }
                i++;
            }
            if (customRange) {
                if (this.showCustomRangeLabel) {
                    this.chosenLabel = this.container.find('.ranges li:last').addClass('active').html();
                } else {
                    this.chosenLabel = null;
                }
                this.showCalendars();
            }
        },

        clickApply: function(e) {
            this.hide();
            this.element.trigger('apply.daterangepicker', this);
        },

        clickCancel: function(e) {
            this.startDate = this.oldStartDate;
            this.endDate = this.oldEndDate;
            this.hide();
            this.element.trigger('cancel.daterangepicker', this);
        },

        monthOrYearChanged: function(e) {
            var isLeft = $(e.target).closest('.calendar').hasClass('left'),
                leftOrRight = isLeft ? 'left' : 'right',
                cal = this.container.find('.calendar.'+leftOrRight);

            // Month must be Number for new moment versions
            var month = parseInt(cal.find('.monthselect').val(), 10);
            var year = cal.find('.yearselect').val();

            if (!isLeft) {
                if (year < this.startDate.year() || (year == this.startDate.year() && month < this.startDate.month())) {
                    month = this.startDate.month();
                    year = this.startDate.year();
                }
            }

            if (this.minDate) {
                if (year < this.minDate.year() || (year == this.minDate.year() && month < this.minDate.month())) {
                    month = this.minDate.month();
                    year = this.minDate.year();
                }
            }

            if (this.maxDate) {
                if (year > this.maxDate.year() || (year == this.maxDate.year() && month > this.maxDate.month())) {
                    month = this.maxDate.month();
                    year = this.maxDate.year();
                }
            }

            if (isLeft) {
                this.leftCalendar.month.month(month).year(year);
                if (this.linkedCalendars)
                    this.rightCalendar.month = this.leftCalendar.month.clone().add(1, 'month');
            } else {
                this.rightCalendar.month.month(month).year(year);
                if (this.linkedCalendars)
                    this.leftCalendar.month = this.rightCalendar.month.clone().subtract(1, 'month');
            }
            this.updateCalendars();
        },

        timeChanged: function(e) {

            var cal = $(e.target).closest('.calendar'),
                isLeft = cal.hasClass('left');

            var hour = parseInt(cal.find('.hourselect').val(), 10);
            var minute = parseInt(cal.find('.minuteselect').val(), 10);
            var second = this.timePickerSeconds ? parseInt(cal.find('.secondselect').val(), 10) : 0;

            if (!this.timePicker24Hour) {
                var ampm = cal.find('.ampmselect').val();
                if (ampm === 'PM' && hour < 12)
                    hour += 12;
                if (ampm === 'AM' && hour === 12)
                    hour = 0;
            }

            if (isLeft) {
                var start = this.startDate.clone();
                start.hour(hour);
                start.minute(minute);
                start.second(second);
                this.setStartDate(start);
                if (this.singleDatePicker) {
                    this.endDate = this.startDate.clone();
                } else if (this.endDate && this.endDate.format('YYYY-MM-DD') == start.format('YYYY-MM-DD') && this.endDate.isBefore(start)) {
                    this.setEndDate(start.clone());
                }
            } else if (this.endDate) {
                var end = this.endDate.clone();
                end.hour(hour);
                end.minute(minute);
                end.second(second);
                this.setEndDate(end);
            }

            //update the calendars so all clickable dates reflect the new time component
            this.updateCalendars();

            //update the form inputs above the calendars with the new time
            this.updateFormInputs();

            //re-render the time pickers because changing one selection can affect what's enabled in another
            this.renderTimePicker('left');
            this.renderTimePicker('right');

        },

        formInputsChanged: function(e) {
            var isRight = $(e.target).closest('.calendar').hasClass('right');
            var start = moment(this.container.find('input[name="daterangepicker_start"]').val(), this.locale.format);
            var end = moment(this.container.find('input[name="daterangepicker_end"]').val(), this.locale.format);

            if (start.isValid() && end.isValid()) {

                if (isRight && end.isBefore(start))
                    start = end.clone();

                this.setStartDate(start);
                this.setEndDate(end);

                if (isRight) {
                    this.container.find('input[name="daterangepicker_start"]').val(this.startDate.format(this.locale.format));
                } else {
                    this.container.find('input[name="daterangepicker_end"]').val(this.endDate.format(this.locale.format));
                }

            }

            this.updateView();
        },

        formInputsFocused: function(e) {

            // Highlight the focused input
            this.container.find('input[name="daterangepicker_start"], input[name="daterangepicker_end"]').removeClass('active');
            $(e.target).addClass('active');

            // Set the state such that if the user goes back to using a mouse, 
            // the calendars are aware we're selecting the end of the range, not
            // the start. This allows someone to edit the end of a date range without
            // re-selecting the beginning, by clicking on the end date input then
            // using the calendar.
            var isRight = $(e.target).closest('.calendar').hasClass('right');
            if (isRight) {
                this.endDate = null;
                this.setStartDate(this.startDate.clone());
                this.updateView();
            }

        },

        formInputsBlurred: function(e) {

            // this function has one purpose right now: if you tab from the first
            // text input to the second in the UI, the endDate is nulled so that
            // you can click another, but if you tab out without clicking anything
            // or changing the input value, the old endDate should be retained

            if (!this.endDate) {
                var val = this.container.find('input[name="daterangepicker_end"]').val();
                var end = moment(val, this.locale.format);
                if (end.isValid()) {
                    this.setEndDate(end);
                    this.updateView();
                }
            }

        },

        elementChanged: function() {
            if (!this.element.is('input')) return;
            if (!this.element.val().length) return;
            if (this.element.val().length < this.locale.format.length) return;

            var dateString = this.element.val().split(this.locale.separator),
                start = null,
                end = null;

            if (dateString.length === 2) {
                start = moment(dateString[0], this.locale.format);
                end = moment(dateString[1], this.locale.format);
            }

            if (this.singleDatePicker || start === null || end === null) {
                start = moment(this.element.val(), this.locale.format);
                end = start;
            }

            if (!start.isValid() || !end.isValid()) return;

            this.setStartDate(start);
            this.setEndDate(end);
            this.updateView();
        },

        keydown: function(e) {
            //hide on tab or enter
            if ((e.keyCode === 9) || (e.keyCode === 13)) {
                this.hide();
            }
        },

        updateElement: function() {
            if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
                this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
                this.element.trigger('change');
            } else if (this.element.is('input') && this.autoUpdateInput) {
                this.element.val(this.startDate.format(this.locale.format));
                this.element.trigger('change');
            }
        },

        remove: function() {
            this.container.remove();
            this.element.off('.daterangepicker');
            this.element.removeData();
        }

    };

    $.fn.daterangepicker = function(options, callback) {
        this.each(function() {
            var el = $(this);
            if (el.data('daterangepicker'))
                el.data('daterangepicker').remove();
            el.data('daterangepicker', new DateRangePicker(el, options, callback));
        });
        return this;
    };

    return DateRangePicker;

}));

function DateFilter(namespace, id, showYearsDateRange, filterMinYear){
	this.namespace = namespace;
	this.id = id;
    this.showYearsDateRange = showYearsDateRange;
    this.filterMinYear = filterMinYear;
	this.init();
}

DateFilter.prototype = {
	init: function() {
	    // Event handler
	    this.event_handler({instance: this});
    },

    // Event handler
    event_handler: function(data) {
        var instance = data.instance;

        instance.getElement(instance.id.resetDateFilter).click(function() {
            instance.getElement(instance.id.searchDateInput).val('').attr("value", "").change();
            instance.hideResetButton();
        });

        instance.customDatepicker(instance.showYearsDateRange,instance.filterMinYear);
        instance.buttonCalendar();
    },

    /*****************************************************************
     ************ DATES **********************************************
     *****************************************************************/
    buttonCalendar: function() {
        var instance = this;
        if ($('[data-function="fc-calendar-datarange"]').length > 0) {
            if(instance.getElement(instance.id.searchDateInput).val() != "") {
                instance.showResetButton();
            }
            $('[data-function="fc-calendar-datarange"]').click(function() {
                instance.showResetButton();
            });
        }
    },

    hideResetButton: function() {
        var instance = this;
        instance.getElement(instance.id.searchDateInput).removeClass('evr-filter-search-open__date--no-bg');
        $('[data-function="fc-buttonResetCalendar"]').addClass('evr-filter-search__search__reset--none');
        $('[data-function="fc-buttonResetCalendar"]').removeClass('evr-filter-search__search__reset--close');
    },

    showResetButton: function() {
        var instance = this;
        instance.getElement(instance.id.searchDateInput).addClass('evr-filter-search-open__date--no-bg');
        $('[data-function="fc-buttonResetCalendar"]').removeClass('evr-filter-search__search__reset--none');
        $('[data-function="fc-buttonResetCalendar"]').addClass('evr-filter-search__search__reset--close');
    },

    customDatepicker: function(showD, minY) {
        if ($('[data-function="fc-calendar-datarange"]').length > 0) {
            var instance = this;
            $('[data-function="fc-calendar-datarange"]').daterangepicker({
                "parentEl" : "evr-filter-search-open__date",
                "autoApply" : true,
                "autoUpdateInput" : false,
                "opens" : "right",
                "locale" : {
                    "format" : "DD/MM/YYYY",
                    "firstDay" : 1,
                    "daysOfWeek" : [
                                    'D',
            						'L',
            						'M',
            						'X',
            						'J',
            						'V',
            						'S'
            						                    ],
                    "monthNames" : [
            						'Enero',
            						'Febrero',
            						'Marzo',
            						'Abril',
            						'Mayo',
            						'Junio',
            						'Julio',
            						'Agosto',
            						'Septiembre',
            						'Octubre',
            						'Noviembre',
            						'Diciembre'
                                ]
                },
                "showDropdowns" : showD,
                "minYear" : minY
            },

            function(start, end, label) {
                instance.getElement(instance.id.searchDateInput).val(start.format('DD/MM/YYYY') + ' - ' + end.format('DD/MM/YYYY')).change();
            });
        }
    },

    /*****************************************************************
     ************ UTILS **********************************************
     *****************************************************************/

    getElement: function(str) {
        return $('#' + this.namespace + str);
    }
}
var coursesSearch = coursesSearch || {};
coursesSearch.id = coursesSearch.id || {};
coursesSearch.url = coursesSearch.url || {};
coursesSearch.namespace = coursesSearch.namespace || {};
coursesSearch.options = coursesSearch.options || {};
coursesSearch.pagination = coursesSearch.pagination || {};

coursesSearch.init = function () {
    coursesSearch.initSelects();
    coursesSearch.options.preSelectedFields = coursesSearch.preSelectedOptions();
    coursesSearch.isSearchable();
    coursesSearch.event_handler();
};

coursesSearch.event_handler = function() {
    var selectorArea = $('#' + coursesSearch.namespace + coursesSearch.id.formationAreaId);
    var selectorSubarea = $('#' + coursesSearch.namespace + coursesSearch.id.formationSubareaId);
    var selectorSpeciality = $('#' + coursesSearch.namespace + coursesSearch.id.formationEspecialityId);
    var selectorAction = $('#' + coursesSearch.namespace + coursesSearch.id.formationActionId);

    selectorArea.on('change', function () {
        generateParamsSearchFields(selectorArea, selectorSubarea, coursesSearch.id.formationSubareaId, coursesSearch.url.searchSubareas, coursesSearch.id.formationAreaId);
        generateParamsSearchFields(selectorSubarea, selectorSpeciality, coursesSearch.id.formationEspecialityId, coursesSearch.url.searchSpecialities, coursesSearch.id.formationAreaId);
        generateParamsSearchFields(selectorSpeciality, selectorAction, coursesSearch.id.formationActionId, coursesSearch.url.searchActions, coursesSearch.id.formationAreaId);
    });

    selectorSubarea.on('change', function () {
        generateParamsSearchFields(selectorSubarea, selectorSpeciality, coursesSearch.id.formationEspecialityId, coursesSearch.url.searchSpecialities, coursesSearch.id.formationSubareaId);
        generateParamsSearchFields(selectorSpeciality, selectorAction, coursesSearch.id.formationActionId, coursesSearch.url.searchActions, coursesSearch.id.formationSubareaId);
    });

    selectorSpeciality.on('change', function () {
        generateParamsSearchFields(selectorSpeciality, selectorAction, coursesSearch.id.formationActionId, coursesSearch.url.searchActions, coursesSearch.id.formationEspecialityId);
    });

    coursesSearch.getElement(coursesSearch.id.form).find("select").on('selectmenuchange', function (e) {
		$(this).trigger("change");
	});
    coursesSearch.getElement(coursesSearch.id.form).find(".form-control").each(function(){
        if($(this).is('input[type="text"]') ){
            $(this).keyup(function(){
                coursesSearch.isSearchable();
            });
        }
        $(this).change(function(){
            coursesSearch.isSearchable();
        });
    });

    coursesSearch.getElement(coursesSearch.id.backSimpleSearch).click(function(event){
        coursesSearch.clearField(coursesSearch.id.collectivityId);
        coursesSearch.clearField(coursesSearch.id.courseCode);
    });

    if(coursesSearch.options.ajax) {
        coursesSearch.getElement(coursesSearch.id.simpleSearchButton).click(function(event){
            coursesSearch.pagination.curPage = 0;
            coursesSearch.searchCourses();
        });
        coursesSearch.getElement(coursesSearch.id.advancedSearchButton).click(function(event){
            coursesSearch.pagination.curPage = 0;
            coursesSearch.searchCourses();
        });
        coursesSearch.searchCourses();
    } else {
        coursesSearch.getElement(coursesSearch.id.simpleSearchButton).click(function(){
            coursesSearch.getElement(coursesSearch.id.form).submit();
        });
        coursesSearch.getElement(coursesSearch.id.advancedSearchButton).click(function(){
            coursesSearch.getElement(coursesSearch.id.form).submit();
        });
    }
};

coursesSearch.searchCourses = function() {
    var divLoad = $('.evr-courses__loading-courses');
    var divResults = coursesSearch.getElement(coursesSearch.id.listCourses);
    var dates = coursesSearch.getDatesValues();
    if(dates != "") {
        var form = coursesSearch.getElement(coursesSearch.id.form);
        var params = form.serializeArray();
        var curPage = {
            'name': coursesSearch.namespace + 'curPage',
            'value': coursesSearch.pagination.curPage
        };
        params.push(curPage);
        var startDate = {
            'name': coursesSearch.namespace + 'startDate',
            'value': dates[0]
        };
        params.push(startDate);
        var endDate = {
            'name': coursesSearch.namespace + 'endDate',
            'value': dates[1]
        };
        params.push(endDate);
        $.ajax({
            url: coursesSearch.url.searchCourses,
            data: params,
            type: 'GET',
            dataType: 'html',
            cache: false,
            beforeSend: coursesSearch.beforeSend(divLoad, divResults)
        }).done(function (data, textStatus, jsqXHR) {
            divResults.append(data);
            initRrssShare();
        }).fail(function (jqXHR, textStatus, errorThrown) {
            divResults.append(textStatus);
        }).always(function(){
            divLoad.removeClass("open");
            divLoad.empty();
        });
    }
};

coursesSearch.searchFields = function (selector, params, searchUrl) {
    var url = searchUrl + '&' + coursesSearch.namespace + params.name + '=' + params.value;
    $.ajax({
        url: url,
        type: 'GET',
        cache: false
    }).done(function (data, textStatus, jsqXHR) {
        selector.empty();
        selector.append(data);
        refreshSelect(selector);
    }).fail(function (jqXHR, textStatus, errorThrown) {
        selector.html("");
    });
}

generateParamsSearchFields = function(parentSelector, selector, selectorId, searchFieldUrl, selectorChangedId) {
    var selectorArea = $('#' + coursesSearch.namespace + coursesSearch.id.formationAreaId);
    var selectorSubarea = $('#' + coursesSearch.namespace + coursesSearch.id.formationSubareaId);
    var selectorSpeciality = $('#' + coursesSearch.namespace + coursesSearch.id.formationEspecialityId);
    var fieldCode = parentSelector.val();
    var params = {
        'name': 'formationAreaId',
        'value': fieldCode
    };
    if (selectorId === coursesSearch.id.formationSubareaId) {
        if (selectorArea.val() === '') {
            fieldCode = '';
        }
        params = {
            'name': 'formationAreaId',
            'value': fieldCode
        };
    } else if (selectorId === coursesSearch.id.formationEspecialityId) {
        if (selectorChangedId === coursesSearch.id.formationAreaId || selectorArea.val() === '' || selectorSubarea.val() === '') {
            fieldCode = '';
        }
        params = {
            'name': 'formationSubareaId',
            'value': fieldCode
        };
    } else if (selectorId === coursesSearch.id.formationActionId) {
        if (selectorChangedId === coursesSearch.id.formationAreaId || selectorChangedId === coursesSearch.id.formationSubareaId || selectorArea.val() === '' || selectorSubarea.val() === '' || selectorSpeciality.val() === '') {
            fieldCode = '';
        }
        params = {
            'name': 'formationEspecialityId',
            'value': fieldCode
        };
    }

    coursesSearch.searchFields(selector, params, searchFieldUrl);
}

refreshSelect = function(obj) {
    if (obj.length >= 0) {
        $(obj).selectmenu('refresh');
    }
}
/******************************************************************/
/*************************** SELECTS ******************************/
/******************************************************************/
coursesSearch.initSelects = function () {
    $.ui.selectmenu.prototype._renderItem = function( ul, item ) {
        var li = $("<li>");
        var div = $("<div>");
        if (item.value.split("_")[0] == "autonomyId") {
            div.addClass("evr-courses-search__options--autonomy");
        } else if(item.value.split("_")[0] == "provinceId") {
            div.addClass("evr-courses-search__options--province")
        }
        div.text(item.label).appendTo(li);

        return li.appendTo( ul );
    };
    var obj = $(".evr-courses-search select");
    if (obj.length > 0) {
        $(obj).selectmenu({
            classes: {
                "ui-selectmenu-menu": "evr-courses-search__options"
            }
        });
    }
}

/******************************************************************/
/************************** PAGINATION ****************************/
/******************************************************************/
coursesSearch.hidePagination = function () {
    coursesSearch.getElement(coursesSearch.id.pagination).twbsPagination('destroy');
};

coursesSearch.printPagination = function () {
    var currentPage = coursesSearch.pagination.curPage;
    var delta = coursesSearch.pagination.delta;
    var elementsSize = coursesSearch.pagination.size;
    var totalPage = Math.ceil(elementsSize / delta);
    var maxPageNumberShow = 5;

    coursesSearch.getElement(coursesSearch.id.pagination).twbsPagination({
        totalPages: totalPage,
        visiblePages: maxPageNumberShow,
        startPage: currentPage + 1,
        hideOnlyOnePage: true,
        initiateStartPageClick: false,
        paginationClass: 'paginator',
        pageClass: 'paginator__item',
        nextClass: 'paginator__item paginator__item--next',
        prevClass: 'paginator__item paginator__item--prev',
        anchorClass: 'paginator__txt',
        prev: '<',
        next: '>',
        first: 'Primero',
        last: 'Último',
        onPageClick: function (event, page) {
            coursesSearch.pagination.curPage = page - 1;
            coursesSearch.searchCourses();
        }
    });
};

/******************************************************************/
/***************************** UTILS ******************************/
/******************************************************************/
coursesSearch.beforeSend = function(divLoad, divResults) {
    coursesSearch.hidePagination();
    divResults.empty();
    coursesSearch.showLoading(divLoad);
};

coursesSearch.showLoading = function (divLoad) {
    if (divLoad.hasClass("evr-courses__loading-courses")) {
        $(".evr-courses__loading-courses").addClass("open");
    }
    divLoad.html('<div class="evr-loader-charge"></div>');
};

coursesSearch.getElement = function(str) {
    return $('#' + coursesSearch.namespace + str);
};

coursesSearch.isSearchable = function() {
    var disabled = true;
    coursesSearch.getElement(coursesSearch.id.form).find(".form-control").each(function(){
        if(this.value != "") {
            disabled = false;
            return false;
        }
    });
    coursesSearch.getElement(coursesSearch.id.simpleSearchButton).prop("disabled", disabled);
    coursesSearch.getElement(coursesSearch.id.advancedSearchButton).prop("disabled", disabled);
    return disabled;
};

coursesSearch.preSelectedOptions = function() {
    var fields = [];
    coursesSearch.getElement(coursesSearch.id.form).find(".form-control").each(function(){
        if(this.value != "") {
            fields.push(this.name);
        }
    });
    return fields;
};

coursesSearch.clearField = function(field) {
    if(coursesSearch.options.preSelectedFields.indexOf(coursesSearch.namespace + field) == -1) {
        var element = coursesSearch.getElement(field);
        element.val("").change();
        if(element.is("select")) {
            element.selectmenu("refresh");
        }
    }
};

coursesSearch.getDatesValues = function() {
    var dates = [ '', '' ];
    var searchDateInput = coursesSearch.getElement(coursesSearch.id.searchDateInput);
    var datesString = searchDateInput.val();
    if (typeof datesString != "undefined" && datesString != null && datesString != "") {
        var datesParsed = datesString.split(" - ");
        if (datesParsed.length != 2 || !coursesSearch.validateDates(datesParsed[0], datesParsed[1])) {
            coursesSearch.showErrorDate();
            dates = "";
        } else {
            dates = datesParsed;
            coursesSearch.hideErrorDate();
        }
    }
    return dates;
};

coursesSearch.validateDates = function(startDate, endDate) {
    var startDateDate = coursesSearch.parseDate(startDate);
    var endDateDate = coursesSearch.parseDate(endDate);
    if (startDateDate && endDateDate && startDateDate <= endDateDate) {
        coursesSearch.hideErrorDate();
        return true;
    } else {
        coursesSearch.showErrorDate();
        return false;
    }
};

coursesSearch.parseDate = function(str) {
    var m = null;
    if (str.length == 15) {
        /* IE11 */
        m = str.match(/^.(\d{2}).\/.(\d{2}).\/.(\d{4})$/);
    } else {
        m = str.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
    }
    return (m) ? new Date(m[3], m[2] - 1, m[1]) : null;
};

coursesSearch.showErrorDate = function() {
    coursesSearch.getElement(coursesSearch.id.searchDateInput).val('');
    coursesSearch.getElement(coursesSearch.id.errorDates).fadeIn();
};

coursesSearch.hideErrorDate = function() {
    coursesSearch.getElement(coursesSearch.id.errorDates).fadeOut();
};
async function showPerfiladoPopup(renderURL, title, popupId) {
    Liferay.Util.openWindow({
        dialog: {
            centered: true,
            draggable : false,
            resizable:false,
            destroyOnClose: true,
            cache: false,
            modal: true,
            height: 225,
            width: 300
        },
        title: title,
        id: popupId,
        uri: renderURL.toString()
    });
}

function notificationInNavBar(url){
    itemRefProfile = $("ul.evr-header__submenu-items > li.evr-header__submenu-item > ul.evr-header__dropdown-item > li.evr-header__dropdown-items > a[href*='"+url+"']");
    parent1 = $(itemRefProfile).parent("li");
    group1 = $(parent1).parent("ul");
    group1Title = $(group1).parent("li");
    linkParent = $(group1Title).children("a.evr-header__submenu-link-main");
    hamburguer = $("#heading .evr-tools__button");

    addExclamationProfile(hamburguer);
    addExclamationProfile(parent1);
    addExclamationProfile(parent1);
    addExclamationProfile(linkParent);
    addExclamationProfile(group1Title);
}

function addExclamationProfile(element){
    $(element).addClass("profile");
    $(element).prepend("<i class=\"icon-exclamation-sign\"></i>");
}
var filters = filters || {};
filters.id = filters.id || {};
filters.url = filters.url || {};


filters.init = function() {

	// Event handler
	filters.event_handler();

}

    // Event handler
    filters.event_handler = function() {

        filters.getElement(filters.id.searchButton).click({
            }, filters.searchCenters
        );


        filters.getElement(filters.id.selectCCAA).change({
            }, filters.searchProvinces
        );



            filters.getElement(filters.id.selectProvinces).change(function(){

                if ($(window).width() < 993) {
                    filters.searchCenters()
                }
            });


}

/*****************************************************************
 ************ UTILS **********************************************
 *****************************************************************/

filters.getElement = function(str) {
	return $('#' + filters.namespace + str);
}

filters.getElementsByClass = function(idStr, classStr) {
	return $('#' + filters.namespace + idStr + " ." + classStr);
}

filters.getElementByName = function(str) {
	return $('[name=' + filters.namespace + str + ']');
}

filters.getElementSelected = function(str) {
	return $('#' + filters.namespace + str + ' :selected');
}


filters.addParameters = function(url, params, withoutParams) {
	var newUrl = url;
	$.each(params, function(index, param) {
		if (withoutParams && index == 0) {
			newUrl += '?';
		} else {
			newUrl += '&';
		}
		newUrl += filters.namespace + param.name + "=" + param.value;
	});
	return newUrl;
}

filters.searchProvinces = function () {

var ccaa = $("#"+filters.namespace+"ccaa").val();
var params = [ {
		'name' : 'ccaa',
		'value' : ccaa
	}];
	var url = filters.addParameters(filters.url.searchProvinces,params);

	$.ajax({
		url : url,
		type : 'GET',
		cache : false
	}).done(function(data, textStatus, jsqXHR) {
		filters.getElement(filters.id.selectProvinces).empty();
		filters.getElement(filters.id.selectProvinces).append(data);
	}).fail(function(jqXHR, textStatus, errorThrown) {
		filters.getElement(filters.id.selectProvinces).html("");
	});
}

filters.searchCenters = function () {

    var ccaa = $("#"+filters.namespace+"ccaa").val();
    var province = $("#"+filters.namespace+"province").val();
    var postalCode = $("#"+filters.namespace+"postalCode").val();

    if (ccaa == "" && province == "" && postalCode == "") {


            $("#noFilterSelectedError").removeClass("t-hide");



    } else {

        $("#noFilterSelectedError").addClass("t-hide");
        $(".evr-loader-charge").removeClass("t-hide");

        var params = [ {
                   'name' : 'ccaa',
                   'value' : ccaa
               }, {
                   'name' : 'province',
                   'value' : province
               }, {
                   'name' : 'postalCode',
                   'value' : postalCode
       }];
       var url = filters.addParameters(filters.url.searchURL,params);

       $.ajax({
           url : url,
           type : 'GET',
           cache : false
       }).done(function(data, textStatus, jsqXHR) {
           $(".evr-loader-charge").addClass("t-hide");
           filters.getElement(filters.id.resultsDiv).html(data);
       }).fail(function(jqXHR, textStatus, errorThrown) {
           filters.getElement(filters.id.resultsDiv).html("");
       });
    }
}

function googleMaps(locations,zoom,defLat,defLong,detailPage) {

	/*
	 * Composicion de la estructura. Datos que se pasan por la plantilla
	 * locations[(name,street,phone,fax,latitud,longitud,imagen,link,contador,cp,email)]
	 */

	//Verifica si esta vacio el array locations


    var nombre="", direccion="", telefono="", fax="", imagen="",enlace="",cp="",email="",centerId="";
    var latitud = 0, longitud = 0, latitudDefault=defLat, longitudDefault = defLong;

    var map = new google.maps.Map(document.querySelector('.lfr-google-maps'), {
        center: new google.maps.LatLng(latitudDefault, longitudDefault),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var marcadores = [];

    var defaultMarker ;

    var limites = new google.maps.LatLngBounds();

    var marker, i;

    var customMarker = {
        url: '/o/cruzroja-web-theme/images/custom/icons/pin.svg',
        scaledSize: new google.maps.Size(50, 50)
    }

    var stylez = [{
        featureType: "all",
        elementType: "all",
        stylers: [{
                saturation: -100
            }
        ]
    }];
    var mapType = new google.maps.StyledMapType(stylez, {
        name: "Grayscale"
    });
    //map.mapTypes.set('tehgrayz', mapType);
    //map.setMapTypeId('tehgrayz');

    map.setZoom(parseInt(zoom));


    if (locations != undefined && Array.isArray(locations) && locations.length) {
        for (i = 0; i < locations.length; i++) {
            var infowindow = new google.maps.InfoWindow({
                // pixelOffset: new google.maps.Size(200, 150)
            });

            latitud = locations[i][4].replace(",",".");
            longitud = locations[i][5].replace(",",".");

            marker = new google.maps.Marker({
                position: new google.maps.LatLng(latitud, longitud),
                map: map,
                optimized: false,
                icon: customMarker
            });

             google.maps.event.addListener(marker,'click', (function(marker,i,infowindow){
                 return function () {
                    $(".portlet-boundary_googlemaps_ .lfr-google-maps .gm-ui-hover-effect").click();
                    nombre = locations[i][0];
                    direccion = locations[i][1];
                    telefono = (locations[i][2] != "") ? '<p class="evr-map-center__tooltip-tlf">' + locations[i][2] + '</p>' : '';
                    //fax = (locations[i][3] != "") ? 'Fax: '+locations[i][3] : '';
                    imagen = locations[i][6] != "" ? '<figure class="evr-map-center__figure"><img src="'+locations[i][6]+'" alt="'+nombre+'"/></figure>' : '';
                    centerIdLink = detailPage + "/-/centro/" + locations[i][7];
                    cp = (locations[i][8] != "") ? locations[i][8] : '';
                    email = (locations[i][9] != "") ? '<p class="evr-map-center__tooltip-mail">' + locations[i][9] + '</p>' : "";
                    infowindow.setContent('<div><div class="lfr-google-maps__ctn">' + imagen + '<div class="evr-map-center__tooltip-container"><p class="evr-map-center__tooltip-title">' + nombre + '</p><p class="evr-map-center__tooltip-link"><a target="_blank" href="' + centerIdLink + '">+ info</a></p></div><p class="evr-map-center__tooltip-text">' + direccion + '</p>' + '<p class="evr-map-center__tooltip-text evr-map-center__tooltip-text--aft">' + cp + '</p>' +  telefono + email + '</div></div>');
                    infowindow.open(map, marker);
                 };
             })(marker,i,infowindow));

            marcadores.push(marker);
            limites.extend(new google.maps.LatLng(marker.position.lat(), marker.position.lng()));
            if (locations.length == 1) {
                limites.extend(new google.maps.LatLng(marker.position.lat()-0.001, marker.position.lng()-0.001));
            }

        }
        map.fitBounds(limites);
        map.panToBounds(limites);
    }
}

