/* * Sugar Library v0.9.5 * * Freely distributable and licensed under the MIT-style license. * Copyright (c) 2011 Andrew Plummer * http://sugarjs.com/ * * ---------------------------- */ (function(){var k=function(a,b,c,d){var e=b?a.prototype:a;da(a,b,d);p(d,function(f,g){if(typeof c==="function")j(e,f,ea(e[f],g,c));else if(c===true||!e[f])j(e,f,g);a.SugarMethods[f]={instance:b,method:g}})},da=function(a){if(!a.SugarMethods){a.SugarMethods={};j(a,"sugar",function(){var b=arguments,c=b.length===0;p(a.SugarMethods,function(d,e){if(c||u(b,d))j(e.instance?a.prototype:a,d,e.method)})})}},ea=function(a,b,c){return function(){return a&&(c===true||c.apply(this,arguments))?a.apply(this,arguments): b.apply(this,arguments)}},j=function(a,b,c){if(Object.defineProperty&&Object.defineProperties)Object.defineProperty(a,b,{value:c,configurable:true,enumerable:false,writeable:true});else a[b]=c},p=function(a,b){var c=0,d;for(d in a)if(a.hasOwnProperty(d)){b.call(a,d,a[d],c);c++}},fa=function(a,b,c){var d=[],e;for(e in a)e in a&&e>>>0==e&&e!=4294967295&&e>=c&&d.push(e.toNumber());d.sort();d.each(function(f){return b.call(a,a[f],f,a)});return a},A=function(a,b){if(typeof a=="object"&&typeof b=="object"&& a!==null&&b!==null){for(var c in a)if(a.hasOwnProperty(c))if(!b.hasOwnProperty(c)||!A(a[c],b[c]))return false;return Object.keys(a).length===Object.keys(b).length}else return a===b},v=function(a,b,c,d){return a===b?true:Object.isRegExp(b)?b.test(a):Object.isFunction(b)?b.apply(c,[a].concat(d)):typeof b==="object"?A(b,a):false},x=function(a,b,c,d){var e=a[0];if(a.length===0)return b;else if(!Object.isFunction(e)&&!Object.isString(e))throw new TypeError("first argument must be a function or a string"); return Object.isFunction(e)?e.apply(c,[b].concat(d)):typeof b[e]=="function"?b[e].call(b):b[e]},r=function(a,b){m(Array.prototype.slice.call(a).flatten(),b)},B=function(a,b,c,d){var e=c==="max",f=c==="min",g=e?-Infinity:Infinity,h=[];p(a,function(i){i=a[i];var l=x(b,i,d);if(!(l===undefined||l===null))if(l===g)h.push(i);else if(e&&l>g||f&&l=0&&f>0);for(e=d===true?a.length+f:a.length;f0;f&&a<=b||!f&&a>=b;){e.push(a);c&&c.call(this,a);a+=d}return e},C=function(a){if(!a||!a.call)throw new TypeError("callback is not callable");},D=function(a){if(a.length===0)throw new TypeError("first argument must be defined");},L=function(a,b){return Object.prototype.toString.call(a)==="[object "+b+"]"},E=function(a,b,c){var d;d=Array.isArray(a)?[]:c?Object.extended({}):{};p(a,function(e,f){d[e]=b&&(Object.isObject(f)||Array.isArray(f))?E(f,b,c):f});return d}, S=function(a,b,c,d){var e=/^(.+?)(\[.*\])$/,f,g,h;if(d!==false&&(g=b.match(e))){h=g[1];b=g[2].replace(/^\[|\]$/g,"").split("][");m(b,function(i){f=!i||i.match(/^\d+$/);if(!h&&Object.isArray(a))h=a.length;a[h]||(a[h]=f?[]:{});a=a[h];h=i});if(!h&&f)h=a.length.toString();S(a,h,c)}else a[b]=c.match(/^\d+$/)?parseInt(c):c==="true"?true:c==="false"?false:c},y=function(a){var b=this;p(a,function(c,d){b[c]=d})};y.prototype.constructor=Object;k(y,true,false,{clone:function(a){return E(this,a,true)}});var T= ["Array","Boolean","Date","Function","Number","String","RegExp"],U=["keys","values","each","merge","isEmpty","equals"];k(Object,false,false,{enableSugar:function(){T.each(function(a){j(Object.prototype,"is"+a,function(){return Object["is"+a](this)})});U.each(function(a){j(Object.prototype,a,y.prototype[a])});j(Object.prototype,"clone",function(a){return E(this,a,true)})},extended:function(a){return new y(a)},isObject:function(a){return a===null||a===undefined||arguments.length===0?false:L(a,"Object")&& a.constructor===Object},each:function(a,b){p(a,function(c,d){b&&b.call(a,c,d,a)});return a},merge:function(){var a=arguments[0];r(arguments,function(b){typeof b==="object"&&p(b,function(c,d){a[c]=d})},1);return a},isEmpty:function(a){if(!a)return true;return A(a,{})},equals:function(a,b){return A(a,b)},values:function(a,b){var c=[];p(a,function(d,e){c.push(e);b&&b.call(a,e)});return c},clone:E,fromQueryString:function(a,b){var c=Object.extended();a=a&&a.toString?a.toString():"";a.replace(/^.*?\?/, "").unescapeURL().split("&").each(function(d){d=d.split("=");d.length===2&&S(c,d[0],d[1],b)});return c}});k(Object,false,function(){return arguments.length<2},{keys:function(a,b){if(a===null||typeof a!="object")throw new TypeError("object required");var c=[];p(a,function(d){c.push(d);b&&b.call(a,d)});return c}});k(Array,false,false,{isArray:function(a){return L(a,"Array")}});k(Array,true,function(){return arguments.length===0||Object.isFunction(arguments[0])},{every:function(a,b){var c=this.length, d=0;for(D(arguments);d>0);if(Object.isString(this))return this.indexOf(a,b);if(d<0)d=Math.max(c+d,0);if(c==0||d>c)return-1;for(;d>0);if(Object.isString(this))return this.lastIndexOf(a,b);if(d<0)d=c+d;if(c==0||d<0)return-1;for(;d>=0;){if(d in this&&this[d]===a)return d;d--}return-1},forEach:function(a,b){var c=this.length, d=0;for(C(a);d1&&b;C(a);if(c==0&&!e)throw new TypeError("Reduce called on empty array with no initial value");else if(e)e=e;else{e=this[d];d++}for(;d1&&b;C(a);if(c==0&&!e)throw new TypeError("Reduce called on empty array with no initial value");else if(e)c= e;else{c=this[d];d--}for(;d>=0;){if(d in this)c=a.call(undefined,c,this[d],d,this);d--}return c},each:function(a,b,c){m(this,a,b,c);return this},find:function(a,b,c){return u(this,a,b,c)},findAll:function(a,b,c){var d=[];m(this,function(e,f,g){v(e,a,g,[f,g])&&d.push(e)},b,c);return d},count:function(a){if(a===undefined)return this.length;return this.findAll(a).length},none:function(){return!this.any.apply(this,arguments)},remove:function(){var a,b=this;r(arguments,function(c){for(a=0;a0?a.reduce(function(b,c){return b+c}):0},average:function(a){a=a?this.map(a):this;return a.length>0?a.sum()/a.length:0},groupBy:function(){var a={},b=arguments,c;this.each(function(d){c=x(b,d);a[c]||(a[c]=[]);a[c].push(d)});return a},inGroups:function(a,b){var c=arguments.length>1,d=this,e=[],f=Math.ceil(this.length/a);(0).upto(a-1,function(g){g=g*f;var h=d.slice(g,g+ f);c&&h.length0&&c.push(d);return c},compact:function(a){var b=[];this.each(function(c){if(Array.isArray(c))b.push(c.compact()); else if(a&&c)b.push(c);else if(!a&&c!==undefined&&c!==null&&(typeof c!="number"||!isNaN(c)))b.push(c)});return b},isEmpty:function(){return this.compact().length==0},flatten:function(){var a=[];this.each(function(b){if(Array.isArray(b))a=a.concat(b.flatten());else a.push(b)});return a},sortBy:function(a,b){var c=arguments;this.sort(function(d,e){var f=x(c,d),g=x(c,e),h=typeof f=="number";return h&&b?g-f:h&&!b?f-g:f===g?0:b?f=11&&this<=13)a="th";else switch(this%10){case 1:a="st";break;case 2:a="nd";break;case 3:a="rd";break;default:a="th"}return this.toString()+a},pad:function(a,b,c){c=c||10;c=this.toNumber()===0?"":this.toString(c).replace(/^-/,"");c=F(c,"0",a-c.replace(/\.\d+$/,"").length,0);if(b||this<0)c=(this<0?"-":"+")+c;return c},format:function(a,b){a=a||",";b=b||".";var c=this.toString().split("."), d=c[0];c=c.length>1?b+c[1]:"";for(var e=/(\d+)(\d{3})/;e.test(d);)d=d.replace(e,"$1"+a+"$2");return d+c},hex:function(a){return this.pad(a||1,false,16)}});var ga=[{base:"A",reg:/[A\u24b6\uff21\u00c0\u00c1\u00c2\u1ea6\u1ea4\u1eaa\u1ea8\u00c3\u0100\u0102\u1eb0\u1eae\u1eb4\u1eb2\u0226\u01e0\u00c4\u01de\u1ea2\u00c5\u01fa\u01cd\u0200\u0202\u1ea0\u1eac\u1eb6\u1e00\u0104\u023a\u2c6f]/g},{base:"B",reg:/[B\u24b7\uff22\u1e02\u1e04\u1e06\u0243\u0182\u0181]/g},{base:"C",reg:/[C\u24b8\uff23\u0106\u0108\u010a\u010c\u00c7\u1e08\u0187\u023b\ua73e]/g}, {base:"D",reg:/[D\u24b9\uff24\u1e0a\u010e\u1e0c\u1e10\u1e12\u1e0e\u0110\u018b\u018a\u0189\ua779]/g},{base:"E",reg:/[E\u24ba\uff25\u00c8\u00c9\u00ca\u1ec0\u1ebe\u1ec4\u1ec2\u1ebc\u0112\u1e14\u1e16\u0114\u0116\u00cb\u1eba\u011a\u0204\u0206\u1eb8\u1ec6\u0228\u1e1c\u0118\u1e18\u1e1a\u0190\u018e]/g},{base:"F",reg:/[F\u24bb\uff26\u1e1e\u0191\ua77b]/g},{base:"G",reg:/[G\u24bc\uff27\u01f4\u011c\u1e20\u011e\u0120\u01e6\u0122\u01e4\u0193\ua7a0\ua77d\ua77e]/g},{base:"H",reg:/[H\u24bd\uff28\u0124\u1e22\u1e26\u021e\u1e24\u1e28\u1e2a\u0126\u2c67\u2c75\ua78d]/g}, {base:"I",reg:/[I\u24be\uff29\u00cc\u00cd\u00ce\u0128\u012a\u012c\u0130\u00cf\u1e2e\u1ec8\u01cf\u0208\u020a\u1eca\u012e\u1e2c\u0197]/g},{base:"J",reg:/[J\u24bf\uff2a\u0134\u0248]/g},{base:"K",reg:/[K\u24c0\uff2b\u1e30\u01e8\u1e32\u0136\u1e34\u0198\u2c69\ua740\ua742\ua744\ua7a2]/g},{base:"L",reg:/[L\u24c1\uff2c\u013f\u0139\u013d\u1e36\u1e38\u013b\u1e3c\u1e3a\u0141\u023d\u2c62\u2c60\ua748\ua746\ua780]/g},{base:"M",reg:/[M\u24c2\uff2d\u1e3e\u1e40\u1e42\u2c6e\u019c]/g},{base:"N",reg:/[N\u24c3\uff2e\u01f8\u0143\u00d1\u1e44\u0147\u1e46\u0145\u1e4a\u1e48\u0220\u019d\ua790\ua7a4]/g}, {base:"O",reg:/[O\u24c4\uff2f\u00d2\u00d3\u00d4\u1ed2\u1ed0\u1ed6\u1ed4\u00d5\u1e4c\u022c\u1e4e\u014c\u1e50\u1e52\u014e\u022e\u0230\u00d6\u022a\u1ece\u0150\u01d1\u020c\u020e\u01a0\u1edc\u1eda\u1ee0\u1ede\u1ee2\u1ecc\u1ed8\u01ea\u01ec\u00d8\u01fe\u0186\u019f\ua74a\ua74c]/g},{base:"P",reg:/[P\u24c5\uff30\u1e54\u1e56\u01a4\u2c63\ua750\ua752\ua754]/g},{base:"Q",reg:/[Q\u24c6\uff31\ua756\ua758\u024a]/g},{base:"R",reg:/[R\u24c7\uff32\u0154\u1e58\u0158\u0210\u0212\u1e5a\u1e5c\u0156\u1e5e\u024c\u2c64\ua75a\ua7a6\ua782]/g}, {base:"S",reg:/[S\u24c8\uff33\u1e9e\u015a\u1e64\u015c\u1e60\u0160\u1e66\u1e62\u1e68\u0218\u015e\u2c7e\ua7a8\ua784]/g},{base:"T",reg:/[T\u24c9\uff34\u1e6a\u0164\u1e6c\u021a\u0162\u1e70\u1e6e\u0166\u01ac\u01ae\u023e\ua786]/g},{base:"U",reg:/[U\u24ca\uff35\u00d9\u00da\u00db\u0168\u1e78\u016a\u1e7a\u016c\u00dc\u01db\u01d7\u01d5\u01d9\u1ee6\u016e\u0170\u01d3\u0214\u0216\u01af\u1eea\u1ee8\u1eee\u1eec\u1ef0\u1ee4\u1e72\u0172\u1e76\u1e74\u0244]/g},{base:"V",reg:/[V\u24cb\uff36\u1e7c\u1e7e\u01b2\ua75e\u0245]/g}, {base:"W",reg:/[W\u24cc\uff37\u1e80\u1e82\u0174\u1e86\u1e84\u1e88\u2c72]/g},{base:"X",reg:/[X\u24cd\uff38\u1e8a\u1e8c]/g},{base:"Y",reg:/[Y\u24ce\uff39\u1ef2\u00dd\u0176\u1ef8\u0232\u1e8e\u0178\u1ef6\u1ef4\u01b3\u024e\u1efe]/g},{base:"Z",reg:/[Z\u24cf\uff3a\u0179\u1e90\u017b\u017d\u1e92\u1e94\u01b5\u0224\u2c7f\u2c6b\ua762]/g},{base:"a",reg:/[a\u24d0\uff41\u1e9a\u00e0\u00e1\u00e2\u1ea7\u1ea5\u1eab\u1ea9\u00e3\u0101\u0103\u1eb1\u1eaf\u1eb5\u1eb3\u0227\u01e1\u00e4\u01df\u1ea3\u00e5\u01fb\u01ce\u0201\u0203\u1ea1\u1ead\u1eb7\u1e01\u0105\u2c65\u0250]/g}, {base:"b",reg:/[b\u24d1\uff42\u1e03\u1e05\u1e07\u0180\u0183\u0253]/g},{base:"c",reg:/[c\u24d2\uff43\u0107\u0109\u010b\u010d\u00e7\u1e09\u0188\u023c\ua73f\u2184]/g},{base:"d",reg:/[d\u24d3\uff44\u1e0b\u010f\u1e0d\u1e11\u1e13\u1e0f\u0111\u018c\u0256\u0257\ua77a]/g},{base:"e",reg:/[e\u24d4\uff45\u00e8\u00e9\u00ea\u1ec1\u1ebf\u1ec5\u1ec3\u1ebd\u0113\u1e15\u1e17\u0115\u0117\u00eb\u1ebb\u011b\u0205\u0207\u1eb9\u1ec7\u0229\u1e1d\u0119\u1e19\u1e1b\u0247\u025b\u01dd]/g},{base:"f",reg:/[f\u24d5\uff46\u1e1f\u0192\ua77c]/g}, {base:"g",reg:/[g\u24d6\uff47\u01f5\u011d\u1e21\u011f\u0121\u01e7\u0123\u01e5\u0260\ua7a1\u1d79\ua77f]/g},{base:"h",reg:/[h\u24d7\uff48\u0125\u1e23\u1e27\u021f\u1e25\u1e29\u1e2b\u1e96\u0127\u2c68\u2c76\u0265]/g},{base:"i",reg:/[i\u24d8\uff49\u00ec\u00ed\u00ee\u0129\u012b\u012d\u00ef\u1e2f\u1ec9\u01d0\u0209\u020b\u1ecb\u012f\u1e2d\u0268\u0131]/g},{base:"j",reg:/[j\u24d9\uff4a\u0135\u01f0\u0249]/g},{base:"k",reg:/[k\u24da\uff4b\u1e31\u01e9\u1e33\u0137\u1e35\u0199\u2c6a\ua741\ua743\ua745\ua7a3]/g},{base:"l", reg:/[l\u24db\uff4c\u0140\u013a\u013e\u1e37\u1e39\u013c\u1e3d\u1e3b\u017f\u0142\u019a\u026b\u2c61\ua749\ua781\ua747]/g},{base:"m",reg:/[m\u24dc\uff4d\u1e3f\u1e41\u1e43\u0271\u026f]/g},{base:"n",reg:/[n\u24dd\uff4e\u01f9\u0144\u00f1\u1e45\u0148\u1e47\u0146\u1e4b\u1e49\u019e\u0272\u0149\ua791\ua7a5]/g},{base:"o",reg:/[o\u24de\uff4f\u00f2\u00f3\u00f4\u1ed3\u1ed1\u1ed7\u1ed5\u00f5\u1e4d\u022d\u1e4f\u014d\u1e51\u1e53\u014f\u022f\u0231\u00f6\u022b\u1ecf\u0151\u01d2\u020d\u020f\u01a1\u1edd\u1edb\u1ee1\u1edf\u1ee3\u1ecd\u1ed9\u01eb\u01ed\u00f8\u01ff\u0254\ua74b\ua74d\u0275]/g}, {base:"p",reg:/[p\u24df\uff50\u1e55\u1e57\u01a5\u1d7d\ua751\ua753\ua755]/g},{base:"q",reg:/[q\u24e0\uff51\u024b\ua757\ua759]/g},{base:"r",reg:/[r\u24e1\uff52\u0155\u1e59\u0159\u0211\u0213\u1e5b\u1e5d\u0157\u1e5f\u024d\u027d\ua75b\ua7a7\ua783]/g},{base:"s",reg:/[s\u24e2\uff53\u00df\u015b\u1e65\u015d\u1e61\u0161\u1e67\u1e63\u1e69\u0219\u015f\u023f\ua7a9\ua785\u1e9b]/g},{base:"t",reg:/[t\u24e3\uff54\u1e6b\u1e97\u0165\u1e6d\u021b\u0163\u1e71\u1e6f\u0167\u01ad\u0288\u2c66\ua787]/g},{base:"u",reg:/[u\u24e4\uff55\u00f9\u00fa\u00fb\u0169\u1e79\u016b\u1e7b\u016d\u00fc\u01dc\u01d8\u01d6\u01da\u1ee7\u016f\u0171\u01d4\u0215\u0217\u01b0\u1eeb\u1ee9\u1eef\u1eed\u1ef1\u1ee5\u1e73\u0173\u1e77\u1e75\u0289]/g}, {base:"v",reg:/[v\u24e5\uff56\u1e7d\u1e7f\u028b\ua75f\u028c]/g},{base:"w",reg:/[w\u24e6\uff57\u1e81\u1e83\u0175\u1e87\u1e85\u1e98\u1e89\u2c73]/g},{base:"x",reg:/[x\u24e7\uff58\u1e8b\u1e8d]/g},{base:"y",reg:/[y\u24e8\uff59\u1ef3\u00fd\u0177\u1ef9\u0233\u1e8f\u00ff\u1ef7\u1e99\u1ef5\u01b4\u024f\u1eff]/g},{base:"z",reg:/[z\u24e9\uff5a\u017a\u1e91\u017c\u017e\u1e93\u1e95\u01b6\u0225\u0240\u2c6c\ua763]/g},{base:"AA",reg:/[\ua732]/g},{base:"AE",reg:/[\u00c6\u01fc\u01e2]/g},{base:"AO",reg:/[\ua734]/g},{base:"AU", reg:/[\ua736]/g},{base:"AV",reg:/[\ua738\ua73a]/g},{base:"AY",reg:/[\ua73c]/g},{base:"DZ",reg:/[\u01f1\u01c4]/g},{base:"Dz",reg:/[\u01f2\u01c5]/g},{base:"LJ",reg:/[\u01c7]/g},{base:"Lj",reg:/[\u01c8]/g},{base:"NJ",reg:/[\u01ca]/g},{base:"Nj",reg:/[\u01cb]/g},{base:"OI",reg:/[\u01a2]/g},{base:"OO",reg:/[\ua74e]/g},{base:"OU",reg:/[\u0222]/g},{base:"TZ",reg:/[\ua728]/g},{base:"VY",reg:/[\ua760]/g},{base:"aa",reg:/[\ua733]/g},{base:"ae",reg:/[\u00e6\u01fd\u01e3]/g},{base:"ao",reg:/[\ua735]/g},{base:"au", reg:/[\ua737]/g},{base:"av",reg:/[\ua739\ua73b]/g},{base:"ay",reg:/[\ua73d]/g},{base:"dz",reg:/[\u01f3\u01c6]/g},{base:"hv",reg:/[\u0195]/g},{base:"lj",reg:/[\u01c9]/g},{base:"nj",reg:/[\u01cc]/g},{base:"oi",reg:/[\u01a3]/g},{base:"ou",reg:/[\u0223]/g},{base:"oo",reg:/[\ua74f]/g},{base:"tz",reg:/[\ua729]/g},{base:"vy",reg:/[\ua761]/g}],ha=[{names:["Arabic"],source:"\u0600-\u06ff"},{names:["Armenian"],source:"\u0530-\u058f"},{names:["Bopomofo"],source:"\u3100-\u312f"},{names:["Cyrillic"],source:"\u0400-\u04ff"}, {names:["Devanagari"],source:"\u0900-\u097f"},{names:["Ethiopic"],source:"\u1200-\u137c\u2d80-\u2dde"},{names:["Georgian"],source:"\u10a0-\u10ff"},{names:["Greek"],source:"\u0370-\u03ff"},{names:["Hangul"],source:"\uac00-\ud7af\u1100-\u11ff"},{names:["Han","Kanji"],source:"\u4e00-\u9fff\uf900-\ufaff"},{names:["Hebrew"],source:"\u0590-\u05ff"},{names:["Hiragana"],source:"\u3040-\u309f\u30fb-\u30fc"},{names:["Kana"],source:"\u3040-\u30ff\uff61-\uff9f"},{names:["Katakana"],source:"\u30a0-\u30ff\uff61-\uff9f"}, {names:["Thai"],source:"\u0e00-\u0e7f"}],V=function(a,b,c,d){var e=Array.prototype.slice.call(b).join("");e=e.replace(/all/,"").replace(/(\w)lphabet|umbers?|atakana|paces?|unctuation/g,"$1");return a.replace(c,function(f){return d[f]&&(!e||e.has(d[f].type))?d[f].to:f})},ia=[{type:"a",shift:65248,start:65,end:90},{type:"a",shift:65248,start:97,end:122},{type:"n",shift:65248,start:48,end:57},{type:"p",shift:65248,start:33,end:47},{type:"p",shift:65248,start:58,end:64},{type:"p",shift:65248,start:91, end:96},{type:"p",shift:65248,start:123,end:126}],W={},X={},ja=/[\u0020-\u00A5]|[\uFF61-\uFF9F][\uff9e\uff9f]?/g,ka=/[\u3000-\u301C]|[\u301A-\u30FC]|[\uFF01-\uFF60]|[\uFFE0-\uFFE6]/g,la=/[\u30ab\u30ad\u30af\u30b1\u30b3\u30b5\u30b7\u30b9\u30bb\u30bd\u30bf\u30c1\u30c4\u30c6\u30c8\u30cf\u30d2\u30d5\u30d8\u30db]/,ma=/[\u30cf\u30d2\u30d5\u30d8\u30db\u30f2]/,q=function(a,b,c){W[b]={type:a,to:c};X[c]={type:a,to:b}},F=function(a,b,c,d){var e=String(b);if(e!=b)e="";Object.isNumber(c)||(c=1);Object.isNumber(d)|| (d=1);return e.repeat(c)+a+e.repeat(d)},na=function(a,b){var c=a.match(b);if(c&&!RegExp.NPCGSupport&&!b.global)for(var d=1;d/g,">")},unescapeHTML:function(){return this.replace(/</g, "<").replace(/>/g,">").replace(/&/g,"&")},encodeBase64:function(){return btoa(this)},decodeBase64:function(){return atob(this)},capitalize:function(a){a=a?/\b[a-z]/g:/^[a-z]/;return this.toLowerCase().replace(a,function(b){return b.toUpperCase()})},pad:function(a,b){return F(this,a,b,b)},padLeft:function(a,b){return F(this,a,b,0)},padRight:function(a,b){return F(this,a,0,b)},repeat:function(a){if(!Object.isNumber(a)||a<1)return"";for(var b="",c=0;c0?arguments:[""],function(b){a=a.replace(RegExp("]*>","gi"),"")});return a},removeTags:function(){var a=this;r(arguments.length>0?arguments:["\\S+"],function(b){a=a.replace(RegExp("<("+b+")[^<>]*(?:\\/>|>.*?<\\/\\1>)","gi"),"")});return a},truncate:function(a,b,c){var d;b=b===undefined?"...":String(b);a-=b.length;if(this.length<=a)return this.toString(); d=/^(.)\1+$/.test(b)?b.slice(0,1):"";for(d=RegExp("[^\t\n\u000b\u000c\r \u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u2028\u2029\u3000\ufeff"+d+"][\t\n\u000b\u000c\r \u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u2028\u2029\u3000\ufeff"+d+"]");a>0&&!d.test(this.slice(a-1,a+1))&&c!==true;)a--;return this.slice(0,a)+(a>0?b:"")}});k(String,true,function(a){return!Object.isRegExp(a)},{split:function(a, b){var c=[],d=0,e=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.sticky?"y":"");a=a.addFlag("g");var f,g,h;RegExp.NPCGSupport||(f=RegExp("^"+a.source+"$(?!\\s)",e));if(b===undefined||+b<0)b=Infinity;else{b=Math.floor(+b);if(!b)return[]}for(;g=a.exec(this);){e=g.index+g[0].length;if(e>d){c.push(this.slice(d,g.index));!RegExp.NPCGSupport&&g.length>1&&g[0].replace(f,function(){for(var i=1;i1&&g.index=b)break}a.lastIndex===g.index&&a.lastIndex++}if(d===this.length){if(h||!a.test(""))c.push("")}else c.push(this.slice(d));return c.length>b?c.slice(0,b):c}});k(String,true,false,{insert:String.prototype.add});var G,H,I=["january","february","march","april","may","june","july","august","september","october","november","december"],J=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Y=["zero","one","two","three","four","five","six","seven", "eight","nine","ten"],Z=[{reg:"(\\d{4})",to:["year"]},{reg:"(\\d{4})[-/.](\\d{1,2})",to:["year","month"]},{reg:"([+-])?(\\d{4})[-/.]?(\\d{1,2})[-/.]?(\\d{1,2})",to:["year_sign","year","month","day"]},{reg:"(\\d{2})-?(\\d{2})-?(\\d{2})",to:["year","month","day"]},{reg:"(\\d{1,2})[\\-/.](\\d{1,2})",to:["month","day"],variant:true},{reg:"(\\d{1,2})[\\-/.](\\d{1,2})[\\-/.](\\d{2,4})",to:["month","day","year"],variant:true},{reg:"({MONTHS})[\\s\\-.](\\d{4})",to:["month","year"]},{reg:"(?:{WEEKDAYS})?\\s*({MONTHS})[\\s\\-.]?(?:(\\d{1,2})(?:st|nd|rd|th)?)?,?[\\s\\-.]?(\\d{2,4})?", to:["month","day","year"]},{reg:"(\\d{1,2}) ({MONTHS}),? (\\d{4})",to:["day","month","year"]},{reg:"(?:(the|a|{NUMBER}|\\d+) (day|week|month|year)s? (before|after|from)\\s+)?(today|tomorrow|yesterday|{WEEKDAYS})(?: at)?",to:["modifier_amount","modifier_unit","modifier_sign","fuzzy_day"]},{reg:"(a|{NUMBER}|\\d+) (millisecond|second|minute|hour|day|week|month|year)s? (from now|ago)",to:["modifier_amount","modifier_unit","modifier_sign"],relative:true},{reg:"(this|next|last)?\\s*(?:week\\s*)?({WEEKDAYS})(?: at)?", to:["modifier_sign","fuzzy_day"]},{reg:"({WEEKDAYS}) (?:of\\s*)?(this|next|last) week",to:["fuzzy_day","modifier_sign"]},{reg:"({MONTHS})(?: (\\d{1,2})(?:st|nd|rd|th)?)? of (this|next|last) (year)",to:["month","day","modifier_sign","modifier_unit"]},{reg:"(?:the\\s)?(first day|last day)?(\\d{1,2}(?:st|nd|rd|th))? of (?:(the|this|next|last) (month)|({MONTHS}))",to:["modifier_edge","day","modifier_sign","modifier_unit","month"]},{reg:"(?:the\\s)?(beginning|end|first day|last day) of (?:(the|this|next|last) (week|month|year)|(\\d{4})|({MONTHS}))", to:["modifier_edge","modifier_sign","modifier_unit","year","month"]},{reg:"(this|next|last) (week|month|year)",to:["modifier_sign","modifier_unit"],relative:true},{reg:"(midnight|noon)(?: (tonight|today|tomorrow|yesterday|{WEEKDAYS}))?",to:["hour","fuzzy_day"],timeIncluded:true},{reg:"^(?:(\\d{1,2}):?(\\d{2})?:?(\\d{2})?(\\.\\d{1,6})?(am|pm)?(?:(Z)|(?:([+-])(\\d{2})(?::?(\\d{2}))?)?)?)$",to:["hour","minute","second","millisecond","meridian","utc","offset_sign","offset_hours","offset_minutes"],today:true, timeIncluded:true}],oa=[{token:"millisec(?:onds?)?|ms(?:ms)?",pad:3,format:function(a,b){return n(a,"get",b,"Milliseconds")}},{token:"s(?:s|ec(?:onds?)?)?",pad:2,format:function(a,b){return n(a,"get",b,"Seconds")}},{token:"m(?:m|in(?:utes?)?)?",pad:2,caps:true,format:function(a,b){return n(a,"get",b,"Minutes")}},{token:"h(?:h|(?:ours?))?|24hr",pad:2,format:function(a,b){return n(a,"get",b,"Hours")}},{token:"12hr",pad:2,format:function(a,b){var c=n(a,"get",b,"Hours");return c===0?12:c-Math.floor(c/ 13)*12}},{token:"d(?:d|ate|ays?)?",pad:2,format:function(a,b){return n(a,"get",b,"Date")}},{token:"dow|weekday(?: short)?",weekdays:true,format:function(a,b){return n(a,"get",b,"Day")}},{token:"MM?",pad:2,caps:true,format:function(a,b){return n(a,"get",b,"Month")+1}},{token:"mon(th)?(?: short)?",months:true,format:function(a,b){return n(a,"get",b,"Month")}},{token:"yy",format:function(a,b){return n(a,"get",b,"FullYear").toString().from(2)}},{token:"yyyy|year",format:function(a,b){return n(a,"get", b,"FullYear")}},{token:"t{1,2}",meridian:true,format:function(a,b){return n(a,"get",b,"Hours")<12?"am":"pm"}},{token:"tz|timezone",format:function(a){return a.getUTCOffset()}},{token:"iso(tz|timezone)",format:function(a){return a.getUTCOffset(true)}},{token:"ord",format:function(a,b){return n(a,"get",b,"Date").ordinalize()}}],s=[{unit:"year",method:"FullYear",multiplier:function(a){return(365+(a?a.isLeapYear()?1:0:0.25))*24*60*60*1E3}},{unit:"month",method:"Month",multiplier:function(a,b){var c=30.4375, d;if(a){d=a.daysInMonth();if(b<=d.days())c=d}return c*24*60*60*1E3}},{unit:"week",method:"Week",multiplier:function(){return 6048E5}},{unit:"day",method:"Date",multiplier:function(){return 864E5}},{unit:"hour",method:"Hours",multiplier:function(){return 36E5}},{unit:"minute",method:"Minutes",multiplier:function(){return 6E4}},{unit:"second",method:"Seconds",multiplier:function(){return 1E3}},{unit:"millisecond",method:"Milliseconds",multiplier:function(){return 1}}],z=function(a){if(typeof a[0]=== "object")return a;else if(a.length==1&&Object.isNumber(a[0]))return[a[0]];for(var b={},c=Array.prototype.slice.call(arguments,1),d=0;d0?c:0;if(!h.date.isValid())return false;m(s,function(o){if(h.set[o.unit]!==undefined||h.set[o.unit+"s"]!==undefined){f=o.unit; g=o.multiplier(h.date,a-h.date)-1}});if(h.format.relative)if(b=h.date["beginningOf"+f.capitalize(f)])b.call(h.date);else{c=c||Math.round(g/2);g=0}g=g||0;b=a.getTime();var i=h.date.getTime(),l=i+g;return d==="after"?e?b-c>i:b>l+c:d==="before"?e?b=i-c&&b=0?-1:1;var f="millisecond";m(s.concat().reverse().slice(1),function(g){b=Math.floor(d/g.multiplier(a,d));if(b>=1){e=b;f= g.unit}});if(e!=1)f+="s";return[e,f,d,c]},ra=function(a,b,c){var d,e=a.getDate();if(!(e<29)){m(s.slice(2),function(f){if(b[f.unit]!==undefined)d=true});if(!d){c=(new Date(a.getFullYear()+(b.year*c||0),a.getMonth()+b.month*c)).daysInMonth();c=2&&Object.isNumber(a[0])?z(a,"year","month","day","hour","minute","second","millisecond")[0]:a[0];return $(a).date},ua=function(a,b){var c=function(){return Math.round(this*b)},d=function(){return ca(this,arguments, a,"rewind")},e=function(){return ca(this,arguments,a,"advance")};j(Number.prototype,a,c);j(Number.prototype,a+"s",c);j(Number.prototype,a+"Before",d);j(Number.prototype,a+"sBefore",d);j(Number.prototype,a+"Ago",d);j(Number.prototype,a+"sAgo",d);j(Number.prototype,a+"After",e);j(Number.prototype,a+"sAfter",e);j(Number.prototype,a+"FromNow",e);j(Number.prototype,a+"sFromNow",e)},va=function(){m(s,function(a,b){var c=a.unit,d=c.capitalize(),e=a.multiplier();j(Date.prototype,c+"sSince",function(f){return Math.round((this.getTime()- Date.create(f).getTime())/e)});j(Date.prototype,c+"sUntil",function(f){return Math.round((Date.create(f).getTime()-this.getTime())/e)});j(Date.prototype,c+"sAgo",Date.prototype[c+"sUntil"]);j(Date.prototype,c+"sFromNow",Date.prototype[c+"sSince"]);j(Date.prototype,"add"+d+"s",function(f){var g={};g[c]=f;return this.advance(g)});ua(c,e);if(b<3){j(Date.prototype,"isLast"+d,function(){return this.is("last "+c)});j(Date.prototype,"isThis"+d,function(){return this.is("this "+c)});j(Date.prototype,"isNext"+ d,function(){return this.is("next "+c)})}if(b<4){j(Date.prototype,"beginningOf"+d,function(f){if(f===undefined||c=="day")f=true;var g={month:0,day:1};switch(c){case "week":g.weekday=0;case "day":g.day=this.getDate();case "month":g.month=this.getMonth()}return this.set(g,f)});j(Date.prototype,"endOf"+d,function(f){if(f===undefined||c=="day")f=true;var g=f?{hours:23,minutes:59,seconds:59,milliseconds:999}:{};g.day=this.getDate();g.month=this.getMonth();switch(c){case "year":g.month=11;g.day=31;break; case "month":g.day=this.daysInMonth();break;case "week":g.weekday=6}return this.set(g,f)})}})},wa=function(){G=I.map(function(d){return d.to(3)});H=J.map(function(d){return d.to(3)});var a=I.map(function(d){return d.to(3)+"(?:\\.|"+d.from(3)+")?"}).join("|"),b=J.map(function(d){return d.to(3)+"(?:\\.|"+d.from(3)+")?"}).join("|"),c=Y.join("|");m(Z,function(d){var e="^"+d.reg;e=e.replace(/{WEEKDAYS}/,b);e=e.replace(/{MONTHS}/,a);e=e.replace(/{NUMBER}/,c);if(!d.timeIncluded){e+="(?:(?:\\s+|t)(\\d{1,2}):?(\\d{2})?:?(\\d{2})?(\\.\\d{1,6})?(am|pm)?(?:(Z)|(?:([+-])(\\d{2})(?::?(\\d{2}))?)?)?)?$"; d.to=d.to.concat(["hour","minute","second","millisecond","meridian","utc","offset_sign","offset_hours","offset_minutes"])}d.reg=RegExp(e,"i")})},xa=function(){m(["today","yesterday","tomorrow","weekday","weekend","future","past"].concat(J).concat(I),function(a){j(Date.prototype,"is"+a.capitalize(),function(){return this.is(a)})})},ya=function(){var a=new Date(1999,11,31);k(Date,true,!(a.toISOString&&a.ISOString==="1999-12-31T00:00:00.000Z"),{toISOString:function(){return O(this.toUTC(),Date.ISO8601_DATETIME)}}); k(Date,true,false,{iso:Date.prototype.toISOString})};k(Date,false,false,{create:function(){return N(arguments)},now:function(){return(new Date).getTime()}});k(Date,true,false,{set:function(){var a=z(arguments,"year","month","day","hour","minute","second","millisecond");return K(this,a[0],a[1])},setUTC:function(){var a=z(arguments,"year","month","day","hour","minute","second","millisecond");return K(this,a[0],a[1],true)},setWeekday:function(a){a!==undefined&&this.setDate(this.getDate()+a-this.getDay())}, setUTCWeekday:function(a){a!==undefined&&this.setDate(this.getUTCDate()+a-this.getDay())},setWeek:function(a){if(a!==undefined){this.getDate();this.setMonth(0);this.setDate(a*7+1)}},setUTCWeek:function(a){if(a!==undefined){this.getUTCDate();this.setMonth(0);this.setUTCDate(a*7+1)}},getWeek:function(){var a=new Date(this.getFullYear(),0,1);return Math.ceil((this.getTime()-a.getTime()+1)/6048E5)},getUTCWeek:function(){var a=(new Date).setUTC(this.getUTCFullYear(),0,1,0,0,0,0);return Math.ceil((this.getTime()- a.getTime()+1)/6048E5)},getUTCOffset:function(a){var b=this.utc?0:this.getTimezoneOffset(),c=a===true?":":"";if(!b&&a)return"Z";return Math.round(-b/60).pad(2,true)+c+(b%60).pad(2)},toUTC:function(){if(this.utc)return this;var a=this.clone().addMinutes(this.getTimezoneOffset());a.utc=true;return a},isUTC:function(){return this.utc||this.getTimezoneOffset()===0},advance:function(){var a=z(arguments,"year","month","day","hour","minute","second","millisecond");return K(this,a[0],false,false,1,true)}, rewind:function(){var a=z(arguments,"year","month","day","hour","minute","second","millisecond");return K(this,a[0],false,false,-1)},isValid:function(){return!isNaN(this.getTime())},isAfter:function(a,b){return t(this,a,b,"after")},isBefore:function(a,b){return t(this,a,b,"before")},isBetween:function(a,b,c){return t(this,a,c,"after",true)&&t(this,b,c,"before",true)?true:t(this,b,c,"after",true)&&t(this,a,c,"before",true)},isLeapYear:function(){var a=this.getFullYear();return a%4===0&&a%100!==0|| a%400===0},daysInMonth:function(){return 32-(new Date(this.getFullYear(),this.getMonth(),32)).getDate()},format:function(a){return O(this,a)},relative:function(a){return O(this,a||"relative")},is:function(a,b){var c,d;if(Object.isString(b)){var e=u(s,function(f){return f.unit===b});if(e)b=e.multiplier()}b=b>0?b:0;if(Object.isString(a)){a=a.trim();return a==="future"?this.getTime()>(new Date).getTime():a==="past"?this.getTime()<(new Date).getTime():a==="weekday"?!(this.getDay()===0||this.getDay()=== 6):a==="weekend"?this.getDay()===0||this.getDay()===6:(d=ta(a))?this.getDay()===d:(c=sa(a))?this.getMonth()===c:t(this,a,b)}else{a=Date.create(a);b=b||0;c=this.getTime();d=a.getTime();return c>=d-b&&c>2;c=(c&3)<<4|d>>4;g=(d&15)<<2|e>>6;h=e&63;if(isNaN(d))g=h=64;else if(isNaN(e))h=64;b=b+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(f)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(c)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(g)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(h)}while(i>4;d=(d&15)<<4|f>>2;e=(f&3)<<6|g;b+=c.chr();if(f!=64)b+=d.chr();if(g!=64)b+=e.chr()}while(h