(function(){var domDefineProperty=false,objectIdStore=[],objectDescriptorStore=[];var extend,alias;try{Object.defineProperty({},"x",{})}catch(e){domDefineProperty=true}if(typeof window!=="undefined"&&window.__jstExtend){extend=window.__jstExtend}else{extend=function(prototype,methods){if(arguments.length===3){var n=methods,methods={};methods[n]=arguments[2]}for(name in methods){if(Object.prototype.hasOwnProperty.call(methods,name)){var method=methods[name];if(domDefineProperty){for(var id=-1,i=0;i<objectIdStore.length;i++){if(objectIdStore[i]===prototype){id=i}}id=(id<0)?objectIdStore.push(prototype)-1:id;if(!objectDescriptorStore[id]){objectDescriptorStore[id]={}}objectDescriptorStore[id][name]={writable:(typeof method==="function"),enumerable:false,configurable:(typeof method==="function")};prototype[name]=method}else{Object.defineProperty(prototype,name,{value:method,writable:(typeof method==="function"),enumerable:false,configurable:(typeof method==="function")})}}}}}extend(Array,{range:function range(start,stop,step){if(arguments.length===1){stop=start;step=start=(stop<0?-1:1)}else{if(arguments.length===0){return[]}else{if(step===undefined){step=(stop<start?-1:1)}else{if(step===0||isNaN(step)){throw new RangeError("Step must be an valid integer and not be equal to 0.")}}}}step=Number(step),stop=Number(stop),start=Number(start);var arr=[];if(stop<start){if(step>=0){throw new RangeError("Stop must not be greater than start if step is to be positive.")}for(var i=start,arr=[];i>=stop;arr.push(i),i+=step){}}if(stop>start){if(step<=0){throw new RangeError("Stop must not be less than start if step is to be negative.")}for(var i=start,arr=[];i<=stop;arr.push(i),i+=step){}}return arr}});extend(Array.prototype,{concat$:function concat$(){Array.prototype.push.apply(this,arguments);return this},swap:function swap(index1,index2){return this.clone().swap$(index1,index2)},swap$:function swap$(index1,index2){if(!Object.hasOwnProperty.call(this,Number(index1))){throw new RangeError("Array#swap: index1 does not exist within the array.")}if(!Object.hasOwnProperty.call(this,Number(index2))){throw new RangeError("Array#swap: index2 does not exist within the array.")}var value=this[index1];this[index1]=this[index2];this[index2]=value;return this},contains:function contains(){if(arguments.length===0){return false}else{if(arguments.length===1){return !!~this.indexOf(arguments[0])}else{return Array.prototype.slice.call(arguments).every(function(arg){return !!~this.indexOf(arg)}.bind(this))}}},remove$:function remove$(){if(arguments.length===0){return this}exclude=Array.prototype.slice.call(arguments);return this.filter$(function(val){return !exclude.contains(val)})},remove:function remove(){if(arguments.length===0){return this.clone()}exclude=Array.prototype.slice.call(arguments);return this.filter(function(val){return !exclude.contains(val)})},shuffle:function shuffle(){var arr=this.clone();for(var index=0;index<arr.length-1;index++){arr.swap$(index,Number.random(index,arr.length-1).round())}return arr},shuffle$:function shuffle$(){for(var index=0;index<this.length-1;index++){this.swap$(index,Number.random(index,this.length-1).round())}return this},clone:function clone(){return this.slice()},intersect:function intersect(){var arrays=((arguments.length===0)?this:[this].concat(Array.prototype.slice.call(arguments))).map(function(val){return Array.isArray(val)?val.unique():[val]});if(arrays.length===0){return[]}else{if(arrays.length===1){return arrays[0]}}return arrays.shift().filter(function(val){return arrays.every(function(arr){return !!~arr.indexOf(val)})})},diff:function diff(){var concat=Array.prototype.concat,values=concat.apply([],concat.apply(this,arguments));if(values.length===0){return[]}else{if(values.length===1){return arrays[0]}}return values.filter(function(a,i,t){return t.indexOf(a)===t.lastIndexOf(a)})},union:function union(){var concat=Array.prototype.concat,values=concat.apply(this,arguments);if(values.length===0){return[]}else{if(values.length===1){return arrays[0]}}return concat.apply([],values).unique()},chunk:function chunk(size){for(var arr=[];this.length>0;arr.push(this.splice(0,size))){}return arr},chunk$:function chunk$(size){for(var i=0,length=this.length/size;i<length;i++){this.splice(i,0,this.splice(i,size))}return this},unique:function unique(){return this.filter(function(v,i,a){return a.indexOf(v)===i})},each:function each(callback){var self=Object(this),thisArg=arguments[1],length=this.length>>>0,arr=[],result;if(!Function.isFunction(callback)){throw new TypeError(callback+" is not a function.")}for(var i=0;i<length;i++){if((i in self)&&(result=callback.call(thisArg,self[i],i,self))!==undefined){return result}}},flatten:function flatten(level){if(arguments.length===0){level=-1}else{if(level===0){return this.clone()}}for(var i=0,a=this.clone();a.some(Array.isArray)&&(i!=level);i++){a=Array.prototype.concat.apply([],a)}return a},flatten$:function flatten$(level){if(arguments.length===0){level=-1}for(var i=0,length=this.length;i<length;i++){if(Array.isArray(this[i])&&level!=0){this.splice.apply(this,[i,1].concat(this[i].flatten(level-1)))}}return this},sum:function sum(){return this.reduce(function(a,b){return Number(a)+Number(b)})},product:function product(){return this.reduce(function(a,b){return Number(a)*Number(b)})},first:function first(num){return arguments.length?this.slice(0,num||1):this[0]},last:function last(num){return arguments.length?this.slice(this.length-(num||1)):this[this.length-1]},clean:function clean(){return this.filter(function(val){return !!val})},clean$:function clean$(){return this.filter$(function(val){return !!val})},filter$:function filter$(callback,scope){for(var i=0;i<this.length;i++){if(!callback.call(scope,this[i],i,this)){this.splice(i,1)&&i--}}return this},map$:function map$(callback,scope){for(var i=0;i<this.length;i++){this[i]=callback.call(scope,this[i],i,this)}return this},invoke:function invoke(callback){return this.map(function(val){return val[callback].apply(val,Array.prototype.slice.call(this,1))},arguments)},invoke$:function invoke$(callback){return this.map$(function(val){return val[callback].apply(val,Array.prototype.slice.call(this,1))},arguments)},pluck:function pluck(prop){return this.map(function(val){if(Array.isArray(prop)){return Object.filter(val,prop)}return val[prop]})},pluck$:function pluck$(prop){return this.map$(function(val){if(Array.isArray(prop)){return Object.filter(val,prop)}return val[prop]})},grep:function grep(regex){return this.filter(function(val){return !!val.match(regex)})},grep$:function grep$(regex){return this.filter$(function(val){return !!val.match(regex)})},sort$:function sort$(sort){var sorted=(typeof sort==="function")?this.sort(sort):this.sort();sorted.forEach(function(val,i){this[i]=val},this);return this},sortBy:function sortBy(cmp,sort){if(cmp===undefined){return(typeof sort==="function")?this.sort(sort):this.sort()}if(sort===undefined){sort=function(a,b){return String(a)-String(b)}}var arr=this[typeof cmp==="function"?"map":"pluck"](cmp).map(function(val,i){return{key:i,val:val}});return arr.sort(function(a,b){return sort(a.val,b.val)}).map(function(val){return this[val.key]},this)},sortBy$:function sortBy$(cmp,sort){this.sortBy(cmp,sort).forEach(function(v,i){this[i]=v},this);return this},fetch:function fetch(order){if(typeof order=="function"){order=this.map(order)}if(!Array.isArray(order)){order=Array.prototype.slice.call(arguments)}var arr=[];order.forEach(function(o,i){arr[o]=this[i]},this);return arr}});if(!Array.isArray){extend(Array,"isArray",function isArray(arr){return Object.prototype.toString.call(arr)==="[object Array]"})}if(!Array.prototype.forEach){extend(Array.prototype,"forEach",function forEach(callback){var self=Object(this),thisArg=arguments[1],length=this.length>>>0;if(!Function.isFunction(callback)){throw new TypeError(callback+" is not a function.")}for(var i=0;i<length;i++){if(i in self){callback.call(thisArg,self[i],i,self)}}})}if(!Array.prototype.map){extend(Array.prototype,"map",function map(callback){var self=Object(this),thisArg=arguments[1],length=this.length>>>0,arr=new Array(length);if(!Function.isFunction(callback)){throw new TypeError(callback+" is not a function.")}for(var i=0;i<length;i++){if(i in self){arr[i]=callback.call(thisArg,self[i],i,self)}}return arr})}if(!Array.prototype.filter){extend(Array.prototype,"filter",function filter(callback){var self=Object(this),thisArg=arguments[1],length=this.length>>>0,arr=[];if(!Function.isFunction(callback)){throw new TypeError(callback+" is not a function.")}for(var i=0;i<length;i++){if((i in self)&&callback.call(thisArg,self[i],i,self)){arr.push(self[i])}}return arr})}if(!Array.prototype.every){extend(Array.prototype,"every",function every(callback){var self=Object(this),thisArg=arguments[1],length=this.length>>>0;if(!Function.isFunction(callback)){throw new TypeError(callback+" is not a function.")}for(var i=0;i<length;i++){if((i in self)&&!callback.call(thisArg,self[i],i,self)){return false}}return true})}if(!Array.prototype.some){extend(Array.prototype,"some",function some(callback){var self=Object(this),thisArg=arguments[1],length=this.length>>>0;if(!Function.isFunction(callback)){throw new TypeError(callback+" is not a function.")}for(var i=0;i<length;i++){if((i in self)&&callback.call(thisArg,self[i],i,self)){return true}}return false})}if(!Array.prototype.reduce){extend(Array.prototype,"reduce",function reduce(callback){var self=Object(this),value=arguments[1],length=this.length>>>0,i=0,j=i;if(!Function.isFunction(callback)){throw new TypeError(callback+" is not a function.")}if(arguments.length<=1){if(!length){throw new TypeError("Reduce of empty array with no initial value.")}for(i=-1;j<self.length;j++){if(Object.hasOwnProperty.call(self,String(j))){i=j;break}}if(i===-1){throw new TypeError("Reduce of empty array with no initial value.")}value=self[i++]}for(;i<length;i++){if(Object.hasOwnProperty.call(self,i)){value=callback.call(undefined,value,self[i],i,self)}}return value})}if(!Array.prototype.reduceRight){extend(Array.prototype,"reduceRight",function reduceRight(callback){var self=Object(this),value=arguments[1],length=this.length>>>0,i=length-1,j=i;if(!Function.isFunction(callback)){throw new TypeError(callback+" is not a function.")}if(arguments.length<=1){if(!length){throw new TypeError("Array length is 0 and no initial value given.")}for(i=-1;j>=0;j--){if(Object.hasOwnProperty.call(self,String(j))){i=j;break}}if(i===-1){throw new TypeError("Reduce of empty array with no initial value.")}value=self[i--]}for(;i>=0;i--){if(Object.hasOwnProperty.call(self,i)){value=callback.call(undefined,value,self[i],i,self)}}return value})}if(!Array.prototype.indexOf){extend(Array.prototype,"indexOf",function indexOf(value){var self=Object(this),length=this.length>>>0,index=(arguments.length<=1)?0:Number(arguments[1]);index=index<0?length-Math.abs(index):index;for(var i=index;i<length;i++){if((i in self)&&self[i]===value){return i}}return -1})}if(!Array.prototype.lastIndexOf){extend(Array.prototype,"lastIndexOf",function lastIndexOf(value){if(this===void 0||this===null){throw new TypeError()}var self=Object(this),length=this.length>>>0,index=length;if(length===0){return -1}if(arguments.length>1){index=Number(arguments[1]);if(index!==index){index=0}else{if(index!==0&&index!==(1/0)&&index!==-(1/0)){index=(index>0||-1)*Math.floor(Math.abs(index))}}}var i=(index>=0)?Math.min(index,length-1):length-Math.abs(index);for(;i>=0;i--){if((i in self)&&(self[i]===value)){return i}}return -1})}extend(Date.prototype,{fuzzyDiff:function fuzzyDiff(date,suffix,prefix){if(!(date instanceof Date)){date=new Date(date)}var delta=this.getTime()-date.getTime(),units={second:1000,minute:60000,hour:3600000,day:86400000,year:31557600000};var keys=Object.keys(units),divs=Object.values(units);for(var i=0;i<divs.length;i++){if((delta/divs[i])<1||i==divs.length){var time=(delta/divs[i-1]),key=keys[i-1];if(time>1){key+="s"}if(arguments.length<3){prefix=(time.round()==time)?"exactly":"about"}if(arguments.length<2){suffix="ago"}return"%s %d %s %s".sprintf(prefix,time.round(),key,suffix)}}}});if(!Date.now){extend(Date,"now",function now(){return(new Date()).getTime()})}extend(Date,{SECOND:1,MINUTE:60,HOUR:3600,DAY:86400,YEAR:31557600,DECADE:315576000});if(isNaN(Date.parse("2011-06-15T21:40:05+06:00"))){Date=(function(NativeDate){var Date=function(Y,M,D,h,m,s,ms){var length=arguments.length;if(this instanceof NativeDate){var date=length==1&&String(Y)===Y?new NativeDate(Date.parse(Y)):length>=7?new NativeDate(Y,M,D,h,m,s,ms):length>=6?new NativeDate(Y,M,D,h,m,s):length>=5?new NativeDate(Y,M,D,h,m):length>=4?new NativeDate(Y,M,D,h):length>=3?new NativeDate(Y,M,D):length>=2?new NativeDate(Y,M):length>=1?new NativeDate(Y):new NativeDate();date.constructor=Date;return date}return NativeDate.apply(this,arguments)};var isoDateExpression=new RegExp("^(\\d{4})(?:-(\\d{2})(?:-(\\d{2})(?:T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{3}))?)?(?:Z|(?:([-+])(\\d{2}):(\\d{2})))?)?)?)?$");for(var key in NativeDate){Date[key]=NativeDate[key]}Date.now=NativeDate.now;Date.UTC=NativeDate.UTC;Date.prototype=NativeDate.prototype;Date.prototype.constructor=Date;Date.parse=function parse(string){var match=isoDateExpression.exec(string);if(match){match.shift();for(var i=1;i<7;i++){match[i]=+(match[i]||(i<3?1:0));if(i==1){match[i]--}}var minutesOffset=+match.pop(),hourOffset=+match.pop(),sign=match.pop();var offset=0;if(sign){if(hourOffset>23||minuteOffset>59){return NaN}offset=(hourOffset*60+minuteOffset)*60000*(sign=="+"?-1:1)}return NativeDate.UTC.apply(this,match)+offset}return NativeDate.parse.apply(this,arguments)};return Date})(Date)}extend(Function,{isFunction:function isFunction(func){return(typeof func==="function")&&!!func.call},compose:function compose(funcs){if(!Array.isArray(funcs)){funcs=Array.prototype.slice.call(arguments)}funcs=funcs.reverse();return function(arg){return funcs.reduce(function(a,b){return b(a)},arg)}}});extend(Function.prototype,{cache:function cache(time,ident){time=isNaN(time)?-1:time;ident=ident||function(id){return(typeof id=="object")?Object.id(id):id.toString()};var cache={},callback=this,timeouts={};return function(){var args=Array.prototype.slice.call(arguments),id="("+args.map(ident).join(",")+")";if(!(id in cache)){cache[id]=callback.apply(callback,args)}else{if(id in timeouts){clearTimeout(timeouts[id]);delete timeouts[id]}}if(time>0){timeouts[id]=setTimeout(function(){delete cache[id]},time)}return cache[id]}},delay:function delay(callback,time,scope){return setTimeout(function(args){callback.apply(scope,[this()].concat(Array.prototype.slice.call(args,2)))}.bind(this,arguments),time)},once:function once(scope){var called=false,val=null;return function(args){if(!called){called=true;val=this.apply(scope,args)}return val}.bind(this,Array.prototype.slice.call(arguments))}});if(!Function.prototype.bind){extend(Function.prototype,"bind",function bind(thisArg){if(!Function.isFunction(this)){throw new TypeError(this+" is not a function.")}var args=Array.prototype.slice.call(arguments,1),self=this,target=function(){};function bound(){return self.apply(this instanceof target?this:thisArg,args.concat(Array.prototype.slice.call(arguments)))}target.prototype=this.prototype;bound.prototype=new target();return bound})}extend(Number,{random:function random(start,end){return(start=start||0)+(((end||start+1)-start)*Math.random())}});extend(Number.prototype,{pow:function pow(n){return Math.pow(this,n)},ordinal:function ordinal(append){append=(arguments.length===0)?true:!!append;var ord="";if(this>=4&&this<=20){ord="th"}else{switch(this%10){case 1:ord="st";break;case 2:ord="nd";break;case 3:ord="rd";break;default:ord="th";break}}return(append?this.round():"")+ord},chr:function(){return String.fromCharCode(this)},odd:function(){return !this.even()},even:function(){return(this%2)==0},gcd:function gcd(){return Array.prototype.slice.call(arguments).reduce(function(a,b){if(a==0||b==0){return a|b}for(var shift=0;((a|b)&1)==0;shift++){a>>=1;b>>=1}while((a&1)==0){a>>=1}do{while((b&1)==0){b>>=1}if(a<b){b-=a}else{var diff=a-b;a=b;b=diff}b>>=1}while(b!=0);return a<<shift},this)},lcm:function lcm(){var nums=Array.prototype.slice.call(arguments),gcd=this.gcd.apply(this,nums);return Math.abs(nums.product()*this)/gcd},ceil:function ceil(){return Math.ceil(this)},floor:function floor(){return Math.floor(this)},abs:function abs(){return Math.abs(this)},round:function round(digits){digits=digits||0;if(digits==0){return Math.round(this)}else{if(digits<0){return Number(this.toPrecision(this.floor().toString().length-digits.abs()))}else{return Number(this.toFixed(digits))}}},radix:function radix(base,size,character){return this.toString(base).pad(-size,(character||"0"))},bin:function bin(size,character){return this.radix(2,size,character)},oct:function oct(size,character){return this.radix(8,size,character)},dec:function dec(size,character){return this.radix(10,size,character)},hexl:function hexl(size,character){return this.radix(16,size,character)},hex:function hex(size,character){return this.radix(16,size,character).toUpperCase()},abbr:function abbr(digits,binary){binary=!!(binary==undefined?false:binary);var prefixes={k:binary?1<<10:1000,M:binary?1<<20:1000000,G:binary?1<<30:1000000000,T:binary?Math.pow(2,40):1000000000000,P:binary?Math.pow(2,50):1000000000000000,E:binary?Math.pow(2,60):1000000000000000000,Z:binary?Math.pow(2,70):1e+21,Y:binary?Math.pow(2,80):1e+24};var keys=Object.keys(prefixes),divs=Object.values(prefixes);if(divs[0]>this){return this.toFixed(digits)}for(var i=0;i<divs.length;i++){if((this/divs[i])<1){return(this/divs[i-1]).toFixed(digits)+keys[i-1]}}return(this/divs.last()).toFixed(digits)+keys.last()}});extend(Object,{follow:function follow(obj,keys,sep){if(!Array.isArray(keys)){if(typeof keys!=="string"){throw new TypeError("Object.follow requires keys to either be an array or string value.")}keys=keys.split(sep||".")}return keys.reduce(function(o,k){if(o&&(k in o)){return o[k]}},obj)},value:function value(obj,key){var desc=Object.getOwnPropertyDescriptor(obj,key);if(desc&&!Object.getOwnPropertyDescriptor(obj,key).writable){return obj[key]}return(arguments.length===2)?obj[key]:(obj[key]=arguments[2])},remove:function remove(obj,key){if(!Object.getOwnPropertyDescriptor(obj,key).configurable){return false}if(obj.__ownPropertyDescriptors__){delete obj.__ownPropertyDescriptors__[key]}return delete obj[key]},id:function id(obj){if(!objectIdStore.contains(obj)){objectIdStore.push(obj)}return objectIdStore.indexOf(obj)},alias:function alias(object,property,alias,complete){var desc=Object.getOwnPropertyDescriptor(object,property);if(!complete){Object.defineProperty(object,alias,desc)}else{if(("get" in desc)||("value" in desc)){delete desc.value,delete desc.writable;desc.get=function(){return object[property]}}desc.set=function(val){return object[property]=val};Object.defineProperty(object,alias,desc)}return object},values:function values(obj){var arr=[];Object.keys(obj).forEach(function(key){arr.push(obj[key])});return arr},forEach:function forEach(obj,callback,scope){return Object.keys(obj).forEach(function(key){return callback.call(scope,key,obj[key],obj)})},isObject:function isObject(){return Array.prototype.slice.call(arguments).every(function(value){return Object(value)===value})},each:function each(obj,callback,scope){var key,result;for(key in obj){if(key!=="__proto__"){if((result=callback.call(scope,key,obj[key],this))!==undefined){return result}}}},map:function map(object,callback,scope){var obj=Object.clone(object);Object.map$(obj,callback,scope);return obj},map$:function map$(obj,callback,scope){Object.forEach(obj,function(key,val){Object.value(obj,key,callback.call(scope,key,val))});return obj},getOwnPropertyDescriptors:function getOwnPropertyDescriptors(object){var descriptors={};Object.getOwnPropertyNames(object).forEach(function(key){descriptors[key]=Object.getOwnPropertyDescriptor(object,key)});return descriptors},reduce:function reduce(obj,callback,start,scope){Object.forEach(obj,function(key,val){start=callback.call(scope,start,key,obj[key])});return start},merge:function merge(objects,level){if(Object.isObject(objects,level)){objects=Array.prototype.slice.call(arguments),level=0}level=(level===undefined)?0:level;return objects.reduce(function(group,obj){Object.forEach(obj,function(key,val){if(!val in group||level==0||!Object.isObject(group[key])||!Object.isObject(val)){group[key]=val}else{group[key]=Object.merge([group[key],val],level-1)}});return group},{})},merge$:function merge$(object,objects,level){if(Array.isArray(objects)){objects=[object].concat(objects)}else{objects=Array.prototype.slice.call(arguments);level=undefined}var obj=Object.merge.apply(undefined,objects,level);Object.filter$(object,function(key,val){return Object.hasOwnProperty.call(obj,key)});Object.map$(object,function(key,val){return obj[key]});Object.keys(obj).diff(Object.keys(object)).forEach(function(key){Object.value(object,key,obj[key])});return object},clone:function clone(obj,inherit){inherit=(inherit===undefined)?true:false;var obj=Object.create(Object.getPrototypeOf(obj),inherit?Object.getOwnPropertyDescriptors(obj):undefined);return obj},filter:function filter(object,callback,scope){return Object.filter$(Object.clone(object),callback,scope)},filter$:function filter$(obj,callback,scope){if(Array.isArray(callback)){var keys=callback.invoke("toString")}Object.forEach(obj,function(key,val){if(Array.isArray(callback)){if(!keys.contains(key)){Object.remove(obj,key)}}else{if(callback.call(scope,key,val,obj)===false){Object.remove(obj,key)}}});return obj},clean:function clean(obj){return Object.filter(obj,function(key,val){return !!val})},clean$:function clean$(obj){return Object.filter$(obj,function(key,val){return !!val})},size:function size(obj){return Object.keys(obj).length},combine:function combine(keys,values){var obj={};keys.forEach(function(key,i){obj[key]=values[i]});return obj},hash:function hash(object){return Object.hash$(Object.clone(object))},hash$:function hash$(object){return Object.defineProperties(object,{size:{value:function(){return Object.size(this)},writable:true,enumerable:false,configurable:true},keys:{value:function keys(callback,scope){return Object.keys(this)},writable:true,enumerable:false,configurable:true},each:{value:function each(callback,scope){return Object.each(this,callback,scope)},writable:true,enumerable:false,configurable:true},forEach:{value:function forEach(callback,scope){return Object.forEach(this,callback,scope)},writable:true,enumerable:false,configurable:true},map:{value:function map(callback,scope){return Object.map(this,callback,scope)},writable:true,enumerable:false,configurable:true},map$:{value:function map$(callback,scope){return Object.map$(this,callback,scope)},writable:true,enumerable:false,configurable:true},reduce:{value:function reduce(callback,start){return Object.reduce(this,callback,start)},writable:true,enumerable:false,configurable:true},filter:{value:function filter(callback,scope){return Object.filter(this,callback,scope)},writable:true,enumerable:false,configurable:true},filter$:{value:function filter$(callback,scope){return Object.filter$(this,callback,scope)},writable:true,enumerable:false,configurable:true},clean:{value:function clean(callback,scope){return Object.clean(this,callback,scope)},writable:true,enumerable:false,configurable:true},clean$:{value:function clean$(callback,scope){return Object.clean$(this,callback,scope)},writable:true,enumerable:false,configurable:true},clone:{value:function clone(callback,scope){return Object.clone(this,callback,scope)},writable:true,enumerable:false,configurable:true},merge:{value:function merge(){return Object.merge.apply(undefined,[this].concat(Array.prototype.slice.call(arguments)))},writable:true,enumerable:false,configurable:true},merge$:{value:function merge$(){return Object.merge$.apply(undefined,[this].concat(Array.prototype.slice.call(arguments)))},writable:true,enumerable:false,configurable:true}})}});if(!Object.getPrototypeOf){extend(Object,"getPrototypeOf",function getPrototypeOf(object){return object.__proto__||object.constructor.prototype||protoStore[Object.id(object)]})}if(!Object.getOwnPropertyDescriptor||domDefineProperty){var oldGetOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,objectDescriptorStore={};extend(Object,"getOwnPropertyDescriptor",function getOwnPropertyDescriptor(object,property){if(object.nodeType&&oldGetOwnPropertyDescriptor){return oldGetOwnPropertyDescriptor(object,property)}if(!Object.isObject(object)){throw new TypeError(object+" is not an object.")}if(!Object.prototype.hasOwnProperty.call(object,property)){return}var descriptor={enumerable:Object.prototype.propertyIsEnumerable.call(object,property),writable:true,configurable:true},getter,setter,id=Object.id(object);if((object instanceof Function&&["arguments","length","name","prototype","caller"].contains(property))||(object===Number&&["NaN","NEGATIVE_INFINITY","POSITIVE_INFINITY","MAX_VALUE","MIN_VALUE"].contains(property))||(object===Math&&["LN10","PI","E","LOG10E","SQRT2","LOG2E","SQRT1_2","LN2"].contains(property))){descriptor={configurable:false,writable:false,enumerable:false}}if(object instanceof RegExp&&["lastIndex","multiline","global","source","ignoreCase"].contains(property)){descriptor={configurable:false,writable:(property=="lastIndex"),enumerable:false}}if((Array.isArray(object)||String.isString(object))&&property==="length"){descriptor={configurable:false,writable:true,enumerable:false}}else{if(objectDescriptorStore[id]&&(property in objectDescriptorStore[id])){descriptor=objectDescriptorStore[id][property]}}if(Object.prototype.__lookupGetter__&&(getter=object.__lookupGetter__(property))){descriptor.writable=false;descriptor.get=getter}if(Object.prototype.__lookupSetter__&&(setter=object.__lookupSetter__(property))){descriptor.writable=false;descriptor.set=setter}if(!("set" in descriptor||"get" in descriptor)){descriptor.value=object[property]}return descriptor})}if(!Object.getOwnPropertyNames){extend(Object,"getOwnPropertyNames",function getOwnPropertyNames(object){var names=Object.keys(object);if((typeof globals!=="undefined"&&object===globals)||(typeof window!=="undefined"&&object===window)){names.push("Infinity","NaN","undefined","decodeURI","encodeURIComponent","isNaN","decodeURIComponent","eval","parseFloat","encodeURI","isFinite","parseInt")}if(object instanceof Function){names.push("arguments","length","name","prototype","caller")}if(object===Number){names.push("NaN","NEGATIVE_INFINITY","POSITIVE_INFINITY","MAX_VALUE","MIN_VALUE")}else{if(object===Math){names.push("LN10","PI","E","LOG10E","SQRT2","LOG2E","SQRT1_2","LN2","cos","pow","log","tan","sqrt","ceil","asin","abs","max","exp","atan2","random","round","floor","acos","atan","min","sin")}else{if(object===String){names.push("fromCharCode")}else{if(object===Date){names.push("UTC","parse")}else{if(object===RegExp){names.push("$*","$3","$`","$9","rightContext","multiline","$7","lastParen","$input","$+","$&","leftContext","$8","$4","$1","$'","$_","input","lastMatch","$2","$5","$6")}else{if(object===Date.prototype){names.push("constructor","toUTCString","setMinutes","setUTCMonth","getMilliseconds","getTime","getMinutes","getUTCHours","toString","setUTCFullYear","setMonth","getUTCMinutes","getUTCDate","setSeconds","toLocaleDateString","getMonth","toTimeString","toLocaleTimeString","setUTCMilliseconds","setYear","getUTCFullYear","getFullYear","getTimezoneOffset","setDate","getUTCMonth","getHours","toLocaleString","toISOString","toDateString","getUTCSeconds","valueOf","setUTCMinutes","getUTCDay","setUTCDate","setUTCSeconds","getYear","getUTCMilliseconds","getDay","setFullYear","setMilliseconds","setTime","setHours","getSeconds","toGMTString","getDate","setUTCHours")}else{if(object===Object.prototype){names.push("toString","toLocaleString","hasOwnProperty","valueOf","constructor","propertyIsEnumerable","isPrototypeOf")}else{if(object===Number.prototype){names.push("toExponential","toString","toLocaleString","toPrecision","valueOf","constructor","toFixed")}else{if(object===RegExp.prototype){names.push("toString","constructor","exec","compile","test")}else{if(object===String.prototype){names.push("length","constructor","concat","localeCompare","substring","italics","charCodeAt","strike","indexOf","toLowerCase","toString","toLocaleLowerCase","replace","toUpperCase","fontsize","split","substr","sub","charAt","blink","lastIndexOf","sup","fontcolor","valueOf","link","bold","anchor","small","search","fixed","big","match","toLocaleUpperCase","slice")}else{if(object===Array.prototype){names.push("length","constructor","concat","sort","join","indexOf","toString","splice","shift","unshift","toLocaleString","reverse","pop","push","slice")}else{if(object===Function.prototype){names.push("toString","constructor","call","apply","arguments","length","name","prototype","caller")}else{if(object instanceof RegExp){names.push("lastIndex","multiline","global","source","ignoreCase")}else{if(Array.isArray(object)||String.isString(object)){names.push("length")}}}}}}}}}}}}}}return names.concat(Object.keys(objectDescriptorStore[Object.id(object)]||{})).unique()})}if(!Object.create){var protoStore=[];extend(Object,"create",function create(prototype,descriptors){if(prototype!==null&&Object(prototype)!==prototype){throw new TypeError("Object prototype may only be an Object or null")}var object={};if(prototype!==null){var type=function(){};type.prototype=prototype;object=new type()}if(descriptors!==undefined){Object.defineProperties(object,descriptors)}if(object.__proto__!==undefined){object.__proto__=prototype}else{protoStore[Object.id(object)]=prototype}return object})}if(!Object.defineProperty||domDefineProperty){var oldDefineProperty=Object.defineProperty,definePropertyError=function(object,name,descriptor){if(!Object.isObject(descriptor)){return"Property description must be an object: "+descriptor}if(!Object.isObject(object)){return"Object.defineProperty called on non-object"}if("get" in descriptor){if(!object.__defineGetter__){return"Getters are not supported on this javascript engine."}if(!Function.isFunction(descriptor.get)){return"Getter must be a function: "+descriptor.get}}if("set" in descriptor){if(!object.__defineSetter__){return"Setters are not supported on this javascript engine."}if(!Function.isFunction(descriptor.set)){return"Setter must be a function: "+descriptor.get}}if(("get" in descriptor||"set" in descriptor)&&("value" in descriptor||descriptor.writable)){return"A property cannot both have accessors and be writable or have a value: "+object}};extend(Object,"defineProperty",function defineProperty(object,name,descriptor){if(object.nodeType&&oldDefineProperty){oldDefineProperty(object,name,descriptor)}var id=Object.id(object),error,prototype;if((error=definePropertyError(object,name,descriptor))){throw new TypeError(error)}if(object.__defineGetter__){if((name in object)&&(object.__lookupGetter__(name))){prototype=object.__proto__;object.__proto__=Object.prototype;delete object[name]}if("get" in descriptor){object.__defineGetter__(name,descriptor.get)}if("set" in descriptor){object.__defineSetter__(name,descriptor.set)}}if(!objectDescriptorStore[id]){objectDescriptorStore[id]={}}if(!descriptor.writable){descriptor.writable=false}if(!descriptor.configurable){descriptor.configurable=false}if(!descriptor.enumerable){descriptor.enumerable=false}if(!("get" in descriptor||"set" in descriptor)){object[name]=descriptor.value}objectDescriptorStore[id][name]=descriptor;if(prototype){object.__proto__=prototype}return object})}if(!Object.defineProperties||domDefineProperty){extend(Object,"defineProperties",function defineProperties(object,descriptors){if(!Object.isObject(object)){throw new TypeError("Object.defineProperties called on non-object")}var name,error;for(name in descriptors){if(error=definePropertyError(object,name,descriptors[name])){throw new TypeError(error)}}for(name in descriptors){Object.defineProperty(object,name,descriptors[name])}return object})}if(!Object.seal){var sealedStore=[]}extend(Object,"seal",function seal(object){if(!Object.isObject(object)){throw new TypeError("Object.seal called on non-object")}sealedStore[Object.id(object)]=true;return object});if(!Object.isSealed){extend(Object,"isSealed",function isSealed(object){if(!Object.isObject(object)){throw new TypeError("Object.isSealed called on non-object")}return !!sealedStore[Object.id(object)]})}if(!Object.freeze){var frozenStore=[]}extend(Object,"freeze",function freeze(object){if(!Object.isObject(object)){throw new TypeError("Object.freeze called on non-object")}frozenStore[Object.id(object)]=true;return object});if(!Object.isFrozen){extend(Object,"isFrozen",function isFrozen(object){if(!Object.isObject(object)){throw new TypeError("Object.isFrozen called on non-object")}return !!frozenStore[Object.id(object)]})}if(!Object.preventExtensions){var preventExtensionsStore=[]}extend(Object,"preventExtensions",function preventExtensions(object){if(!Object.isObject(object)){throw new TypeError("Object.preventExtensions called on non-object")}preventExtensionsStore[Object.id(object)]=true;return object});if(!Object.isExtensible){extend(Object,"isExtensible",function isExtensible(object){if(!Object.isObject(object)){throw new TypeError("Object.isExtensible called on non-object")}var id=Object.id(object);return !preventExtensionsStore[id]&&!sealedStore[id]})}if(!Object.keys){extend(Object,"keys",function keys(object){if(object!==Object(object)){throw new TypeError("Object.keys called on non-object")}var keys=[],key;for(key in object){if(object.hasOwnProperty(key)){keys.push(key)}}keys=keys.filter(function(key){return Object.prototype.propertyIsEnumerable.call(object,key)});if(String.isString(object)&&!(0 in (new String(" ")))){keys=keys.concat(Array.range(0,object.length-1))}return keys.map(String)})}if(domDefineProperty){var oldPropertyIsEnumerable=Object.prototype.propertyIsEnumerable;Object.prototype.propertyIsEnumerable=function propertyIsEnumerable(key){var desc=objectDescriptorStore[Object.id(this)];if(desc&&desc[key]){return desc[key].enumerable===true}else{if(oldPropertyIsEnumerable){oldPropertyIsEnumerable.call(this,key)}else{for(var name in this){if(name==key){return true}}}}return true}}extend(RegExp,{escape:function escape(input){return input.replace(/([/'*+?|()\[\]{}.^$])/g,"\\$1")}});if(typeof module!=="undefined"&&module.exports){module.exports.repl=function(){var vm=require("vm"),repl=require("repl");process.stdin.removeAllListeners("keypress");var ctx=repl.start("toolkit> ").context;ctx.Array=Array;ctx.Object=Object;ctx.Number=Number;ctx.Date=Date;ctx.RegExp=RegExp;ctx.String=String;ctx.Function=Function}}extend(String,{isString:function isString(object){return typeof object==="string"||object instanceof String},UUID:function UUID(){return Array.range(0,35).map(function(i){switch(i){case 8:case 13:case 23:return"-";case 14:i=4;break;case 19:i=(Number.random(0,16).floor()&3)|8;break;default:i=Number.random(0,16).floor();break}return"0123456789ABCDEF".charAt(i)}).join("")}});extend(String.prototype,{repeat:function repeat(num){var str="";for(var i=0,str="";i<(num||1);i++){str+=this}return str},chars:function chars(){for(var i=0,arr=[];i<this.length;i++){arr.push(this.charAt(i))}return arr},count:function count(substr,mod){return this.match(RegExp(substr,mod||"gi")).length},insert:function insert(substr,pos){return this.substr(0,pos||0)+substr+this.substr(pos||0)},remove:function remove(substr,modifiers){if(!(substr instanceof RegExp)){substr=new RegExp(substr,modifiers||"gmi")}return this.replace(substr,"")},reverse:function reverse(){return this.chars().reverse().join("")},ucfirst:function ucfirst(){return this.charAt(0).toUpperCase()+this.substr(1)},swapcase:function swapcase(){return this.chars().map(function(a){return/[a-z]/.test(a)?a.toUpperCase():a.toLowerCase()}).join("")},rpad:function rpad(len,chars){len=Number(len);if(len<this.length){return this.valueOf()}for(var str=this;str.length<len;str+=(chars||" ")){}return str.substr(0,len)},lpad:function lpad(len,chars){len=Number(len);if(len<this.length){return this.valueOf()}chars=(chars||" ").reverse();for(var str=this;str.length<len;str=(chars+str)){}return str.substr(str.length-len)},pad:function pad(len,chars){return this[len>0?"rpad":"lpad"](Math.abs(len),chars)},soundex:function soundex(){return this.substr(0,1).toUpperCase()+this.toUpperCase().substr(1).remove(/[^A-Z]/gi).trim().replace(/DG/g,"G").replace(/GH/g,"H").replace(/GN|KN/g,"N").replace(/PH/g,"F").replace(/MP([STZ])/g,"M$1").replace(/^PS/g,"S").replace(/^PF/g,"F").replace(/MB/g,"M").replace(/TCH/g,"CH").replace(/[AEIOUHWY]/g,"0").replace(/[BFPV]/g,"1").replace(/[CGJKQSXZ]/g,"2").replace(/[DT]/g,"3").replace(/[L]/g,"4").replace(/[MN]/g,"5").replace(/[R]/g,"6").replace(/(\w)\1+/g,"$1").slice(0,3).rpad(3,"0")},distance:function distance(c){var s,l=(s=this.split("")).length,t=(c=c.split("")).length,i,j,m,n;if(!(l||t)){return Math.max(l,t)}for(var a=[],i=l+1;i;a[--i]=[i]){}for(i=t+1;a[0][--i]=i;){}for(i=-1,m=s.length;++i<m;){for(j=-1,n=c.length;++j<n;){a[(i*=1)+1][(j*=1)+1]=Math.min(a[i][j+1]+1,a[i+1][j]+1,a[i][j]+(s[i]!=c[j]))}}return a[l][t]},soundex:function soundex(){return this.substr(0,1).toUpperCase()+this.toUpperCase().substr(1).remove(/[^A-Z]/gi).trim().replace(/DG/g,"G").replace(/GH/g,"H").replace(/GN|KN/g,"N").replace(/PH/g,"F").replace(/MP([STZ])/g,"M$1").replace(/^PS/g,"S").replace(/^PF/g,"F").replace(/MB/g,"M").replace(/TCH/g,"CH").replace(/[AEIOUHWY]/g,"0").replace(/[BFPV]/g,"1").replace(/[CGJKQSXZ]/g,"2").replace(/[DT]/g,"3").replace(/[L]/g,"4").replace(/[MN]/g,"5").replace(/[R]/g,"6").replace(/(\w)\1+/g,"$1").rpad(3,"0")},chunk:function chunk(len){return this.chars().chunk(len).map(function(chars){return chars.join("")})},btoa:function btoa(){var key="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",output="",input=this.valueOf();for(i=0;i<input.length;i+=3){var c1=input.charCodeAt(i),c2=input.charCodeAt(i+1),c3=input.charCodeAt(i+2);var e1=c1>>2,e2=((c1&3)<<4)|(c2>>4),e3=((c2&15)<<2)|(c3>>6),e4=c3&63;if(isNaN(c1)){e3=e4=64}else{if(isNaN(c3)){e4=64}}output+=key.charAt(e1)+key.charAt(e2)+key.charAt(e3)+key.charAt(e4)}return output},atob:function atob(){var key="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",output="",input=this;return input.split("\n").map(function(line){var output="";for(i=0;i<line.length;i+=4){var e1=key.indexOf(line.charAt(i)),e2=key.indexOf(line.charAt(i+1)),e3=key.indexOf(line.charAt(i+2)),e4=key.indexOf(line.charAt(i+3));var c1=(e1<<2)|(e2>>4),c2=((e2&15)<<4)|(e3>>2),c3=((e3&3)<<6)|e4;output+=String.fromCharCode(c1);if(e3!=64){output+=String.fromCharCode(c2)}if(e4!=64){output+=String.fromCharCode(c3)}}return output}).join("")},sprintf:function sprintf(c){var vals=arguments,regex=/%%|%(?:(\d+)[\$#])?([+-])?('.|0| )?(\d*)(?:\.(\d+))?([bcdfosuxX])/g;var index=0;return this.replace(regex,function(substr,flags,align,padding,width,precision,type){if(substr=="%%"){return"%"}flags=flags||"",align=align||"",padding=(padding||"").slice(-1)||" ",width=width||"",precision=precision||"";val=vals[+flags?flags-1:index];index++;if(type.match(/[duobxXf]{1}/)){val=Number(val)}else{val=String(val)}switch(type){case"d":case"u":return val.dec(align+width,padding);case"o":return val.oct(align+width,padding);case"b":return val.bin(align+width,padding);case"x":return val.hexl(align+width,padding);case"X":return val.hex(align+width,padding);case"s":return val.pad(align+width,padding);case"c":return String.fromCharCode(val).pad(align+width,padding);case"f":if(precision){val=val.toFixed(precision)}else{if(width){val=val.toExponential(width)}else{val=val.toExponential()}}align=align=="-"?"+":"-";return val.toString().pad(align+width,padding)}})}});if(!String.prototype.trim){extend(String.prototype,"trim",function trim(){return this.trimRight().trimLeft()})}if(!String.prototype.trimRight){extend(String.prototype,"trimRight",function trimRight(){return this.remove(/^\s\s*/)})}if(!String.prototype.trimLeft){extend(String.prototype,"trimLeft",function trimLeft(){return this.remove(/\s\s*$/)})}})();
