made with requirebin
Created
October 7, 2014 03:17
-
-
Save JaapRood/31e91cd9e766652322c3 to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Immutable = require('immutable'), | |
_ = require('lodash'), | |
IMap = Immutable.Map, | |
IVector = Immutable.Vector; | |
var messagesData = [ | |
{ | |
id: 'm_1', | |
threadID: 't_1', | |
threadName: 'Jing and Bill', | |
authorName: 'Bill', | |
text: 'Hey Jing, want to give a Flux talk at ForwardJS?', | |
date: new Date(Date.now() - 99999) | |
}, | |
{ | |
id: 'm_2', | |
threadID: 't_1', | |
threadName: 'Jing and Bill', | |
authorName: 'Bill', | |
text: 'Seems like a pretty cool conference.', | |
date: new Date(Date.now() - 89999) | |
} | |
]; | |
var newMessageData = { | |
id: 'm_3', | |
threadID: 't_1', | |
threadName: 'Jing and Bill', | |
authorName: 'Bill', | |
text: 'Ohnoes, this might go wrong', | |
date: new Date(Date.now() - 39999) | |
}; | |
var messages = IMap(); | |
var messagesSortedByDate = IVector(); | |
var currentThreadID = 't_1'; | |
// state 1 | |
addMessages(messagesData); | |
var oldMessages = messages; | |
var oldMessagesSortedByDate = messagesSortedByDate; | |
var oldMessagesByThread = getMessagesForThread(currentThreadID); | |
// state 2 | |
addMessages([newMessageData]); | |
var newMessagesByThread = getMessagesForThread(currentThreadID); | |
console.log(oldMessagesByThread.count(), oldMessagesByThread, newMessagesByThread); | |
console.assert(Immutable.is(oldMessagesByThread, newMessagesByThread) === false, "shouldn't be equal"); | |
function addMessages(rawMessages) { | |
var messageIds = _.pluck(rawMessages, 'id'); | |
var newMessages = IMap.from(_.zip( | |
messageIds, | |
_.map(rawMessages, function(message) { | |
return IMap.from(message); | |
}) | |
)); | |
messages = messages.merge(newMessages); | |
messagesSortedByDate = IVector.from(messages.keySeq()) | |
.sort(function(a, b) { | |
var dateA = messages.getIn([a, 'date']), | |
dateB = messages.getIn([b, 'date']); | |
if (dateA < dateB) { | |
return -1; | |
} else if (dateA > dateB) { | |
return 1; | |
} else { | |
return 0; | |
} | |
}); | |
} | |
function getMessagesForThread(threadID) { | |
return messagesSortedByDate | |
.map(function(messageId) { | |
return messages.get(messageId); | |
}) | |
.filter(function(message) { | |
return message.get('threadID') === threadID; | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({immutable:[function(require,module,exports){function universalModule(){var $Object=Object;function createClass(ctor,methods,staticMethods,superClass){var proto;if(superClass){var superProto=superClass.prototype;proto=$Object.create(superProto)}else{proto=ctor.prototype}$Object.keys(methods).forEach(function(key){proto[key]=methods[key]});$Object.keys(staticMethods).forEach(function(key){ctor[key]=staticMethods[key]});proto.constructor=ctor;ctor.prototype=proto;return ctor}function superCall(self,proto,name,args){return $Object.getPrototypeOf(proto)[name].apply(self,args)}function defaultSuperCall(self,proto,args){superCall(self,proto,"constructor",args)}var $traceurRuntime={};$traceurRuntime.createClass=createClass;$traceurRuntime.superCall=superCall;$traceurRuntime.defaultSuperCall=defaultSuperCall;"use strict";var SHIFT=5;var SIZE=1<<SHIFT;var MASK=SIZE-1;var NOT_SET={};var CHANGE_LENGTH={value:false};var DID_ALTER={value:false};function MakeRef(ref){ref.value=false;return ref}function SetRef(ref){ref&&(ref.value=true)}function OwnerID(){}function arrCopy(arr,offset){offset=offset||0;var len=Math.max(0,arr.length-offset);var newArr=new Array(len);for(var ii=0;ii<len;ii++){newArr[ii]=arr[ii+offset]}return newArr}var ITER_RESULT={value:undefined,done:false};function iteratorValue(value){ITER_RESULT.value=value;ITER_RESULT.done=false;return ITER_RESULT}function iteratorDone(){ITER_RESULT.value=undefined;ITER_RESULT.done=true;return ITER_RESULT}function invariant(condition,error){if(!condition)throw new Error(error)}var DELETE="delete";var ITERATOR=typeof Symbol!=="undefined"?Symbol.iterator:"@@iterator";function hash(o){if(!o){return 0}if(o===true){return 1}var type=typeof o;if(type==="number"){if((o|0)===o){return o&HASH_MAX_VAL}o=""+o;type="string"}if(type==="string"){return o.length>STRING_HASH_CACHE_MIN_STRLEN?cachedHashString(o):hashString(o)}if(o.hashCode){return hash(typeof o.hashCode==="function"?o.hashCode():o.hashCode)}return hashJSObj(o)}function cachedHashString(string){var hash=STRING_HASH_CACHE[string];if(hash==null){hash=hashString(string);if(STRING_HASH_CACHE_SIZE===STRING_HASH_CACHE_MAX_SIZE){STRING_HASH_CACHE_SIZE=0;STRING_HASH_CACHE={}}STRING_HASH_CACHE_SIZE++;STRING_HASH_CACHE[string]=hash}return hash}function hashString(string){var hash=0;for(var ii=0;ii<string.length;ii++){hash=31*hash+string.charCodeAt(ii)&HASH_MAX_VAL}return hash}function hashJSObj(obj){if(obj[UID_HASH_KEY]){return obj[UID_HASH_KEY]}var uid=++UID_HASH_COUNT&HASH_MAX_VAL;if(!isIE8){try{Object.defineProperty(obj,UID_HASH_KEY,{enumerable:false,configurable:false,writable:false,value:uid});return uid}catch(e){isIE8=true}}obj[UID_HASH_KEY]=uid;return uid}var HASH_MAX_VAL=2147483647;var UID_HASH_COUNT=0;var UID_HASH_KEY="__immutablehash__";if(typeof Symbol!=="undefined"){UID_HASH_KEY=Symbol(UID_HASH_KEY)}var isIE8=false;var STRING_HASH_CACHE_MIN_STRLEN=16;var STRING_HASH_CACHE_MAX_SIZE=255;var STRING_HASH_CACHE_SIZE=0;var STRING_HASH_CACHE={};var Sequence=function Sequence(value){return $Sequence.from(arguments.length===1?value:Array.prototype.slice.call(arguments))};var $Sequence=Sequence;$traceurRuntime.createClass(Sequence,{toString:function(){return this.__toString("Seq {","}")},__toString:function(head,tail){if(this.length===0){return head+tail}return head+" "+this.map(this.__toStringMapper).join(", ")+" "+tail},__toStringMapper:function(v,k){return k+": "+quoteString(v)},toJS:function(){return this.map(function(value){return value instanceof $Sequence?value.toJS():value}).__toJS()},toArray:function(){assertNotInfinite(this.length);var array=new Array(this.length||0);this.valueSeq().forEach(function(v,i){array[i]=v});return array},toObject:function(){assertNotInfinite(this.length);var object={};this.forEach(function(v,k){object[k]=v});return object},toVector:function(){assertNotInfinite(this.length);return Vector.from(this)},toMap:function(){assertNotInfinite(this.length);return Map.from(this)},toOrderedMap:function(){assertNotInfinite(this.length);return OrderedMap.from(this)},toSet:function(){assertNotInfinite(this.length);return Set.from(this)},hashCode:function(){return this.__hash||(this.__hash=this.length===Infinity?0:this.reduce(function(h,v,k){return h+(hash(v)^(v===k?0:hash(k)))&HASH_MAX_VAL},0))},equals:function(other){if(this===other){return true}if(!(other instanceof $Sequence)){return false}if(this.length!=null&&other.length!=null){if(this.length!==other.length){return false}if(this.length===0&&other.length===0){return true}}if(this.__hash!=null&&other.__hash!=null&&this.__hash!==other.__hash){return false}return this.__deepEquals(other)},__deepEquals:function(other){var entries=this.cacheResult().entrySeq().toArray();var iterations=0;return other.every(function(v,k){var entry=entries[iterations++];return is(k,entry[0])&&is(v,entry[1])})},join:function(separator){separator=separator!==undefined?""+separator:",";var string="";var isFirst=true;this.forEach(function(v,k){if(isFirst){isFirst=false;string+=v!=null?v:""}else{string+=separator+(v!=null?v:"")}});return string},count:function(predicate,thisArg){if(!predicate){if(this.length==null){this.length=this.forEach(returnTrue)}return this.length}return this.filter(predicate,thisArg).count()},countBy:function(mapper,context){var seq=this;return OrderedMap.empty().withMutations(function(map){seq.forEach(function(value,key,collection){map.update(mapper(value,key,collection),increment)})})},concat:function(){for(var values=[],$__2=0;$__2<arguments.length;$__2++)values[$__2]=arguments[$__2];var sequences=[this].concat(values.map(function(value){return $Sequence(value)}));var concatSequence=this.__makeSequence();concatSequence.length=sequences.reduce(function(sum,seq){return sum!=null&&seq.length!=null?sum+seq.length:undefined},0);concatSequence.__iterateUncached=function(fn,reverse){var iterations=0;var stoppedIteration;var lastIndex=sequences.length-1;for(var ii=0;ii<=lastIndex&&!stoppedIteration;ii++){var seq=sequences[reverse?lastIndex-ii:ii];iterations+=seq.__iterate(function(v,k,c){if(fn(v,k,c)===false){stoppedIteration=true;return false}},reverse)}return iterations};return concatSequence},reverse:function(){var sequence=this;var reversedSequence=sequence.__makeSequence();reversedSequence.length=sequence.length;reversedSequence.__iterateUncached=function(fn,reverse){return sequence.__iterate(fn,!reverse)};reversedSequence.reverse=function(){return sequence};return reversedSequence},keySeq:function(){return this.flip().valueSeq()},valueSeq:function(){var sequence=this;var valuesSequence=makeIndexedSequence(sequence);valuesSequence.length=sequence.length;valuesSequence.valueSeq=returnThis;valuesSequence.__iterateUncached=function(fn,reverse,flipIndices){if(flipIndices&&this.length==null){return this.cacheResult().__iterate(fn,reverse,flipIndices)}var iterations=0;var predicate;if(flipIndices){iterations=this.length-1;predicate=function(v,k,c){return fn(v,iterations--,c)!==false}}else{predicate=function(v,k,c){return fn(v,iterations++,c)!==false}}sequence.__iterate(predicate,reverse);return flipIndices?this.length:iterations};return valuesSequence},entrySeq:function(){var sequence=this;if(sequence._cache){return $Sequence(sequence._cache)}var entriesSequence=sequence.map(entryMapper).valueSeq();entriesSequence.fromEntries=function(){return sequence};return entriesSequence},forEach:function(sideEffect,thisArg){return this.__iterate(thisArg?sideEffect.bind(thisArg):sideEffect)},reduce:function(reducer,initialReduction,thisArg){var reduction;var useFirst;if(arguments.length<2){useFirst=true}else{reduction=initialReduction}this.forEach(function(v,k,c){if(useFirst){useFirst=false;reduction=v}else{reduction=reducer.call(thisArg,reduction,v,k,c)}});return reduction},reduceRight:function(reducer,initialReduction,thisArg){var reversed=this.reverse(true);return reversed.reduce.apply(reversed,arguments)},every:function(predicate,thisArg){var returnValue=true;this.forEach(function(v,k,c){if(!predicate.call(thisArg,v,k,c)){returnValue=false;return false}});return returnValue},some:function(predicate,thisArg){return!this.every(not(predicate),thisArg)},first:function(){return this.find(returnTrue)},last:function(){return this.findLast(returnTrue)},rest:function(){return this.slice(1)},butLast:function(){return this.slice(0,-1)},has:function(searchKey){return this.get(searchKey,NOT_SET)!==NOT_SET},get:function(searchKey,notSetValue){return this.find(function(_,key){return is(key,searchKey)},null,notSetValue)},getIn:function(searchKeyPath,notSetValue){if(!searchKeyPath||searchKeyPath.length===0){return this}return getInDeepSequence(this,searchKeyPath,notSetValue,0)},contains:function(searchValue){return this.find(function(value){return is(value,searchValue)},null,NOT_SET)!==NOT_SET},find:function(predicate,thisArg,notSetValue){var foundValue=notSetValue;this.forEach(function(v,k,c){if(predicate.call(thisArg,v,k,c)){foundValue=v;return false}});return foundValue},findKey:function(predicate,thisArg){var foundKey;this.forEach(function(v,k,c){if(predicate.call(thisArg,v,k,c)){foundKey=k;return false}});return foundKey},findLast:function(predicate,thisArg,notSetValue){return this.reverse(true).find(predicate,thisArg,notSetValue)},findLastKey:function(predicate,thisArg){return this.reverse(true).findKey(predicate,thisArg)},flip:function(){var sequence=this;var flipSequence=makeSequence();flipSequence.length=sequence.length;flipSequence.flip=function(){return sequence};flipSequence.__iterateUncached=function(fn,reverse){var $__0=this;return sequence.__iterate(function(v,k){return fn(k,v,$__0)!==false},reverse)};return flipSequence},map:function(mapper,thisArg){var sequence=this;var mappedSequence=sequence.__makeSequence();mappedSequence.length=sequence.length;mappedSequence.__iterateUncached=function(fn,reverse){var $__0=this;return sequence.__iterate(function(v,k,c){return fn(mapper.call(thisArg,v,k,c),k,$__0)!==false},reverse)};return mappedSequence},mapKeys:function(mapper,thisArg){var sequence=this;var mappedSequence=sequence.__makeSequence();mappedSequence.length=sequence.length;mappedSequence.__iterateUncached=function(fn,reverse){var $__0=this;return sequence.__iterate(function(v,k,c){return fn(v,mapper.call(thisArg,k,v,c),$__0)!==false},reverse)};return mappedSequence},filter:function(predicate,thisArg){return filterFactory(this,predicate,thisArg,true,false)},slice:function(begin,end){if(wholeSlice(begin,end,this.length)){return this}var resolvedBegin=resolveBegin(begin,this.length);var resolvedEnd=resolveEnd(end,this.length);if(resolvedBegin!==resolvedBegin||resolvedEnd!==resolvedEnd){return this.entrySeq().slice(begin,end).fromEntrySeq()}var skipped=resolvedBegin===0?this:this.skip(resolvedBegin);return resolvedEnd==null||resolvedEnd===this.length?skipped:skipped.take(resolvedEnd-resolvedBegin)},take:function(amount){var sequence=this;if(amount>sequence.length){return sequence}var takeSequence=sequence.__makeSequence();takeSequence.__iterateUncached=function(fn,reverse,flipIndices){var $__0=this;if(reverse){return this.cacheResult().__iterate(fn,reverse,flipIndices)}var iterations=0;sequence.__iterate(function(v,k){if(iterations<amount&&fn(v,k,$__0)!==false){iterations++}else{return false}},reverse,flipIndices);return iterations};takeSequence.length=this.length&&Math.min(this.length,amount);return takeSequence},takeLast:function(amount,maintainIndices){return this.reverse(maintainIndices).take(amount).reverse(maintainIndices)},takeWhile:function(predicate,thisArg){var sequence=this;var takeSequence=sequence.__makeSequence();takeSequence.__iterateUncached=function(fn,reverse,flipIndices){var $__0=this;if(reverse){return this.cacheResult().__iterate(fn,reverse,flipIndices)}var iterations=0;sequence.__iterate(function(v,k,c){if(predicate.call(thisArg,v,k,c)&&fn(v,k,$__0)!==false){iterations++}else{return false}},reverse,flipIndices);return iterations};return takeSequence},takeUntil:function(predicate,thisArg,maintainIndices){return this.takeWhile(not(predicate),thisArg,maintainIndices)},skip:function(amount,maintainIndices){var sequence=this;if(amount===0){return sequence}var skipSequence=sequence.__makeSequence();skipSequence.__iterateUncached=function(fn,reverse,flipIndices){var $__0=this;if(reverse){return this.cacheResult().__iterate(fn,reverse,flipIndices)}var isSkipping=true;var iterations=0;var skipped=0;sequence.__iterate(function(v,k){if(!(isSkipping&&(isSkipping=skipped++<amount))){if(fn(v,k,$__0)!==false){iterations++}else{return false}}},reverse,flipIndices);return iterations};skipSequence.length=this.length&&Math.max(0,this.length-amount);return skipSequence},skipLast:function(amount,maintainIndices){return this.reverse(maintainIndices).skip(amount).reverse(maintainIndices)},skipWhile:function(predicate,thisArg,maintainIndices){var sequence=this;var skipSequence=sequence.__makeSequence();skipSequence.__iterateUncached=function(fn,reverse,flipIndices){var $__0=this;if(reverse){return this.cacheResult().__iterate(fn,reverse,flipIndices)}var isSkipping=true;var iterations=0;sequence.__iterate(function(v,k,c){if(!(isSkipping&&(isSkipping=predicate.call(thisArg,v,k,c)))){if(fn(v,k,$__0)!==false){iterations++}else{return false}}},reverse,flipIndices);return iterations};return skipSequence},skipUntil:function(predicate,thisArg,maintainIndices){return this.skipWhile(not(predicate),thisArg,maintainIndices)},groupBy:function(mapper,context){var seq=this;var groups=OrderedMap.empty().withMutations(function(map){seq.forEach(function(value,key,collection){var groupKey=mapper(value,key,collection);var group=map.get(groupKey,NOT_SET);if(group===NOT_SET){group=[];map.set(groupKey,group)}group.push([key,value])})});return groups.map(function(group){return $Sequence(group).fromEntrySeq()})},sort:function(comparator,maintainIndices){return this.sortBy(valueMapper,comparator,maintainIndices)},sortBy:function(mapper,comparator,maintainIndices){comparator=comparator||defaultComparator;var seq=this;return $Sequence(this.entrySeq().entrySeq().toArray().sort(function(indexedEntryA,indexedEntryB){return comparator(mapper(indexedEntryA[1][1],indexedEntryA[1][0],seq),mapper(indexedEntryB[1][1],indexedEntryB[1][0],seq))||indexedEntryA[0]-indexedEntryB[0]})).fromEntrySeq().valueSeq().fromEntrySeq()},cacheResult:function(){if(!this._cache&&this.__iterateUncached){assertNotInfinite(this.length);this._cache=this.entrySeq().toArray();if(this.length==null){this.length=this._cache.length}}return this},__iterate:function(fn,reverse,flipIndices){if(!this._cache){return this.__iterateUncached(fn,reverse,flipIndices)}var maxIndex=this.length-1;var cache=this._cache;var c=this;if(reverse){for(var ii=cache.length-1;ii>=0;ii--){var revEntry=cache[ii];if(fn(revEntry[1],flipIndices?revEntry[0]:maxIndex-revEntry[0],c)===false){break}}}else{cache.every(flipIndices?function(entry){return fn(entry[1],maxIndex-entry[0],c)!==false}:function(entry){return fn(entry[1],entry[0],c)!==false})}return this.length},__makeSequence:function(){return makeSequence()}},{from:function(value){if(value instanceof $Sequence){return value}if(!Array.isArray(value)){if(value&&value.constructor===Object){return new ObjectSequence(value)}value=[value]}return new ArraySequence(value)}});var SequencePrototype=Sequence.prototype;SequencePrototype.toJSON=SequencePrototype.toJS;SequencePrototype.__toJS=SequencePrototype.toObject;SequencePrototype.inspect=SequencePrototype.toSource=function(){return this.toString()};var IndexedSequence=function IndexedSequence(){$traceurRuntime.defaultSuperCall(this,$IndexedSequence.prototype,arguments)};var $IndexedSequence=IndexedSequence;$traceurRuntime.createClass(IndexedSequence,{toString:function(){return this.__toString("Seq [","]")},toArray:function(){assertNotInfinite(this.length);var array=new Array(this.length||0);array.length=this.forEach(function(v,i){array[i]=v});return array},fromEntrySeq:function(){var sequence=this;var fromEntriesSequence=makeSequence();fromEntriesSequence.length=sequence.length;fromEntriesSequence.entrySeq=function(){return sequence};fromEntriesSequence.__iterateUncached=function(fn,reverse,flipIndices){var $__0=this;return sequence.__iterate(function(entry){return entry&&fn(entry[1],entry[0],$__0)},reverse,flipIndices)};return fromEntriesSequence},join:function(separator){separator=separator!==undefined?""+separator:",";var joined="";this.forEach(function(v,ii){joined+=(ii?separator:"")+(v!=null?v:"")});return joined},concat:function(){for(var values=[],$__3=0;$__3<arguments.length;$__3++)values[$__3]=arguments[$__3];var sequences=[this].concat(values).map(function(value){return Sequence(value)});var concatSequence=this.__makeSequence();concatSequence.length=sequences.reduce(function(sum,seq){return sum!=null&&seq.length!=null?sum+seq.length:undefined},0);concatSequence.__iterateUncached=function(fn,reverse,flipIndices){var $__0=this;if(flipIndices&&!this.length){return this.cacheResult().__iterate(fn,reverse,flipIndices)}var iterations=0;var stoppedIteration;var maxIndex=flipIndices&&this.length-1;var maxSequencesIndex=sequences.length-1;for(var ii=0;ii<=maxSequencesIndex&&!stoppedIteration;ii++){var sequence=sequences[reverse?maxSequencesIndex-ii:ii];if(!(sequence instanceof $IndexedSequence)){sequence=sequence.valueSeq()}iterations+=sequence.__iterate(function(v,index){index+=iterations;if(fn(v,flipIndices?maxIndex-index:index,$__0)===false){stoppedIteration=true;return false}},reverse)}return iterations};return concatSequence},reverse:function(maintainIndices){var sequence=this;var reversedSequence=sequence.__makeSequence();reversedSequence.length=sequence.length;reversedSequence.__reversedIndices=!!(maintainIndices^sequence.__reversedIndices);reversedSequence.__iterateUncached=function(fn,reverse,flipIndices){return sequence.__iterate(fn,!reverse,flipIndices^maintainIndices)};reversedSequence.reverse=function(_maintainIndices){return maintainIndices===_maintainIndices?sequence:IndexedSequencePrototype.reverse.call(this,_maintainIndices)};return reversedSequence},filter:function(predicate,thisArg,maintainIndices){var filterSequence=filterFactory(this,predicate,thisArg,maintainIndices,maintainIndices);if(maintainIndices){filterSequence.length=this.length}return filterSequence},get:function(index,notSetValue){index=wrapIndex(this,index);return this.find(function(_,key){return key===index},null,notSetValue)},indexOf:function(searchValue){return this.findIndex(function(value){return is(value,searchValue)})},lastIndexOf:function(searchValue){return this.reverse(true).indexOf(searchValue)},findIndex:function(predicate,thisArg){var key=this.findKey(predicate,thisArg);return key==null?-1:key},findLastIndex:function(predicate,thisArg){return this.reverse(true).findIndex(predicate,thisArg)},slice:function(begin,end,maintainIndices){var sequence=this;if(wholeSlice(begin,end,sequence.length)){return sequence}var sliceSequence=sequence.__makeSequence();var resolvedBegin=resolveBegin(begin,sequence.length);var resolvedEnd=resolveEnd(end,sequence.length);sliceSequence.length=sequence.length&&(maintainIndices?sequence.length:resolvedEnd-resolvedBegin);sliceSequence.__reversedIndices=sequence.__reversedIndices;sliceSequence.__iterateUncached=function(fn,reverse,flipIndices){var $__0=this;if(reverse){return this.cacheResult().__iterate(fn,reverse,flipIndices)}var reversedIndices=this.__reversedIndices^flipIndices;if(resolvedBegin!==resolvedBegin||resolvedEnd!==resolvedEnd||reversedIndices&&sequence.length==null){var exactLength=sequence.count();resolvedBegin=resolveBegin(begin,exactLength);resolvedEnd=resolveEnd(end,exactLength)}var iiBegin=reversedIndices?sequence.length-resolvedEnd:resolvedBegin;var iiEnd=reversedIndices?sequence.length-resolvedBegin:resolvedEnd;var lengthIterated=sequence.__iterate(function(v,ii){return reversedIndices?iiEnd!=null&&ii>=iiEnd||ii>=iiBegin&&fn(v,maintainIndices?ii:ii-iiBegin,$__0)!==false:ii<iiBegin||(iiEnd==null||ii<iiEnd)&&fn(v,maintainIndices?ii:ii-iiBegin,$__0)!==false},reverse,flipIndices);return this.length!=null?this.length:maintainIndices?lengthIterated:Math.max(0,lengthIterated-iiBegin)};return sliceSequence},splice:function(index,removeNum){var numArgs=arguments.length;removeNum=Math.max(removeNum|0,0);if(numArgs===0||numArgs===2&&!removeNum){return this}index=resolveBegin(index,this.length);var spliced=this.slice(0,index);return numArgs===1?spliced:spliced.concat(arrCopy(arguments,2),this.slice(index+removeNum))},flatten:function(){var sequence=this;var flatSequence=sequence.__makeSequence();flatSequence.__iterateUncached=function(fn,reverse,flipIndices){var $__0=this;if(flipIndices){return this.cacheResult().__iterate(fn,reverse,flipIndices)}var index=0;sequence.__iterate(function(seq){index+=Sequence(seq).__iterate(function(v,i){return fn(v,index+i,$__0)!==false},reverse,flipIndices)},reverse,flipIndices);return index};return flatSequence},flatMap:function(mapper,thisArg){return this.map(mapper,thisArg).flatten()},skip:function(amount,maintainIndices){var sequence=this;if(amount===0){return sequence}var skipSequence=sequence.__makeSequence();if(maintainIndices){skipSequence.length=this.length}skipSequence.__iterateUncached=function(fn,reverse,flipIndices){var $__0=this;if(reverse){return this.cacheResult().__iterate(fn,reverse,flipIndices)}var reversedIndices=sequence.__reversedIndices^flipIndices;var isSkipping=true;var indexOffset=0;var skipped=0;var length=sequence.__iterate(function(v,ii){if(isSkipping){isSkipping=skipped++<amount;if(!isSkipping){indexOffset=ii}}return isSkipping||fn(v,flipIndices||maintainIndices?ii:ii-indexOffset,$__0)!==false},reverse,flipIndices);return maintainIndices?length:reversedIndices?indexOffset+1:length-indexOffset};skipSequence.length=this.length&&Math.max(0,this.length-amount);return skipSequence},skipWhile:function(predicate,thisArg,maintainIndices){var sequence=this;var skipWhileSequence=sequence.__makeSequence();if(maintainIndices){skipWhileSequence.length=this.length}skipWhileSequence.__iterateUncached=function(fn,reverse,flipIndices){var $__0=this;if(reverse){return this.cacheResult().__iterate(fn,reverse,flipIndices)}var reversedIndices=sequence.__reversedIndices^flipIndices;var isSkipping=true;var indexOffset=0;var length=sequence.__iterate(function(v,ii,c){if(isSkipping){isSkipping=predicate.call(thisArg,v,ii,c);if(!isSkipping){indexOffset=ii}}return isSkipping||fn(v,flipIndices||maintainIndices?ii:ii-indexOffset,$__0)!==false},reverse,flipIndices);return maintainIndices?length:reversedIndices?indexOffset+1:length-indexOffset};return skipWhileSequence},groupBy:function(mapper,context,maintainIndices){var seq=this;var groups=OrderedMap.empty().withMutations(function(map){seq.forEach(function(value,index,collection){var groupKey=mapper(value,index,collection);var group=map.get(groupKey,NOT_SET);if(group===NOT_SET){group=new Array(maintainIndices?seq.length:0);map.set(groupKey,group)}maintainIndices?group[index]=value:group.push(value)})});return groups.map(function(group){return Sequence(group)})},sortBy:function(mapper,comparator,maintainIndices){var sortedSeq=$traceurRuntime.superCall(this,$IndexedSequence.prototype,"sortBy",[mapper,comparator]);if(!maintainIndices){sortedSeq=sortedSeq.valueSeq()}sortedSeq.length=this.length;return sortedSeq},__makeSequence:function(){return makeIndexedSequence(this)}},{},Sequence);var IndexedSequencePrototype=IndexedSequence.prototype;IndexedSequencePrototype.__toJS=IndexedSequencePrototype.toArray;IndexedSequencePrototype.__toStringMapper=quoteString;IndexedSequencePrototype.chain=IndexedSequencePrototype.flatMap;var ObjectSequence=function ObjectSequence(object){var keys=Object.keys(object);this._object=object;this._keys=keys;this.length=keys.length};$traceurRuntime.createClass(ObjectSequence,{toObject:function(){return this._object},get:function(key,notSetValue){if(notSetValue!==undefined&&!this.has(key)){return notSetValue}return this._object[key]},has:function(key){return this._object.hasOwnProperty(key)},__iterate:function(fn,reverse){var object=this._object;var keys=this._keys;var maxIndex=keys.length-1;for(var ii=0;ii<=maxIndex;ii++){var iteration=reverse?maxIndex-ii:ii;if(fn(object[keys[iteration]],keys[iteration],object)===false){break}}return ii}},{},Sequence);var ArraySequence=function ArraySequence(array){this._array=array;this.length=array.length};$traceurRuntime.createClass(ArraySequence,{toArray:function(){return this._array},get:function(index,notSetValue){return this.has(index)?this._array[wrapIndex(this,index)]:notSetValue},has:function(index){index=wrapIndex(this,index);return index>=0&&index<this.length},__iterate:function(fn,reverse,flipIndices){var array=this._array;var maxIndex=array.length-1;var ii,rr;var reversedIndices=reverse^flipIndices;for(ii=0;ii<=maxIndex;ii++){rr=maxIndex-ii;if(fn(array[reverse?rr:ii],flipIndices?rr:ii,array)===false){return reversedIndices?reverse?rr:ii:array.length}}return array.length}},{},IndexedSequence);var SequenceIterator=function SequenceIterator(){};$traceurRuntime.createClass(SequenceIterator,{toString:function(){return"[Iterator]"}},{});var SequenceIteratorPrototype=SequenceIterator.prototype;SequenceIteratorPrototype[ITERATOR]=returnThis;SequenceIteratorPrototype.inspect=SequenceIteratorPrototype.toSource=function(){return this.toString()};function makeSequence(){return Object.create(SequencePrototype)}function makeIndexedSequence(parent){var newSequence=Object.create(IndexedSequencePrototype);newSequence.__reversedIndices=parent?parent.__reversedIndices:false;return newSequence}function getInDeepSequence(seq,keyPath,notSetValue,pathOffset){var nested=seq.get?seq.get(keyPath[pathOffset],NOT_SET):NOT_SET;if(nested===NOT_SET){return notSetValue}if(++pathOffset===keyPath.length){return nested}return getInDeepSequence(nested,keyPath,notSetValue,pathOffset)}function wholeSlice(begin,end,length){return(begin===0||length!=null&&begin<=-length)&&(end==null||length!=null&&end>=length)}function resolveBegin(begin,length){return resolveIndex(begin,length,0)}function resolveEnd(end,length){return resolveIndex(end,length,length)}function resolveIndex(index,length,defaultIndex){return index==null?defaultIndex:index<0?Math.max(0,length+index):length?Math.min(length,index):index}function valueMapper(v){return v}function entryMapper(v,k){return[k,v]}function returnTrue(){return true}function returnThis(){return this}function increment(value){return(value||0)+1}function filterFactory(sequence,predicate,thisArg,useKeys,maintainIndices){var filterSequence=sequence.__makeSequence();filterSequence.__iterateUncached=function(fn,reverse,flipIndices){var $__0=this;var iterations=0;var length=sequence.__iterate(function(v,k,c){if(predicate.call(thisArg,v,k,c)){if(fn(v,useKeys?k:iterations,$__0)!==false){iterations++}else{return false}}},reverse,flipIndices);return maintainIndices?length:iterations};return filterSequence}function not(predicate){return function(){return!predicate.apply(this,arguments)}}function quoteString(value){return typeof value==="string"?JSON.stringify(value):value}function defaultComparator(a,b){return a>b?1:a<b?-1:0}function wrapIndex(seq,index){if(index<0){if(seq.length==null){seq.cacheResult()}return seq.length+index}return index}function assertNotInfinite(length){invariant(length!==Infinity,"Cannot perform this action with an infinite sequence.")}function iteratorMapper(iter,fn){var newIter=new SequenceIterator;newIter.next=function(){var step=iter.next();if(step.done)return step;step.value=fn(step.value);return step};return newIter}var Cursor=function Cursor(rootData,keyPath,onChange,value){value=value?value:rootData.getIn(keyPath);this.length=value instanceof Sequence?value.length:null;this._rootData=rootData;this._keyPath=keyPath;this._onChange=onChange};$traceurRuntime.createClass(Cursor,{deref:function(notSetValue){return this._rootData.getIn(this._keyPath,notSetValue)},get:function(key,notSetValue){if(Array.isArray(key)&&key.length===0){return this}var value=this._rootData.getIn(this._keyPath.concat(key),NOT_SET);return value===NOT_SET?notSetValue:wrappedValue(this,key,value)},set:function(key,value){return updateCursor(this,function(m){return m.set(key,value)},key)},remove:function(key){return updateCursor(this,function(m){return m.remove(key)},key)},clear:function(){return updateCursor(this,function(m){return m.clear()})},update:function(keyOrFn,notSetValue,updater){return arguments.length===1?updateCursor(this,keyOrFn):updateCursor(this,function(map){return map.update(keyOrFn,notSetValue,updater)},keyOrFn)},withMutations:function(fn){return updateCursor(this,function(m){return(m||Map.empty()).withMutations(fn)})},cursor:function(subKey){return Array.isArray(subKey)&&subKey.length===0?this:subCursor(this,subKey)},__iterate:function(fn,reverse,flipIndices){var cursor=this;var deref=cursor.deref();return deref&&deref.__iterate?deref.__iterate(function(value,key,collection){return fn(wrappedValue(cursor,key,value),key,collection)},reverse,flipIndices):0}},{},Sequence);Cursor.prototype[DELETE]=Cursor.prototype.remove;Cursor.prototype.getIn=Cursor.prototype.get;function wrappedValue(cursor,key,value){return value instanceof Sequence?subCursor(cursor,key,value):value}function subCursor(cursor,key,value){return new Cursor(cursor._rootData,cursor._keyPath.concat(key),cursor._onChange,value)}function updateCursor(cursor,changeFn,changeKey){var newRootData=cursor._rootData.updateIn(cursor._keyPath,changeKey?Map.empty():undefined,changeFn);var keyPath=cursor._keyPath||[];cursor._onChange&&cursor._onChange.call(undefined,newRootData,cursor._rootData,changeKey?keyPath.concat(changeKey):keyPath);return new Cursor(newRootData,cursor._keyPath,cursor._onChange)}function is(first,second){if(first instanceof Cursor){first=first.deref()}if(second instanceof Cursor){second=second.deref()}if(first===second){return first!==0||second!==0||1/first===1/second}if(first!==first){return second!==second}if(first instanceof Sequence){return first.equals(second)}return false}var Map=function Map(sequence){var map=$Map.empty();return sequence?sequence.constructor===$Map?sequence:map.merge(sequence):map};var $Map=Map;$traceurRuntime.createClass(Map,{toString:function(){return this.__toString("Map {","}")},get:function(k,notSetValue){return this._root?this._root.get(0,hash(k),k,notSetValue):notSetValue},set:function(k,v){return updateMap(this,k,v)},remove:function(k){return updateMap(this,k,NOT_SET)},update:function(k,notSetValue,updater){return arguments.length===1?this.updateIn([],null,k):this.updateIn([k],notSetValue,updater)},updateIn:function(keyPath,notSetValue,updater){var $__13;if(!updater){$__13=[notSetValue,updater],updater=$__13[0],notSetValue=$__13[1],$__13}return updateInDeepMap(this,keyPath,notSetValue,updater,0)},clear:function(){if(this.length===0){return this}if(this.__ownerID){this.length=0;this._root=null;this.__hash=undefined;this.__altered=true;return this}return $Map.empty()},merge:function(){return mergeIntoMapWith(this,null,arguments)},mergeWith:function(merger){for(var seqs=[],$__4=1;$__4<arguments.length;$__4++)seqs[$__4-1]=arguments[$__4];return mergeIntoMapWith(this,merger,seqs)},mergeDeep:function(){return mergeIntoMapWith(this,deepMerger(null),arguments)},mergeDeepWith:function(merger){for(var seqs=[],$__5=1;$__5<arguments.length;$__5++)seqs[$__5-1]=arguments[$__5];return mergeIntoMapWith(this,deepMerger(merger),seqs)},cursor:function(keyPath,onChange){if(!onChange&&typeof keyPath==="function"){onChange=keyPath;keyPath=[]}else if(arguments.length===0){keyPath=[] | |
}else if(!Array.isArray(keyPath)){keyPath=[keyPath]}return new Cursor(this,keyPath,onChange)},withMutations:function(fn){var mutable=this.asMutable();fn(mutable);return mutable.wasAltered()?mutable.__ensureOwner(this.__ownerID):this},asMutable:function(){return this.__ownerID?this:this.__ensureOwner(new OwnerID)},asImmutable:function(){return this.__ensureOwner()},wasAltered:function(){return this.__altered},keys:function(){return new MapIterator(this,0)},values:function(){return new MapIterator(this,1)},entries:function(){return new MapIterator(this,2)},__iterator:function(reverse){return new MapIterator(this,2,reverse)},__iterate:function(fn,reverse){var map=this;if(!map._root){return 0}var iterations=0;this._root.iterate(function(entry){if(fn(entry[1],entry[0],map)===false){return false}iterations++},reverse);return iterations},__deepEquals:function(other){var self=this;return other.every(function(v,k){return is(self.get(k,NOT_SET),v)})},__ensureOwner:function(ownerID){if(ownerID===this.__ownerID){return this}if(!ownerID){this.__ownerID=ownerID;this.__altered=false;return this}return makeMap(this.length,this._root,ownerID,this.__hash)}},{empty:function(){return EMPTY_MAP||(EMPTY_MAP=makeMap(0))}},Sequence);var MapPrototype=Map.prototype;MapPrototype[DELETE]=MapPrototype.remove;MapPrototype[ITERATOR]=function(){return this.entries()};Map.from=Map;var BitmapIndexedNode=function BitmapIndexedNode(ownerID,bitmap,nodes){this.ownerID=ownerID;this.bitmap=bitmap;this.nodes=nodes};var $BitmapIndexedNode=BitmapIndexedNode;$traceurRuntime.createClass(BitmapIndexedNode,{get:function(shift,hash,key,notSetValue){var bit=1<<((shift===0?hash:hash>>>shift)&MASK);var bitmap=this.bitmap;return(bitmap&bit)===0?notSetValue:this.nodes[popCount(bitmap&bit-1)].get(shift+SHIFT,hash,key,notSetValue)},update:function(ownerID,shift,hash,key,value,didChangeLength,didAlter){var hashFrag=(shift===0?hash:hash>>>shift)&MASK;var bit=1<<hashFrag;var bitmap=this.bitmap;var exists=(bitmap&bit)!==0;if(!exists&&value===NOT_SET){return this}var idx=popCount(bitmap&bit-1);var nodes=this.nodes;var node=exists?nodes[idx]:null;var newNode=updateNode(node,ownerID,shift+SHIFT,hash,key,value,didChangeLength,didAlter);if(newNode===node){return this}if(!exists&&newNode&&nodes.length>=MAX_BITMAP_SIZE){return expandNodes(ownerID,nodes,bitmap,hashFrag,newNode)}if(exists&&!newNode&&nodes.length===2&&isLeafNode(nodes[idx^1])){return nodes[idx^1]}if(exists&&newNode&&nodes.length===1&&isLeafNode(newNode)){return newNode}var isEditable=ownerID&&ownerID===this.ownerID;var newBitmap=exists?newNode?bitmap:bitmap^bit:bitmap|bit;var newNodes=exists?newNode?setIn(nodes,idx,newNode,isEditable):spliceOut(nodes,idx,isEditable):spliceIn(nodes,idx,newNode,isEditable);if(isEditable){this.bitmap=newBitmap;this.nodes=newNodes;return this}return new $BitmapIndexedNode(ownerID,newBitmap,newNodes)},iterate:function(fn,reverse){var nodes=this.nodes;for(var ii=0,maxIndex=nodes.length-1;ii<=maxIndex;ii++){if(nodes[reverse?maxIndex-ii:ii].iterate(fn,reverse)===false){return false}}}},{});var ArrayNode=function ArrayNode(ownerID,count,nodes){this.ownerID=ownerID;this.count=count;this.nodes=nodes};var $ArrayNode=ArrayNode;$traceurRuntime.createClass(ArrayNode,{get:function(shift,hash,key,notSetValue){var idx=(shift===0?hash:hash>>>shift)&MASK;var node=this.nodes[idx];return node?node.get(shift+SHIFT,hash,key,notSetValue):notSetValue},update:function(ownerID,shift,hash,key,value,didChangeLength,didAlter){var idx=(shift===0?hash:hash>>>shift)&MASK;var removed=value===NOT_SET;var nodes=this.nodes;var node=nodes[idx];if(removed&&!node){return this}var newNode=updateNode(node,ownerID,shift+SHIFT,hash,key,value,didChangeLength,didAlter);if(newNode===node){return this}var newCount=this.count;if(!node){newCount++}else if(!newNode){newCount--;if(newCount<MIN_ARRAY_SIZE){return packNodes(ownerID,nodes,newCount,idx)}}var isEditable=ownerID&&ownerID===this.ownerID;var newNodes=setIn(nodes,idx,newNode,isEditable);if(isEditable){this.count=newCount;this.nodes=newNodes;return this}return new $ArrayNode(ownerID,newCount,newNodes)},iterate:function(fn,reverse){var nodes=this.nodes;for(var ii=0,maxIndex=nodes.length-1;ii<=maxIndex;ii++){var node=nodes[reverse?maxIndex-ii:ii];if(node&&node.iterate(fn,reverse)===false){return false}}}},{});var HashCollisionNode=function HashCollisionNode(ownerID,hash,entries){this.ownerID=ownerID;this.hash=hash;this.entries=entries};var $HashCollisionNode=HashCollisionNode;$traceurRuntime.createClass(HashCollisionNode,{get:function(shift,hash,key,notSetValue){var entries=this.entries;for(var ii=0,len=entries.length;ii<len;ii++){if(is(key,entries[ii][0])){return entries[ii][1]}}return notSetValue},update:function(ownerID,shift,hash,key,value,didChangeLength,didAlter){var removed=value===NOT_SET;if(hash!==this.hash){if(removed){return this}SetRef(didAlter);SetRef(didChangeLength);return mergeIntoNode(this,ownerID,shift,hash,[key,value])}var entries=this.entries;var idx=0;for(var len=entries.length;idx<len;idx++){if(is(key,entries[idx][0])){break}}var exists=idx<len;if(removed&&!exists){return this}SetRef(didAlter);(removed||!exists)&&SetRef(didChangeLength);if(removed&&len===2){return new ValueNode(ownerID,this.hash,entries[idx^1])}var isEditable=ownerID&&ownerID===this.ownerID;var newEntries=isEditable?entries:arrCopy(entries);if(exists){if(removed){idx===len-1?newEntries.pop():newEntries[idx]=newEntries.pop()}else{newEntries[idx]=[key,value]}}else{newEntries.push([key,value])}if(isEditable){this.entries=newEntries;return this}return new $HashCollisionNode(ownerID,this.hash,newEntries)},iterate:function(fn,reverse){var entries=this.entries;for(var ii=0,maxIndex=entries.length-1;ii<=maxIndex;ii++){if(fn(entries[reverse?maxIndex-ii:ii])===false){return false}}}},{});var ValueNode=function ValueNode(ownerID,hash,entry){this.ownerID=ownerID;this.hash=hash;this.entry=entry};var $ValueNode=ValueNode;$traceurRuntime.createClass(ValueNode,{get:function(shift,hash,key,notSetValue){return is(key,this.entry[0])?this.entry[1]:notSetValue},update:function(ownerID,shift,hash,key,value,didChangeLength,didAlter){var removed=value===NOT_SET;var keyMatch=is(key,this.entry[0]);if(keyMatch?value===this.entry[1]:removed){return this}SetRef(didAlter);if(removed){SetRef(didChangeLength);return null}if(keyMatch){if(ownerID&&ownerID===this.ownerID){this.entry[1]=value;return this}return new $ValueNode(ownerID,hash,[key,value])}SetRef(didChangeLength);return mergeIntoNode(this,ownerID,shift,hash,[key,value])},iterate:function(fn){return fn(this.entry)}},{});var MapIterator=function MapIterator(map,type,reverse){this._type=type;this._reverse=reverse;this._stack=map._root&&mapIteratorFrame(map._root)};$traceurRuntime.createClass(MapIterator,{next:function(){var type=this._type;var stack=this._stack;while(stack){var node=stack.node;var index=stack.index++;var maxIndex;if(node.entry){if(index===0){return mapIteratorValue(type,node.entry)}}else if(node.entries){maxIndex=node.entries.length-1;if(index<=maxIndex){return mapIteratorValue(type,node.entries[this._reverse?maxIndex-index:index])}}else{maxIndex=node.nodes.length-1;if(index<=maxIndex){var subNode=node.nodes[this._reverse?maxIndex-index:index];if(subNode){if(subNode.entry){return mapIteratorValue(type,subNode.entry)}stack=this._stack=mapIteratorFrame(subNode,stack)}continue}}stack=this._stack=this._stack.__prev}return iteratorDone()}},{},SequenceIterator);function mapIteratorValue(type,entry){return iteratorValue(type===0||type===1?entry[type]:[entry[0],entry[1]])}function mapIteratorFrame(node,prev){return{node:node,index:0,__prev:prev}}function makeMap(length,root,ownerID,hash){var map=Object.create(MapPrototype);map.length=length;map._root=root;map.__ownerID=ownerID;map.__hash=hash;map.__altered=false;return map}function updateMap(map,k,v){var didChangeLength=MakeRef(CHANGE_LENGTH);var didAlter=MakeRef(DID_ALTER);var newRoot=updateNode(map._root,map.__ownerID,0,hash(k),k,v,didChangeLength,didAlter);if(!didAlter.value){return map}var newLength=map.length+(didChangeLength.value?v===NOT_SET?-1:1:0);if(map.__ownerID){map.length=newLength;map._root=newRoot;map.__hash=undefined;map.__altered=true;return map}return newRoot?makeMap(newLength,newRoot):Map.empty()}function updateNode(node,ownerID,shift,hash,key,value,didChangeLength,didAlter){if(!node){if(value===NOT_SET){return node}SetRef(didAlter);SetRef(didChangeLength);return new ValueNode(ownerID,hash,[key,value])}return node.update(ownerID,shift,hash,key,value,didChangeLength,didAlter)}function isLeafNode(node){return node.constructor===ValueNode||node.constructor===HashCollisionNode}function mergeIntoNode(node,ownerID,shift,hash,entry){if(node.hash===hash){return new HashCollisionNode(ownerID,hash,[node.entry,entry])}var idx1=(shift===0?node.hash:node.hash>>>shift)&MASK;var idx2=(shift===0?hash:hash>>>shift)&MASK;var newNode;var nodes=idx1===idx2?[mergeIntoNode(node,ownerID,shift+SHIFT,hash,entry)]:(newNode=new ValueNode(ownerID,hash,entry),idx1<idx2?[node,newNode]:[newNode,node]);return new BitmapIndexedNode(ownerID,1<<idx1|1<<idx2,nodes)}function packNodes(ownerID,nodes,count,excluding){var bitmap=0;var packedII=0;var packedNodes=new Array(count);for(var ii=0,bit=1,len=nodes.length;ii<len;ii++,bit<<=1){var node=nodes[ii];if(node!=null&&ii!==excluding){bitmap|=bit;packedNodes[packedII++]=node}}return new BitmapIndexedNode(ownerID,bitmap,packedNodes)}function expandNodes(ownerID,nodes,bitmap,including,node){var count=0;var expandedNodes=new Array(SIZE);for(var ii=0;bitmap!==0;ii++,bitmap>>>=1){expandedNodes[ii]=bitmap&1?nodes[count++]:null}expandedNodes[including]=node;return new ArrayNode(ownerID,count+1,expandedNodes)}function mergeIntoMapWith(map,merger,iterables){var seqs=[];for(var ii=0;ii<iterables.length;ii++){var seq=iterables[ii];seq&&seqs.push(Array.isArray(seq)?Sequence(seq).fromEntrySeq():Sequence(seq))}return mergeIntoCollectionWith(map,merger,seqs)}function deepMerger(merger){return function(existing,value){return existing&&existing.mergeDeepWith?existing.mergeDeepWith(merger,value):merger?merger(existing,value):value}}function mergeIntoCollectionWith(collection,merger,seqs){if(seqs.length===0){return collection}return collection.withMutations(function(collection){var mergeIntoMap=merger?function(value,key){var existing=collection.get(key,NOT_SET);collection.set(key,existing===NOT_SET?value:merger(existing,value))}:function(value,key){collection.set(key,value)};for(var ii=0;ii<seqs.length;ii++){seqs[ii].forEach(mergeIntoMap)}})}function updateInDeepMap(collection,keyPath,notSetValue,updater,pathOffset){var pathLen=keyPath.length;if(pathOffset===pathLen){return updater(collection)}invariant(collection.set,"updateIn with invalid keyPath");var notSet=pathOffset===pathLen-1?notSetValue:Map.empty();var key=keyPath[pathOffset];var existing=collection.get(key,notSet);var value=updateInDeepMap(existing,keyPath,notSetValue,updater,pathOffset+1);return value===existing?collection:collection.set(key,value)}function popCount(x){x=x-(x>>1&1431655765);x=(x&858993459)+(x>>2&858993459);x=x+(x>>4)&252645135;x=x+(x>>8);x=x+(x>>16);return x&127}function setIn(array,idx,val,canEdit){var newArray=canEdit?array:arrCopy(array);newArray[idx]=val;return newArray}function spliceIn(array,idx,val,canEdit){var newLen=array.length+1;if(canEdit&&idx+1===newLen){array[idx]=val;return array}var newArray=new Array(newLen);var after=0;for(var ii=0;ii<newLen;ii++){if(ii===idx){newArray[ii]=val;after=-1}else{newArray[ii]=array[ii+after]}}return newArray}function spliceOut(array,idx,canEdit){var newLen=array.length-1;if(canEdit&&idx===newLen){array.pop();return array}var newArray=new Array(newLen);var after=0;for(var ii=0;ii<newLen;ii++){if(ii===idx){after=1}newArray[ii]=array[ii+after]}return newArray}var MAX_BITMAP_SIZE=SIZE/2;var MIN_ARRAY_SIZE=SIZE/4;var EMPTY_MAP;var Vector=function Vector(){for(var values=[],$__6=0;$__6<arguments.length;$__6++)values[$__6]=arguments[$__6];return $Vector.from(values)};var $Vector=Vector;$traceurRuntime.createClass(Vector,{toString:function(){return this.__toString("Vector [","]")},has:function(index){index=wrapIndex(this,index);return index>=0&&index<this.length},get:function(index,notSetValue){index=wrapIndex(this,index);if(index<0||index>=this.length){return notSetValue}index+=this._origin;var node=vectorNodeFor(this,index);return node&&node.array[index&MASK]},first:function(){return this.get(0)},last:function(){return this.get(this.length?this.length-1:0)},set:function(index,value){return updateVector(this,index,value)},remove:function(index){return updateVector(this,index,NOT_SET)},clear:function(){if(this.length===0){return this}if(this.__ownerID){this.length=this._origin=this._size=0;this._level=SHIFT;this._root=this._tail=null;this.__hash=undefined;this.__altered=true;return this}return $Vector.empty()},push:function(){var values=arguments;var oldLength=this.length;return this.withMutations(function(vect){setVectorBounds(vect,0,oldLength+values.length);for(var ii=0;ii<values.length;ii++){vect.set(oldLength+ii,values[ii])}})},pop:function(){return setVectorBounds(this,0,-1)},unshift:function(){var values=arguments;return this.withMutations(function(vect){setVectorBounds(vect,-values.length);for(var ii=0;ii<values.length;ii++){vect.set(ii,values[ii])}})},shift:function(){return setVectorBounds(this,1)},merge:function(){return mergeIntoVectorWith(this,null,arguments)},mergeWith:function(merger){for(var seqs=[],$__7=1;$__7<arguments.length;$__7++)seqs[$__7-1]=arguments[$__7];return mergeIntoVectorWith(this,merger,seqs)},mergeDeep:function(){return mergeIntoVectorWith(this,deepMerger(null),arguments)},mergeDeepWith:function(merger){for(var seqs=[],$__8=1;$__8<arguments.length;$__8++)seqs[$__8-1]=arguments[$__8];return mergeIntoVectorWith(this,deepMerger(merger),seqs)},setLength:function(length){return setVectorBounds(this,0,length)},slice:function(begin,end,maintainIndices){var sliceSequence=$traceurRuntime.superCall(this,$Vector.prototype,"slice",[begin,end,maintainIndices]);if(!maintainIndices&&sliceSequence!==this){var vector=this;var length=vector.length;sliceSequence.toVector=function(){return setVectorBounds(vector,begin<0?Math.max(0,length+begin):length?Math.min(length,begin):begin,end==null?length:end<0?Math.max(0,length+end):length?Math.min(length,end):end)}}return sliceSequence},keys:function(){return new VectorIterator(this,0)},values:function(){return new VectorIterator(this,1)},entries:function(){return new VectorIterator(this,2)},__iterator:function(reverse,flipIndices){return new VectorIterator(this,2,reverse,flipIndices)},__iterate:function(fn,reverse,flipIndices){var vector=this;var lastIndex=0;var maxIndex=vector.length-1;flipIndices^=reverse;var eachFn=function(value,ii){if(fn(value,flipIndices?maxIndex-ii:ii,vector)===false){return false}else{lastIndex=ii;return true}};var didComplete;var tailOffset=getTailOffset(this._size);if(reverse){didComplete=iterateVNode(this._tail,0,tailOffset-this._origin,this._size-this._origin,eachFn,reverse)&&iterateVNode(this._root,this._level,-this._origin,tailOffset-this._origin,eachFn,reverse)}else{didComplete=iterateVNode(this._root,this._level,-this._origin,tailOffset-this._origin,eachFn,reverse)&&iterateVNode(this._tail,0,tailOffset-this._origin,this._size-this._origin,eachFn,reverse)}return(didComplete?maxIndex:reverse?maxIndex-lastIndex:lastIndex)+1},__deepEquals:function(other){var iterator=this.entries(true);return other.every(function(v,i){var entry=iterator.next().value;return entry&&entry[0]===i&&is(entry[1],v)})},__ensureOwner:function(ownerID){if(ownerID===this.__ownerID){return this}if(!ownerID){this.__ownerID=ownerID;return this}return makeVector(this._origin,this._size,this._level,this._root,this._tail,ownerID,this.__hash)}},{empty:function(){return EMPTY_VECT||(EMPTY_VECT=makeVector(0,0,SHIFT))},from:function(sequence){if(!sequence||sequence.length===0){return $Vector.empty()}if(sequence.constructor===$Vector){return sequence}var isArray=Array.isArray(sequence);if(sequence.length>0&&sequence.length<SIZE){return makeVector(0,sequence.length,SHIFT,null,new VNode(isArray?arrCopy(sequence):Sequence(sequence).toArray()))}if(!isArray){sequence=Sequence(sequence);if(!(sequence instanceof IndexedSequence)){sequence=sequence.valueSeq()}}return $Vector.empty().merge(sequence)}},IndexedSequence);var VectorPrototype=Vector.prototype;VectorPrototype[DELETE]=VectorPrototype.remove;VectorPrototype[ITERATOR]=VectorPrototype.values;VectorPrototype.update=MapPrototype.update;VectorPrototype.updateIn=MapPrototype.updateIn;VectorPrototype.cursor=MapPrototype.cursor;VectorPrototype.withMutations=MapPrototype.withMutations;VectorPrototype.asMutable=MapPrototype.asMutable;VectorPrototype.asImmutable=MapPrototype.asImmutable;VectorPrototype.wasAltered=MapPrototype.wasAltered;var VNode=function VNode(array,ownerID){this.array=array;this.ownerID=ownerID};var $VNode=VNode;$traceurRuntime.createClass(VNode,{removeBefore:function(ownerID,level,index){if(index===level?1<<level:0||this.array.length===0){return this}var originIndex=index>>>level&MASK;if(originIndex>=this.array.length){return new $VNode([],ownerID)}var removingFirst=originIndex===0;var newChild;if(level>0){var oldChild=this.array[originIndex];newChild=oldChild&&oldChild.removeBefore(ownerID,level-SHIFT,index);if(newChild===oldChild&&removingFirst){return this}}if(removingFirst&&!newChild){return this}var editable=editableVNode(this,ownerID);if(!removingFirst){for(var ii=0;ii<originIndex;ii++){editable.array[ii]=undefined}}if(newChild){editable.array[originIndex]=newChild}return editable},removeAfter:function(ownerID,level,index){if(index===level?1<<level:0||this.array.length===0){return this}var sizeIndex=index-1>>>level&MASK;if(sizeIndex>=this.array.length){return this}var removingLast=sizeIndex===this.array.length-1;var newChild;if(level>0){var oldChild=this.array[sizeIndex];newChild=oldChild&&oldChild.removeAfter(ownerID,level-SHIFT,index);if(newChild===oldChild&&removingLast){return this}}if(removingLast&&!newChild){return this}var editable=editableVNode(this,ownerID);if(!removingLast){editable.array.pop()}if(newChild){editable.array[sizeIndex]=newChild}return editable}},{});function iterateVNode(node,level,offset,max,fn,reverse){var ii;var array=node&&node.array;if(level===0){var from=offset<0?0:offset;var to=offset+SIZE;if(to>max){to=max}for(ii=from;ii<to;ii++){var index=reverse?from+to-1-ii:ii;if(fn(array&&array[index-offset],index)===false){return false}}}else{var step=1<<level;var newLevel=level-SHIFT;for(ii=0;ii<=MASK;ii++){var levelIndex=reverse?MASK-ii:ii;var newOffset=offset+(levelIndex<<level);if(newOffset<max&&newOffset+step>0){var nextNode=array&&array[levelIndex];if(!iterateVNode(nextNode,newLevel,newOffset,max,fn,reverse)){return false}}}}return true}var VectorIterator=function VectorIterator(vector,type,reverse,flipIndices){this._type=type;this._reverse=!!reverse;this._flipIndices=!!(flipIndices^reverse);this._maxIndex=vector.length-1;var tailOffset=getTailOffset(vector._size);var rootStack=vectIteratorFrame(vector._root&&vector._root.array,vector._level,-vector._origin,tailOffset-vector._origin-1);var tailStack=vectIteratorFrame(vector._tail&&vector._tail.array,0,tailOffset-vector._origin,vector._size-vector._origin-1);this._stack=reverse?tailStack:rootStack;this._stack.__prev=reverse?rootStack:tailStack};$traceurRuntime.createClass(VectorIterator,{next:function(){var stack=this._stack;while(stack){var array=stack.array;var rawIndex=stack.index++;if(this._reverse){rawIndex=MASK-rawIndex;if(rawIndex>stack.rawMax){rawIndex=stack.rawMax;stack.index=SIZE-rawIndex}}if(rawIndex>=0&&rawIndex<SIZE&&rawIndex<=stack.rawMax){var value=array&&array[rawIndex];if(stack.level===0){var type=this._type;var index;if(type!==1){index=stack.offset+(rawIndex<<stack.level);if(this._flipIndices){index=this._maxIndex-index}}return iteratorValue(type===0?index:type===1?value:[index,value])}else{this._stack=stack=vectIteratorFrame(value&&value.array,stack.level-SHIFT,stack.offset+(rawIndex<<stack.level),stack.max,stack)}continue}stack=this._stack=this._stack.__prev}return iteratorDone()}},{},SequenceIterator);function vectIteratorFrame(array,level,offset,max,prevFrame){return{array:array,level:level,offset:offset,max:max,rawMax:max-offset>>level,index:0,__prev:prevFrame}}function makeVector(origin,size,level,root,tail,ownerID,hash){var vect=Object.create(VectorPrototype);vect.length=size-origin;vect._origin=origin;vect._size=size;vect._level=level;vect._root=root;vect._tail=tail;vect.__ownerID=ownerID;vect.__hash=hash;vect.__altered=false;return vect}function updateVector(vector,index,value){index=wrapIndex(vector,index);if(index>=vector.length||index<0){return value===NOT_SET?vector:vector.withMutations(function(vect){index<0?setVectorBounds(vect,index).set(0,value):setVectorBounds(vect,0,index+1).set(index,value)})}index+=vector._origin;var newTail=vector._tail;var newRoot=vector._root;var didAlter=MakeRef(DID_ALTER);if(index>=getTailOffset(vector._size)){newTail=updateVNode(newTail,vector.__ownerID,0,index,value,didAlter)}else{newRoot=updateVNode(newRoot,vector.__ownerID,vector._level,index,value,didAlter)}if(!didAlter.value){return vector}if(vector.__ownerID){vector._root=newRoot;vector._tail=newTail;vector.__hash=undefined;vector.__altered=true;return vector}return makeVector(vector._origin,vector._size,vector._level,newRoot,newTail)}function updateVNode(node,ownerID,level,index,value,didAlter){var removed=value===NOT_SET;var newNode;var idx=index>>>level&MASK;var nodeHas=node&&idx<node.array.length;if(removed&&!nodeHas){return node}if(level>0){var lowerNode=node&&node.array[idx];var newLowerNode=updateVNode(lowerNode,ownerID,level-SHIFT,index,value,didAlter);if(newLowerNode===lowerNode){return node}newNode=editableVNode(node,ownerID);newNode.array[idx]=newLowerNode;return newNode}if(!removed&&nodeHas&&node.array[idx]===value){return node}SetRef(didAlter);newNode=editableVNode(node,ownerID);if(removed&&idx===newNode.array.length-1){newNode.array.pop()}else{newNode.array[idx]=removed?undefined:value}return newNode}function editableVNode(node,ownerID){if(ownerID&&node&&ownerID===node.ownerID){return node}return new VNode(node?node.array.slice():[],ownerID)}function vectorNodeFor(vector,rawIndex){if(rawIndex>=getTailOffset(vector._size)){return vector._tail}if(rawIndex<1<<vector._level+SHIFT){var node=vector._root;var level=vector._level;while(node&&level>0){node=node.array[rawIndex>>>level&MASK];level-=SHIFT}return node}}function setVectorBounds(vector,begin,end){var owner=vector.__ownerID||new OwnerID;var oldOrigin=vector._origin;var oldSize=vector._size;var newOrigin=oldOrigin+begin;var newSize=end==null?oldSize:end<0?oldSize+end:oldOrigin+end;if(newOrigin===oldOrigin&&newSize===oldSize){return vector}if(newOrigin>=newSize){return vector.clear()}var newLevel=vector._level;var newRoot=vector._root;var offsetShift=0;while(newOrigin+offsetShift<0){newRoot=new VNode(newRoot&&newRoot.array.length?[null,newRoot]:[],owner);newLevel+=SHIFT;offsetShift+=1<<newLevel}if(offsetShift){newOrigin+=offsetShift;oldOrigin+=offsetShift;newSize+=offsetShift;oldSize+=offsetShift}var oldTailOffset=getTailOffset(oldSize);var newTailOffset=getTailOffset(newSize);while(newTailOffset>=1<<newLevel+SHIFT){newRoot=new VNode(newRoot&&newRoot.array.length?[newRoot]:[],owner);newLevel+=SHIFT}var oldTail=vector._tail;var newTail=newTailOffset<oldTailOffset?vectorNodeFor(vector,newSize-1):newTailOffset>oldTailOffset?new VNode([],owner):oldTail;if(oldTail&&newTailOffset>oldTailOffset&&newOrigin<oldSize&&oldTail.array.length){newRoot=editableVNode(newRoot,owner);var node=newRoot;for(var level=newLevel;level>SHIFT;level-=SHIFT){var idx=oldTailOffset>>>level&MASK;node=node.array[idx]=editableVNode(node.array[idx],owner)}node.array[oldTailOffset>>>SHIFT&MASK]=oldTail}if(newSize<oldSize){newTail=newTail&&newTail.removeAfter(owner,0,newSize)}if(newOrigin>=newTailOffset){newOrigin-=newTailOffset;newSize-=newTailOffset;newLevel=SHIFT;newRoot=null;newTail=newTail&&newTail.removeBefore(owner,0,newOrigin)}else if(newOrigin>oldOrigin||newTailOffset<oldTailOffset){var beginIndex,endIndex;offsetShift=0;do{beginIndex=newOrigin>>>newLevel&MASK;endIndex=newTailOffset-1>>>newLevel&MASK;if(beginIndex===endIndex){if(beginIndex){offsetShift+=(1<<newLevel)*beginIndex}newLevel-=SHIFT;newRoot=newRoot&&newRoot.array[beginIndex]}}while(newRoot&&beginIndex===endIndex);if(newRoot&&newOrigin>oldOrigin){newRoot=newRoot&&newRoot.removeBefore(owner,newLevel,newOrigin-offsetShift)}if(newRoot&&newTailOffset<oldTailOffset){newRoot=newRoot&&newRoot.removeAfter(owner,newLevel,newTailOffset-offsetShift)}if(offsetShift){newOrigin-=offsetShift;newSize-=offsetShift}}if(vector.__ownerID){vector.length=newSize-newOrigin;vector._origin=newOrigin;vector._size=newSize;vector._level=newLevel;vector._root=newRoot;vector._tail=newTail;vector.__hash=undefined;vector.__altered=true;return vector}return makeVector(newOrigin,newSize,newLevel,newRoot,newTail)}function mergeIntoVectorWith(vector,merger,iterables){var seqs=[];for(var ii=0;ii<iterables.length;ii++){var seq=iterables[ii];seq&&seqs.push(Sequence(seq))}var maxLength=Math.max.apply(null,seqs.map(function(s){return s.length||0}));if(maxLength>vector.length){vector=vector.setLength(maxLength)}return mergeIntoCollectionWith(vector,merger,seqs)}function getTailOffset(size){return size<SIZE?0:size-1>>>SHIFT<<SHIFT}var EMPTY_VECT;var Set=function Set(){for(var values=[],$__9=0;$__9<arguments.length;$__9++)values[$__9]=arguments[$__9];return $Set.from(values)};var $Set=Set;$traceurRuntime.createClass(Set,{toString:function(){return this.__toString("Set {","}")},has:function(value){return this._map.has(value)},get:function(value,notSetValue){return this.has(value)?value:notSetValue},add:function(value){var newMap=this._map.set(value,null);if(this.__ownerID){this.length=newMap.length;this._map=newMap;return this}return newMap===this._map?this:makeSet(newMap)},remove:function(value){var newMap=this._map.remove(value);if(this.__ownerID){this.length=newMap.length;this._map=newMap;return this}return newMap===this._map?this:newMap.length===0?$Set.empty():makeSet(newMap)},clear:function(){if(this.length===0){return this}if(this.__ownerID){this.length=0;this._map.clear();return this}return $Set.empty()},union:function(){var seqs=arguments;if(seqs.length===0){return this}return this.withMutations(function(set){for(var ii=0;ii<seqs.length;ii++){Sequence(seqs[ii]).forEach(function(value){return set.add(value)})}})},intersect:function(){for(var seqs=[],$__10=0;$__10<arguments.length;$__10++)seqs[$__10]=arguments[$__10];if(seqs.length===0){return this}seqs=seqs.map(function(seq){return Sequence(seq)});var originalSet=this;return this.withMutations(function(set){originalSet.forEach(function(value){if(!seqs.every(function(seq){return seq.contains(value)})){set.remove(value)}})})},subtract:function(){for(var seqs=[],$__11=0;$__11<arguments.length;$__11++)seqs[$__11]=arguments[$__11];if(seqs.length===0){return this}seqs=seqs.map(function(seq){return Sequence(seq)});var originalSet=this;return this.withMutations(function(set){originalSet.forEach(function(value){if(seqs.some(function(seq){return seq.contains(value)})){set.remove(value)}})})},isSubset:function(seq){seq=Sequence(seq);return this.every(function(value){return seq.contains(value)})},isSuperset:function(seq){var set=this;seq=Sequence(seq);return seq.every(function(value){return set.contains(value)})},wasAltered:function(){return this._map.wasAltered()},values:function(){return this._map.keys()},entries:function(){return iteratorMapper(this.values(),function(key){return[key,key]})},hashCode:function(){return this._map.hashCode()},__iterate:function(fn,reverse){var collection=this;return this._map.__iterate(function(_,k){return fn(k,k,collection)},reverse)},__deepEquals:function(other){return this.isSuperset(other)},__ensureOwner:function(ownerID){if(ownerID===this.__ownerID){return this}var newMap=this._map.__ensureOwner(ownerID);if(!ownerID){this.__ownerID=ownerID;this._map=newMap;return this}return makeSet(newMap,ownerID)}},{empty:function(){return EMPTY_SET||(EMPTY_SET=makeSet(Map.empty()))},from:function(sequence){var set=$Set.empty();return sequence?sequence.constructor===$Set?sequence:set.union(sequence):set},fromKeys:function(sequence){return $Set.from(Sequence(sequence).flip())}},Sequence);var SetPrototype=Set.prototype;SetPrototype[DELETE]=SetPrototype.remove;SetPrototype[ITERATOR]=SetPrototype.keys=SetPrototype.values;SetPrototype.contains=SetPrototype.has;SetPrototype.mergeDeep=SetPrototype.merge=SetPrototype.union;SetPrototype.mergeDeepWith=SetPrototype.mergeWith=function(merger){for(var seqs=[],$__12=1;$__12<arguments.length;$__12++)seqs[$__12-1]=arguments[$__12];return this.merge.apply(this,seqs)};SetPrototype.withMutations=MapPrototype.withMutations;SetPrototype.asMutable=MapPrototype.asMutable;SetPrototype.asImmutable=MapPrototype.asImmutable;SetPrototype.__toJS=IndexedSequencePrototype.__toJS;SetPrototype.__toStringMapper=IndexedSequencePrototype.__toStringMapper;function makeSet(map,ownerID){var set=Object.create(SetPrototype);set.length=map?map.length:0;set._map=map;set.__ownerID=ownerID;return set}var EMPTY_SET;var OrderedMap=function OrderedMap(sequence){var map=$OrderedMap.empty();return sequence?sequence.constructor===$OrderedMap?sequence:map.merge(sequence):map};var $OrderedMap=OrderedMap;$traceurRuntime.createClass(OrderedMap,{toString:function(){return this.__toString("OrderedMap {","}")},get:function(k,notSetValue){var index=this._map.get(k);return index!=null?this._vector.get(index)[1]:notSetValue},clear:function(){if(this.length===0){return this}if(this.__ownerID){this.length=0;this._map.clear();this._vector.clear();return this}return $OrderedMap.empty()},set:function(k,v){return updateOrderedMap(this,k,v)},remove:function(k){return updateOrderedMap(this,k,NOT_SET)},wasAltered:function(){return this._map.wasAltered()||this._vector.wasAltered()},keys:function(){return iteratorMapper(this.entries(),function(entry){return entry[0]})},values:function(){return iteratorMapper(this.entries(),function(entry){return entry[1]})},entries:function(){return this._vector.values(true)},__iterate:function(fn,reverse){return this._vector.fromEntrySeq().__iterate(fn,reverse)},__deepEquals:function(other){var iterator=this.entries();return other.every(function(v,k){var entry=iterator.next().value;return entry&&is(entry[0],k)&&is(entry[1],v)})},__ensureOwner:function(ownerID){if(ownerID===this.__ownerID){return this}var newMap=this._map.__ensureOwner(ownerID);var newVector=this._vector.__ensureOwner(ownerID);if(!ownerID){this.__ownerID=ownerID;this._map=newMap;this._vector=newVector;return this}return makeOrderedMap(newMap,newVector,ownerID,this.__hash)}},{empty:function(){return EMPTY_ORDERED_MAP||(EMPTY_ORDERED_MAP=makeOrderedMap(Map.empty(),Vector.empty()))}},Map);OrderedMap.from=OrderedMap;OrderedMap.prototype[DELETE]=OrderedMap.prototype.remove;function makeOrderedMap(map,vector,ownerID,hash){var omap=Object.create(OrderedMap.prototype);omap.length=map?map.length:0;omap._map=map;omap._vector=vector;omap.__ownerID=ownerID;omap.__hash=hash;return omap}function updateOrderedMap(omap,k,v){var map=omap._map;var vector=omap._vector;var i=map.get(k);var has=i!==undefined;var removed=v===NOT_SET;if(!has&&removed||has&&v===vector.get(i)[1]){return omap}if(!has){i=vector.length}var newMap=removed?map.remove(k):has?map:map.set(k,i);var newVector=removed?vector.remove(i):vector.set(i,[k,v]);if(omap.__ownerID){omap.length=newMap.length;omap._map=newMap;omap._vector=newVector;omap.__hash=undefined;return omap}return makeOrderedMap(newMap,newVector)}var EMPTY_ORDERED_MAP;var Record=function Record(defaultValues,name){var RecordType=function(values){if(!(this instanceof RecordType)){return new RecordType(values)}this._map=Map(values)};defaultValues=Sequence(defaultValues); | |
var RecordTypePrototype=RecordType.prototype=Object.create(RecordPrototype);RecordTypePrototype.constructor=RecordType;RecordTypePrototype._name=name;RecordTypePrototype._defaultValues=defaultValues;var keys=Object.keys(defaultValues);RecordType.prototype.length=keys.length;if(Object.defineProperty){defaultValues.forEach(function(_,key){Object.defineProperty(RecordType.prototype,key,{get:function(){return this.get(key)},set:function(value){invariant(this.__ownerID,"Cannot set on an immutable record.");this.set(key,value)}})})}return RecordType};var $Record=Record;$traceurRuntime.createClass(Record,{toString:function(){return this.__toString((this._name||"Record")+" {","}")},has:function(k){return this._defaultValues.has(k)},get:function(k,notSetValue){if(notSetValue!==undefined&&!this.has(k)){return notSetValue}return this._map.get(k,this._defaultValues.get(k))},clear:function(){if(this.__ownerID){this._map.clear();return this}var Record=Object.getPrototypeOf(this).constructor;return $Record._empty||($Record._empty=makeRecord(this,Map.empty()))},set:function(k,v){if(k==null||!this.has(k)){return this}var newMap=this._map.set(k,v);if(this.__ownerID||newMap===this._map){return this}return makeRecord(this,newMap)},remove:function(k){if(k==null||!this.has(k)){return this}var newMap=this._map.remove(k);if(this.__ownerID||newMap===this._map){return this}return makeRecord(this,newMap)},keys:function(){return this._map.keys()},values:function(){return this._map.values()},entries:function(){return this._map.entries()},wasAltered:function(){return this._map.wasAltered()},__iterate:function(fn,reverse){var record=this;return this._defaultValues.map(function(_,k){return record.get(k)}).__iterate(fn,reverse)},__ensureOwner:function(ownerID){if(ownerID===this.__ownerID){return this}var newMap=this._map&&this._map.__ensureOwner(ownerID);if(!ownerID){this.__ownerID=ownerID;this._map=newMap;return this}return makeRecord(this,newMap,ownerID)}},{},Sequence);var RecordPrototype=Record.prototype;RecordPrototype[DELETE]=RecordPrototype.remove;RecordPrototype[ITERATOR]=MapPrototype[ITERATOR];RecordPrototype.merge=MapPrototype.merge;RecordPrototype.mergeWith=MapPrototype.mergeWith;RecordPrototype.mergeDeep=MapPrototype.mergeDeep;RecordPrototype.mergeDeepWith=MapPrototype.mergeDeepWith;RecordPrototype.update=MapPrototype.update;RecordPrototype.updateIn=MapPrototype.updateIn;RecordPrototype.cursor=MapPrototype.cursor;RecordPrototype.withMutations=MapPrototype.withMutations;RecordPrototype.asMutable=MapPrototype.asMutable;RecordPrototype.asImmutable=MapPrototype.asImmutable;RecordPrototype.__deepEquals=MapPrototype.__deepEquals;function makeRecord(likeRecord,map,ownerID){var record=Object.create(Object.getPrototypeOf(likeRecord));record._map=map;record.__ownerID=ownerID;return record}var Range=function Range(start,end,step){if(!(this instanceof $Range)){return new $Range(start,end,step)}invariant(step!==0,"Cannot step a Range by 0");start=start||0;if(end==null){end=Infinity}if(start===end&&__EMPTY_RANGE){return __EMPTY_RANGE}step=step==null?1:Math.abs(step);if(end<start){step=-step}this._start=start;this._end=end;this._step=step;this.length=Math.max(0,Math.ceil((end-start)/step-1)+1)};var $Range=Range;$traceurRuntime.createClass(Range,{toString:function(){if(this.length===0){return"Range []"}return"Range [ "+this._start+"..."+this._end+(this._step>1?" by "+this._step:"")+" ]"},has:function(index){index=wrapIndex(this,index);return index>=0&&(this.length===Infinity||index<this.length)},get:function(index,notSetValue){index=wrapIndex(this,index);return this.has(index)?this._start+index*this._step:notSetValue},contains:function(searchValue){var possibleIndex=(searchValue-this._start)/this._step;return possibleIndex>=0&&possibleIndex<this.length&&possibleIndex===Math.floor(possibleIndex)},slice:function(begin,end,maintainIndices){if(wholeSlice(begin,end,this.length)){return this}if(maintainIndices){return $traceurRuntime.superCall(this,$Range.prototype,"slice",[begin,end,maintainIndices])}begin=resolveBegin(begin,this.length);end=resolveEnd(end,this.length);if(end<=begin){return __EMPTY_RANGE}return new $Range(this.get(begin,this._end),this.get(end,this._end),this._step)},indexOf:function(searchValue){var offsetValue=searchValue-this._start;if(offsetValue%this._step===0){var index=offsetValue/this._step;if(index>=0&&index<this.length){return index}}return-1},lastIndexOf:function(searchValue){return this.indexOf(searchValue)},take:function(amount){return this.slice(0,amount)},skip:function(amount,maintainIndices){return maintainIndices?$traceurRuntime.superCall(this,$Range.prototype,"skip",[amount]):this.slice(amount)},__iterate:function(fn,reverse,flipIndices){var maxIndex=this.length-1;var step=this._step;var value=reverse?this._start+maxIndex*step:this._start;for(var ii=0;ii<=maxIndex;ii++){if(fn(value,flipIndices?maxIndex-ii:ii,this)===false){break}value+=reverse?-step:step}return flipIndices?this.length:ii},__deepEquals:function(other){return this._start===other._start&&this._end===other._end&&this._step===other._step}},{},IndexedSequence);var RangePrototype=Range.prototype;RangePrototype.__toJS=RangePrototype.toArray;RangePrototype.first=VectorPrototype.first;RangePrototype.last=VectorPrototype.last;var __EMPTY_RANGE=Range(0,0);var Repeat=function Repeat(value,times){if(times===0&&EMPTY_REPEAT){return EMPTY_REPEAT}if(!(this instanceof $Repeat)){return new $Repeat(value,times)}this._value=value;this.length=times==null?Infinity:Math.max(0,times)};var $Repeat=Repeat;$traceurRuntime.createClass(Repeat,{toString:function(){if(this.length===0){return"Repeat []"}return"Repeat [ "+this._value+" "+this.length+" times ]"},get:function(index,notSetValue){return this.has(index)?this._value:notSetValue},first:function(){return this._value},contains:function(searchValue){return is(this._value,searchValue)},slice:function(begin,end,maintainIndices){if(maintainIndices){return $traceurRuntime.superCall(this,$Repeat.prototype,"slice",[begin,end,maintainIndices])}var length=this.length;begin=begin<0?Math.max(0,length+begin):Math.min(length,begin);end=end==null?length:end>0?Math.min(length,end):Math.max(0,length+end);return end>begin?new $Repeat(this._value,end-begin):EMPTY_REPEAT},reverse:function(maintainIndices){return maintainIndices?$traceurRuntime.superCall(this,$Repeat.prototype,"reverse",[maintainIndices]):this},indexOf:function(searchValue){if(is(this._value,searchValue)){return 0}return-1},lastIndexOf:function(searchValue){if(is(this._value,searchValue)){return this.length}return-1},__iterate:function(fn,reverse,flipIndices){var reversedIndices=reverse^flipIndices;invariant(!reversedIndices||this.length<Infinity,"Cannot access end of infinite range.");var maxIndex=this.length-1;for(var ii=0;ii<=maxIndex;ii++){if(fn(this._value,reversedIndices?maxIndex-ii:ii,this)===false){break}}return reversedIndices?this.length:ii},__deepEquals:function(other){return is(this._value,other._value)}},{},IndexedSequence);var RepeatPrototype=Repeat.prototype;RepeatPrototype.last=RepeatPrototype.first;RepeatPrototype.has=RangePrototype.has;RepeatPrototype.take=RangePrototype.take;RepeatPrototype.skip=RangePrototype.skip;RepeatPrototype.__toJS=RangePrototype.__toJS;var EMPTY_REPEAT=new Repeat(undefined,0);function fromJS(json,converter){if(converter){return _fromJSWith(converter,json,"",{"":json})}return _fromJSDefault(json)}function _fromJSWith(converter,json,key,parentJSON){if(json&&(Array.isArray(json)||json.constructor===Object)){return converter.call(parentJSON,key,Sequence(json).map(function(v,k){return _fromJSWith(converter,v,k,json)}))}return json}function _fromJSDefault(json){if(json){if(Array.isArray(json)){return Sequence(json).map(_fromJSDefault).toVector()}if(json.constructor===Object){return Sequence(json).map(_fromJSDefault).toMap()}}return json}var Immutable={Sequence:Sequence,Map:Map,Vector:Vector,Set:Set,OrderedMap:OrderedMap,Record:Record,Range:Range,Repeat:Repeat,is:is,fromJS:fromJS};return Immutable}typeof exports==="object"?module.exports=universalModule():typeof define==="function"&&define.amd?define(universalModule):Immutable=universalModule()},{}]},{},[]);require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({lodash:[function(require,module,exports){(function(global){(function(){var undefined;var arrayPool=[],objectPool=[];var idCounter=0;var keyPrefix=+new Date+"";var largeArraySize=75;var maxPoolSize=40;var whitespace=" \f "+"\n\r\u2028\u2029"+" ";var reEmptyStringLeading=/\b__p \+= '';/g,reEmptyStringMiddle=/\b(__p \+=) '' \+/g,reEmptyStringTrailing=/(__e\(.*?\)|\b__t\)) \+\n'';/g;var reEsTemplate=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;var reFlags=/\w*$/;var reFuncName=/^\s*function[ \n\r\t]+\w/;var reInterpolate=/<%=([\s\S]+?)%>/g;var reLeadingSpacesAndZeros=RegExp("^["+whitespace+"]*0+(?=.$)");var reNoMatch=/($^)/;var reThis=/\bthis\b/;var reUnescapedString=/['\n\r\t\u2028\u2029\\]/g;var contextProps=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setTimeout"];var templateCounter=0;var argsClass="[object Arguments]",arrayClass="[object Array]",boolClass="[object Boolean]",dateClass="[object Date]",funcClass="[object Function]",numberClass="[object Number]",objectClass="[object Object]",regexpClass="[object RegExp]",stringClass="[object String]";var cloneableClasses={};cloneableClasses[funcClass]=false;cloneableClasses[argsClass]=cloneableClasses[arrayClass]=cloneableClasses[boolClass]=cloneableClasses[dateClass]=cloneableClasses[numberClass]=cloneableClasses[objectClass]=cloneableClasses[regexpClass]=cloneableClasses[stringClass]=true;var debounceOptions={leading:false,maxWait:0,trailing:false};var descriptor={configurable:false,enumerable:false,value:null,writable:false};var objectTypes={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false};var stringEscapes={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};var root=objectTypes[typeof window]&&window||this;var freeExports=objectTypes[typeof exports]&&exports&&!exports.nodeType&&exports;var freeModule=objectTypes[typeof module]&&module&&!module.nodeType&&module;var moduleExports=freeModule&&freeModule.exports===freeExports&&freeExports;var freeGlobal=objectTypes[typeof global]&&global;if(freeGlobal&&(freeGlobal.global===freeGlobal||freeGlobal.window===freeGlobal)){root=freeGlobal}function baseIndexOf(array,value,fromIndex){var index=(fromIndex||0)-1,length=array?array.length:0;while(++index<length){if(array[index]===value){return index}}return-1}function cacheIndexOf(cache,value){var type=typeof value;cache=cache.cache;if(type=="boolean"||value==null){return cache[value]?0:-1}if(type!="number"&&type!="string"){type="object"}var key=type=="number"?value:keyPrefix+value;cache=(cache=cache[type])&&cache[key];return type=="object"?cache&&baseIndexOf(cache,value)>-1?0:-1:cache?0:-1}function cachePush(value){var cache=this.cache,type=typeof value;if(type=="boolean"||value==null){cache[value]=true}else{if(type!="number"&&type!="string"){type="object"}var key=type=="number"?value:keyPrefix+value,typeCache=cache[type]||(cache[type]={});if(type=="object"){(typeCache[key]||(typeCache[key]=[])).push(value)}else{typeCache[key]=true}}}function charAtCallback(value){return value.charCodeAt(0)}function compareAscending(a,b){var ac=a.criteria,bc=b.criteria,index=-1,length=ac.length;while(++index<length){var value=ac[index],other=bc[index];if(value!==other){if(value>other||typeof value=="undefined"){return 1}if(value<other||typeof other=="undefined"){return-1}}}return a.index-b.index}function createCache(array){var index=-1,length=array.length,first=array[0],mid=array[length/2|0],last=array[length-1];if(first&&typeof first=="object"&&mid&&typeof mid=="object"&&last&&typeof last=="object"){return false}var cache=getObject();cache["false"]=cache["null"]=cache["true"]=cache["undefined"]=false;var result=getObject();result.array=array;result.cache=cache;result.push=cachePush;while(++index<length){result.push(array[index])}return result}function escapeStringChar(match){return"\\"+stringEscapes[match]}function getArray(){return arrayPool.pop()||[]}function getObject(){return objectPool.pop()||{array:null,cache:null,criteria:null,"false":false,index:0,"null":false,number:null,object:null,push:null,string:null,"true":false,undefined:false,value:null}}function releaseArray(array){array.length=0;if(arrayPool.length<maxPoolSize){arrayPool.push(array)}}function releaseObject(object){var cache=object.cache;if(cache){releaseObject(cache)}object.array=object.cache=object.criteria=object.object=object.number=object.string=object.value=null;if(objectPool.length<maxPoolSize){objectPool.push(object)}}function slice(array,start,end){start||(start=0);if(typeof end=="undefined"){end=array?array.length:0}var index=-1,length=end-start||0,result=Array(length<0?0:length);while(++index<length){result[index]=array[start+index]}return result}function runInContext(context){context=context?_.defaults(root.Object(),context,_.pick(root,contextProps)):root;var Array=context.Array,Boolean=context.Boolean,Date=context.Date,Function=context.Function,Math=context.Math,Number=context.Number,Object=context.Object,RegExp=context.RegExp,String=context.String,TypeError=context.TypeError;var arrayRef=[];var objectProto=Object.prototype;var oldDash=context._;var toString=objectProto.toString;var reNative=RegExp("^"+String(toString).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");var ceil=Math.ceil,clearTimeout=context.clearTimeout,floor=Math.floor,fnToString=Function.prototype.toString,getPrototypeOf=isNative(getPrototypeOf=Object.getPrototypeOf)&&getPrototypeOf,hasOwnProperty=objectProto.hasOwnProperty,push=arrayRef.push,setTimeout=context.setTimeout,splice=arrayRef.splice,unshift=arrayRef.unshift;var defineProperty=function(){try{var o={},func=isNative(func=Object.defineProperty)&&func,result=func(o,o,o)&&func}catch(e){}return result}();var nativeCreate=isNative(nativeCreate=Object.create)&&nativeCreate,nativeIsArray=isNative(nativeIsArray=Array.isArray)&&nativeIsArray,nativeIsFinite=context.isFinite,nativeIsNaN=context.isNaN,nativeKeys=isNative(nativeKeys=Object.keys)&&nativeKeys,nativeMax=Math.max,nativeMin=Math.min,nativeParseInt=context.parseInt,nativeRandom=Math.random;var ctorByClass={};ctorByClass[arrayClass]=Array;ctorByClass[boolClass]=Boolean;ctorByClass[dateClass]=Date;ctorByClass[funcClass]=Function;ctorByClass[objectClass]=Object;ctorByClass[numberClass]=Number;ctorByClass[regexpClass]=RegExp;ctorByClass[stringClass]=String;function lodash(value){return value&&typeof value=="object"&&!isArray(value)&&hasOwnProperty.call(value,"__wrapped__")?value:new lodashWrapper(value)}function lodashWrapper(value,chainAll){this.__chain__=!!chainAll;this.__wrapped__=value}lodashWrapper.prototype=lodash.prototype;var support=lodash.support={};support.funcDecomp=!isNative(context.WinRTError)&&reThis.test(runInContext);support.funcNames=typeof Function.name=="string";lodash.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:reInterpolate,variable:"",imports:{_:lodash}};function baseBind(bindData){var func=bindData[0],partialArgs=bindData[2],thisArg=bindData[4];function bound(){if(partialArgs){var args=slice(partialArgs);push.apply(args,arguments)}if(this instanceof bound){var thisBinding=baseCreate(func.prototype),result=func.apply(thisBinding,args||arguments);return isObject(result)?result:thisBinding}return func.apply(thisArg,args||arguments)}setBindData(bound,bindData);return bound}function baseClone(value,isDeep,callback,stackA,stackB){if(callback){var result=callback(value);if(typeof result!="undefined"){return result}}var isObj=isObject(value);if(isObj){var className=toString.call(value);if(!cloneableClasses[className]){return value}var ctor=ctorByClass[className];switch(className){case boolClass:case dateClass:return new ctor(+value);case numberClass:case stringClass:return new ctor(value);case regexpClass:result=ctor(value.source,reFlags.exec(value));result.lastIndex=value.lastIndex;return result}}else{return value}var isArr=isArray(value);if(isDeep){var initedStack=!stackA;stackA||(stackA=getArray());stackB||(stackB=getArray());var length=stackA.length;while(length--){if(stackA[length]==value){return stackB[length]}}result=isArr?ctor(value.length):{}}else{result=isArr?slice(value):assign({},value)}if(isArr){if(hasOwnProperty.call(value,"index")){result.index=value.index}if(hasOwnProperty.call(value,"input")){result.input=value.input}}if(!isDeep){return result}stackA.push(value);stackB.push(result);(isArr?forEach:forOwn)(value,function(objValue,key){result[key]=baseClone(objValue,isDeep,callback,stackA,stackB)});if(initedStack){releaseArray(stackA);releaseArray(stackB)}return result}function baseCreate(prototype,properties){return isObject(prototype)?nativeCreate(prototype):{}}if(!nativeCreate){baseCreate=function(){function Object(){}return function(prototype){if(isObject(prototype)){Object.prototype=prototype;var result=new Object;Object.prototype=null}return result||context.Object()}}()}function baseCreateCallback(func,thisArg,argCount){if(typeof func!="function"){return identity}if(typeof thisArg=="undefined"||!("prototype"in func)){return func}var bindData=func.__bindData__;if(typeof bindData=="undefined"){if(support.funcNames){bindData=!func.name}bindData=bindData||!support.funcDecomp;if(!bindData){var source=fnToString.call(func);if(!support.funcNames){bindData=!reFuncName.test(source)}if(!bindData){bindData=reThis.test(source);setBindData(func,bindData)}}}if(bindData===false||bindData!==true&&bindData[1]&1){return func}switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 2:return function(a,b){return func.call(thisArg,a,b)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)}}return bind(func,thisArg)}function baseCreateWrapper(bindData){var func=bindData[0],bitmask=bindData[1],partialArgs=bindData[2],partialRightArgs=bindData[3],thisArg=bindData[4],arity=bindData[5];var isBind=bitmask&1,isBindKey=bitmask&2,isCurry=bitmask&4,isCurryBound=bitmask&8,key=func;function bound(){var thisBinding=isBind?thisArg:this;if(partialArgs){var args=slice(partialArgs);push.apply(args,arguments)}if(partialRightArgs||isCurry){args||(args=slice(arguments));if(partialRightArgs){push.apply(args,partialRightArgs)}if(isCurry&&args.length<arity){bitmask|=16&~32;return baseCreateWrapper([func,isCurryBound?bitmask:bitmask&~3,args,null,thisArg,arity])}}args||(args=arguments);if(isBindKey){func=thisBinding[key]}if(this instanceof bound){thisBinding=baseCreate(func.prototype);var result=func.apply(thisBinding,args);return isObject(result)?result:thisBinding}return func.apply(thisBinding,args)}setBindData(bound,bindData);return bound}function baseDifference(array,values){var index=-1,indexOf=getIndexOf(),length=array?array.length:0,isLarge=length>=largeArraySize&&indexOf===baseIndexOf,result=[];if(isLarge){var cache=createCache(values);if(cache){indexOf=cacheIndexOf;values=cache}else{isLarge=false}}while(++index<length){var value=array[index];if(indexOf(values,value)<0){result.push(value)}}if(isLarge){releaseObject(values)}return result}function baseFlatten(array,isShallow,isStrict,fromIndex){var index=(fromIndex||0)-1,length=array?array.length:0,result=[];while(++index<length){var value=array[index];if(value&&typeof value=="object"&&typeof value.length=="number"&&(isArray(value)||isArguments(value))){if(!isShallow){value=baseFlatten(value,isShallow,isStrict)}var valIndex=-1,valLength=value.length,resIndex=result.length;result.length+=valLength;while(++valIndex<valLength){result[resIndex++]=value[valIndex]}}else if(!isStrict){result.push(value)}}return result}function baseIsEqual(a,b,callback,isWhere,stackA,stackB){if(callback){var result=callback(a,b);if(typeof result!="undefined"){return!!result}}if(a===b){return a!==0||1/a==1/b}var type=typeof a,otherType=typeof b;if(a===a&&!(a&&objectTypes[type])&&!(b&&objectTypes[otherType])){return false}if(a==null||b==null){return a===b}var className=toString.call(a),otherClass=toString.call(b);if(className==argsClass){className=objectClass}if(otherClass==argsClass){otherClass=objectClass}if(className!=otherClass){return false}switch(className){case boolClass:case dateClass:return+a==+b;case numberClass:return a!=+a?b!=+b:a==0?1/a==1/b:a==+b;case regexpClass:case stringClass:return a==String(b)}var isArr=className==arrayClass;if(!isArr){var aWrapped=hasOwnProperty.call(a,"__wrapped__"),bWrapped=hasOwnProperty.call(b,"__wrapped__");if(aWrapped||bWrapped){return baseIsEqual(aWrapped?a.__wrapped__:a,bWrapped?b.__wrapped__:b,callback,isWhere,stackA,stackB)}if(className!=objectClass){return false}var ctorA=a.constructor,ctorB=b.constructor;if(ctorA!=ctorB&&!(isFunction(ctorA)&&ctorA instanceof ctorA&&isFunction(ctorB)&&ctorB instanceof ctorB)&&("constructor"in a&&"constructor"in b)){return false}}var initedStack=!stackA;stackA||(stackA=getArray());stackB||(stackB=getArray());var length=stackA.length;while(length--){if(stackA[length]==a){return stackB[length]==b}}var size=0;result=true;stackA.push(a);stackB.push(b);if(isArr){length=a.length;size=b.length;result=size==length;if(result||isWhere){while(size--){var index=length,value=b[size];if(isWhere){while(index--){if(result=baseIsEqual(a[index],value,callback,isWhere,stackA,stackB)){break}}}else if(!(result=baseIsEqual(a[size],value,callback,isWhere,stackA,stackB))){break}}}}else{forIn(b,function(value,key,b){if(hasOwnProperty.call(b,key)){size++;return result=hasOwnProperty.call(a,key)&&baseIsEqual(a[key],value,callback,isWhere,stackA,stackB)}});if(result&&!isWhere){forIn(a,function(value,key,a){if(hasOwnProperty.call(a,key)){return result=--size>-1}})}}stackA.pop();stackB.pop();if(initedStack){releaseArray(stackA);releaseArray(stackB)}return result}function baseMerge(object,source,callback,stackA,stackB){(isArray(source)?forEach:forOwn)(source,function(source,key){var found,isArr,result=source,value=object[key];if(source&&((isArr=isArray(source))||isPlainObject(source))){var stackLength=stackA.length;while(stackLength--){if(found=stackA[stackLength]==source){value=stackB[stackLength];break}}if(!found){var isShallow;if(callback){result=callback(value,source);if(isShallow=typeof result!="undefined"){value=result}}if(!isShallow){value=isArr?isArray(value)?value:[]:isPlainObject(value)?value:{}}stackA.push(source);stackB.push(value);if(!isShallow){baseMerge(value,source,callback,stackA,stackB)}}}else{if(callback){result=callback(value,source);if(typeof result=="undefined"){result=source}}if(typeof result!="undefined"){value=result}}object[key]=value})}function baseRandom(min,max){return min+floor(nativeRandom()*(max-min+1))}function baseUniq(array,isSorted,callback){var index=-1,indexOf=getIndexOf(),length=array?array.length:0,result=[];var isLarge=!isSorted&&length>=largeArraySize&&indexOf===baseIndexOf,seen=callback||isLarge?getArray():result;if(isLarge){var cache=createCache(seen);indexOf=cacheIndexOf;seen=cache}while(++index<length){var value=array[index],computed=callback?callback(value,index,array):value;if(isSorted?!index||seen[seen.length-1]!==computed:indexOf(seen,computed)<0){if(callback||isLarge){seen.push(computed)}result.push(value)}}if(isLarge){releaseArray(seen.array);releaseObject(seen)}else if(callback){releaseArray(seen)}return result}function createAggregator(setter){return function(collection,callback,thisArg){var result={};callback=lodash.createCallback(callback,thisArg,3);var index=-1,length=collection?collection.length:0;if(typeof length=="number"){while(++index<length){var value=collection[index];setter(result,value,callback(value,index,collection),collection)}}else{forOwn(collection,function(value,key,collection){setter(result,value,callback(value,key,collection),collection)})}return result}}function createWrapper(func,bitmask,partialArgs,partialRightArgs,thisArg,arity){var isBind=bitmask&1,isBindKey=bitmask&2,isCurry=bitmask&4,isCurryBound=bitmask&8,isPartial=bitmask&16,isPartialRight=bitmask&32;if(!isBindKey&&!isFunction(func)){throw new TypeError}if(isPartial&&!partialArgs.length){bitmask&=~16;isPartial=partialArgs=false}if(isPartialRight&&!partialRightArgs.length){bitmask&=~32;isPartialRight=partialRightArgs=false}var bindData=func&&func.__bindData__;if(bindData&&bindData!==true){bindData=slice(bindData);if(bindData[2]){bindData[2]=slice(bindData[2])}if(bindData[3]){bindData[3]=slice(bindData[3])}if(isBind&&!(bindData[1]&1)){bindData[4]=thisArg}if(!isBind&&bindData[1]&1){bitmask|=8}if(isCurry&&!(bindData[1]&4)){bindData[5]=arity}if(isPartial){push.apply(bindData[2]||(bindData[2]=[]),partialArgs)}if(isPartialRight){unshift.apply(bindData[3]||(bindData[3]=[]),partialRightArgs)}bindData[1]|=bitmask;return createWrapper.apply(null,bindData)}var creater=bitmask==1||bitmask===17?baseBind:baseCreateWrapper;return creater([func,bitmask,partialArgs,partialRightArgs,thisArg,arity])}function escapeHtmlChar(match){return htmlEscapes[match]}function getIndexOf(){var result=(result=lodash.indexOf)===indexOf?baseIndexOf:result;return result}function isNative(value){return typeof value=="function"&&reNative.test(value)}var setBindData=!defineProperty?noop:function(func,value){descriptor.value=value;defineProperty(func,"__bindData__",descriptor)};function shimIsPlainObject(value){var ctor,result;if(!(value&&toString.call(value)==objectClass)||(ctor=value.constructor,isFunction(ctor)&&!(ctor instanceof ctor))){return false}forIn(value,function(value,key){result=key});return typeof result=="undefined"||hasOwnProperty.call(value,result)}function unescapeHtmlChar(match){return htmlUnescapes[match]}function isArguments(value){return value&&typeof value=="object"&&typeof value.length=="number"&&toString.call(value)==argsClass||false}var isArray=nativeIsArray||function(value){return value&&typeof value=="object"&&typeof value.length=="number"&&toString.call(value)==arrayClass||false};var shimKeys=function(object){var index,iterable=object,result=[];if(!iterable)return result;if(!objectTypes[typeof object])return result;for(index in iterable){if(hasOwnProperty.call(iterable,index)){result.push(index)}}return result};var keys=!nativeKeys?shimKeys:function(object){if(!isObject(object)){return[]}return nativeKeys(object)};var htmlEscapes={"&":"&","<":"<",">":">",'"':""","'":"'"};var htmlUnescapes=invert(htmlEscapes);var reEscapedHtml=RegExp("("+keys(htmlUnescapes).join("|")+")","g"),reUnescapedHtml=RegExp("["+keys(htmlEscapes).join("")+"]","g");var assign=function(object,source,guard){var index,iterable=object,result=iterable;if(!iterable)return result;var args=arguments,argsIndex=0,argsLength=typeof guard=="number"?2:args.length;if(argsLength>3&&typeof args[argsLength-2]=="function"){var callback=baseCreateCallback(args[--argsLength-1],args[argsLength--],2)}else if(argsLength>2&&typeof args[argsLength-1]=="function"){callback=args[--argsLength]}while(++argsIndex<argsLength){iterable=args[argsIndex];if(iterable&&objectTypes[typeof iterable]){var ownIndex=-1,ownProps=objectTypes[typeof iterable]&&keys(iterable),length=ownProps?ownProps.length:0;while(++ownIndex<length){index=ownProps[ownIndex];result[index]=callback?callback(result[index],iterable[index]):iterable[index]}}}return result};function clone(value,isDeep,callback,thisArg){if(typeof isDeep!="boolean"&&isDeep!=null){thisArg=callback;callback=isDeep;isDeep=false}return baseClone(value,isDeep,typeof callback=="function"&&baseCreateCallback(callback,thisArg,1))}function cloneDeep(value,callback,thisArg){return baseClone(value,true,typeof callback=="function"&&baseCreateCallback(callback,thisArg,1))}function create(prototype,properties){var result=baseCreate(prototype);return properties?assign(result,properties):result}var defaults=function(object,source,guard){var index,iterable=object,result=iterable;if(!iterable)return result;var args=arguments,argsIndex=0,argsLength=typeof guard=="number"?2:args.length;while(++argsIndex<argsLength){iterable=args[argsIndex];if(iterable&&objectTypes[typeof iterable]){var ownIndex=-1,ownProps=objectTypes[typeof iterable]&&keys(iterable),length=ownProps?ownProps.length:0;while(++ownIndex<length){index=ownProps[ownIndex];if(typeof result[index]=="undefined")result[index]=iterable[index]}}}return result};function findKey(object,callback,thisArg){var result;callback=lodash.createCallback(callback,thisArg,3);forOwn(object,function(value,key,object){if(callback(value,key,object)){result=key;return false}});return result}function findLastKey(object,callback,thisArg){var result;callback=lodash.createCallback(callback,thisArg,3);forOwnRight(object,function(value,key,object){if(callback(value,key,object)){result=key;return false}});return result}var forIn=function(collection,callback,thisArg){var index,iterable=collection,result=iterable;if(!iterable)return result;if(!objectTypes[typeof iterable])return result;callback=callback&&typeof thisArg=="undefined"?callback:baseCreateCallback(callback,thisArg,3);for(index in iterable){if(callback(iterable[index],index,collection)===false)return result}return result};function forInRight(object,callback,thisArg){var pairs=[];forIn(object,function(value,key){pairs.push(key,value)});var length=pairs.length;callback=baseCreateCallback(callback,thisArg,3);while(length--){if(callback(pairs[length--],pairs[length],object)===false){break}}return object}var forOwn=function(collection,callback,thisArg){var index,iterable=collection,result=iterable;if(!iterable)return result;if(!objectTypes[typeof iterable])return result;callback=callback&&typeof thisArg=="undefined"?callback:baseCreateCallback(callback,thisArg,3);var ownIndex=-1,ownProps=objectTypes[typeof iterable]&&keys(iterable),length=ownProps?ownProps.length:0;while(++ownIndex<length){index=ownProps[ownIndex];if(callback(iterable[index],index,collection)===false)return result}return result};function forOwnRight(object,callback,thisArg){var props=keys(object),length=props.length;callback=baseCreateCallback(callback,thisArg,3);while(length--){var key=props[length];if(callback(object[key],key,object)===false){break}}return object}function functions(object){var result=[];forIn(object,function(value,key){if(isFunction(value)){result.push(key)}});return result.sort()}function has(object,key){return object?hasOwnProperty.call(object,key):false}function invert(object){var index=-1,props=keys(object),length=props.length,result={};while(++index<length){var key=props[index];result[object[key]]=key}return result}function isBoolean(value){return value===true||value===false||value&&typeof value=="object"&&toString.call(value)==boolClass||false}function isDate(value){return value&&typeof value=="object"&&toString.call(value)==dateClass||false}function isElement(value){return value&&value.nodeType===1||false}function isEmpty(value){var result=true;if(!value){return result}var className=toString.call(value),length=value.length;if(className==arrayClass||className==stringClass||className==argsClass||className==objectClass&&typeof length=="number"&&isFunction(value.splice)){return!length}forOwn(value,function(){return result=false});return result}function isEqual(a,b,callback,thisArg){return baseIsEqual(a,b,typeof callback=="function"&&baseCreateCallback(callback,thisArg,2))}function isFinite(value){return nativeIsFinite(value)&&!nativeIsNaN(parseFloat(value)) | |
}function isFunction(value){return typeof value=="function"}function isObject(value){return!!(value&&objectTypes[typeof value])}function isNaN(value){return isNumber(value)&&value!=+value}function isNull(value){return value===null}function isNumber(value){return typeof value=="number"||value&&typeof value=="object"&&toString.call(value)==numberClass||false}var isPlainObject=!getPrototypeOf?shimIsPlainObject:function(value){if(!(value&&toString.call(value)==objectClass)){return false}var valueOf=value.valueOf,objProto=isNative(valueOf)&&(objProto=getPrototypeOf(valueOf))&&getPrototypeOf(objProto);return objProto?value==objProto||getPrototypeOf(value)==objProto:shimIsPlainObject(value)};function isRegExp(value){return value&&typeof value=="object"&&toString.call(value)==regexpClass||false}function isString(value){return typeof value=="string"||value&&typeof value=="object"&&toString.call(value)==stringClass||false}function isUndefined(value){return typeof value=="undefined"}function mapValues(object,callback,thisArg){var result={};callback=lodash.createCallback(callback,thisArg,3);forOwn(object,function(value,key,object){result[key]=callback(value,key,object)});return result}function merge(object){var args=arguments,length=2;if(!isObject(object)){return object}if(typeof args[2]!="number"){length=args.length}if(length>3&&typeof args[length-2]=="function"){var callback=baseCreateCallback(args[--length-1],args[length--],2)}else if(length>2&&typeof args[length-1]=="function"){callback=args[--length]}var sources=slice(arguments,1,length),index=-1,stackA=getArray(),stackB=getArray();while(++index<length){baseMerge(object,sources[index],callback,stackA,stackB)}releaseArray(stackA);releaseArray(stackB);return object}function omit(object,callback,thisArg){var result={};if(typeof callback!="function"){var props=[];forIn(object,function(value,key){props.push(key)});props=baseDifference(props,baseFlatten(arguments,true,false,1));var index=-1,length=props.length;while(++index<length){var key=props[index];result[key]=object[key]}}else{callback=lodash.createCallback(callback,thisArg,3);forIn(object,function(value,key,object){if(!callback(value,key,object)){result[key]=value}})}return result}function pairs(object){var index=-1,props=keys(object),length=props.length,result=Array(length);while(++index<length){var key=props[index];result[index]=[key,object[key]]}return result}function pick(object,callback,thisArg){var result={};if(typeof callback!="function"){var index=-1,props=baseFlatten(arguments,true,false,1),length=isObject(object)?props.length:0;while(++index<length){var key=props[index];if(key in object){result[key]=object[key]}}}else{callback=lodash.createCallback(callback,thisArg,3);forIn(object,function(value,key,object){if(callback(value,key,object)){result[key]=value}})}return result}function transform(object,callback,accumulator,thisArg){var isArr=isArray(object);if(accumulator==null){if(isArr){accumulator=[]}else{var ctor=object&&object.constructor,proto=ctor&&ctor.prototype;accumulator=baseCreate(proto)}}if(callback){callback=lodash.createCallback(callback,thisArg,4);(isArr?forEach:forOwn)(object,function(value,index,object){return callback(accumulator,value,index,object)})}return accumulator}function values(object){var index=-1,props=keys(object),length=props.length,result=Array(length);while(++index<length){result[index]=object[props[index]]}return result}function at(collection){var args=arguments,index=-1,props=baseFlatten(args,true,false,1),length=args[2]&&args[2][args[1]]===collection?1:props.length,result=Array(length);while(++index<length){result[index]=collection[props[index]]}return result}function contains(collection,target,fromIndex){var index=-1,indexOf=getIndexOf(),length=collection?collection.length:0,result=false;fromIndex=(fromIndex<0?nativeMax(0,length+fromIndex):fromIndex)||0;if(isArray(collection)){result=indexOf(collection,target,fromIndex)>-1}else if(typeof length=="number"){result=(isString(collection)?collection.indexOf(target,fromIndex):indexOf(collection,target,fromIndex))>-1}else{forOwn(collection,function(value){if(++index>=fromIndex){return!(result=value===target)}})}return result}var countBy=createAggregator(function(result,value,key){hasOwnProperty.call(result,key)?result[key]++:result[key]=1});function every(collection,callback,thisArg){var result=true;callback=lodash.createCallback(callback,thisArg,3);var index=-1,length=collection?collection.length:0;if(typeof length=="number"){while(++index<length){if(!(result=!!callback(collection[index],index,collection))){break}}}else{forOwn(collection,function(value,index,collection){return result=!!callback(value,index,collection)})}return result}function filter(collection,callback,thisArg){var result=[];callback=lodash.createCallback(callback,thisArg,3);var index=-1,length=collection?collection.length:0;if(typeof length=="number"){while(++index<length){var value=collection[index];if(callback(value,index,collection)){result.push(value)}}}else{forOwn(collection,function(value,index,collection){if(callback(value,index,collection)){result.push(value)}})}return result}function find(collection,callback,thisArg){callback=lodash.createCallback(callback,thisArg,3);var index=-1,length=collection?collection.length:0;if(typeof length=="number"){while(++index<length){var value=collection[index];if(callback(value,index,collection)){return value}}}else{var result;forOwn(collection,function(value,index,collection){if(callback(value,index,collection)){result=value;return false}});return result}}function findLast(collection,callback,thisArg){var result;callback=lodash.createCallback(callback,thisArg,3);forEachRight(collection,function(value,index,collection){if(callback(value,index,collection)){result=value;return false}});return result}function forEach(collection,callback,thisArg){var index=-1,length=collection?collection.length:0;callback=callback&&typeof thisArg=="undefined"?callback:baseCreateCallback(callback,thisArg,3);if(typeof length=="number"){while(++index<length){if(callback(collection[index],index,collection)===false){break}}}else{forOwn(collection,callback)}return collection}function forEachRight(collection,callback,thisArg){var length=collection?collection.length:0;callback=callback&&typeof thisArg=="undefined"?callback:baseCreateCallback(callback,thisArg,3);if(typeof length=="number"){while(length--){if(callback(collection[length],length,collection)===false){break}}}else{var props=keys(collection);length=props.length;forOwn(collection,function(value,key,collection){key=props?props[--length]:--length;return callback(collection[key],key,collection)})}return collection}var groupBy=createAggregator(function(result,value,key){(hasOwnProperty.call(result,key)?result[key]:result[key]=[]).push(value)});var indexBy=createAggregator(function(result,value,key){result[key]=value});function invoke(collection,methodName){var args=slice(arguments,2),index=-1,isFunc=typeof methodName=="function",length=collection?collection.length:0,result=Array(typeof length=="number"?length:0);forEach(collection,function(value){result[++index]=(isFunc?methodName:value[methodName]).apply(value,args)});return result}function map(collection,callback,thisArg){var index=-1,length=collection?collection.length:0;callback=lodash.createCallback(callback,thisArg,3);if(typeof length=="number"){var result=Array(length);while(++index<length){result[index]=callback(collection[index],index,collection)}}else{result=[];forOwn(collection,function(value,key,collection){result[++index]=callback(value,key,collection)})}return result}function max(collection,callback,thisArg){var computed=-Infinity,result=computed;if(typeof callback!="function"&&thisArg&&thisArg[callback]===collection){callback=null}if(callback==null&&isArray(collection)){var index=-1,length=collection.length;while(++index<length){var value=collection[index];if(value>result){result=value}}}else{callback=callback==null&&isString(collection)?charAtCallback:lodash.createCallback(callback,thisArg,3);forEach(collection,function(value,index,collection){var current=callback(value,index,collection);if(current>computed){computed=current;result=value}})}return result}function min(collection,callback,thisArg){var computed=Infinity,result=computed;if(typeof callback!="function"&&thisArg&&thisArg[callback]===collection){callback=null}if(callback==null&&isArray(collection)){var index=-1,length=collection.length;while(++index<length){var value=collection[index];if(value<result){result=value}}}else{callback=callback==null&&isString(collection)?charAtCallback:lodash.createCallback(callback,thisArg,3);forEach(collection,function(value,index,collection){var current=callback(value,index,collection);if(current<computed){computed=current;result=value}})}return result}var pluck=map;function reduce(collection,callback,accumulator,thisArg){if(!collection)return accumulator;var noaccum=arguments.length<3;callback=lodash.createCallback(callback,thisArg,4);var index=-1,length=collection.length;if(typeof length=="number"){if(noaccum){accumulator=collection[++index]}while(++index<length){accumulator=callback(accumulator,collection[index],index,collection)}}else{forOwn(collection,function(value,index,collection){accumulator=noaccum?(noaccum=false,value):callback(accumulator,value,index,collection)})}return accumulator}function reduceRight(collection,callback,accumulator,thisArg){var noaccum=arguments.length<3;callback=lodash.createCallback(callback,thisArg,4);forEachRight(collection,function(value,index,collection){accumulator=noaccum?(noaccum=false,value):callback(accumulator,value,index,collection)});return accumulator}function reject(collection,callback,thisArg){callback=lodash.createCallback(callback,thisArg,3);return filter(collection,function(value,index,collection){return!callback(value,index,collection)})}function sample(collection,n,guard){if(collection&&typeof collection.length!="number"){collection=values(collection)}if(n==null||guard){return collection?collection[baseRandom(0,collection.length-1)]:undefined}var result=shuffle(collection);result.length=nativeMin(nativeMax(0,n),result.length);return result}function shuffle(collection){var index=-1,length=collection?collection.length:0,result=Array(typeof length=="number"?length:0);forEach(collection,function(value){var rand=baseRandom(0,++index);result[index]=result[rand];result[rand]=value});return result}function size(collection){var length=collection?collection.length:0;return typeof length=="number"?length:keys(collection).length}function some(collection,callback,thisArg){var result;callback=lodash.createCallback(callback,thisArg,3);var index=-1,length=collection?collection.length:0;if(typeof length=="number"){while(++index<length){if(result=callback(collection[index],index,collection)){break}}}else{forOwn(collection,function(value,index,collection){return!(result=callback(value,index,collection))})}return!!result}function sortBy(collection,callback,thisArg){var index=-1,isArr=isArray(callback),length=collection?collection.length:0,result=Array(typeof length=="number"?length:0);if(!isArr){callback=lodash.createCallback(callback,thisArg,3)}forEach(collection,function(value,key,collection){var object=result[++index]=getObject();if(isArr){object.criteria=map(callback,function(key){return value[key]})}else{(object.criteria=getArray())[0]=callback(value,key,collection)}object.index=index;object.value=value});length=result.length;result.sort(compareAscending);while(length--){var object=result[length];result[length]=object.value;if(!isArr){releaseArray(object.criteria)}releaseObject(object)}return result}function toArray(collection){if(collection&&typeof collection.length=="number"){return slice(collection)}return values(collection)}var where=filter;function compact(array){var index=-1,length=array?array.length:0,result=[];while(++index<length){var value=array[index];if(value){result.push(value)}}return result}function difference(array){return baseDifference(array,baseFlatten(arguments,true,true,1))}function findIndex(array,callback,thisArg){var index=-1,length=array?array.length:0;callback=lodash.createCallback(callback,thisArg,3);while(++index<length){if(callback(array[index],index,array)){return index}}return-1}function findLastIndex(array,callback,thisArg){var length=array?array.length:0;callback=lodash.createCallback(callback,thisArg,3);while(length--){if(callback(array[length],length,array)){return length}}return-1}function first(array,callback,thisArg){var n=0,length=array?array.length:0;if(typeof callback!="number"&&callback!=null){var index=-1;callback=lodash.createCallback(callback,thisArg,3);while(++index<length&&callback(array[index],index,array)){n++}}else{n=callback;if(n==null||thisArg){return array?array[0]:undefined}}return slice(array,0,nativeMin(nativeMax(0,n),length))}function flatten(array,isShallow,callback,thisArg){if(typeof isShallow!="boolean"&&isShallow!=null){thisArg=callback;callback=typeof isShallow!="function"&&thisArg&&thisArg[isShallow]===array?null:isShallow;isShallow=false}if(callback!=null){array=map(array,callback,thisArg)}return baseFlatten(array,isShallow)}function indexOf(array,value,fromIndex){if(typeof fromIndex=="number"){var length=array?array.length:0;fromIndex=fromIndex<0?nativeMax(0,length+fromIndex):fromIndex||0}else if(fromIndex){var index=sortedIndex(array,value);return array[index]===value?index:-1}return baseIndexOf(array,value,fromIndex)}function initial(array,callback,thisArg){var n=0,length=array?array.length:0;if(typeof callback!="number"&&callback!=null){var index=length;callback=lodash.createCallback(callback,thisArg,3);while(index--&&callback(array[index],index,array)){n++}}else{n=callback==null||thisArg?1:callback||n}return slice(array,0,nativeMin(nativeMax(0,length-n),length))}function intersection(){var args=[],argsIndex=-1,argsLength=arguments.length,caches=getArray(),indexOf=getIndexOf(),trustIndexOf=indexOf===baseIndexOf,seen=getArray();while(++argsIndex<argsLength){var value=arguments[argsIndex];if(isArray(value)||isArguments(value)){args.push(value);caches.push(trustIndexOf&&value.length>=largeArraySize&&createCache(argsIndex?args[argsIndex]:seen))}}var array=args[0],index=-1,length=array?array.length:0,result=[];outer:while(++index<length){var cache=caches[0];value=array[index];if((cache?cacheIndexOf(cache,value):indexOf(seen,value))<0){argsIndex=argsLength;(cache||seen).push(value);while(--argsIndex){cache=caches[argsIndex];if((cache?cacheIndexOf(cache,value):indexOf(args[argsIndex],value))<0){continue outer}}result.push(value)}}while(argsLength--){cache=caches[argsLength];if(cache){releaseObject(cache)}}releaseArray(caches);releaseArray(seen);return result}function last(array,callback,thisArg){var n=0,length=array?array.length:0;if(typeof callback!="number"&&callback!=null){var index=length;callback=lodash.createCallback(callback,thisArg,3);while(index--&&callback(array[index],index,array)){n++}}else{n=callback;if(n==null||thisArg){return array?array[length-1]:undefined}}return slice(array,nativeMax(0,length-n))}function lastIndexOf(array,value,fromIndex){var index=array?array.length:0;if(typeof fromIndex=="number"){index=(fromIndex<0?nativeMax(0,index+fromIndex):nativeMin(fromIndex,index-1))+1}while(index--){if(array[index]===value){return index}}return-1}function pull(array){var args=arguments,argsIndex=0,argsLength=args.length,length=array?array.length:0;while(++argsIndex<argsLength){var index=-1,value=args[argsIndex];while(++index<length){if(array[index]===value){splice.call(array,index--,1);length--}}}return array}function range(start,end,step){start=+start||0;step=typeof step=="number"?step:+step||1;if(end==null){end=start;start=0}var index=-1,length=nativeMax(0,ceil((end-start)/(step||1))),result=Array(length);while(++index<length){result[index]=start;start+=step}return result}function remove(array,callback,thisArg){var index=-1,length=array?array.length:0,result=[];callback=lodash.createCallback(callback,thisArg,3);while(++index<length){var value=array[index];if(callback(value,index,array)){result.push(value);splice.call(array,index--,1);length--}}return result}function rest(array,callback,thisArg){if(typeof callback!="number"&&callback!=null){var n=0,index=-1,length=array?array.length:0;callback=lodash.createCallback(callback,thisArg,3);while(++index<length&&callback(array[index],index,array)){n++}}else{n=callback==null||thisArg?1:nativeMax(0,callback)}return slice(array,n)}function sortedIndex(array,value,callback,thisArg){var low=0,high=array?array.length:low;callback=callback?lodash.createCallback(callback,thisArg,1):identity;value=callback(value);while(low<high){var mid=low+high>>>1;callback(array[mid])<value?low=mid+1:high=mid}return low}function union(){return baseUniq(baseFlatten(arguments,true,true))}function uniq(array,isSorted,callback,thisArg){if(typeof isSorted!="boolean"&&isSorted!=null){thisArg=callback;callback=typeof isSorted!="function"&&thisArg&&thisArg[isSorted]===array?null:isSorted;isSorted=false}if(callback!=null){callback=lodash.createCallback(callback,thisArg,3)}return baseUniq(array,isSorted,callback)}function without(array){return baseDifference(array,slice(arguments,1))}function xor(){var index=-1,length=arguments.length;while(++index<length){var array=arguments[index];if(isArray(array)||isArguments(array)){var result=result?baseUniq(baseDifference(result,array).concat(baseDifference(array,result))):array}}return result||[]}function zip(){var array=arguments.length>1?arguments:arguments[0],index=-1,length=array?max(pluck(array,"length")):0,result=Array(length<0?0:length);while(++index<length){result[index]=pluck(array,index)}return result}function zipObject(keys,values){var index=-1,length=keys?keys.length:0,result={};if(!values&&length&&!isArray(keys[0])){values=[]}while(++index<length){var key=keys[index];if(values){result[key]=values[index]}else if(key){result[key[0]]=key[1]}}return result}function after(n,func){if(!isFunction(func)){throw new TypeError}return function(){if(--n<1){return func.apply(this,arguments)}}}function bind(func,thisArg){return arguments.length>2?createWrapper(func,17,slice(arguments,2),null,thisArg):createWrapper(func,1,null,null,thisArg)}function bindAll(object){var funcs=arguments.length>1?baseFlatten(arguments,true,false,1):functions(object),index=-1,length=funcs.length;while(++index<length){var key=funcs[index];object[key]=createWrapper(object[key],1,null,null,object)}return object}function bindKey(object,key){return arguments.length>2?createWrapper(key,19,slice(arguments,2),null,object):createWrapper(key,3,null,null,object)}function compose(){var funcs=arguments,length=funcs.length;while(length--){if(!isFunction(funcs[length])){throw new TypeError}}return function(){var args=arguments,length=funcs.length;while(length--){args=[funcs[length].apply(this,args)]}return args[0]}}function curry(func,arity){arity=typeof arity=="number"?arity:+arity||func.length;return createWrapper(func,4,null,null,null,arity)}function debounce(func,wait,options){var args,maxTimeoutId,result,stamp,thisArg,timeoutId,trailingCall,lastCalled=0,maxWait=false,trailing=true;if(!isFunction(func)){throw new TypeError}wait=nativeMax(0,wait)||0;if(options===true){var leading=true;trailing=false}else if(isObject(options)){leading=options.leading;maxWait="maxWait"in options&&(nativeMax(wait,options.maxWait)||0);trailing="trailing"in options?options.trailing:trailing}var delayed=function(){var remaining=wait-(now()-stamp);if(remaining<=0){if(maxTimeoutId){clearTimeout(maxTimeoutId)}var isCalled=trailingCall;maxTimeoutId=timeoutId=trailingCall=undefined;if(isCalled){lastCalled=now();result=func.apply(thisArg,args);if(!timeoutId&&!maxTimeoutId){args=thisArg=null}}}else{timeoutId=setTimeout(delayed,remaining)}};var maxDelayed=function(){if(timeoutId){clearTimeout(timeoutId)}maxTimeoutId=timeoutId=trailingCall=undefined;if(trailing||maxWait!==wait){lastCalled=now();result=func.apply(thisArg,args);if(!timeoutId&&!maxTimeoutId){args=thisArg=null}}};return function(){args=arguments;stamp=now();thisArg=this;trailingCall=trailing&&(timeoutId||!leading);if(maxWait===false){var leadingCall=leading&&!timeoutId}else{if(!maxTimeoutId&&!leading){lastCalled=stamp}var remaining=maxWait-(stamp-lastCalled),isCalled=remaining<=0;if(isCalled){if(maxTimeoutId){maxTimeoutId=clearTimeout(maxTimeoutId)}lastCalled=stamp;result=func.apply(thisArg,args)}else if(!maxTimeoutId){maxTimeoutId=setTimeout(maxDelayed,remaining)}}if(isCalled&&timeoutId){timeoutId=clearTimeout(timeoutId)}else if(!timeoutId&&wait!==maxWait){timeoutId=setTimeout(delayed,wait)}if(leadingCall){isCalled=true;result=func.apply(thisArg,args)}if(isCalled&&!timeoutId&&!maxTimeoutId){args=thisArg=null}return result}}function defer(func){if(!isFunction(func)){throw new TypeError}var args=slice(arguments,1);return setTimeout(function(){func.apply(undefined,args)},1)}function delay(func,wait){if(!isFunction(func)){throw new TypeError}var args=slice(arguments,2);return setTimeout(function(){func.apply(undefined,args)},wait)}function memoize(func,resolver){if(!isFunction(func)){throw new TypeError}var memoized=function(){var cache=memoized.cache,key=resolver?resolver.apply(this,arguments):keyPrefix+arguments[0];return hasOwnProperty.call(cache,key)?cache[key]:cache[key]=func.apply(this,arguments)};memoized.cache={};return memoized}function once(func){var ran,result;if(!isFunction(func)){throw new TypeError}return function(){if(ran){return result}ran=true;result=func.apply(this,arguments);func=null;return result}}function partial(func){return createWrapper(func,16,slice(arguments,1))}function partialRight(func){return createWrapper(func,32,null,slice(arguments,1))}function throttle(func,wait,options){var leading=true,trailing=true;if(!isFunction(func)){throw new TypeError}if(options===false){leading=false}else if(isObject(options)){leading="leading"in options?options.leading:leading;trailing="trailing"in options?options.trailing:trailing}debounceOptions.leading=leading;debounceOptions.maxWait=wait;debounceOptions.trailing=trailing;return debounce(func,wait,debounceOptions)}function wrap(value,wrapper){return createWrapper(wrapper,16,[value])}function constant(value){return function(){return value}}function createCallback(func,thisArg,argCount){var type=typeof func;if(func==null||type=="function"){return baseCreateCallback(func,thisArg,argCount)}if(type!="object"){return property(func)}var props=keys(func),key=props[0],a=func[key];if(props.length==1&&a===a&&!isObject(a)){return function(object){var b=object[key];return a===b&&(a!==0||1/a==1/b)}}return function(object){var length=props.length,result=false;while(length--){if(!(result=baseIsEqual(object[props[length]],func[props[length]],null,true))){break}}return result}}function escape(string){return string==null?"":String(string).replace(reUnescapedHtml,escapeHtmlChar)}function identity(value){return value}function mixin(object,source,options){var chain=true,methodNames=source&&functions(source);if(!source||!options&&!methodNames.length){if(options==null){options=source}ctor=lodashWrapper;source=object;object=lodash;methodNames=functions(source)}if(options===false){chain=false}else if(isObject(options)&&"chain"in options){chain=options.chain}var ctor=object,isFunc=isFunction(ctor);forEach(methodNames,function(methodName){var func=object[methodName]=source[methodName];if(isFunc){ctor.prototype[methodName]=function(){var chainAll=this.__chain__,value=this.__wrapped__,args=[value];push.apply(args,arguments);var result=func.apply(object,args);if(chain||chainAll){if(value===result&&isObject(result)){return this}result=new ctor(result);result.__chain__=chainAll}return result}}})}function noConflict(){context._=oldDash;return this}function noop(){}var now=isNative(now=Date.now)&&now||function(){return(new Date).getTime()};var parseInt=nativeParseInt(whitespace+"08")==8?nativeParseInt:function(value,radix){return nativeParseInt(isString(value)?value.replace(reLeadingSpacesAndZeros,""):value,radix||0)};function property(key){return function(object){return object[key]}}function random(min,max,floating){var noMin=min==null,noMax=max==null;if(floating==null){if(typeof min=="boolean"&&noMax){floating=min;min=1}else if(!noMax&&typeof max=="boolean"){floating=max;noMax=true}}if(noMin&&noMax){max=1}min=+min||0;if(noMax){max=min;min=0}else{max=+max||0}if(floating||min%1||max%1){var rand=nativeRandom();return nativeMin(min+rand*(max-min+parseFloat("1e-"+((rand+"").length-1))),max)}return baseRandom(min,max)}function result(object,key){if(object){var value=object[key];return isFunction(value)?object[key]():value}}function template(text,data,options){var settings=lodash.templateSettings;text=String(text||"");options=defaults({},options,settings);var imports=defaults({},options.imports,settings.imports),importsKeys=keys(imports),importsValues=values(imports);var isEvaluating,index=0,interpolate=options.interpolate||reNoMatch,source="__p += '";var reDelimiters=RegExp((options.escape||reNoMatch).source+"|"+interpolate.source+"|"+(interpolate===reInterpolate?reEsTemplate:reNoMatch).source+"|"+(options.evaluate||reNoMatch).source+"|$","g");text.replace(reDelimiters,function(match,escapeValue,interpolateValue,esTemplateValue,evaluateValue,offset){interpolateValue||(interpolateValue=esTemplateValue);source+=text.slice(index,offset).replace(reUnescapedString,escapeStringChar);if(escapeValue){source+="' +\n__e("+escapeValue+") +\n'"}if(evaluateValue){isEvaluating=true;source+="';\n"+evaluateValue+";\n__p += '"}if(interpolateValue){source+="' +\n((__t = ("+interpolateValue+")) == null ? '' : __t) +\n'"}index=offset+match.length;return match});source+="';\n";var variable=options.variable,hasVariable=variable;if(!hasVariable){variable="obj";source="with ("+variable+") {\n"+source+"\n}\n"}source=(isEvaluating?source.replace(reEmptyStringLeading,""):source).replace(reEmptyStringMiddle,"$1").replace(reEmptyStringTrailing,"$1;");source="function("+variable+") {\n"+(hasVariable?"":variable+" || ("+variable+" = {});\n")+"var __t, __p = '', __e = _.escape"+(isEvaluating?", __j = Array.prototype.join;\n"+"function print() { __p += __j.call(arguments, '') }\n":";\n")+source+"return __p\n}";var sourceURL="\n/*\n//# sourceURL="+(options.sourceURL||"/lodash/template/source["+templateCounter++ +"]")+"\n*/";try{var result=Function(importsKeys,"return "+source+sourceURL).apply(undefined,importsValues)}catch(e){e.source=source;throw e}if(data){return result(data)}result.source=source;return result}function times(n,callback,thisArg){n=(n=+n)>-1?n:0;var index=-1,result=Array(n);callback=baseCreateCallback(callback,thisArg,1);while(++index<n){result[index]=callback(index)}return result}function unescape(string){return string==null?"":String(string).replace(reEscapedHtml,unescapeHtmlChar)}function uniqueId(prefix){var id=++idCounter;return String(prefix==null?"":prefix)+id}function chain(value){value=new lodashWrapper(value);value.__chain__=true;return value}function tap(value,interceptor){interceptor(value);return value}function wrapperChain(){this.__chain__=true;return this}function wrapperToString(){return String(this.__wrapped__)}function wrapperValueOf(){return this.__wrapped__}lodash.after=after;lodash.assign=assign;lodash.at=at;lodash.bind=bind;lodash.bindAll=bindAll;lodash.bindKey=bindKey;lodash.chain=chain;lodash.compact=compact;lodash.compose=compose;lodash.constant=constant;lodash.countBy=countBy;lodash.create=create;lodash.createCallback=createCallback;lodash.curry=curry;lodash.debounce=debounce;lodash.defaults=defaults;lodash.defer=defer;lodash.delay=delay;lodash.difference=difference;lodash.filter=filter;lodash.flatten=flatten;lodash.forEach=forEach;lodash.forEachRight=forEachRight;lodash.forIn=forIn;lodash.forInRight=forInRight;lodash.forOwn=forOwn;lodash.forOwnRight=forOwnRight;lodash.functions=functions;lodash.groupBy=groupBy;lodash.indexBy=indexBy;lodash.initial=initial;lodash.intersection=intersection;lodash.invert=invert;lodash.invoke=invoke;lodash.keys=keys;lodash.map=map;lodash.mapValues=mapValues;lodash.max=max;lodash.memoize=memoize;lodash.merge=merge;lodash.min=min;lodash.omit=omit;lodash.once=once;lodash.pairs=pairs;lodash.partial=partial;lodash.partialRight=partialRight;lodash.pick=pick;lodash.pluck=pluck;lodash.property=property;lodash.pull=pull;lodash.range=range;lodash.reject=reject;lodash.remove=remove;lodash.rest=rest;lodash.shuffle=shuffle;lodash.sortBy=sortBy;lodash.tap=tap;lodash.throttle=throttle;lodash.times=times;lodash.toArray=toArray;lodash.transform=transform;lodash.union=union;lodash.uniq=uniq;lodash.values=values;lodash.where=where;lodash.without=without;lodash.wrap=wrap;lodash.xor=xor;lodash.zip=zip;lodash.zipObject=zipObject;lodash.collect=map;lodash.drop=rest;lodash.each=forEach;lodash.eachRight=forEachRight;lodash.extend=assign;lodash.methods=functions;lodash.object=zipObject;lodash.select=filter;lodash.tail=rest;lodash.unique=uniq;lodash.unzip=zip;mixin(lodash);lodash.clone=clone;lodash.cloneDeep=cloneDeep;lodash.contains=contains;lodash.escape=escape;lodash.every=every;lodash.find=find;lodash.findIndex=findIndex;lodash.findKey=findKey;lodash.findLast=findLast;lodash.findLastIndex=findLastIndex;lodash.findLastKey=findLastKey;lodash.has=has;lodash.identity=identity;lodash.indexOf=indexOf;lodash.isArguments=isArguments;lodash.isArray=isArray;lodash.isBoolean=isBoolean;lodash.isDate=isDate;lodash.isElement=isElement;lodash.isEmpty=isEmpty;lodash.isEqual=isEqual;lodash.isFinite=isFinite;lodash.isFunction=isFunction;lodash.isNaN=isNaN;lodash.isNull=isNull;lodash.isNumber=isNumber;lodash.isObject=isObject;lodash.isPlainObject=isPlainObject;lodash.isRegExp=isRegExp;lodash.isString=isString;lodash.isUndefined=isUndefined;lodash.lastIndexOf=lastIndexOf;lodash.mixin=mixin;lodash.noConflict=noConflict;lodash.noop=noop;lodash.now=now;lodash.parseInt=parseInt;lodash.random=random;lodash.reduce=reduce;lodash.reduceRight=reduceRight;lodash.result=result;lodash.runInContext=runInContext;lodash.size=size;lodash.some=some;lodash.sortedIndex=sortedIndex;lodash.template=template;lodash.unescape=unescape;lodash.uniqueId=uniqueId;lodash.all=every;lodash.any=some;lodash.detect=find;lodash.findWhere=find;lodash.foldl=reduce;lodash.foldr=reduceRight;lodash.include=contains;lodash.inject=reduce;mixin(function(){var source={};forOwn(lodash,function(func,methodName){if(!lodash.prototype[methodName]){source[methodName]=func}});return source}(),false);lodash.first=first;lodash.last=last;lodash.sample=sample;lodash.take=first;lodash.head=first;forOwn(lodash,function(func,methodName){var callbackable=methodName!=="sample";if(!lodash.prototype[methodName]){lodash.prototype[methodName]=function(n,guard){var chainAll=this.__chain__,result=func(this.__wrapped__,n,guard);return!chainAll&&(n==null||guard&&!(callbackable&&typeof n=="function"))?result:new lodashWrapper(result,chainAll)}}});lodash.VERSION="2.4.1";lodash.prototype.chain=wrapperChain;lodash.prototype.toString=wrapperToString;lodash.prototype.value=wrapperValueOf;lodash.prototype.valueOf=wrapperValueOf;forEach(["join","pop","shift"],function(methodName){var func=arrayRef[methodName];lodash.prototype[methodName]=function(){var chainAll=this.__chain__,result=func.apply(this.__wrapped__,arguments);return chainAll?new lodashWrapper(result,chainAll):result}});forEach(["push","reverse","sort","unshift"],function(methodName){var func=arrayRef[methodName];lodash.prototype[methodName]=function(){func.apply(this.__wrapped__,arguments);return this}});forEach(["concat","slice","splice"],function(methodName){var func=arrayRef[methodName];lodash.prototype[methodName]=function(){return new lodashWrapper(func.apply(this.__wrapped__,arguments),this.__chain__)}});return lodash}var _=runInContext();if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){root._=_;define(function(){return _})}else if(freeExports&&freeModule){if(moduleExports){(freeModule.exports=_)._=_}else{freeExports._=_ | |
}}else{root._=_}}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}]},{},[]);var Immutable=require("immutable"),_=require("lodash"),IMap=Immutable.Map,IVector=Immutable.Vector;var messagesData=[{id:"m_1",threadID:"t_1",threadName:"Jing and Bill",authorName:"Bill",text:"Hey Jing, want to give a Flux talk at ForwardJS?",date:new Date(Date.now()-99999)},{id:"m_2",threadID:"t_1",threadName:"Jing and Bill",authorName:"Bill",text:"Seems like a pretty cool conference.",date:new Date(Date.now()-89999)}];var newMessageData={id:"m_3",threadID:"t_1",threadName:"Jing and Bill",authorName:"Bill",text:"Ohnoes, this might go wrong",date:new Date(Date.now()-39999)};var messages=IMap();var messagesSortedByDate=IVector();var currentThreadID="t_1";addMessages(messagesData);var oldMessages=messages;var oldMessagesSortedByDate=messagesSortedByDate;var oldMessagesByThread=getMessagesForThread(currentThreadID);addMessages([newMessageData]);var newMessagesByThread=getMessagesForThread(currentThreadID);console.log(oldMessagesByThread.count(),oldMessagesByThread,newMessagesByThread);console.assert(Immutable.is(oldMessagesByThread,newMessagesByThread)===false,"shouldn't be equal");function addMessages(rawMessages){var messageIds=_.pluck(rawMessages,"id");var newMessages=IMap.from(_.zip(messageIds,_.map(rawMessages,function(message){return IMap.from(message)})));messages=messages.merge(newMessages);messagesSortedByDate=IVector.from(messages.keySeq()).sort(function(a,b){var dateA=messages.getIn([a,"date"]),dateB=messages.getIn([b,"date"]);if(dateA<dateB){return-1}else if(dateA>dateB){return 1}else{return 0}})}function getMessagesForThread(threadID){return messagesSortedByDate.map(function(messageId){return messages.get(messageId)}).filter(function(message){return message.get("threadID")===threadID})} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "requirebin-sketch", | |
"version": "1.0.0", | |
"dependencies": { | |
"immutable": "2.1.0", | |
"lodash": "2.4.1" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; } | |
body, html { height: 100%; width: 100%; }</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment