; (function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?-1!=n.indexOf(t):E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||void 0===r)return 1;if(e>r||void 0===e)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0==t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=S(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&S(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return S(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),w.isFunction=function(n){return"function"==typeof n},w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return void 0===n},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+(0|Math.random()*(t-n+1))};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};T.unescape=w.invert(T.escape);var M={escape:RegExp("["+w.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(T.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(M[n],function(t){return T[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=""+ ++N;return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){r=w.defaults({},r,w.templateSettings);var e=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,a,o){return i+=n.slice(u,o).replace(D,function(n){return"\\"+B[n]}),r&&(i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(i+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),a&&(i+="';\n"+a+"\n__p+='"),u=o+t.length,t}),i+="';\n",r.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var a=Function(r.variable||"obj","_",i)}catch(o){throw o.source=i,o}if(t)return a(t,w);var c=function(n){return a.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+i+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); ; // moment.js // version : 2.1.0 // author : Tim Wood // license : MIT // momentjs.com (function (undefined) { /************************************ Constants ************************************/ var moment, VERSION = "2.1.0", round = Math.round, i, // internal storage for language config files languages = {}, // check for nodeJS hasModule = (typeof module !== 'undefined' && module.exports), // ASP.NET json date format regex aspNetJsonRegex = /^\/?Date\((\-?\d+)/i, aspNetTimeSpanJsonRegex = /(\-)?(\d*)?\.?(\d+)\:(\d+)\:(\d+)\.?(\d{3})?/, // format tokens formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/g, localFormattingTokens = /(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g, // parsing token regexes parseTokenOneOrTwoDigits = /\d\d?/, // 0 - 99 parseTokenOneToThreeDigits = /\d{1,3}/, // 0 - 999 parseTokenThreeDigits = /\d{3}/, // 000 - 999 parseTokenFourDigits = /\d{1,4}/, // 0 - 9999 parseTokenSixDigits = /[+\-]?\d{1,6}/, // -999,999 - 999,999 parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i, // any word (or two) characters or numbers including two/three word month in arabic. parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/i, // +00:00 -00:00 +0000 -0000 or Z parseTokenT = /T/i, // T (ISO seperator) parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123 // preliminary iso regex // 0000-00-00 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 isoRegex = /^\s*\d{4}-\d\d-\d\d((T| )(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/, isoFormat = 'YYYY-MM-DDTHH:mm:ssZ', // iso time formats and regexes isoTimes = [ ['HH:mm:ss.S', /(T| )\d\d:\d\d:\d\d\.\d{1,3}/], ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/], ['HH:mm', /(T| )\d\d:\d\d/], ['HH', /(T| )\d\d/] ], // timezone chunker "+10:00" > ["10", "00"] or "-1530" > ["-15", "30"] parseTimezoneChunker = /([\+\-]|\d\d)/gi, // getter and setter names proxyGettersAndSetters = 'Date|Hours|Minutes|Seconds|Milliseconds'.split('|'), unitMillisecondFactors = { 'Milliseconds' : 1, 'Seconds' : 1e3, 'Minutes' : 6e4, 'Hours' : 36e5, 'Days' : 864e5, 'Months' : 2592e6, 'Years' : 31536e6 }, unitAliases = { ms : 'millisecond', s : 'second', m : 'minute', h : 'hour', d : 'day', w : 'week', M : 'month', y : 'year' }, // format function strings formatFunctions = {}, // tokens to ordinalize and pad ordinalizeTokens = 'DDD w W M D d'.split(' '), paddedTokens = 'M D H h m s w W'.split(' '), formatTokenFunctions = { M : function () { return this.month() + 1; }, MMM : function (format) { return this.lang().monthsShort(this, format); }, MMMM : function (format) { return this.lang().months(this, format); }, D : function () { return this.date(); }, DDD : function () { return this.dayOfYear(); }, d : function () { return this.day(); }, dd : function (format) { return this.lang().weekdaysMin(this, format); }, ddd : function (format) { return this.lang().weekdaysShort(this, format); }, dddd : function (format) { return this.lang().weekdays(this, format); }, w : function () { return this.week(); }, W : function () { return this.isoWeek(); }, YY : function () { return leftZeroFill(this.year() % 100, 2); }, YYYY : function () { return leftZeroFill(this.year(), 4); }, YYYYY : function () { return leftZeroFill(this.year(), 5); }, gg : function () { return leftZeroFill(this.weekYear() % 100, 2); }, gggg : function () { return this.weekYear(); }, ggggg : function () { return leftZeroFill(this.weekYear(), 5); }, GG : function () { return leftZeroFill(this.isoWeekYear() % 100, 2); }, GGGG : function () { return this.isoWeekYear(); }, GGGGG : function () { return leftZeroFill(this.isoWeekYear(), 5); }, e : function () { return this.weekday(); }, E : function () { return this.isoWeekday(); }, a : function () { return this.lang().meridiem(this.hours(), this.minutes(), true); }, A : function () { return this.lang().meridiem(this.hours(), this.minutes(), false); }, H : function () { return this.hours(); }, h : function () { return this.hours() % 12 || 12; }, m : function () { return this.minutes(); }, s : function () { return this.seconds(); }, S : function () { return ~~(this.milliseconds() / 100); }, SS : function () { return leftZeroFill(~~(this.milliseconds() / 10), 2); }, SSS : function () { return leftZeroFill(this.milliseconds(), 3); }, Z : function () { var a = -this.zone(), b = "+"; if (a < 0) { a = -a; b = "-"; } return b + leftZeroFill(~~(a / 60), 2) + ":" + leftZeroFill(~~a % 60, 2); }, ZZ : function () { var a = -this.zone(), b = "+"; if (a < 0) { a = -a; b = "-"; } return b + leftZeroFill(~~(10 * a / 6), 4); }, z : function () { return this.zoneAbbr(); }, zz : function () { return this.zoneName(); }, X : function () { return this.unix(); } }; function padToken(func, count) { return function (a) { return leftZeroFill(func.call(this, a), count); }; } function ordinalizeToken(func, period) { return function (a) { return this.lang().ordinal(func.call(this, a), period); }; } while (ordinalizeTokens.length) { i = ordinalizeTokens.pop(); formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i], i); } while (paddedTokens.length) { i = paddedTokens.pop(); formatTokenFunctions[i + i] = padToken(formatTokenFunctions[i], 2); } formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3); /************************************ Constructors ************************************/ function Language() { } // Moment prototype object function Moment(config) { extend(this, config); } // Duration Constructor function Duration(duration) { var years = duration.years || duration.year || duration.y || 0, months = duration.months || duration.month || duration.M || 0, weeks = duration.weeks || duration.week || duration.w || 0, days = duration.days || duration.day || duration.d || 0, hours = duration.hours || duration.hour || duration.h || 0, minutes = duration.minutes || duration.minute || duration.m || 0, seconds = duration.seconds || duration.second || duration.s || 0, milliseconds = duration.milliseconds || duration.millisecond || duration.ms || 0; // store reference to input for deterministic cloning this._input = duration; // representation for dateAddRemove this._milliseconds = milliseconds + seconds * 1e3 + // 1000 minutes * 6e4 + // 1000 * 60 hours * 36e5; // 1000 * 60 * 60 // Because of dateAddRemove treats 24 hours as different from a // day when working around DST, we need to store them separately this._days = days + weeks * 7; // It is impossible translate months into days without knowing // which months you are are talking about, so we have to store // it separately. this._months = months + years * 12; this._data = {}; this._bubble(); } /************************************ Helpers ************************************/ function extend(a, b) { for (var i in b) { if (b.hasOwnProperty(i)) { a[i] = b[i]; } } return a; } function absRound(number) { if (number < 0) { return Math.ceil(number); } else { return Math.floor(number); } } // left zero fill a number // see http://jsperf.com/left-zero-filling for performance comparison function leftZeroFill(number, targetLength) { var output = number + ''; while (output.length < targetLength) { output = '0' + output; } return output; } // helper function for _.addTime and _.subtractTime function addOrSubtractDurationFromMoment(mom, duration, isAdding, ignoreUpdateOffset) { var milliseconds = duration._milliseconds, days = duration._days, months = duration._months, minutes, hours, currentDate; if (milliseconds) { mom._d.setTime(+mom._d + milliseconds * isAdding); } // store the minutes and hours so we can restore them if (days || months) { minutes = mom.minute(); hours = mom.hour(); } if (days) { mom.date(mom.date() + days * isAdding); } if (months) { mom.month(mom.month() + months * isAdding); } if (milliseconds && !ignoreUpdateOffset) { moment.updateOffset(mom); } // restore the minutes and hours after possibly changing dst if (days || months) { mom.minute(minutes); mom.hour(hours); } } // check if is an array function isArray(input) { return Object.prototype.toString.call(input) === '[object Array]'; } // compare two arrays, return the number of differences function compareArrays(array1, array2) { var len = Math.min(array1.length, array2.length), lengthDiff = Math.abs(array1.length - array2.length), diffs = 0, i; for (i = 0; i < len; i++) { if (~~array1[i] !== ~~array2[i]) { diffs++; } } return diffs + lengthDiff; } function normalizeUnits(units) { return units ? unitAliases[units] || units.toLowerCase().replace(/(.)s$/, '$1') : units; } /************************************ Languages ************************************/ Language.prototype = { set : function (config) { var prop, i; for (i in config) { prop = config[i]; if (typeof prop === 'function') { this[i] = prop; } else { this['_' + i] = prop; } } }, _months : "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), months : function (m) { return this._months[m.month()]; }, _monthsShort : "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"), monthsShort : function (m) { return this._monthsShort[m.month()]; }, monthsParse : function (monthName) { var i, mom, regex; if (!this._monthsParse) { this._monthsParse = []; } for (i = 0; i < 12; i++) { // make the regex if we don't have it already if (!this._monthsParse[i]) { mom = moment([2000, i]); regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); } // test the regex if (this._monthsParse[i].test(monthName)) { return i; } } }, _weekdays : "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), weekdays : function (m) { return this._weekdays[m.day()]; }, _weekdaysShort : "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"), weekdaysShort : function (m) { return this._weekdaysShort[m.day()]; }, _weekdaysMin : "Su_Mo_Tu_We_Th_Fr_Sa".split("_"), weekdaysMin : function (m) { return this._weekdaysMin[m.day()]; }, weekdaysParse : function (weekdayName) { var i, mom, regex; if (!this._weekdaysParse) { this._weekdaysParse = []; } for (i = 0; i < 7; i++) { // make the regex if we don't have it already if (!this._weekdaysParse[i]) { mom = moment([2000, 1]).day(i); regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, ''); this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); } // test the regex if (this._weekdaysParse[i].test(weekdayName)) { return i; } } }, _longDateFormat : { LT : "h:mm A", L : "MM/DD/YYYY", LL : "MMMM D YYYY", LLL : "MMMM D YYYY LT", LLLL : "dddd, MMMM D YYYY LT" }, longDateFormat : function (key) { var output = this._longDateFormat[key]; if (!output && this._longDateFormat[key.toUpperCase()]) { output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) { return val.slice(1); }); this._longDateFormat[key] = output; } return output; }, isPM : function (input) { return ((input + '').toLowerCase()[0] === 'p'); }, _meridiemParse : /[ap]\.?m?\.?/i, meridiem : function (hours, minutes, isLower) { if (hours > 11) { return isLower ? 'pm' : 'PM'; } else { return isLower ? 'am' : 'AM'; } }, _calendar : { sameDay : '[Today at] LT', nextDay : '[Tomorrow at] LT', nextWeek : 'dddd [at] LT', lastDay : '[Yesterday at] LT', lastWeek : '[Last] dddd [at] LT', sameElse : 'L' }, calendar : function (key, mom) { var output = this._calendar[key]; return typeof output === 'function' ? output.apply(mom) : output; }, _relativeTime : { future : "in %s", past : "%s ago", s : "a few 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" }, relativeTime : function (number, withoutSuffix, string, isFuture) { var output = this._relativeTime[string]; return (typeof output === 'function') ? output(number, withoutSuffix, string, isFuture) : output.replace(/%d/i, number); }, pastFuture : function (diff, output) { var format = this._relativeTime[diff > 0 ? 'future' : 'past']; return typeof format === 'function' ? format(output) : format.replace(/%s/i, output); }, ordinal : function (number) { return this._ordinal.replace("%d", number); }, _ordinal : "%d", preparse : function (string) { return string; }, postformat : function (string) { return string; }, week : function (mom) { return weekOfYear(mom, this._week.dow, this._week.doy).week; }, _week : { dow : 0, // Sunday is the first day of the week. doy : 6 // The week that contains Jan 1st is the first week of the year. } }; // Loads a language definition into the `languages` cache. The function // takes a key and optionally values. If not in the browser and no values // are provided, it will load the language file module. As a convenience, // this function also returns the language values. function loadLang(key, values) { values.abbr = key; if (!languages[key]) { languages[key] = new Language(); } languages[key].set(values); return languages[key]; } // Determines which language definition to use and returns it. // // With no parameters, it will return the global language. If you // pass in a language key, such as 'en', it will return the // definition for 'en', so long as 'en' has already been loaded using // moment.lang. function getLangDefinition(key) { if (!key) { return moment.fn._lang; } if (!languages[key] && hasModule) { try { require('./lang/' + key); } catch (e) { // call with no params to set to default return moment.fn._lang; } } return languages[key]; } /************************************ Formatting ************************************/ function removeFormattingTokens(input) { if (input.match(/\[.*\]/)) { return input.replace(/^\[|\]$/g, ""); } return input.replace(/\\/g, ""); } function makeFormatFunction(format) { var array = format.match(formattingTokens), i, length; for (i = 0, length = array.length; i < length; i++) { if (formatTokenFunctions[array[i]]) { array[i] = formatTokenFunctions[array[i]]; } else { array[i] = removeFormattingTokens(array[i]); } } return function (mom) { var output = ""; for (i = 0; i < length; i++) { output += array[i] instanceof Function ? array[i].call(mom, format) : array[i]; } return output; }; } // format date using native date object function formatMoment(m, format) { var i = 5; function replaceLongDateFormatTokens(input) { return m.lang().longDateFormat(input) || input; } while (i-- && localFormattingTokens.test(format)) { format = format.replace(localFormattingTokens, replaceLongDateFormatTokens); } if (!formatFunctions[format]) { formatFunctions[format] = makeFormatFunction(format); } return formatFunctions[format](m); } /************************************ Parsing ************************************/ // get the regex to find the next token function getParseRegexForToken(token, config) { switch (token) { case 'DDDD': return parseTokenThreeDigits; case 'YYYY': return parseTokenFourDigits; case 'YYYYY': return parseTokenSixDigits; case 'S': case 'SS': case 'SSS': case 'DDD': return parseTokenOneToThreeDigits; case 'MMM': case 'MMMM': case 'dd': case 'ddd': case 'dddd': return parseTokenWord; case 'a': case 'A': return getLangDefinition(config._l)._meridiemParse; case 'X': return parseTokenTimestampMs; case 'Z': case 'ZZ': return parseTokenTimezone; case 'T': return parseTokenT; case 'MM': case 'DD': case 'YY': case 'HH': case 'hh': case 'mm': case 'ss': case 'M': case 'D': case 'd': case 'H': case 'h': case 'm': case 's': return parseTokenOneOrTwoDigits; default : return new RegExp(token.replace('\\', '')); } } function timezoneMinutesFromString(string) { var tzchunk = (parseTokenTimezone.exec(string) || [])[0], parts = (tzchunk + '').match(parseTimezoneChunker) || ['-', 0, 0], minutes = +(parts[1] * 60) + ~~parts[2]; return parts[0] === '+' ? -minutes : minutes; } // function to convert string input to date function addTimeToArrayFromToken(token, input, config) { var a, datePartArray = config._a; switch (token) { // MONTH case 'M' : // fall through to MM case 'MM' : datePartArray[1] = (input == null) ? 0 : ~~input - 1; break; case 'MMM' : // fall through to MMMM case 'MMMM' : a = getLangDefinition(config._l).monthsParse(input); // if we didn't find a month name, mark the date as invalid. if (a != null) { datePartArray[1] = a; } else { config._isValid = false; } break; // DAY OF MONTH case 'D' : // fall through to DDDD case 'DD' : // fall through to DDDD case 'DDD' : // fall through to DDDD case 'DDDD' : if (input != null) { datePartArray[2] = ~~input; } break; // YEAR case 'YY' : datePartArray[0] = ~~input + (~~input > 68 ? 1900 : 2000); break; case 'YYYY' : case 'YYYYY' : datePartArray[0] = ~~input; break; // AM / PM case 'a' : // fall through to A case 'A' : config._isPm = getLangDefinition(config._l).isPM(input); break; // 24 HOUR case 'H' : // fall through to hh case 'HH' : // fall through to hh case 'h' : // fall through to hh case 'hh' : datePartArray[3] = ~~input; break; // MINUTE case 'm' : // fall through to mm case 'mm' : datePartArray[4] = ~~input; break; // SECOND case 's' : // fall through to ss case 'ss' : datePartArray[5] = ~~input; break; // MILLISECOND case 'S' : case 'SS' : case 'SSS' : datePartArray[6] = ~~ (('0.' + input) * 1000); break; // UNIX TIMESTAMP WITH MS case 'X': config._d = new Date(parseFloat(input) * 1000); break; // TIMEZONE case 'Z' : // fall through to ZZ case 'ZZ' : config._useUTC = true; config._tzm = timezoneMinutesFromString(input); break; } // if the input is null, the date is not valid if (input == null) { config._isValid = false; } } // convert an array to a date. // the array should mirror the parameters below // note: all values past the year are optional and will default to the lowest possible value. // [year, month, day , hour, minute, second, millisecond] function dateFromArray(config) { var i, date, input = []; if (config._d) { return; } for (i = 0; i < 7; i++) { config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i]; } // add the offsets to the time to be parsed so that we can have a clean array for checking isValid input[3] += ~~((config._tzm || 0) / 60); input[4] += ~~((config._tzm || 0) % 60); date = new Date(0); if (config._useUTC) { date.setUTCFullYear(input[0], input[1], input[2]); date.setUTCHours(input[3], input[4], input[5], input[6]); } else { date.setFullYear(input[0], input[1], input[2]); date.setHours(input[3], input[4], input[5], input[6]); } config._d = date; } // date from string and format string function makeDateFromStringAndFormat(config) { // This array is used to make a Date, either with `new Date` or `Date.UTC` var tokens = config._f.match(formattingTokens), string = config._i, i, parsedInput; config._a = []; for (i = 0; i < tokens.length; i++) { parsedInput = (getParseRegexForToken(tokens[i], config).exec(string) || [])[0]; if (parsedInput) { string = string.slice(string.indexOf(parsedInput) + parsedInput.length); } // don't parse if its not a known token if (formatTokenFunctions[tokens[i]]) { addTimeToArrayFromToken(tokens[i], parsedInput, config); } } // add remaining unparsed input to the string if (string) { config._il = string; } // handle am pm if (config._isPm && config._a[3] < 12) { config._a[3] += 12; } // if is 12 am, change hours to 0 if (config._isPm === false && config._a[3] === 12) { config._a[3] = 0; } // return dateFromArray(config); } // date from string and array of format strings function makeDateFromStringAndArray(config) { var tempConfig, tempMoment, bestMoment, scoreToBeat = 99, i, currentScore; for (i = 0; i < config._f.length; i++) { tempConfig = extend({}, config); tempConfig._f = config._f[i]; makeDateFromStringAndFormat(tempConfig); tempMoment = new Moment(tempConfig); currentScore = compareArrays(tempConfig._a, tempMoment.toArray()); // if there is any input that was not parsed // add a penalty for that format if (tempMoment._il) { currentScore += tempMoment._il.length; } if (currentScore < scoreToBeat) { scoreToBeat = currentScore; bestMoment = tempMoment; } } extend(config, bestMoment); } // date from iso format function makeDateFromString(config) { var i, string = config._i, match = isoRegex.exec(string); if (match) { // match[2] should be "T" or undefined config._f = 'YYYY-MM-DD' + (match[2] || " "); for (i = 0; i < 4; i++) { if (isoTimes[i][1].exec(string)) { config._f += isoTimes[i][0]; break; } } if (parseTokenTimezone.exec(string)) { config._f += " Z"; } makeDateFromStringAndFormat(config); } else { config._d = new Date(string); } } function makeDateFromInput(config) { var input = config._i, matched = aspNetJsonRegex.exec(input); if (input === undefined) { config._d = new Date(); } else if (matched) { config._d = new Date(+matched[1]); } else if (typeof input === 'string') { makeDateFromString(config); } else if (isArray(input)) { config._a = input.slice(0); dateFromArray(config); } else { config._d = input instanceof Date ? new Date(+input) : new Date(input); } } /************************************ Relative Time ************************************/ // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize function substituteTimeAgo(string, number, withoutSuffix, isFuture, lang) { return lang.relativeTime(number || 1, !!withoutSuffix, string, isFuture); } function relativeTime(milliseconds, withoutSuffix, lang) { var seconds = round(Math.abs(milliseconds) / 1000), minutes = round(seconds / 60), hours = round(minutes / 60), days = round(hours / 24), years = round(days / 365), args = seconds < 45 && ['s', seconds] || minutes === 1 && ['m'] || minutes < 45 && ['mm', minutes] || hours === 1 && ['h'] || hours < 22 && ['hh', hours] || days === 1 && ['d'] || days <= 25 && ['dd', days] || days <= 45 && ['M'] || days < 345 && ['MM', round(days / 30)] || years === 1 && ['y'] || ['yy', years]; args[2] = withoutSuffix; args[3] = milliseconds > 0; args[4] = lang; return substituteTimeAgo.apply({}, args); } /************************************ Week of Year ************************************/ // firstDayOfWeek 0 = sun, 6 = sat // the day of the week that starts the week // (usually sunday or monday) // firstDayOfWeekOfYear 0 = sun, 6 = sat // the first week is the week that contains the first // of this day of the week // (eg. ISO weeks use thursday (4)) function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) { var end = firstDayOfWeekOfYear - firstDayOfWeek, daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(), adjustedMoment; if (daysToDayOfWeek > end) { daysToDayOfWeek -= 7; } if (daysToDayOfWeek < end - 7) { daysToDayOfWeek += 7; } adjustedMoment = moment(mom).add('d', daysToDayOfWeek); return { week: Math.ceil(adjustedMoment.dayOfYear() / 7), year: adjustedMoment.year() }; } /************************************ Top Level Functions ************************************/ function makeMoment(config) { var input = config._i, format = config._f; if (input === null || input === '') { return null; } if (typeof input === 'string') { config._i = input = getLangDefinition().preparse(input); } if (moment.isMoment(input)) { config = extend({}, input); config._d = new Date(+input._d); } else if (format) { if (isArray(format)) { makeDateFromStringAndArray(config); } else { makeDateFromStringAndFormat(config); } } else { makeDateFromInput(config); } return new Moment(config); } moment = function (input, format, lang) { return makeMoment({ _i : input, _f : format, _l : lang, _isUTC : false }); }; // creating with utc moment.utc = function (input, format, lang) { return makeMoment({ _useUTC : true, _isUTC : true, _l : lang, _i : input, _f : format }); }; // creating with unix timestamp (in seconds) moment.unix = function (input) { return moment(input * 1000); }; // duration moment.duration = function (input, key) { var isDuration = moment.isDuration(input), isNumber = (typeof input === 'number'), duration = (isDuration ? input._input : (isNumber ? {} : input)), matched = aspNetTimeSpanJsonRegex.exec(input), sign, ret; if (isNumber) { if (key) { duration[key] = input; } else { duration.milliseconds = input; } } else if (matched) { sign = (matched[1] === "-") ? -1 : 1; duration = { y: 0, d: ~~matched[2] * sign, h: ~~matched[3] * sign, m: ~~matched[4] * sign, s: ~~matched[5] * sign, ms: ~~matched[6] * sign }; } ret = new Duration(duration); if (isDuration && input.hasOwnProperty('_lang')) { ret._lang = input._lang; } return ret; }; // version number moment.version = VERSION; // default format moment.defaultFormat = isoFormat; // This function will be called whenever a moment is mutated. // It is intended to keep the offset in sync with the timezone. moment.updateOffset = function () {}; // This function will load languages and then set the global language. If // no arguments are passed in, it will simply return the current global // language key. moment.lang = function (key, values) { if (!key) { return moment.fn._lang._abbr; } if (values) { loadLang(key, values); } else if (!languages[key]) { getLangDefinition(key); } moment.duration.fn._lang = moment.fn._lang = getLangDefinition(key); }; // returns language data moment.langData = function (key) { if (key && key._lang && key._lang._abbr) { key = key._lang._abbr; } return getLangDefinition(key); }; // compare moment object moment.isMoment = function (obj) { return obj instanceof Moment; }; // for typechecking Duration objects moment.isDuration = function (obj) { return obj instanceof Duration; }; /************************************ Moment Prototype ************************************/ moment.fn = Moment.prototype = { clone : function () { return moment(this); }, valueOf : function () { return +this._d + ((this._offset || 0) * 60000); }, unix : function () { return Math.floor(+this / 1000); }, toString : function () { return this.format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ"); }, toDate : function () { return this._offset ? new Date(+this) : this._d; }, toISOString : function () { return formatMoment(moment(this).utc(), 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); }, toArray : function () { var m = this; return [ m.year(), m.month(), m.date(), m.hours(), m.minutes(), m.seconds(), m.milliseconds() ]; }, isValid : function () { if (this._isValid == null) { if (this._a) { this._isValid = !compareArrays(this._a, (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray()); } else { this._isValid = !isNaN(this._d.getTime()); } } return !!this._isValid; }, utc : function () { return this.zone(0); }, local : function () { this.zone(0); this._isUTC = false; return this; }, format : function (inputString) { var output = formatMoment(this, inputString || moment.defaultFormat); return this.lang().postformat(output); }, add : function (input, val) { var dur; // switch args to support add('s', 1) and add(1, 's') if (typeof input === 'string') { dur = moment.duration(+val, input); } else { dur = moment.duration(input, val); } addOrSubtractDurationFromMoment(this, dur, 1); return this; }, subtract : function (input, val) { var dur; // switch args to support subtract('s', 1) and subtract(1, 's') if (typeof input === 'string') { dur = moment.duration(+val, input); } else { dur = moment.duration(input, val); } addOrSubtractDurationFromMoment(this, dur, -1); return this; }, diff : function (input, units, asFloat) { var that = this._isUTC ? moment(input).zone(this._offset || 0) : moment(input).local(), zoneDiff = (this.zone() - that.zone()) * 6e4, diff, output; units = normalizeUnits(units); if (units === 'year' || units === 'month') { // average number of days in the months in the given dates diff = (this.daysInMonth() + that.daysInMonth()) * 432e5; // 24 * 60 * 60 * 1000 / 2 // difference in months output = ((this.year() - that.year()) * 12) + (this.month() - that.month()); // adjust by taking difference in days, average number of days // and dst in the given months. output += ((this - moment(this).startOf('month')) - (that - moment(that).startOf('month'))) / diff; // same as above but with zones, to negate all dst output -= ((this.zone() - moment(this).startOf('month').zone()) - (that.zone() - moment(that).startOf('month').zone())) * 6e4 / diff; if (units === 'year') { output = output / 12; } } else { diff = (this - that); output = units === 'second' ? diff / 1e3 : // 1000 units === 'minute' ? diff / 6e4 : // 1000 * 60 units === 'hour' ? diff / 36e5 : // 1000 * 60 * 60 units === 'day' ? (diff - zoneDiff) / 864e5 : // 1000 * 60 * 60 * 24, negate dst units === 'week' ? (diff - zoneDiff) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst diff; } return asFloat ? output : absRound(output); }, from : function (time, withoutSuffix) { return moment.duration(this.diff(time)).lang(this.lang()._abbr).humanize(!withoutSuffix); }, fromNow : function (withoutSuffix) { return this.from(moment(), withoutSuffix); }, calendar : function () { var diff = this.diff(moment().startOf('day'), 'days', true), format = diff < -6 ? 'sameElse' : diff < -1 ? 'lastWeek' : diff < 0 ? 'lastDay' : diff < 1 ? 'sameDay' : diff < 2 ? 'nextDay' : diff < 7 ? 'nextWeek' : 'sameElse'; return this.format(this.lang().calendar(format, this)); }, isLeapYear : function () { var year = this.year(); return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; }, isDST : function () { return (this.zone() < this.clone().month(0).zone() || this.zone() < this.clone().month(5).zone()); }, day : function (input) { var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); if (input != null) { if (typeof input === 'string') { input = this.lang().weekdaysParse(input); if (typeof input !== 'number') { return this; } } return this.add({ d : input - day }); } else { return day; } }, month : function (input) { var utc = this._isUTC ? 'UTC' : '', dayOfMonth, daysInMonth; if (input != null) { if (typeof input === 'string') { input = this.lang().monthsParse(input); if (typeof input !== 'number') { return this; } } dayOfMonth = this.date(); this.date(1); this._d['set' + utc + 'Month'](input); this.date(Math.min(dayOfMonth, this.daysInMonth())); moment.updateOffset(this); return this; } else { return this._d['get' + utc + 'Month'](); } }, startOf: function (units) { units = normalizeUnits(units); // the following switch intentionally omits break keywords // to utilize falling through the cases. switch (units) { case 'year': this.month(0); /* falls through */ case 'month': this.date(1); /* falls through */ case 'week': case 'day': this.hours(0); /* falls through */ case 'hour': this.minutes(0); /* falls through */ case 'minute': this.seconds(0); /* falls through */ case 'second': this.milliseconds(0); /* falls through */ } // weeks are a special case if (units === 'week') { this.weekday(0); } return this; }, endOf: function (units) { return this.startOf(units).add(units, 1).subtract('ms', 1); }, isAfter: function (input, units) { units = typeof units !== 'undefined' ? units : 'millisecond'; return +this.clone().startOf(units) > +moment(input).startOf(units); }, isBefore: function (input, units) { units = typeof units !== 'undefined' ? units : 'millisecond'; return +this.clone().startOf(units) < +moment(input).startOf(units); }, isSame: function (input, units) { units = typeof units !== 'undefined' ? units : 'millisecond'; return +this.clone().startOf(units) === +moment(input).startOf(units); }, min: function (other) { other = moment.apply(null, arguments); return other < this ? this : other; }, max: function (other) { other = moment.apply(null, arguments); return other > this ? this : other; }, zone : function (input) { var offset = this._offset || 0; if (input != null) { if (typeof input === "string") { input = timezoneMinutesFromString(input); } if (Math.abs(input) < 16) { input = input * 60; } this._offset = input; this._isUTC = true; if (offset !== input) { addOrSubtractDurationFromMoment(this, moment.duration(offset - input, 'm'), 1, true); } } else { return this._isUTC ? offset : this._d.getTimezoneOffset(); } return this; }, zoneAbbr : function () { return this._isUTC ? "UTC" : ""; }, zoneName : function () { return this._isUTC ? "Coordinated Universal Time" : ""; }, daysInMonth : function () { return moment.utc([this.year(), this.month() + 1, 0]).date(); }, dayOfYear : function (input) { var dayOfYear = round((moment(this).startOf('day') - moment(this).startOf('year')) / 864e5) + 1; return input == null ? dayOfYear : this.add("d", (input - dayOfYear)); }, weekYear : function (input) { var year = weekOfYear(this, this.lang()._week.dow, this.lang()._week.doy).year; return input == null ? year : this.add("y", (input - year)); }, isoWeekYear : function (input) { var year = weekOfYear(this, 1, 4).year; return input == null ? year : this.add("y", (input - year)); }, week : function (input) { var week = this.lang().week(this); return input == null ? week : this.add("d", (input - week) * 7); }, isoWeek : function (input) { var week = weekOfYear(this, 1, 4).week; return input == null ? week : this.add("d", (input - week) * 7); }, weekday : function (input) { var weekday = (this._d.getDay() + 7 - this.lang()._week.dow) % 7; return input == null ? weekday : this.add("d", input - weekday); }, isoWeekday : function (input) { // behaves the same as moment#day except // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) // as a setter, sunday should belong to the previous week. return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7); }, // If passed a language key, it will set the language for this // instance. Otherwise, it will return the language configuration // variables for this instance. lang : function (key) { if (key === undefined) { return this._lang; } else { this._lang = getLangDefinition(key); return this; } } }; // helper for adding shortcuts function makeGetterAndSetter(name, key) { moment.fn[name] = moment.fn[name + 's'] = function (input) { var utc = this._isUTC ? 'UTC' : ''; if (input != null) { this._d['set' + utc + key](input); moment.updateOffset(this); return this; } else { return this._d['get' + utc + key](); } }; } // loop through and add shortcuts (Month, Date, Hours, Minutes, Seconds, Milliseconds) for (i = 0; i < proxyGettersAndSetters.length; i ++) { makeGetterAndSetter(proxyGettersAndSetters[i].toLowerCase().replace(/s$/, ''), proxyGettersAndSetters[i]); } // add shortcut for year (uses different syntax than the getter/setter 'year' == 'FullYear') makeGetterAndSetter('year', 'FullYear'); // add plural methods moment.fn.days = moment.fn.day; moment.fn.months = moment.fn.month; moment.fn.weeks = moment.fn.week; moment.fn.isoWeeks = moment.fn.isoWeek; // add aliased format methods moment.fn.toJSON = moment.fn.toISOString; /************************************ Duration Prototype ************************************/ moment.duration.fn = Duration.prototype = { _bubble : function () { var milliseconds = this._milliseconds, days = this._days, months = this._months, data = this._data, seconds, minutes, hours, years; // The following code bubbles up values, see the tests for // examples of what that means. data.milliseconds = milliseconds % 1000; seconds = absRound(milliseconds / 1000); data.seconds = seconds % 60; minutes = absRound(seconds / 60); data.minutes = minutes % 60; hours = absRound(minutes / 60); data.hours = hours % 24; days += absRound(hours / 24); data.days = days % 30; months += absRound(days / 30); data.months = months % 12; years = absRound(months / 12); data.years = years; }, weeks : function () { return absRound(this.days() / 7); }, valueOf : function () { return this._milliseconds + this._days * 864e5 + (this._months % 12) * 2592e6 + ~~(this._months / 12) * 31536e6; }, humanize : function (withSuffix) { var difference = +this, output = relativeTime(difference, !withSuffix, this.lang()); if (withSuffix) { output = this.lang().pastFuture(difference, output); } return this.lang().postformat(output); }, add : function (input, val) { // supports only 2.0-style add(1, 's') or add(moment) var dur = moment.duration(input, val); this._milliseconds += dur._milliseconds; this._days += dur._days; this._months += dur._months; this._bubble(); return this; }, subtract : function (input, val) { var dur = moment.duration(input, val); this._milliseconds -= dur._milliseconds; this._days -= dur._days; this._months -= dur._months; this._bubble(); return this; }, get : function (units) { units = normalizeUnits(units); return this[units.toLowerCase() + 's'](); }, as : function (units) { units = normalizeUnits(units); return this['as' + units.charAt(0).toUpperCase() + units.slice(1) + 's'](); }, lang : moment.fn.lang }; function makeDurationGetter(name) { moment.duration.fn[name] = function () { return this._data[name]; }; } function makeDurationAsGetter(name, factor) { moment.duration.fn['as' + name] = function () { return +this / factor; }; } for (i in unitMillisecondFactors) { if (unitMillisecondFactors.hasOwnProperty(i)) { makeDurationAsGetter(i, unitMillisecondFactors[i]); makeDurationGetter(i.toLowerCase()); } } makeDurationAsGetter('Weeks', 6048e5); moment.duration.fn.asMonths = function () { return (+this - this.years() * 31536e6) / 2592e6 + this.years() * 12; }; /************************************ Default Lang ************************************/ // Set default language, other languages will inherit from English. moment.lang('en', { ordinal : function (number) { var b = number % 10, output = (~~ (number % 100 / 10) === 1) ? 'th' : (b === 1) ? 'st' : (b === 2) ? 'nd' : (b === 3) ? 'rd' : 'th'; return number + output; } }); /************************************ Exposing Moment ************************************/ // CommonJS module is defined if (hasModule) { module.exports = moment; } /*global ender:false */ if (typeof ender === 'undefined') { // here, `this` means `window` in the browser, or `global` on the server // add `moment` as a global object via a string identifier, // for Closure Compiler "advanced" mode this['moment'] = moment; } /*global define:false */ if (typeof define === "function" && define.amd) { define("moment", [], function () { return moment; }); } }).call(this); ; // ┌────────────────────────────────────────────────────────────────────┐ \\ // │ Raphaël 2.1.0 - JavaScript Vector Library │ \\ // ├────────────────────────────────────────────────────────────────────┤ \\ // │ Copyright © 2008-2012 Dmitry Baranovskiy (http://raphaeljs.com) │ \\ // │ Copyright © 2008-2012 Sencha Labs (http://sencha.com) │ \\ // ├────────────────────────────────────────────────────────────────────┤ \\ // │ Licensed under the MIT (http://raphaeljs.com/license.html) license.│ \\ // └────────────────────────────────────────────────────────────────────┘ \\ (function(a){var b="0.3.4",c="hasOwnProperty",d=/[\.\/]/,e="*",f=function(){},g=function(a,b){return a-b},h,i,j={n:{}},k=function(a,b){var c=j,d=i,e=Array.prototype.slice.call(arguments,2),f=k.listeners(a),l=0,m=!1,n,o=[],p={},q=[],r=h,s=[];h=a,i=0;for(var t=0,u=f.length;tf*b.top){e=b.percents[y],p=b.percents[y-1]||0,t=t/b.top*(e-p),o=b.percents[y+1],j=b.anim[e];break}f&&d.attr(b.anim[b.percents[y]])}if(!!j){if(!k){for(var A in j)if(j[g](A))if(U[g](A)||d.paper.customAttributes[g](A)){u[A]=d.attr(A),u[A]==null&&(u[A]=T[A]),v[A]=j[A];switch(U[A]){case C:w[A]=(v[A]-u[A])/t;break;case"colour":u[A]=a.getRGB(u[A]);var B=a.getRGB(v[A]);w[A]={r:(B.r-u[A].r)/t,g:(B.g-u[A].g)/t,b:(B.b-u[A].b)/t};break;case"path":var D=bR(u[A],v[A]),E=D[1];u[A]=D[0],w[A]=[];for(y=0,z=u[A].length;yd)return d;while(cf?c=e:d=e,e=(d-c)/2+c}return e}function n(a,b){var c=o(a,b);return((l*c+k)*c+j)*c}function m(a){return((i*a+h)*a+g)*a}var g=3*b,h=3*(d-b)-g,i=1-g-h,j=3*c,k=3*(e-c)-j,l=1-j-k;return n(a,1/(200*f))}function cq(){return this.x+q+this.y+q+this.width+" × "+this.height}function cp(){return this.x+q+this.y}function cb(a,b,c,d,e,f){a!=null?(this.a=+a,this.b=+b,this.c=+c,this.d=+d,this.e=+e,this.f=+f):(this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0)}function bH(b,c,d){b=a._path2curve(b),c=a._path2curve(c);var e,f,g,h,i,j,k,l,m,n,o=d?0:[];for(var p=0,q=b.length;p=0&&y<=1&&A>=0&&A<=1&&(d?n++:n.push({x:x.x,y:x.y,t1:y,t2:A}))}}return n}function bF(a,b){return bG(a,b,1)}function bE(a,b){return bG(a,b)}function bD(a,b,c,d,e,f,g,h){if(!(x(a,c)x(e,g)||x(b,d)x(f,h))){var i=(a*d-b*c)*(e-g)-(a-c)*(e*h-f*g),j=(a*d-b*c)*(f-h)-(b-d)*(e*h-f*g),k=(a-c)*(f-h)-(b-d)*(e-g);if(!k)return;var l=i/k,m=j/k,n=+l.toFixed(2),o=+m.toFixed(2);if(n<+y(a,c).toFixed(2)||n>+x(a,c).toFixed(2)||n<+y(e,g).toFixed(2)||n>+x(e,g).toFixed(2)||o<+y(b,d).toFixed(2)||o>+x(b,d).toFixed(2)||o<+y(f,h).toFixed(2)||o>+x(f,h).toFixed(2))return;return{x:l,y:m}}}function bC(a,b,c,d,e,f,g,h,i){if(!(i<0||bB(a,b,c,d,e,f,g,h)n)k/=2,l+=(m1?1:i<0?0:i;var j=i/2,k=12,l=[-0.1252,.1252,-0.3678,.3678,-0.5873,.5873,-0.7699,.7699,-0.9041,.9041,-0.9816,.9816],m=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],n=0;for(var o=0;od;d+=2){var f=[{x:+a[d-2],y:+a[d-1]},{x:+a[d],y:+a[d+1]},{x:+a[d+2],y:+a[d+3]},{x:+a[d+4],y:+a[d+5]}];b?d?e-4==d?f[3]={x:+a[0],y:+a[1]}:e-2==d&&(f[2]={x:+a[0],y:+a[1]},f[3]={x:+a[2],y:+a[3]}):f[0]={x:+a[e-2],y:+a[e-1]}:e-4==d?f[3]=f[2]:d||(f[0]={x:+a[d],y:+a[d+1]}),c.push(["C",(-f[0].x+6*f[1].x+f[2].x)/6,(-f[0].y+6*f[1].y+f[2].y)/6,(f[1].x+6*f[2].x-f[3].x)/6,(f[1].y+6*f[2].y-f[3].y)/6,f[2].x,f[2].y])}return c}function bx(){return this.hex}function bv(a,b,c){function d(){var e=Array.prototype.slice.call(arguments,0),f=e.join("␀"),h=d.cache=d.cache||{},i=d.count=d.count||[];if(h[g](f)){bu(i,f);return c?c(h[f]):h[f]}i.length>=1e3&&delete h[i.shift()],i.push(f),h[f]=a[m](b,e);return c?c(h[f]):h[f]}return d}function bu(a,b){for(var c=0,d=a.length;c',bl=bk.firstChild,bl.style.behavior="url(#default#VML)";if(!bl||typeof bl.adj!="object")return a.type=p;bk=null}a.svg=!(a.vml=a.type=="VML"),a._Paper=j,a.fn=k=j.prototype=a.prototype,a._id=0,a._oid=0,a.is=function(a,b){b=v.call(b);if(b=="finite")return!M[g](+a);if(b=="array")return a instanceof Array;return b=="null"&&a===null||b==typeof a&&a!==null||b=="object"&&a===Object(a)||b=="array"&&Array.isArray&&Array.isArray(a)||H.call(a).slice(8,-1).toLowerCase()==b},a.angle=function(b,c,d,e,f,g){if(f==null){var h=b-d,i=c-e;if(!h&&!i)return 0;return(180+w.atan2(-i,-h)*180/B+360)%360}return a.angle(b,c,f,g)-a.angle(d,e,f,g)},a.rad=function(a){return a%360*B/180},a.deg=function(a){return a*180/B%360},a.snapTo=function(b,c,d){d=a.is(d,"finite")?d:10;if(a.is(b,E)){var e=b.length;while(e--)if(z(b[e]-c)<=d)return b[e]}else{b=+b;var f=c%b;if(fb-d)return c-f+b}return c};var bn=a.createUUID=function(a,b){return function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(a,b).toUpperCase()}}(/[xy]/g,function(a){var b=w.random()*16|0,c=a=="x"?b:b&3|8;return c.toString(16)});a.setWindow=function(b){eve("raphael.setWindow",a,h.win,b),h.win=b,h.doc=h.win.document,a._engine.initWin&&a._engine.initWin(h.win)};var bo=function(b){if(a.vml){var c=/^\s+|\s+$/g,d;try{var e=new ActiveXObject("htmlfile");e.write(""),e.close(),d=e.body}catch(f){d=createPopup().document.body}var g=d.createTextRange();bo=bv(function(a){try{d.style.color=r(a).replace(c,p);var b=g.queryCommandValue("ForeColor");b=(b&255)<<16|b&65280|(b&16711680)>>>16;return"#"+("000000"+b.toString(16)).slice(-6)}catch(e){return"none"}})}else{var i=h.doc.createElement("i");i.title="Raphaël Colour Picker",i.style.display="none",h.doc.body.appendChild(i),bo=bv(function(a){i.style.color=a;return h.doc.defaultView.getComputedStyle(i,p).getPropertyValue("color")})}return bo(b)},bp=function(){return"hsb("+[this.h,this.s,this.b]+")"},bq=function(){return"hsl("+[this.h,this.s,this.l]+")"},br=function(){return this.hex},bs=function(b,c,d){c==null&&a.is(b,"object")&&"r"in b&&"g"in b&&"b"in b&&(d=b.b,c=b.g,b=b.r);if(c==null&&a.is(b,D)){var e=a.getRGB(b);b=e.r,c=e.g,d=e.b}if(b>1||c>1||d>1)b/=255,c/=255,d/=255;return[b,c,d]},bt=function(b,c,d,e){b*=255,c*=255,d*=255;var f={r:b,g:c,b:d,hex:a.rgb(b,c,d),toString:br};a.is(e,"finite")&&(f.opacity=e);return f};a.color=function(b){var c;a.is(b,"object")&&"h"in b&&"s"in b&&"b"in b?(c=a.hsb2rgb(b),b.r=c.r,b.g=c.g,b.b=c.b,b.hex=c.hex):a.is(b,"object")&&"h"in b&&"s"in b&&"l"in b?(c=a.hsl2rgb(b),b.r=c.r,b.g=c.g,b.b=c.b,b.hex=c.hex):(a.is(b,"string")&&(b=a.getRGB(b)),a.is(b,"object")&&"r"in b&&"g"in b&&"b"in b?(c=a.rgb2hsl(b),b.h=c.h,b.s=c.s,b.l=c.l,c=a.rgb2hsb(b),b.v=c.b):(b={hex:"none"},b.r=b.g=b.b=b.h=b.s=b.v=b.l=-1)),b.toString=br;return b},a.hsb2rgb=function(a,b,c,d){this.is(a,"object")&&"h"in a&&"s"in a&&"b"in a&&(c=a.b,b=a.s,a=a.h,d=a.o),a*=360;var e,f,g,h,i;a=a%360/60,i=c*b,h=i*(1-z(a%2-1)),e=f=g=c-i,a=~~a,e+=[i,h,0,0,h,i][a],f+=[h,i,i,h,0,0][a],g+=[0,0,h,i,i,h][a];return bt(e,f,g,d)},a.hsl2rgb=function(a,b,c,d){this.is(a,"object")&&"h"in a&&"s"in a&&"l"in a&&(c=a.l,b=a.s,a=a.h);if(a>1||b>1||c>1)a/=360,b/=100,c/=100;a*=360;var e,f,g,h,i;a=a%360/60,i=2*b*(c<.5?c:1-c),h=i*(1-z(a%2-1)),e=f=g=c-i/2,a=~~a,e+=[i,h,0,0,h,i][a],f+=[h,i,i,h,0,0][a],g+=[0,0,h,i,i,h][a];return bt(e,f,g,d)},a.rgb2hsb=function(a,b,c){c=bs(a,b,c),a=c[0],b=c[1],c=c[2];var d,e,f,g;f=x(a,b,c),g=f-y(a,b,c),d=g==0?null:f==a?(b-c)/g:f==b?(c-a)/g+2:(a-b)/g+4,d=(d+360)%6*60/360,e=g==0?0:g/f;return{h:d,s:e,b:f,toString:bp}},a.rgb2hsl=function(a,b,c){c=bs(a,b,c),a=c[0],b=c[1],c=c[2];var d,e,f,g,h,i;g=x(a,b,c),h=y(a,b,c),i=g-h,d=i==0?null:g==a?(b-c)/i:g==b?(c-a)/i+2:(a-b)/i+4,d=(d+360)%6*60/360,f=(g+h)/2,e=i==0?0:f<.5?i/(2*f):i/(2-2*f);return{h:d,s:e,l:f,toString:bq}},a._path2string=function(){return this.join(",").replace(Y,"$1")};var bw=a._preload=function(a,b){var c=h.doc.createElement("img");c.style.cssText="position:absolute;left:-9999em;top:-9999em",c.onload=function(){b.call(this),this.onload=null,h.doc.body.removeChild(this)},c.onerror=function(){h.doc.body.removeChild(this)},h.doc.body.appendChild(c),c.src=a};a.getRGB=bv(function(b){if(!b||!!((b=r(b)).indexOf("-")+1))return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:bx};if(b=="none")return{r:-1,g:-1,b:-1,hex:"none",toString:bx};!X[g](b.toLowerCase().substring(0,2))&&b.charAt()!="#"&&(b=bo(b));var c,d,e,f,h,i,j,k=b.match(L);if(k){k[2]&&(f=R(k[2].substring(5),16),e=R(k[2].substring(3,5),16),d=R(k[2].substring(1,3),16)),k[3]&&(f=R((i=k[3].charAt(3))+i,16),e=R((i=k[3].charAt(2))+i,16),d=R((i=k[3].charAt(1))+i,16)),k[4]&&(j=k[4][s](W),d=Q(j[0]),j[0].slice(-1)=="%"&&(d*=2.55),e=Q(j[1]),j[1].slice(-1)=="%"&&(e*=2.55),f=Q(j[2]),j[2].slice(-1)=="%"&&(f*=2.55),k[1].toLowerCase().slice(0,4)=="rgba"&&(h=Q(j[3])),j[3]&&j[3].slice(-1)=="%"&&(h/=100));if(k[5]){j=k[5][s](W),d=Q(j[0]),j[0].slice(-1)=="%"&&(d*=2.55),e=Q(j[1]),j[1].slice(-1)=="%"&&(e*=2.55),f=Q(j[2]),j[2].slice(-1)=="%"&&(f*=2.55),(j[0].slice(-3)=="deg"||j[0].slice(-1)=="°")&&(d/=360),k[1].toLowerCase().slice(0,4)=="hsba"&&(h=Q(j[3])),j[3]&&j[3].slice(-1)=="%"&&(h/=100);return a.hsb2rgb(d,e,f,h)}if(k[6]){j=k[6][s](W),d=Q(j[0]),j[0].slice(-1)=="%"&&(d*=2.55),e=Q(j[1]),j[1].slice(-1)=="%"&&(e*=2.55),f=Q(j[2]),j[2].slice(-1)=="%"&&(f*=2.55),(j[0].slice(-3)=="deg"||j[0].slice(-1)=="°")&&(d/=360),k[1].toLowerCase().slice(0,4)=="hsla"&&(h=Q(j[3])),j[3]&&j[3].slice(-1)=="%"&&(h/=100);return a.hsl2rgb(d,e,f,h)}k={r:d,g:e,b:f,toString:bx},k.hex="#"+(16777216|f|e<<8|d<<16).toString(16).slice(1),a.is(h,"finite")&&(k.opacity=h);return k}return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:bx}},a),a.hsb=bv(function(b,c,d){return a.hsb2rgb(b,c,d).hex}),a.hsl=bv(function(b,c,d){return a.hsl2rgb(b,c,d).hex}),a.rgb=bv(function(a,b,c){return"#"+(16777216|c|b<<8|a<<16).toString(16).slice(1)}),a.getColor=function(a){var b=this.getColor.start=this.getColor.start||{h:0,s:1,b:a||.75},c=this.hsb2rgb(b.h,b.s,b.b);b.h+=.075,b.h>1&&(b.h=0,b.s-=.2,b.s<=0&&(this.getColor.start={h:0,s:1,b:b.b}));return c.hex},a.getColor.reset=function(){delete this.start},a.parsePathString=function(b){if(!b)return null;var c=bz(b);if(c.arr)return bJ(c.arr);var d={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},e=[];a.is(b,E)&&a.is(b[0],E)&&(e=bJ(b)),e.length||r(b).replace(Z,function(a,b,c){var f=[],g=b.toLowerCase();c.replace(_,function(a,b){b&&f.push(+b)}),g=="m"&&f.length>2&&(e.push([b][n](f.splice(0,2))),g="l",b=b=="m"?"l":"L");if(g=="r")e.push([b][n](f));else while(f.length>=d[g]){e.push([b][n](f.splice(0,d[g])));if(!d[g])break}}),e.toString=a._path2string,c.arr=bJ(e);return e},a.parseTransformString=bv(function(b){if(!b)return null;var c={r:3,s:4,t:2,m:6},d=[];a.is(b,E)&&a.is(b[0],E)&&(d=bJ(b)),d.length||r(b).replace($,function(a,b,c){var e=[],f=v.call(b);c.replace(_,function(a,b){b&&e.push(+b)}),d.push([b][n](e))}),d.toString=a._path2string;return d});var bz=function(a){var b=bz.ps=bz.ps||{};b[a]?b[a].sleep=100:b[a]={sleep:100},setTimeout(function(){for(var c in b)b[g](c)&&c!=a&&(b[c].sleep--,!b[c].sleep&&delete b[c])});return b[a]};a.findDotsAtSegment=function(a,b,c,d,e,f,g,h,i){var j=1-i,k=A(j,3),l=A(j,2),m=i*i,n=m*i,o=k*a+l*3*i*c+j*3*i*i*e+n*g,p=k*b+l*3*i*d+j*3*i*i*f+n*h,q=a+2*i*(c-a)+m*(e-2*c+a),r=b+2*i*(d-b)+m*(f-2*d+b),s=c+2*i*(e-c)+m*(g-2*e+c),t=d+2*i*(f-d)+m*(h-2*f+d),u=j*a+i*c,v=j*b+i*d,x=j*e+i*g,y=j*f+i*h,z=90-w.atan2(q-s,r-t)*180/B;(q>s||r=a.x&&b<=a.x2&&c>=a.y&&c<=a.y2},a.isBBoxIntersect=function(b,c){var d=a.isPointInsideBBox;return d(c,b.x,b.y)||d(c,b.x2,b.y)||d(c,b.x,b.y2)||d(c,b.x2,b.y2)||d(b,c.x,c.y)||d(b,c.x2,c.y)||d(b,c.x,c.y2)||d(b,c.x2,c.y2)||(b.xc.x||c.xb.x)&&(b.yc.y||c.yb.y)},a.pathIntersection=function(a,b){return bH(a,b)},a.pathIntersectionNumber=function(a,b){return bH(a,b,1)},a.isPointInsidePath=function(b,c,d){var e=a.pathBBox(b);return a.isPointInsideBBox(e,c,d)&&bH(b,[["M",c,d],["H",e.x2+10]],1)%2==1},a._removedFactory=function(a){return function(){eve("raphael.log",null,"Raphaël: you are calling to method “"+a+"” of removed object",a)}};var bI=a.pathBBox=function(a){var b=bz(a);if(b.bbox)return b.bbox;if(!a)return{x:0,y:0,width:0,height:0,x2:0,y2:0};a=bR(a);var c=0,d=0,e=[],f=[],g;for(var h=0,i=a.length;h1&&(v=w.sqrt(v),c=v*c,d=v*d);var x=c*c,y=d*d,A=(f==g?-1:1)*w.sqrt(z((x*y-x*u*u-y*t*t)/(x*u*u+y*t*t))),C=A*c*u/d+(a+h)/2,D=A*-d*t/c+(b+i)/2,E=w.asin(((b-D)/d).toFixed(9)),F=w.asin(((i-D)/d).toFixed(9));E=aF&&(E=E-B*2),!g&&F>E&&(F=F-B*2)}else E=j[0],F=j[1],C=j[2],D=j[3];var G=F-E;if(z(G)>k){var H=F,I=h,J=i;F=E+k*(g&&F>E?1:-1),h=C+c*w.cos(F),i=D+d*w.sin(F),m=bO(h,i,c,d,e,0,g,I,J,[F,H,C,D])}G=F-E;var K=w.cos(E),L=w.sin(E),M=w.cos(F),N=w.sin(F),O=w.tan(G/4),P=4/3*c*O,Q=4/3*d*O,R=[a,b],S=[a+P*L,b-Q*K],T=[h+P*N,i-Q*M],U=[h,i];S[0]=2*R[0]-S[0],S[1]=2*R[1]-S[1];if(j)return[S,T,U][n](m);m=[S,T,U][n](m).join()[s](",");var V=[];for(var W=0,X=m.length;W"1e12"&&(l=.5),z(n)>"1e12"&&(n=.5),l>0&&l<1&&(q=bP(a,b,c,d,e,f,g,h,l),p.push(q.x),o.push(q.y)),n>0&&n<1&&(q=bP(a,b,c,d,e,f,g,h,n),p.push(q.x),o.push(q.y)),i=f-2*d+b-(h-2*f+d),j=2*(d-b)-2*(f-d),k=b-d,l=(-j+w.sqrt(j*j-4*i*k))/2/i,n=(-j-w.sqrt(j*j-4*i*k))/2/i,z(l)>"1e12"&&(l=.5),z(n)>"1e12"&&(n=.5),l>0&&l<1&&(q=bP(a,b,c,d,e,f,g,h,l),p.push(q.x),o.push(q.y)),n>0&&n<1&&(q=bP(a,b,c,d,e,f,g,h,n),p.push(q.x),o.push(q.y));return{min:{x:y[m](0,p),y:y[m](0,o)},max:{x:x[m](0,p),y:x[m](0,o)}}}),bR=a._path2curve=bv(function(a,b){var c=!b&&bz(a);if(!b&&c.curve)return bJ(c.curve);var d=bL(a),e=b&&bL(b),f={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},g={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},h=function(a,b){var c,d;if(!a)return["C",b.x,b.y,b.x,b.y,b.x,b.y];!(a[0]in{T:1,Q:1})&&(b.qx=b.qy=null);switch(a[0]){case"M":b.X=a[1],b.Y=a[2];break;case"A":a=["C"][n](bO[m](0,[b.x,b.y][n](a.slice(1))));break;case"S":c=b.x+(b.x-(b.bx||b.x)),d=b.y+(b.y-(b.by||b.y)),a=["C",c,d][n](a.slice(1));break;case"T":b.qx=b.x+(b.x-(b.qx||b.x)),b.qy=b.y+(b.y-(b.qy||b.y)),a=["C"][n](bN(b.x,b.y,b.qx,b.qy,a[1],a[2]));break;case"Q":b.qx=a[1],b.qy=a[2],a=["C"][n](bN(b.x,b.y,a[1],a[2],a[3],a[4]));break;case"L":a=["C"][n](bM(b.x,b.y,a[1],a[2]));break;case"H":a=["C"][n](bM(b.x,b.y,a[1],b.y));break;case"V":a=["C"][n](bM(b.x,b.y,b.x,a[1]));break;case"Z":a=["C"][n](bM(b.x,b.y,b.X,b.Y))}return a},i=function(a,b){if(a[b].length>7){a[b].shift();var c=a[b];while(c.length)a.splice(b++,0,["C"][n](c.splice(0,6)));a.splice(b,1),l=x(d.length,e&&e.length||0)}},j=function(a,b,c,f,g){a&&b&&a[g][0]=="M"&&b[g][0]!="M"&&(b.splice(g,0,["M",f.x,f.y]),c.bx=0,c.by=0,c.x=a[g][1],c.y=a[g][2],l=x(d.length,e&&e.length||0))};for(var k=0,l=x(d.length,e&&e.length||0);ke){if(c&&!l.start){m=cs(g,h,i[1],i[2],i[3],i[4],i[5],i[6],e-n),k+=["C"+m.start.x,m.start.y,m.m.x,m.m.y,m.x,m.y];if(f)return k;l.start=k,k=["M"+m.x,m.y+"C"+m.n.x,m.n.y,m.end.x,m.end.y,i[5],i[6]].join(),n+=j,g=+i[5],h=+i[6];continue}if(!b&&!c){m=cs(g,h,i[1],i[2],i[3],i[4],i[5],i[6],e-n);return{x:m.x,y:m.y,alpha:m.alpha}}}n+=j,g=+i[5],h=+i[6]}k+=i.shift()+i}l.end=k,m=b?n:c?l:a.findDotsAtSegment(g,h,i[0],i[1],i[2],i[3],i[4],i[5],1),m.alpha&&(m={x:m.x,y:m.y,alpha:m.alpha});return m}},cu=ct(1),cv=ct(),cw=ct(0,1);a.getTotalLength=cu,a.getPointAtLength=cv,a.getSubpath=function(a,b,c){if(this.getTotalLength(a)-c<1e-6)return cw(a,b).end;var d=cw(a,c,1);return b?cw(d,b).end:d},cl.getTotalLength=function(){if(this.type=="path"){if(this.node.getTotalLength)return this.node.getTotalLength();return cu(this.attrs.path)}},cl.getPointAtLength=function(a){if(this.type=="path")return cv(this.attrs.path,a)},cl.getSubpath=function(b,c){if(this.type=="path")return a.getSubpath(this.attrs.path,b,c)};var cx=a.easing_formulas={linear:function(a){return a},"<":function(a){return A(a,1.7)},">":function(a){return A(a,.48)},"<>":function(a){var b=.48-a/1.04,c=w.sqrt(.1734+b*b),d=c-b,e=A(z(d),1/3)*(d<0?-1:1),f=-c-b,g=A(z(f),1/3)*(f<0?-1:1),h=e+g+.5;return(1-h)*3*h*h+h*h*h},backIn:function(a){var b=1.70158;return a*a*((b+1)*a-b)},backOut:function(a){a=a-1;var b=1.70158;return a*a*((b+1)*a+b)+1},elastic:function(a){if(a==!!a)return a;return A(2,-10*a)*w.sin((a-.075)*2*B/.3)+1},bounce:function(a){var b=7.5625,c=2.75,d;a<1/c?d=b*a*a:a<2/c?(a-=1.5/c,d=b*a*a+.75):a<2.5/c?(a-=2.25/c,d=b*a*a+.9375):(a-=2.625/c,d=b*a*a+.984375);return d}};cx.easeIn=cx["ease-in"]=cx["<"],cx.easeOut=cx["ease-out"]=cx[">"],cx.easeInOut=cx["ease-in-out"]=cx["<>"],cx["back-in"]=cx.backIn,cx["back-out"]=cx.backOut;var cy=[],cz=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,16)},cA=function(){var b=+(new Date),c=0;for(;c1&&!d.next){for(s in k)k[g](s)&&(r[s]=d.totalOrigin[s]);d.el.attr(r),cE(d.anim,d.el,d.anim.percents[0],null,d.totalOrigin,d.repeat-1)}d.next&&!d.stop&&cE(d.anim,d.el,d.next,null,d.totalOrigin,d.repeat)}}a.svg&&m&&m.paper&&m.paper.safari(),cy.length&&cz(cA)},cB=function(a){return a>255?255:a<0?0:a};cl.animateWith=function(b,c,d,e,f,g){var h=this;if(h.removed){g&&g.call(h);return h}var i=d instanceof cD?d:a.animation(d,e,f,g),j,k;cE(i,h,i.percents[0],null,h.attr());for(var l=0,m=cy.length;l.5)*2-1;i(m-.5,2)+i(n-.5,2)>.25&&(n=f.sqrt(.25-i(m-.5,2))*e+.5)&&n!=.5&&(n=n.toFixed(5)-1e-5*e)}return l}),e=e.split(/\s*\-\s*/);if(j=="linear"){var t=e.shift();t=-d(t);if(isNaN(t))return null;var u=[0,0,f.cos(a.rad(t)),f.sin(a.rad(t))],v=1/(g(h(u[2]),h(u[3]))||1);u[2]*=v,u[3]*=v,u[2]<0&&(u[0]=-u[2],u[2]=0),u[3]<0&&(u[1]=-u[3],u[3]=0)}var w=a._parseDots(e);if(!w)return null;k=k.replace(/[\(\)\s,\xb0#]/g,"_"),b.gradient&&k!=b.gradient.id&&(p.defs.removeChild(b.gradient),delete b.gradient);if(!b.gradient){s=q(j+"Gradient",{id:k}),b.gradient=s,q(s,j=="radial"?{fx:m,fy:n}:{x1:u[0],y1:u[1],x2:u[2],y2:u[3],gradientTransform:b.matrix.invert()}),p.defs.appendChild(s);for(var x=0,y=w.length;x1?G.opacity/100:G.opacity});case"stroke":G=a.getRGB(p),i.setAttribute(o,G.hex),o=="stroke"&&G[b]("opacity")&&q(i,{"stroke-opacity":G.opacity>1?G.opacity/100:G.opacity}),o=="stroke"&&d._.arrows&&("startString"in d._.arrows&&t(d,d._.arrows.startString),"endString"in d._.arrows&&t(d,d._.arrows.endString,1));break;case"gradient":(d.type=="circle"||d.type=="ellipse"||c(p).charAt()!="r")&&r(d,p);break;case"opacity":k.gradient&&!k[b]("stroke-opacity")&&q(i,{"stroke-opacity":p>1?p/100:p});case"fill-opacity":if(k.gradient){H=a._g.doc.getElementById(i.getAttribute("fill").replace(/^url\(#|\)$/g,l)),H&&(I=H.getElementsByTagName("stop"),q(I[I.length-1],{"stop-opacity":p}));break};default:o=="font-size"&&(p=e(p,10)+"px");var J=o.replace(/(\-.)/g,function(a){return a.substring(1).toUpperCase()});i.style[J]=p,d._.dirty=1,i.setAttribute(o,p)}}y(d,f),i.style.visibility=m},x=1.2,y=function(d,f){if(d.type=="text"&&!!(f[b]("text")||f[b]("font")||f[b]("font-size")||f[b]("x")||f[b]("y"))){var g=d.attrs,h=d.node,i=h.firstChild?e(a._g.doc.defaultView.getComputedStyle(h.firstChild,l).getPropertyValue("font-size"),10):10;if(f[b]("text")){g.text=f.text;while(h.firstChild)h.removeChild(h.firstChild);var j=c(f.text).split("\n"),k=[],m;for(var n=0,o=j.length;n"));var $=X.getBoundingClientRect();t.W=m.w=($.right-$.left)/Y,t.H=m.h=($.bottom-$.top)/Y,t.X=m.x,t.Y=m.y+t.H/2,("x"in i||"y"in i)&&(t.path.v=a.format("m{0},{1}l{2},{1}",f(m.x*u),f(m.y*u),f(m.x*u)+1));var _=["x","y","text","font","font-family","font-weight","font-style","font-size"];for(var ba=0,bb=_.length;ba.25&&(c=e.sqrt(.25-i(b-.5,2))*((c>.5)*2-1)+.5),m=b+n+c);return o}),f=f.split(/\s*\-\s*/);if(l=="linear"){var p=f.shift();p=-d(p);if(isNaN(p))return null}var q=a._parseDots(f);if(!q)return null;b=b.shape||b.node;if(q.length){b.removeChild(g),g.on=!0,g.method="none",g.color=q[0].color,g.color2=q[q.length-1].color;var r=[];for(var s=0,t=q.length;s')}}catch(c){F=function(a){return b.createElement("<"+a+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}},a._engine.initWin(a._g.win),a._engine.create=function(){var b=a._getContainer.apply(0,arguments),c=b.container,d=b.height,e,f=b.width,g=b.x,h=b.y;if(!c)throw new Error("VML container not found.");var i=new a._Paper,j=i.canvas=a._g.doc.createElement("div"),k=j.style;g=g||0,h=h||0,f=f||512,d=d||342,i.width=f,i.height=d,f==+f&&(f+="px"),d==+d&&(d+="px"),i.coordsize=u*1e3+n+u*1e3,i.coordorigin="0 0",i.span=a._g.doc.createElement("span"),i.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;",j.appendChild(i.span),k.cssText=a.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",f,d),c==1?(a._g.doc.body.appendChild(j),k.left=g+"px",k.top=h+"px",k.position="absolute"):c.firstChild?c.insertBefore(j,c.firstChild):c.appendChild(j),i.renderfix=function(){};return i},a.prototype.clear=function(){a.eve("raphael.clear",this),this.canvas.innerHTML=o,this.span=a._g.doc.createElement("span"),this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",this.canvas.appendChild(this.span),this.bottom=this.top=null},a.prototype.remove=function(){a.eve("raphael.remove",this),this.canvas.parentNode.removeChild(this.canvas);for(var b in this)this[b]=typeof this[b]=="function"?a._removedFactory(b):null;return!0};var G=a.st;for(var H in E)E[b](H)&&!G[b](H)&&(G[H]=function(a){return function(){var b=arguments;return this.forEach(function(c){c[a].apply(c,b)})}}(H))}(window.Raphael) ; window.polyjs=function(X){if(!X){var c={};(function(){var n=[].indexOf||function(c){for(var l=0,d=this.length;lr[0].val||b[0].val===r[0].val&& ("lt"===b[0].key||"gt"===r[0].key)))throw"No intersection found!";return e};e={};for(a in c)h=c[a],e[a]=a in l?"in"in c[a]?b(a):d(a):h;for(a in l)h=l[a],a in e||(e[a]=h);return e};c.linear=function(n,l,d,b){if(_.isFinite(n)&&_.isFinite(l)&&_.isFinite(d)&&_.isFinite(b))return function(a){return(b-l)/(d-n)*(a-n)+l};throw c.error.input("Attempting to create linear function from infinity");};c.median=function(c,l){var d;null==l&&(l=!1);l||(c=_.sortBy(c,function(b){return b}));d=c.length/2;return 0!== d%1?c[Math.floor(d)]:(c[d-1]+c[d])/2};c.counter=function(){var c;c=0;return function(){return c++}};c.sample=function(c,l){return _.pick(c,_.shuffle(_.keys(c)).splice(0,l))};c.compare=function(c,l){var d,b,a,e,h,k,m,t,p;p=_.sortBy(c,function(a){return a});t=_.sortBy(l,function(a){return a});b=[];a=[];d=[];for(m=h=0;m=p.length)d.push(e),h+=1;else if(h>=t.length)b.push(k),m+=1;else if(ke)d.push(e),h+=1;else if(k===e)a.push(k),m+= 1,h+=1;else throw DataError("Unknown data encounted");return{deleted:b,kept:a,added:d}};c.flatten=function(n){var l,d,b,a;l=[];if(null!=n)if(_.isObject(n))if("scalefn"===n.t)"novalue"!==n.f&&l.push(n.v);else for(d in n)b=n[d],l=l.concat(c.flatten(b));else if(_.isArray(n))for(d=0,a=n.length;dc?6*c:5*(c-10)+60};c.sortArrays=function(c,l){var d;d=_.zip.apply(_,l);d.sort(function(b,a){return c(b[0],a[0])});return _.zip.apply(_,d)};c.isDefined=function(n){return _.isObject(n)?"scalefn"===n.t&&"novalue"!==n.f?c.isDefined(n.v):!0:void 0!==n&&null!==n&&!(_.isNumber(n)&&_.isNaN(n))};c.isURI=function(c){var l;return _.isString(c)?(l=RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$", "i"),l.test(c)):!1}}).call(this);(function(){c["const"]={aes:"x y color size opacity shape id text".split(" "),pivot_aes:["row","column","value"],noDomain:["id","text","tooltip"],noLegend:["x","y","id","text","tooltip"],trans:{bin:["key","binwidth"],lag:["key","lag"]},stat:{count:["key"],unique:["key"],sum:["key"],mean:["key"],box:["key"],median:["key"]},timerange:"second minute hour day week month twomonth quarter sixmonth year twoyear fiveyear decade".split(" "),approxTimeInSeconds:{second:1,minute:60, hour:3600,day:86400,week:604800,month:2592E3,twomonth:5184E3,quarter:10368E3,sixmonth:15552E3,year:31536E3,twoyear:63072E3,fiveyear:157766400},sort:{key:null,sort:null,limit:null,asc:!1},scaleFns:{novalue:function(){return{v:null,f:"novalue",t:"scalefn"}},max:function(c){return{v:c,f:"max",t:"scalefn"}},min:function(c){return{v:c,f:"min",t:"scalefn"}},upper:function(c,s,l){return{v:c,n:s,m:l,f:"upper",t:"scalefn"}},lower:function(c,s,l){return{v:c,n:s,m:l,f:"lower",t:"scalefn"}},middle:function(c){return{v:c, f:"middle",t:"scalefn"}},jitter:function(c){return{v:c,f:"jitter",t:"scalefn"}},identity:function(c){return{v:c,f:"identity",t:"scalefn"}}},epsilon:Math.pow(10,-7),defaults:{x:{v:null,f:"novalue",t:"scalefn"},y:{v:null,f:"novalue",t:"scalefn"},color:"steelblue",size:2,opacity:0.7}}}).call(this);(function(){var n,s,l,d,b,a,e,h,k,m={}.hasOwnProperty,t=function(a,b){function f(){this.constructor=a}for(var g in b)m.call(b,g)&&(a[g]=b[g]);f.prototype=b.prototype;a.prototype=new f;a.__super__=b.prototype; return a};s=function(a){function b(f){this.message=f;this.name="DefinitionError"}t(b,a);return b}(Error);l=function(a){function b(f){this.message=f;this.name="DependencyError"}t(b,a);return b}(Error);b=function(a){function b(f){this.message=f;this.name="ModeError"}t(b,a);return b}(Error);n=function(a){function b(f){this.message=f;this.name="DataError"}t(b,a);return b}(Error);k=function(a){function b(f){this.message=f;this.name="UnknownInput"}t(b,a);return b}(Error);a=function(a){function b(f){this.message= f;this.name="ModeError"}t(b,a);return b}(Error);e=function(a){function b(f){this.message=f;this.name="ScaleError"}t(b,a);return b}(Error);d=function(a){function b(f){this.message=f;this.name="MissingData"}t(b,a);return b}(Error);h=function(a){function b(f){this.message=f;this.name="Type"}t(b,a);return b}(Error);c.error=function(a){return Error(a)};c.error.data=function(a){return new n(a)};c.error.depn=function(a){return new l(a)};c.error.defn=function(a){return new s(a)};c.error.mode=function(a){return new b(a)}; c.error.impl=function(b){return new a(b)};c.error.input=function(a){return new k(a)};c.error.scale=function(a){return new e(a)};c.error.missing=function(a){return new d(a)};c.error.type=function(a){return new h(a)}}).call(this);(function(){var n,s,l,d,b,a,e={}.hasOwnProperty,h=function(a,b){function c(){this.constructor=a}for(var d in b)e.call(b,d)&&(a[d]=b[d]);c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a},k=function(a,b){return function(){return a.apply(b,arguments)}}; d=function(){function a(){}a.prototype.render=function(){return c.error.impl()};a.prototype.dispose=function(){return c.error.impl()};return a}();s=function(a){function e(){return b=e.__super__.constructor.apply(this,arguments)}h(e,a);e.prototype.getDimension=function(){throw c.error.impl();};return e}(d);l=function(b){function e(){return a=e.__super__.constructor.apply(this,arguments)}h(e,b);e.prototype.getDimension=function(){throw c.error.impl();};e.prototype.make=function(){throw c.error.impl(); };return e}(d);n=function(a){function b(a){this.type=null!=a?a:null;this.dispose=k(this.dispose,this);this.geoms={};this.pts={}}h(b,a);b.prototype.set=function(a){return this.geoms=a};b.prototype.render=function(a){var b,f,g,q,e,v,d;e={};g=c.compare(_.keys(this.pts),_.keys(this.geoms));f=g.deleted;q=g.kept;b=g.added;v=0;for(d=f.length;vb.timeStamp-n.lastStart)return c.touchToMouse("click",n)}else if("touchcancel"===l)return window.clearTimeout(n.pressTimer),c.touchToMouse("mouseout",n),c.touchToMouse("mouseup",n,300)}}).call(this); (function(){var n,s,l;c.format=function(d,b){switch(d){case "cat":return c.format.identity;case "num":return c.format.number(b);case "date":return c.format.date(b);case "none":return c.format.identity}};c.format.identity=function(c){return c};n={0:"",3:"k",6:"m",9:"b",12:"t"};l=function(c,b){return _.isUndefined(n[b])?c+"e"+(0c))+ e[0].slice(b).replace(/(\d{3})/g,",$1"),a=e.join("."));return a};c.format.getExp=function(c){return Math.floor(Math.log(Math.abs(0===c?1:c))/Math.LN10)};c.format.number=function(d){return function(b){var a,e;e=0;a=null!=d?d:c.format.getExp(b);null==d||2!==a&&5!==a&&8!==a&&11!==a?-1===a?(a=0,e=null!=d?1:2):-2===a?(a=0,e=null!=d?2:3):1===a||2===a?a=0:3a?a=3:6a?a=6:9a?a=9:12a?a=12:e=null!=d?0:1:(a+=1,e=1);b=Math.round(b/Math.pow(10,a-e));b/=Math.pow(10,e);b=b.toFixed(e);return l(s(b), a)}};c.format.date=function(d){return-1!==_.indexOf(c["const"].timerange,d)?"second"===d?function(b){return moment.unix(b).format("h:mm:ss a")}:"minute"===d?function(b){return moment.unix(b).format("h:mm a")}:"hour"===d?function(b){return moment.unix(b).format("MMM D h a")}:"day"===d||"week"===d?function(b){return moment.unix(b).format("MMM D")}:"month"===d||"twomonth"===d||"quarter"===d||"sixmonth"===d?function(b){return moment.unix(b).format("YYYY/MM")}:function(b){return moment.unix(b).format("YYYY")}: function(b){return moment.unix(b).format(d)}};c.format._number_instance=c.format.number();c.format.value=function(d){return _.isNumber(d)?c.format._number_instance(d):d}}).call(this);(function(){var n,s;c.type={};c.type.impute=function(c){var d,b,a,e,h,k;h=b=e=d=0;for(k=c.length;h0.95*b?"num":d>0.95*b?"date":"cat"};c.type.coerce=function(c,d){if(_.isUndefined(c)||_.isNull(c)||"cat"=== d.type)return c;if("num"===d.type)return isNaN(c)?+(""+c).replace(/\$|\,/g,""):+c;if("date"===d.type)return!_.isNumber(c)&&_.isEmpty(c)?null:d.format?"unix"===d.format?moment.unix(c).unix():moment(c,d.format).unix():isFinite(c)&&c>=Math.pow(10,9)?moment.unix(c).unix():moment(c).unix()};c.type.compare=function(c){switch(c){case "cat":return n;default:return s}};n=function(c,d){var b,a;if(c===d)return 0;_.isString(c)||(c=""+c);_.isString(d)||(d=""+d);b=c.toLowerCase();a=d.toLowerCase();return b===a? cd?1:0:ba?1:0};s=function(c,d){return c===d?0:null===c?1:null===d?-1:cd?1:0}}).call(this);(function(){var n,s,l,d,b,a,e=function(a,b){return function(){return a.apply(b,arguments)}},h={}.hasOwnProperty,k=function(a,b){function c(){this.constructor=a}for(var e in b)h.call(b,e)&&(a[e]=b[e]);c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a};c.spec={};c.spec.toStrictMode=function(a){var b,e,d,f,g,q,u,v;a=_.clone(a);null==a.layers&&a.layer&&(a.layers=[a.layer]); null==a.guides&&a.guide&&(a.guides=a.guide);null==a.guides&&(a.guides={});if(a.layers)for(q=a.layers,b=e=0,f=q.length;earguments.length?(l=s,s=null):s&&d.overrideMimeType&&d.overrideMimeType(s);d.open("GET",c,!0);s&&d.setRequestHeader("Accept",s);d.onreadystatechange=function(){var b;if(4===d.readyState)return b= d.status,b=!b&&d.response||200<=b&&300>b||304===b?d:null,l(b)};return d.send(null)};c.text=function(n,s,l){3>arguments.length&&(l=s,s=null);return c.xhr(n,s,function(c){return l(c&&c.responseText)})};c.json=function(n,s){return c.text(n,"application/json",function(c){return s(c?JSON.parse(c):null)})};c.dsv=function(n,s){var l,d,b,a,e,h,k;k=RegExp("\r\n|["+n+"\r\n]","g");h=RegExp('["'+n+"\n]");l=n.charCodeAt(0);b=function(b){return b.map(a).join(n)};a=function(a){var b;return null!=(b=h.test(a))?b: '"'+a.replace(/\"/g,'""')+{'"':a}};e=null;d=function(a,b){return c.text(a,s,function(a){return b(a&&d.parse(a))})};d.parse=function(a){return d.parseRows(a,function(a,b){var c,f,g;if(b){g={};c=-1;for(f=e.length;++c=a.length)return c;if(g)return g=!1,e;q=k.lastIndex;if(34===a.charCodeAt(q)){for(f=q;f++")}O(b,a);b.prototype.toString=function(){var a,b,f,g,c;g=this.domains;c=[];b=0;for(f=g.length;b "+this.range+")"};b.prototype._unify=function(a,f){var g,c,q,e,d;b.__super__._unify.call(this,a,f);this.domains.length!==f.domains.length&&this.error(a,"function domains differ in length"); d=_.zip(this.domains,f.domains);q=0;for(e=d.length;q"};a.prototype.contents=function(){return[this.tag]};return a}();C=function(a){function b(a){this.name=a;this.contents=w(this.contents,this);this.name=ja(this.name);b.__super__.constructor.call(this,z.Tag.symbol)}O(b,a);b.prototype.contents=function(){return b.__super__.contents.call(this).concat([this.name])};return b}(z);g=function(b){function f(b,g){this.val=b;this.type=g;this.contents= w(this.contents,this);f.__super__.constructor.call(this,z.Tag.literal);this.type===a.Base.cat&&(this.val=ka(this.val))}O(f,b);f.prototype.contents=function(){return f.__super__.contents.call(this).concat([this.val])};return f}(z);p=function(a){function b(a){this.op=a;this.contents=w(this.contents,this);b.__super__.constructor.call(this,z.Tag.infixsymbol)}O(b,a);b.prototype.contents=function(){return b.__super__.contents.call(this).concat([this.op])};return b}(z);r=function(a){function b(a){this.name= a;this.contents=w(this.contents,this);b.__super__.constructor.call(this,z.Tag.keyword)}O(b,a);b.prototype.contents=function(){return b.__super__.contents.call(this).concat([this.name])};return b}(z);h=function(){var a,b,f,g;f=[z.Tag.lparen,z.Tag.rparen,z.Tag.comma];g=[];a=0;for(b=f.length;a= > <= < != ==".split(" ");R=function(a,b){return S.indexOf(a)<=S.indexOf(b)};h=function(){var a,b,f;f=[];a=0;for(b=S.length;ac?1:0}:c.type.compare(a.type):function(a){return a}};l=function(){return function(a){this.type=a.type;this.min=a.min;this.max=a.max;this.bw=a.bw}}();s=function(){return function(a){this.type=a.type; this.min=a.min;this.max=a.max;this.bw=a.bw}}();n=function(){return function(a){this.type=a.type;this.levels=a.levels;this.sorted=a.sorted}}();e=function(a){"cat"!==a.type&&a.max===a.min&&(a.bw?(a.max+=a.bw,a.min-=a.bw):0===a.max?a.max+=1:(a.max*=1.1,a.min/=1.1));switch(a.type){case "num":return new l(a);case "date":return new s(a);case "cat":return new n(a)}};c.domain.single=function(a,b,d){var f,g,q,u,v,h,k,m,l,G,B,F,x,H,I,P,R,n,A;if(0===a.length)throw c.error.input("Dataset is none?");g=function(a){return null!= d?d[a]:null};switch(b.type){case "num":return f=null!=(u=g("bw"))?u:b.bw,1=b.min&&a<=b.max}):a.ticks:(h=null!=(r=a.numticks)?r:5,h=d[e](b,h),r=h.ticks,p=h.step);h=a.labels?function(b){var f;return null!=(f=a.labels[b])?f:b}:a.formatter?a.formatter:c.format(e.split("-")[0],p);p={};e=l(e,h);if(r)for(k=f=0,g=r.length-1;0<=g?f<=g:f>=g;k=0<=g?++f:--f)n=0===k?null:r[k-1],m=k===r.length-1?null:r[k+1],k=r[k],m=e(k,n,m),p[m.value]= m;return{ticks:p,ticksFormatter:h}};n=function(){return function(b){this.location=b.location;this.value=b.value;this.index=b.index;this.evtData=b.evtData}}();l=function(b,a){var c;c=0;return function(d,k,m){var l;"cat"===b?l={"in":[d]}:(l={},null!=k&&(l.ge=k),null!=m&&(l.le=m));return new n({location:d,value:a(d),index:c++,evtData:l})}};s=function(b,a){var c,d;d=Math.pow(10,Math.floor(Math.log(b/a)/Math.LN10));c=a/b*d;0.15>c?d*=10:0.35>=c?d*=5:0.75>=c&&(d*=2);return d};d={none:function(){return{}}, cat:function(b,a){var c,d,k,m,l,p,r;k=Math.max(1,Math.round(b.levels.length/a));m=[];r=b.levels;c=l=0;for(p=r.length;l1.4*a;)c*=2;m=k}else c=s(d-k,a),m=Math.ceil(k/c)*c;for(k=[];m<=d;)k.push(m),m+=c;return{ticks:k,step:Math.floor(Math.log(c)/Math.LN10)}},"num-log":function(b,a){var d,h,k,m,l,p,r,f,g;f=[];p=b.min;l=b.max;h=function(a){return Math.log(a)/Math.LN10};d=function(a){return Math.exp(a* Math.LN10)};m=Math.max(h(p),0);k=h(l);r=s(k-m,a);for(g=Math.ceil(m/r)*r;g=g%1)){if(g%1>c["const"].epsilon){if(m=Math.floor(g)+h(10*(g%1)),0===m%1){g+=r;continue}}else m=g;m=d(m);ml||f.push(m)}g+=r}return{ticks:f}},date:function(b,a){var d,h,k,m,l,p,r;m=b.min;k=b.max;if(d=b.bw)for(l=d;"decade"!==l&&(k-m)/c["const"].approxTimeInSeconds[l]>1.4*a;)l=c["const"].timerange[_.indexOf(c["const"].timerange,l)+1];else for(h in d=(k-m)/a,l="decade",r=c["const"].approxTimeInSeconds, r)if(p=r[h],d<1.4*p){l=h;break}p=[];h=moment.unix(m).startOf(l);d=function(){switch(l){case "twomonth":return["months",2];case "quarter":return["months",4];case "sixmonth":return["months",6];case "twoyear":return["years",2];case "fiveyear":return["years",5];case "decade":return["years",10];default:return[l+"s",1]}}();for(h.unix()g.call(this.validPositions,h))throw c.error.defn("X-axis position can't be "+this.position+".");this.titletext=q("title",a);this.renderTick=q("renderTick",this.renderTickDefault);this.renderGrid=q("renderGrid",this.renderGridDefault);this.renderLabel=q("renderLabel", this.renderLabelDefault);this.renderLine=q("renderLine",this.renderLineDefault);this.gridColor=q("gridColor",this.gridColor);d=c.tick.make(d,e,u);this.ticks=d.ticks;this.ticksFormatter=d.ticksFormatter;this.maxwidth=_.max(_.map(this.ticks,function(a){return c.strSize(a.value)}));this.maxwidth=Math.max(this.maxwidth,0)}r(b,a);b.prototype.renderTickDefault=!0;b.prototype.renderGridDefault=!0;b.prototype.renderLabelDefault=!0;b.prototype.renderLineDefault=!0;b.prototype.calculate=function(a,b,f){var g, c,d,e,q,u,h;this.coord=b;if("none"===this.position)return{};null==f&&(f={});a.centerx=a.left+a.width/2;a.centery=a.top+a.height/2;a.radius=Math.min(a.width,a.height)/2-10;b={};this.renderLine&&(b.line={marks:{0:this._renderline(a)}});e=this.ticks;for(g in e)d=e[g],c={},this.renderTick&&(null!=(q=f.renderTick)?q:1)&&(c.tick=this._makeTick(a,d)),this.renderLabel&&(null!=(u=f.renderLabel)?u:1)&&(c.text=this._makeLabel(a,d)),this.renderGrid&&(null!=(h=f.renderGrid)?h:1)&&(c.grid=this._makeGrid(a,d)), b[g]={marks:c};return b};b.prototype._makeTick=function(a){if(!a)throw c.error.impl();a.type="path";a.stroke=e.identity("#666");a.color=e.identity("#666");return a};b.prototype._makeLabel=function(a){if(!a)throw c.error.impl();a.type="text";a.stroke=e.identity("#666");a.color=e.identity("#666");return a};b.prototype._makeGrid=function(a){if(!a)throw c.error.impl();a.stroke=null!=this.gridColor?this.gridColor:"#EFEFEF";return a};return b}(c.Guide);b=function(a){function b(){return h=b.__super__.constructor.apply(this, arguments)}r(b,a);b.prototype.type="x";b.prototype.renderGridDefault=!1;b.prototype.defaultPosition="bottom";b.prototype.validPositions=["top","bottom","none"];b.prototype._renderline=function(a){var b,f;f="top"===this.position?e.identity(a.top):e.identity(a.bottom);b=e.identity(a.left);a=e.identity(a.left+a.width);return{type:"path",y:[f,f],x:[b,a],stroke:e.identity("#666")}};b.prototype._makeTick=function(a,f){var g,c;"top"===this.position?(g=e.identity(a.top),c=e.identity(a.top-5)):(g=e.identity(a.bottom), c=e.identity(a.bottom+5));return b.__super__._makeTick.call(this,{x:[f.location,f.location],y:[g,c]})};b.prototype._makeLabel=function(a,f){var g;g="top"===this.position?e.identity(a.top-15):e.identity(a.bottom+15);return b.__super__._makeLabel.call(this,{x:f.location,y:g,text:f.value,"text-anchor":"middle"})};b.prototype._makeGrid=function(a,f){var g,c;g=e.identity(a.top);c=e.identity(a.bottom);return b.__super__._makeGrid.call(this,{type:"path",x:[f.location,f.location],y:[g,c]})};b.prototype.getDimension= function(){var a;return{position:null!=(a=this.position)?a:"bottom",height:30,width:"all"}};return b}(s);a=function(a){function b(){return k=b.__super__.constructor.apply(this,arguments)}r(b,a);b.prototype.type="y";b.prototype.renderLineDefault=!1;b.prototype.renderTickDefault=!1;b.prototype.defaultPosition="left";b.prototype.validPositions=["left","right","none"];b.prototype._renderline=function(a){var b,f;b="left"===this.position?e.identity(a.left):e.identity(a.right);f=e.identity(a.top);a=e.identity(a.top+ a.height);return{type:"path",x:[b,b],y:[f,a],stroke:e.identity("#666")}};b.prototype._makeTick=function(a,f){var g,c;"left"===this.position?(g=e.identity(a.left),c=e.identity(a.left-5)):(g=e.identity(a.right),c=e.identity(a.right+5));return b.__super__._makeTick.call(this,{x:[g,c],y:[f.location,f.location]})};b.prototype._makeLabel=function(a,f){var g;g="left"===this.position?e.identity(a.left-7):e.identity(a.right+7);return b.__super__._makeLabel.call(this,{x:g,y:f.location,text:f.value,"text-anchor":"left"=== this.position?"end":"start"})};b.prototype._makeGrid=function(a,f){var g,c;g=e.identity(a.left);c=e.identity(a.right);return b.__super__._makeGrid.call(this,{type:"path",y:[f.location,f.location],x:[g,c]})};b.prototype.getDimension=function(){var a;return{position:null!=(a=this.position)?a:"right",height:"all",width:5+this.maxwidth}};return b}(s);l=function(a){function b(){return m=b.__super__.constructor.apply(this,arguments)}r(b,a);b.prototype.type="r";b.prototype.defaultPosition="left";b.prototype.validPositions= ["left","right","none"];b.prototype._renderline=function(a){var b,f;b=e.identity(a.left);f=e.identity(a.top);a=e.identity(a.top+a.height/2);return{type:"path",x:[b,b],y:[f,a],stroke:e.identity("#666")}};b.prototype._makeTick=function(a,f){return b.__super__._makeTick.call(this,{x:[e.identity(a.left),e.identity(a.left-5)],y:[f.location,f.location]})};b.prototype._makeLabel=function(a,f){return b.__super__._makeLabel.call(this,{x:e.identity(a.left-7),y:f.location,text:f.value,"text-anchor":"end"})}; b.prototype._makeGrid=function(a,f){return b.__super__._makeGrid.call(this,{type:"circle",x:e.identity(a.centerx),y:e.identity(a.centery),size:e.identity(this.coord.getScale("r")(f.location)),color:e.identity("none"),"fill-opacity":0,"stroke-width":1})};b.prototype.getDimension=function(){return{position:"left",height:"all",width:5+this.maxwidth}};return b}(s);d=function(a){function b(){return t=b.__super__.constructor.apply(this,arguments)}r(b,a);b.prototype.type="t";b.prototype.defaultPosition= "out";b.prototype.validPositions=["out","none"];b.prototype._renderline=function(a){return{type:"circle",x:e.identity(a.centerx),y:e.identity(a.centery),size:e.identity(a.radius),color:e.identity("none"),stroke:e.identity("#666"),"stroke-width":1}};b.prototype._makeTick=function(a,f){return b.__super__._makeTick.call(this,{x:[f.location,f.location],y:[e.max(0),e.max(3)]})};b.prototype._makeLabel=function(a,f){return b.__super__._makeLabel.call(this,{x:f.location,y:e.max(12),text:f.value,"text-anchor":"middle"})}; b.prototype._makeGrid=function(a,f){var g,c,d,q;c=e.identity(a.centerx);q=e.identity(a.centery);g=this.coord.getScale("t")(f.location)-Math.PI/2;d=e.identity(a.centerx+a.radius*Math.cos(g));g=e.identity(a.centery+a.radius*Math.sin(g));return b.__super__._makeGrid.call(this,{type:"path",y:[q,g],x:[c,d]})};b.prototype.getDimension=function(){return{}};return b}(s);null==c.guide&&(c.guide={});c.guide.axis=function(f,g){if("x"===f)return new b(g);if("y"===f)return new a(g);if("r"===f)return new l(g); if("t"===f)return new d(g)};c.guide.axes=function(a){return new n(a)}}).call(this);(function(){var n,s,l,d,b,a,e,h={}.hasOwnProperty,k=function(a,b){function f(){this.constructor=a}for(var g in b)h.call(b,g)&&(a[g]=b[g]);f.prototype=b.prototype;a.prototype=new f;a.__super__=b.prototype;return a},m=[].indexOf||function(a){for(var b=0,f=this.length;be&&(b+=h+5,h=c=0),d.width>h&&(h=d.width),c+=d.height;return b+h};b.prototype._topbottomHeight=function(a){var b,c,d,e,h;c=10;h=this.legends;d=0;for(e=h.length;dk&&(r+=m+5,m=p=0),l.width> m&&(m=l.width),n={x:r+e,y:p+d},h.render(b(n,!1,!1),m),P.push(p+=l.height);return P};b.prototype._renderH=function(a,b,c){var d,e,h,k,m,l;d=a.paddingLeft;e="top"===this.position?a.paddingTop:a.height-a.guideBottom-a.paddingBottom;e={x:d,y:"top"===this.position?c.top+e:c.bottom+e+10};m=this.legends;l=[];h=0;for(k=m.length;hthis.domain.min)throw c.error.input("Log scale cannot handle zero or negative input.");a=Math.log;f=c.linear(a(this.domain.min),this.range.min,a(this.domain.max),this.range.max);this.f=this._numWrapper(this.domain,function(b){return f(a(b))});g=c.linear(this.range.min,a(this.domain.min),this.range.max,a(this.domain.max));b=function(a){return Math.exp(g(a))};return this.finv= function(a,c){var f;f=[b(a),b(c)];return{ge:_.min(f),le:_.max(f)}}};b.prototype._tickNum=function(){return"num-log"};return b}(n);n=function(a){function b(){this._makeDate=v(this._makeDate,this);this._makeNum=v(this._makeNum,this);return r=b.__super__.constructor.apply(this,arguments)}C(b,a);b.prototype._makeNum=function(){var a,b,f;a=0===this.domain.min?0:1;b=Math.sqrt;f=c.linear(b(this.domain.min),a,b(this.domain.max),10);return this.f=this._identityWrapper(function(a){return f(b(a))})};b.prototype._makeDate= function(){return this._makeNum()};return b}(m);h=function(a){function b(){this._makeDate=v(this._makeDate,this);this._makeNum=v(this._makeNum,this);return f=b.__super__.constructor.apply(this,arguments)}C(b,a);b.prototype._makeNum=function(){return this.f=this._identityWrapper(c.linear(this.domain.min,0===this.domain.min?0:0.1,this.domain.max,1))};b.prototype._makeDate=function(){return this._makeNum()};return b}(m);k=function(a){function b(){this._makeCat=v(this._makeCat,this);return g=b.__super__.constructor.apply(this, arguments)}C(b,a);b.prototype._makeCat=function(){var a,b,c,f=this;c=this.domain.levels.length;if(9>=c)return a="#E41A1C #377EB8 #4DAF4A #984EA3 #FF7F00 #FFFF33 #A65628 #F781BF #999999".split(" "),this.f=function(b){b=_.indexOf(f.domain.levels,b);return a[b]};b=function(a){return _.indexOf(f.domain.levels,a)/c+1/(2*c)};return this.f=function(a){return"undefined"!==typeof Raphael&&null!==Raphael?Raphael.hsl(b(a),0.5,0.5):"hsl("+b(a)+",0.5,0.5)"}};return b}(m);l=function(a){function b(a){this._makeDate= v(this._makeDate,this);this._makeNum=v(this._makeNum,this);this.lower=a.lower;this.upper=a.upper}C(b,a);b.prototype._makeNum=function(){var a,b,f,g,d;f="undefined"!==typeof Raphael&&null!==Raphael?Raphael.color(this.lower):this.lower;d="undefined"!==typeof Raphael&&null!==Raphael?Raphael.color(this.upper):this.upper;g=c.linear(this.domain.min,f.r,this.domain.max,d.r);b=c.linear(this.domain.min,f.g,this.domain.max,d.g);a=c.linear(this.domain.min,f.b,this.domain.max,d.b);return this.f=this._identityWrapper(function(c){return"undefined"!== typeof Raphael&&null!==Raphael?Raphael.rgb(g(c),b(c),a(c)):"rgb("+g(c)+","+b(c)+","+a(c)+")"})};b.prototype._makeDate=function(){return this._makeNum()};return b}(m);d=function(a){function b(a){this._makeDate=v(this._makeDate,this);this._makeCat=v(this._makeCat,this);this._makeNum=v(this._makeNum,this);this.lower=a.lower;this.middle=a.middle;this.upper=a.upper;this.midpoint=a.midpoint;null==this.midpoint&&(this.midpoint=0)}C(b,a);b.prototype._makeNum=function(){var a,b,f,g,d,e,q,h,k,m=this;d="undefined"!== typeof Raphael&&null!==Raphael?Raphael.color(this.lower):this.lower;e="undefined"!==typeof Raphael&&null!==Raphael?Raphael.color(this.middle):this.middle;k="undefined"!==typeof Raphael&&null!==Raphael?Raphael.color(this.upper):this.upper;q=c.linear(this.domain.min,d.r,this.midpoint,e.r);f=c.linear(this.domain.min,d.g,this.midpoint,e.g);a=c.linear(this.domain.min,d.b,this.midpoint,e.b);h=c.linear(this.midpoint,e.r,this.domain.max,k.r);g=c.linear(this.midpoint,e.g,this.domain.max,k.g);b=c.linear(this.midpoint, e.b,this.domain.max,k.b);return this.f=this._identityWrapper(function(c){return c(b=_.keys(a).length)&&"meta"in a||5>b)?(b=a.data,d=a.meta):b=a;switch(h(b)){case "json-object":case "json-grid":case "json-array":return c.data.json(b,d,void 0);case "url":return c.data.url(b,d,void 0);case "csv":return c.data.csv(b,d);case "api":return c.data.api(b);default:throw c.error.data("Unknown data format."); }};c.data.json=function(a,b,c){return new d({data:a,meta:b,type:c})};c.data.csv=function(a,b){return new d({data:a,meta:b,csv:"csv"})};c.data.url=function(a,b,c){return new l({url:a,computeBackend:b,limit:c})};c.data.api=function(a){return new s({apiFun:a})};h=function(a){if(_.isArray(a))return _.isArray(a[0])?"json-grid":"json-array";if(_.isObject(a))return"json-object";if(_.isString(a))return c.isURI(a)?"url":"csv";if(_.isFunction(a))return"api";throw c.error.data("Unknown data format.");};b=function(a, b){var d,e,h,k,m,l,p;if(0=r;d=0<=r?++l:--l){k={};p=0;for(n=h.length;p_.keys(f).length&&"data"in f?(g=f.data, d=null!=(m=f.meta)?m:{}):(g=f,d={});m=function(){var m;switch(null!=(m=f.type)?m:h(g)){case "json-object":return k(g,d);case "json-grid":return a(g,d);case "json-array":return b(g,d);case "csv":return e(g,d);default:throw c.error.data("Unknown data format.");}}();this.key=m.key;this.raw=m.raw;this.meta=m.meta;return this.data=this.raw};g.prototype._checkRename=function(a,b){if(""===b)throw c.error.defn("Column names cannot be an empty string");if(-1===_.indexOf(this.key,a))throw c.error.defn("The key "+ a+" doesn't exist!");if(-1!==_.indexOf(this.key,b))throw c.error.defn("The key "+b+" already exists!");};g.prototype.rename=function(a,b,c){var f,g,d;null==c&&(c=!1);a=a.toString();b=b.toString();if(a===b)return!0;c||this._checkRename(a,b);d=this.raw;f=0;for(g=d.length;f_.keys(g).length&&"data"in g?(d=g.data,m=null!=(p=g.meta)?p:{}):(d=g,m={});g=function(){switch(h(d)){case "json-object":return k(d,m);case "json-grid":return a(d,m);case "json-array":return b(d,m);case "csv":return e(d,m); default:throw c.error.data("Unknown data format.");}}();l.key=g.key;l.raw=g.raw;l.meta=g.meta;l.data=l.raw;return f(null,l)});if(null==g)return f(null,this);c.data.frontendProcess(g,this,function(a,b){b.raw=b.data;return f(a,b)})};g.prototype.update=function(a){this.raw=null;return g.__super__.update.call(this)};g.prototype.renameMany=function(a){return 0===_.keys(a).length};return g}(n);s=function(f){function g(a){this.getData=r(this.getData,this);g.__super__.constructor.call(this);this.apiFun=a.apiFun; this.computeBackend=!0}t(g,f);g.prototype.getData=function(f,g){var d=this;return this.apiFun(g,function(g,m){var l,p,n,r,t;if(null!=g)return f(g,null);if(_.isString(m))try{m=JSON.parse(m)}catch(x){p=x}p=null;try{l=m.data,n=null!=(r=m.meta)?r:{},t=function(){switch(h(l)){case "json-object":return k(l,n);case "json-grid":return a(l,n);case "json-array":return b(l,n);case "csv":return e(l,n);default:throw c.error.data("Unknown data format.");}}(),d.key=t.key,d.raw=t.raw,d.meta=t.meta,d.data=d.raw}catch(H){p= H}return f(p,d)})};g.prototype.update=function(a){this.raw=null;return g.__super__.update.call(this)};g.prototype.renameMany=function(a){return 0===_.keys(a).length};return g}(n)}).call(this);(function(){var n,s,l,d,b,a,e,h,k,m,t,p=function(a,b){return function(){return a.apply(b,arguments)}},r=[].indexOf||function(a){for(var b=0,c=this.length;b":function(a,b){return function(c){return a(c)>b(c)}},">=":function(a,b){return function(c){return a(c)>=b(c)}},"<":function(a,b){return function(c){return a(c)=d;1<=d?++e:--e)k.push(void 0);b=k}else if(e!==d)throw c.error.defn("Lag period needs to be constant, but isn't!");b.push(h);return b.shift()}},bin:function(a){return function(b){var c,d;c=a[0](b);b=a[1](b);if(_.isNumber(b))return Math.floor(c/b)*b;d=function(a,b){var d;d=moment.unix(c).startOf(b);d[b](a*Math.floor(d[b]()/a));return d.unix()};switch(b){case "week":return moment.unix(c).day(0).unix();case "twomonth":return d(2,"month");case "quarter":return d(4,"month");case "sixmonth":return d(6, "month");case "twoyear":return d(2,"year");case "fiveyear":return d(5,"year");case "decade":return d(10,"year");default:return moment.unix(c).startOf(b).unix()}}}}};b=function(d){var e,h,k,m,l,p,n;l=d[0];d=d[1];if("ident"===l)d=a.ident(d.name);else if("const"===l)d=(n=c.type.coerce(d.value,{type:d.type}),a["const"](n));else if("infixop"===l)d=(m=b(d.lhs),p=b(d.rhs),a.infixop[d.opname](m,p));else if("conditional"===l)d=(h=b(d.cond),k=b(d.conseq),e=b(d.altern),a.conditional(h,k,e));else if("call"=== l){m=d.args;p=[];h=0;for(k=m.length;hb},ge:function(a,b){return a>=b},"in":function(a,b){return 0<=r.call(b,a)}};e=function(a){var b;b=[];_.each(a,function(a){var d,f;d=c.parser.unbracket(a.expr.name);f=_.pick(a,"lt","gt","le","ge","in");return _.each(f,function(c,f){if(f in h)return a= function(a){return h[f](a[d],c)},b.push(a)})});return function(a){var c,d,f;d=0;for(f=b.length;d=e&&a<=k}),{q1:_.min(b["true"]),q2:h,q3:c.median(a,!0),q4:d,q5:_.max(b["true"]),outliers:null!=(m=b["false"])?m:[]}):{outliers:a}}};d=function(a,b){var d,e,h;h={};_.each(b.stats,function(a){var b,d,f,e; e=a.name;b=a.expr;a=a.args;d=t[e];f=c.parser.unbracket(a[0].name);return h[b.name]=function(a){return d(_.pluck(a,f))}});e=c.groupBy(a,function(){var a,f,e,h;e=b.groups;h=[];a=0;for(f=e.length;a=b[n]?1*l:-1*l});m&&(b=b.slice(0,+(m-1)+1||9E9));h=_.uniq(_.pluck(b,c.parser.unbracket(k.name)));return{meta:{levels:h,sorted:!0},filter:{expr:k,"in":h}}};m=function(a){var b;b=c.parser.createColTypeEnv(a);return function(a){var d,e,f;d=a.expr;f=d[0];e=d[1];d=null;"call"===f&&"bin"===e.fname&&(e=e.args[1],f=e[0],e=e[1],"const"===f&&(d=c.type.coerce(e.value, {type:e.type})));return{type:c.parser.getType(a.name,b),bw:d}}};k=function(a,g,h){var k,p,n,r,t,s,G,B,F,x,H;G=null!=(p=_.clone(g.meta))?p:{};t=m(G);p=function(a,b){var d,e;null==b&&(b={});d=c.parser.unbracket(a.name);return G[d]=_.extend(null!=(e=G[d])?e:{},t(a),b)};g=_.clone(g.raw);k=function(a,b){var c,d,e,f;f=[];d=0;for(e=g.length;db?1:0}:(b=c.type.compare(this.meta[this.mapping.color].type),function(a,c){a=a[n.mapping.color];c=c[n.mapping.color];return b(a,c)}),d.sort(h)),k=0,m=null!=this.mapping.y?function(a){return a[n.mapping.y]}:function(a){return 0},l.push(function(){var a,b,c;c=[];a=0;for(b=d.length;aG.call(this.guideSpec[b].levels,g)))return!1;return!0};return a}();e=function(a){function b(){return f=b.__super__.constructor.apply(this, arguments)}F(b,a);b.prototype._calcGeoms=function(){var a,b,c,d,e,f,g,h,k;b=this._getIdFunc();this.geoms={};h=this.statData;k=[];f=0;for(g=h.length;fs&&(c.guideLeft=s);c.guideRight>s&&(c.guideRight=s);c.guideTop>b&&(c.guideTop=b);c.guideBottom>b&&(c.guideBottom=b);c.chartHeight=c.height-c.paddingTop-c.paddingBottom-c.guideTop-c.guideBottom;c.chartWidth= c.width-c.paddingLeft-c.paddingRight-c.guideLeft-c.guideRight;null!=l.cols&&1=d;e=0<=d?++c:--c)f.push(void 0===a[e]||void 0===b[e]);return f}()))throw c.error.missing(""+d+" cannot be plotted due to too many missing points.");};a.prototype._checkArrayNaN=function(a,b){var c,d;d=_.map(_.zip(a,b),function(a,b){return isNaN(a[0])||isNaN(a[1])?void 0:a});return{x:function(){var a,b,e;e= [];a=0;for(b=d.length;a=q;h=1<=q?++p:--p)k=Math.abs(m[h]-m[h-1])>Math.PI?1:0,g=0Math.PI?1:0,b="M "+h[0]+" "+k[0]+" A "+f[0]+" "+f[1]+" 0 "+d+" 1 "+h[1]+" "+k[1],d=Math.abs(g[3]-g[2])>Math.PI?1:0,b+="L "+h[2]+" "+k[2]+" A "+f[2]+" "+f[3]+" 0 "+d+" 0 "+h[3]+" "+k[3]+" Z");d=this._maybeApply(a,e,e.stroke?"stroke":"color");return this._shared(a,e,{path:b,fill:this._maybeApply(a,e,"color"),stroke:d,"stroke-width":this._maybeApply(a, e,"stroke-width")})};return b}(h);h=function(a){function b(){return C=b.__super__.constructor.apply(this,arguments)}J(b,a);b.prototype._make=function(a){return a.text()};b.prototype.attr=function(a,b,c,d,e){var f;e=b.getXY(e,d);b=e.x;e=e.y;this._checkPointUndefined(b,e,"Text");c=this._applyOffset(b,e,c);b=c.x;e=c.y;return this._shared(a,d,{x:b,y:e,r:10,text:this._maybeApply(a,d,"text"),"font-size":this._maybeApply(a,d,"size"),"text-anchor":null!=(f=d["text-anchor"])?f:"left",fill:this._maybeApply(a, d,"color")||"black"})};return b}(h);m={cartesian:{circle:new s,line:new d,pline:new d,area:new n,path:new b,text:new h,rect:new e,spline:new k},polar:{circle:new s,path:new b,line:new d,pline:new a,area:new n,text:new h,rect:new l,spline:new k}}}).call(this);(function(){var n=[].indexOf||function(c){for(var l=0,d=this.length;lc.y&&(c.y=h+30+e,f.y=d+e/2+15),c.x+c.width>n&&(d=c.x+c.width-n,c.x-=d/2,f.x-=d/2),c.xn.call(c["const"].aes,s))throw c.error.input("Unknown aesthetic "+s+".");b=0;a=[d];return function(c,d,k,m){var n,p;if("reset"===c&&0c["const"].epsilon&&(null==f[p]&&(f[p]={min:null,max:null}),f[p].min=h[e].ge,f[p].max=h[e].le),"cat"===r.axes.domains[p].type&&0!==h[e]["in"].length&&(null==f[p]&&(f[p]={levels:null}),f[p].levels=h[e]["in"]));r.handlers=_.map(r.handlers,k);J.push(r.make(r.spec))}return J}}}}}).call(this);(function(){var n,s=[].indexOf||function(c){for(var d=0,b=this.length;dh||h>=this.cols||0>m||m>=this.rows)return null;k={x:d.paddingLeft+d.guideLeft+(d.eachWidth+d.horizontalSpacing)*h,y:d.paddingTop+d.guideTop+(d.eachHeight+d.verticalSpacing)*m+d.verticalSpacing};b={x:b-k.x,y:a-k.y};if(!e&&(b.x>d.eachWidth||b.y>d.eachHeight))return null;b.x=Math.max(Math.min(b.x,d.eachWidth), 0);b.y=Math.max(Math.min(b.y,d.eachHeight),0);return{row:m,col:h,offset:k,adjusted:b,evtData:this.getEvtData(h,m)}};l.prototype._getMappings=function(d){var b;b={type:"none",mapping:{}};if(_.isObject(d))if("wrap"===d.type){b.type="wrap";if(!d["var"])throw c.error.defn("You didn't specify a variable to facet on.");d["var"]&&(b.mapping["var"]=c.parser.normalize(d["var"]["var"]))}else if("grid"===d.type){b.type="grid";if(!d.x&&d.y)throw c.error.defn("You didn't specify a variable to facet on.");d.x&& (b.mapping.x=c.parser.normalize(d.x["var"]));d.y&&(b.mapping.y=c.parser.normalize(d.y["var"]))}return b};l.prototype._makeIndices=function(d,b){var a,e,h,k,m,l,p,n;n={};for(a in b)if(e=b[a],m=c.parser.normalize(e["var"]),e.levels)n[m]=e.levels;else{l=[];for(h in d){e=d[h];if(k=e.metaData[m])!k||"num"!==(p=k.type)&&"date"!==p||c.type.compare(k.type);l=_.uniq(_.union(l,_.pluck(e.statData,m)))}n[m]=l}a=c.cross(n);h={};k=_.pluck(b,"var");l=[];p=0;for(e=k.length;p").attr("border","1px solid black");C.attr("cellspacing",0);C.attr("cellpadding",0); for(q=0;q");r=c.parser.unbracket(this.spec.columns[q]["var"]);0===q&&1"),u.attr("rowspan",k),u.attr("colspan",l-1),D.append(u));D.append($(""+r+":").attr("align","right"));for(u=0;u"+p+"").attr("colspan",f*n);p.attr("align","center");D.append(p);u+=f}C.append(D);q++}D=$("");0===l&&(u=$(""),u.attr("rowspan",a.length+ 1),D.append(u));for(q=0;q"+r+"").attr("align","center")),q++;for(q=0;q"+c.parser.unbracket(p["var"])+""),p.attr("align","center"),D.append(p);q++}C.append(D);for(q=0;q");l=this.spec.rows;u=0;for(k=l.length;u"+p+"").attr("rowspan",n);p.attr("align","center");p.attr("valign","middle");D.append(p)}for(u=0;u"+p+"").attr("align","right"));u++}C.append(D);q++}this.prepare&&this.prepare(this);this.spec.width&&C.attr("width",this.spec.width);this.spec.height&&C.attr("height", this.spec.height);this.dom=_.isString(this.spec.dom)?$("#"+this.spec.dom):$(this.spec.dom);this.dom.empty();this.dom.append(C);if(this.callback)return this.callback(null,this)};return b}();c.pivot=function(b,a,c){return new n(b,a,c)}}).call(this);(function(){var n,s,l=function(b,a){return function(){return b.apply(a,arguments)}},d=[].indexOf||function(b){for(var a=0,c=this.length;ad.call(this.handlers,a))return this.handlers.push(a)};b.prototype.render=function(a,b,d){var k,l,n,p;if(null!=a)console.error(a);else{a=c.parser.normalize(this.spec.value["var"]);this.value=b[0][a];this.title=null!=(n=this.spec.title)? n:a;b=0<(l=this.value)&&1>l?void 0:0===this.value%1?0:-1;this.value=c.format.number(b)(this.value);if(_.isNaN(this.value)||"NaN"===this.value)this.value="Not a Number";null!=this.prepare&&this.prepare(this);this.dom=this.spec.dom;this.width=null!=(k=this.spec.width)?k:200;this.height=null!=(p=this.spec.height)?p:100;null==this.paper&&(this.paper=this._makePaper(this.dom,this.width,this.height,this));null==this.titleObj&&(this.titleObj=this.paper.text(this.width/2,10,""));this.titleObj.attr({text:this.title, "font-size":"12px"});this.titleObj.click(this.handleEvent("guide-title"));this.titleObj.hover(this.handleEvent("tover"),this.handleEvent("tout"));null==this.textObj&&(this.textObj=this.paper.text(this.width/2,this.height/2,""));this.textObj.attr({x:this.width/2,y:7+this.height/2,text:this.value});k=this.textObj.getBBox();l=k.width;k=k.height;l=Math.min(0.9*this.width/l,0.9*(this.height-14)/k);this.textObj.transform("s"+l);this.callback&&this.callback(null,this)}};b.prototype._makePaper=function(a, b,d,k){return c.paper(a,b,d,{numeral:k},!1)};return b}();c.numeral=function(b,a,d){try{return new n(b,a,d)}catch(h){console.log(h);if(null!=a)return a(h,null);throw c.error.defn("Bad specification.");}}}).call(this);(function(){var n,s,l,d={}.hasOwnProperty,b=function(a,b){function c(){this.constructor=a}for(var k in b)d.call(b,k)&&(a[k]=b[k]);c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a};s=function(){function a(a,b,c){null==a&&(a="polyjsEvent");this.eventName=a;this.cancelable= this.bubbles=!0;this.detail={type:c,data:b}}a.prototype.dispatch=function(a){var b;b=new CustomEvent(this.eventName,{detail:this.detail});if(null!=a)return a.dispatchEvent(b)};return a}();l=function(a){function c(a,b){c.__super__.constructor.call(this,"title-click",a,b)}b(c,a);return c}(s);n=function(a){function c(a,b){c.__super__.constructor.call(this,"legend-click",a,b)}b(c,a);return c}(s);c.event={};c.event.make=function(a,b){if("guide-title"===a||"guide-titleH"===a||"guide-titleV"===a)return new l(b, a);if("legend-label"===a||"legend-title"===a)return new n(b,a);throw c.error.defn("No such event "+a+".");}}).call(this);(function(){var n,s=function(c,b){return function(){return c.apply(b,arguments)}},l=[].indexOf||function(c){for(var b=0,a=this.length;bl.call(this.handlers,b))return this.handlers.push(b)};d.prototype.removeHandler=function(b){return this.handlers.splice(_.indexOf(this.handlers,b),1)};d.prototype.handleEvent=function(b){var a;a=this;return _.throttle(function(d){var h,k,l,n,p;if("touchstart"===b||"touchmove"===b||"touchend"===b||"touchcancel"===b)c.touch(b,this,d,a);else if("select"===b){k=d.start;h=d.end;k=a.facet.getFacetInfo(a.dims,k.x,k.y);if(!k)return;n=k.col;p=k.row;l=k.adjusted;k=_.clone(l);l=a.facet.getFacetInfo(a.dims, h.x,h.y,{col:n,row:p}).adjusted;h=_.clone(l);this.evtData="cartesian"===a.coord.type?a.scaleSet.fromPixels(k,h):null}else if("data"===b)this.evtData={};else if("reset"===b||"click"===b||"mover"===b||"mout"===b||"tover"===b||"tout"===b||"gover"===b||"gout"===b||"guide-click"===b)this.tooltip=this.data("t"),this.evtData=this.data("e"),"guide-click"===b&&"text"===this.type&&null!=this.evtData&&(d="legendTitle"===this.evtData.value?c.event.make("legend-title",this):c.event.make("legend-label",this),d.dispatch(a.dom)); else if("guide-title"===b||"guide-titleH"===b||"guide-titleV"===b)this.tooltip=this.data("t"),this.evtData=this.data("e"),d=c.event.make(b,this),d.dispatch(a.dom);p=a.handlers;l=[];k=0;for(n=p.length;k