diff --git a/Gruntfile.js b/Gruntfile.js index 04352ad..678ce9a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,6 +1,8 @@ /*global module:false*/ module.exports = function (grunt) { // Project configuration. + var path = require("path"), + child = require("child_process"); grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), jshint: { @@ -48,9 +50,37 @@ module.exports = function (grunt) { }); // Default task. - grunt.registerTask('default', ['jshint', 'it', 'browserify:nools', 'uglify:min']); + grunt.registerTask('default', ['jshint', "compile-tests", 'it', 'browserify:nools', 'uglify:min']); grunt.loadNpmTasks('grunt-it'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-browserify'); + + grunt.registerTask("compile-tests", "compiles all lest files", function () { + var files = grunt.file.expand("./test/rules/*.nools"), count = files.length, done = this.async(); + + function counter(err) { + if (err) { + done(err); + } else { + count--; + if (!count) { + done(); + } + } + } + + files.forEach(function (file) { + var base = path.basename(file, ".nools"), + out = path.resolve(path.dirname(file), base + "-compiled.js"); + child.exec(path.resolve(__dirname, "./bin/nools") + " compile " + file + " -l ../../ -n " + base + "-compiled", function (err, output) { + if (!err) { + grunt.file.write(out, output.toString()); + } + counter(err); + }); + }); + + + }); }; diff --git a/benchmark/manners/benchmark.js b/benchmark/manners/benchmark.js index fe12e25..3bed7a0 100644 --- a/benchmark/manners/benchmark.js +++ b/benchmark/manners/benchmark.js @@ -4,7 +4,7 @@ nools = require("../../index"); var flow = nools.compile(__dirname + "/manners.nools"); - var guests = data.load(flow).manners32; + var guests = data.load(flow).manners64; var session = flow.getSession.apply(flow, guests); session.assert(new (flow.getDefined("count"))({value: 1})); var start = new Date(); diff --git a/bin/nools b/bin/nools index 4ba2596..4d94869 100755 --- a/bin/nools +++ b/bin/nools @@ -5,6 +5,7 @@ var nools = require(".."), path = require("path"), fs = require("fs"), path = require("path"), + stdout = process.stdout, template = fs.readFileSync(path.join(__dirname, "assets", "compile_wrapper.tmpl"), "utf8"), str = require("string-extended"), uglifyjs = require("uglify-js"), @@ -42,7 +43,7 @@ program.command("compile") var noolsLocation = program["nools_location"] || "nools"; files.forEach(function (file) { var name = program.name || path.basename(file, path.extname(file)); - console.log(uglify(str.format(template, { source: nools.transpile(path.resolve(process.cwd(), file), {name: name}), noolsLocation: noolsLocation}), program)); + stdout.write(uglify(str.format(template, { source: nools.transpile(path.resolve(process.cwd(), file), {name: name}), noolsLocation: noolsLocation}), program)); }); }); diff --git a/docs/History.html b/docs/History.html index ff035bb..1acb256 100644 --- a/docs/History.html +++ b/docs/History.html @@ -178,6 +178,16 @@ +

0.2.3

+

0.2.2

-
  • Actions
  • +
  • Actions +
  • Globals
  • Import
  • @@ -434,6 +438,23 @@

    Modify

    session.modify(m);

    Note modify is typically used during the execution of the rules.

    +

    +

    Retrieving Facts

    +

    To get a list of facts currently in the session you can use the getFacts() method exposed on a session.

    +
    session.assert(1);
    +session.assert("A");
    +session.assert("B");
    +session.assert(2);
    +
    +session.getFacts(); //[1, "A", "B", 2];
    +

    You may also pass in a Type to getFacts which will return facts only of the given type.

    +
    session.assert(1);
    +session.assert("A");
    +session.assert("B");
    +session.assert(2);
    +
    +session.getFacts(Number); //[1, 2];
    +session.getFacts(String); //["A", "B"];

    Firing the rules

    When you get a session from a flow no rules will be fired until the match method is called.

    @@ -1250,8 +1271,17 @@

    Action

    session.modify(f3); session.retract(f1); } -

    If you have an async action that needs to take place an optional third argument can be passed in which is a function -to be called when the action is completed.

    +

    To define the actions with the nools DSL

    +
    then {
    +    modify(f3, function(){
    +        this.value = f1.value + f2.value;
    +    });
    +    retract(f1);
    +}
    +

    For rules defined using the rules language nools will automatically determine what parameters need to be passed in based on what is referenced in the action.

    +

    +

    Async Actions

    +

    If your action is async you can use the third argument which should called when the action is completed.

    function (facts, engine, next) {
             //some async action
             process.nextTick(function(){
    @@ -1261,17 +1291,18 @@ 

    Action

    engine.modify(f3); engine.retract(f1); next(); - }) + }); }
    -

    If any arguments are passed into next it is assumed there was an error and the session will error out.

    -

    To define the action with the nools DSL

    -
    then {
    -    modify(f3, function(){
    -        this.value = f1.value + f2.value;
    -    });
    -    retract(f1);
    +

    If an error occurs you can pass the error as the first argument to next.

    +
    then{
    +   saveToDatabase(user, function(err){
    +      next(new Error("Something went BOOM!"));
    +   });
    +}
    +

    If you are using a Promises/A+ compliant library you can just return a promise from your action and nools will wait for the promise to resolve before continuing.

    +
    then{
    +   return saveToDatabase(user); // assume saveToDatabase returns a promise
     }
    -

    For rules defined using the rules language nools will automatically determine what parameters need to be passed in based on what is referenced in the action.

    Globals

    Globals are accessible through the current working scope of rules defined in a dsl, very similar to using the scope option when compiling.

    diff --git a/docs/nools.js b/docs/nools.js index f4a6d0d..a97ebcd 100644 --- a/docs/nools.js +++ b/docs/nools.js @@ -1,11 +1,11 @@ -/*! nools - v0.2.2 - 2013-11-20 +/*! nools - v0.2.3 - 2013-12-17 * http://c2fo.github.com/nools * Copyright (c) 2013 Doug Martin (http://c2fo.com); Licensed */ -!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gc&&g>c&&c++;);var h=d[c]-e[c];return h||(h=f-g),h}function g(a,b){return a.recency-b.recency}var h=a("./extended").map,i={salience:d,bucketCounter:e,factRecency:f,activationRecency:g};c.strategies=i,c.strategy=function(a){a=h(a,function(a){return i[a]});var b=a.length;return function(c,d){var e=-1,f=0,g=c===d||c.name===d.name&&c.hashCode===d.hashCode;if(!g){for(;++e0?1:-1}return f}}},{"./extended":12}],8:[function(a,b,c){"use strict";var d,e=a("./extended"),f=e.deepEqual,g=e.merge,h=e.instanceOf,i=e.filter,j=e.declare,k=0,l=j({type:null,instance:{constructor:function(b){d||(d=a("./constraintMatcher")),this.id=k++,this.constraint=b,e.bindAll(this,["assert"])},assert:function(){throw new Error("not implemented")},getIndexableProperties:function(){return[]},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return[this.get("alias")]}}}});l.extend({instance:{type:"object",constructor:function(a){this._super([a])},assert:function(a){return a instanceof this.constraint||a.constructor===this.constraint},equal:function(a){return h(a,this._static)&&this.constraint===a.constraint}}}).as(c,"ObjectConstraint");var m=l.extend({instance:{type:"equality",constructor:function(a,b){this._super([a]),b=b||{},this.pattern=b.pattern,this._matcher=d.getMatcher(a,b,!0)},assert:function(a){return this._matcher(a)}}}).as(c,"EqualityConstraint");m.extend({instance:{type:"inequality"}}).as(c,"InequalityConstraint"),m.extend({instance:{type:"comparison"}}).as(c,"ComparisonConstraint"),l.extend({instance:{type:"equality",constructor:function(){this._super([[!0]])},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")},assert:function(){return!0}}}).as(c,"TrueConstraint");var n=l.extend({instance:{type:"reference",constructor:function(a,b){this.cache={},this._super([a]),b=b||{},this.values=[],this.pattern=b.pattern,this._options=b,this._matcher=d.getMatcher(a,b,!1)},assert:function(a,b){try{return this._matcher(a,b)}catch(c){throw new Error("Error with evaluating pattern "+this.pattern+" "+c.message)}},merge:function(a){var b=this;return a instanceof n&&(b=new this._static([this.constraint,a.constraint,"and"],g({},this._options,this._options)),b._alias=this._alias||a._alias,b.vars=this.vars.concat(a.vars)),b},equal:function(a){return h(a,this._static)&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return this.vars},alias:function(){return this._alias}},setters:{alias:function(a){this._alias=a,this.vars=i(d.getIdentifiers(this.constraint),function(b){return b!==a})}}}}).as(c,"ReferenceConstraint");n.extend({instance:{type:"reference_equality",op:"eq",getIndexableProperties:function(){return d.getIndexableProperties(this.constraint)}}}).as(c,"ReferenceEqualityConstraint").extend({instance:{type:"reference_inequality",op:"neq"}}).as(c,"ReferenceInequalityConstraint"),l.extend({instance:{type:"hash",constructor:function(a){this._super([a])},equal:function(a){return e.instanceOf(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},assert:function(){return!0},getters:{variables:function(){return this.constraint}}}}).as(c,"HashConstraint"),l.extend({instance:{constructor:function(a,b){this.type="from",this.constraints=d.getSourceMatcher(a,b||{},!0),e.bindAll(this,["assert"])},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")&&f(this.constraints,a.constraints)},assert:function(a,b){return this.constraints(a,b)},getters:{variables:function(){return this.constraint}}}}).as(c,"FromConstraint")},{"./constraintMatcher":9,"./extended":12}],9:[function(a,b,c){"use strict";function d(a){return e(a).map(function(a){return f(a)?f(a[0])?d(a).value():a.reverse().join("."):a}).flatten().filter(function(a){return!!a})}var e=a("./extended"),f=e.isArray,g=e.forEach,h=e.some,i=e.indexOf,j=e.isNumber,k=e.removeDuplicates,l=a("./constraint"),m={indexOf:e.indexOf,now:function(){return new Date},Date:function(a,b,c,d,e,f,g){var h=new Date;return j(a)&&h.setYear(a),j(b)&&h.setMonth(b),j(c)&&h.setDate(c),j(d)&&h.setHours(d),j(e)&&h.setMinutes(e),j(f)&&h.setSeconds(f),j(g)&&h.setMilliseconds(g),h},lengthOf:function(a,b){return a.length===b},isTrue:function(a){return a===!0},isFalse:function(a){return a===!1},isNotNull:function(a){return null!==a},dateCmp:function(a,b){return e.compare(a,b)}};g(["years","days","months","hours","minutes","seconds"],function(a){m[a+"FromNow"]=e[a+"FromNow"],m[a+"Ago"]=e[a+"Ago"]}),g(["isArray","isNumber","isHash","isObject","isDate","isBoolean","isString","isRegExp","isNull","isEmpty","isUndefined","isDefined","isUndefinedOrNull","isPromiseLike","isFunction","deepEqual"],function(a){var b=e[a];m[a]=function(){return b.apply(e,arguments)}});var n={equal:function(a,b){var c=!1;return a===b?c=!0:a[2]===b[2]&&(c=-1!==i(["string","number","boolean","regexp","identifier","null"],a[2])?a[0]===b[0]:"unary"===a[2]||"logicalNot"===a[2]?this.equal(a[0],b[0]):this.equal(a[0],b[0])&&this.equal(a[1],b[1])),c},__getProperties:function(a){var b=[];if(a){var c=a[2];if(!c)return b;"prop"!==c&&"identifier"!==c&&"string"!==c&&"number"!==c&&"boolean"!==c&&"regexp"!==c&&"unary"!==c&&"unary"!==c?(b[0]=this.__getProperties(a[0]),b[1]=this.__getProperties(a[1])):b="identifier"===c?[a[0]]:n.__getProperties(a[1]).concat(n.__getProperties(a[0]))}return b},getIndexableProperties:function(a){return"composite"===a[2]?this.getIndexableProperties(a[0]):/^(\w+(\['[^']*'])*) *[!=]== (\w+(\['[^']*'])*)$/.test(this.parse(a))?d(this.__getProperties(a)).flatten().value():[]},getIdentifiers:function(a){var b=[],c=a[2];if("identifier"===c)return[a[0]];if("function"===c)b=b.concat(this.getIdentifiers(a[0])).concat(this.getIdentifiers(a[1]));else if("string"!==c&&"number"!==c&&"boolean"!==c&&"regexp"!==c&&"unary"!==c&&"unary"!==c)if("prop"===c){if(b=b.concat(this.getIdentifiers(a[0])),a[1])for(var d=a[1];f(d);){if("function"===d[2]){b=b.concat(this.getIdentifiers(d[1]));break}d=d[1]}}else a[0]&&(b=b.concat(this.getIdentifiers(a[0]))),a[1]&&(b=b.concat(this.getIdentifiers(a[1])));return k(b)},toConstraints:function(a,b){var c=[],d=b.alias,e=b.scope||{},f=a[2];if("and"===f)c=c.concat(this.toConstraints(a[0],b)).concat(this.toConstraints(a[1],b));else if("composite"===f||"or"===f||"lt"===f||"gt"===f||"lte"===f||"gte"===f||"like"===f||"notLike"===f||"eq"===f||"neq"===f||"in"===f||"notIn"===f||"prop"===f||"propLookup"===f||"function"===f||"logicalNot"===f){var g=h(this.getIdentifiers(a),function(a){return!(a===d||a in m||a in e)});"eq"===f?c.push(new l[g?"ReferenceEqualityConstraint":"EqualityConstraint"](a,b)):"neq"===f?c.push(new l[g?"ReferenceInequalityConstraint":"InequalityConstraint"](a,b)):c.push(new l[g?"ReferenceConstraint":"ComparisonConstraint"](a,b))}return c},parse:function(a){return this[a[2]](a[0],a[1])},composite:function(a){return this.parse(a)},and:function(a,b){return["(",this.parse(a),"&&",this.parse(b),")"].join(" ")},or:function(a,b){return["(",this.parse(a),"||",this.parse(b),")"].join(" ")},prop:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"['",this.parse(b),"']"].join("")},propLookup:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"[",this.parse(b),"]"].join("")},unary:function(a){return-1*this.parse(a)},plus:function(a,b){return[this.parse(a),"+",this.parse(b)].join(" ")},minus:function(a,b){return[this.parse(a),"-",this.parse(b)].join(" ")},mult:function(a,b){return[this.parse(a),"*",this.parse(b)].join(" ")},div:function(a,b){return[this.parse(a),"/",this.parse(b)].join(" ")},mod:function(a,b){return[this.parse(a),"%",this.parse(b)].join(" ")},lt:function(a,b){return[this.parse(a),"<",this.parse(b)].join(" ")},gt:function(a,b){return[this.parse(a),">",this.parse(b)].join(" ")},lte:function(a,b){return[this.parse(a),"<=",this.parse(b)].join(" ")},gte:function(a,b){return[this.parse(a),">=",this.parse(b)].join(" ")},like:function(a,b){return[this.parse(b),".test(",this.parse(a),")"].join("")},notLike:function(a,b){return["!",this.parse(b),".test(",this.parse(a),")"].join("")},eq:function(a,b){return[this.parse(a),"===",this.parse(b)].join(" ")},neq:function(a,b){return[this.parse(a),"!==",this.parse(b)].join(" ")},"in":function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) != -1"].join("")},notIn:function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) == -1"].join("")},arguments:function(a,b){var c=[];return a&&c.push(this.parse(a)),b&&c.push(this.parse(b)),c.join(",")},array:function(a){var b=[];return a?(b=this.parse(a),f(b)?b:["[",b,"]"].join("")):["[",b.join(","),"]"].join("")},"function":function(a,b){var c=this.parse(b);return[this.parse(a),"(",c,")"].join("")},string:function(a){return"'"+a+"'"},number:function(a){return a},"boolean":function(a){return a},regexp:function(a){return a},identifier:function(a){return a},"null":function(){return"null"},logicalNot:function(a){return["!(",this.parse(a),")"].join("")}},o=0,p=c.toJs=function(a,b,c,d,f){var g=n.parse(a);b=b||{};var h=n.getIdentifiers(a),i=["var indexOf = definedFuncs.indexOf; var hasOwnProperty = Object.prototype.hasOwnProperty;"],j=[];e(h).filter(function(a){var c=["var ",a," = "];if(m.hasOwnProperty(a))c.push("definedFuncs['",a,"']");else{if(!b.hasOwnProperty(a))return!0;c.push("scope['",a,"']")}return c.push(";"),i.push(c.join("")),!1}).forEach(function(a){var b=["var ",a," = "];d||a!==c?b.push("fact."+a):a===c&&b.push("hash.",a,""),b.push(";"),j.push(b.join(""))});var k=i.join("")+"return function matcher"+o++ +(d?"(fact){":"(fact, hash){")+j.join("")+" return "+(f?f(g):g)+";}",l=new Function("definedFuncs, scope",k)(m,b);return l};c.getMatcher=function(a,b,c){return b=b||{},p(a,b.scope,b.alias,c,function(a){return"!!("+a+")"})},c.getSourceMatcher=function(a,b,c){return b=b||{},p(a,b.scope,b.alias,c,function(a){return a})},c.toConstraints=function(a,b){return n.toConstraints(a,b)},c.equal=function(a,b){return n.equal(a,b)},c.getIdentifiers=function(a){return n.getIdentifiers(a)},c.getIndexableProperties=function(a){return n.getIndexableProperties(a)}},{"./constraint":8,"./extended":12}],10:[function(a,b){"use strict";function c(a,b){for(var c=[],d=-1,e=a.length;++di){for(f=a.slice();++gb;b++)a.assert(arguments[b]);return a},containsRule:function(a){return c.some(this.__rules,function(b){return b.name===a})}},"static":{getFlow:function(a){return l[a]},hasFlow:function(a){return c.has(l,a)},deleteFlow:function(a){return d(a,m)&&(a=a.name),delete l[a],m},deleteFlows:function(){for(var a in l)a in l&&delete l[a];return m},create:function(a,b){return new m(a,b)}}}).as(b)},{"./conflict":7,"./extended":12,"./flow":13,"./pattern":45,"./rule":46}],15:[function(a,b,c){"use strict";function d(a){return/\.nools$/.test(a)}function e(a){var b;return b=d(a)?i.parse(g.readFileSync(a,"utf8"),a):i.parse(a)}var f=a("./extended"),g=a("fs"),h=a("path"),i=a("./compile"),j=a("./flowContainer");c.Flow=j,c.getFlow=j.getFlow,c.hasFlow=j.hasFlow,c.deleteFlow=function(a){return j.deleteFlow(a),this},c.deleteFlows=function(){return j.deleteFlows(),this},c.flow=j.create,c.compile=function(a,b,c){if(f.isFunction(b)?(c=b,b={}):(b=b||{},c=null),f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),!b.name)throw new Error("Name required when compiling nools source");return i.compile(a,b,c,j)},c.transpile=function(a,b){return b=b||{},f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),i.transpile(a,b)},c.parse=e},{"./compile":5,"./extended":12,"./flowContainer":14,fs:65,path:66}],16:[function(a,b){var c=a("declare.js");c({instance:{constructor:function(){this.head=null,this.tail=null,this.length=null},push:function(a){var b=this.tail,c=this.head,d={data:a,prev:b,next:null};return b&&(this.tail.next=d),this.tail=d,c||(this.head=d),this.length++,d},remove:function(a){a.prev?a.prev.next=a.next:this.head=a.next,a.next?a.next.prev=a.prev:this.tail=a.prev,this.length--},forEach:function(a){for(var b={next:this.head};b=b.next;)a(b.data)},toArray:function(){for(var a={next:this.head},b=[];a=a.next;)b.push(a);return b},removeByData:function(a){for(var b={next:this.head};b=b.next;)if(b.data===a){this.remove(b);break}},getByData:function(a){for(var b={next:this.head};b=b.next;)if(b.data===a)return b},clear:function(){this.head=this.tail=null,this.length=0}}}).as(b)},{"declare.js":52}],17:[function(a,b){var c,d=a("__browserify_process"),e=a("./extended");if("function"==typeof setImmediate)c="undefined"!=typeof window?e.bind(window,setImmediate):setImmediate;else if("undefined"!=typeof d)c=d.nextTick;else if("undefined"!=typeof MessageChannel){var f=new MessageChannel,g={},h=g;f.port1.onmessage=function(){g=g.next;var a=g.task;delete g.task,a()},c=function(a){h=h.next={task:a},f.port2.postMessage(0)}}else c=function(a){setTimeout(a,0)};b.exports=c},{"./extended":12,__browserify_process:68}],18:[function(a,b){var c=a("./node"),d=a("../extended").intersection,e=a("../context");c.extend({instance:{__propagatePaths:function(a,b){for(var c,f,g,h,i=this.__entrySet,j=i.length;--j>-1;)c=i[j],f=c.key,g=c.value,(h=d(g,b.paths)).length&&f[a](new e(b.fact,h,b.match))},__propagateNoPaths:function(a,b){for(var c=this.__entrySet,d=c.length;--d>-1;)c[d].key[a](b)},__propagate:function(a,b){b.paths?this.__propagatePaths(a,b):this.__propagateNoPaths(a,b)}}}).as(b)},{"../context":10,"../extended":12,"./node":34}],19:[function(a,b){var c=a("./alphaNode");c.extend({instance:{constructor:function(){this._super(arguments),this.alias=this.constraint.get("alias")},toString:function(){return"AliasNode"+this.__count -},assert:function(a){return this.__propagate("assert",a.set(this.alias,a.fact.object))},modify:function(a){return this.__propagate("modify",a.set(this.alias,a.fact.object))},retract:function(a){return this.__propagate("retract",a.set(this.alias,a.fact.object))},equal:function(a){return a instanceof this._static&&this.alias===a.alias}}}).as(b)},{"./alphaNode":20}],20:[function(a,b){"use strict";var c=a("./node");c.extend({instance:{constructor:function(a){this._super([]),this.constraint=a,this.constraintAssert=this.constraint.assert},toString:function(){return"AlphaNode "+this.__count},equal:function(a){return this.constraint.equal(a.constraint)}}}).as(b)},{"./node":34}],21:[function(a,b){var c=a("../extended"),d=c.hash.values,e=c.hash.keys,f=a("./node"),g=a("./misc/leftMemory"),h=a("./misc/rightMemory");f.extend({instance:{nodeType:"BetaNode",constructor:function(){this._super([]),this.leftMemory={},this.rightMemory={},this.leftTuples=new g,this.rightTuples=new h},__propagate:function(a,b){for(var c,d,e=this.__entrySet,f=e.length;--f>-1;)c=e[f],d=c.key,d[a](b)},dispose:function(){this.leftMemory={},this.rightMemory={},this.leftTuples.clear(),this.rightTuples.clear()},disposeLeft:function(a){this.leftMemory={},this.leftTuples.clear(),this.propagateDispose(a)},disposeRight:function(a){this.rightMemory={},this.rightTuples.clear(),this.propagateDispose(a)},hashCode:function(){return this.nodeType+" "+this.__count},toString:function(){return this.nodeType+" "+this.__count},retractLeft:function(a){a=this.removeFromLeftMemory(a).data;for(var b=d(a.rightMatches),c=-1,e=b.length;++ch;h++)if(this.__isMatch(a,e[h],!0)){a.blocked=!0;break}}else f(e)&&(a.blocked=this.__isMatch(a,e,!0));var j=a.blocked;j?c?this.__propagate("modify",a.clone()):this.__propagate("assert",a.clone()):c&&this.__propagate("retract",a.clone())},__findMatches:function(a){var b=a.factHash,c=this.from(b),d=!1;if(g(c)){for(var e=0,h=c.length;h>e;e++)if(this.__isMatch(a,c[e],!0))return a.blocked=!0,this.__propagate("assert",a.clone()),void 0}else f(c)&&this.__isMatch(a,c,!0)&&(a.blocked=!0,this.__propagate("assert",a.clone()));return d},__isMatch:function(a,b,c){var d=!1;if(this.type(b)){var f=this.workingMemory.getFactHandle(b),g=new e(f,null).mergeMatch(a.match).set(this.alias,b);if(c){var h=this.fromMemory[f.id];h||(h=this.fromMemory[f.id]={}),h[a.hashCode]=a}for(var i=g.factHash,j=this.__equalityConstraints,k=0,l=j.length;l>k;k++){if(!j[k](i)){d=!1;break}d=!0}}return d},assertLeft:function(a){this.__addToLeftMemory(a),this.__findMatches(a)}}}).as(b)},{"../context":10,"../extended":12,"./fromNotNode":26}],24:[function(a,b){var c=a("./notNode"),d=a("../linkedList");c.extend({instance:{nodeType:"ExistsNode",blockedContext:function(a,b){a.blocker=b,this.removeFromLeftMemory(a),this.addToLeftBlockedMemory(b.blocking.push(a)),this.__propagate("assert",this.__cloneContext(a))},notBlockedContext:function(a,b){this.__addToLeftMemory(a),b&&this.__propagate("retract",this.__cloneContext(a))},propagateFromLeft:function(a){this.notBlockedContext(a,!1)},retractLeft:function(a){var b;if(!this.removeFromLeftMemory(a)){if(!(b=this.removeFromLeftBlockedMemory(a)))throw new Error;this.__propagate("retract",this.__cloneContext(b.data))}},modifyLeft:function(a){var b,c,d,e,f=this.removeFromLeftMemory(a),g=this.constraint,h=this.rightTuples,i=h.length,j=!1;if(f||(f=this.removeFromLeftBlockedMemory(a),j=!0),!f)throw new Error;if(b=f.data,b&&b.blocker&&(e=this.rightMemory[b.blocker.hashCode]),e?(g.isMatch(a,d=e.data)&&(this.__propagate(j?"modify":"assert",this.__cloneContext(b)),a.blocker=d,this.addToLeftBlockedMemory(d.blocking.push(a)),a=null),a&&(c={next:e.next})):c={next:h.head},a&&i)for(c={next:h.head};c=c.next;)if(g.isMatch(a,d=c.data)){this.__propagate(j?"modify":"assert",this.__cloneContext(b)),this.addToLeftBlockedMemory(d.blocking.push(a)),a.blocker=d,a=null;break}a&&(this.__addToLeftMemory(a),j&&this.__propagate("retract",this.__cloneContext(a)))},modifyRight:function(a){var b=this.removeFromRightMemory(a);if(!b)throw new Error;var c,e,f=b.data,g=this.leftTuples,h=g.length,i=this.constraint,j=f.blocking;if(this.__addToRightMemory(a),a.blocking=new d,h||j.length){if(j.length)for(var k,l={next:j.head};l=l.next;)if(c=l.data,c.blocker=null,i.isMatch(c,a))c.blocker=a,this.addToLeftBlockedMemory(a.blocking.push(c)),this.__propagate("assert",this.__cloneContext(c)),c=null;else{for(c.blocker=null,e=b;e=e.next;)if(i.isMatch(c,k=e.data)){c.blocker=k,this.addToLeftBlockedMemory(k.blocking.push(c)),this.__propagate("assert",this.__cloneContext(c)),c=null;break}c&&this.__addToLeftMemory(c)}if(h)for(e={next:g.head};e=e.next;)c=e.data,i.isMatch(c,a)&&(this.__propagate("assert",this.__cloneContext(c)),this.removeFromLeftMemory(c),this.addToLeftBlockedMemory(a.blocking.push(c)),c.blocker=a)}}}}).as(b)},{"../linkedList":16,"./notNode":35}],25:[function(a,b){var c=a("./joinNode"),d=a("../extended"),e=a("../constraint"),f=e.EqualityConstraint,g=e.HashConstraint,h=e.ReferenceConstraint,i=a("../context"),j=d.isDefined,k=d.isEmpty,l=d.forEach,m=d.isArray,n={isMatch:function(){return!1}};c.extend({instance:{nodeType:"FromNode",constructor:function(a,b){this._super(arguments),this.workingMemory=b,this.fromMemory={},this.pattern=a,this.type=a.get("constraints")[0].assert,this.alias=a.get("alias"),this.from=a.from.assert;var c=this.__equalityConstraints=[],d=[];l(this.constraints=this.pattern.get("constraints").slice(1),function(a){a instanceof f||a instanceof h?c.push(a.assert):a instanceof g&&(d=d.concat(a.get("variables")))}),this.__variables=d},__createMatches:function(a){var b=a.factHash,c=this.from(b);if(m(c))for(var d=0,e=c.length;e>d;d++)this.__checkMatch(a,c[d],!0);else j(c)&&this.__checkMatch(a,c,!0)},__checkMatch:function(a,b,c){var d;return(d=this.__createMatch(a,b)).isMatch()&&c&&this.__propagate("assert",d.clone()),d},__createMatch:function(a,b){if(this.type(b)){var c,d=this.workingMemory.getFactHandle(b,!0),e=new i(d).set(this.alias,b),f=d.id,g=e.factHash,h=a.factHash;for(var j in h)g[j]=h[j];for(var k=this.__equalityConstraints,l=this.__variables,m=-1,o=k.length;++mc;c++)b=this.__checkMatch(a,l[c],!1),b.isMatch()&&(e=b.fact.id,e in k?this.__propagate("modify",b.clone()):this.__propagate("assert",b.clone()));else j(l)&&(b=this.__checkMatch(a,l,!1),b.isMatch()&&(e=b.fact.id,e in k?this.__propagate("modify",b.clone()):this.__propagate("assert",b.clone())));for(c in k)c in i||(this.removeFromFromMemory(k[c]),this.__propagate("retract",k[c].clone()))}else this.assertLeft(a);f=a.fact,e=f.id;var n=this.fromMemory[e];if(this.fromMemory[e]={},n){var o,p,q,r,s=f.object;for(c in n)p=n[c],o=p[0],q=p[1],r=q.isMatch(),o.hashCode!==a.hashCode&&(b=this.__createMatch(o,s,!1),r&&this.__propagate("retract",q.clone()),b.isMatch()&&this.__propagate(r?"modify":"assert",b.clone()))}},assertLeft:function(a){this.__addToLeftMemory(a),a.fromMatches={},this.__createMatches(a)},assertRight:function(){throw new Error("Shouldnt have gotten here")}}}).as(b)},{"../constraint":8,"../context":10,"../extended":12,"./joinNode":28}],26:[function(a,b){var c=a("./joinNode"),d=a("../extended"),e=a("../constraint"),f=e.EqualityConstraint,g=e.HashConstraint,h=e.ReferenceConstraint,i=a("../context"),j=d.isDefined,k=d.forEach,l=d.isArray;c.extend({instance:{nodeType:"FromNotNode",constructor:function(a,b){this._super(arguments),this.workingMemory=b,this.pattern=a,this.type=a.get("constraints")[0].assert,this.alias=a.get("alias"),this.from=a.from.assert,this.fromMemory={};var c=this.__equalityConstraints=[],d=[];k(this.constraints=this.pattern.get("constraints").slice(1),function(a){a instanceof f||a instanceof h?c.push(a.assert):a instanceof g&&(d=d.concat(a.get("variables")))}),this.__variables=d},retractLeft:function(a){var b=this.removeFromLeftMemory(a);b&&(b=b.data,b.blocked||this.__propagate("retract",b.clone()))},__modify:function(a,b){var c=b.blocked,d=a.factHash,e=this.from(d);if(l(e)){for(var f=0,g=e.length;g>f;f++)if(this.__isMatch(a,e[f],!0)){a.blocked=!0;break}}else j(e)&&(a.blocked=this.__isMatch(a,e,!0));var h=a.blocked;h?c||this.__propagate("retract",b.clone()):c?this.__propagate("assert",a.clone()):this.__propagate("modify",a.clone())},modifyLeft:function(a){var b=this.removeFromLeftMemory(a);if(!b)throw new Error;this.__addToLeftMemory(a),this.__modify(a,b.data);var c=this.fromMemory[a.fact.id];if(this.fromMemory[a.fact.id]={},c)for(var d in c)if(d!==a.hashCode){var e=c[d];b=this.removeFromLeftMemory(e),b&&(e=e.clone(),e.blocked=!1,this.__addToLeftMemory(e),this.__modify(e,b.data))}},__findMatches:function(a){var b=a.factHash,c=this.from(b),d=!1;if(l(c)){for(var e=0,f=c.length;f>e;e++)if(this.__isMatch(a,c[e],!0))return a.blocked=!0,void 0;this.__propagate("assert",a.clone())}else j(c)&&!(a.blocked=this.__isMatch(a,c,!0))&&this.__propagate("assert",a.clone());return d},__isMatch:function(a,b,c){var d=!1;if(this.type(b)){var e=this.workingMemory.getFactHandle(b),f=new i(e,null).mergeMatch(a.match).set(this.alias,b);if(c){var g=this.fromMemory[e.id];g||(g=this.fromMemory[e.id]={}),g[a.hashCode]=a}for(var h=f.factHash,j=this.__equalityConstraints,k=0,l=j.length;l>k;k++){if(!j[k](h,h)){d=!1;break}d=!0}}return d},assertLeft:function(a){this.__addToLeftMemory(a),this.__findMatches(a)},assertRight:function(){throw new Error("Shouldnt have gotten here")},retractRight:function(){throw new Error("Shouldnt have gotten here")}}}).as(b)},{"../constraint":8,"../context":10,"../extended":12,"./joinNode":28}],27:[function(a,b,c){"use strict";function d(a){return g(a.constraints||[],function(a){return a instanceof t})}var e=a("../extended"),f=e.forEach,g=e.some,h=e.declare,i=a("../pattern.js"),j=i.ObjectPattern,k=i.FromPattern,l=i.FromNotPattern,m=i.ExistsPattern,n=i.FromExistsPattern,o=i.NotPattern,p=i.CompositePattern,q=i.InitialFactPattern,r=a("../constraint"),s=r.HashConstraint,t=r.ReferenceConstraint,u=a("./aliasNode"),v=a("./equalityNode"),w=a("./joinNode"),x=a("./betaNode"),y=a("./notNode"),z=a("./fromNode"),A=a("./fromNotNode"),B=a("./existsNode"),C=a("./existsFromNode"),D=a("./leftAdapterNode"),E=a("./rightAdapterNode"),F=a("./typeNode"),G=a("./terminalNode"),H=a("./propertyNode");h({instance:{constructor:function(a,b){this.terminalNodes=[],this.joinNodes=[],this.nodes=[],this.constraints=[],this.typeNodes=[],this.__ruleCount=0,this.bucket={counter:0,recency:0},this.agendaTree=b,this.workingMemory=a},assertRule:function(a){var b=new G(this.bucket,this.__ruleCount++,a,this.agendaTree);this.__addToNetwork(a,a.pattern,b),this.__mergeJoinNodes(),this.terminalNodes.push(b)},resetCounter:function(){this.bucket.counter=0},incrementCounter:function(){this.bucket.counter++},assertFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].assert(a)},retractFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].retract(a)},modifyFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].modify(a)},containsRule:function(a){return g(this.terminalNodes,function(b){return b.rule.name===a})},dispose:function(){for(var a=this.typeNodes,b=a.length-1;b>=0;b--)a[b].dispose()},__mergeJoinNodes:function(){for(var a=this.joinNodes,b=0;b=0;c--){var d=b[c];if(a.equal(d))return d}return b.push(a),a},__createTypeNode:function(a,b){for(var c=new F(b.get("constraints")[0]),d=this.typeNodes,e=d.length-1;e>=0;e--){var f=d[e];if(c.equal(f))return f}return d.push(c),c},__createEqualityNode:function(a,b){return this.__checkEqual(new v(b)).addRule(a)},__createPropertyNode:function(a,b){return this.__checkEqual(new H(b)).addRule(a)},__createAliasNode:function(a,b){return this.__checkEqual(new u(b)).addRule(a)},__createAdapterNode:function(a,b){return("left"===b?new D:new E).addRule(a)},__createJoinNode:function(a,b,c,e){var f;b.rightPattern instanceof o?f=new y:b.rightPattern instanceof n?f=new C(b.rightPattern,this.workingMemory):b.rightPattern instanceof m?f=new B:b.rightPattern instanceof l?f=new A(b.rightPattern,this.workingMemory):b.rightPattern instanceof k?f=new z(b.rightPattern,this.workingMemory):b instanceof p&&!d(b.leftPattern)&&!d(b.rightPattern)?(f=new x,this.joinNodes.push(f)):(f=new w,this.joinNodes.push(f)),f.__rule__=a;var g=f;if(c instanceof x){var h=this.__createAdapterNode(a,e);g.addOutNode(h,b),g=h}return g.addOutNode(c,b),f.addRule(a)},__addToNetwork:function(a,b,c,d){b instanceof j?b instanceof q||d&&"left"!==d?this.__createAlphaNode(a,b,c,d):this.__createBetaNode(a,new p(new q,b),c,d):b instanceof p&&this.__createBetaNode(a,b,c,d)},__createBetaNode:function(a,b,c,d){var e=this.__createJoinNode(a,b,c,d);return this.__addToNetwork(a,b.rightPattern,e,"right"),this.__addToNetwork(a,b.leftPattern,e,"left"),c.addParentNode(e),e},__createAlphaNode:function(a,b,c,d){var e,f;if(!(b instanceof k)){var g=b.get("constraints");e=this.__createTypeNode(a,b);var h=this.__createAliasNode(a,b);e.addOutNode(h,b),h.addParentNode(e),f=h;for(var i=g.length-1;i>0;i--){var j,l=g[i];if(l instanceof s)j=this.__createPropertyNode(a,l);else{if(l instanceof t){c.constraint.addConstraint(l);continue}j=this.__createEqualityNode(a,l)}f.addOutNode(j,b),j.addParentNode(f),f=j}if(c instanceof x){var m=this.__createAdapterNode(a,d);m.addParentNode(f),f.addOutNode(m,b),f=m}return c.addParentNode(f),f.addOutNode(c,b),e}},print:function(){f(this.terminalNodes,function(a){a.print(" ")})}}}).as(c,"RootNode")},{"../constraint":8,"../extended":12,"../pattern.js":45,"./aliasNode":19,"./betaNode":21,"./equalityNode":22,"./existsFromNode":23,"./existsNode":24,"./fromNode":25,"./fromNotNode":26,"./joinNode":28,"./leftAdapterNode":30,"./notNode":35,"./propertyNode":36,"./rightAdapterNode":37,"./terminalNode":38,"./typeNode":39}],28:[function(a,b){var c=a("./betaNode"),d=a("./joinReferenceNode");c.extend({instance:{constructor:function(){this._super(arguments),this.constraint=new d(this.leftTuples,this.rightTuples)},nodeType:"JoinNode",propagateFromLeft:function(a,b){var c;return(c=this.constraint.match(a,b)).isMatch&&this.__propagate("assert",this.__addToMemoryMatches(b,a,a.clone(null,null,c))),this},propagateFromRight:function(a,b){var c;return(c=this.constraint.match(b,a)).isMatch&&this.__propagate("assert",this.__addToMemoryMatches(a,b,a.clone(null,null,c))),this},propagateAssertModifyFromLeft:function(a,b,c){var d,e=c.hashCode;if(e in b){d=this.constraint.match(a,c);var f=d.isMatch;f?this.__propagate("modify",this.__addToMemoryMatches(c,a,a.clone(null,null,d))):this.__propagate("retract",b[e].clone())}else this.propagateFromLeft(a,c)},propagateAssertModifyFromRight:function(a,b,c){var d,e=c.hashCode;if(e in b){d=this.constraint.match(c,a);var f=d.isMatch;f?this.__propagate("modify",this.__addToMemoryMatches(a,c,a.clone(null,null,d))):this.__propagate("retract",b[e].clone())}else this.propagateFromRight(a,c)}}}).as(b)},{"./betaNode":21,"./joinReferenceNode":29}],29:[function(a,b){var c=a("./node"),d=a("../constraint"),e=d.ReferenceEqualityConstraint,f={isDefault:!0,assert:function(){return!0},equal:function(){return!1}};c.extend({instance:{constraint:f,constructor:function(a,b){this._super(arguments),this.constraint=f,this.constraintAssert=f.assert,this.rightIndexes=[],this.leftIndexes=[],this.constraintLength=0,this.leftMemory=a,this.rightMemory=b},addConstraint:function(a){if(a instanceof e){var b=a.getIndexableProperties(),c=a.get("alias");if(2===b.length&&c){for(var d,f,g=-1;++g<2;){var h=b[g];null===h.match(new RegExp("^"+c+"(\\.?)"))?d=h:f=h}d&&f&&(this.rightMemory.addIndex(f,d,a.op),this.leftMemory.addIndex(d,f,a.op))}}this.constraint.isDefault?(this.constraint=a,this.isDefault=!1):this.constraint=this.constraint.merge(a),this.constraintAssert=this.constraint.assert},equal:function(a){return this.constraint.equal(a.constraint)},isMatch:function(a,b){return this.constraintAssert(a.factHash,b.factHash)},match:function(a,b){var c={isMatch:!1};return this.constraintAssert(a.factHash,b.factHash)&&(c=a.match.merge(b.match)),c}}}).as(b)},{"../constraint":8,"./node":34}],30:[function(a,b){var c=a("./adapterNode");c.extend({instance:{propagateAssert:function(a){this.__propagate("assertLeft",a)},propagateRetract:function(a){this.__propagate("retractLeft",a)},propagateResolve:function(a){this.__propagate("retractResolve",a)},propagateModify:function(a){this.__propagate("modifyLeft",a)},retractResolve:function(a){this.__propagate("retractResolve",a)},dispose:function(a){this.propagateDispose(a)},toString:function(){return"LeftAdapterNode "+this.__count}}}).as(b)},{"./adapterNode":18}],31:[function(a,b){var c=a("./memory");c.extend({instance:{getLeftMemory:function(a){return this.getMemory(a)}}}).as(b)},{"./memory":32}],32:[function(a,b){var c=a("../../extended"),d=c.indexOf,e=c.plucker,f=c.diffArr,g=Array.prototype.push,h=c.declare,i=c.HashTable;h({instance:{constructor:function(){this.head=null,this.tail=null,this.length=null,this.indexes=[],this.tables={tuples:[],tables:[]}},inequalityThreshold:.5,push:function(a){var b=this.tail,c=this.head,d={data:a,prev:b,next:null};return b&&(this.tail.next=d),this.tail=d,c||(this.head=d),this.length++,this.__index(d),this.tables.tuples.push(d),d},remove:function(a){a.prev?a.prev.next=a.next:this.head=a.next,a.next?a.next.prev=a.prev:this.tail=a.prev;var b=d(this.tables.tuples,a);-1!==b&&this.tables.tuples.splice(b,1),this.__removeFromIndex(a),this.length--},forEach:function(a){for(var b={next:this.head};b=b.next;)a(b.data)},toArray:function(){for(var a={next:this.head},b=[];a=a.next;)b.push(a);return b},clear:function(){this.head=this.tail=null,this.length=0,this.clearIndexes()},clearIndexes:function(){this.tables={},this.indexes.length=0},__index:function(a){for(var b,c,d,e,f,g,h,j=a.data,k=j.factHash,l=this.indexes,m=this.tables,n=-1,o=l.length;++nm&&(k=f(k,n)),k.slice()},__createIndexTree:function(){var a=this.tables.tables={},b=this.indexes;a[b[0][0]]=new i},addIndex:function(a,b,c){this.indexes.push([a,b,e(a),e(b),c||"eq"]),this.indexes.sort(function(a,b){var c=a[4],d=b[4];return c===d?0:c>d?1:-1}),this.__createIndexTree()}}}).as(b)},{"../../extended":12}],33:[function(a,b){var c=a("./memory");c.extend({instance:{getRightMemory:function(a){return this.getMemory(a)}}}).as(b)},{"./memory":32}],34:[function(a,b){var c=a("../extended"),d=c.forEach,e=c.indexOf,f=c.intersection,g=c.declare,h=c.HashTable,i=a("../context"),j=0;g({instance:{constructor:function(){this.nodes=new h,this.rules=[],this.parentNodes=[],this.__count=j++,this.__entrySet=[]},addRule:function(a){return-1===e(this.rules,a)&&this.rules.push(a),this},merge:function(a){a.nodes.forEach(function(b){for(var c=b.value,d=b.key,e=0,f=c.length;f>e;e++)this.addOutNode(d,c[e]);a.nodes.remove(d)},this);for(var b=a.parentNodes,c=0,d=a.parentNodes.l;d>c;c++){var e=b[c];this.addParentNode(e),e.nodes.remove(a)}return this},resolve:function(a,b){return a.hashCode===b.hashCode},print:function(a){console.log(a+this.toString()),d(this.parentNodes,function(b){b.print(" "+a)})},addOutNode:function(a,b){this.nodes.contains(a)||this.nodes.put(a,[]),this.nodes.get(a).push(b),this.__entrySet=this.nodes.entrySet()},addParentNode:function(a){-1===e(this.parentNodes,a)&&this.parentNodes.push(a)},shareable:function(){return!1},__propagate:function(a,b){for(var c,d,e,g,h=this.__entrySet,j=h.length;--j>-1;)c=h[j],d=c.key,e=c.value,(g=f(e,b.paths)).length&&d[a](new i(b.fact,g,b.match))},dispose:function(a){this.propagateDispose(a)},retract:function(a){this.propagateRetract(a)},propagateDispose:function(a,b){b=b||this.nodes;for(var c=this.__entrySet,d=c.length-1;d>=0;d--){var e=c[d],f=e.key;f.dispose(a)}},propagateAssert:function(a){this.__propagate("assert",a)},propagateRetract:function(a){this.__propagate("retract",a)},assert:function(a){this.propagateAssert(a)},modify:function(a){this.propagateModify(a)},propagateModify:function(a){this.__propagate("modify",a)}}}).as(b)},{"../context":10,"../extended":12}],35:[function(a,b){var c=a("./joinNode"),d=a("../linkedList"),e=a("../context"),f=a("../pattern").InitialFact;c.extend({instance:{nodeType:"NotNode",constructor:function(){this._super(arguments),this.leftTupleMemory={},this.notMatch=new e(new f).match},__cloneContext:function(a){return a.clone(null,null,a.match.merge(this.notMatch))},retractRight:function(a){var b=this.removeFromRightMemory(a),c=b.data,d=c.blocking;if(d.length){for(var e,f,g,h=this.rightTuples.getSimilarMemory(c),i=h.length,j=this.constraint,k={next:d.head};k=k.next;){for(f=k.data,e=-1;++eg;g++)b=e[g],c.set(b[1],f[b[0]]);this.__propagate("assert",c)},retract:function(a){this.__propagate("retract",new d(a.fact,a.paths))},modify:function(a){var b,c=new d(a.fact,a.paths),e=this.variables,f=a.fact.object;c.set(this.alias,f);for(var g=0,h=this.varLength;h>g;g++)b=e[g],c.set(b[1],f[b[0]]);this.__propagate("modify",c)},toString:function(){return"PropertyNode"+this.__count}}}).as(b)},{"../context":10,"../extended":12,"./alphaNode":20}],37:[function(a,b){var c=a("./adapterNode");c.extend({instance:{retractResolve:function(a){this.__propagate("retractResolve",a)},dispose:function(a){this.propagateDispose(a)},propagateAssert:function(a){this.__propagate("assertRight",a)},propagateRetract:function(a){this.__propagate("retractRight",a)},propagateResolve:function(a){this.__propagate("retractResolve",a)},propagateModify:function(a){this.__propagate("modifyRight",a)},toString:function(){return"RightAdapterNode "+this.__count}}}).as(b)},{"./adapterNode":18}],38:[function(a,b){var c=a("./node"),d=a("../extended"),e=d.bind;c.extend({instance:{constructor:function(a,b,c,d){this._super([]),this.resolve=e(this,this.resolve),this.rule=c,this.index=b,this.name=this.rule.name,this.agenda=d,this.bucket=a,d.register(this)},__assertModify:function(a){var b=a.match;if(b.isMatch){var c=this.rule,d=this.bucket;this.agenda.insert(this,{rule:c,hashCode:a.hashCode,index:this.index,name:c.name,recency:d.recency++,match:b,counter:d.counter})}},assert:function(a){this.__assertModify(a)},modify:function(a){this.agenda.retract(this,a),this.__assertModify(a)},retract:function(a){this.agenda.retract(this,a)},retractRight:function(a){this.agenda.retract(this,a)},retractLeft:function(a){this.agenda.retract(this,a)},assertLeft:function(a){this.__assertModify(a)},assertRight:function(a){this.__assertModify(a)},toString:function(){return"TerminalNode "+this.rule.name}}}).as(b)},{"../extended":12,"./node":34}],39:[function(a,b){var c=a("./alphaNode"),d=a("../context"); -c.extend({instance:{assert:function(a){this.constraintAssert(a.object)&&this.__propagate("assert",a)},modify:function(a){this.constraintAssert(a.object)&&this.__propagate("modify",a)},retract:function(a){this.constraintAssert(a.object)&&this.__propagate("retract",a)},toString:function(){return"TypeNode"+this.__count},dispose:function(){for(var a=this.__entrySet,b=a.length-1;b>=0;b--){var c=a[b],d=c.key,e=c.value;d.dispose({paths:e})}},__propagate:function(a,b){for(var c=this.__entrySet,e=-1,f=c.length;++e":20,"<=":21,">=":22,EQUALITY_EXPRESSION:23,"==":24,"!=":25,"=~":26,"!=~":27,IN_EXPRESSION:28,"in":29,ARRAY_EXPRESSION:30,notIn:31,OBJECT_EXPRESSION:32,AND_EXPRESSION:33,"&&":34,OR_EXPRESSION:35,"||":36,ARGUMENT_LIST:37,",":38,IDENTIFIER_EXPRESSION:39,IDENTIFIER:40,".":41,"[":42,STRING_EXPRESSION:43,"]":44,NUMBER_EXPRESSION:45,"(":46,")":47,STRING:48,NUMBER:49,REGEXP_EXPRESSION:50,REGEXP:51,BOOLEAN_EXPRESSION:52,BOOLEAN:53,NULL_EXPRESSION:54,NULL:55,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:"-",9:"!",11:"*",12:"/",13:"%",15:"+",17:"^",19:"<",20:">",21:"<=",22:">=",24:"==",25:"!=",26:"=~",27:"!=~",29:"in",31:"notIn",34:"&&",36:"||",38:",",40:"IDENTIFIER",41:".",42:"[",44:"]",46:"(",47:")",48:"STRING",49:"NUMBER",51:"REGEXP",53:"BOOLEAN",55:"NULL"},productions_:[0,[3,2],[6,1],[6,2],[6,2],[10,1],[10,3],[10,3],[10,3],[14,1],[14,3],[14,3],[16,1],[16,3],[18,1],[18,3],[18,3],[18,3],[18,3],[23,1],[23,3],[23,3],[23,3],[23,3],[28,1],[28,3],[28,3],[28,3],[28,3],[33,1],[33,3],[35,1],[35,3],[37,1],[37,3],[39,1],[32,1],[32,3],[32,4],[32,4],[32,4],[32,3],[32,4],[43,1],[45,1],[50,1],[52,1],[54,1],[30,2],[30,3],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,3],[4,1]],performAction:function(a,b,c,d,e,f){var g=f.length-1;switch(e){case 1:return f[g-1];case 3:this.$=[f[g],null,"unary"];break;case 4:this.$=[f[g],null,"logicalNot"];break;case 6:this.$=[f[g-2],f[g],"mult"];break;case 7:this.$=[f[g-2],f[g],"div"];break;case 8:this.$=[f[g-2],f[g],"mod"];break;case 10:this.$=[f[g-2],f[g],"plus"];break;case 11:this.$=[f[g-2],f[g],"minus"];break;case 13:this.$=[f[g-2],f[g],"pow"];break;case 15:this.$=[f[g-2],f[g],"lt"];break;case 16:this.$=[f[g-2],f[g],"gt"];break;case 17:this.$=[f[g-2],f[g],"lte"];break;case 18:this.$=[f[g-2],f[g],"gte"];break;case 20:this.$=[f[g-2],f[g],"eq"];break;case 21:this.$=[f[g-2],f[g],"neq"];break;case 22:this.$=[f[g-2],f[g],"like"];break;case 23:this.$=[f[g-2],f[g],"notLike"];break;case 25:this.$=[f[g-2],f[g],"in"];break;case 26:this.$=[f[g-2],f[g],"notIn"];break;case 27:this.$=[f[g-2],f[g],"in"];break;case 28:this.$=[f[g-2],f[g],"notIn"];break;case 30:this.$=[f[g-2],f[g],"and"];break;case 32:this.$=[f[g-2],f[g],"or"];break;case 34:this.$=[f[g-2],f[g],"arguments"];break;case 35:this.$=[String(a),null,"identifier"];break;case 37:this.$=[f[g-2],f[g],"prop"];break;case 38:this.$=[f[g-3],f[g-1],"propLookup"];break;case 39:this.$=[f[g-3],f[g-1],"propLookup"];break;case 40:this.$=[f[g-3],f[g-1],"propLookup"];break;case 41:this.$=[f[g-2],[null,null,"arguments"],"function"];break;case 42:this.$=[f[g-3],f[g-1],"function"];break;case 43:this.$=[String(a.replace(/^['|"]|['|"]$/g,"")),null,"string"];break;case 44:this.$=[Number(a),null,"number"];break;case 45:this.$=[a,null,"regexp"];break;case 46:this.$=["true"==a.replace(/^\s+/,""),null,"boolean"];break;case 47:this.$=[null,null,"null"];break;case 48:this.$=[null,null,"array"];break;case 49:this.$=[f[g-1],null,"array"];break;case 57:this.$=[f[g-1],null,"composite"]}},table:[{3:1,4:2,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[3]},{5:[1,31]},{5:[2,58],36:[1,32],47:[2,58]},{5:[2,31],34:[1,33],36:[2,31],47:[2,31]},{5:[2,29],34:[2,29],36:[2,29],47:[2,29]},{5:[2,24],24:[1,34],25:[1,35],26:[1,36],27:[1,37],34:[2,24],36:[2,24],47:[2,24]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],29:[1,38],31:[1,39],34:[2,2],36:[2,2],47:[2,2]},{5:[2,19],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,19],25:[2,19],26:[2,19],27:[2,19],34:[2,19],36:[2,19],47:[2,19]},{5:[2,50],8:[2,50],11:[2,50],12:[2,50],13:[2,50],15:[2,50],17:[2,50],19:[2,50],20:[2,50],21:[2,50],22:[2,50],24:[2,50],25:[2,50],26:[2,50],27:[2,50],29:[2,50],31:[2,50],34:[2,50],36:[2,50],38:[2,50],44:[2,50],47:[2,50]},{5:[2,51],8:[2,51],11:[2,51],12:[2,51],13:[2,51],15:[2,51],17:[2,51],19:[2,51],20:[2,51],21:[2,51],22:[2,51],24:[2,51],25:[2,51],26:[2,51],27:[2,51],29:[2,51],31:[2,51],34:[2,51],36:[2,51],38:[2,51],44:[2,51],47:[2,51]},{5:[2,52],8:[2,52],11:[2,52],12:[2,52],13:[2,52],15:[2,52],17:[2,52],19:[2,52],20:[2,52],21:[2,52],22:[2,52],24:[2,52],25:[2,52],26:[2,52],27:[2,52],29:[2,52],31:[2,52],34:[2,52],36:[2,52],38:[2,52],44:[2,52],47:[2,52]},{5:[2,53],8:[2,53],11:[2,53],12:[2,53],13:[2,53],15:[2,53],17:[2,53],19:[2,53],20:[2,53],21:[2,53],22:[2,53],24:[2,53],25:[2,53],26:[2,53],27:[2,53],29:[2,53],31:[2,53],34:[2,53],36:[2,53],38:[2,53],44:[2,53],47:[2,53]},{5:[2,54],8:[2,54],11:[2,54],12:[2,54],13:[2,54],15:[2,54],17:[2,54],19:[2,54],20:[2,54],21:[2,54],22:[2,54],24:[2,54],25:[2,54],26:[2,54],27:[2,54],29:[2,54],31:[2,54],34:[2,54],36:[2,54],38:[2,54],44:[2,54],47:[2,54]},{5:[2,55],8:[2,55],11:[2,55],12:[2,55],13:[2,55],15:[2,55],17:[2,55],19:[2,55],20:[2,55],21:[2,55],22:[2,55],24:[2,55],25:[2,55],26:[2,55],27:[2,55],29:[2,55],31:[2,55],34:[2,55],36:[2,55],38:[2,55],41:[1,44],42:[1,45],44:[2,55],46:[1,46],47:[2,55]},{5:[2,56],8:[2,56],11:[2,56],12:[2,56],13:[2,56],15:[2,56],17:[2,56],19:[2,56],20:[2,56],21:[2,56],22:[2,56],24:[2,56],25:[2,56],26:[2,56],27:[2,56],29:[2,56],31:[2,56],34:[2,56],36:[2,56],38:[2,56],44:[2,56],47:[2,56]},{4:47,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,14],17:[1,48],19:[2,14],20:[2,14],21:[2,14],22:[2,14],24:[2,14],25:[2,14],26:[2,14],27:[2,14],34:[2,14],36:[2,14],47:[2,14]},{5:[2,43],8:[2,43],11:[2,43],12:[2,43],13:[2,43],15:[2,43],17:[2,43],19:[2,43],20:[2,43],21:[2,43],22:[2,43],24:[2,43],25:[2,43],26:[2,43],27:[2,43],29:[2,43],31:[2,43],34:[2,43],36:[2,43],38:[2,43],44:[2,43],47:[2,43]},{5:[2,44],8:[2,44],11:[2,44],12:[2,44],13:[2,44],15:[2,44],17:[2,44],19:[2,44],20:[2,44],21:[2,44],22:[2,44],24:[2,44],25:[2,44],26:[2,44],27:[2,44],29:[2,44],31:[2,44],34:[2,44],36:[2,44],38:[2,44],44:[2,44],47:[2,44]},{5:[2,45],8:[2,45],11:[2,45],12:[2,45],13:[2,45],15:[2,45],17:[2,45],19:[2,45],20:[2,45],21:[2,45],22:[2,45],24:[2,45],25:[2,45],26:[2,45],27:[2,45],29:[2,45],31:[2,45],34:[2,45],36:[2,45],38:[2,45],44:[2,45],47:[2,45]},{5:[2,46],8:[2,46],11:[2,46],12:[2,46],13:[2,46],15:[2,46],17:[2,46],19:[2,46],20:[2,46],21:[2,46],22:[2,46],24:[2,46],25:[2,46],26:[2,46],27:[2,46],29:[2,46],31:[2,46],34:[2,46],36:[2,46],38:[2,46],44:[2,46],47:[2,46]},{5:[2,47],8:[2,47],11:[2,47],12:[2,47],13:[2,47],15:[2,47],17:[2,47],19:[2,47],20:[2,47],21:[2,47],22:[2,47],24:[2,47],25:[2,47],26:[2,47],27:[2,47],29:[2,47],31:[2,47],34:[2,47],36:[2,47],38:[2,47],44:[2,47],47:[2,47]},{5:[2,36],8:[2,36],11:[2,36],12:[2,36],13:[2,36],15:[2,36],17:[2,36],19:[2,36],20:[2,36],21:[2,36],22:[2,36],24:[2,36],25:[2,36],26:[2,36],27:[2,36],29:[2,36],31:[2,36],34:[2,36],36:[2,36],38:[2,36],41:[2,36],42:[2,36],44:[2,36],46:[2,36],47:[2,36]},{7:51,30:15,32:14,37:50,39:23,40:[1,26],42:[1,24],43:9,44:[1,49],45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,12],8:[1,53],15:[1,52],17:[2,12],19:[2,12],20:[2,12],21:[2,12],22:[2,12],24:[2,12],25:[2,12],26:[2,12],27:[2,12],34:[2,12],36:[2,12],47:[2,12]},{5:[2,35],8:[2,35],11:[2,35],12:[2,35],13:[2,35],15:[2,35],17:[2,35],19:[2,35],20:[2,35],21:[2,35],22:[2,35],24:[2,35],25:[2,35],26:[2,35],27:[2,35],29:[2,35],31:[2,35],34:[2,35],36:[2,35],38:[2,35],41:[2,35],42:[2,35],44:[2,35],46:[2,35],47:[2,35]},{5:[2,9],8:[2,9],11:[1,54],12:[1,55],13:[1,56],15:[2,9],17:[2,9],19:[2,9],20:[2,9],21:[2,9],22:[2,9],24:[2,9],25:[2,9],26:[2,9],27:[2,9],34:[2,9],36:[2,9],47:[2,9]},{5:[2,5],8:[2,5],11:[2,5],12:[2,5],13:[2,5],15:[2,5],17:[2,5],19:[2,5],20:[2,5],21:[2,5],22:[2,5],24:[2,5],25:[2,5],26:[2,5],27:[2,5],34:[2,5],36:[2,5],47:[2,5]},{6:57,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:59,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[2,1]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:60,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:61,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:62,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:63,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:64,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:65,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{30:66,32:67,39:23,40:[1,26],42:[1,24]},{30:68,32:69,39:23,40:[1,26],42:[1,24]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:70,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:71,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:72,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:73,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{39:74,40:[1,26]},{32:77,39:23,40:[1,26],43:75,45:76,48:[1,18],49:[1,19]},{7:51,30:15,32:14,37:79,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],47:[1,78],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{47:[1,80]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:81,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,48],8:[2,48],11:[2,48],12:[2,48],13:[2,48],15:[2,48],17:[2,48],19:[2,48],20:[2,48],21:[2,48],22:[2,48],24:[2,48],25:[2,48],26:[2,48],27:[2,48],29:[2,48],31:[2,48],34:[2,48],36:[2,48],38:[2,48],44:[2,48],47:[2,48]},{38:[1,83],44:[1,82]},{38:[2,33],44:[2,33],47:[2,33]},{6:28,7:58,8:[1,29],9:[1,30],10:84,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:85,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:86,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:87,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:88,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,3],8:[2,3],11:[2,3],12:[2,3],13:[2,3],15:[2,3],17:[2,3],19:[2,3],20:[2,3],21:[2,3],22:[2,3],24:[2,3],25:[2,3],26:[2,3],27:[2,3],34:[2,3],36:[2,3],47:[2,3]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],34:[2,2],36:[2,2],47:[2,2]},{5:[2,4],8:[2,4],11:[2,4],12:[2,4],13:[2,4],15:[2,4],17:[2,4],19:[2,4],20:[2,4],21:[2,4],22:[2,4],24:[2,4],25:[2,4],26:[2,4],27:[2,4],34:[2,4],36:[2,4],47:[2,4]},{5:[2,32],34:[1,33],36:[2,32],47:[2,32]},{5:[2,30],34:[2,30],36:[2,30],47:[2,30]},{5:[2,20],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,20],25:[2,20],26:[2,20],27:[2,20],34:[2,20],36:[2,20],47:[2,20]},{5:[2,21],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,21],25:[2,21],26:[2,21],27:[2,21],34:[2,21],36:[2,21],47:[2,21]},{5:[2,22],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,22],25:[2,22],26:[2,22],27:[2,22],34:[2,22],36:[2,22],47:[2,22]},{5:[2,23],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,23],25:[2,23],26:[2,23],27:[2,23],34:[2,23],36:[2,23],47:[2,23]},{5:[2,25],34:[2,25],36:[2,25],47:[2,25]},{5:[2,27],34:[2,27],36:[2,27],41:[1,44],42:[1,45],46:[1,46],47:[2,27]},{5:[2,26],34:[2,26],36:[2,26],47:[2,26]},{5:[2,28],34:[2,28],36:[2,28],41:[1,44],42:[1,45],46:[1,46],47:[2,28]},{5:[2,15],17:[1,48],19:[2,15],20:[2,15],21:[2,15],22:[2,15],24:[2,15],25:[2,15],26:[2,15],27:[2,15],34:[2,15],36:[2,15],47:[2,15]},{5:[2,16],17:[1,48],19:[2,16],20:[2,16],21:[2,16],22:[2,16],24:[2,16],25:[2,16],26:[2,16],27:[2,16],34:[2,16],36:[2,16],47:[2,16]},{5:[2,17],17:[1,48],19:[2,17],20:[2,17],21:[2,17],22:[2,17],24:[2,17],25:[2,17],26:[2,17],27:[2,17],34:[2,17],36:[2,17],47:[2,17]},{5:[2,18],17:[1,48],19:[2,18],20:[2,18],21:[2,18],22:[2,18],24:[2,18],25:[2,18],26:[2,18],27:[2,18],34:[2,18],36:[2,18],47:[2,18]},{5:[2,37],8:[2,37],11:[2,37],12:[2,37],13:[2,37],15:[2,37],17:[2,37],19:[2,37],20:[2,37],21:[2,37],22:[2,37],24:[2,37],25:[2,37],26:[2,37],27:[2,37],29:[2,37],31:[2,37],34:[2,37],36:[2,37],38:[2,37],41:[2,37],42:[2,37],44:[2,37],46:[2,37],47:[2,37]},{44:[1,89]},{44:[1,90]},{41:[1,44],42:[1,45],44:[1,91],46:[1,46]},{5:[2,41],8:[2,41],11:[2,41],12:[2,41],13:[2,41],15:[2,41],17:[2,41],19:[2,41],20:[2,41],21:[2,41],22:[2,41],24:[2,41],25:[2,41],26:[2,41],27:[2,41],29:[2,41],31:[2,41],34:[2,41],36:[2,41],38:[2,41],41:[2,41],42:[2,41],44:[2,41],46:[2,41],47:[2,41]},{38:[1,83],47:[1,92]},{5:[2,57],8:[2,57],11:[2,57],12:[2,57],13:[2,57],15:[2,57],17:[2,57],19:[2,57],20:[2,57],21:[2,57],22:[2,57],24:[2,57],25:[2,57],26:[2,57],27:[2,57],29:[2,57],31:[2,57],34:[2,57],36:[2,57],38:[2,57],44:[2,57],47:[2,57]},{5:[2,13],8:[1,53],15:[1,52],17:[2,13],19:[2,13],20:[2,13],21:[2,13],22:[2,13],24:[2,13],25:[2,13],26:[2,13],27:[2,13],34:[2,13],36:[2,13],47:[2,13]},{5:[2,49],8:[2,49],11:[2,49],12:[2,49],13:[2,49],15:[2,49],17:[2,49],19:[2,49],20:[2,49],21:[2,49],22:[2,49],24:[2,49],25:[2,49],26:[2,49],27:[2,49],29:[2,49],31:[2,49],34:[2,49],36:[2,49],38:[2,49],44:[2,49],47:[2,49]},{7:93,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,10],8:[2,10],11:[1,54],12:[1,55],13:[1,56],15:[2,10],17:[2,10],19:[2,10],20:[2,10],21:[2,10],22:[2,10],24:[2,10],25:[2,10],26:[2,10],27:[2,10],34:[2,10],36:[2,10],47:[2,10]},{5:[2,11],8:[2,11],11:[1,54],12:[1,55],13:[1,56],15:[2,11],17:[2,11],19:[2,11],20:[2,11],21:[2,11],22:[2,11],24:[2,11],25:[2,11],26:[2,11],27:[2,11],34:[2,11],36:[2,11],47:[2,11]},{5:[2,6],8:[2,6],11:[2,6],12:[2,6],13:[2,6],15:[2,6],17:[2,6],19:[2,6],20:[2,6],21:[2,6],22:[2,6],24:[2,6],25:[2,6],26:[2,6],27:[2,6],34:[2,6],36:[2,6],47:[2,6]},{5:[2,7],8:[2,7],11:[2,7],12:[2,7],13:[2,7],15:[2,7],17:[2,7],19:[2,7],20:[2,7],21:[2,7],22:[2,7],24:[2,7],25:[2,7],26:[2,7],27:[2,7],34:[2,7],36:[2,7],47:[2,7]},{5:[2,8],8:[2,8],11:[2,8],12:[2,8],13:[2,8],15:[2,8],17:[2,8],19:[2,8],20:[2,8],21:[2,8],22:[2,8],24:[2,8],25:[2,8],26:[2,8],27:[2,8],34:[2,8],36:[2,8],47:[2,8]},{5:[2,38],8:[2,38],11:[2,38],12:[2,38],13:[2,38],15:[2,38],17:[2,38],19:[2,38],20:[2,38],21:[2,38],22:[2,38],24:[2,38],25:[2,38],26:[2,38],27:[2,38],29:[2,38],31:[2,38],34:[2,38],36:[2,38],38:[2,38],41:[2,38],42:[2,38],44:[2,38],46:[2,38],47:[2,38]},{5:[2,39],8:[2,39],11:[2,39],12:[2,39],13:[2,39],15:[2,39],17:[2,39],19:[2,39],20:[2,39],21:[2,39],22:[2,39],24:[2,39],25:[2,39],26:[2,39],27:[2,39],29:[2,39],31:[2,39],34:[2,39],36:[2,39],38:[2,39],41:[2,39],42:[2,39],44:[2,39],46:[2,39],47:[2,39]},{5:[2,40],8:[2,40],11:[2,40],12:[2,40],13:[2,40],15:[2,40],17:[2,40],19:[2,40],20:[2,40],21:[2,40],22:[2,40],24:[2,40],25:[2,40],26:[2,40],27:[2,40],29:[2,40],31:[2,40],34:[2,40],36:[2,40],38:[2,40],41:[2,40],42:[2,40],44:[2,40],46:[2,40],47:[2,40]},{5:[2,42],8:[2,42],11:[2,42],12:[2,42],13:[2,42],15:[2,42],17:[2,42],19:[2,42],20:[2,42],21:[2,42],22:[2,42],24:[2,42],25:[2,42],26:[2,42],27:[2,42],29:[2,42],31:[2,42],34:[2,42],36:[2,42],38:[2,42],41:[2,42],42:[2,42],44:[2,42],46:[2,42],47:[2,42]},{38:[2,34],44:[2,34],47:[2,34]}],defaultActions:{31:[2,1]},parseError:function(a,b){if(!b.recoverable)throw new Error(a);this.trace(a)},parse:function(a){function b(){var a;return a=c.lexer.lex()||m,"number"!=typeof a&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(a),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n);var o=this.lexer.options&&this.lexer.options.ranges;this.parseError="function"==typeof this.yy.parseError?this.yy.parseError:Object.getPrototypeOf(this).parseError;for(var p,q,r,s,t,u,v,w,x,y={};;){if(r=d[d.length-1],this.defaultActions[r]?s=this.defaultActions[r]:((null===p||"undefined"==typeof p)&&(p=b()),s=g[r]&&g[r][p]),"undefined"==typeof s||!s.length||!s[0]){var z="";x=[];for(u in g[r])this.terminals_[u]&&u>l&&x.push("'"+this.terminals_[u]+"'");z=this.lexer.showPosition?"Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+x.join(", ")+", got '"+(this.terminals_[p]||p)+"'":"Parse error on line "+(i+1)+": Unexpected "+(p==m?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(z,{text:this.lexer.match,token:this.terminals_[p]||p,line:this.lexer.yylineno,loc:n,expected:x})}if(s[0]instanceof Array&&s.length>1)throw new Error("Parse Error: multiple actions possible at state: "+r+", token: "+p);switch(s[0]){case 1:d.push(p),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(s[1]),p=null,q?(p=q,q=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:if(v=this.productions_[s[1]][1],y.$=e[e.length-v],y._$={first_line:f[f.length-(v||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(v||1)].first_column,last_column:f[f.length-1].last_column},o&&(y._$.range=[f[f.length-(v||1)].range[0],f[f.length-1].range[1]]),t=this.performAction.call(y,h,j,i,this.yy,s[1],e,f),"undefined"!=typeof t)return t;v&&(d=d.slice(0,2*-1*v),e=e.slice(0,-1*v),f=f.slice(0,-1*v)),d.push(this.productions_[s[1]][0]),e.push(y.$),f.push(y._$),w=g[d[d.length-2]][d[d.length-1]],d.push(w);break;case 3:return!0}}return!0}},c=function(){var a={EOF:1,parseError:function(a,b){if(!this.yy.parser)throw new Error(a);this.yy.parser.parseError(a,b)},setInput:function(a){return this._input=a,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var b=a.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},unput:function(a){var b=a.length,c=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b-1),this.offset-=b;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),c.length-1&&(this.yylineno-=c.length-1);var e=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===d.length?this.yylloc.first_column:0)+d[d.length-c.length].length-c[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[e[0],e[0]+this.yyleng-b]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=new Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},test_match:function(a,b){var c,d,e;if(this.options.backtrack_lexer&&(e={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(e.yylloc.range=this.yylloc.range.slice(0))),d=a[0].match(/(?:\r\n?|\n).*/g),d&&(this.yylineno+=d.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:d?d[d.length-1].length-d[d.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+a[0].length},this.yytext+=a[0],this.match+=a[0],this.matches=a,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(a[0].length),this.matched+=a[0],c=this.performAction.call(this,this.yy,this,b,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),c)return c;if(this._backtrack){for(var f in e)this[f]=e[f];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d;this._more||(this.yytext="",this.match="");for(var e=this._currentRules(),f=0;fb[0].length)){if(b=c,d=f,this.options.backtrack_lexer){if(a=this.test_match(c,e[f]),a!==!1)return a;if(this._backtrack){b=!1;continue}return!1}if(!this.options.flex)break}return b?(a=this.test_match(b,e[d]),a!==!1?a:!1):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){var a=this.conditionStack.length-1;return a>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(a){return a=this.conditionStack.length-1-Math.abs(a||0),a>=0?this.conditionStack[a]:"INITIAL"},pushState:function(a){this.begin(a)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(a,b,c,d){switch(c){case 0:return 29;case 1:return 31;case 2:return"from";case 3:return 24;case 4:return 25;case 5:return 21;case 6:return 19;case 7:return 22;case 8:return 20;case 9:return 26;case 10:return 27;case 11:return 34;case 12:return 36;case 13:return 55;case 14:return 53;case 15:break;case 16:return 49;case 17:return 48;case 18:return 48;case 19:return 40;case 20:return 51;case 21:return 41;case 22:return 11;case 23:return 12;case 24:return 13;case 25:return 38;case 26:return 8;case 27:return 26;case 28:return 27;case 29:return 24;case 30:return 24;case 31:return 25;case 32:return 25;case 33:return 21;case 34:return 22;case 35:return 20;case 36:return 19;case 37:return 34;case 38:return 36;case 39:return 15;case 40:return 17;case 41:return 46;case 42:return 44;case 43:return 42;case 44:return 47;case 45:return 9;case 46:return 5}},rules:[/^(?:\s+in\b)/,/^(?:\s+notIn\b)/,/^(?:\s+from\b)/,/^(?:\s+(eq|EQ)\b)/,/^(?:\s+(neq|NEQ)\b)/,/^(?:\s+(lte|LTE)\b)/,/^(?:\s+(lt|LT)\b)/,/^(?:\s+(gte|GTE)\b)/,/^(?:\s+(gt|GT)\b)/,/^(?:\s+(like|LIKE)\b)/,/^(?:\s+(notLike|NOT_LIKE)\b)/,/^(?:\s+(and|AND)\b)/,/^(?:\s+(or|OR)\b)/,/^(?:\s+null\b)/,/^(?:\s+(true|false)\b)/,/^(?:\s+)/,/^(?:-?[0-9]+(?:\.[0-9]+)?\b)/,/^(?:'[^']*')/,/^(?:"[^"]*")/,/^(?:([a-zA-Z_$][0-9a-zA-Z_$]*))/,/^(?:^\/((?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/[imgy]{0,4})(?!\w))/,/^(?:\.)/,/^(?:\*)/,/^(?:\/)/,/^(?:\%)/,/^(?:,)/,/^(?:-)/,/^(?:=~)/,/^(?:!=~)/,/^(?:==)/,/^(?:===)/,/^(?:!=)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:>)/,/^(?:<)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\])/,/^(?:\[)/,/^(?:\))/,/^(?:!)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0}}};return a}();return b.lexer=c,a.prototype=b,b.Parser=a,new a}();"undefined"!=typeof a&&"undefined"!=typeof c&&(c.parser=e,c.Parser=e.Parser,c.parse=function(){return e.parse.apply(e,arguments)},c.main=function(b){b[1]||(console.log("Usage: "+b[0]+" FILE"),d.exit(1));var e=a("fs").readFileSync(a("path").normalize(b[1]),"utf8");return c.parser.parse(e)},"undefined"!=typeof b&&a.main===b&&c.main(d.argv.slice(1)))},{__browserify_process:68,fs:65,path:66}],41:[function(a,b,c){!function(){"use strict";var b=a("./constraint/parser"),d=a("./nools/nool.parser");c.parseConstraint=function(a){try{return b.parse(a)}catch(c){throw new Error("Invalid expression '"+a+"'")}},c.parseRuleSet=function(a,b){return d.parse(a,b)}}()},{"./constraint/parser":40,"./nools/nool.parser":42}],42:[function(a,b,c){"use strict";var d=a("./tokens.js"),e=a("../../extended"),f=e.hash.keys,g=a("./util.js"),h=function(a,b,c){var d=a;a=a.replace(/\/\/(.*)/g,"").replace(/\n|\r|\r\n/g," ");for(var e,i=new RegExp("^("+f(b).join("|")+")");a&&-1!==(e=g.findNextTokenIndex(a));){a=a.substr(e);var j=a.match(i);if(null===j)throw new Error("Error parsing "+a);if(j=j[1],!(j in b))throw new Error("Unknown token"+j);try{a=b[j](a,c,h).replace(/^\s*|\s*$/g,"")}catch(k){throw new Error("Invalid "+j+" definition \n"+k.message+"; \nstarting at : "+d)}}};c.parse=function(a,b){var c={define:[],rules:[],scope:[],loaded:[],file:b};return h(a,d,c),c}},{"../../extended":12,"./tokens.js":43,"./util.js":44}],43:[function(require,module,exports){var process=require("__browserify_process"),utils=require("./util.js"),fs=require("fs"),extd=require("../../extended"),filter=extd.filter,indexOf=extd.indexOf,predicates=["not","or","exists"],predicateRegExp=new RegExp("^("+predicates.join("|")+") *\\((.*)\\)$","m"),predicateBeginExp=new RegExp(" *("+predicates.join("|")+") *\\(","g"),isWhiteSpace=function(a){return 0===a.replace(/[\s|\n|\r|\t]/g,"").length},joinFunc=function(a,b){return"; "+b},splitRuleLineByPredicateExpressions=function(a){var b=a.replace(/,\s*(\$?\w+\s*:)/g,joinFunc),c=filter(b.split(predicateBeginExp),function(a){return""!==a}),d=c.length,e=[];if(!d)return b;for(var f=0;d>f;f++)-1!==indexOf(predicates,c[f])?e.push([c[f],"(",c[++f].replace(/, *$/,"")].join("")):e.push(c[f].replace(/, *$/,""));return e.join(";")},ruleTokens={salience:function(){var a=/^(salience|priority)\s*:\s*(-?\d+)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=parseInt(d[2],10);if(isNaN(e))throw new Error("Invalid salience/priority "+d[2]);return c.options.priority=e,b.replace(d[0],"")}throw new Error("invalid format")}}(),agendaGroup:function(){var a=/^(agenda-group|agendaGroup)\s*:\s*([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid agenda-group "+d[2]);return c.options.agendaGroup=e.replace(/^["']|["']$/g,""),b.replace(d[0],"")}throw new Error("invalid format")}}(),autoFocus:function(){var a=/^(auto-focus|autoFocus)\s*:\s*(true|false)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid auto-focus "+d[2]);return c.options.autoFocus="true"===e?!0:!1,b.replace(d[0],"")}throw new Error("invalid format")}}(),"agenda-group":function(){return this.agendaGroup.apply(this,arguments)},"auto-focus":function(){return this.autoFocus.apply(this,arguments)},priority:function(){return this.salience.apply(this,arguments)},when:function(){var ruleRegExp=/^(\$?\w+) *: *(\w+)(.*)/,constraintRegExp=/(\{ *(?:["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']? *(?:, *["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']?)*)+ *\})/,fromRegExp=/(\bfrom\s+.*)/,parseRules=function(str){for(var rules=[],ruleLines=str.split(";"),l=ruleLines.length,ruleLine,i=0;l>i&&(ruleLine=ruleLines[i].replace(/^\s*|\s*$/g,"").replace(/\n/g,""));i++)if(!isWhiteSpace(ruleLine)){var rule=[];if(predicateRegExp.test(ruleLine)){var m=ruleLine.match(predicateRegExp),pred=m[1].replace(/^\s*|\s*$/g,"");if(rule.push(pred),ruleLine=m[2].replace(/^\s*|\s*$/g,""),"or"===pred){rule=rule.concat(parseRules(splitRuleLineByPredicateExpressions(ruleLine))),rules.push(rule);continue}}var parts=ruleLine.match(ruleRegExp);if(!parts||!parts.length)throw new Error("Invalid constraint "+ruleLine);rule.push(parts[2],parts[1]);var constraints=parts[3].replace(/^\s*|\s*$/g,""),hashParts=constraints.match(constraintRegExp),from=null,fromMatch;if(hashParts){var hash=hashParts[1],constraint=constraints.replace(hash,"");fromRegExp.test(constraint)&&(fromMatch=constraint.match(fromRegExp),from=fromMatch[0],constraint=constraint.replace(fromMatch[0],"")),constraint&&rule.push(constraint.replace(/^\s*|\s*$/g,"")),hash&&rule.push(eval("("+hash.replace(/(\$?\w+)\s*:\s*(\$?\w+)/g,'"$1" : "$2"')+")"))}else constraints&&!isWhiteSpace(constraints)&&(fromRegExp.test(constraints)&&(fromMatch=constraints.match(fromRegExp),from=fromMatch[0],constraints=constraints.replace(fromMatch[0],"")),rule.push(constraints));from&&rule.push(from),rules.push(rule)}return rules};return function(a,b){var c=a.replace(/^when\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(d,""),b.constraints=parseRules(d.replace(/^\{\s*|\}\s*$/g,"")),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}(),then:function(){return function(a,b){if(b.action)throw new Error("action already defined for rule"+b.name);var c=a.replace(/^then\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join(""); -if(c=c.replace(d,""),b.action||(b.action=d.replace(/^\{\s*|\}\s*$/g,"")),!isWhiteSpace(c))throw new Error("Error parsing then block "+a);return c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}()},topLevelTokens={"/":function(a){return a.match(/^\/\*/)?a.replace(/\/\*.*?\*\//,""):a},define:function(a,b){var c=a.replace(/^define\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){d=d[1];var e=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(e,""),b.define.push({name:d,properties:"("+e+")"}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"import":function(a,b,c){if("undefined"!=typeof window)throw new Error("import cannot be used in a browser");var d=a.replace(/^import\s*/,"");if("("===utils.findNextToken(d)){var e=utils.getParamList(d);if(d=d.replace(e,"").replace(/^\s*|\s*$/g,""),";"===utils.findNextToken(d)&&(d=d.replace(/\s*;/,"")),e=e.replace(/[\(|\)]/g,"").split(","),1===e.length){if(e=utils.resolve(b.file||process.cwd(),e[0].replace(/["|']/g,"")),-1===indexOf(b.loaded,e)){var f=b.file;b.file=e,c(fs.readFileSync(e,"utf8"),topLevelTokens,b),b.loaded.push(e),b.file=f}return d}throw new Error("import accepts a single file")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(d)+"'")},global:function(a,b){var c=a.replace(/^global\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*\s*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"="===utils.findNextToken(c)){d=d[1].replace(/^\s+|\s+$/g,"");var e=utils.getTokensBetween(c,"=",";",!0).join(""),f=e.substring(1,e.length-1);if(f=f.replace(/^\s+|\s+$/g,""),/^require\(/.test(f)){var g=utils.getParamList(f.replace("require")).replace(/[\(|\)]/g,"").split(",");1===g.length&&(g=g[0].replace(/["|']/g,""),f=["require('",utils.resolve(b.file||process.cwd(),g),"')"].join(""))}return b.scope.push({name:d,body:f}),c=c.replace(e,"")}throw new Error("unexpected token : expected : '=' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"function":function(a,b){var c=a.replace(/^function\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)\s*/);if(d){if(c=c.replace(d[0],""),"("===utils.findNextToken(c)){d=d[1];var e=utils.getParamList(c);if(c=c.replace(e,"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){var f=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(f,""),b.scope.push({name:d,body:"function"+e+f}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},rule:function(a,b,c){var d=a.replace(/^rule\s*/,""),e=d.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')/);if(e){if(d=d.replace(e[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(d)){e=e[1].replace(/^["']|["']$/g,"");var f={name:e,options:{},constraints:null,action:null},g=utils.getTokensBetween(d,"{","}",!0).join("");return d=d.replace(g,""),c(g.replace(/^\{\s*|\}\s*$/g,""),ruleTokens,f),b.rules.push(f),d}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(d)+"'")}throw new Error("missing name")}};module.exports=topLevelTokens},{"../../extended":12,"./util.js":44,__browserify_process:68,fs:65}],44:[function(a,b,c){var d=a("__browserify_process"),e=a("path"),f=/[\s|\n|\r|\t]/,g=e.sep||("win32"===d.platform?"\\":"/"),h={"{":"}","}":"{","(":")",")":"(","[":"]"},i=c.getTokensBetween=function(a,b,c,d){var e=0,f=[];b||(b=h[c],e=1),c||(c=h[b]),a=Object(a);for(var g,i=!1,j=0,k=!1;g=a.charAt(j++);)if(g===b)e++,i?f.push(g):(i=!0,d&&f.push(g));else if(g===c&&j){if(e--,0===e){d&&f.push(g),k=!0;break}f.push(g)}else i&&f.push(g);if(!k)throw new Error("Unable to match "+b+" in "+a);return f};c.getParamList=function(a){return i(a,"(",")",!0).join("")},c.resolve=function(a,b){return""!==e.extname(a)&&(a=e.dirname(a)),1===b.split(g).length?b:e.resolve(a,b)};var j=c.findNextTokenIndex=function(a,b,c){b=b||0,c=c||a.length;var d=-1,e=a.length;for((!c||c>e)&&(c=e);c>b;b++){var g=a.charAt(b);if(!f.test(g)){d=b;break}}return d};c.findNextToken=function(a,b,c){return a.charAt(j(a,b,c))}},{__browserify_process:68,path:66}],45:[function(a,b,c){"use strict";var d=a("./extended"),e=d.isEmpty,f=d.merge,g=d.forEach,h=d.declare,i=a("./constraintMatcher"),j=a("./constraint"),k=j.EqualityConstraint,l=j.FromConstraint,m=0,n=h({}),o=n.extend({instance:{constructor:function(a,b,c,d,h){h=h||{},this.id=m++,this.type=a,this.alias=b,this.conditions=c,this.pattern=h.pattern;var k=[new j.ObjectConstraint(a)],l=i.toConstraints(c,f({alias:b},h));if(l.length)k=k.concat(l);else{var n=new j.TrueConstraint;k.push(n)}if(d&&!e(d)){var o=new j.HashConstraint(d);k.push(o)}g(k,function(a){a.set("alias",b)}),this.constraints=k},getSpecificity:function(){for(var a=this.constraints,b=0,c=0,d=a.length;d>c;c++)a[c]instanceof k&&b++;return b},hasConstraint:function(a){return d.some(this.constraints,function(b){return b instanceof a})},hashCode:function(){return[this.type,this.alias,d.format("%j",this.conditions)].join(":")},toString:function(){return d.format("%j",this.constraints)}}}).as(c,"ObjectPattern"),p=o.extend({instance:{constructor:function(a,b,c,d,e,f){this._super([a,b,c,d,f]),this.from=new l(e,f)},hasConstraint:function(a){return d.some(this.constraints,function(b){return b instanceof a})},getSpecificity:function(){return this._super(arguments)+1},hashCode:function(){return[this.type,this.alias,d.format("%j",this.conditions),this.from.from].join(":")},toString:function(){return d.format("%j from %s",this.constraints,this.from.from)}}}).as(c,"FromPattern");p.extend().as(c,"FromNotPattern"),o.extend().as(c,"NotPattern"),o.extend().as(c,"ExistsPattern"),p.extend().as(c,"FromExistsPattern"),n.extend({instance:{constructor:function(a,b){this.id=m++,this.leftPattern=a,this.rightPattern=b},hashCode:function(){return[this.leftPattern.hashCode(),this.rightPattern.hashCode()].join(":")},getSpecificity:function(){return this.rightPattern.getSpecificity()+this.leftPattern.getSpecificity()},getters:{constraints:function(){return this.leftPattern.constraints.concat(this.rightPattern.constraints)}}}}).as(c,"CompositePattern");var q=h({instance:{constructor:function(){this.id=m++,this.recency=0}}}).as(c,"InitialFact");o.extend({instance:{constructor:function(){this._super([q,"__i__",[],{}])},assert:function(){return!0}}}).as(c,"InitialFactPattern")},{"./constraint":8,"./constraintMatcher":9,"./extended":12}],46:[function(a,b,c){"use strict";function d(a,b,c,d){f(b)?(d=c,c=b):b=b||{};var g=e.every(c,function(a){return f(a)});g&&1===c.length&&(c=c[0],g=!1);var h=[],i=b.scope||{};if(c.scope=i,g){for(var j,k=function(a,b){m[b]?e(m).forEach(function(b){b.push(a)}):(m[b]=0===b?[]:m[b-1].slice(),0!==b&&m[b].pop(),m[b].push(a))},l=c.length,m=[],n=0;l>n;n++)j=c[n],j.scope=i,e.forEach(y(j),k);h=e.map(m,function(c){for(var e=null,f=0;f>>0;if(0===d)return-1;var e=d;arguments.length>2&&(e=Number(arguments[2]),e!==e?e=0:0!==e&&e!==1/0&&e!==-(1/0)&&(e=(e>0||-1)*P(Q(e))));for(var f=e>=0?R(e,d-1):d-Q(e);f>=0;f--)if(f in c&&c[f]===b)return f;return-1}function i(a,b,c){if(a&&X&&X===a.filter)return a.filter(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)if(g in d){var h=d[g];b.call(c,h,g,d)&&f.push(h)}return f}function j(a,b,c){if(!N(a)||"function"!=typeof b)throw new TypeError;if(a&&T&&T===a.forEach)return a.forEach(b,c),a;for(var d=0,e=a.length;e>d;++d)b.call(c||a,a[d],d,a);return a}function k(a,b,c){if(a&&Y&&Y===a.every)return a.every(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&!b.call(c,d[f],f,d))return!1;return!0}function l(a,b,c){if(a&&Z&&Z===a.some)return a.some(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&b.call(c,d[f],f,d))return!0;return!1}function m(a,b,c){if(a&&U&&U===a.map)return a.map(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)g in d&&f.push(b.call(c,d[g],g,d));return f}function n(a,b,c){var d=arguments.length>2;if(a&&V&&V===a.reduce)return d?a.reduce(b,c):a.reduce(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=0,f=a.length>>0;if(arguments.length<3){if(0===f)throw new TypeError("Array length is 0 and no second argument");c=a[0],e=1}else c=arguments[2];for(;f>e;)e in a&&(c=b.call(void 0,c,a[e],e,a)),++e;return c}function o(a,b,c){var d=arguments.length>2;if(a&&W&&W===a.reduceRight)return d?a.reduceRight(b,c):a.reduceRight(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=Object(a),f=e.length>>>0;if(0===f&&2===arguments.length)throw new TypeError;var g=f-1;if(arguments.length>=3)c=arguments[2];else for(;;)if(g in a){c=a[g--];break}for(;g>=0;)g in e&&(c=b.call(void 0,c,e[g],g,e)),g--;return c}function p(a){var c=[];if(null!==a){var d=$(arguments);if(1===d.length)if(N(a))c=a;else if(b.isHash(a))for(var e in a)a.hasOwnProperty(e)&&c.push([e,a[e]]);else c.push(a);else j(d,function(a){c=c.concat(p(a))})}return c}function q(a){return a=a||[],a.length?n(a,function(a,b){return a+b}):0}function r(a){if(a=a||[],a.length){var c=q(a);if(b.isNumber(c))return c/a.length;throw new Error("Cannot average an array of non numbers.")}return 0}function s(a,b){return _(a,b)}function t(a,b){return _(a,b)[0]}function u(a,b){return _(a,b)[a.length-1]}function v(a){var b=a,c=J($(arguments,1));return N(a)&&(b=i(a,function(a){return-1===g(c,a)})),b}function w(a){var b,c=[],d=-1,e=0;if(a)for(b=a.length;++d0?(c.push(c.shift()),b--):(c.unshift(c.pop()),b++),y(c,b)):c}function z(a,b){var c=[];if(N(a)){var d=a.slice(0);"number"!=typeof b&&(b=a.length),b?b<=a.length&&(c=n(a,function(a,c,f){var g;return g=b>1?e(c,y(d,f).slice(1),b):[[c]],a.concat(g)},[])):c=[[]]}return c}function A(){var a=[],c=$(arguments);if(c.length>1){var d=c.shift();N(d)&&(a=n(d,function(a,d,e){for(var f=[d],g=0;gd;d++)c.push(a[b[d]]||null);return c}function D(){var a=[],b=$(arguments);if(b.length>1){for(var c=0,d=b.length;d>c;c++)a=a.concat(b[c]);a=w(a)}return a}function E(){var a,b,c=[],d=-1;if(a=arguments.length>1?$(arguments):arguments[0],N(a))for(c=a[0],d=0,b=a.length;++d1?c:p(a),n(b,function(a,b){return a.concat(b)},[])}function K(a,b){b=b.split(".");var c=a.slice(0);return j(b,function(a){var b=a.match(/(\w+)\(\)$/);c=m(c,function(c){return b?c[b[1]]():c[a]})}),c}function L(a,b,c){return c=$(arguments,2),m(a,function(a){var d=M(b)?a[b]:b;return d.apply(a,c)})}var M=b.isString,N=Array.isArray||b.isArray,O=b.isDate,P=Math.floor,Q=Math.abs,R=(Math.max,Math.min),S=Array.prototype,T=(S.indexOf,S.forEach),U=S.map,V=S.reduce,W=S.reduceRight,X=S.filter,Y=S.every,Z=S.some,$=c.argsToArray,_=function(){var a=function(a,b){return k(a,b)},b=function(a,b){return a-b},c=function(a,b){return a.getTime()-b.getTime()};return function(d,e){var f=[];return N(d)&&(f=d.slice(),e?"function"==typeof e?f.sort(e):f.sort(function(a,b){var c=a[e],d=b[e];return M(c)&&M(d)?c>d?1:d>c?-1:0:O(c)&&O(d)?c.getTime()-d.getTime():c-d}):a(f,M)?f.sort():a(f,O)?f.sort(c):f.sort(b)),f}}(),ab={toArray:p,sum:q,avg:r,sort:s,min:t,max:u,difference:v,removeDuplicates:w,unique:x,rotate:y,permutations:z,zip:A,transpose:B,valuesAt:C,union:D,intersect:E,powerSet:F,cartesian:G,compact:H,multiply:I,flatten:J,pluck:K,invoke:L,forEach:j,map:m,filter:i,reduce:n,reduceRight:o,some:l,every:k,indexOf:g,lastIndexOf:h};return a.define(N,ab).expose(ab)}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.arrayExtended=d(this.extended,this.isExtended,this.argumentsExtended)}.call(this)},{"arguments-extended":48,extended:53,"is-extended":70}],50:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b,c,d){a=""+a,c=c||" ";for(var e=a.length;b>e;)d?a+=c:a=c+a,e++;return a}function e(a,c,d){var f=a;if(b.isString(f)){if(a.length>c)if(d){var g=a.length;f=a.substring(g-c,g)}else f=a.substring(0,c)}else f=e(""+f,c);return f}function f(a,c,d){if(!b.isArray(a)||"function"!=typeof c)throw new TypeError;for(var e=Object(a),f=e.length>>>0,g=0;f>g;g++)if(g in e&&!c.call(d,e[g],g,e))return!1;return!0}function g(a,b){return A.difference(new Date(a.getFullYear(),0,1,a.getHours()),a,null,b)+1}function h(a,b,c){b=b||0;var d=a[c?"getUTCFullYear":"getFullYear"](),e=new Date(d,0,1).getDay(),f=(e-b+7)%7,h=o((g(a)+f-1)/7);return e===b&&h++,h}function i(a){var b=a.toString(),c="",d=b.indexOf("(");return d>-1&&(c=b.substring(++d,b.indexOf(")"))),c}function j(a,b){return a.replace(/([a-z])\1*/gi,function(a){var c,d=a.charAt(0),e=a.length,f="0?",g="0{0,2}";if("y"===d)c="\\d{2,4}";else if("M"===d)c=e>2?"\\S+?":"1[0-2]|"+f+"[1-9]";else if("D"===d)c="[12][0-9][0-9]|3[0-5][0-9]|36[0-6]|"+g+"[1-9][0-9]|"+f+"[1-9]";else if("d"===d)c="3[01]|[12]\\d|"+f+"[1-9]";else if("w"===d)c="[1-4][0-9]|5[0-3]|"+f+"[1-9]";else if("E"===d)c="\\S+";else if("h"===d)c="1[0-2]|"+f+"[1-9]";else if("K"===d)c="1[01]|"+f+"\\d";else if("H"===d)c="1\\d|2[0-3]|"+f+"\\d";else if("k"===d)c="1\\d|2[0-4]|"+f+"[1-9]";else if("m"===d||"s"===d)c="[0-5]\\d";else if("S"===d)c="\\d{"+e+"}";else if("a"===d){var h="AM",i="PM";c=h+"|"+i,h!==h.toLowerCase()&&(c+="|"+h.toLowerCase()),i!==i.toLowerCase()&&(c+="|"+i.toLowerCase()),c=c.replace(/\./g,"\\.")}else c="v"===d||"z"===d||"Z"===d||"G"===d||"q"===d||"Q"===d?".*":" "===d?"\\s*":d+"*";return b&&b.push(a),"("+c+")"}).replace(/[\xa0 ]/g,"[\\s\\xa0]")}function k(a){B[a+"sFromNow"]=function(b){return A.add(new Date,a,b)},B[a+"sAgo"]=function(b){return A.add(new Date,a,-b)}}for(var l=function(){function a(a,b,c){return a=a.replace(/s$/,""),e.hasOwnProperty(a)?e[a](b,c):[c,"UTC"+a.charAt(0).toUpperCase()+a.substring(1)+"s",!1]}function b(a,b,c,e){return a=a.replace(/s$/,""),d(f[a](b,c,e))}var c=Math.floor,d=Math.round,e={day:function(a,b){return[b,"Date",!1]},weekday:function(a,b){var c,d,e=b%5,f=a.getDay(),g=0;e?(c=e,d=parseInt(b/5,10)):(c=b>0?5:-5,d=b>0?(b-5)/5:(b+5)/5),6===f&&b>0?g=1:0===f&&0>b&&(g=-1);var h=f+c;return(0===h||6===h)&&(g=b>0?2:-2),[7*d+c+g,"Date",!1]},year:function(a,b){return[b,"FullYear",!0]},week:function(a,b){return[7*b,"Date",!1]},quarter:function(a,b){return[3*b,"Month",!0]},month:function(a,b){return[b,"Month",!0]}},f={quarter:function(a,b,d){var e=b.getFullYear()-a.getFullYear(),f=a[d?"getUTCMonth":"getMonth"](),g=b[d?"getUTCMonth":"getMonth"](),h=c(f/3)+1,i=c(g/3)+1;return i+=4*e,i-h},weekday:function(a,c,d){var e,f=b("day",a,c,d),g=f%7;if(0===g)f=5*b("week",a,c,d);else{var h=0,i=a[d?"getUTCDay":"getDay"](),j=c[d?"getUTCDay":"getDay"]();e=parseInt(f/7,10);var k=new Date(+a);k.setDate(k[d?"getUTCDate":"getDate"]()+7*e);var l=k[d?"getUTCDay":"getDay"]();f>0?6===i||6===j?h=-1:0===i?h=0:(0===j||l+g>5)&&(h=-2):0>f&&(6===i?h=0:0===i||0===j?h=1:(6===j||0>l+g)&&(h=2)),f+=h,f-=2*e}return f},year:function(a,b){return b.getFullYear()-a.getFullYear()},month:function(a,b,c){var d=a[c?"getUTCMonth":"getMonth"](),e=b[c?"getUTCMonth":"getMonth"]();return e-d+12*(b.getFullYear()-a.getFullYear())},week:function(a,c,e){return d(b("day",a,c,e)/7)},day:function(a,b){return 1.1574074074074074e-8*(b.getTime()-a.getTime())},hour:function(a,b){return 2.7777777777777776e-7*(b.getTime()-a.getTime())},minute:function(a,b){return 16666666666666667e-21*(b.getTime()-a.getTime())},second:function(a,b){return.001*(b.getTime()-a.getTime())},millisecond:function(a,b){return b.getTime()-a.getTime()}};return{addTransform:a,differenceTransform:b}}(),m=l.addTransform,n=l.differenceTransform,o=Math.floor,p=Math.round,q=Math.min,r=Math.pow,s=Math.ceil,t=Math.abs,u=["January","February","March","April","May","June","July","August","September","October","November","December"],v=["Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."],w=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],x=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],y=["Before Christ","Anno Domini"],z=["BC","AD"],A={getDaysInMonth:function(a){var b=a.getMonth(),c=[31,28,31,30,31,30,31,31,30,31,30,31];return 1===b&&A.isLeapYear(a)?29:c[b]},isLeapYear:function(a,b){var c=a[b?"getUTCFullYear":"getFullYear"]();return 0===c%400||0===c%4&&0!==c%100},isWeekend:function(a,b){var c=(a||new Date)[b?"getUTCDay":"getDay"]();return 0===c||6===c},getTimezoneName:i,compare:function(a,b,c){return a=new Date(+a),b=new Date(+(b||new Date)),"date"===c?(a.setHours(0,0,0,0),b.setHours(0,0,0,0)):"time"===c&&(a.setFullYear(0,0,0),b.setFullYear(0,0,0)),a>b?1:b>a?-1:0},add:function(a,b,c){var d=m(b,a,c||0);c=d[0];var e=d[1],f=new Date(+a),g=d[2];return e&&f["set"+e](f["get"+e]()+c),g&&f.getDate()E?z:y)[0>f?0:1];else if("y"===D)B=f,E>1&&(2===E?B=e(""+B,2,!0):C=!0);else if("Q"===D.toUpperCase())B=s((j+1)/3),C=!0;else if("M"===D)3>E?(B=j+1,C=!0):B=(3===E?v:u)[j];else if("w"===D)B=h(a,0,c),C=!0;else if("D"===D)B=g(a,c),C=!0;else if("E"===D)3>E?(B=k+1,C=!0):B=(-3===E?x:w)[k];else if("a"===D)B=12>m?"AM":"PM";else if("h"===D)B=m%12||12,C=!0;else if("K"===D)B=m%12,C=!0;else if("k"===D)B=m||24,C=!0;else if("S"===D)B=p(A*r(10,E-3)),C=!0;else if("z"===D||"v"===D||"Z"===D){if(B=i(a),"z"!==D&&"v"!==D||B||(E=4),!B||"Z"===D){var F=a.getTimezoneOffset(),G=[F>=0?"-":"+",d(o(t(F)/60),2,"0"),d(t(F)%60,2,"0")];4===E&&(G.splice(0,0,"GMT"),G.splice(3,0,":")),B=G.join("")}}else B=b;else B=""+n,C=!0;else B=""+m,C=!0;return C&&(B=d(B,E,"0")),B})}},B={},C=["year","month","day","hour","minute","second"],D=0,E=C.length;E>D;D++)k(C[D]);var F={parseDate:function(a,b){if(!b)throw new Error("format required when calling dateExtender.parse");var d=[],e=j(b,d),g=new RegExp("^"+e+"$","i"),h=g.exec(a);if(!h)return null;var i=[1970,0,1,0,0,0,0],k="",l=f(h,function(a,b){if(b){var e=d[b-1],f=e.length,g=e.charAt(0);if("y"===g)if(100>a){a=parseInt(a,10);var h=""+(new Date).getFullYear(),j=100*h.substring(0,2),l=q(h.substring(2,4)+20,99);i[0]=l>a?j+a:j-100+a}else i[0]=a;else if("M"===g){if(f>2){var m,n,o=u;3===f&&(o=v),a=a.replace(".","").toLowerCase();var p=!1;for(m=0,n=o.length;n>m&&!p;m++){var r=o[m].replace(".","").toLocaleLowerCase();r===a&&(a=m,p=!0)}if(!p)return!1}else a--;i[1]=a}else if("E"===g||"e"===g){var s=w;3===f&&(s=x),a=a.toLowerCase(),s=c.map(s,function(a){return a.toLowerCase()});var t=c.indexOf(s,a);if(-1===t){if(a=parseInt(a,10),isNaN(a)||a>s.length)return!1}else a=t}else if("D"===g||"d"===g)"D"===g&&(i[1]=0),i[2]=a;else if("a"===g){var y="am",z="pm",A=/\./g;a=a.replace(A,"").toLowerCase(),k=a===z?"p":a===y?"a":""}else"k"===g||"h"===g||"H"===g||"K"===g?("k"===g&&24===+a&&(a=0),i[3]=a):"m"===g?i[4]=a:"s"===g?i[5]=a:"S"===g&&(i[6]=a)}return!0});if(l){var m=+i[3];"p"===k&&12>m?i[3]=m+12:"a"===k&&12===m&&(i[3]=0);var n=new Date(i[0],i[1],i[2],i[3],i[4],i[5],i[6]),o=-1!==c.indexOf(d,"d"),p=-1!==c.indexOf(d,"M"),r=i[1],s=i[2],t=n.getMonth(),y=n.getDate();return p&&t>r||o&&y>s?null:n}return null}},G=a.define(b.isDate,A).define(b.isString,F).define(b.isNumber,B);for(D in A)A.hasOwnProperty(D)&&(G[D]=A[D]);for(D in F)F.hasOwnProperty(D)&&(G[D]=F[D]);for(D in B)B.hasOwnProperty(D)&&(G[D]=B[D]);return G}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c)}):this.dateExtended=d(this.extended,this.isExtended,this.arrayExtended)}.call(this)},{"array-extended":49,extended:53,"is-extended":70}],51:[function(a,b,c){!function(){function a(){function a(a,b){return b=b||0,x.call(a,b)}function b(a){return"[object Array]"===Object.prototype.toString.call(a)}function c(a){var b;return null!==a&&a!==b&&"object"==typeof a}function d(a){var b=c(a);return b&&a.constructor===Object}function e(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function f(a,b,c){var d,f;for(d in b)b.hasOwnProperty(d)&&-1===e(c,d)&&(f=b[d],d in a&&a[d]===f||(a[d]=f));return a}function g(a){var c=this.__meta,d=c.supers,e=d.length,f=c.superMeta,g=f.pos;if(e>g){a=a?B(a)||b(a)?a:[a]:[];var h,i=f.name,j=f.f;do if(h=d[g][i],"function"==typeof h&&(h=h._f||h)!==j)return f.pos=1+g,h.apply(this,a);while(e>++g)}return null}function h(){var a=this.__meta,b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.bind(this);while(c>++e)}return null}function i(a){var b=this.__getters__;return b.hasOwnProperty(a)?b[a].apply(this):this[a]}function j(b,c){var e=this.__setters__;if(!d(b))return e.hasOwnProperty(b)?e[b].apply(this,a(arguments,1)):this[b]=c;for(var f in b){var g=b[f];e.hasOwnProperty(f)?e[b].call(this,g):this[f]=g}}function k(){var a=this.__meta||{},b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.apply(this,arguments);while(c>++e)}return null}function l(a,b){if(a.toString().match(A)){var c=function(){var c,d=this.__meta||{},e=d.superMeta;switch(d.superMeta={f:a,pos:0,name:b},arguments.length){case 0:c=a.call(this);break;case 1:c=a.call(this,arguments[0]);break;case 2:c=a.call(this,arguments[0],arguments[1]);break;case 3:c=a.call(this,arguments[0],arguments[1],arguments[2]);break;default:c=a.apply(this,arguments)}return d.superMeta=e,c};return c._f=a,c}return a._f=a,a}function m(a,b){var c=b.setters||{},d=a.__setters__,e=a.__getters__;for(var f in c)d.hasOwnProperty(f)||(d[f]=c[f]);c=b.getters||{};for(f in c)e.hasOwnProperty(f)||(e[f]=c[f]);for(var g in b)if("getters"!==g&&"setters"!==g){var h=b[g];"function"==typeof h?a.hasOwnProperty(g)||(a[g]=l(k,g)):a[g]=h}}function n(){for(var b=a(arguments),c=b.length,d=this.prototype,e=d.__meta,f=this.__meta,g=d.__meta.bases,h=g.slice(),i=f.supers||[],j=e.supers||[],k=0;c>k;k++){var l=b[k],n=l.prototype,p=n.__meta,q=l.__meta;!p&&(p=n.__meta={proto:n||{}}),!q&&(q=l.__meta={proto:l.__proto__||{}}),m(d,p.proto||{}),m(this,q.proto||{}),o(l.prototype,j,g),o(l,i,h)}return this}function o(a,b,c){var d=a.__meta;!d&&(d=a.__meta={});var f=a.__meta.unique;if(!f&&(d.unique="declare"+ ++y),-1===e(c,f)){c.push(f);for(var g=a.__meta.supers||[],h=g.length-1||0;h>=0;)o(g[h--],b,c);b.unshift(a)}}function p(a,b){var c=b.setters,d=a.__setters__,e=a.__getters__;if(c)for(var f in c)d[f]=c[f];if(c=b.getters||{})for(f in c)e[f]=c[f];for(f in b)if("getters"!=f&&"setters"!=f){var g=b[f];if("function"==typeof g){var h=g.__meta||{};a[f]=h.isConstructor?g:l(g,f)}else a[f]=g}}function q(a,b){return a&&b?a[b]=this:a.exports=a=this,this}function r(a){return u(this,a)}function s(a){z.prototype=a.prototype;var b=new z;return z.prototype=null,b}function t(a,c,e){var i={},j=[],m="declare"+ ++y,q=[],r=[],t=[],u=[],v={supers:t,unique:m,bases:q,superMeta:{f:null,pos:0,name:null}},x={supers:u,unique:m,bases:r,isConstructor:!0,superMeta:{f:null,pos:0,name:null}};if(d(c)&&!e&&(e=c,c=w),"function"==typeof c||b(c)?(j=b(c)?c:[c],c=j.shift(),a.__meta=x,i=s(c),i.__meta=v,i.__getters__=f({},i.__getters__||{}),i.__setters__=f({},i.__setters__||{}),a.__getters__=f({},a.__getters__||{}),a.__setters__=f({},a.__setters__||{}),o(c.prototype,t,q),o(c,u,r)):(a.__meta=x,i.__meta=v,i.__getters__=i.__getters__||{},i.__setters__=i.__setters__||{},a.__getters__=a.__getters__||{},a.__setters__=a.__setters__||{}),a.prototype=i,e){var z=v.proto=e.instance||{},A=x.proto=e.static||{};A.init=A.init||k,p(i,z),p(a,A),i.constructor=z.hasOwnProperty("constructor")?l(z.constructor,"constructor"):z.constructor=l(k,"constructor")}else v.proto={},x.proto={},a.init=l(k,"init"),i.constructor=l(k,"constructor");j.length&&n.apply(a,j),c&&f(a,f(f({},c),a)),i._super=a._super=g,i._getSuper=a._getSuper=h,i._static=a}function u(a,b){function c(){switch(arguments.length){case 0:this.constructor.call(this);break;case 1:this.constructor.call(this,arguments[0]);break;case 2:this.constructor.call(this,arguments[0],arguments[1]);break;case 3:this.constructor.call(this,arguments[0],arguments[1],arguments[2]);break;default:this.constructor.apply(this,arguments)}}return t(c,a,b),c.init()||c}function v(a,b){function c(){return d||(this.constructor.apply(this,arguments),d=this),d}var d;return t(c,a,b),c.init()||c}var w,x=Array.prototype.slice,y=0,z=new Function,A=/(super)/g,B=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};return B(arguments)||(B=function(a){return!(!a||!a.hasOwnProperty("callee"))}),w=u({instance:{get:i,set:j},"static":{get:i,set:j,mixin:n,extend:r,as:q}}),u.singleton=v,u}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=a()):"function"==typeof define&&define.amd?define(a):this.declare=a()}()},{}],52:[function(a,b){b.exports=a("./declare.js")},{"./declare.js":51}],53:[function(a,b,c){!function(){"use strict";function d(a){function b(){var b=a.define(); -return b.expose({register:function(a,c){c||(c=a,a=null);var d=typeof c;if(a)b[a]=c;else if(c&&"function"===d)b.extend(c);else{if("object"!==d)throw new TypeError("extended.register must be called with an extender function");b.expose(c)}return b},define:function(){return a.define.apply(a,arguments)}}),b}function c(){return b()}return function(){function a(a,b){var c,d;for(c in b)b.hasOwnProperty(c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}return function(b){b||(b={});for(var c=1,d=arguments.length;d>c;c++)a(b,arguments[c]);return b}}(),c.define=function(){return a.define.apply(a,arguments)},c}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extender"))):"function"==typeof define&&define.amd?define(["extender"],function(a){return d(a)}):this.extended=d(this.extender)}.call(this)},{extender:55}],54:[function(a,b,c){!function(){function d(a){function b(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function c(a){return"[object Array]"===Object.prototype.toString.call(a)}function d(b){function c(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);a.unshift(this._value);var b=c.apply(this,a);return b!==e?this.__extender__(b):this},a[b]=d}function d(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);return a.unshift(this._value),c.apply(this,a)},a[b]=d}function h(a,b,e){for(var f in b)b.hasOwnProperty(f)&&("getters"!==f&&"setters"!==f?"noWrap"===f?h(a,b[f],!0):e?d(a,f,b[f]):c(a,f,b[f]):a[f]=b[f])}function i(a){var b,c,d=a;if(!(a instanceof m)){var e=m;for(b=0,c=n.length;c>b;b++){var f=n[b];f[0](a)&&(e=e.extend({instance:f[1]}))}d=new e(a),d.__extender__=i}return d}function j(){return!0}function k(a,b){if(arguments.length){"object"==typeof a&&(b=a,a=j),b=b||{};var d={};h(d,b),d.hasOwnProperty("constructor")||(b.hasOwnProperty("constructor")?c(d,"constructor",b.constructor):d.constructor=function(){this._super(arguments)}),n.push([a,d])}return i}function l(a){return a&&a.hasOwnProperty("__defined__")&&(i.__defined__=n=n.concat(a.__defined__)),g(i,a,["define","extend","expose","__defined__"]),i}b=b||[];var m=a({instance:{constructor:function(a){this._value=a},value:function(){return this._value},eq:function(a){return this.__extender__(this._value===a)},neq:function(a){return this.__extender__(this._value!==a)},print:function(){return console.log(this._value),this}}}),n=[];return i.define=k,i.extend=l,i.expose=function(){for(var a,b=0,c=arguments.length;c>b;b++)a=arguments[b],"object"==typeof a&&g(i,a,["define","extend","expose","__defined__"]);return i},i.__defined__=n,i}var e,f=Array.prototype.slice,g=function(){function a(a,c,d){var e,f;for(e in c)c.hasOwnProperty(e)&&-1===b(d,e)&&(f=c[e],e in a&&a[e]===f||(a[e]=f));return a}return function(b){b||(b={});var d=arguments.length,e=arguments[arguments.length-1];c(e)?d--:e=[];for(var f=1;d>f;f++)a(b,arguments[f],e);return b}}();return{define:function(){return d().define.apply(d,arguments)},extend:function(a){return d().define().extend(a)}}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("declare.js"))):"function"==typeof define&&define.amd?define(["declare"],function(a){return d(a)}):this.extender=d(this.declare)}.call(this)},{"declare.js":52}],55:[function(a,b){b.exports=a("./extender.js")},{"./extender.js":54}],56:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b,c){var d;switch((b||[]).length){case 0:d=a.call(c);break;case 1:d=a.call(c,b[0]);break;case 2:d=a.call(c,b[0],b[1]);break;case 3:d=a.call(c,b[0],b[1],b[2]);break;default:d=a.apply(c,b)}return d}function e(a,b,c){if(c=p(arguments,2),n(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!n(b)&&!o(b))throw new Error(b+" is not a function");return n(b)?function(){var d=a[b];if(o(d)){var e=c.concat(p(arguments));return d.apply(a,e)}return d}:c.length?function(){return c.concat(p(arguments)),d(b,arguments,a)}:function(){return d(b,arguments,a)}}function f(a,b){if(b=p(arguments,1),!n(a)&&!o(a))throw new Error(a+" must be the name of a property or function to execute");return n(a)?function(){var c=p(arguments),d=c.shift(),e=d[a];return o(e)?(c=b.concat(c),e.apply(d,c)):e}:function(){var c=p(arguments),d=c.shift();return c=b.concat(c),a.apply(d,c)}}function g(a,b,c){if(c=p(arguments,2),n(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!n(b)&&!o(b))throw new Error(b+" is not a function");return n(b)?function(){var d=a[b];return o(d)?d.apply(a,c):d}:function(){return b.apply(a,c)}}function h(a){var b=p(arguments,1);if(!m(a)&&!o(a))throw new TypeError("scope must be an object");if(1===b.length&&l(b[0])&&(b=b[0]),!b.length){b=[];for(var c in a)a.hasOwnProperty(c)&&o(a[c])&&b.push(c)}for(var d=0,f=b.length;f>d;d++)a[b[d]]=e(a,a[b[d]]);return a}function i(a,b){if(b=p(arguments,1),!n(a)&&!o(a))throw new Error(a+" must be the name of a property or function to execute");return n(a)?function(){var c=this[a];if(o(c)){var d=b.concat(p(arguments));return c.apply(this,d)}return c}:function(){var c=b.concat(p(arguments));return a.apply(this,c)}}function j(a,b){return function(){var c=p(arguments);return b?a.apply(this,arguments):function(){return a.apply(this,c.concat(p(arguments)))}}}function k(a,b,c){var d;if(d=c?e(c,b):b,a)for(var f=a-1,g=f;g>=0;g--)d=j(d,g===f);return d}var l=b.isArray,m=b.isObject,n=b.isString,o=b.isFunction,p=c.argsToArray;return a.define(m,{bind:e,bindAll:h,bindIgnore:g,curry:function(a,b,c){return k(b,c,a)}}).define(o,{bind:function(a,b){return e.apply(this,[b,a].concat(p(arguments,2)))},bindIgnore:function(a,b){return g.apply(this,[b,a].concat(p(arguments,2)))},partial:i,applyFirst:f,curry:function(a,b,c){return k(b,a,c)},noWrap:{f:function(){return this.value()}}}).define(n,{bind:function(a,b){return e(b,a)},bindIgnore:function(a,b){return g(b,a)},partial:i,applyFirst:f,curry:function(a,b,c){return k(b,a,c)}}).expose({bind:e,bindAll:h,bindIgnore:g,partial:i,applyFirst:f,curry:k})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.functionExtended=d(this.extended,this.isExtended,this.argumentsExtended)}.call(this)},{"arguments-extended":57,extended:58,"is-extended":63}],57:[function(a,b,c){!function(){"use strict";function d(a,b){function c(a,b){var c=-1,d=0,e=a.length,f=[];for(b=b||0,c+=b;++cc;c++)a(b,arguments[c]);return b}}(),c.define=function(){return a.define.apply(a,arguments)},c}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extender"))):"function"==typeof define&&define.amd?define(["extender"],function(a){return d(a)}):this.extended=d(this.extender)}.call(this)},{extender:60}],59:[function(a,b,c){!function(){function d(a){function b(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function c(a){return"[object Array]"===Object.prototype.toString.call(a)}function d(b){function c(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);a.unshift(this._value);var b=c.apply(this,a);return b!==e?this.__extender__(b):this},a[b]=d}function d(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);return a.unshift(this._value),c.apply(this,a)},a[b]=d}function h(a,b,e){for(var f in b)b.hasOwnProperty(f)&&("getters"!==f&&"setters"!==f?"noWrap"===f?h(a,b[f],!0):e?d(a,f,b[f]):c(a,f,b[f]):a[f]=b[f])}function i(a){var b,c,d=a;if(!(a instanceof m)){var e=m;for(b=0,c=n.length;c>b;b++){var f=n[b];f[0](a)&&(e=e.extend({instance:f[1]}))}d=new e(a),d.__extender__=i}return d}function j(){return!0}function k(a,b){if(arguments.length){"object"==typeof a&&(b=a,a=j),b=b||{};var d={};h(d,b),d.hasOwnProperty("constructor")||(b.hasOwnProperty("constructor")?c(d,"constructor",b.constructor):d.constructor=function(){this._super(arguments)}),n.push([a,d])}return i}function l(a){return a&&a.hasOwnProperty("__defined__")&&(i.__defined__=n=n.concat(a.__defined__)),g(i,a,["define","extend","expose","__defined__"]),i}b=b||[];var m=a({instance:{constructor:function(a){this._value=a},value:function(){return this._value},eq:function(a){return this.__extender__(this._value===a)},neq:function(a){return this.__extender__(this._value!==a)},print:function(){return console.log(this._value),this}}}),n=[];return i.define=k,i.extend=l,i.expose=function(){for(var a,b=0,c=arguments.length;c>b;b++)a=arguments[b],"object"==typeof a&&g(i,a,["define","extend","expose","__defined__"]);return i},i.__defined__=n,i}var e,f=Array.prototype.slice,g=function(){function a(a,c,d){var e,f;for(e in c)c.hasOwnProperty(e)&&-1===b(d,e)&&(f=c[e],e in a&&a[e]===f||(a[e]=f));return a}return function(b){b||(b={});var d=arguments.length,e=arguments[arguments.length-1];c(e)?d--:e=[];for(var f=1;d>f;f++)a(b,arguments[f],e);return b}}();return{define:function(){return d().define.apply(d,arguments)},extend:function(a){return d().define().extend(a)}}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("declare.js"))):"function"==typeof define&&define.amd?define(["declare"],function(a){return d(a)}):this.extender=d(this.declare)}.call(this)},{"declare.js":62}],60:[function(a,b){b.exports=a("./extender.js")},{"./extender.js":59}],61:[function(a,b,c){!function(){function a(){function a(a,b){return b=b||0,x.call(a,b)}function b(a){return"[object Array]"===Object.prototype.toString.call(a)}function c(a){var b;return null!==a&&a!==b&&"object"==typeof a}function d(a){var b=c(a);return b&&a.constructor===Object}function e(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function f(a,b,c){var d,f;for(d in b)b.hasOwnProperty(d)&&-1===e(c,d)&&(f=b[d],d in a&&a[d]===f||(a[d]=f));return a}function g(a){var c=this.__meta,d=c.supers,e=d.length,f=c.superMeta,g=f.pos;if(e>g){a=a?B(a)||b(a)?a:[a]:[];var h,i=f.name,j=f.f;do if(h=d[g][i],"function"==typeof h&&(h=h._f||h)!==j)return f.pos=1+g,h.apply(this,a);while(e>++g)}return null}function h(){var a=this.__meta,b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.bind(this);while(c>++e)}return null}function i(a){var b=this.__getters__;return b.hasOwnProperty(a)?b[a].apply(this):this[a]}function j(b,c){var e=this.__setters__;if(!d(b))return e.hasOwnProperty(b)?e[b].apply(this,a(arguments,1)):this[b]=c;for(var f in b){var g=b[f];e.hasOwnProperty(f)?e[b].call(this,g):this[f]=g}}function k(){var a=this.__meta||{},b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.apply(this,arguments);while(c>++e)}return null}function l(a,b){if(a.toString().match(A)){var c=function(){var c,d=this.__meta||{},e=d.superMeta;switch(d.superMeta={f:a,pos:0,name:b},arguments.length){case 0:c=a.call(this);break;case 1:c=a.call(this,arguments[0]);break;case 2:c=a.call(this,arguments[0],arguments[1]);break;case 3:c=a.call(this,arguments[0],arguments[1],arguments[2]);break;default:c=a.apply(this,arguments)}return d.superMeta=e,c};return c._f=a,c}return a._f=a,a}function m(a,b){var c=b.setters||{},d=a.__setters__,e=a.__getters__;for(var f in c)d.hasOwnProperty(f)||(d[f]=c[f]);c=b.getters||{};for(f in c)e.hasOwnProperty(f)||(e[f]=c[f]);for(var g in b)if("getters"!==g&&"setters"!==g){var h=b[g];"function"==typeof h?a.hasOwnProperty(g)||(a[g]=l(k,g)):a[g]=h}}function n(){for(var b=a(arguments),c=b.length,d=this.prototype,e=d.__meta,f=this.__meta,g=d.__meta.bases,h=g.slice(),i=f.supers||[],j=e.supers||[],k=0;c>k;k++){var l=b[k],n=l.prototype,p=n.__meta,q=l.__meta;!p&&(p=n.__meta={proto:n||{}}),!q&&(q=l.__meta={proto:l.__proto__||{}}),m(d,p.proto||{}),m(this,q.proto||{}),o(l.prototype,j,g),o(l,i,h)}return this}function o(a,b,c){var d=a.__meta;!d&&(d=a.__meta={});var f=a.__meta.unique;if(!f&&(d.unique="declare"+ ++y),-1===e(c,f)){c.push(f);for(var g=a.__meta.supers||[],h=g.length-1||0;h>=0;)o(g[h--],b,c);b.unshift(a)}}function p(a,b){var c=b.setters,d=a.__setters__,e=a.__getters__;if(c)for(var f in c)d[f]=c[f];if(c=b.getters||{})for(f in c)e[f]=c[f];for(f in b)if("getters"!=f&&"setters"!=f){var g=b[f];if("function"==typeof g){var h=g.__meta||{};a[f]=h.isConstructor?g:l(g,f)}else a[f]=g}}function q(a,b){return a&&b?a[b]=this:a.exports=a=this,this}function r(a){return u(this,a)}function s(a){z.prototype=a.prototype;var b=new z;return z.prototype=null,b}function t(a,c,e){var i={},j=[],m="declare"+ ++y,q=[],r=[],t=[],u=[],v={supers:t,unique:m,bases:q,superMeta:{f:null,pos:0,name:null}},x={supers:u,unique:m,bases:r,isConstructor:!0,superMeta:{f:null,pos:0,name:null}};if(d(c)&&!e&&(e=c,c=w),"function"==typeof c||b(c)?(j=b(c)?c:[c],c=j.shift(),a.__meta=x,i=s(c),i.__meta=v,i.__getters__=f({},i.__getters__||{}),i.__setters__=f({},i.__setters__||{}),a.__getters__=f({},a.__getters__||{}),a.__setters__=f({},a.__setters__||{}),o(c.prototype,t,q),o(c,u,r)):(a.__meta=x,i.__meta=v,i.__getters__=i.__getters__||{},i.__setters__=i.__setters__||{},a.__getters__=a.__getters__||{},a.__setters__=a.__setters__||{}),a.prototype=i,e){var z=v.proto=e.instance||{},A=x.proto=e.static||{};A.init=A.init||k,p(i,z),p(a,A),i.constructor=z.hasOwnProperty("constructor")?l(z.constructor,"constructor"):z.constructor=l(k,"constructor")}else v.proto={},x.proto={},a.init=l(k,"init"),i.constructor=l(k,"constructor");j.length&&n.apply(a,j),c&&f(a,f(f({},c),a)),i._super=a._super=g,i._getSuper=a._getSuper=h,i._static=a}function u(a,b){function c(){this.constructor.apply(this,arguments)}return t(c,a,b),c.init()||c}function v(a,b){function c(){return d||(this.constructor.apply(this,arguments),d=this),d}var d;return t(c,a,b),c.init()||c}var w,x=Array.prototype.slice,y=0,z=new Function,A=/(super)/g,B=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};return B(arguments)||(B=function(a){return!(!a||!a.hasOwnProperty("callee"))}),w=u({instance:{get:i,set:j},"static":{get:i,set:j,mixin:n,extend:r,as:q}}),u.singleton=v,u}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=a()):"function"==typeof define&&define.amd?define(a):this.declare=a()}()},{}],62:[function(a,b){b.exports=a("./declare.js")},{"./declare.js":61}],63:[function(a,b,c){var d=a("__browserify_Buffer").Buffer;!function(){"use strict";function e(a){function b(a,b){return b=b||0,S.call(a,b)}function c(a){var b=[];for(var c in a)T.call(a,c)&&b.push(c);return b}function e(a,b){if(a===b)return!0;if("undefined"!=typeof d&&d.isBuffer(a)&&d.isBuffer(b)){if(a.length!==b.length)return!1;for(var c=0;c=0;f--)if(g[f]!==h[f])return!1;for(f=g.length-1;f>=0;f--)if(d=g[f],!e(a[d],b[d]))return!1}catch(i){return!1}return!0}function g(a){return null!==a&&"object"==typeof a}function h(a){var b=g(a);return b&&a.constructor===Object&&!a.nodeType&&!a.setInterval}function i(a){return W(a)?0===a.length:g(a)?0===c(a).length:r(a)||X(a)?0===a.length:!0}function j(a){return a===!0||a===!1||"[object Boolean]"===U.call(a)}function k(a){return"undefined"==typeof a}function l(a){return!k(a)}function m(a){return k(a)||n(a)}function n(a){return null===a}function o(a,b){return V(b)?a instanceof b:!1}function p(a){return"[object RegExp]"===U.call(a)}function q(a){return"[object Date]"===U.call(a)}function r(a){return"[object String]"===U.call(a)}function s(a){return"[object Number]"===U.call(a)}function t(a){return a===!0}function u(a){return a===!1}function v(a){return!n(a)}function w(a,b){return a==b}function x(a,b){return a!=b}function y(a,b){return a===b}function z(a,b){return a!==b}function A(a,b){if(X(b)&&Array.prototype.indexOf||r(b))return b.indexOf(a)>-1;if(X(b))for(var c=0,d=b.length;d>c;c++)if(w(a,b[c]))return!0;return!1}function B(a,b){return!A(a,b)}function C(a,b){return b>a}function D(a,b){return b>=a}function E(a,b){return a>b}function F(a,b){return a>=b}function G(a,b){return r(b)?null!==(""+a).match(b):p(b)?b.test(a):!1}function H(a,b){return!G(a,b)}function I(a,b){return A(b,a)}function J(a,b){return!A(b,a)}function K(a,b,c){return X(a)&&a.length>c?w(a[c],b):!1}function L(a,b,c){return X(a)?!w(a[c],b):!1}function M(a,b){return T.call(a,b)}function N(a,b){return!M(a,b)}function O(a,b){return M(a,"length")?a.length===b:!1}function P(a,b){return M(a,"length")?a.length!==b:!1}function Q(a){Z[a]=function(){this._testers.push(Y[a])}}function R(a){$[a]=function(){var c,d=b(arguments,1),e=Y[a],f=!0;if(d.length<=e.length-1)throw new TypeError("A handler must be defined when calling using switch");if(c=d.pop(),j(c)&&(f=c,c=d.pop()),!V(c))throw new TypeError("handler must be defined");this._cases.push(function(a){return e.apply(Y,a.concat(d))?[f,c.apply(this,a)]:[!1]})}}var S=Array.prototype.slice,T=Object.prototype.hasOwnProperty,U=Object.prototype.toString,V=function(a){return"[object Function]"===U.call(a)};"undefined"==typeof window||V(window.alert)||function(a){V=function(b){return"[object Function]"===U.call(b)||b===a}}(window.alert);var W=function(a){return"[object Arguments]"===U.call(a)};W(arguments)||(W=function(a){return!(!a||!T.call(a,"callee"))});var X=Array.isArray||function(a){return"[object Array]"===U.call(a)},Y={isFunction:V,isObject:g,isEmpty:i,isHash:h,isNumber:s,isString:r,isDate:q,isArray:X,isBoolean:j,isUndefined:k,isDefined:l,isUndefinedOrNull:m,isNull:n,isArguments:W,instanceOf:o,isRegExp:p,deepEqual:e,isTrue:t,isFalse:u,isNotNull:v,isEq:w,isNeq:x,isSeq:y,isSneq:z,isIn:A,isNotIn:B,isLt:C,isLte:D,isGt:E,isGte:F,isLike:G,isNotLike:H,contains:I,notContains:J,has:M,notHas:N,isLength:O,isNotLength:P,containsAt:K,notContainsAt:L},Z={constructor:function(){this._testers=[]},noWrap:{tester:function(){var a=this._testers;return function(b){for(var c=!1,d=0,e=a.length;e>d&&!c;d++)c=a[d](b);return c}}}},$={constructor:function(){this._cases=[],this.__default=null},def:function(a,b){this.__default=b},noWrap:{switcher:function(){var a=this._cases,c=this.__default;return function(){for(var d,e=!1,f=b(arguments),g=0,h=a.length;h>g&&!e;g++)if(d=a[g](f),d.length>1&&(d[1]||d[0]))return d[1];return!e&&c?c.apply(this,f):void 0}}}};for(var _ in Y)T.call(Y,_)&&(R(_),Q(_));var ab=a.define(Y).expose(Y);return ab.tester=a.define(Z),ab.switcher=a.define($),ab}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("extended"))):"function"==typeof define&&define.amd?define(["extended"],function(a){return e(a)}):this.isExtended=e(this.extended)}.call(this)},{__browserify_Buffer:67,extended:58}],64:[function(a,b,c){function d(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;ce;e++)d[e].apply(this,c);return!0}return!1},f.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(g(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:h,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},f.prototype.on=f.prototype.addListener,f.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},f.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(g(c)){var e=d(c,b);if(0>e)return this;c.splice(e,1),0==c.length&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},f.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},f.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),g(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]},f.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?"function"==typeof a._events[b]?1:a._events[b].length:0}},{__browserify_process:68}],65:[function(){},{}],66:[function(a,b,c){function d(a,b){for(var c=[],d=0;d=0;d--){var e=a[d];"."==e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var f=a("__browserify_process"),g=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){for(var a="",b=!1,c=arguments.length;c>=-1&&!b;c--){var g=c>=0?arguments[c]:f.cwd();"string"==typeof g&&g&&(a=g+"/"+a,b="/"===g.charAt(0))}return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b="/"===a.charAt(0),c="/"===a.slice(-1);return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),a||b||(a="."),a&&c&&(a+="/"),(b?"/":"")+a},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(d(a,function(a){return a&&"string"==typeof a}).join("/"))},c.dirname=function(a){var b=g.exec(a)[1]||"",c=!1;return b?1===b.length||c&&b.length<=3&&":"===b.charAt(1)?b:b.substring(0,b.length-1):"."},c.basename=function(a,b){var c=g.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return g.exec(a)[3]||""},c.relative=function(a,b){function d(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;i=0;e--)if(f[e]!=g[e])return!1;for(e=f.length-1;e>=0;e--)if(d=f[e],!h(a[d],b[d]))return!1;return!0}function l(a,b){return a&&b?b instanceof RegExp?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function m(a,b,c,d){var e;"string"==typeof c&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f("Missing expected exception"+d),!a&&l(e,c)&&f("Got unwanted exception"+d),a&&e&&c&&!l(e,c)||!a&&e)throw e}var n=a("util"),o=a("buffer").Buffer,p=Array.prototype.slice,q=b.exports=g;q.AssertionError=function(a){this.name="AssertionError",this.message=a.message,this.actual=a.actual,this.expected=a.expected,this.operator=a.operator;var b=a.stackStartFunction||f;Error.captureStackTrace&&Error.captureStackTrace(this,b)},n.inherits(q.AssertionError,Error),q.AssertionError.prototype.toString=function(){return this.message?[this.name+":",this.message].join(" "):[this.name+":",e(JSON.stringify(this.actual,d),128),this.operator,e(JSON.stringify(this.expected,d),128)].join(" ")},q.AssertionError.__proto__=Error.prototype,q.fail=f,q.ok=g,q.equal=function(a,b,c){a!=b&&f(a,b,c,"==",q.equal)},q.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",q.notEqual)},q.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",q.deepEqual)},q.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",q.notDeepEqual)},q.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",q.strictEqual)},q.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",q.notStrictEqual)},q.throws=function(){m.apply(this,[!0].concat(p.call(arguments)))},q.doesNotThrow=function(){m.apply(this,[!1].concat(p.call(arguments)))},q.ifError=function(a){if(a)throw a}},{util:2,buffer:3}],2:[function(a,b,c){function d(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&d(a.__proto__)}function e(a){return a instanceof RegExp||"object"==typeof a&&"[object RegExp]"===Object.prototype.toString.call(a)}function f(a){if(a instanceof Date)return!0;if("object"!=typeof a)return!1;var b=Date.prototype&&h(Date.prototype),c=a.__proto__&&h(a.__proto__);return JSON.stringify(c)===JSON.stringify(b)}a("events"),c.isArray=d,c.isDate=function(a){return"[object Date]"===Object.prototype.toString.call(a)},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)},c.print=function(){},c.puts=function(){},c.debug=function(){},c.inspect=function(a,b,i,j){function k(a,i){if(a&&"function"==typeof a.inspect&&a!==c&&(!a.constructor||a.constructor.prototype!==a))return a.inspect(i);switch(typeof a){case"undefined":return m("undefined","undefined");case"string":var j="'"+JSON.stringify(a).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return m(j,"string");case"number":return m(""+a,"number");case"boolean":return m(""+a,"boolean")}if(null===a)return m("null","null");var n=g(a),o=b?h(a):n;if("function"==typeof a&&0===o.length){if(e(a))return m(""+a,"regexp");var p=a.name?": "+a.name:"";return m("[Function"+p+"]","special")}if(f(a)&&0===o.length)return m(a.toUTCString(),"date");var q,r,s;if(d(a)?(r="Array",s=["[","]"]):(r="Object",s=["{","}"]),"function"==typeof a){var t=a.name?": "+a.name:"";q=e(a)?" "+a:" [Function"+t+"]"}else q="";if(f(a)&&(q=" "+a.toUTCString()),0===o.length)return s[0]+q+s[1];if(0>i)return e(a)?m(""+a,"regexp"):m("[Object]","special");l.push(a);var u=o.map(function(b){var c,e;if(a.__lookupGetter__&&(a.__lookupGetter__(b)?e=a.__lookupSetter__(b)?m("[Getter/Setter]","special"):m("[Getter]","special"):a.__lookupSetter__(b)&&(e=m("[Setter]","special"))),n.indexOf(b)<0&&(c="["+b+"]"),e||(l.indexOf(a[b])<0?(e=null===i?k(a[b]):k(a[b],i-1),e.indexOf("\n")>-1&&(e=d(a)?e.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+e.split("\n").map(function(a){return" "+a}).join("\n"))):e=m("[Circular]","special")),"undefined"==typeof c){if("Array"===r&&b.match(/^\d+$/))return e;c=JSON.stringify(""+b),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=m(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=m(c,"string"))}return c+": "+e});l.pop();var v=0,w=u.reduce(function(a,b){return v++,b.indexOf("\n")>=0&&v++,a+b.length+1},0);return u=w>50?s[0]+(""===q?"":q+"\n ")+" "+u.join(",\n ")+" "+s[1]:s[0]+q+" "+u.join(", ")+" "+s[1]}var l=[],m=function(a,b){var c={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[b];return d?"["+c[d][0]+"m"+a+"["+c[d][1]+"m":a};return j||(m=function(a){return a}),k(a,"undefined"==typeof i?2:i)},c.log=function(){},c.pump=null;var g=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},h=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.hasOwnProperty.call(a,c)&&b.push(c);return b},i=Object.create||function(a,b){var c;if(null===a)c={__proto__:null};else{if("object"!=typeof a)throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}return"undefined"!=typeof b&&Object.defineProperties&&Object.defineProperties(c,b),c};c.inherits=function(a,b){a.super_=b,a.prototype=i(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}) -};var j=/%[sdj%]/g;c.format=function(a){if("string"!=typeof a){for(var b=[],d=0;d=f)return a;switch(a){case"%s":return String(e[d++]);case"%d":return Number(e[d++]);case"%j":return JSON.stringify(e[d++]);default:return a}}),h=e[d];f>d;h=e[++d])g+=null===h||"object"!=typeof h?" "+h:" "+c.inspect(h);return g}},{events:4}],5:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],6:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],4:[function(a,b,c){!function(a){function b(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;cf;f++)d[f].apply(this,c);return!0}return!1},d.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(e(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:f,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},d.prototype.removeListener=function(a,c){if("function"!=typeof c)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var d=this._events[a];if(e(d)){var f=b(d,c);if(0>f)return this;d.splice(f,1),0==d.length&&delete this._events[a]}else this._events[a]===c&&delete this._events[a];return this},d.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},d.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),e(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}(a("__browserify_process"))},{__browserify_process:6}],"buffer-browserify":[function(a,b){b.exports=a("q9TxCC")},{}],q9TxCC:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used=a.length?0:(c?(e=a.parent[a.offset+b]<<8,b+1=a.length?0:(c?(b+1>>0):(b+2>>0)),e)}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8*(d?1-f:f)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>8*(d?3-f:f)}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fthis.length)throw new Error("oob");if(b>c)throw new Error("oob");for(var d=b;c>d;d++)this[d]=a},c.SlowBuffer=d,c.Buffer=l,l.poolSize=8192;var E;l.isBuffer=function(a){return a instanceof l||a instanceof d},l.concat=function(a,b){if(!Array.isArray(a))throw new Error("Usage: Buffer.concat(list, [totalLength])\n list should be an Array.");if(0===a.length)return new l(0);if(1===a.length)return a[0];if("number"!=typeof b){b=0;for(var c=0;cd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=c.length?void 0:c.parent[c.offset+a]},l.prototype.readUInt16LE=function(a,b){return o(this,a,!1,b)},l.prototype.readUInt16BE=function(a,b){return o(this,a,!0,b)},l.prototype.readUInt32LE=function(a,b){return p(this,a,!1,b)},l.prototype.readUInt32BE=function(a,b){return p(this,a,!0,b)},l.prototype.readInt8=function(a,b){var c,d=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=d.length?void 0:(c=128&d.parent[d.offset+a],c?-1*(255-d.parent[d.offset+a]+1):d.parent[d.offset+a])},l.prototype.readInt16LE=function(a,b){return q(this,a,!1,b)},l.prototype.readInt16BE=function(a,b){return q(this,a,!0,b)},l.prototype.readInt32LE=function(a,b){return r(this,a,!1,b)},l.prototype.readInt32BE=function(a,b){return r(this,a,!0,b)},l.prototype.readFloatLE=function(a,b){return s(this,a,!1,b)},l.prototype.readFloatBE=function(a,b){return s(this,a,!0,b)},l.prototype.readDoubleLE=function(a,b){return t(this,a,!1,b)},l.prototype.readDoubleBE=function(a,b){return t(this,a,!0,b)},l.prototype.writeUInt8=function(a,b,c){var d=this;c||(D.ok(void 0!==a&&null!==a,"missing value"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":5,"base64-js":7}],7:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(255&f>>8),h.push(255&f)),h}function c(a){function b(a){return d[63&a>>18]+d[63&a>>12]+d[63&a>>6]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[63&e<<4],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[63&e>>4],h+=d[63&e<<2],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}],8:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],3:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used>>0):(e=a.parent[a.offset+b+2]<<16,e|=a.parent[a.offset+b+1]<<8,e|=a.parent[a.offset+b],e+=a.parent[a.offset+b+3]<<24>>>0),e}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8,a.parent[a.offset+c+1]=255&b):(a.parent[a.offset+c+1]=(65280&b)>>>8,a.parent[a.offset+c]=255&b)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>24,a.parent[a.offset+c+1]=255&b>>>16,a.parent[a.offset+c+2]=255&b>>>8,a.parent[a.offset+c+3]=255&b):(a.parent[a.offset+c+3]=255&b>>>24,a.parent[a.offset+c+2]=255&b>>>16,a.parent[a.offset+c+1]=255&b>>>8,a.parent[a.offset+c]=255&b)}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob"); -if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":8,"base64-js":9}],9:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(255&f>>8),h.push(255&f)),h}function c(a){function b(a){return d[63&a>>18]+d[63&a>>12]+d[63&a>>6]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[63&e<<4],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[63&e>>4],h+=d[63&e<<2],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}]},{},[]),b.exports=a("buffer-browserify")},{}],68:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],69:[function(a,b,c){!function(){"use strict";function d(a){var b=function(a){return"string"==typeof a?a:"object"==typeof a?a.hashCode?a.hashCode():""+a:""+a},c=a.declare({instance:{constructor:function(){this.__entries=[],this.__keys=[],this.__values=[]},pushValue:function(a,b){return this.__keys.push(a),this.__values.push(b),this.__entries.push({key:a,value:b}),b},remove:function(a){for(var b,c=null,d=this.__entries,e=this.__keys,f=this.__values,g=d.length-1;g>=0;g--)if((b=d[g])&&b.key===a)return d.splice(g,1),e.splice(g,1),f.splice(g,1),b.value;return c},set:function(a,b){for(var c=null,d=this.__entries,e=this.__values,f=d.length-1;f>=0;f--){var g=d[f];if(g&&a===g.key){e[f]=b,g.value=b,c=b;break}}return c||d.push({key:a,value:b}),c},find:function(a){for(var b,c=null,d=this.__entries,e=d.length-1;e>=0;e--)if(b=d[e],b&&a===b.key){c=b.value;break}return c},getEntrySet:function(){return this.__entries},getKeys:function(){return this.__keys},getValues:function(){return this.__values}}});return a.declare({instance:{constructor:function(){this.__map={}},entrySet:function(){var a=[],b=this.__map;for(var c in b)b.hasOwnProperty(c)&&(a=a.concat(b[c].getEntrySet()));return a},put:function(a,d){var e=b(a),f=null;return(f=this.__map[e])||(f=this.__map[e]=new c),f.pushValue(a,d),d},remove:function(a){var c=b(a),d=null,e=this.__map[c];return e&&(d=e.remove(a)),d},get:function(a){var c,d=b(a),e=null;return(c=this.__map[d])&&(e=c.find(a)),e},set:function(a,d){var e=b(a),f=null,g=null,h=this.__map;return f=(g=h[e])?g.set(a,d):(h[e]=new c).pushValue(a,d)},contains:function(a){var c=b(a),d=!1,e=null;return(e=this.__map[c])&&(d=!!e.find(a)),d},concat:function(a){if(a instanceof this._static){for(var b=new this._static,c=a.entrySet().concat(this.entrySet()),d=c.length-1;d>=0;d--){var e=c[d];b.put(e.key,e.value)}return b}throw new TypeError("When joining hashtables the joining arg must be a HashTable")},filter:function(b,c){var d=this.entrySet(),e=new this._static;d=a.filter(d,b,c);for(var f=d.length-1;f>=0;f--){var g=d[f];e.put(g.key,g.value)}return e},forEach:function(b,c){var d=this.entrySet();a.forEach(d,b,c)},every:function(b,c){var d=this.entrySet();return a.every(d,b,c)},map:function(b,c){var d=this.entrySet();return a.map(d,b,c)},some:function(b,c){var d=this.entrySet();return a.some(d,b,c)},reduce:function(b,c){var d=this.entrySet();return a.reduce(d,b,c)},reduceRight:function(b,c){var d=this.entrySet();return a.reduceRight(d,b,c)},clear:function(){this.__map={}},keys:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getKeys());return a},values:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getValues());return a},isEmpty:function(){return 0===this.keys().length}}})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")))):"function"==typeof define?define(["extended","declare","is-extended","array-extended"],function(a,b,c,e){return d(a().register("declare",b).register(c).register(e))}):this.Ht=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended))}.call(this)},{"array-extended":49,"declare.js":52,extended:53,"is-extended":70}],70:[function(a,b,c){var d=a("__browserify_Buffer").Buffer;!function(){"use strict";function e(a){function b(a,b){var c=-1,d=0,e=a.length,f=[];for(b=b||0,c+=b;++c=0;f--)if(g[f]!==h[f])return!1;for(f=g.length-1;f>=0;f--)if(d=g[f],!e(a[d],b[d]))return!1}catch(i){return!1}return!0}function g(a){return null!==a&&"object"==typeof a}function h(a){var b=g(a);return b&&a.constructor===Object&&!a.nodeType&&!a.setInterval}function i(a){return W(a)?0===a.length:g(a)?0===c(a).length:r(a)||X(a)?0===a.length:!0}function j(a){return a===!0||a===!1||"[object Boolean]"===U.call(a)}function k(a){return"undefined"==typeof a}function l(a){return!k(a)}function m(a){return k(a)||n(a)}function n(a){return null===a}function o(a,b){return V(b)?a instanceof b:!1}function p(a){return"[object RegExp]"===U.call(a)}function q(a){return"[object Date]"===U.call(a)}function r(a){return"[object String]"===U.call(a)}function s(a){return"[object Number]"===U.call(a)}function t(a){return a===!0}function u(a){return a===!1}function v(a){return!n(a)}function w(a,b){return a==b}function x(a,b){return a!=b}function y(a,b){return a===b}function z(a,b){return a!==b}function A(a,b){if(X(b)&&Array.prototype.indexOf||r(b))return b.indexOf(a)>-1;if(X(b))for(var c=0,d=b.length;d>c;c++)if(w(a,b[c]))return!0;return!1}function B(a,b){return!A(a,b)}function C(a,b){return b>a}function D(a,b){return b>=a}function E(a,b){return a>b}function F(a,b){return a>=b}function G(a,b){return r(b)?null!==(""+a).match(b):p(b)?b.test(a):!1}function H(a,b){return!G(a,b)}function I(a,b){return A(b,a)}function J(a,b){return!A(b,a)}function K(a,b,c){return X(a)&&a.length>c?w(a[c],b):!1}function L(a,b,c){return X(a)?!w(a[c],b):!1}function M(a,b){return T.call(a,b)}function N(a,b){return!M(a,b)}function O(a,b){return M(a,"length")?a.length===b:!1}function P(a,b){return M(a,"length")?a.length!==b:!1}function Q(a){Z[a]=function(){this._testers.push(Y[a])}}function R(a){$[a]=function(){var c,d=b(arguments,1),e=Y[a],f=!0;if(d.length<=e.length-1)throw new TypeError("A handler must be defined when calling using switch");if(c=d.pop(),j(c)&&(f=c,c=d.pop()),!V(c))throw new TypeError("handler must be defined");this._cases.push(function(a){return e.apply(Y,a.concat(d))?[f,c.apply(this,a)]:[!1]})}}var S=Array.prototype.slice,T=Object.prototype.hasOwnProperty,U=Object.prototype.toString,V=function(a){return"[object Function]"===U.call(a)};"undefined"==typeof window||V(window.alert)||function(a){V=function(b){return"[object Function]"===U.call(b)||b===a}}(window.alert);var W=function(a){return"[object Arguments]"===U.call(a)};W(arguments)||(W=function(a){return!(!a||!T.call(a,"callee"))});var X=Array.isArray||function(a){return"[object Array]"===U.call(a)},Y={isFunction:V,isObject:g,isEmpty:i,isHash:h,isNumber:s,isString:r,isDate:q,isArray:X,isBoolean:j,isUndefined:k,isDefined:l,isUndefinedOrNull:m,isNull:n,isArguments:W,instanceOf:o,isRegExp:p,deepEqual:e,isTrue:t,isFalse:u,isNotNull:v,isEq:w,isNeq:x,isSeq:y,isSneq:z,isIn:A,isNotIn:B,isLt:C,isLte:D,isGt:E,isGte:F,isLike:G,isNotLike:H,contains:I,notContains:J,has:M,notHas:N,isLength:O,isNotLength:P,containsAt:K,notContainsAt:L},Z={constructor:function(){this._testers=[]},noWrap:{tester:function(){var a=this._testers;return function(b){for(var c=!1,d=0,e=a.length;e>d&&!c;d++)c=a[d](b);return c}}}},$={constructor:function(){this._cases=[],this.__default=null},def:function(a,b){this.__default=b},noWrap:{switcher:function(){var a=this._cases,c=this.__default;return function(){for(var d,e=!1,f=b(arguments),g=0,h=a.length;h>g&&!e;g++)if(d=a[g](f),d.length>1&&(d[1]||d[0]))return d[1];return!e&&c?c.apply(this,f):void 0}}}};for(var _ in Y)T.call(Y,_)&&(R(_),Q(_));var ab=a.define(Y).expose(Y);return ab.tester=a.define(Z),ab.switcher=a.define($),ab}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("extended"))):"function"==typeof define&&define.amd?define(["extended"],function(a){return e(a)}):this.isExtended=e(this.extended)}.call(this)},{__browserify_Buffer:67,extended:53}],71:[function(a,b,c){!function(){"use strict";function d(a){function b(a,b){var c=0;return a>b?1:b>a?-1:b?c:1}var c=a.multiply,d=a.declare({instance:{__printNode:function(b,d){var e=[];a.isUndefinedOrNull(b)?(e.push(c(" ",d)),e.push("~"),console.log(e.join(""))):(this.__printNode(b.right,d+1),e.push(c(" ",d)),e.push(b.data+"\n"),console.log(e.join("")),this.__printNode(b.left,d+1))},constructor:function(a){a=a||{},this.compare=a.compare||b,this.__root=null},insert:function(){throw new Error("Not Implemented")},remove:function(){throw new Error("Not Implemented")},clear:function(){this.__root=null},isEmpty:function(){return!this.__root},traverseWithCondition:function(a,b,c){var e=!0;return a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.IN_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.POST_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e&&(e=this.traverseWithCondition(a.right,b,c)),e&&(e=c(a.data)))):b===d.REVERSE_ORDER&&(e=this.traverseWithCondition(a.right,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c))))),e},traverse:function(a,b,c){a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(c(a.data),this.traverse(a.left,b,c),this.traverse(a.right,b,c)):b===d.IN_ORDER?(this.traverse(a.left,b,c),c(a.data),this.traverse(a.right,b,c)):b===d.POST_ORDER?(this.traverse(a.left,b,c),this.traverse(a.right,b,c),c(a.data)):b===d.REVERSE_ORDER&&(this.traverse(a.right,b,c),c(a.data),this.traverse(a.left,b,c)))},forEach:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this,this.traverse(this.__root,c,function(c){a.call(b,c,this)})},map:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){e.insert(a.call(b,c,this))}),e},filter:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){a.call(b,c,this)&&e.insert(c)}),e},reduce:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduce.apply(a,f)},reduceRight:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduceRight.apply(a,f)},every:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=!1;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this)}),e},some:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this),!e}),e},toArray:function(a){a=a||d.IN_ORDER;var b=[];return this.traverse(this.__root,a,function(a){b.push(a)}),b},contains:function(a){for(var b=!1,c=this.__root;null!==c;){var d=this.compare(a,c.data);d?c=c[-1===d?"left":"right"]:(b=!0,c=null)}return b},find:function(a){for(var b,c=this.__root;c;){var d=this.compare(a,c.data);if(!d){b=c.data;break}c=c[-1===d?"left":"right"]}return b},findLessThan:function(a,b){var c=[],e=this.compare;return this.traverseWithCondition(this.__root,d.IN_ORDER,function(d){var f=e(a,d);return!b&&0===f||1===f?(c.push(d),!0):!1}),c},findGreaterThan:function(a,b){var c=[],e=this.compare;return this.traverse(this.__root,d.REVERSE_ORDER,function(d){var f=e(a,d);return!b&&0===f||-1===f?(c.push(d),!0):!1}),c},print:function(){this.__printNode(this.__root,0)}},"static":{PRE_ORDER:"pre_order",IN_ORDER:"in_order",POST_ORDER:"post_order",REVERSE_ORDER:"reverse_order"}}),e=function(){function a(a,b,c){var d=a.__root;if(null===d||void 0===d)a.__root=f(b);else{for(var g,h=d,i=[],k=[],l=0;;){if(g=i[l]=-1===c(b,h.data)?"left":"right",k[l++]=h,!h[g]){h[g]=f(b);break}h=h[g]}if(!h[g])return null;for(;--l>=0&&(k[l].balance+="right"===i[l]?-1:1,0!==k[l].balance);)if(e(k[l].balance)>1){k[l]=j(k[l],i[l]),0!==l?k[l-1][i[l-1]]=k[l]:a.__root=k[0];break}}}function b(a,b,c){var d=a.__root;if(null!==d&&void 0!==d){for(var f,g,h=d,i=0,j=[],l=[],m={done:!1};;){if(!h)return;if(0===(g=c(b,h.data)))break;f=l[i]=-1===g?"left":"right",j[i++]=h,h=h[f]}var n=h.left,o=h.right;if(n&&o){var p=n;for(l[i]="left",j[i++]=h;p.right;)l[i]="right",j[i++]=p,p=p.right;h.data=p.data,j[i-1][j[i-1]===h?"left":"right"]=p.left}else f=n?"left":"right",0!==i?j[i-1][l[i-1]]=h[f]:a.__root=h[f];for(;--i>=0&&!m.done&&(j[i].balance+="left"===l[i]?-1:1,1!==e(j[i].balance));)e(j[i].balance)>1&&(j[i]=k(j[i],l[i],m),0!==i?j[i-1][l[i-1]]=j[i]:a.__root=j[0])}}var e=Math.abs,f=function(a){return{data:a,balance:0,left:null,right:null}},g=function(a,b,c){var d=a[c];return a[c]=d[b],d[b]=a,d},h=function(a,b,c){return a[c]=g(a[c],c,b),g(a,b,c)},i=function(a,b,c){var d="left"===b?"right":"left",e=a[b],f=e[d];0===f.balance?a.balance=e.balance=0:f.balance===c?(a.balance=-c,e.balance=0):(a.balance=0,e.balance=c),f.balance=0},j=function(a,b){var c="left"===b?"right":"left",d=a[b],e="right"===b?-1:1;return d.balance===e?(a.balance=d.balance=0,a=g(a,c,b)):(i(a,b,e),a=h(a,c,b)),a},k=function(a,b,c){var d="left"===b?"right":"left",e=a[d],f="right"===b?-1:1;return e.balance===-f?(a.balance=e.balance=0,a=g(a,b,d)):e.balance===f?(i(a,d,-f),a=h(a,b,d)):(a.balance=-f,e.balance=f,a=g(a,b,d),c.done=!0),a};return d.extend({instance:{insert:function(b){a(this,b,this.compare)},remove:function(a){b(this,a,this.compare)},__printNode:function(a,b){var d=[];a?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.balance+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),f=function(){function a(a,b){return{data:a,level:b,left:g,right:g}}function b(a){if(0!==a.level&&a.left.level===a.level){var b=a.left;a.left=b.right,b.right=a,a=b}return a}function e(a){if(0!==a.level&&a.right.right.level===a.level){var b=a.right;a.right=b.left,b.left=a,a=b,a.level++}return a}function f(c,d,h){if(c===g)c=a(d,1);else{var i=-1===h(d,c.data)?"left":"right";c[i]=f(c[i],d,h),c=b(c),c=e(c)}return c}var g={level:0,data:null},h=function(a,c,d){var f,i;if(a!==g){var j=d(c,a.data);if(0===j)if(f=a.left,i=a.right,f!==g&&i!==g){for(var k=f;k.right!==g;)k=k.right;a.data=k.data,a.left=h(f,k.data,d)}else a=a[f===g?"right":"left"];else{var l=-1===j?"left":"right";a[l]=h(a[l],c,d)}}if(a!==g){var m=a.level,n=a.left.level,o=a.right.level;(m-1>n||m-1>o)&&(o>--a.level&&(a.right.level=a.level),a=b(a),a=e(a))}return a};return d.extend({instance:{isEmpty:function(){return this.__root===g||this._super(arguments)},insert:function(a){this.__root||(this.__root=g),this.__root=f(this.__root,a,this.compare)},remove:function(a){this.__root=h(this.__root,a,this.compare)},traverseWithCondition:function(a){var b=!0;return a!==g?this._super(arguments):b},traverse:function(a){a!==g&&this._super(arguments)},contains:function(){return this.__root!==g?this._super(arguments):!1},__printNode:function(a,b){var d=[];a&&a.data?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.level+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),g=d.extend({instance:{insert:function(a){if(!this.__root)return this.__root={data:a,parent:null,left:null,right:null},this.__root;for(var b=this.compare,c=this.__root;null!==c;){var d=b(a,c.data);if(!d)return;var e=-1===d?"left":"right",f=c[e];if(!f)return c[e]={data:a,parent:c,left:null,right:null};c=f}},remove:function(a){if(null!==this.__root){for(var b,c={right:this.__root},d=c,e=null,f="right";null!==d[f];){b=d,d=d[f];var g=this.compare(a,d.data);g||(e=d),f=-1===g?"left":"right"}null!==e&&(e.data=d.data,b[b.right===d?"right":"left"]=d[null===d.left?"right":"left"]),this.__root=c.right}}}}),h=function(){var a="RED",b="BLACK",e=function(a){return null!==a&&a.red},f=function(a){return{data:a,red:!0,left:null,right:null}},g=function(a,b,c){if(!a)return f(b);var d=c(b,a.data);if(d){var j=-1===d?"left":"right",k="left"===j?"right":"left";a[j]=g(a[j],b,c);var l=a[j];if(e(l)){var m=a[k];e(m)?(a.red=!0,l.red=!1,m.red=!1):e(l[j])?a=h(a,k):e(l[k])&&(a=i(a,k))}}return a},h=function(a,b){var c="left"===b?"right":"left",d=a[c];return a[c]=d[b],d[b]=a,a.red=!0,d.red=!1,d},i=function(a,b){var c="left"===b?"right":"left";return a[c]=h(a[c],c),h(a,b)},j=function(a,b,c,d){if(a){var f;if(0===d(b,a.data)){if(!a.left||!a.right){var g=a[a.left?"left":"right"];return e(a)?c.done=!0:e(g)&&(g.red=!1,c.done=!0),g}for(var h,i=a.right;null!==i.left;)h=i,i=i.left;h&&(h.left=null),a.data=i.data,b=i.data}f=-1===d(b,a.data)?"left":"right",a[f]=j(a[f],b,c,d),c.done||(a=k(a,f,c))}else c.done=!0;return a},k=function(a,b,c){var d="left"===b?"right":"left",f=a,g=f[d];if(e(g)&&(a=h(a,b),g=f[d]),null!==g)if(e(g.left)||e(g.right)){var j=f.red,k=a===f;f=(e(g[d])?h:i)(f,b),f.red=j,f.left.red=f.right.red=0,k?a=f:a[b]=f,c.done=!0}else e(f)&&(c.done=!0),f.red=0,g.red=1;return a};return d.extend({instance:{insert:function(a){this.__root=g(this.__root,a,this.compare),this.__root.red=!1},remove:function(a){var b={done:!1},c=j(this.__root,a,b,this.compare);return null!==c&&(c.red=0),this.__root=c,a},__printNode:function(d,e){var f=[];d?(this.__printNode(d.right,e+1),f.push(c(" ",e)),f.push((d.red?a:b)+":"+d.data+"\n"),console.log(f.join("")),this.__printNode(d.left,e+1)):(f.push(c(" ",e)),f.push("~"),console.log(f.join("")))}}})}();return{Tree:d,AVLTree:e,AnderssonTree:f,BinaryTree:g,RedBlackTree:h,IN_ORDER:d.IN_ORDER,PRE_ORDER:d.PRE_ORDER,POST_ORDER:d.POST_ORDER,REVERSE_ORDER:d.REVERSE_ORDER}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")).register(a("string-extended")))):"function"==typeof define?define(["extended","declare.js","is-extended","array-extended","string-extended"],function(a,b,c,e,f){return d(a().register("declare",b).register(c).register(e).register(f))}):this.leafy=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended).register(this.stringExtended))}.call(this)},{"array-extended":49,"declare.js":52,extended:53,"is-extended":70,"string-extended":74}],72:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b){var c,d;for(c in b)t.call(b,c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}function e(a,b){var c,d,f;for(c in b)t.call(b,c)&&(d=b[c],f=a[c],p(f,d)||(a[c]=r(f)&&r(d)?e(f,d):r(d)?e({},d):d));return a}function f(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)d(a,arguments[b]);return a}function g(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)e(a,arguments[b]);return a}function h(a,b){var c=a.prototype||a;return f(c,b),a}function i(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e=l(a),f=0,g=e.length;g>f;++f)d=e[f],b.call(c||a,a[d],d,a);return a}function j(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e,f=l(a),g={},h=0,i=f.length;i>h;++h)d=f[h],e=a[d],b.call(c||a,e,d,a)&&(g[d]=e);return g}function k(a){if(!r(a))throw new TypeError;for(var b=l(a),c=[],d=0,e=b.length;e>d;++d)c.push(a[b[d]]);return c}function l(a){if(!r(a))throw new TypeError;var b=[];for(var c in a)t.call(a,c)&&b.push(c);return b}function m(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d={},e=0,f=c.length;f>e;++e)b=c[e],d[a[b]]=b;return d}function n(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d=[],e=0,f=c.length;f>e;++e)b=c[e],d.push([b,a[b]]);return d}function o(a,b){if(!r(a))throw new TypeError;q(b)&&(b=[b]);for(var c,d=s(l(a),b),e={},f=0,g=d.length;g>f;++f)c=d[f],e[c]=a[c];return e}var p=b.deepEqual,q=b.isString,r=b.isHash,s=c.difference,t=Object.prototype.hasOwnProperty,u=b.isFunction,v={forEach:i,filter:j,invert:m,values:k,toArray:n,keys:l,omit:o},w={extend:h,merge:f,deepMerge:g,omit:o},x=a.define(b.isObject,w).define(r,v).define(b.isFunction,{extend:h}).expose({hash:v}).expose(w),y=x.extend;return x.extend=function(){return 1===arguments.length?y.extend.apply(x,arguments):(h.apply(null,arguments),void 0)},x}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c)}):this.objectExtended=d(this.extended,this.isExtended,this.arrayExtended)}.call(this)},{"array-extended":49,extended:53,"is-extended":70}],73:[function(a,b,c){var d=a("__browserify_process");!function(){"use strict";function e(a,b,c,e,f,g){function h(a,b){return function(){try{l(a.apply(null,arguments)).addCallback(b).addErrback(b)}catch(c){b.errback(c)}}}function i(a,b,c){var d=(new G).callback();return v(a,function(a){d=d.then(c?a:B(null,a)),c||(d=d.then(function(a){return b.push(a),b}))}),d}function j(a){return!w(a)&&y(a.then)}function k(a){var b=new G;return a.then(A(b,"callback"),A(b,"errback")),b.promise()}function l(a){var b;return a=C(arguments),a.length?1===a.length?(a=a.pop(),j(a)?a.addCallback&&a.addErrback?(b=new G,a.addCallback(b.callback),a.addErrback(b.errback)):b=k(a):b=x(a)&&c.every(a,j)?new H(a,!0).promise():(new G).callback(a)):b=new H(c.map(a,function(a){return l(a)}),!0).promise():b=(new G).callback(a).promise(),b}function m(a,b){return function(){var c=new G,d=C(arguments);return d.push(c.resolve),a.apply(b||this,d),c.promise()}}function n(a){if(x(a))return i(a,[],!1);throw new Error("When calling promise.serial the first argument must be an array")}function o(a){if(x(a))return i(a,[],!0);throw new Error("When calling promise.serial the first argument must be an array")}function p(a,b){a=C(arguments);var c=!1;b=a.pop();var d=l(a);return function(){return c?l(b.apply(this,arguments)):(a=arguments,d.then(A(this,function(){return c=!0,b.apply(this,a)})))}}function q(){return new G}function r(a){return new H(a,!0).promise()}function s(a){return q().errback(a)}function t(a){return q().callback(a)}var u,v=c.forEach,w=e.isUndefinedOrNull,x=e.isArray,y=e.isFunction,z=e.isBoolean,A=f.bind,B=f.bindIgnore,C=g.argsToArray;if("function"==typeof setImmediate)u="undefined"!=typeof window?setImmediate.bind(window):setImmediate;else if("undefined"!=typeof d)u=function(a){d.nextTick(a)};else if("undefined"!=typeof MessageChannel){var D=new MessageChannel,E={},F=E;D.port1.onmessage=function(){E=E.next; -var a=E.task;delete E.task,a()},u=function(a){F=F.next={task:a},D.port2.postMessage(0)}}else u=function(a){setTimeout(a,0)};var G=a({instance:{__fired:!1,__results:null,__error:null,__errorCbs:null,__cbs:null,constructor:function(){this.__errorCbs=[],this.__cbs=[],f.bindAll(this,["callback","errback","resolve","classic","__resolve","addCallback","addErrback"])},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__error?this.__errorCbs:this.__cbs,c=b.length,d=this.__error||this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(this,b)})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=a.callback),this.__fired&&this.__results?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=a.errback),this.__fired&&this.__error?this.__callNextTick(a,this.__error):this.__errorCbs.push(a)),this},callback:function(){return this.__fired||(this.__results=arguments,this.__resolve()),this.promise()},errback:function(){return this.__fired||(this.__error=arguments,this.__resolve()),this.promise()},resolve:function(a){return a?this.errback(a):this.callback.apply(this,C(arguments,1)),this},classic:function(a){return"function"==typeof a&&(this.addErrback(function(b){a(b)}),this.addCallback(function(){a.apply(this,[null].concat(C(arguments)))})),this},then:function(a,b){var c=new G,d=c;return y(b)&&(d=h(b,c)),this.addErrback(d),y(a)?this.addCallback(h(a,c)):this.addCallback(c),c.promise()},both:function(a){return this.then(a,a)},promise:function(){var a={then:A(this,"then"),both:A(this,"both"),promise:function(){return a}};return v(["addCallback","addErrback","classic"],function(b){a[b]=A(this,function(){return this[b].apply(this,arguments),a})},this),a}}}),H=G.extend({instance:{__results:null,__errors:null,__promiseLength:0,__defLength:0,__firedLength:0,normalizeResults:!1,constructor:function(a,b){this.__errors=[],this.__results=[],this.normalizeResults=z(b)?b:!1,this._super(arguments),a&&a.length?(this.__defLength=a.length,v(a,this.__addPromise,this)):this.__resolve()},__addPromise:function(a,b){a.then(A(this,function(){var a=C(arguments);a.unshift(b),this.callback.apply(this,a)}),A(this,function(){var a=C(arguments);a.unshift(b),this.errback.apply(this,a)}))},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__errors.length?this.__errorCbs:this.__cbs,c=b.length,d=this.__errors.length?this.__errors:this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(null,[b])})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=A(a,"callback")),this.__fired&&!this.__errors.length?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=A(a,"errback")),this.__fired&&this.__errors.length?this.__callNextTick(a,this.__errors):this.__errorCbs.push(a)),this},callback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__results[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()},errback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__errors[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()}}});return b.define({isPromiseLike:j}).expose({isPromiseLike:j,when:l,wrap:m,wait:p,serial:n,chain:o,Promise:G,PromiseList:H,promise:q,defer:q,deferredList:r,reject:s,resolve:t})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("declare.js"),a("extended"),a("array-extended"),a("is-extended"),a("function-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["declare","extended","array-extended","is-extended","function-extended","arguments-extended"],function(a,b,c,d,f,g){return e(a,b,c,d,f,g)}):this.promiseExtended=e(this.declare,this.extended,this.arrayExtended,this.isExtended,this.functionExtended,this.argumentsExtended)}.call(this)},{__browserify_process:68,"arguments-extended":48,"array-extended":49,"declare.js":52,extended:53,"function-extended":56,"is-extended":70}],74:[function(a,b,c){!function(){"use strict";function d(a,b,c,d){function e(a,b){var c=a;if(x.test(b)){var d=b.match(x),e=d[1],f=d[3],g=d[4];g&&(g=parseInt(g,10),c=c.length0?"+":"")+d),k&&(k=parseInt(k,10),d=d.lengthe;)d?a+=c:a=c+a,e++;return a}function i(a,c,d){var e=a;if(b.isString(e)){if(a.length>c)if(d){var f=a.length;e=a.substring(f-c,f)}else e=a.substring(0,c)}else e=i(""+e,c);return e}function j(a,d){if(d instanceof Array){var h=0,i=d.length;return a.replace(v,function(a,b,j){var k,l;if(!(i>h))return a;if(k=d[h++],"%s"===a||"%d"===a||"%D"===a)l=k+"";else if("%Z"===a)l=k.toUTCString();else if("%j"===a)try{l=s(k)}catch(m){throw new Error("stringExtended.format : Unable to parse json from ",k)}else switch(b=b.replace(/^\[|\]$/g,""),j){case"s":l=e(k,b);break;case"d":l=f(k,b);break;case"j":l=g(k,b);break;case"D":l=c.format(k,b);break;case"Z":l=c.format(k,b,!0)}return l})}if(t(d))return a.replace(w,function(a,h,i){if(i=d[i],!b.isUndefined(i)){if(!h)return""+i;if(b.isString(i))return e(i,h);if(b.isNumber(i))return f(i,h);if(b.isDate(i))return c.format(i,h);if(b.isObject(i))return g(i,h)}return a});var k=u.call(arguments).slice(1);return j(a,k)}function k(a,b){var c=[];return a&&(a.indexOf(b)>0?c=a.replace(/\s+/g,"").split(b):c.push(a)),c}function l(a,b){var c=[];if(b)for(var d=0;b>d;d++)c.push(a);return c.join("")}function m(a,c){var d,e,f;if(c)if(b.isArray(a))for(d=[],e=0,f=a.length;f>e;e++)d.push(m(a[e],c));else if(c instanceof Array)for(d=a,e=0,f=c.length;f>e;e++)d=m(d,c[e]);else c in z&&(d="["+z[c]+"m"+a+"");return d}function n(a,b){return a.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,function(a){return b&&-1!==d.indexOf(b,a)?a:"\\"+a})}function o(a){return a.replace(/^\s*|\s*$/g,"")}function p(a){return a.replace(/^\s*/,"")}function q(a){return a.replace(/\s*$/,"")}function r(a){return 0===a.length}var s;"undefined"==typeof JSON?function(){function a(a){return 10>a?"0"+a:a}function c(c){return b.isDate(c)?isFinite(c.valueOf())?c.getUTCFullYear()+"-"+a(c.getUTCMonth()+1)+"-"+a(c.getUTCDate())+"T"+a(c.getUTCHours())+":"+a(c.getUTCMinutes())+":"+a(c.getUTCSeconds())+"Z":null:i(c)?c.valueOf():c}function d(a){return j.lastIndex=0,j.test(a)?'"'+a.replace(j,function(a){var b=k[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function e(a,b){var i,j,k,l,m,n=f,o=b[a];switch(o&&(o=c(o)),"function"==typeof h&&(o=h.call(b,a,o)),typeof o){case"string":return d(o);case"number":return isFinite(o)?String(o):"null";case"boolean":case"null":return String(o);case"object":if(!o)return"null";if(f+=g,m=[],"[object Array]"===Object.prototype.toString.apply(o)){for(l=o.length,i=0;l>i;i+=1)m[i]=e(i,o)||"null";return k=0===m.length?"[]":f?"[\n"+f+m.join(",\n"+f)+"\n"+n+"]":"["+m.join(",")+"]",f=n,k}if(h&&"object"==typeof h)for(l=h.length,i=0;l>i;i+=1)"string"==typeof h[i]&&(j=h[i],k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));else for(j in o)Object.prototype.hasOwnProperty.call(o,j)&&(k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));return k=0===m.length?"{}":f?"{\n"+f+m.join(",\n"+f)+"\n"+n+"}":"{"+m.join(",")+"}",f=n,k}}var f,g,h,i=b.tester().isString().isNumber().isBoolean().tester(),j=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,k={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};s=function(a,b,c){var d;if(f="",g="","number"==typeof c)for(d=0;c>d;d+=1)g+=" ";else"string"==typeof c&&(g=c);if(h=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return e("",{"":a})}}():s=JSON.stringify;var t=b.isHash,u=Array.prototype.slice,v=/%((?:-?\+?.?\d*)?|(?:\[[^\[|\]]*\]))?([sjdDZ])/g,w=/\{(?:\[([^\[|\]]*)\])?(\w+)\}/g,x=/(-?)(\+?)([A-Z|a-z|\W]?)([1-9][0-9]*)?$/,y=/([1-9][0-9]*)$/g,z={bold:1,bright:1,italic:3,underline:4,blink:5,inverse:7,crossedOut:9,red:31,green:32,yellow:33,blue:34,magenta:35,cyan:36,white:37,redBackground:41,greenBackground:42,yellowBackground:43,blueBackground:44,magentaBackground:45,cyanBackground:46,whiteBackground:47,encircled:52,overlined:53,grey:90,black:90},A={SMILEY:"☺",SOLID_SMILEY:"☻",HEART:"♥",DIAMOND:"♦",CLOVE:"♣",SPADE:"♠",DOT:"•",SQUARE_CIRCLE:"◘",CIRCLE:"○",FILLED_SQUARE_CIRCLE:"◙",MALE:"♂",FEMALE:"♀",EIGHT_NOTE:"♪",DOUBLE_EIGHTH_NOTE:"♫",SUN:"☼",PLAY:"►",REWIND:"◄",UP_DOWN:"↕",PILCROW:"¶",SECTION:"§",THICK_MINUS:"▬",SMALL_UP_DOWN:"↨",UP_ARROW:"↑",DOWN_ARROW:"↓",RIGHT_ARROW:"→",LEFT_ARROW:"←",RIGHT_ANGLE:"∟",LEFT_RIGHT_ARROW:"↔",TRIANGLE:"▲",DOWN_TRIANGLE:"▼",HOUSE:"⌂",C_CEDILLA:"Ç",U_UMLAUT:"ü",E_ACCENT:"é",A_LOWER_CIRCUMFLEX:"â",A_LOWER_UMLAUT:"ä",A_LOWER_GRAVE_ACCENT:"à",A_LOWER_CIRCLE_OVER:"å",C_LOWER_CIRCUMFLEX:"ç",E_LOWER_CIRCUMFLEX:"ê",E_LOWER_UMLAUT:"ë",E_LOWER_GRAVE_ACCENT:"è",I_LOWER_UMLAUT:"ï",I_LOWER_CIRCUMFLEX:"î",I_LOWER_GRAVE_ACCENT:"ì",A_UPPER_UMLAUT:"Ä",A_UPPER_CIRCLE:"Å",E_UPPER_ACCENT:"É",A_E_LOWER:"æ",A_E_UPPER:"Æ",O_LOWER_CIRCUMFLEX:"ô",O_LOWER_UMLAUT:"ö",O_LOWER_GRAVE_ACCENT:"ò",U_LOWER_CIRCUMFLEX:"û",U_LOWER_GRAVE_ACCENT:"ù",Y_LOWER_UMLAUT:"ÿ",O_UPPER_UMLAUT:"Ö",U_UPPER_UMLAUT:"Ü",CENTS:"¢",POUND:"£",YEN:"¥",CURRENCY:"¤",PTS:"₧",FUNCTION:"ƒ",A_LOWER_ACCENT:"á",I_LOWER_ACCENT:"í",O_LOWER_ACCENT:"ó",U_LOWER_ACCENT:"ú",N_LOWER_TILDE:"ñ",N_UPPER_TILDE:"Ñ",A_SUPER:"ª",O_SUPER:"º",UPSIDEDOWN_QUESTION:"¿",SIDEWAYS_L:"⌐",NEGATION:"¬",ONE_HALF:"½",ONE_FOURTH:"¼",UPSIDEDOWN_EXCLAMATION:"¡",DOUBLE_LEFT:"«",DOUBLE_RIGHT:"»",LIGHT_SHADED_BOX:"░",MEDIUM_SHADED_BOX:"▒",DARK_SHADED_BOX:"▓",VERTICAL_LINE:"│",MAZE__SINGLE_RIGHT_T:"┤",MAZE_SINGLE_RIGHT_TOP:"┐",MAZE_SINGLE_RIGHT_BOTTOM_SMALL:"┘",MAZE_SINGLE_LEFT_TOP_SMALL:"┌",MAZE_SINGLE_LEFT_BOTTOM_SMALL:"└",MAZE_SINGLE_LEFT_T:"├",MAZE_SINGLE_BOTTOM_T:"┴",MAZE_SINGLE_TOP_T:"┬",MAZE_SINGLE_CENTER:"┼",MAZE_SINGLE_HORIZONTAL_LINE:"─",MAZE_SINGLE_RIGHT_DOUBLECENTER_T:"╡",MAZE_SINGLE_RIGHT_DOUBLE_BL:"╛",MAZE_SINGLE_RIGHT_DOUBLE_T:"╢",MAZE_SINGLE_RIGHT_DOUBLEBOTTOM_TOP:"╖",MAZE_SINGLE_RIGHT_DOUBLELEFT_TOP:"╕",MAZE_SINGLE_LEFT_DOUBLE_T:"╞",MAZE_SINGLE_BOTTOM_DOUBLE_T:"╧",MAZE_SINGLE_TOP_DOUBLE_T:"╤",MAZE_SINGLE_TOP_DOUBLECENTER_T:"╥",MAZE_SINGLE_BOTTOM_DOUBLECENTER_T:"╨",MAZE_SINGLE_LEFT_DOUBLERIGHT_BOTTOM:"╘",MAZE_SINGLE_LEFT_DOUBLERIGHT_TOP:"╒",MAZE_SINGLE_LEFT_DOUBLEBOTTOM_TOP:"╓",MAZE_SINGLE_LEFT_DOUBLETOP_BOTTOM:"╙",MAZE_SINGLE_LEFT_TOP:"Γ",MAZE_SINGLE_RIGHT_BOTTOM:"╜",MAZE_SINGLE_LEFT_CENTER:"╟",MAZE_SINGLE_DOUBLECENTER_CENTER:"╫",MAZE_SINGLE_DOUBLECROSS_CENTER:"╪",MAZE_DOUBLE_LEFT_CENTER:"╣",MAZE_DOUBLE_VERTICAL:"║",MAZE_DOUBLE_RIGHT_TOP:"╗",MAZE_DOUBLE_RIGHT_BOTTOM:"╝",MAZE_DOUBLE_LEFT_BOTTOM:"╚",MAZE_DOUBLE_LEFT_TOP:"╔",MAZE_DOUBLE_BOTTOM_T:"╩",MAZE_DOUBLE_TOP_T:"╦",MAZE_DOUBLE_LEFT_T:"╠",MAZE_DOUBLE_HORIZONTAL:"═",MAZE_DOUBLE_CROSS:"╬",SOLID_RECTANGLE:"█",THICK_LEFT_VERTICAL:"▌",THICK_RIGHT_VERTICAL:"▐",SOLID_SMALL_RECTANGLE_BOTTOM:"▄",SOLID_SMALL_RECTANGLE_TOP:"▀",PHI_UPPER:"Φ",INFINITY:"∞",INTERSECTION:"∩",DEFINITION:"≡",PLUS_MINUS:"±",GT_EQ:"≥",LT_EQ:"≤",THEREFORE:"⌠",SINCE:"∵",DOESNOT_EXIST:"∄",EXISTS:"∃",FOR_ALL:"∀",EXCLUSIVE_OR:"⊕",BECAUSE:"⌡",DIVIDE:"÷",APPROX:"≈",DEGREE:"°",BOLD_DOT:"∙",DOT_SMALL:"·",CHECK:"√",ITALIC_X:"✗",SUPER_N:"ⁿ",SQUARED:"²",CUBED:"³",SOLID_BOX:"■",PERMILE:"‰",REGISTERED_TM:"®",COPYRIGHT:"©",TRADEMARK:"™",BETA:"β",GAMMA:"γ",ZETA:"ζ",ETA:"η",IOTA:"ι",KAPPA:"κ",LAMBDA:"λ",NU:"ν",XI:"ξ",OMICRON:"ο",RHO:"ρ",UPSILON:"υ",CHI_LOWER:"φ",CHI_UPPER:"χ",PSI:"ψ",ALPHA:"α",ESZETT:"ß",PI:"π",SIGMA_UPPER:"Σ",SIGMA_LOWER:"σ",MU:"µ",TAU:"τ",THETA:"Θ",OMEGA:"Ω",DELTA:"δ",PHI_LOWER:"φ",EPSILON:"ε"},B={toArray:k,pad:h,truncate:i,multiply:l,format:j,style:m,escape:n,trim:o,trimLeft:p,trimRight:q,isEmpty:r};return a.define(b.isString,B).define(b.isArray,{style:m}).expose(B).expose({characters:A})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("date-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","date-extended","array-extended"],function(a,b,c,e){return d(a,b,c,e)}):this.stringExtended=d(this.extended,this.isExtended,this.dateExtended,this.arrayExtended)}.call(this)},{"array-extended":49,"date-extended":50,extended:53,"is-extended":70}]},{},[1]); \ No newline at end of file +!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gc&&g>c&&c++;);var h=d[c]-e[c];return h||(h=f-g),h}function g(a,b){return a.recency-b.recency}var h=a("./extended").map,i={salience:d,bucketCounter:e,factRecency:f,activationRecency:g};c.strategies=i,c.strategy=function(a){a=h(a,function(a){return i[a]});var b=a.length;return function(c,d){var e=-1,f=0,g=c===d||c.name===d.name&&c.hashCode===d.hashCode;if(!g){for(;++e0?1:-1}return f}}},{"./extended":12}],8:[function(a,b,c){"use strict";var d,e=a("./extended"),f=e.deepEqual,g=e.merge,h=e.instanceOf,i=e.filter,j=e.declare,k=0,l=j({type:null,instance:{constructor:function(b){d||(d=a("./constraintMatcher")),this.id=k++,this.constraint=b,e.bindAll(this,["assert"])},assert:function(){throw new Error("not implemented")},getIndexableProperties:function(){return[]},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return[this.get("alias")]}}}});l.extend({instance:{type:"object",constructor:function(a){this._super([a])},assert:function(a){return a instanceof this.constraint||a.constructor===this.constraint},equal:function(a){return h(a,this._static)&&this.constraint===a.constraint}}}).as(c,"ObjectConstraint");var m=l.extend({instance:{type:"equality",constructor:function(a,b){this._super([a]),b=b||{},this.pattern=b.pattern,this._matcher=d.getMatcher(a,b,!0)},assert:function(a){return this._matcher(a)}}}).as(c,"EqualityConstraint");m.extend({instance:{type:"inequality"}}).as(c,"InequalityConstraint"),m.extend({instance:{type:"comparison"}}).as(c,"ComparisonConstraint"),l.extend({instance:{type:"equality",constructor:function(){this._super([[!0]])},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")},assert:function(){return!0}}}).as(c,"TrueConstraint");var n=l.extend({instance:{type:"reference",constructor:function(a,b){this.cache={},this._super([a]),b=b||{},this.values=[],this.pattern=b.pattern,this._options=b,this._matcher=d.getMatcher(a,b,!1)},assert:function(a,b){try{return this._matcher(a,b)}catch(c){throw new Error("Error with evaluating pattern "+this.pattern+" "+c.message)}},merge:function(a){var b=this;return a instanceof n&&(b=new this._static([this.constraint,a.constraint,"and"],g({},this._options,this._options)),b._alias=this._alias||a._alias,b.vars=this.vars.concat(a.vars)),b},equal:function(a){return h(a,this._static)&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return this.vars},alias:function(){return this._alias}},setters:{alias:function(a){this._alias=a,this.vars=i(d.getIdentifiers(this.constraint),function(b){return b!==a})}}}}).as(c,"ReferenceConstraint");n.extend({instance:{type:"reference_equality",op:"eq",getIndexableProperties:function(){return d.getIndexableProperties(this.constraint)}}}).as(c,"ReferenceEqualityConstraint").extend({instance:{type:"reference_inequality",op:"neq"}}).as(c,"ReferenceInequalityConstraint").extend({instance:{type:"reference_gt",op:"gt"}}).as(c,"ReferenceGTConstraint").extend({instance:{type:"reference_gte",op:"gte"}}).as(c,"ReferenceGTEConstraint").extend({instance:{type:"reference_lt",op:"lt"}}).as(c,"ReferenceLTConstraint").extend({instance:{type:"reference_lte",op:"lte"}}).as(c,"ReferenceLTEConstraint"),l.extend({instance:{type:"hash",constructor:function(a){this._super([a])},equal:function(a){return e.instanceOf(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},assert:function(){return!0},getters:{variables:function(){return this.constraint}}}}).as(c,"HashConstraint"),l.extend({instance:{constructor:function(a,b){this.type="from",this.constraints=d.getSourceMatcher(a,b||{},!0),e.bindAll(this,["assert"])},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")&&f(this.constraints,a.constraints)},assert:function(a,b){return this.constraints(a,b)},getters:{variables:function(){return this.constraint}}}}).as(c,"FromConstraint")},{"./constraintMatcher":9,"./extended":12}],9:[function(a,b,c){"use strict";function d(a){return e(a).map(function(a){return f(a)?f(a[0])?d(a).value():a.reverse().join("."):a}).flatten().filter(function(a){return!!a})}var e=a("./extended"),f=e.isArray,g=e.forEach,h=e.some,i=e.indexOf,j=e.isNumber,k=e.removeDuplicates,l=a("./constraint"),m={indexOf:e.indexOf,now:function(){return new Date},Date:function(a,b,c,d,e,f,g){var h=new Date;return j(a)&&h.setYear(a),j(b)&&h.setMonth(b),j(c)&&h.setDate(c),j(d)&&h.setHours(d),j(e)&&h.setMinutes(e),j(f)&&h.setSeconds(f),j(g)&&h.setMilliseconds(g),h},lengthOf:function(a,b){return a.length===b},isTrue:function(a){return a===!0},isFalse:function(a){return a===!1},isNotNull:function(a){return null!==a},dateCmp:function(a,b){return e.compare(a,b)}};g(["years","days","months","hours","minutes","seconds"],function(a){m[a+"FromNow"]=e[a+"FromNow"],m[a+"Ago"]=e[a+"Ago"]}),g(["isArray","isNumber","isHash","isObject","isDate","isBoolean","isString","isRegExp","isNull","isEmpty","isUndefined","isDefined","isUndefinedOrNull","isPromiseLike","isFunction","deepEqual"],function(a){var b=e[a];m[a]=function(){return b.apply(e,arguments)}});var n={equal:function(a,b){var c=!1;return a===b?c=!0:a[2]===b[2]&&(c=-1!==i(["string","number","boolean","regexp","identifier","null"],a[2])?a[0]===b[0]:"unary"===a[2]||"logicalNot"===a[2]?this.equal(a[0],b[0]):this.equal(a[0],b[0])&&this.equal(a[1],b[1])),c},__getProperties:function(a){var b=[];if(a){var c=a[2];if(!c)return b;"prop"!==c&&"identifier"!==c&&"string"!==c&&"number"!==c&&"boolean"!==c&&"regexp"!==c&&"unary"!==c&&"unary"!==c?(b[0]=this.__getProperties(a[0]),b[1]=this.__getProperties(a[1])):b="identifier"===c?[a[0]]:n.__getProperties(a[1]).concat(n.__getProperties(a[0]))}return b},getIndexableProperties:function(a){return"composite"===a[2]?this.getIndexableProperties(a[0]):/^(\w+(\['[^']*'])*) *([!=]==|[<>]=?) (\w+(\['[^']*'])*)$/.test(this.parse(a))?d(this.__getProperties(a)).flatten().value():[]},getIdentifiers:function(a){var b=[],c=a[2];if("identifier"===c)return[a[0]];if("function"===c)b=b.concat(this.getIdentifiers(a[0])).concat(this.getIdentifiers(a[1]));else if("string"!==c&&"number"!==c&&"boolean"!==c&&"regexp"!==c&&"unary"!==c&&"unary"!==c)if("prop"===c){if(b=b.concat(this.getIdentifiers(a[0])),a[1])for(var d=a[1];f(d);){if("function"===d[2]){b=b.concat(this.getIdentifiers(d[1]));break}d=d[1]}}else a[0]&&(b=b.concat(this.getIdentifiers(a[0]))),a[1]&&(b=b.concat(this.getIdentifiers(a[1])));return k(b)},toConstraints:function(a,b){var c=[],d=b.alias,e=b.scope||{},f=a[2];if("and"===f)c=c.concat(this.toConstraints(a[0],b)).concat(this.toConstraints(a[1],b));else if("composite"===f||"or"===f||"lt"===f||"gt"===f||"lte"===f||"gte"===f||"like"===f||"notLike"===f||"eq"===f||"neq"===f||"in"===f||"notIn"===f||"prop"===f||"propLookup"===f||"function"===f||"logicalNot"===f){var g=h(this.getIdentifiers(a),function(a){return!(a===d||a in m||a in e)});switch(f){case"eq":c.push(new l[g?"ReferenceEqualityConstraint":"EqualityConstraint"](a,b));break;case"neq":c.push(new l[g?"ReferenceInequalityConstraint":"InequalityConstraint"](a,b));break;case"gt":c.push(new l[g?"ReferenceGTConstraint":"ComparisonConstraint"](a,b));break;case"gte":c.push(new l[g?"ReferenceGTEConstraint":"ComparisonConstraint"](a,b));break;case"lt":c.push(new l[g?"ReferenceLTConstraint":"ComparisonConstraint"](a,b));break;case"lte":c.push(new l[g?"ReferenceLTEConstraint":"ComparisonConstraint"](a,b));break;default:c.push(new l[g?"ReferenceConstraint":"ComparisonConstraint"](a,b))}}return c},parse:function(a){return this[a[2]](a[0],a[1])},composite:function(a){return this.parse(a)},and:function(a,b){return["(",this.parse(a),"&&",this.parse(b),")"].join(" ")},or:function(a,b){return["(",this.parse(a),"||",this.parse(b),")"].join(" ")},prop:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"['",this.parse(b),"']"].join("")},propLookup:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"[",this.parse(b),"]"].join("")},unary:function(a){return-1*this.parse(a)},plus:function(a,b){return[this.parse(a),"+",this.parse(b)].join(" ")},minus:function(a,b){return[this.parse(a),"-",this.parse(b)].join(" ")},mult:function(a,b){return[this.parse(a),"*",this.parse(b)].join(" ")},div:function(a,b){return[this.parse(a),"/",this.parse(b)].join(" ")},mod:function(a,b){return[this.parse(a),"%",this.parse(b)].join(" ")},lt:function(a,b){return[this.parse(a),"<",this.parse(b)].join(" ")},gt:function(a,b){return[this.parse(a),">",this.parse(b)].join(" ")},lte:function(a,b){return[this.parse(a),"<=",this.parse(b)].join(" ")},gte:function(a,b){return[this.parse(a),">=",this.parse(b)].join(" ")},like:function(a,b){return[this.parse(b),".test(",this.parse(a),")"].join("")},notLike:function(a,b){return["!",this.parse(b),".test(",this.parse(a),")"].join("")},eq:function(a,b){return[this.parse(a),"===",this.parse(b)].join(" ")},neq:function(a,b){return[this.parse(a),"!==",this.parse(b)].join(" ")},"in":function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) != -1"].join("")},notIn:function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) == -1"].join("")},arguments:function(a,b){var c=[];return a&&c.push(this.parse(a)),b&&c.push(this.parse(b)),c.join(",")},array:function(a){var b=[];return a?(b=this.parse(a),f(b)?b:["[",b,"]"].join("")):["[",b.join(","),"]"].join("")},"function":function(a,b){var c=this.parse(b);return[this.parse(a),"(",c,")"].join("")},string:function(a){return"'"+a+"'"},number:function(a){return a},"boolean":function(a){return a},regexp:function(a){return a},identifier:function(a){return a},"null":function(){return"null"},logicalNot:function(a){return["!(",this.parse(a),")"].join("")}},o=0,p=c.toJs=function(a,b,c,d,f){var g=n.parse(a);b=b||{};var h=n.getIdentifiers(a),i=["var indexOf = definedFuncs.indexOf; var hasOwnProperty = Object.prototype.hasOwnProperty;"],j=[];e(h).filter(function(a){var c=["var ",a," = "];if(m.hasOwnProperty(a))c.push("definedFuncs['",a,"']");else{if(!b.hasOwnProperty(a))return!0;c.push("scope['",a,"']")}return c.push(";"),i.push(c.join("")),!1}).forEach(function(a){var b=["var ",a," = "];d||a!==c?b.push("fact."+a):a===c&&b.push("hash.",a,""),b.push(";"),j.push(b.join(""))});var k=i.join("")+"return function matcher"+o++ +(d?"(fact){":"(fact, hash){")+j.join("")+" return "+(f?f(g):g)+";}",l=new Function("definedFuncs, scope",k)(m,b);return l};c.getMatcher=function(a,b,c){return b=b||{},p(a,b.scope,b.alias,c,function(a){return"!!("+a+")"})},c.getSourceMatcher=function(a,b,c){return b=b||{},p(a,b.scope,b.alias,c,function(a){return a})},c.toConstraints=function(a,b){return n.toConstraints(a,b)},c.equal=function(a,b){return n.equal(a,b)},c.getIdentifiers=function(a){return n.getIdentifiers(a)},c.getIndexableProperties=function(a){return n.getIndexableProperties(a)}},{"./constraint":8,"./extended":12}],10:[function(a,b){"use strict";function c(a,b){for(var c="",d=-1,e=a.length;++di){for(f=a.slice();++gb;b++)a.assert(arguments[b]);return a},containsRule:function(a){return c.some(this.__rules,function(b){return b.name===a})}},"static":{getFlow:function(a){return l[a]},hasFlow:function(a){return c.has(l,a)},deleteFlow:function(a){return d(a,m)&&(a=a.name),delete l[a],m},deleteFlows:function(){for(var a in l)a in l&&delete l[a];return m},create:function(a,b){return new m(a,b)}}}).as(b)},{"./conflict":7,"./extended":12,"./flow":13,"./pattern":48,"./rule":49}],15:[function(a,b,c){"use strict";function d(a){return/\.nools$/.test(a)}function e(a){var b;return b=d(a)?i.parse(g.readFileSync(a,"utf8"),a):i.parse(a)}var f=a("./extended"),g=a("fs"),h=a("path"),i=a("./compile"),j=a("./flowContainer");c.Flow=j,c.getFlow=j.getFlow,c.hasFlow=j.hasFlow,c.deleteFlow=function(a){return j.deleteFlow(a),this},c.deleteFlows=function(){return j.deleteFlows(),this},c.flow=j.create,c.compile=function(a,b,c){if(f.isFunction(b)?(c=b,b={}):(b=b||{},c=null),f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),!b.name)throw new Error("Name required when compiling nools source");return i.compile(a,b,c,j)},c.transpile=function(a,b){return b=b||{},f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),i.transpile(a,b)},c.parse=e},{"./compile":5,"./extended":12,"./flowContainer":14,fs:61,path:62}],16:[function(a,b){var c=a("declare.js");c({instance:{constructor:function(){this.head=null,this.tail=null,this.length=null},push:function(a){var b=this.tail,c=this.head,d={data:a,prev:b,next:null};return b&&(this.tail.next=d),this.tail=d,c||(this.head=d),this.length++,d +},remove:function(a){a.prev?a.prev.next=a.next:this.head=a.next,a.next?a.next.prev=a.prev:this.tail=a.prev,this.length--},forEach:function(a){for(var b={next:this.head};b=b.next;)a(b.data)},toArray:function(){for(var a={next:this.head},b=[];a=a.next;)b.push(a);return b},removeByData:function(a){for(var b={next:this.head};b=b.next;)if(b.data===a){this.remove(b);break}},getByData:function(a){for(var b={next:this.head};b=b.next;)if(b.data===a)return b},clear:function(){this.head=this.tail=null,this.length=0}}}).as(b)},{"declare.js":55}],17:[function(a,b){var c,d=a("__browserify_process"),e=a("./extended");if("function"==typeof setImmediate)c="undefined"!=typeof window?e.bind(window,setImmediate):setImmediate;else if("undefined"!=typeof d)c=d.nextTick;else if("undefined"!=typeof MessageChannel){var f=new MessageChannel,g={},h=g;f.port1.onmessage=function(){g=g.next;var a=g.task;delete g.task,a()},c=function(a){h=h.next={task:a},f.port2.postMessage(0)}}else c=function(a){setTimeout(a,0)};b.exports=c},{"./extended":12,__browserify_process:64}],18:[function(a,b){var c=a("./node"),d=a("../extended").intersection;c.extend({instance:{__propagatePaths:function(a,b){for(var c,e,f,g,h=this.__entrySet,i=h.length;--i>-1;)c=h[i],e=c.key,f=c.value,(g=d(f,b.paths)).length&&e[a](b.clone(null,g,null))},__propagateNoPaths:function(a,b){for(var c=this.__entrySet,d=c.length;--d>-1;)c[d].key[a](b)},__propagate:function(a,b){b.paths?this.__propagatePaths(a,b):this.__propagateNoPaths(a,b)}}}).as(b)},{"../extended":12,"./node":37}],19:[function(a,b){var c=a("./alphaNode");c.extend({instance:{constructor:function(){this._super(arguments),this.alias=this.constraint.get("alias")},toString:function(){return"AliasNode"+this.__count},assert:function(a){return this.__propagate("assert",a.set(this.alias,a.fact.object))},modify:function(a){return this.__propagate("modify",a.set(this.alias,a.fact.object))},retract:function(a){return this.__propagate("retract",a.set(this.alias,a.fact.object))},equal:function(a){return a instanceof this._static&&this.alias===a.alias}}}).as(b)},{"./alphaNode":20}],20:[function(a,b){"use strict";var c=a("./node");c.extend({instance:{constructor:function(a){this._super([]),this.constraint=a,this.constraintAssert=this.constraint.assert},toString:function(){return"AlphaNode "+this.__count},equal:function(a){return this.constraint.equal(a.constraint)}}}).as(b)},{"./node":37}],21:[function(a,b){var c=a("../extended"),d=c.hash.keys,e=a("./node"),f=a("./misc/leftMemory"),g=a("./misc/rightMemory");e.extend({instance:{nodeType:"BetaNode",constructor:function(){this._super([]),this.leftMemory={},this.rightMemory={},this.leftTuples=new f,this.rightTuples=new g},__propagate:function(a,b){for(var c,d,e=this.__entrySet,f=e.length;--f>-1;)c=e[f],d=c.key,d[a](b)},dispose:function(){this.leftMemory={},this.rightMemory={},this.leftTuples.clear(),this.rightTuples.clear()},disposeLeft:function(a){this.leftMemory={},this.leftTuples.clear(),this.propagateDispose(a)},disposeRight:function(a){this.rightMemory={},this.rightTuples.clear(),this.propagateDispose(a)},hashCode:function(){return this.nodeType+" "+this.__count},toString:function(){return this.nodeType+" "+this.__count},retractLeft:function(a){a=this.removeFromLeftMemory(a).data;for(var b=a.rightMatches,c=d(b),e=-1,f=c.length;++eh;h++)if(this.__isMatch(a,e[h],!0)){a.blocked=!0;break}}else f(e)&&(a.blocked=this.__isMatch(a,e,!0));var j=a.blocked;j?c?this.__propagate("modify",a.clone()):this.__propagate("assert",a.clone()):c&&this.__propagate("retract",a.clone())},__findMatches:function(a){var b=a.factHash,c=this.from(b),d=!1;if(g(c)){for(var e=0,h=c.length;h>e;e++)if(this.__isMatch(a,c[e],!0))return a.blocked=!0,this.__propagate("assert",a.clone()),void 0}else f(c)&&this.__isMatch(a,c,!0)&&(a.blocked=!0,this.__propagate("assert",a.clone()));return d},__isMatch:function(a,b,c){var d=!1;if(this.type(b)){var f=this.workingMemory.getFactHandle(b),g=new e(f,null,null).mergeMatch(a.match).set(this.alias,b);if(c){var h=this.fromMemory[f.id];h||(h=this.fromMemory[f.id]={}),h[a.hashCode]=a}for(var i=g.factHash,j=this.__equalityConstraints,k=0,l=j.length;l>k;k++){if(!j[k](i)){d=!1;break}d=!0}}return d},assertLeft:function(a){this.__addToLeftMemory(a),this.__findMatches(a)}}}).as(b)},{"../context":10,"../extended":12,"./fromNotNode":26}],24:[function(a,b){var c=a("./notNode"),d=a("../linkedList");c.extend({instance:{nodeType:"ExistsNode",blockedContext:function(a,b){a.blocker=b,this.removeFromLeftMemory(a),this.addToLeftBlockedMemory(b.blocking.push(a)),this.__propagate("assert",this.__cloneContext(a))},notBlockedContext:function(a,b){this.__addToLeftMemory(a),b&&this.__propagate("retract",this.__cloneContext(a))},propagateFromLeft:function(a){this.notBlockedContext(a,!1)},retractLeft:function(a){var b;if(!this.removeFromLeftMemory(a)){if(!(b=this.removeFromLeftBlockedMemory(a)))throw new Error;this.__propagate("retract",this.__cloneContext(b.data))}},modifyLeft:function(a){var b,c,d,e,f=this.removeFromLeftMemory(a),g=this.constraint,h=this.rightTuples,i=h.length,j=!1;if(f||(f=this.removeFromLeftBlockedMemory(a),j=!0),!f)throw new Error;if(b=f.data,b&&b.blocker&&(e=this.rightMemory[b.blocker.hashCode]),e?(g.isMatch(a,d=e.data)&&(this.__propagate(j?"modify":"assert",this.__cloneContext(b)),a.blocker=d,this.addToLeftBlockedMemory(d.blocking.push(a)),a=null),a&&(c={next:e.next})):c={next:h.head},a&&i)for(c={next:h.head};c=c.next;)if(g.isMatch(a,d=c.data)){this.__propagate(j?"modify":"assert",this.__cloneContext(b)),this.addToLeftBlockedMemory(d.blocking.push(a)),a.blocker=d,a=null;break}a&&(this.__addToLeftMemory(a),j&&this.__propagate("retract",this.__cloneContext(a)))},modifyRight:function(a){var b=this.removeFromRightMemory(a);if(!b)throw new Error;var c,e,f=b.data,g=this.leftTuples,h=g.length,i=this.constraint,j=f.blocking;if(this.__addToRightMemory(a),a.blocking=new d,h||j.length){if(j.length)for(var k,l={next:j.head};l=l.next;)if(c=l.data,c.blocker=null,i.isMatch(c,a))c.blocker=a,this.addToLeftBlockedMemory(a.blocking.push(c)),this.__propagate("assert",this.__cloneContext(c)),c=null;else{for(c.blocker=null,e=b;e=e.next;)if(i.isMatch(c,k=e.data)){c.blocker=k,this.addToLeftBlockedMemory(k.blocking.push(c)),this.__propagate("assert",this.__cloneContext(c)),c=null;break}c&&this.__addToLeftMemory(c)}if(h)for(e={next:g.head};e=e.next;)c=e.data,i.isMatch(c,a)&&(this.__propagate("assert",this.__cloneContext(c)),this.removeFromLeftMemory(c),this.addToLeftBlockedMemory(a.blocking.push(c)),c.blocker=a)}}}}).as(b)},{"../linkedList":16,"./notNode":38}],25:[function(a,b){var c=a("./joinNode"),d=a("../extended"),e=a("../constraint"),f=e.EqualityConstraint,g=e.HashConstraint,h=e.ReferenceConstraint,i=a("../context"),j=d.isDefined,k=d.isEmpty,l=d.forEach,m=d.isArray,n={isMatch:function(){return!1}};c.extend({instance:{nodeType:"FromNode",constructor:function(a,b){this._super(arguments),this.workingMemory=b,this.fromMemory={},this.pattern=a,this.type=a.get("constraints")[0].assert,this.alias=a.get("alias"),this.from=a.from.assert;var c=this.__equalityConstraints=[],d=[];l(this.constraints=this.pattern.get("constraints").slice(1),function(a){a instanceof f||a instanceof h?c.push(a.assert):a instanceof g&&(d=d.concat(a.get("variables")))}),this.__variables=d},__createMatches:function(a){var b=a.factHash,c=this.from(b);if(m(c))for(var d=0,e=c.length;e>d;d++)this.__checkMatch(a,c[d],!0);else j(c)&&this.__checkMatch(a,c,!0)},__checkMatch:function(a,b,c){var d;return(d=this.__createMatch(a,b)).isMatch()&&c&&this.__propagate("assert",d.clone()),d},__createMatch:function(a,b){if(this.type(b)){var c,d=this.workingMemory.getFactHandle(b,!0),e=new i(d,null,null).set(this.alias,b),f=d.id,g=e.factHash,h=a.factHash;for(var j in h)g[j]=h[j];for(var k=this.__equalityConstraints,l=this.__variables,m=-1,o=k.length;++mc;c++)b=this.__checkMatch(a,l[c],!1),b.isMatch()&&(e=b.fact.id,e in k?this.__propagate("modify",b.clone()):this.__propagate("assert",b.clone()));else j(l)&&(b=this.__checkMatch(a,l,!1),b.isMatch()&&(e=b.fact.id,e in k?this.__propagate("modify",b.clone()):this.__propagate("assert",b.clone())));for(c in k)c in i||(this.removeFromFromMemory(k[c]),this.__propagate("retract",k[c].clone()))}else this.assertLeft(a);f=a.fact,e=f.id;var n=this.fromMemory[e];if(this.fromMemory[e]={},n){var o,p,q,r,s=f.object;for(c in n)p=n[c],o=p[0],q=p[1],r=q.isMatch(),o.hashCode!==a.hashCode&&(b=this.__createMatch(o,s,!1),r&&this.__propagate("retract",q.clone()),b.isMatch()&&this.__propagate(r?"modify":"assert",b.clone()))}},assertLeft:function(a){this.__addToLeftMemory(a),a.fromMatches={},this.__createMatches(a)},assertRight:function(){throw new Error("Shouldnt have gotten here")}}}).as(b)},{"../constraint":8,"../context":10,"../extended":12,"./joinNode":28}],26:[function(a,b){var c=a("./joinNode"),d=a("../extended"),e=a("../constraint"),f=e.EqualityConstraint,g=e.HashConstraint,h=e.ReferenceConstraint,i=a("../context"),j=d.isDefined,k=d.forEach,l=d.isArray;c.extend({instance:{nodeType:"FromNotNode",constructor:function(a,b){this._super(arguments),this.workingMemory=b,this.pattern=a,this.type=a.get("constraints")[0].assert,this.alias=a.get("alias"),this.from=a.from.assert,this.fromMemory={};var c=this.__equalityConstraints=[],d=[];k(this.constraints=this.pattern.get("constraints").slice(1),function(a){a instanceof f||a instanceof h?c.push(a.assert):a instanceof g&&(d=d.concat(a.get("variables")))}),this.__variables=d},retractLeft:function(a){var b=this.removeFromLeftMemory(a);b&&(b=b.data,b.blocked||this.__propagate("retract",b.clone()))},__modify:function(a,b){var c=b.blocked,d=a.factHash,e=this.from(d);if(l(e)){for(var f=0,g=e.length;g>f;f++)if(this.__isMatch(a,e[f],!0)){a.blocked=!0;break}}else j(e)&&(a.blocked=this.__isMatch(a,e,!0));var h=a.blocked;h?c||this.__propagate("retract",b.clone()):c?this.__propagate("assert",a.clone()):this.__propagate("modify",a.clone())},modifyLeft:function(a){var b=this.removeFromLeftMemory(a);if(!b)throw new Error;this.__addToLeftMemory(a),this.__modify(a,b.data);var c=this.fromMemory[a.fact.id];if(this.fromMemory[a.fact.id]={},c)for(var d in c)if(d!==a.hashCode){var e=c[d];b=this.removeFromLeftMemory(e),b&&(e=e.clone(),e.blocked=!1,this.__addToLeftMemory(e),this.__modify(e,b.data))}},__findMatches:function(a){var b=a.factHash,c=this.from(b),d=!1;if(l(c)){for(var e=0,f=c.length;f>e;e++)if(this.__isMatch(a,c[e],!0))return a.blocked=!0,void 0;this.__propagate("assert",a.clone())}else j(c)&&!(a.blocked=this.__isMatch(a,c,!0))&&this.__propagate("assert",a.clone());return d},__isMatch:function(a,b,c){var d=!1;if(this.type(b)){var e=this.workingMemory.getFactHandle(b),f=new i(e,null).mergeMatch(a.match).set(this.alias,b);if(c){var g=this.fromMemory[e.id];g||(g=this.fromMemory[e.id]={}),g[a.hashCode]=a}for(var h=f.factHash,j=this.__equalityConstraints,k=0,l=j.length;l>k;k++){if(!j[k](h,h)){d=!1;break}d=!0}}return d},assertLeft:function(a){this.__addToLeftMemory(a),this.__findMatches(a)},assertRight:function(){throw new Error("Shouldnt have gotten here")},retractRight:function(){throw new Error("Shouldnt have gotten here")}}}).as(b)},{"../constraint":8,"../context":10,"../extended":12,"./joinNode":28}],27:[function(a,b,c){"use strict";function d(a){return g(a.constraints||[],function(a){return a instanceof t})}var e=a("../extended"),f=e.forEach,g=e.some,h=e.declare,i=a("../pattern.js"),j=i.ObjectPattern,k=i.FromPattern,l=i.FromNotPattern,m=i.ExistsPattern,n=i.FromExistsPattern,o=i.NotPattern,p=i.CompositePattern,q=i.InitialFactPattern,r=a("../constraint"),s=r.HashConstraint,t=r.ReferenceConstraint,u=a("./aliasNode"),v=a("./equalityNode"),w=a("./joinNode"),x=a("./betaNode"),y=a("./notNode"),z=a("./fromNode"),A=a("./fromNotNode"),B=a("./existsNode"),C=a("./existsFromNode"),D=a("./leftAdapterNode"),E=a("./rightAdapterNode"),F=a("./typeNode"),G=a("./terminalNode"),H=a("./propertyNode");h({instance:{constructor:function(a,b){this.terminalNodes=[],this.joinNodes=[],this.nodes=[],this.constraints=[],this.typeNodes=[],this.__ruleCount=0,this.bucket={counter:0,recency:0},this.agendaTree=b,this.workingMemory=a},assertRule:function(a){var b=new G(this.bucket,this.__ruleCount++,a,this.agendaTree);this.__addToNetwork(a,a.pattern,b),this.__mergeJoinNodes(),this.terminalNodes.push(b)},resetCounter:function(){this.bucket.counter=0},incrementCounter:function(){this.bucket.counter++},assertFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].assert(a)},retractFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].retract(a)},modifyFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].modify(a)},containsRule:function(a){return g(this.terminalNodes,function(b){return b.rule.name===a})},dispose:function(){for(var a=this.typeNodes,b=a.length-1;b>=0;b--)a[b].dispose()},__mergeJoinNodes:function(){for(var a=this.joinNodes,b=0;b=0;c--){var d=b[c];if(a.equal(d))return d}return b.push(a),a},__createTypeNode:function(a,b){for(var c=new F(b.get("constraints")[0]),d=this.typeNodes,e=d.length-1;e>=0;e--){var f=d[e];if(c.equal(f))return f}return d.push(c),c},__createEqualityNode:function(a,b){return this.__checkEqual(new v(b)).addRule(a)},__createPropertyNode:function(a,b){return this.__checkEqual(new H(b)).addRule(a)},__createAliasNode:function(a,b){return this.__checkEqual(new u(b)).addRule(a)},__createAdapterNode:function(a,b){return("left"===b?new D:new E).addRule(a)},__createJoinNode:function(a,b,c,e){var f;b.rightPattern instanceof o?f=new y:b.rightPattern instanceof n?f=new C(b.rightPattern,this.workingMemory):b.rightPattern instanceof m?f=new B:b.rightPattern instanceof l?f=new A(b.rightPattern,this.workingMemory):b.rightPattern instanceof k?f=new z(b.rightPattern,this.workingMemory):b instanceof p&&!d(b.leftPattern)&&!d(b.rightPattern)?(f=new x,this.joinNodes.push(f)):(f=new w,this.joinNodes.push(f)),f.__rule__=a;var g=f;if(c instanceof x){var h=this.__createAdapterNode(a,e);g.addOutNode(h,b),g=h}return g.addOutNode(c,b),f.addRule(a)},__addToNetwork:function(a,b,c,d){b instanceof j?b instanceof q||d&&"left"!==d?this.__createAlphaNode(a,b,c,d):this.__createBetaNode(a,new p(new q,b),c,d):b instanceof p&&this.__createBetaNode(a,b,c,d)},__createBetaNode:function(a,b,c,d){var e=this.__createJoinNode(a,b,c,d);return this.__addToNetwork(a,b.rightPattern,e,"right"),this.__addToNetwork(a,b.leftPattern,e,"left"),c.addParentNode(e),e},__createAlphaNode:function(a,b,c,d){var e,f;if(!(b instanceof k)){var g=b.get("constraints");e=this.__createTypeNode(a,b);var h=this.__createAliasNode(a,b);e.addOutNode(h,b),h.addParentNode(e),f=h;for(var i=g.length-1;i>0;i--){var j,l=g[i];if(l instanceof s)j=this.__createPropertyNode(a,l);else{if(l instanceof t){c.constraint.addConstraint(l);continue}j=this.__createEqualityNode(a,l)}f.addOutNode(j,b),j.addParentNode(f),f=j}if(c instanceof x){var m=this.__createAdapterNode(a,d);m.addParentNode(f),f.addOutNode(m,b),f=m}return c.addParentNode(f),f.addOutNode(c,b),e}},print:function(){f(this.terminalNodes,function(a){a.print(" ")})}}}).as(c,"RootNode")},{"../constraint":8,"../extended":12,"../pattern.js":48,"./aliasNode":19,"./betaNode":21,"./equalityNode":22,"./existsFromNode":23,"./existsNode":24,"./fromNode":25,"./fromNotNode":26,"./joinNode":28,"./leftAdapterNode":30,"./notNode":38,"./propertyNode":39,"./rightAdapterNode":40,"./terminalNode":41,"./typeNode":42}],28:[function(a,b){var c=a("./betaNode"),d=a("./joinReferenceNode");c.extend({instance:{constructor:function(){this._super(arguments),this.constraint=new d(this.leftTuples,this.rightTuples)},nodeType:"JoinNode",propagateFromLeft:function(a,b){var c;return(c=this.constraint.match(a,b)).isMatch&&this.__propagate("assert",this.__addToMemoryMatches(b,a,a.clone(null,null,c))),this},propagateFromRight:function(a,b){var c;return(c=this.constraint.match(b,a)).isMatch&&this.__propagate("assert",this.__addToMemoryMatches(a,b,a.clone(null,null,c))),this},propagateAssertModifyFromLeft:function(a,b,c){var d,e=c.hashCode;if(e in b){d=this.constraint.match(a,c);var f=d.isMatch;f?this.__propagate("modify",this.__addToMemoryMatches(c,a,a.clone(null,null,d))):this.__propagate("retract",b[e].clone())}else this.propagateFromLeft(a,c)},propagateAssertModifyFromRight:function(a,b,c){var d,e=c.hashCode;if(e in b){d=this.constraint.match(c,a);var f=d.isMatch;f?this.__propagate("modify",this.__addToMemoryMatches(a,c,a.clone(null,null,d))):this.__propagate("retract",b[e].clone())}else this.propagateFromRight(a,c)}}}).as(b)},{"./betaNode":21,"./joinReferenceNode":29}],29:[function(a,b){function c(a,b,c){return a===b[1]&&(c=i[c]),c}function d(a,b,c){return a===b[1]&&(c=i[c]),c}var e=a("./node"),f=a("../constraint"),g=f.ReferenceEqualityConstraint,h={isDefault:!0,assert:function(){return!0},equal:function(){return!1}},i={gt:"lte",gte:"lte",lt:"gte",lte:"gte",eq:"eq",neq:"neq"};e.extend({instance:{constraint:h,constructor:function(a,b){this._super(arguments),this.constraint=h,this.constraintAssert=h.assert,this.rightIndexes=[],this.leftIndexes=[],this.constraintLength=0,this.leftMemory=a,this.rightMemory=b},addConstraint:function(a){if(a instanceof g){var b=a.getIndexableProperties(),e=a.get("alias");if(2===b.length&&e){for(var f,h,i=-1,j=[];++i<2;){var k=b[i];null===k.match(new RegExp("^"+e+"(\\.?)"))?(j.push(k),f=k):(j.push(k),h=k)}if(f&&h){var l=d(f,j,a.op),m=c(h,j,a.op);this.rightMemory.addIndex(h,f,m),this.leftMemory.addIndex(f,h,l)}}}this.constraint.isDefault?(this.constraint=a,this.isDefault=!1):this.constraint=this.constraint.merge(a),this.constraintAssert=this.constraint.assert},equal:function(a){return this.constraint.equal(a.constraint)},isMatch:function(a,b){return this.constraintAssert(a.factHash,b.factHash)},match:function(a,b){var c={isMatch:!1};return this.constraintAssert(a.factHash,b.factHash)&&(c=a.match.merge(b.match)),c}}}).as(b)},{"../constraint":8,"./node":37}],30:[function(a,b){var c=a("./adapterNode");c.extend({instance:{propagateAssert:function(a){this.__propagate("assertLeft",a)},propagateRetract:function(a){this.__propagate("retractLeft",a)},propagateResolve:function(a){this.__propagate("retractResolve",a)},propagateModify:function(a){this.__propagate("modifyLeft",a)},retractResolve:function(a){this.__propagate("retractResolve",a)},dispose:function(a){this.propagateDispose(a)},toString:function(){return"LeftAdapterNode "+this.__count}}}).as(b)},{"./adapterNode":18}],31:[function(a,b,c){c.getMemory=function(){function a(a,b,c){var d,e=0,f=-1;if(c>m)for(;m&&++fi)for(;++fi)for(var d,e,g=0,h=-1;++h=0;)b[c].removeNode(a);a.tuples.length=0},getMemory:function(a){var b;return b=this.length?f(this.tables,a.factHash,this.indexes):[]},__createIndexTree:function(){var a=this.tables.tables={},b=this.indexes;a[b[0][0]]=new g},addIndex:function(a,b,c){this.indexes.push([a,b,d(a),d(b),c||"eq"]),this.indexes.sort(function(a,b){var c=a[4],d=b[4];return c===d?0:c>d?1:c===d?0:-1}),this.__createIndexTree()}}}).as(b)},{"../../extended":12,"./helpers":31,"./table":35,"./tupleEntry":36}],34:[function(a,b){var c=a("./memory");c.extend({instance:{getRightMemory:function(a){return this.getMemory(a)}}}).as(b)},{"./memory":33}],35:[function(a,b){function c(a,b){a=a.key,b=b.key;var c;return c=a===b?0:a>b?1:b>a?-1:1}function d(a,b){return 1===c(a,b)}function e(a,b){return-1!==c(a,b)}function f(a,b){return-1===c(a,b)}function g(a,b){return 1!==c(a,b)}function h(a,b,c){o.key=b;for(var d,e=[],f=0,g=a.__root;;)if(g)g=(n[f++]=g).left;else{if(!(f>0))break;if(d=(g=n[--f]).data,!c(d,o))break;k.apply(e,d.value.tuples),g=g.right}return n.length=0,e}function i(a,b,c){o.key=b;for(var d,e=[],f=0,g=a.__root;;)if(g)g=(n[f++]=g).right;else{if(!(f>0))break;if(d=(g=n[--f]).data,!c(d,o))break;k.apply(e,d.value.tuples),g=g.left}return n.length=0,e}var j=a("../../extended"),k=Array.prototype.push,l=j.HashTable,m=j.AVLTree,n=[],o={key:null};m.extend({instance:{constructor:function(){this._super([{compare:c}]),this.gtCache=new l,this.gteCache=new l,this.ltCache=new l,this.lteCache=new l,this.hasGTCache=!1,this.hasGTECache=!1,this.hasLTCache=!1,this.hasLTECache=!1},clearCache:function(){this.hasGTCache&&this.gtCache.clear()&&(this.hasGTCache=!1),this.hasGTECache&&this.gteCache.clear()&&(this.hasGTECache=!1),this.hasLTCache&&this.ltCache.clear()&&(this.hasLTCache=!1),this.hasLTECache&&this.lteCache.clear()&&(this.hasLTECache=!1)},contains:function(a){return this._super([{key:a}])},set:function(a,b){this.insert({key:a,value:b}),this.clearCache()},get:function(a){var b=this.find({key:a});return b&&b.value},remove:function(a){return this.clearCache(),this._super([{key:a}])},findGT:function(a){var b=this.gtCache.get(a);return b||(this.hasGTCache=!0,this.gtCache.put(a,b=i(this,a,d))),b},findGTE:function(a){var b=this.gteCache.get(a);return b||(this.hasGTECache=!0,this.gteCache.put(a,b=i(this,a,e))),b},findLT:function(a){var b=this.ltCache.get(a);return b||(this.hasLTCache=!0,this.ltCache.put(a,b=h(this,a,f))),b},findLTE:function(a){var b=this.lteCache.get(a);return b||(this.hasLTECache=!0,this.lteCache.put(a,b=h(this,a,g))),b}}}).as(b)},{"../../extended":12}],36:[function(a,b){var c=a("../../extended"),d=c.indexOf,e=0;c.declare({instance:{tuples:null,tupleMap:null,hashCode:null,tables:null,entry:null,constructor:function(a,b,c){this.val=a,this.canRemove=c,this.tuples=[],this.tupleMap={},this.hashCode=e++,this.tables={},this.length=0,this.entry=b},addNode:function(a){return this.tuples[this.length++]=a,this.length>1&&this.entry.clearCache(),this},removeNode:function(a){var b=this.tuples,c=d(b,a);-1!==c&&(b.splice(c,1),this.length--,this.entry.clearCache()),this.canRemove&&!this.length&&this.entry.remove(this.val)}}}).as(b)},{"../../extended":12}],37:[function(a,b){var c=a("../extended"),d=c.forEach,e=c.indexOf,f=c.intersection,g=c.declare,h=c.HashTable,i=a("../context"),j=0;g({instance:{constructor:function(){this.nodes=new h,this.rules=[],this.parentNodes=[],this.__count=j++,this.__entrySet=[]},addRule:function(a){return-1===e(this.rules,a)&&this.rules.push(a),this},merge:function(a){a.nodes.forEach(function(b){for(var c=b.value,d=b.key,e=0,f=c.length;f>e;e++)this.addOutNode(d,c[e]);a.nodes.remove(d)},this);for(var b=a.parentNodes,c=0,d=a.parentNodes.l;d>c;c++){var e=b[c];this.addParentNode(e),e.nodes.remove(a)}return this},resolve:function(a,b){return a.hashCode===b.hashCode},print:function(a){console.log(a+this.toString()),d(this.parentNodes,function(b){b.print(" "+a)})},addOutNode:function(a,b){this.nodes.contains(a)||this.nodes.put(a,[]),this.nodes.get(a).push(b),this.__entrySet=this.nodes.entrySet()},addParentNode:function(a){-1===e(this.parentNodes,a)&&this.parentNodes.push(a)},shareable:function(){return!1},__propagate:function(a,b){for(var c,d,e,g,h=this.__entrySet,j=h.length;--j>-1;)c=h[j],d=c.key,e=c.value,(g=f(e,b.paths)).length&&d[a](new i(b.fact,g,b.match))},dispose:function(a){this.propagateDispose(a)},retract:function(a){this.propagateRetract(a)},propagateDispose:function(a,b){b=b||this.nodes;for(var c=this.__entrySet,d=c.length-1;d>=0;d--){var e=c[d],f=e.key;f.dispose(a)}},propagateAssert:function(a){this.__propagate("assert",a)},propagateRetract:function(a){this.__propagate("retract",a)},assert:function(a){this.propagateAssert(a)},modify:function(a){this.propagateModify(a)},propagateModify:function(a){this.__propagate("modify",a)}}}).as(b)},{"../context":10,"../extended":12}],38:[function(a,b){var c=a("./joinNode"),d=a("../linkedList"),e=a("../context"),f=a("../pattern").InitialFact;c.extend({instance:{nodeType:"NotNode",constructor:function(){this._super(arguments),this.leftTupleMemory={},this.notMatch=new e(new f).match},__cloneContext:function(a){return a.clone(null,null,a.match.merge(this.notMatch))},retractRight:function(a){var b=this.removeFromRightMemory(a),c=b.data,d=c.blocking;if(d.length){for(var e,f,g=this.constraint,h={next:d.head};h=h.next;){e=h.data,this.removeFromLeftBlockedMemory(e);var i,j=this.rightTuples.getRightMemory(e),k=j.length;for(i=-1;++ig;g++)b=e[g],c.set(b[1],f[b[0]]);this.__propagate("assert",c)},retract:function(a){this.__propagate("retract",new d(a.fact,a.paths))},modify:function(a){var b,c=new d(a.fact,a.paths),e=this.variables,f=a.fact.object;c.set(this.alias,f);for(var g=0,h=this.varLength;h>g;g++)b=e[g],c.set(b[1],f[b[0]]);this.__propagate("modify",c)},toString:function(){return"PropertyNode"+this.__count}}}).as(b)},{"../context":10,"../extended":12,"./alphaNode":20}],40:[function(a,b){var c=a("./adapterNode");c.extend({instance:{retractResolve:function(a){this.__propagate("retractResolve",a)},dispose:function(a){this.propagateDispose(a)},propagateAssert:function(a){this.__propagate("assertRight",a)},propagateRetract:function(a){this.__propagate("retractRight",a)},propagateResolve:function(a){this.__propagate("retractResolve",a)},propagateModify:function(a){this.__propagate("modifyRight",a)},toString:function(){return"RightAdapterNode "+this.__count}}}).as(b)},{"./adapterNode":18}],41:[function(a,b){var c=a("./node"),d=a("../extended"),e=d.bind;c.extend({instance:{constructor:function(a,b,c,d){this._super([]),this.resolve=e(this,this.resolve),this.rule=c,this.index=b,this.name=this.rule.name,this.agenda=d,this.bucket=a,d.register(this)},__assertModify:function(a){var b=a.match;if(b.isMatch){var c=this.rule,d=this.bucket;this.agenda.insert(this,{rule:c,hashCode:a.hashCode,index:this.index,name:c.name,recency:d.recency++,match:b,counter:d.counter})}},assert:function(a){this.__assertModify(a)},modify:function(a){this.agenda.retract(this,a),this.__assertModify(a)},retract:function(a){this.agenda.retract(this,a)},retractRight:function(a){this.agenda.retract(this,a)},retractLeft:function(a){this.agenda.retract(this,a)},assertLeft:function(a){this.__assertModify(a)},assertRight:function(a){this.__assertModify(a)},toString:function(){return"TerminalNode "+this.rule.name}}}).as(b)},{"../extended":12,"./node":37}],42:[function(a,b){var c=a("./alphaNode"),d=a("../context");c.extend({instance:{assert:function(a){this.constraintAssert(a.object)&&this.__propagate("assert",a)},modify:function(a){this.constraintAssert(a.object)&&this.__propagate("modify",a)},retract:function(a){this.constraintAssert(a.object)&&this.__propagate("retract",a)},toString:function(){return"TypeNode"+this.__count},dispose:function(){for(var a=this.__entrySet,b=a.length-1;b>=0;b--){var c=a[b],d=c.key,e=c.value;d.dispose({paths:e})}},__propagate:function(a,b){for(var c=this.__entrySet,e=-1,f=c.length;++e":20,"<=":21,">=":22,EQUALITY_EXPRESSION:23,"==":24,"!=":25,"=~":26,"!=~":27,IN_EXPRESSION:28,"in":29,ARRAY_EXPRESSION:30,notIn:31,OBJECT_EXPRESSION:32,AND_EXPRESSION:33,"&&":34,OR_EXPRESSION:35,"||":36,ARGUMENT_LIST:37,",":38,IDENTIFIER_EXPRESSION:39,IDENTIFIER:40,".":41,"[":42,STRING_EXPRESSION:43,"]":44,NUMBER_EXPRESSION:45,"(":46,")":47,STRING:48,NUMBER:49,REGEXP_EXPRESSION:50,REGEXP:51,BOOLEAN_EXPRESSION:52,BOOLEAN:53,NULL_EXPRESSION:54,NULL:55,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:"-",9:"!",11:"*",12:"/",13:"%",15:"+",17:"^",19:"<",20:">",21:"<=",22:">=",24:"==",25:"!=",26:"=~",27:"!=~",29:"in",31:"notIn",34:"&&",36:"||",38:",",40:"IDENTIFIER",41:".",42:"[",44:"]",46:"(",47:")",48:"STRING",49:"NUMBER",51:"REGEXP",53:"BOOLEAN",55:"NULL"},productions_:[0,[3,2],[6,1],[6,2],[6,2],[10,1],[10,3],[10,3],[10,3],[14,1],[14,3],[14,3],[16,1],[16,3],[18,1],[18,3],[18,3],[18,3],[18,3],[23,1],[23,3],[23,3],[23,3],[23,3],[28,1],[28,3],[28,3],[28,3],[28,3],[33,1],[33,3],[35,1],[35,3],[37,1],[37,3],[39,1],[32,1],[32,3],[32,4],[32,4],[32,4],[32,3],[32,4],[43,1],[45,1],[50,1],[52,1],[54,1],[30,2],[30,3],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,3],[4,1]],performAction:function(a,b,c,d,e,f){var g=f.length-1;switch(e){case 1:return f[g-1];case 3:this.$=[f[g],null,"unary"];break;case 4:this.$=[f[g],null,"logicalNot"];break;case 6:this.$=[f[g-2],f[g],"mult"];break;case 7:this.$=[f[g-2],f[g],"div"];break;case 8:this.$=[f[g-2],f[g],"mod"];break;case 10:this.$=[f[g-2],f[g],"plus"];break;case 11:this.$=[f[g-2],f[g],"minus"];break;case 13:this.$=[f[g-2],f[g],"pow"];break;case 15:this.$=[f[g-2],f[g],"lt"];break;case 16:this.$=[f[g-2],f[g],"gt"];break;case 17:this.$=[f[g-2],f[g],"lte"];break;case 18:this.$=[f[g-2],f[g],"gte"];break;case 20:this.$=[f[g-2],f[g],"eq"];break;case 21:this.$=[f[g-2],f[g],"neq"];break;case 22:this.$=[f[g-2],f[g],"like"];break;case 23:this.$=[f[g-2],f[g],"notLike"];break;case 25:this.$=[f[g-2],f[g],"in"];break;case 26:this.$=[f[g-2],f[g],"notIn"];break;case 27:this.$=[f[g-2],f[g],"in"];break;case 28:this.$=[f[g-2],f[g],"notIn"];break;case 30:this.$=[f[g-2],f[g],"and"];break;case 32:this.$=[f[g-2],f[g],"or"];break;case 34:this.$=[f[g-2],f[g],"arguments"];break;case 35:this.$=[String(a),null,"identifier"];break;case 37:this.$=[f[g-2],f[g],"prop"];break;case 38:this.$=[f[g-3],f[g-1],"propLookup"];break;case 39:this.$=[f[g-3],f[g-1],"propLookup"];break;case 40:this.$=[f[g-3],f[g-1],"propLookup"];break;case 41:this.$=[f[g-2],[null,null,"arguments"],"function"];break;case 42:this.$=[f[g-3],f[g-1],"function"];break;case 43:this.$=[String(a.replace(/^['|"]|['|"]$/g,"")),null,"string"];break;case 44:this.$=[Number(a),null,"number"];break;case 45:this.$=[a,null,"regexp"];break;case 46:this.$=["true"==a.replace(/^\s+/,""),null,"boolean"];break;case 47:this.$=[null,null,"null"];break;case 48:this.$=[null,null,"array"];break;case 49:this.$=[f[g-1],null,"array"];break;case 57:this.$=[f[g-1],null,"composite"]}},table:[{3:1,4:2,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[3]},{5:[1,31]},{5:[2,58],36:[1,32],47:[2,58]},{5:[2,31],34:[1,33],36:[2,31],47:[2,31]},{5:[2,29],34:[2,29],36:[2,29],47:[2,29]},{5:[2,24],24:[1,34],25:[1,35],26:[1,36],27:[1,37],34:[2,24],36:[2,24],47:[2,24]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],29:[1,38],31:[1,39],34:[2,2],36:[2,2],47:[2,2]},{5:[2,19],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,19],25:[2,19],26:[2,19],27:[2,19],34:[2,19],36:[2,19],47:[2,19]},{5:[2,50],8:[2,50],11:[2,50],12:[2,50],13:[2,50],15:[2,50],17:[2,50],19:[2,50],20:[2,50],21:[2,50],22:[2,50],24:[2,50],25:[2,50],26:[2,50],27:[2,50],29:[2,50],31:[2,50],34:[2,50],36:[2,50],38:[2,50],44:[2,50],47:[2,50]},{5:[2,51],8:[2,51],11:[2,51],12:[2,51],13:[2,51],15:[2,51],17:[2,51],19:[2,51],20:[2,51],21:[2,51],22:[2,51],24:[2,51],25:[2,51],26:[2,51],27:[2,51],29:[2,51],31:[2,51],34:[2,51],36:[2,51],38:[2,51],44:[2,51],47:[2,51]},{5:[2,52],8:[2,52],11:[2,52],12:[2,52],13:[2,52],15:[2,52],17:[2,52],19:[2,52],20:[2,52],21:[2,52],22:[2,52],24:[2,52],25:[2,52],26:[2,52],27:[2,52],29:[2,52],31:[2,52],34:[2,52],36:[2,52],38:[2,52],44:[2,52],47:[2,52]},{5:[2,53],8:[2,53],11:[2,53],12:[2,53],13:[2,53],15:[2,53],17:[2,53],19:[2,53],20:[2,53],21:[2,53],22:[2,53],24:[2,53],25:[2,53],26:[2,53],27:[2,53],29:[2,53],31:[2,53],34:[2,53],36:[2,53],38:[2,53],44:[2,53],47:[2,53]},{5:[2,54],8:[2,54],11:[2,54],12:[2,54],13:[2,54],15:[2,54],17:[2,54],19:[2,54],20:[2,54],21:[2,54],22:[2,54],24:[2,54],25:[2,54],26:[2,54],27:[2,54],29:[2,54],31:[2,54],34:[2,54],36:[2,54],38:[2,54],44:[2,54],47:[2,54]},{5:[2,55],8:[2,55],11:[2,55],12:[2,55],13:[2,55],15:[2,55],17:[2,55],19:[2,55],20:[2,55],21:[2,55],22:[2,55],24:[2,55],25:[2,55],26:[2,55],27:[2,55],29:[2,55],31:[2,55],34:[2,55],36:[2,55],38:[2,55],41:[1,44],42:[1,45],44:[2,55],46:[1,46],47:[2,55]},{5:[2,56],8:[2,56],11:[2,56],12:[2,56],13:[2,56],15:[2,56],17:[2,56],19:[2,56],20:[2,56],21:[2,56],22:[2,56],24:[2,56],25:[2,56],26:[2,56],27:[2,56],29:[2,56],31:[2,56],34:[2,56],36:[2,56],38:[2,56],44:[2,56],47:[2,56]},{4:47,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,14],17:[1,48],19:[2,14],20:[2,14],21:[2,14],22:[2,14],24:[2,14],25:[2,14],26:[2,14],27:[2,14],34:[2,14],36:[2,14],47:[2,14]},{5:[2,43],8:[2,43],11:[2,43],12:[2,43],13:[2,43],15:[2,43],17:[2,43],19:[2,43],20:[2,43],21:[2,43],22:[2,43],24:[2,43],25:[2,43],26:[2,43],27:[2,43],29:[2,43],31:[2,43],34:[2,43],36:[2,43],38:[2,43],44:[2,43],47:[2,43]},{5:[2,44],8:[2,44],11:[2,44],12:[2,44],13:[2,44],15:[2,44],17:[2,44],19:[2,44],20:[2,44],21:[2,44],22:[2,44],24:[2,44],25:[2,44],26:[2,44],27:[2,44],29:[2,44],31:[2,44],34:[2,44],36:[2,44],38:[2,44],44:[2,44],47:[2,44]},{5:[2,45],8:[2,45],11:[2,45],12:[2,45],13:[2,45],15:[2,45],17:[2,45],19:[2,45],20:[2,45],21:[2,45],22:[2,45],24:[2,45],25:[2,45],26:[2,45],27:[2,45],29:[2,45],31:[2,45],34:[2,45],36:[2,45],38:[2,45],44:[2,45],47:[2,45]},{5:[2,46],8:[2,46],11:[2,46],12:[2,46],13:[2,46],15:[2,46],17:[2,46],19:[2,46],20:[2,46],21:[2,46],22:[2,46],24:[2,46],25:[2,46],26:[2,46],27:[2,46],29:[2,46],31:[2,46],34:[2,46],36:[2,46],38:[2,46],44:[2,46],47:[2,46]},{5:[2,47],8:[2,47],11:[2,47],12:[2,47],13:[2,47],15:[2,47],17:[2,47],19:[2,47],20:[2,47],21:[2,47],22:[2,47],24:[2,47],25:[2,47],26:[2,47],27:[2,47],29:[2,47],31:[2,47],34:[2,47],36:[2,47],38:[2,47],44:[2,47],47:[2,47]},{5:[2,36],8:[2,36],11:[2,36],12:[2,36],13:[2,36],15:[2,36],17:[2,36],19:[2,36],20:[2,36],21:[2,36],22:[2,36],24:[2,36],25:[2,36],26:[2,36],27:[2,36],29:[2,36],31:[2,36],34:[2,36],36:[2,36],38:[2,36],41:[2,36],42:[2,36],44:[2,36],46:[2,36],47:[2,36]},{7:51,30:15,32:14,37:50,39:23,40:[1,26],42:[1,24],43:9,44:[1,49],45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,12],8:[1,53],15:[1,52],17:[2,12],19:[2,12],20:[2,12],21:[2,12],22:[2,12],24:[2,12],25:[2,12],26:[2,12],27:[2,12],34:[2,12],36:[2,12],47:[2,12]},{5:[2,35],8:[2,35],11:[2,35],12:[2,35],13:[2,35],15:[2,35],17:[2,35],19:[2,35],20:[2,35],21:[2,35],22:[2,35],24:[2,35],25:[2,35],26:[2,35],27:[2,35],29:[2,35],31:[2,35],34:[2,35],36:[2,35],38:[2,35],41:[2,35],42:[2,35],44:[2,35],46:[2,35],47:[2,35]},{5:[2,9],8:[2,9],11:[1,54],12:[1,55],13:[1,56],15:[2,9],17:[2,9],19:[2,9],20:[2,9],21:[2,9],22:[2,9],24:[2,9],25:[2,9],26:[2,9],27:[2,9],34:[2,9],36:[2,9],47:[2,9]},{5:[2,5],8:[2,5],11:[2,5],12:[2,5],13:[2,5],15:[2,5],17:[2,5],19:[2,5],20:[2,5],21:[2,5],22:[2,5],24:[2,5],25:[2,5],26:[2,5],27:[2,5],34:[2,5],36:[2,5],47:[2,5]},{6:57,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:59,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[2,1]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:60,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:61,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:62,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:63,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:64,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:65,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{30:66,32:67,39:23,40:[1,26],42:[1,24]},{30:68,32:69,39:23,40:[1,26],42:[1,24]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:70,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:71,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:72,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:73,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{39:74,40:[1,26]},{32:77,39:23,40:[1,26],43:75,45:76,48:[1,18],49:[1,19]},{7:51,30:15,32:14,37:79,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],47:[1,78],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{47:[1,80]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:81,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,48],8:[2,48],11:[2,48],12:[2,48],13:[2,48],15:[2,48],17:[2,48],19:[2,48],20:[2,48],21:[2,48],22:[2,48],24:[2,48],25:[2,48],26:[2,48],27:[2,48],29:[2,48],31:[2,48],34:[2,48],36:[2,48],38:[2,48],44:[2,48],47:[2,48]},{38:[1,83],44:[1,82]},{38:[2,33],44:[2,33],47:[2,33]},{6:28,7:58,8:[1,29],9:[1,30],10:84,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:85,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:86,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:87,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:88,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,3],8:[2,3],11:[2,3],12:[2,3],13:[2,3],15:[2,3],17:[2,3],19:[2,3],20:[2,3],21:[2,3],22:[2,3],24:[2,3],25:[2,3],26:[2,3],27:[2,3],34:[2,3],36:[2,3],47:[2,3]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],34:[2,2],36:[2,2],47:[2,2]},{5:[2,4],8:[2,4],11:[2,4],12:[2,4],13:[2,4],15:[2,4],17:[2,4],19:[2,4],20:[2,4],21:[2,4],22:[2,4],24:[2,4],25:[2,4],26:[2,4],27:[2,4],34:[2,4],36:[2,4],47:[2,4]},{5:[2,32],34:[1,33],36:[2,32],47:[2,32]},{5:[2,30],34:[2,30],36:[2,30],47:[2,30]},{5:[2,20],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,20],25:[2,20],26:[2,20],27:[2,20],34:[2,20],36:[2,20],47:[2,20]},{5:[2,21],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,21],25:[2,21],26:[2,21],27:[2,21],34:[2,21],36:[2,21],47:[2,21]},{5:[2,22],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,22],25:[2,22],26:[2,22],27:[2,22],34:[2,22],36:[2,22],47:[2,22]},{5:[2,23],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,23],25:[2,23],26:[2,23],27:[2,23],34:[2,23],36:[2,23],47:[2,23]},{5:[2,25],34:[2,25],36:[2,25],47:[2,25]},{5:[2,27],34:[2,27],36:[2,27],41:[1,44],42:[1,45],46:[1,46],47:[2,27]},{5:[2,26],34:[2,26],36:[2,26],47:[2,26]},{5:[2,28],34:[2,28],36:[2,28],41:[1,44],42:[1,45],46:[1,46],47:[2,28]},{5:[2,15],17:[1,48],19:[2,15],20:[2,15],21:[2,15],22:[2,15],24:[2,15],25:[2,15],26:[2,15],27:[2,15],34:[2,15],36:[2,15],47:[2,15]},{5:[2,16],17:[1,48],19:[2,16],20:[2,16],21:[2,16],22:[2,16],24:[2,16],25:[2,16],26:[2,16],27:[2,16],34:[2,16],36:[2,16],47:[2,16]},{5:[2,17],17:[1,48],19:[2,17],20:[2,17],21:[2,17],22:[2,17],24:[2,17],25:[2,17],26:[2,17],27:[2,17],34:[2,17],36:[2,17],47:[2,17]},{5:[2,18],17:[1,48],19:[2,18],20:[2,18],21:[2,18],22:[2,18],24:[2,18],25:[2,18],26:[2,18],27:[2,18],34:[2,18],36:[2,18],47:[2,18]},{5:[2,37],8:[2,37],11:[2,37],12:[2,37],13:[2,37],15:[2,37],17:[2,37],19:[2,37],20:[2,37],21:[2,37],22:[2,37],24:[2,37],25:[2,37],26:[2,37],27:[2,37],29:[2,37],31:[2,37],34:[2,37],36:[2,37],38:[2,37],41:[2,37],42:[2,37],44:[2,37],46:[2,37],47:[2,37]},{44:[1,89]},{44:[1,90]},{41:[1,44],42:[1,45],44:[1,91],46:[1,46]},{5:[2,41],8:[2,41],11:[2,41],12:[2,41],13:[2,41],15:[2,41],17:[2,41],19:[2,41],20:[2,41],21:[2,41],22:[2,41],24:[2,41],25:[2,41],26:[2,41],27:[2,41],29:[2,41],31:[2,41],34:[2,41],36:[2,41],38:[2,41],41:[2,41],42:[2,41],44:[2,41],46:[2,41],47:[2,41]},{38:[1,83],47:[1,92]},{5:[2,57],8:[2,57],11:[2,57],12:[2,57],13:[2,57],15:[2,57],17:[2,57],19:[2,57],20:[2,57],21:[2,57],22:[2,57],24:[2,57],25:[2,57],26:[2,57],27:[2,57],29:[2,57],31:[2,57],34:[2,57],36:[2,57],38:[2,57],44:[2,57],47:[2,57]},{5:[2,13],8:[1,53],15:[1,52],17:[2,13],19:[2,13],20:[2,13],21:[2,13],22:[2,13],24:[2,13],25:[2,13],26:[2,13],27:[2,13],34:[2,13],36:[2,13],47:[2,13]},{5:[2,49],8:[2,49],11:[2,49],12:[2,49],13:[2,49],15:[2,49],17:[2,49],19:[2,49],20:[2,49],21:[2,49],22:[2,49],24:[2,49],25:[2,49],26:[2,49],27:[2,49],29:[2,49],31:[2,49],34:[2,49],36:[2,49],38:[2,49],44:[2,49],47:[2,49]},{7:93,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,10],8:[2,10],11:[1,54],12:[1,55],13:[1,56],15:[2,10],17:[2,10],19:[2,10],20:[2,10],21:[2,10],22:[2,10],24:[2,10],25:[2,10],26:[2,10],27:[2,10],34:[2,10],36:[2,10],47:[2,10]},{5:[2,11],8:[2,11],11:[1,54],12:[1,55],13:[1,56],15:[2,11],17:[2,11],19:[2,11],20:[2,11],21:[2,11],22:[2,11],24:[2,11],25:[2,11],26:[2,11],27:[2,11],34:[2,11],36:[2,11],47:[2,11]},{5:[2,6],8:[2,6],11:[2,6],12:[2,6],13:[2,6],15:[2,6],17:[2,6],19:[2,6],20:[2,6],21:[2,6],22:[2,6],24:[2,6],25:[2,6],26:[2,6],27:[2,6],34:[2,6],36:[2,6],47:[2,6]},{5:[2,7],8:[2,7],11:[2,7],12:[2,7],13:[2,7],15:[2,7],17:[2,7],19:[2,7],20:[2,7],21:[2,7],22:[2,7],24:[2,7],25:[2,7],26:[2,7],27:[2,7],34:[2,7],36:[2,7],47:[2,7]},{5:[2,8],8:[2,8],11:[2,8],12:[2,8],13:[2,8],15:[2,8],17:[2,8],19:[2,8],20:[2,8],21:[2,8],22:[2,8],24:[2,8],25:[2,8],26:[2,8],27:[2,8],34:[2,8],36:[2,8],47:[2,8]},{5:[2,38],8:[2,38],11:[2,38],12:[2,38],13:[2,38],15:[2,38],17:[2,38],19:[2,38],20:[2,38],21:[2,38],22:[2,38],24:[2,38],25:[2,38],26:[2,38],27:[2,38],29:[2,38],31:[2,38],34:[2,38],36:[2,38],38:[2,38],41:[2,38],42:[2,38],44:[2,38],46:[2,38],47:[2,38]},{5:[2,39],8:[2,39],11:[2,39],12:[2,39],13:[2,39],15:[2,39],17:[2,39],19:[2,39],20:[2,39],21:[2,39],22:[2,39],24:[2,39],25:[2,39],26:[2,39],27:[2,39],29:[2,39],31:[2,39],34:[2,39],36:[2,39],38:[2,39],41:[2,39],42:[2,39],44:[2,39],46:[2,39],47:[2,39]},{5:[2,40],8:[2,40],11:[2,40],12:[2,40],13:[2,40],15:[2,40],17:[2,40],19:[2,40],20:[2,40],21:[2,40],22:[2,40],24:[2,40],25:[2,40],26:[2,40],27:[2,40],29:[2,40],31:[2,40],34:[2,40],36:[2,40],38:[2,40],41:[2,40],42:[2,40],44:[2,40],46:[2,40],47:[2,40]},{5:[2,42],8:[2,42],11:[2,42],12:[2,42],13:[2,42],15:[2,42],17:[2,42],19:[2,42],20:[2,42],21:[2,42],22:[2,42],24:[2,42],25:[2,42],26:[2,42],27:[2,42],29:[2,42],31:[2,42],34:[2,42],36:[2,42],38:[2,42],41:[2,42],42:[2,42],44:[2,42],46:[2,42],47:[2,42]},{38:[2,34],44:[2,34],47:[2,34]}],defaultActions:{31:[2,1]},parseError:function(a,b){if(!b.recoverable)throw new Error(a);this.trace(a)},parse:function(a){function b(){var a;return a=c.lexer.lex()||m,"number"!=typeof a&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(a),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n);var o=this.lexer.options&&this.lexer.options.ranges;this.parseError="function"==typeof this.yy.parseError?this.yy.parseError:Object.getPrototypeOf(this).parseError;for(var p,q,r,s,t,u,v,w,x,y={};;){if(r=d[d.length-1],this.defaultActions[r]?s=this.defaultActions[r]:((null===p||"undefined"==typeof p)&&(p=b()),s=g[r]&&g[r][p]),"undefined"==typeof s||!s.length||!s[0]){var z="";x=[];for(u in g[r])this.terminals_[u]&&u>l&&x.push("'"+this.terminals_[u]+"'");z=this.lexer.showPosition?"Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+x.join(", ")+", got '"+(this.terminals_[p]||p)+"'":"Parse error on line "+(i+1)+": Unexpected "+(p==m?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(z,{text:this.lexer.match,token:this.terminals_[p]||p,line:this.lexer.yylineno,loc:n,expected:x})}if(s[0]instanceof Array&&s.length>1)throw new Error("Parse Error: multiple actions possible at state: "+r+", token: "+p);switch(s[0]){case 1:d.push(p),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(s[1]),p=null,q?(p=q,q=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:if(v=this.productions_[s[1]][1],y.$=e[e.length-v],y._$={first_line:f[f.length-(v||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(v||1)].first_column,last_column:f[f.length-1].last_column},o&&(y._$.range=[f[f.length-(v||1)].range[0],f[f.length-1].range[1]]),t=this.performAction.call(y,h,j,i,this.yy,s[1],e,f),"undefined"!=typeof t)return t;v&&(d=d.slice(0,-1*v*2),e=e.slice(0,-1*v),f=f.slice(0,-1*v)),d.push(this.productions_[s[1]][0]),e.push(y.$),f.push(y._$),w=g[d[d.length-2]][d[d.length-1]],d.push(w);break;case 3:return!0}}return!0}},c=function(){var a={EOF:1,parseError:function(a,b){if(!this.yy.parser)throw new Error(a);this.yy.parser.parseError(a,b)},setInput:function(a){return this._input=a,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var b=a.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},unput:function(a){var b=a.length,c=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b-1),this.offset-=b;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),c.length-1&&(this.yylineno-=c.length-1);var e=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===d.length?this.yylloc.first_column:0)+d[d.length-c.length].length-c[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[e[0],e[0]+this.yyleng-b]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=new Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},test_match:function(a,b){var c,d,e;if(this.options.backtrack_lexer&&(e={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(e.yylloc.range=this.yylloc.range.slice(0))),d=a[0].match(/(?:\r\n?|\n).*/g),d&&(this.yylineno+=d.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:d?d[d.length-1].length-d[d.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+a[0].length},this.yytext+=a[0],this.match+=a[0],this.matches=a,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(a[0].length),this.matched+=a[0],c=this.performAction.call(this,this.yy,this,b,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),c)return c;if(this._backtrack){for(var f in e)this[f]=e[f];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d;this._more||(this.yytext="",this.match="");for(var e=this._currentRules(),f=0;fb[0].length)){if(b=c,d=f,this.options.backtrack_lexer){if(a=this.test_match(c,e[f]),a!==!1)return a;if(this._backtrack){b=!1;continue}return!1}if(!this.options.flex)break}return b?(a=this.test_match(b,e[d]),a!==!1?a:!1):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){var a=this.conditionStack.length-1;return a>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(a){return a=this.conditionStack.length-1-Math.abs(a||0),a>=0?this.conditionStack[a]:"INITIAL"},pushState:function(a){this.begin(a)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(a,b,c,d){switch(c){case 0:return 29;case 1:return 31;case 2:return"from";case 3:return 24;case 4:return 25;case 5:return 21;case 6:return 19;case 7:return 22;case 8:return 20;case 9:return 26;case 10:return 27;case 11:return 34;case 12:return 36;case 13:return 55;case 14:return 53;case 15:break;case 16:return 49;case 17:return 48;case 18:return 48;case 19:return 40;case 20:return 51;case 21:return 41;case 22:return 11;case 23:return 12;case 24:return 13;case 25:return 38;case 26:return 8;case 27:return 26;case 28:return 27;case 29:return 24;case 30:return 24;case 31:return 25;case 32:return 25;case 33:return 21;case 34:return 22;case 35:return 20;case 36:return 19;case 37:return 34;case 38:return 36;case 39:return 15;case 40:return 17;case 41:return 46;case 42:return 44;case 43:return 42;case 44:return 47;case 45:return 9;case 46:return 5}},rules:[/^(?:\s+in\b)/,/^(?:\s+notIn\b)/,/^(?:\s+from\b)/,/^(?:\s+(eq|EQ)\b)/,/^(?:\s+(neq|NEQ)\b)/,/^(?:\s+(lte|LTE)\b)/,/^(?:\s+(lt|LT)\b)/,/^(?:\s+(gte|GTE)\b)/,/^(?:\s+(gt|GT)\b)/,/^(?:\s+(like|LIKE)\b)/,/^(?:\s+(notLike|NOT_LIKE)\b)/,/^(?:\s+(and|AND)\b)/,/^(?:\s+(or|OR)\b)/,/^(?:\s+null\b)/,/^(?:\s+(true|false)\b)/,/^(?:\s+)/,/^(?:-?[0-9]+(?:\.[0-9]+)?\b)/,/^(?:'[^']*')/,/^(?:"[^"]*")/,/^(?:([a-zA-Z_$][0-9a-zA-Z_$]*))/,/^(?:^\/((?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/[imgy]{0,4})(?!\w))/,/^(?:\.)/,/^(?:\*)/,/^(?:\/)/,/^(?:\%)/,/^(?:,)/,/^(?:-)/,/^(?:=~)/,/^(?:!=~)/,/^(?:==)/,/^(?:===)/,/^(?:!=)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:>)/,/^(?:<)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\])/,/^(?:\[)/,/^(?:\))/,/^(?:!)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0}}};return a}();return b.lexer=c,a.prototype=b,b.Parser=a,new a}();"undefined"!=typeof a&&"undefined"!=typeof c&&(c.parser=e,c.Parser=e.Parser,c.parse=function(){return e.parse.apply(e,arguments)},c.main=function(b){b[1]||(console.log("Usage: "+b[0]+" FILE"),d.exit(1));var e=a("fs").readFileSync(a("path").normalize(b[1]),"utf8"); +return c.parser.parse(e)},"undefined"!=typeof b&&a.main===b&&c.main(d.argv.slice(1)))},{__browserify_process:64,fs:61,path:62}],44:[function(a,b,c){!function(){"use strict";var b=a("./constraint/parser"),d=a("./nools/nool.parser");c.parseConstraint=function(a){try{return b.parse(a)}catch(c){throw new Error("Invalid expression '"+a+"'")}},c.parseRuleSet=function(a,b){return d.parse(a,b)}}()},{"./constraint/parser":43,"./nools/nool.parser":45}],45:[function(a,b,c){"use strict";var d=a("./tokens.js"),e=a("../../extended"),f=e.hash.keys,g=a("./util.js"),h=function(a,b,c){var d=a;a=a.replace(/\/\/(.*)/g,"").replace(/\n|\r|\r\n/g," ");for(var e,i=new RegExp("^("+f(b).join("|")+")");a&&-1!==(e=g.findNextTokenIndex(a));){a=a.substr(e);var j=a.match(i);if(null===j)throw new Error("Error parsing "+a);if(j=j[1],!(j in b))throw new Error("Unknown token"+j);try{a=b[j](a,c,h).replace(/^\s*|\s*$/g,"")}catch(k){throw new Error("Invalid "+j+" definition \n"+k.message+"; \nstarting at : "+d)}}};c.parse=function(a,b){var c={define:[],rules:[],scope:[],loaded:[],file:b};return h(a,d,c),c}},{"../../extended":12,"./tokens.js":46,"./util.js":47}],46:[function(require,module,exports){var process=require("__browserify_process"),utils=require("./util.js"),fs=require("fs"),extd=require("../../extended"),filter=extd.filter,indexOf=extd.indexOf,predicates=["not","or","exists"],predicateRegExp=new RegExp("^("+predicates.join("|")+") *\\((.*)\\)$","m"),predicateBeginExp=new RegExp(" *("+predicates.join("|")+") *\\(","g"),isWhiteSpace=function(a){return 0===a.replace(/[\s|\n|\r|\t]/g,"").length},joinFunc=function(a,b){return"; "+b},splitRuleLineByPredicateExpressions=function(a){var b=a.replace(/,\s*(\$?\w+\s*:)/g,joinFunc),c=filter(b.split(predicateBeginExp),function(a){return""!==a}),d=c.length,e=[];if(!d)return b;for(var f=0;d>f;f++)-1!==indexOf(predicates,c[f])?e.push([c[f],"(",c[++f].replace(/, *$/,"")].join("")):e.push(c[f].replace(/, *$/,""));return e.join(";")},ruleTokens={salience:function(){var a=/^(salience|priority)\s*:\s*(-?\d+)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=parseInt(d[2],10);if(isNaN(e))throw new Error("Invalid salience/priority "+d[2]);return c.options.priority=e,b.replace(d[0],"")}throw new Error("invalid format")}}(),agendaGroup:function(){var a=/^(agenda-group|agendaGroup)\s*:\s*([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid agenda-group "+d[2]);return c.options.agendaGroup=e.replace(/^["']|["']$/g,""),b.replace(d[0],"")}throw new Error("invalid format")}}(),autoFocus:function(){var a=/^(auto-focus|autoFocus)\s*:\s*(true|false)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid auto-focus "+d[2]);return c.options.autoFocus="true"===e?!0:!1,b.replace(d[0],"")}throw new Error("invalid format")}}(),"agenda-group":function(){return this.agendaGroup.apply(this,arguments)},"auto-focus":function(){return this.autoFocus.apply(this,arguments)},priority:function(){return this.salience.apply(this,arguments)},when:function(){var ruleRegExp=/^(\$?\w+) *: *(\w+)(.*)/,constraintRegExp=/(\{ *(?:["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']? *(?:, *["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']?)*)+ *\})/,fromRegExp=/(\bfrom\s+.*)/,parseRules=function(str){for(var rules=[],ruleLines=str.split(";"),l=ruleLines.length,ruleLine,i=0;l>i&&(ruleLine=ruleLines[i].replace(/^\s*|\s*$/g,"").replace(/\n/g,""));i++)if(!isWhiteSpace(ruleLine)){var rule=[];if(predicateRegExp.test(ruleLine)){var m=ruleLine.match(predicateRegExp),pred=m[1].replace(/^\s*|\s*$/g,"");if(rule.push(pred),ruleLine=m[2].replace(/^\s*|\s*$/g,""),"or"===pred){rule=rule.concat(parseRules(splitRuleLineByPredicateExpressions(ruleLine))),rules.push(rule);continue}}var parts=ruleLine.match(ruleRegExp);if(!parts||!parts.length)throw new Error("Invalid constraint "+ruleLine);rule.push(parts[2],parts[1]);var constraints=parts[3].replace(/^\s*|\s*$/g,""),hashParts=constraints.match(constraintRegExp),from=null,fromMatch;if(hashParts){var hash=hashParts[1],constraint=constraints.replace(hash,"");fromRegExp.test(constraint)&&(fromMatch=constraint.match(fromRegExp),from=fromMatch[0],constraint=constraint.replace(fromMatch[0],"")),constraint&&rule.push(constraint.replace(/^\s*|\s*$/g,"")),hash&&rule.push(eval("("+hash.replace(/(\$?\w+)\s*:\s*(\$?\w+)/g,'"$1" : "$2"')+")"))}else constraints&&!isWhiteSpace(constraints)&&(fromRegExp.test(constraints)&&(fromMatch=constraints.match(fromRegExp),from=fromMatch[0],constraints=constraints.replace(fromMatch[0],"")),rule.push(constraints));from&&rule.push(from),rules.push(rule)}return rules};return function(a,b){var c=a.replace(/^when\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(d,""),b.constraints=parseRules(d.replace(/^\{\s*|\}\s*$/g,"")),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}(),then:function(){return function(a,b){if(b.action)throw new Error("action already defined for rule"+b.name);var c=a.replace(/^then\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join("");if(c=c.replace(d,""),b.action||(b.action=d.replace(/^\{\s*|\}\s*$/g,"")),!isWhiteSpace(c))throw new Error("Error parsing then block "+a);return c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}()},topLevelTokens={"/":function(a){return a.match(/^\/\*/)?a.replace(/\/\*.*?\*\//,""):a},define:function(a,b){var c=a.replace(/^define\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){d=d[1];var e=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(e,""),b.define.push({name:d,properties:"("+e+")"}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"import":function(a,b,c){if("undefined"!=typeof window)throw new Error("import cannot be used in a browser");var d=a.replace(/^import\s*/,"");if("("===utils.findNextToken(d)){var e=utils.getParamList(d);if(d=d.replace(e,"").replace(/^\s*|\s*$/g,""),";"===utils.findNextToken(d)&&(d=d.replace(/\s*;/,"")),e=e.replace(/[\(|\)]/g,"").split(","),1===e.length){if(e=utils.resolve(b.file||process.cwd(),e[0].replace(/["|']/g,"")),-1===indexOf(b.loaded,e)){var f=b.file;b.file=e,c(fs.readFileSync(e,"utf8"),topLevelTokens,b),b.loaded.push(e),b.file=f}return d}throw new Error("import accepts a single file")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(d)+"'")},global:function(a,b){var c=a.replace(/^global\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*\s*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"="===utils.findNextToken(c)){d=d[1].replace(/^\s+|\s+$/g,"");var e=utils.getTokensBetween(c,"=",";",!0).join(""),f=e.substring(1,e.length-1);if(f=f.replace(/^\s+|\s+$/g,""),/^require\(/.test(f)){var g=utils.getParamList(f.replace("require")).replace(/[\(|\)]/g,"").split(",");1===g.length&&(g=g[0].replace(/["|']/g,""),f=["require('",utils.resolve(b.file||process.cwd(),g),"')"].join(""))}return b.scope.push({name:d,body:f}),c=c.replace(e,"")}throw new Error("unexpected token : expected : '=' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"function":function(a,b){var c=a.replace(/^function\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)\s*/);if(d){if(c=c.replace(d[0],""),"("===utils.findNextToken(c)){d=d[1];var e=utils.getParamList(c);if(c=c.replace(e,"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){var f=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(f,""),b.scope.push({name:d,body:"function"+e+f}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},rule:function(a,b,c){var d=a.replace(/^rule\s*/,""),e=d.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')/);if(e){if(d=d.replace(e[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(d)){e=e[1].replace(/^["']|["']$/g,"");var f={name:e,options:{},constraints:null,action:null},g=utils.getTokensBetween(d,"{","}",!0).join("");return d=d.replace(g,""),c(g.replace(/^\{\s*|\}\s*$/g,""),ruleTokens,f),b.rules.push(f),d}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(d)+"'")}throw new Error("missing name")}};module.exports=topLevelTokens},{"../../extended":12,"./util.js":47,__browserify_process:64,fs:61}],47:[function(a,b,c){var d=a("__browserify_process"),e=a("path"),f=/[\s|\n|\r|\t]/,g=e.sep||("win32"===d.platform?"\\":"/"),h={"{":"}","}":"{","(":")",")":"(","[":"]"},i=c.getTokensBetween=function(a,b,c,d){var e=0,f=[];b||(b=h[c],e=1),c||(c=h[b]),a=Object(a);for(var g,i=!1,j=0,k=!1;g=a.charAt(j++);)if(g===b)e++,i?f.push(g):(i=!0,d&&f.push(g));else if(g===c&&j){if(e--,0===e){d&&f.push(g),k=!0;break}f.push(g)}else i&&f.push(g);if(!k)throw new Error("Unable to match "+b+" in "+a);return f};c.getParamList=function(a){return i(a,"(",")",!0).join("")},c.resolve=function(a,b){return""!==e.extname(a)&&(a=e.dirname(a)),1===b.split(g).length?b:e.resolve(a,b)};var j=c.findNextTokenIndex=function(a,b,c){b=b||0,c=c||a.length;var d=-1,e=a.length;for((!c||c>e)&&(c=e);c>b;b++){var g=a.charAt(b);if(!f.test(g)){d=b;break}}return d};c.findNextToken=function(a,b,c){return a.charAt(j(a,b,c))}},{__browserify_process:64,path:62}],48:[function(a,b,c){"use strict";var d=a("./extended"),e=d.isEmpty,f=d.merge,g=d.forEach,h=d.declare,i=a("./constraintMatcher"),j=a("./constraint"),k=j.EqualityConstraint,l=j.FromConstraint,m=0,n=h({}),o=n.extend({instance:{constructor:function(a,b,c,d,h){h=h||{},this.id=m++,this.type=a,this.alias=b,this.conditions=c,this.pattern=h.pattern;var k=[new j.ObjectConstraint(a)],l=i.toConstraints(c,f({alias:b},h));if(l.length)k=k.concat(l);else{var n=new j.TrueConstraint;k.push(n)}if(d&&!e(d)){var o=new j.HashConstraint(d);k.push(o)}g(k,function(a){a.set("alias",b)}),this.constraints=k},getSpecificity:function(){for(var a=this.constraints,b=0,c=0,d=a.length;d>c;c++)a[c]instanceof k&&b++;return b},hasConstraint:function(a){return d.some(this.constraints,function(b){return b instanceof a})},hashCode:function(){return[this.type,this.alias,d.format("%j",this.conditions)].join(":")},toString:function(){return d.format("%j",this.constraints)}}}).as(c,"ObjectPattern"),p=o.extend({instance:{constructor:function(a,b,c,d,e,f){this._super([a,b,c,d,f]),this.from=new l(e,f)},hasConstraint:function(a){return d.some(this.constraints,function(b){return b instanceof a})},getSpecificity:function(){return this._super(arguments)+1},hashCode:function(){return[this.type,this.alias,d.format("%j",this.conditions),this.from.from].join(":")},toString:function(){return d.format("%j from %s",this.constraints,this.from.from)}}}).as(c,"FromPattern");p.extend().as(c,"FromNotPattern"),o.extend().as(c,"NotPattern"),o.extend().as(c,"ExistsPattern"),p.extend().as(c,"FromExistsPattern"),n.extend({instance:{constructor:function(a,b){this.id=m++,this.leftPattern=a,this.rightPattern=b},hashCode:function(){return[this.leftPattern.hashCode(),this.rightPattern.hashCode()].join(":")},getSpecificity:function(){return this.rightPattern.getSpecificity()+this.leftPattern.getSpecificity()},getters:{constraints:function(){return this.leftPattern.constraints.concat(this.rightPattern.constraints)}}}}).as(c,"CompositePattern");var q=h({instance:{constructor:function(){this.id=m++,this.recency=0}}}).as(c,"InitialFact");o.extend({instance:{constructor:function(){this._super([q,"__i__",[],{}])},assert:function(){return!0}}}).as(c,"InitialFactPattern")},{"./constraint":8,"./constraintMatcher":9,"./extended":12}],49:[function(a,b,c){"use strict";function d(a,b,c,d){f(b)?(d=c,c=b):b=b||{};var g=e.every(c,function(a){return f(a)});g&&1===c.length&&(c=c[0],g=!1);var h=[],i=b.scope||{};if(c.scope=i,g){for(var j,k=function(a,b){m[b]?e(m).forEach(function(b){b.push(a)}):(m[b]=0===b?[]:m[b-1].slice(),0!==b&&m[b].pop(),m[b].push(a))},l=c.length,m=[],n=0;l>n;n++)j=c[n],j.scope=i,e.forEach(y(j),k);h=e.map(m,function(c){for(var e=null,f=0;f>>0;if(0===d)return-1;var e=d;arguments.length>2&&(e=Number(arguments[2]),e!==e?e=0:0!==e&&e!==1/0&&e!==-(1/0)&&(e=(e>0||-1)*P(Q(e))));for(var f=e>=0?R(e,d-1):d-Q(e);f>=0;f--)if(f in c&&c[f]===b)return f;return-1}function i(a,b,c){if(a&&X&&X===a.filter)return a.filter(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)if(g in d){var h=d[g];b.call(c,h,g,d)&&f.push(h)}return f}function j(a,b,c){if(!N(a)||"function"!=typeof b)throw new TypeError;if(a&&T&&T===a.forEach)return a.forEach(b,c),a;for(var d=0,e=a.length;e>d;++d)b.call(c||a,a[d],d,a);return a}function k(a,b,c){if(a&&Y&&Y===a.every)return a.every(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&!b.call(c,d[f],f,d))return!1;return!0}function l(a,b,c){if(a&&Z&&Z===a.some)return a.some(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&b.call(c,d[f],f,d))return!0;return!1}function m(a,b,c){if(a&&U&&U===a.map)return a.map(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)g in d&&f.push(b.call(c,d[g],g,d));return f}function n(a,b,c){var d=arguments.length>2;if(a&&V&&V===a.reduce)return d?a.reduce(b,c):a.reduce(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=0,f=a.length>>0;if(arguments.length<3){if(0===f)throw new TypeError("Array length is 0 and no second argument");c=a[0],e=1}else c=arguments[2];for(;f>e;)e in a&&(c=b.call(void 0,c,a[e],e,a)),++e;return c}function o(a,b,c){var d=arguments.length>2;if(a&&W&&W===a.reduceRight)return d?a.reduceRight(b,c):a.reduceRight(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=Object(a),f=e.length>>>0;if(0===f&&2===arguments.length)throw new TypeError;var g=f-1;if(arguments.length>=3)c=arguments[2];else for(;;)if(g in a){c=a[g--];break}for(;g>=0;)g in e&&(c=b.call(void 0,c,e[g],g,e)),g--;return c}function p(a){var c=[];if(null!==a){var d=$(arguments);if(1===d.length)if(N(a))c=a;else if(b.isHash(a))for(var e in a)a.hasOwnProperty(e)&&c.push([e,a[e]]);else c.push(a);else j(d,function(a){c=c.concat(p(a))})}return c}function q(a){return a=a||[],a.length?n(a,function(a,b){return a+b}):0}function r(a){if(a=a||[],a.length){var c=q(a);if(b.isNumber(c))return c/a.length;throw new Error("Cannot average an array of non numbers.")}return 0}function s(a,b){return _(a,b)}function t(a,b){return _(a,b)[0]}function u(a,b){return _(a,b)[a.length-1]}function v(a){var b=a,c=J($(arguments,1));return N(a)&&(b=i(a,function(a){return-1===g(c,a)})),b}function w(a){var b,c=[],d=-1,e=0;if(a)for(b=a.length;++d0?(c.push(c.shift()),b--):(c.unshift(c.pop()),b++),y(c,b)):c}function z(a,b){var c=[];if(N(a)){var d=a.slice(0);"number"!=typeof b&&(b=a.length),b?b<=a.length&&(c=n(a,function(a,c,f){var g;return g=b>1?e(c,y(d,f).slice(1),b):[[c]],a.concat(g)},[])):c=[[]]}return c}function A(){var a=[],c=$(arguments);if(c.length>1){var d=c.shift();N(d)&&(a=n(d,function(a,d,e){for(var f=[d],g=0;gd;d++)c.push(a[b[d]]||null);return c}function D(){var a=[],b=$(arguments);if(b.length>1){for(var c=0,d=b.length;d>c;c++)a=a.concat(b[c]);a=w(a)}return a}function E(){var a,b,c=[],d=-1;if(a=arguments.length>1?$(arguments):arguments[0],N(a))for(c=a[0],d=0,b=a.length;++d1?c:p(a),n(b,function(a,b){return a.concat(b)},[])}function K(a,b){b=b.split(".");var c=a.slice(0);return j(b,function(a){var b=a.match(/(\w+)\(\)$/);c=m(c,function(c){return b?c[b[1]]():c[a]})}),c}function L(a,b,c){return c=$(arguments,2),m(a,function(a){var d=M(b)?a[b]:b;return d.apply(a,c)})}var M=b.isString,N=Array.isArray||b.isArray,O=b.isDate,P=Math.floor,Q=Math.abs,R=(Math.max,Math.min),S=Array.prototype,T=(S.indexOf,S.forEach),U=S.map,V=S.reduce,W=S.reduceRight,X=S.filter,Y=S.every,Z=S.some,$=c.argsToArray,_=function(){var a=function(a,b){return k(a,b)},b=function(a,b){return a-b},c=function(a,b){return a.getTime()-b.getTime()};return function(d,e){var f=[];return N(d)&&(f=d.slice(),e?"function"==typeof e?f.sort(e):f.sort(function(a,b){var c=a[e],d=b[e];return M(c)&&M(d)?c>d?1:d>c?-1:0:O(c)&&O(d)?c.getTime()-d.getTime():c-d}):a(f,M)?f.sort():a(f,O)?f.sort(c):f.sort(b)),f}}(),ab={toArray:p,sum:q,avg:r,sort:s,min:t,max:u,difference:v,removeDuplicates:w,unique:x,rotate:y,permutations:z,zip:A,transpose:B,valuesAt:C,union:D,intersect:E,powerSet:F,cartesian:G,compact:H,multiply:I,flatten:J,pluck:K,invoke:L,forEach:j,map:m,filter:i,reduce:n,reduceRight:o,some:l,every:k,indexOf:g,lastIndexOf:h};return a.define(N,ab).expose(ab)}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.arrayExtended=d(this.extended,this.isExtended,this.argumentsExtended)}).call(this)},{"arguments-extended":51,extended:56,"is-extended":66}],53:[function(a,b,c){(function(){"use strict";function d(a,b,c){function d(a,b,c,d){a=""+a,c=c||" ";for(var e=a.length;b>e;)d?a+=c:a=c+a,e++;return a}function e(a,c,d){var f=a;if(b.isString(f)){if(a.length>c)if(d){var g=a.length;f=a.substring(g-c,g)}else f=a.substring(0,c)}else f=e(""+f,c);return f}function f(a,c,d){if(!b.isArray(a)||"function"!=typeof c)throw new TypeError;for(var e=Object(a),f=e.length>>>0,g=0;f>g;g++)if(g in e&&!c.call(d,e[g],g,e))return!1;return!0}function g(a,b){return A.difference(new Date(a.getFullYear(),0,1,a.getHours()),a,null,b)+1}function h(a,b,c){b=b||0;var d=a[c?"getUTCFullYear":"getFullYear"](),e=new Date(d,0,1).getDay(),f=(e-b+7)%7,h=o((g(a)+f-1)/7);return e===b&&h++,h}function i(a){var b=a.toString(),c="",d=b.indexOf("(");return d>-1&&(c=b.substring(++d,b.indexOf(")"))),c}function j(a,b){return a.replace(/([a-z])\1*/gi,function(a){var c,d=a.charAt(0),e=a.length,f="0?",g="0{0,2}";if("y"===d)c="\\d{2,4}";else if("M"===d)c=e>2?"\\S+?":"1[0-2]|"+f+"[1-9]";else if("D"===d)c="[12][0-9][0-9]|3[0-5][0-9]|36[0-6]|"+g+"[1-9][0-9]|"+f+"[1-9]";else if("d"===d)c="3[01]|[12]\\d|"+f+"[1-9]";else if("w"===d)c="[1-4][0-9]|5[0-3]|"+f+"[1-9]";else if("E"===d)c="\\S+";else if("h"===d)c="1[0-2]|"+f+"[1-9]";else if("K"===d)c="1[01]|"+f+"\\d";else if("H"===d)c="1\\d|2[0-3]|"+f+"\\d";else if("k"===d)c="1\\d|2[0-4]|"+f+"[1-9]";else if("m"===d||"s"===d)c="[0-5]\\d";else if("S"===d)c="\\d{"+e+"}";else if("a"===d){var h="AM",i="PM";c=h+"|"+i,h!==h.toLowerCase()&&(c+="|"+h.toLowerCase()),i!==i.toLowerCase()&&(c+="|"+i.toLowerCase()),c=c.replace(/\./g,"\\.")}else c="v"===d||"z"===d||"Z"===d||"G"===d||"q"===d||"Q"===d?".*":" "===d?"\\s*":d+"*";return b&&b.push(a),"("+c+")"}).replace(/[\xa0 ]/g,"[\\s\\xa0]")}function k(a){B[a+"sFromNow"]=function(b){return A.add(new Date,a,b)},B[a+"sAgo"]=function(b){return A.add(new Date,a,-b)}}for(var l=function(){function a(a,b,c){return a=a.replace(/s$/,""),e.hasOwnProperty(a)?e[a](b,c):[c,"UTC"+a.charAt(0).toUpperCase()+a.substring(1)+"s",!1]}function b(a,b,c,e){return a=a.replace(/s$/,""),d(f[a](b,c,e))}var c=Math.floor,d=Math.round,e={day:function(a,b){return[b,"Date",!1]},weekday:function(a,b){var c,d,e=b%5,f=a.getDay(),g=0;e?(c=e,d=parseInt(b/5,10)):(c=b>0?5:-5,d=b>0?(b-5)/5:(b+5)/5),6===f&&b>0?g=1:0===f&&0>b&&(g=-1);var h=f+c;return(0===h||6===h)&&(g=b>0?2:-2),[7*d+c+g,"Date",!1]},year:function(a,b){return[b,"FullYear",!0]},week:function(a,b){return[7*b,"Date",!1]},quarter:function(a,b){return[3*b,"Month",!0]},month:function(a,b){return[b,"Month",!0]}},f={quarter:function(a,b,d){var e=b.getFullYear()-a.getFullYear(),f=a[d?"getUTCMonth":"getMonth"](),g=b[d?"getUTCMonth":"getMonth"](),h=c(f/3)+1,i=c(g/3)+1;return i+=4*e,i-h},weekday:function(a,c,d){var e,f=b("day",a,c,d),g=f%7;if(0===g)f=5*b("week",a,c,d);else{var h=0,i=a[d?"getUTCDay":"getDay"](),j=c[d?"getUTCDay":"getDay"]();e=parseInt(f/7,10);var k=new Date(+a);k.setDate(k[d?"getUTCDate":"getDate"]()+7*e);var l=k[d?"getUTCDay":"getDay"]();f>0?6===i||6===j?h=-1:0===i?h=0:(0===j||l+g>5)&&(h=-2):0>f&&(6===i?h=0:0===i||0===j?h=1:(6===j||0>l+g)&&(h=2)),f+=h,f-=2*e}return f},year:function(a,b){return b.getFullYear()-a.getFullYear()},month:function(a,b,c){var d=a[c?"getUTCMonth":"getMonth"](),e=b[c?"getUTCMonth":"getMonth"]();return e-d+12*(b.getFullYear()-a.getFullYear())},week:function(a,c,e){return d(b("day",a,c,e)/7)},day:function(a,b){return 1.1574074074074074e-8*(b.getTime()-a.getTime())},hour:function(a,b){return 2.7777777777777776e-7*(b.getTime()-a.getTime())},minute:function(a,b){return 16666666666666667e-21*(b.getTime()-a.getTime())},second:function(a,b){return.001*(b.getTime()-a.getTime())},millisecond:function(a,b){return b.getTime()-a.getTime()}};return{addTransform:a,differenceTransform:b}}(),m=l.addTransform,n=l.differenceTransform,o=Math.floor,p=Math.round,q=Math.min,r=Math.pow,s=Math.ceil,t=Math.abs,u=["January","February","March","April","May","June","July","August","September","October","November","December"],v=["Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."],w=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],x=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],y=["Before Christ","Anno Domini"],z=["BC","AD"],A={getDaysInMonth:function(a){var b=a.getMonth(),c=[31,28,31,30,31,30,31,31,30,31,30,31];return 1===b&&A.isLeapYear(a)?29:c[b]},isLeapYear:function(a,b){var c=a[b?"getUTCFullYear":"getFullYear"]();return c%400===0||c%4===0&&c%100!==0},isWeekend:function(a,b){var c=(a||new Date)[b?"getUTCDay":"getDay"]();return 0===c||6===c},getTimezoneName:i,compare:function(a,b,c){return a=new Date(+a),b=new Date(+(b||new Date)),"date"===c?(a.setHours(0,0,0,0),b.setHours(0,0,0,0)):"time"===c&&(a.setFullYear(0,0,0),b.setFullYear(0,0,0)),a>b?1:b>a?-1:0},add:function(a,b,c){var d=m(b,a,c||0);c=d[0];var e=d[1],f=new Date(+a),g=d[2];return e&&f["set"+e](f["get"+e]()+c),g&&f.getDate()E?z:y)[0>f?0:1];else if("y"===D)B=f,E>1&&(2===E?B=e(""+B,2,!0):C=!0);else if("Q"===D.toUpperCase())B=s((j+1)/3),C=!0;else if("M"===D)3>E?(B=j+1,C=!0):B=(3===E?v:u)[j];else if("w"===D)B=h(a,0,c),C=!0;else if("D"===D)B=g(a,c),C=!0;else if("E"===D)3>E?(B=k+1,C=!0):B=(-3===E?x:w)[k];else if("a"===D)B=12>m?"AM":"PM";else if("h"===D)B=m%12||12,C=!0;else if("K"===D)B=m%12,C=!0;else if("k"===D)B=m||24,C=!0;else if("S"===D)B=p(A*r(10,E-3)),C=!0;else if("z"===D||"v"===D||"Z"===D){if(B=i(a),"z"!==D&&"v"!==D||B||(E=4),!B||"Z"===D){var F=a.getTimezoneOffset(),G=[F>=0?"-":"+",d(o(t(F)/60),2,"0"),d(t(F)%60,2,"0")];4===E&&(G.splice(0,0,"GMT"),G.splice(3,0,":")),B=G.join("")}}else B=b;else B=""+n,C=!0;else B=""+m,C=!0;return C&&(B=d(B,E,"0")),B})}},B={},C=["year","month","day","hour","minute","second"],D=0,E=C.length;E>D;D++)k(C[D]);var F={parseDate:function(a,b){if(!b)throw new Error("format required when calling dateExtender.parse");var d=[],e=j(b,d),g=new RegExp("^"+e+"$","i"),h=g.exec(a);if(!h)return null;var i=[1970,0,1,0,0,0,0],k="",l=f(h,function(a,b){if(b){var e=d[b-1],f=e.length,g=e.charAt(0);if("y"===g)if(100>a){a=parseInt(a,10);var h=""+(new Date).getFullYear(),j=100*h.substring(0,2),l=q(h.substring(2,4)+20,99);i[0]=l>a?j+a:j-100+a}else i[0]=a;else if("M"===g){if(f>2){var m,n,o=u;3===f&&(o=v),a=a.replace(".","").toLowerCase();var p=!1;for(m=0,n=o.length;n>m&&!p;m++){var r=o[m].replace(".","").toLocaleLowerCase();r===a&&(a=m,p=!0)}if(!p)return!1}else a--;i[1]=a}else if("E"===g||"e"===g){var s=w;3===f&&(s=x),a=a.toLowerCase(),s=c.map(s,function(a){return a.toLowerCase()});var t=c.indexOf(s,a);if(-1===t){if(a=parseInt(a,10),isNaN(a)||a>s.length)return!1}else a=t}else if("D"===g||"d"===g)"D"===g&&(i[1]=0),i[2]=a;else if("a"===g){var y="am",z="pm",A=/\./g;a=a.replace(A,"").toLowerCase(),k=a===z?"p":a===y?"a":""}else"k"===g||"h"===g||"H"===g||"K"===g?("k"===g&&24===+a&&(a=0),i[3]=a):"m"===g?i[4]=a:"s"===g?i[5]=a:"S"===g&&(i[6]=a)}return!0});if(l){var m=+i[3];"p"===k&&12>m?i[3]=m+12:"a"===k&&12===m&&(i[3]=0);var n=new Date(i[0],i[1],i[2],i[3],i[4],i[5],i[6]),o=-1!==c.indexOf(d,"d"),p=-1!==c.indexOf(d,"M"),r=i[1],s=i[2],t=n.getMonth(),y=n.getDate();return p&&t>r||o&&y>s?null:n}return null}},G=a.define(b.isDate,A).define(b.isString,F).define(b.isNumber,B);for(D in A)A.hasOwnProperty(D)&&(G[D]=A[D]);for(D in F)F.hasOwnProperty(D)&&(G[D]=F[D]);for(D in B)B.hasOwnProperty(D)&&(G[D]=B[D]);return G}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c) +}):this.dateExtended=d(this.extended,this.isExtended,this.arrayExtended)}).call(this)},{"array-extended":52,extended:56,"is-extended":66}],54:[function(a,b,c){!function(){function a(){function a(a,b){return b=b||0,x.call(a,b)}function b(a){return"[object Array]"===Object.prototype.toString.call(a)}function c(a){var b;return null!==a&&a!==b&&"object"==typeof a}function d(a){var b=c(a);return b&&a.constructor===Object}function e(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function f(a,b,c){var d,f;for(d in b)b.hasOwnProperty(d)&&-1===e(c,d)&&(f=b[d],d in a&&a[d]===f||(a[d]=f));return a}function g(a){var c=this.__meta,d=c.supers,e=d.length,f=c.superMeta,g=f.pos;if(e>g){a=a?B(a)||b(a)?a:[a]:[];var h,i=f.name,j=f.f;do if(h=d[g][i],"function"==typeof h&&(h=h._f||h)!==j)return f.pos=1+g,h.apply(this,a);while(e>++g)}return null}function h(){var a=this.__meta,b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.bind(this);while(c>++e)}return null}function i(a){var b=this.__getters__;return b.hasOwnProperty(a)?b[a].apply(this):this[a]}function j(b,c){var e=this.__setters__;if(!d(b))return e.hasOwnProperty(b)?e[b].apply(this,a(arguments,1)):this[b]=c;for(var f in b){var g=b[f];e.hasOwnProperty(f)?e[b].call(this,g):this[f]=g}}function k(){var a=this.__meta||{},b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.apply(this,arguments);while(c>++e)}return null}function l(a,b){if(a.toString().match(A)){var c=function(){var c,d=this.__meta||{},e=d.superMeta;switch(d.superMeta={f:a,pos:0,name:b},arguments.length){case 0:c=a.call(this);break;case 1:c=a.call(this,arguments[0]);break;case 2:c=a.call(this,arguments[0],arguments[1]);break;case 3:c=a.call(this,arguments[0],arguments[1],arguments[2]);break;default:c=a.apply(this,arguments)}return d.superMeta=e,c};return c._f=a,c}return a._f=a,a}function m(a,b){var c=b.setters||{},d=a.__setters__,e=a.__getters__;for(var f in c)d.hasOwnProperty(f)||(d[f]=c[f]);c=b.getters||{};for(f in c)e.hasOwnProperty(f)||(e[f]=c[f]);for(var g in b)if("getters"!==g&&"setters"!==g){var h=b[g];"function"==typeof h?a.hasOwnProperty(g)||(a[g]=l(k,g)):a[g]=h}}function n(){for(var b=a(arguments),c=b.length,d=this.prototype,e=d.__meta,f=this.__meta,g=d.__meta.bases,h=g.slice(),i=f.supers||[],j=e.supers||[],k=0;c>k;k++){var l=b[k],n=l.prototype,p=n.__meta,q=l.__meta;!p&&(p=n.__meta={proto:n||{}}),!q&&(q=l.__meta={proto:l.__proto__||{}}),m(d,p.proto||{}),m(this,q.proto||{}),o(l.prototype,j,g),o(l,i,h)}return this}function o(a,b,c){var d=a.__meta;!d&&(d=a.__meta={});var f=a.__meta.unique;if(!f&&(d.unique="declare"+ ++y),-1===e(c,f)){c.push(f);for(var g=a.__meta.supers||[],h=g.length-1||0;h>=0;)o(g[h--],b,c);b.unshift(a)}}function p(a,b){var c=b.setters,d=a.__setters__,e=a.__getters__;if(c)for(var f in c)d[f]=c[f];if(c=b.getters||{})for(f in c)e[f]=c[f];for(f in b)if("getters"!=f&&"setters"!=f){var g=b[f];if("function"==typeof g){var h=g.__meta||{};a[f]=h.isConstructor?g:l(g,f)}else a[f]=g}}function q(a,b){return a&&b?a[b]=this:a.exports=a=this,this}function r(a){return u(this,a)}function s(a){z.prototype=a.prototype;var b=new z;return z.prototype=null,b}function t(a,c,e){var i={},j=[],m="declare"+ ++y,q=[],r=[],t=[],u=[],v={supers:t,unique:m,bases:q,superMeta:{f:null,pos:0,name:null}},x={supers:u,unique:m,bases:r,isConstructor:!0,superMeta:{f:null,pos:0,name:null}};if(d(c)&&!e&&(e=c,c=w),"function"==typeof c||b(c)?(j=b(c)?c:[c],c=j.shift(),a.__meta=x,i=s(c),i.__meta=v,i.__getters__=f({},i.__getters__||{}),i.__setters__=f({},i.__setters__||{}),a.__getters__=f({},a.__getters__||{}),a.__setters__=f({},a.__setters__||{}),o(c.prototype,t,q),o(c,u,r)):(a.__meta=x,i.__meta=v,i.__getters__=i.__getters__||{},i.__setters__=i.__setters__||{},a.__getters__=a.__getters__||{},a.__setters__=a.__setters__||{}),a.prototype=i,e){var z=v.proto=e.instance||{},A=x.proto=e.static||{};A.init=A.init||k,p(i,z),p(a,A),i.constructor=z.hasOwnProperty("constructor")?l(z.constructor,"constructor"):z.constructor=l(k,"constructor")}else v.proto={},x.proto={},a.init=l(k,"init"),i.constructor=l(k,"constructor");j.length&&n.apply(a,j),c&&f(a,f(f({},c),a)),i._super=a._super=g,i._getSuper=a._getSuper=h,i._static=a}function u(a,b){function c(){switch(arguments.length){case 0:this.constructor.call(this);break;case 1:this.constructor.call(this,arguments[0]);break;case 2:this.constructor.call(this,arguments[0],arguments[1]);break;case 3:this.constructor.call(this,arguments[0],arguments[1],arguments[2]);break;default:this.constructor.apply(this,arguments)}}return t(c,a,b),c.init()||c}function v(a,b){function c(){return d||(this.constructor.apply(this,arguments),d=this),d}var d;return t(c,a,b),c.init()||c}var w,x=Array.prototype.slice,y=0,z=new Function,A=/(super)/g,B=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};return B(arguments)||(B=function(a){return!(!a||!a.hasOwnProperty("callee"))}),w=u({instance:{get:i,set:j},"static":{get:i,set:j,mixin:n,extend:r,as:q}}),u.singleton=v,u}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=a()):"function"==typeof define&&define.amd?define(a):this.declare=a()}()},{}],55:[function(a,b){b.exports=a("./declare.js")},{"./declare.js":54}],56:[function(a,b,c){(function(){"use strict";function d(a){function b(){var b=a.define();return b.expose({register:function(a,c){c||(c=a,a=null);var d=typeof c;if(a)b[a]=c;else if(c&&"function"===d)b.extend(c);else{if("object"!==d)throw new TypeError("extended.register must be called with an extender function");b.expose(c)}return b},define:function(){return a.define.apply(a,arguments)}}),b}function c(){return b()}!function(){function a(a,b){var c,d;for(c in b)b.hasOwnProperty(c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}return function(b){b||(b={});for(var c=1,d=arguments.length;d>c;c++)a(b,arguments[c]);return b}}();return c.define=function(){return a.define.apply(a,arguments)},c}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extender"))):"function"==typeof define&&define.amd?define(["extender"],function(a){return d(a)}):this.extended=d(this.extender)}).call(this)},{extender:58}],57:[function(a,b,c){(function(){function d(a){function b(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function c(a){return"[object Array]"===Object.prototype.toString.call(a)}function d(b){function c(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);a.unshift(this._value);var b=c.apply(this,a);return b!==e?this.__extender__(b):this},a[b]=d}function d(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);return a.unshift(this._value),c.apply(this,a)},a[b]=d}function h(a,b,e){for(var f in b)b.hasOwnProperty(f)&&("getters"!==f&&"setters"!==f?"noWrap"===f?h(a,b[f],!0):e?d(a,f,b[f]):c(a,f,b[f]):a[f]=b[f])}function i(a){var b,c,d=a;if(!(a instanceof m)){var e=m;for(b=0,c=n.length;c>b;b++){var f=n[b];f[0](a)&&(e=e.extend({instance:f[1]}))}d=new e(a),d.__extender__=i}return d}function j(){return!0}function k(a,b){if(arguments.length){"object"==typeof a&&(b=a,a=j),b=b||{};var d={};h(d,b),d.hasOwnProperty("constructor")||(b.hasOwnProperty("constructor")?c(d,"constructor",b.constructor):d.constructor=function(){this._super(arguments)}),n.push([a,d])}return i}function l(a){return a&&a.hasOwnProperty("__defined__")&&(i.__defined__=n=n.concat(a.__defined__)),g(i,a,["define","extend","expose","__defined__"]),i}b=b||[];var m=a({instance:{constructor:function(a){this._value=a},value:function(){return this._value},eq:function(a){return this.__extender__(this._value===a)},neq:function(a){return this.__extender__(this._value!==a)},print:function(){return console.log(this._value),this}}}),n=[];return i.define=k,i.extend=l,i.expose=function(){for(var a,b=0,c=arguments.length;c>b;b++)a=arguments[b],"object"==typeof a&&g(i,a,["define","extend","expose","__defined__"]);return i},i.__defined__=n,i}var e,f=Array.prototype.slice,g=function(){function a(a,c,d){var e,f;for(e in c)c.hasOwnProperty(e)&&-1===b(d,e)&&(f=c[e],e in a&&a[e]===f||(a[e]=f));return a}return function(b){b||(b={});var d=arguments.length,e=arguments[arguments.length-1];c(e)?d--:e=[];for(var f=1;d>f;f++)a(b,arguments[f],e);return b}}();return{define:function(){return d().define.apply(d,arguments)},extend:function(a){return d().define().extend(a)}}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("declare.js"))):"function"==typeof define&&define.amd?define(["declare"],function(a){return d(a)}):this.extender=d(this.declare)}).call(this)},{"declare.js":55}],58:[function(a,b){b.exports=a("./extender.js")},{"./extender.js":57}],59:[function(a,b,c){(function(){"use strict";function d(a,b,c){function d(a,b,c){var d;switch((b||[]).length){case 0:d=a.call(c);break;case 1:d=a.call(c,b[0]);break;case 2:d=a.call(c,b[0],b[1]);break;case 3:d=a.call(c,b[0],b[1],b[2]);break;default:d=a.apply(c,b)}return d}function e(a,b,c){if(c=p(arguments,2),n(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!n(b)&&!o(b))throw new Error(b+" is not a function");return n(b)?function(){var e=a[b];return o(e)?d(e,c.concat(p(arguments)),a):e}:c.length?function(){return d(b,c.concat(p(arguments)),a)}:function(){return d(b,arguments,a)}}function f(a,b){if(b=p(arguments,1),!n(a)&&!o(a))throw new Error(a+" must be the name of a property or function to execute");return n(a)?function(){var c=p(arguments),e=c.shift(),f=e[a];return o(f)?(c=b.concat(c),d(f,c,e)):f}:function(){var c=p(arguments),e=c.shift();return c=b.concat(c),d(a,c,e)}}function g(a,b,c){if(c=p(arguments,2),n(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!n(b)&&!o(b))throw new Error(b+" is not a function");return n(b)?function(){var e=a[b];return o(e)?d(e,c,a):e}:function(){return d(b,c,a)}}function h(a){var b=p(arguments,1);if(!m(a)&&!o(a))throw new TypeError("scope must be an object");if(1===b.length&&l(b[0])&&(b=b[0]),!b.length){b=[];for(var c in a)a.hasOwnProperty(c)&&o(a[c])&&b.push(c)}for(var d=0,f=b.length;f>d;d++)a[b[d]]=e(a,a[b[d]]);return a}function i(a,b){if(b=p(arguments,1),!n(a)&&!o(a))throw new Error(a+" must be the name of a property or function to execute");return n(a)?function(){var c=this[a];if(o(c)){var e=b.concat(p(arguments));return d(c,e,this)}return c}:function(){var c=b.concat(p(arguments));return d(a,c,this)}}function j(a,b){return function(){var c=p(arguments);return b?d(a,arguments,this):function(){return d(a,c.concat(p(arguments)),this)}}}function k(a,b,c){var d;if(d=c?e(c,b):b,a)for(var f=a-1,g=f;g>=0;g--)d=j(d,g===f);return d}var l=b.isArray,m=b.isObject,n=b.isString,o=b.isFunction,p=c.argsToArray;return a.define(m,{bind:e,bindAll:h,bindIgnore:g,curry:function(a,b,c){return k(b,c,a)}}).define(o,{bind:function(a,b){return d(e,[b,a].concat(p(arguments,2)),this)},bindIgnore:function(a,b){return d(g,[b,a].concat(p(arguments,2)),this)},partial:i,applyFirst:f,curry:function(a,b,c){return k(b,a,c)},noWrap:{f:function(){return this.value()}}}).define(n,{bind:function(a,b){return e(b,a)},bindIgnore:function(a,b){return g(b,a)},partial:i,applyFirst:f,curry:function(a,b,c){return k(b,a,c)}}).expose({bind:e,bindAll:h,bindIgnore:g,partial:i,applyFirst:f,curry:k})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.functionExtended=d(this.extended,this.isExtended,this.argumentsExtended)}).call(this)},{"arguments-extended":51,extended:56,"is-extended":66}],60:[function(a,b,c){function d(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;ce;e++)d[e].apply(this,c);return!0}return!1},f.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(g(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:h,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},f.prototype.on=f.prototype.addListener,f.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},f.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(g(c)){var e=d(c,b);if(0>e)return this;c.splice(e,1),0==c.length&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},f.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},f.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),g(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]},f.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?"function"==typeof a._events[b]?1:a._events[b].length:0}},{__browserify_process:64}],61:[function(){},{}],62:[function(a,b,c){function d(a,b){for(var c=[],d=0;d=0;d--){var e=a[d];"."==e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var f=a("__browserify_process"),g=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){for(var a="",b=!1,c=arguments.length;c>=-1&&!b;c--){var g=c>=0?arguments[c]:f.cwd();"string"==typeof g&&g&&(a=g+"/"+a,b="/"===g.charAt(0))}return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b="/"===a.charAt(0),c="/"===a.slice(-1);return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),a||b||(a="."),a&&c&&(a+="/"),(b?"/":"")+a},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(d(a,function(a){return a&&"string"==typeof a}).join("/"))},c.dirname=function(a){var b=g.exec(a)[1]||"",c=!1;return b?1===b.length||c&&b.length<=3&&":"===b.charAt(1)?b:b.substring(0,b.length-1):"."},c.basename=function(a,b){var c=g.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return g.exec(a)[3]||""},c.relative=function(a,b){function d(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;i=0;e--)if(f[e]!=g[e])return!1;for(e=f.length-1;e>=0;e--)if(d=f[e],!h(a[d],b[d]))return!1;return!0}function l(a,b){return a&&b?b instanceof RegExp?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function m(a,b,c,d){var e;"string"==typeof c&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f("Missing expected exception"+d),!a&&l(e,c)&&f("Got unwanted exception"+d),a&&e&&c&&!l(e,c)||!a&&e)throw e}var n=a("util"),o=a("buffer").Buffer,p=Array.prototype.slice,q=b.exports=g;q.AssertionError=function(a){this.name="AssertionError",this.message=a.message,this.actual=a.actual,this.expected=a.expected,this.operator=a.operator;var b=a.stackStartFunction||f;Error.captureStackTrace&&Error.captureStackTrace(this,b)},n.inherits(q.AssertionError,Error),q.AssertionError.prototype.toString=function(){return this.message?[this.name+":",this.message].join(" "):[this.name+":",e(JSON.stringify(this.actual,d),128),this.operator,e(JSON.stringify(this.expected,d),128)].join(" ")},q.AssertionError.__proto__=Error.prototype,q.fail=f,q.ok=g,q.equal=function(a,b,c){a!=b&&f(a,b,c,"==",q.equal)},q.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",q.notEqual)},q.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",q.deepEqual)},q.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",q.notDeepEqual)},q.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",q.strictEqual)},q.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",q.notStrictEqual)},q.throws=function(){m.apply(this,[!0].concat(p.call(arguments)))},q.doesNotThrow=function(){m.apply(this,[!1].concat(p.call(arguments)))},q.ifError=function(a){if(a)throw a}},{util:2,buffer:3}],2:[function(a,b,c){function d(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&d(a.__proto__)}function e(a){return a instanceof RegExp||"object"==typeof a&&"[object RegExp]"===Object.prototype.toString.call(a)}function f(a){if(a instanceof Date)return!0;if("object"!=typeof a)return!1;var b=Date.prototype&&h(Date.prototype),c=a.__proto__&&h(a.__proto__);return JSON.stringify(c)===JSON.stringify(b)}a("events");c.isArray=d,c.isDate=function(a){return"[object Date]"===Object.prototype.toString.call(a)},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)},c.print=function(){},c.puts=function(){},c.debug=function(){},c.inspect=function(a,b,i,j){function k(a,i){if(a&&"function"==typeof a.inspect&&a!==c&&(!a.constructor||a.constructor.prototype!==a))return a.inspect(i);switch(typeof a){case"undefined":return m("undefined","undefined");case"string":var j="'"+JSON.stringify(a).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return m(j,"string");case"number":return m(""+a,"number");case"boolean":return m(""+a,"boolean")}if(null===a)return m("null","null");var n=g(a),o=b?h(a):n;if("function"==typeof a&&0===o.length){if(e(a))return m(""+a,"regexp");var p=a.name?": "+a.name:"";return m("[Function"+p+"]","special")}if(f(a)&&0===o.length)return m(a.toUTCString(),"date");var q,r,s;if(d(a)?(r="Array",s=["[","]"]):(r="Object",s=["{","}"]),"function"==typeof a){var t=a.name?": "+a.name:"";q=e(a)?" "+a:" [Function"+t+"]"}else q="";if(f(a)&&(q=" "+a.toUTCString()),0===o.length)return s[0]+q+s[1];if(0>i)return e(a)?m(""+a,"regexp"):m("[Object]","special");l.push(a);var u=o.map(function(b){var c,e;if(a.__lookupGetter__&&(a.__lookupGetter__(b)?e=a.__lookupSetter__(b)?m("[Getter/Setter]","special"):m("[Getter]","special"):a.__lookupSetter__(b)&&(e=m("[Setter]","special"))),n.indexOf(b)<0&&(c="["+b+"]"),e||(l.indexOf(a[b])<0?(e=null===i?k(a[b]):k(a[b],i-1),e.indexOf("\n")>-1&&(e=d(a)?e.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+e.split("\n").map(function(a){return" "+a}).join("\n"))):e=m("[Circular]","special")),"undefined"==typeof c){if("Array"===r&&b.match(/^\d+$/))return e;c=JSON.stringify(""+b),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=m(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=m(c,"string"))}return c+": "+e});l.pop();var v=0,w=u.reduce(function(a,b){return v++,b.indexOf("\n")>=0&&v++,a+b.length+1},0);return u=w>50?s[0]+(""===q?"":q+"\n ")+" "+u.join(",\n ")+" "+s[1]:s[0]+q+" "+u.join(", ")+" "+s[1]}var l=[],m=function(a,b){var c={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[b];return d?"["+c[d][0]+"m"+a+"["+c[d][1]+"m":a};return j||(m=function(a){return a}),k(a,"undefined"==typeof i?2:i)};c.log=function(){},c.pump=null;var g=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},h=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.hasOwnProperty.call(a,c)&&b.push(c);return b},i=Object.create||function(a,b){var c;if(null===a)c={__proto__:null};else{if("object"!=typeof a)throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}return"undefined"!=typeof b&&Object.defineProperties&&Object.defineProperties(c,b),c};c.inherits=function(a,b){a.super_=b,a.prototype=i(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})};var j=/%[sdj%]/g;c.format=function(a){if("string"!=typeof a){for(var b=[],d=0;d=f)return a;switch(a){case"%s":return String(e[d++]);case"%d":return Number(e[d++]);case"%j":return JSON.stringify(e[d++]);default:return a}}),h=e[d];f>d;h=e[++d])g+=null===h||"object"!=typeof h?" "+h:" "+c.inspect(h);return g}},{events:4}],5:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],6:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],4:[function(a,b,c){!function(a){function b(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;cf;f++)d[f].apply(this,c);return!0}return!1},d.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(e(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:f,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},d.prototype.removeListener=function(a,c){if("function"!=typeof c)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var d=this._events[a];if(e(d)){var f=b(d,c);if(0>f)return this;d.splice(f,1),0==d.length&&delete this._events[a]}else this._events[a]===c&&delete this._events[a];return this},d.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},d.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),e(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}(a("__browserify_process"))},{__browserify_process:6}],"buffer-browserify":[function(a,b){b.exports=a("q9TxCC")},{}],q9TxCC:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used=a.length?0:(c?(e=a.parent[a.offset+b]<<8,b+1=a.length?0:(c?(b+1>>0):(b+2>>0)),e)}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8*(d?1-f:f)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>8*(d?3-f:f)&255}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fthis.length)throw new Error("oob");if(b>c)throw new Error("oob");for(var d=b;c>d;d++)this[d]=a},c.SlowBuffer=d,c.Buffer=l,l.poolSize=8192;var E;l.isBuffer=function(a){return a instanceof l||a instanceof d},l.concat=function(a,b){if(!Array.isArray(a))throw new Error("Usage: Buffer.concat(list, [totalLength])\n list should be an Array.");if(0===a.length)return new l(0);if(1===a.length)return a[0];if("number"!=typeof b){b=0;for(var c=0;cd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=c.length?void 0:c.parent[c.offset+a]},l.prototype.readUInt16LE=function(a,b){return o(this,a,!1,b)},l.prototype.readUInt16BE=function(a,b){return o(this,a,!0,b)},l.prototype.readUInt32LE=function(a,b){return p(this,a,!1,b)},l.prototype.readUInt32BE=function(a,b){return p(this,a,!0,b)},l.prototype.readInt8=function(a,b){var c,d=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=d.length?void 0:(c=128&d.parent[d.offset+a],c?-1*(255-d.parent[d.offset+a]+1):d.parent[d.offset+a])},l.prototype.readInt16LE=function(a,b){return q(this,a,!1,b)},l.prototype.readInt16BE=function(a,b){return q(this,a,!0,b)},l.prototype.readInt32LE=function(a,b){return r(this,a,!1,b)},l.prototype.readInt32BE=function(a,b){return r(this,a,!0,b)},l.prototype.readFloatLE=function(a,b){return s(this,a,!1,b)},l.prototype.readFloatBE=function(a,b){return s(this,a,!0,b)},l.prototype.readDoubleLE=function(a,b){return t(this,a,!1,b)},l.prototype.readDoubleBE=function(a,b){return t(this,a,!0,b)},l.prototype.writeUInt8=function(a,b,c){var d=this;c||(D.ok(void 0!==a&&null!==a,"missing value"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":5,"base64-js":7}],7:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(f>>8&255),h.push(255&f)),h}function c(a){function b(a){return d[a>>18&63]+d[a>>12&63]+d[a>>6&63]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[e<<4&63],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[e>>4&63],h+=d[e<<2&63],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}],8:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],3:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used>>0):(e=a.parent[a.offset+b+2]<<16,e|=a.parent[a.offset+b+1]<<8,e|=a.parent[a.offset+b],e+=a.parent[a.offset+b+3]<<24>>>0),e}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8,a.parent[a.offset+c+1]=255&b):(a.parent[a.offset+c+1]=(65280&b)>>>8,a.parent[a.offset+c]=255&b)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>24&255,a.parent[a.offset+c+1]=b>>>16&255,a.parent[a.offset+c+2]=b>>>8&255,a.parent[a.offset+c+3]=255&b):(a.parent[a.offset+c+3]=b>>>24&255,a.parent[a.offset+c+2]=b>>>16&255,a.parent[a.offset+c+1]=b>>>8&255,a.parent[a.offset+c]=255&b)}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":8,"base64-js":9}],9:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(f>>8&255),h.push(255&f)),h}function c(a){function b(a){return d[a>>18&63]+d[a>>12&63]+d[a>>6&63]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[e<<4&63],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[e>>4&63],h+=d[e<<2&63],h+="=" +}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}]},{},[]),b.exports=a("buffer-browserify")},{}],64:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],65:[function(a,b,c){(function(){"use strict";function d(a){var b=function(a){return"string"==typeof a?a:"object"==typeof a?a.hashCode?a.hashCode():""+a:""+a},c=a.declare({instance:{constructor:function(){this.__entries=[],this.__keys=[],this.__values=[]},pushValue:function(a,b){return this.__keys.push(a),this.__values.push(b),this.__entries.push({key:a,value:b}),b},remove:function(a){for(var b,c=null,d=this.__entries,e=this.__keys,f=this.__values,g=d.length-1;g>=0;g--)if((b=d[g])&&b.key===a)return d.splice(g,1),e.splice(g,1),f.splice(g,1),b.value;return c},set:function(a,b){for(var c=null,d=this.__entries,e=this.__values,f=d.length-1;f>=0;f--){var g=d[f];if(g&&a===g.key){e[f]=b,g.value=b,c=b;break}}return c||d.push({key:a,value:b}),c},find:function(a){for(var b,c=null,d=this.__entries,e=d.length-1;e>=0;e--)if(b=d[e],b&&a===b.key){c=b.value;break}return c},getEntrySet:function(){return this.__entries},getKeys:function(){return this.__keys},getValues:function(){return this.__values}}});return a.declare({instance:{constructor:function(){this.__map={}},entrySet:function(){var a=[],b=this.__map;for(var c in b)b.hasOwnProperty(c)&&(a=a.concat(b[c].getEntrySet()));return a},put:function(a,d){var e=b(a),f=null;return(f=this.__map[e])||(f=this.__map[e]=new c),f.pushValue(a,d),d},remove:function(a){var c=b(a),d=null,e=this.__map[c];return e&&(d=e.remove(a)),d},get:function(a){var c,d=b(a),e=null;return(c=this.__map[d])&&(e=c.find(a)),e},set:function(a,d){var e=b(a),f=null,g=null,h=this.__map;return f=(g=h[e])?g.set(a,d):(h[e]=new c).pushValue(a,d)},contains:function(a){var c=b(a),d=!1,e=null;return(e=this.__map[c])&&(d=!!e.find(a)),d},concat:function(a){if(a instanceof this._static){for(var b=new this._static,c=a.entrySet().concat(this.entrySet()),d=c.length-1;d>=0;d--){var e=c[d];b.put(e.key,e.value)}return b}throw new TypeError("When joining hashtables the joining arg must be a HashTable")},filter:function(b,c){var d=this.entrySet(),e=new this._static;d=a.filter(d,b,c);for(var f=d.length-1;f>=0;f--){var g=d[f];e.put(g.key,g.value)}return e},forEach:function(b,c){var d=this.entrySet();a.forEach(d,b,c)},every:function(b,c){var d=this.entrySet();return a.every(d,b,c)},map:function(b,c){var d=this.entrySet();return a.map(d,b,c)},some:function(b,c){var d=this.entrySet();return a.some(d,b,c)},reduce:function(b,c){var d=this.entrySet();return a.reduce(d,b,c)},reduceRight:function(b,c){var d=this.entrySet();return a.reduceRight(d,b,c)},clear:function(){this.__map={}},keys:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getKeys());return a},values:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getValues());return a},isEmpty:function(){return 0===this.keys().length}}})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")))):"function"==typeof define?define(["extended","declare","is-extended","array-extended"],function(a,b,c,e){return d(a().register("declare",b).register(c).register(e))}):this.Ht=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended))}).call(this)},{"array-extended":52,"declare.js":55,extended:56,"is-extended":66}],66:[function(a,b,c){var d=a("__browserify_Buffer").Buffer;(function(){"use strict";function e(a){function b(a,b){var c=-1,d=0,e=a.length,f=[];for(b=b||0,c+=b;++c=0;f--)if(g[f]!==h[f])return!1;for(f=g.length-1;f>=0;f--)if(d=g[f],!e(a[d],b[d]))return!1}catch(i){return!1}return!0}function g(a){return null!==a&&"object"==typeof a}function h(a){var b=g(a);return b&&a.constructor===Object&&!a.nodeType&&!a.setInterval}function i(a){return W(a)?0===a.length:g(a)?0===c(a).length:r(a)||X(a)?0===a.length:!0}function j(a){return a===!0||a===!1||"[object Boolean]"===U.call(a)}function k(a){return"undefined"==typeof a}function l(a){return!k(a)}function m(a){return k(a)||n(a)}function n(a){return null===a}function o(a,b){return V(b)?a instanceof b:!1}function p(a){return"[object RegExp]"===U.call(a)}function q(a){return"[object Date]"===U.call(a)}function r(a){return"[object String]"===U.call(a)}function s(a){return"[object Number]"===U.call(a)}function t(a){return a===!0}function u(a){return a===!1}function v(a){return!n(a)}function w(a,b){return a==b}function x(a,b){return a!=b}function y(a,b){return a===b}function z(a,b){return a!==b}function A(a,b){if(X(b)&&Array.prototype.indexOf||r(b))return b.indexOf(a)>-1;if(X(b))for(var c=0,d=b.length;d>c;c++)if(w(a,b[c]))return!0;return!1}function B(a,b){return!A(a,b)}function C(a,b){return b>a}function D(a,b){return b>=a}function E(a,b){return a>b}function F(a,b){return a>=b}function G(a,b){return r(b)?null!==(""+a).match(b):p(b)?b.test(a):!1}function H(a,b){return!G(a,b)}function I(a,b){return A(b,a)}function J(a,b){return!A(b,a)}function K(a,b,c){return X(a)&&a.length>c?w(a[c],b):!1}function L(a,b,c){return X(a)?!w(a[c],b):!1}function M(a,b){return T.call(a,b)}function N(a,b){return!M(a,b)}function O(a,b){return M(a,"length")?a.length===b:!1}function P(a,b){return M(a,"length")?a.length!==b:!1}function Q(a){Z[a]=function(){this._testers.push(Y[a])}}function R(a){$[a]=function(){var c,d=b(arguments,1),e=Y[a],f=!0;if(d.length<=e.length-1)throw new TypeError("A handler must be defined when calling using switch");if(c=d.pop(),j(c)&&(f=c,c=d.pop()),!V(c))throw new TypeError("handler must be defined");this._cases.push(function(a){return e.apply(Y,a.concat(d))?[f,c.apply(this,a)]:[!1]})}}var S=Array.prototype.slice,T=Object.prototype.hasOwnProperty,U=Object.prototype.toString,V=function(a){return"[object Function]"===U.call(a)};"undefined"==typeof window||V(window.alert)||!function(a){V=function(b){return"[object Function]"===U.call(b)||b===a}}(window.alert);var W=function(a){return"[object Arguments]"===U.call(a)};W(arguments)||(W=function(a){return!(!a||!T.call(a,"callee"))});var X=Array.isArray||function(a){return"[object Array]"===U.call(a)},Y={isFunction:V,isObject:g,isEmpty:i,isHash:h,isNumber:s,isString:r,isDate:q,isArray:X,isBoolean:j,isUndefined:k,isDefined:l,isUndefinedOrNull:m,isNull:n,isArguments:W,instanceOf:o,isRegExp:p,deepEqual:e,isTrue:t,isFalse:u,isNotNull:v,isEq:w,isNeq:x,isSeq:y,isSneq:z,isIn:A,isNotIn:B,isLt:C,isLte:D,isGt:E,isGte:F,isLike:G,isNotLike:H,contains:I,notContains:J,has:M,notHas:N,isLength:O,isNotLength:P,containsAt:K,notContainsAt:L},Z={constructor:function(){this._testers=[]},noWrap:{tester:function(){var a=this._testers;return function(b){for(var c=!1,d=0,e=a.length;e>d&&!c;d++)c=a[d](b);return c}}}},$={constructor:function(){this._cases=[],this.__default=null},def:function(a,b){this.__default=b},noWrap:{switcher:function(){var a=this._cases,c=this.__default;return function(){for(var d,e=!1,f=b(arguments),g=0,h=a.length;h>g&&!e;g++)if(d=a[g](f),d.length>1&&(d[1]||d[0]))return d[1];return!e&&c?c.apply(this,f):void 0}}}};for(var _ in Y)T.call(Y,_)&&(R(_),Q(_));var ab=a.define(Y).expose(Y);return ab.tester=a.define(Z),ab.switcher=a.define($),ab}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("extended"))):"function"==typeof define&&define.amd?define(["extended"],function(a){return e(a)}):this.isExtended=e(this.extended)}).call(this)},{__browserify_Buffer:63,extended:56}],67:[function(a,b,c){(function(){"use strict";function d(a){function b(a,b){var c=0;return a>b?1:b>a?-1:b?c:1}var c=a.multiply,d=a.declare({instance:{__printNode:function(b,d){var e=[];a.isUndefinedOrNull(b)?(e.push(c(" ",d)),e.push("~"),console.log(e.join(""))):(this.__printNode(b.right,d+1),e.push(c(" ",d)),e.push(b.data+"\n"),console.log(e.join("")),this.__printNode(b.left,d+1))},constructor:function(a){a=a||{},this.compare=a.compare||b,this.__root=null},insert:function(){throw new Error("Not Implemented")},remove:function(){throw new Error("Not Implemented")},clear:function(){this.__root=null},isEmpty:function(){return!this.__root},traverseWithCondition:function(a,b,c){var e=!0;return a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.IN_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.POST_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e&&(e=this.traverseWithCondition(a.right,b,c)),e&&(e=c(a.data)))):b===d.REVERSE_ORDER&&(e=this.traverseWithCondition(a.right,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c))))),e},traverse:function(a,b,c){a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(c(a.data),this.traverse(a.left,b,c),this.traverse(a.right,b,c)):b===d.IN_ORDER?(this.traverse(a.left,b,c),c(a.data),this.traverse(a.right,b,c)):b===d.POST_ORDER?(this.traverse(a.left,b,c),this.traverse(a.right,b,c),c(a.data)):b===d.REVERSE_ORDER&&(this.traverse(a.right,b,c),c(a.data),this.traverse(a.left,b,c)))},forEach:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this,this.traverse(this.__root,c,function(c){a.call(b,c,this)})},map:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){e.insert(a.call(b,c,this))}),e},filter:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){a.call(b,c,this)&&e.insert(c)}),e},reduce:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduce.apply(a,f)},reduceRight:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduceRight.apply(a,f)},every:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=!1;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this)}),e},some:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this),!e}),e},toArray:function(a){a=a||d.IN_ORDER;var b=[];return this.traverse(this.__root,a,function(a){b.push(a)}),b},contains:function(a){for(var b=!1,c=this.__root;null!==c;){var d=this.compare(a,c.data);d?c=c[-1===d?"left":"right"]:(b=!0,c=null)}return b},find:function(a){for(var b,c=this.__root;c;){var d=this.compare(a,c.data);if(!d){b=c.data;break}c=c[-1===d?"left":"right"]}return b},findLessThan:function(a,b){var c=[],e=this.compare;return this.traverseWithCondition(this.__root,d.IN_ORDER,function(d){var f=e(a,d);return!b&&0===f||1===f?(c.push(d),!0):!1}),c},findGreaterThan:function(a,b){var c=[],e=this.compare;return this.traverse(this.__root,d.REVERSE_ORDER,function(d){var f=e(a,d);return!b&&0===f||-1===f?(c.push(d),!0):!1}),c},print:function(){this.__printNode(this.__root,0)}},"static":{PRE_ORDER:"pre_order",IN_ORDER:"in_order",POST_ORDER:"post_order",REVERSE_ORDER:"reverse_order"}}),e=function(){function a(a,b,c){var d=a.__root;if(null===d||void 0===d)a.__root=f(b);else{for(var g,h=d,i=[],k=[],l=0;;){if(g=i[l]=-1===c(b,h.data)?"left":"right",k[l++]=h,!h[g]){h[g]=f(b);break}h=h[g]}if(!h[g])return null;for(;--l>=0&&(k[l].balance+="right"===i[l]?-1:1,0!==k[l].balance);)if(e(k[l].balance)>1){k[l]=j(k[l],i[l]),0!==l?k[l-1][i[l-1]]=k[l]:a.__root=k[0];break}}}function b(a,b,c){var d=a.__root;if(null!==d&&void 0!==d){for(var f,g,h=d,i=0,j=[],l=[],m={done:!1};;){if(!h)return;if(0===(g=c(b,h.data)))break;f=l[i]=-1===g?"left":"right",j[i++]=h,h=h[f]}var n=h.left,o=h.right;if(n&&o){var p=n;for(l[i]="left",j[i++]=h;p.right;)l[i]="right",j[i++]=p,p=p.right;h.data=p.data,j[i-1][j[i-1]===h?"left":"right"]=p.left}else f=n?"left":"right",0!==i?j[i-1][l[i-1]]=h[f]:a.__root=h[f];for(;--i>=0&&!m.done&&(j[i].balance+="left"===l[i]?-1:1,1!==e(j[i].balance));)e(j[i].balance)>1&&(j[i]=k(j[i],l[i],m),0!==i?j[i-1][l[i-1]]=j[i]:a.__root=j[0])}}var e=Math.abs,f=function(a){return{data:a,balance:0,left:null,right:null}},g=function(a,b,c){var d=a[c];return a[c]=d[b],d[b]=a,d},h=function(a,b,c){return a[c]=g(a[c],c,b),g(a,b,c)},i=function(a,b,c){var d="left"===b?"right":"left",e=a[b],f=e[d];0===f.balance?a.balance=e.balance=0:f.balance===c?(a.balance=-c,e.balance=0):(a.balance=0,e.balance=c),f.balance=0},j=function(a,b){var c="left"===b?"right":"left",d=a[b],e="right"===b?-1:1;return d.balance===e?(a.balance=d.balance=0,a=g(a,c,b)):(i(a,b,e),a=h(a,c,b)),a},k=function(a,b,c){var d="left"===b?"right":"left",e=a[d],f="right"===b?-1:1;return e.balance===-f?(a.balance=e.balance=0,a=g(a,b,d)):e.balance===f?(i(a,d,-f),a=h(a,b,d)):(a.balance=-f,e.balance=f,a=g(a,b,d),c.done=!0),a};return d.extend({instance:{insert:function(b){a(this,b,this.compare)},remove:function(a){b(this,a,this.compare)},__printNode:function(a,b){var d=[];a?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.balance+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),f=function(){function a(a,b){return{data:a,level:b,left:g,right:g}}function b(a){if(0!==a.level&&a.left.level===a.level){var b=a.left;a.left=b.right,b.right=a,a=b}return a}function e(a){if(0!==a.level&&a.right.right.level===a.level){var b=a.right;a.right=b.left,b.left=a,a=b,a.level++}return a}function f(c,d,h){if(c===g)c=a(d,1);else{var i=-1===h(d,c.data)?"left":"right";c[i]=f(c[i],d,h),c=b(c),c=e(c)}return c}var g={level:0,data:null},h=function(a,c,d){var f,i;if(a!==g){var j=d(c,a.data);if(0===j)if(f=a.left,i=a.right,f!==g&&i!==g){for(var k=f;k.right!==g;)k=k.right;a.data=k.data,a.left=h(f,k.data,d)}else a=a[f===g?"right":"left"];else{var l=-1===j?"left":"right";a[l]=h(a[l],c,d)}}if(a!==g){var m=a.level,n=a.left.level,o=a.right.level;(m-1>n||m-1>o)&&(o>--a.level&&(a.right.level=a.level),a=b(a),a=e(a))}return a};return d.extend({instance:{isEmpty:function(){return this.__root===g||this._super(arguments)},insert:function(a){this.__root||(this.__root=g),this.__root=f(this.__root,a,this.compare)},remove:function(a){this.__root=h(this.__root,a,this.compare)},traverseWithCondition:function(a){var b=!0;return a!==g?this._super(arguments):b},traverse:function(a){a!==g&&this._super(arguments)},contains:function(){return this.__root!==g?this._super(arguments):!1},__printNode:function(a,b){var d=[];a&&a.data?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.level+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),g=d.extend({instance:{insert:function(a){if(!this.__root)return this.__root={data:a,parent:null,left:null,right:null},this.__root;for(var b=this.compare,c=this.__root;null!==c;){var d=b(a,c.data);if(!d)return;var e=-1===d?"left":"right",f=c[e];if(!f)return c[e]={data:a,parent:c,left:null,right:null};c=f}},remove:function(a){if(null!==this.__root){for(var b,c={right:this.__root},d=c,e=null,f="right";null!==d[f];){b=d,d=d[f];var g=this.compare(a,d.data);g||(e=d),f=-1===g?"left":"right"}null!==e&&(e.data=d.data,b[b.right===d?"right":"left"]=d[null===d.left?"right":"left"]),this.__root=c.right}}}}),h=function(){var a="RED",b="BLACK",e=function(a){return null!==a&&a.red},f=function(a){return{data:a,red:!0,left:null,right:null}},g=function(a,b,c){if(!a)return f(b);var d=c(b,a.data);if(d){var j=-1===d?"left":"right",k="left"===j?"right":"left";a[j]=g(a[j],b,c);var l=a[j];if(e(l)){var m=a[k];e(m)?(a.red=!0,l.red=!1,m.red=!1):e(l[j])?a=h(a,k):e(l[k])&&(a=i(a,k))}}return a},h=function(a,b){var c="left"===b?"right":"left",d=a[c];return a[c]=d[b],d[b]=a,a.red=!0,d.red=!1,d},i=function(a,b){var c="left"===b?"right":"left";return a[c]=h(a[c],c),h(a,b)},j=function(a,b,c,d){if(a){var f;if(0===d(b,a.data)){if(!a.left||!a.right){var g=a[a.left?"left":"right"];return e(a)?c.done=!0:e(g)&&(g.red=!1,c.done=!0),g}for(var h,i=a.right;null!==i.left;)h=i,i=i.left;h&&(h.left=null),a.data=i.data,b=i.data}f=-1===d(b,a.data)?"left":"right",a[f]=j(a[f],b,c,d),c.done||(a=k(a,f,c))}else c.done=!0;return a},k=function(a,b,c){var d="left"===b?"right":"left",f=a,g=f[d];if(e(g)&&(a=h(a,b),g=f[d]),null!==g)if(e(g.left)||e(g.right)){var j=f.red,k=a===f;f=(e(g[d])?h:i)(f,b),f.red=j,f.left.red=f.right.red=0,k?a=f:a[b]=f,c.done=!0}else e(f)&&(c.done=!0),f.red=0,g.red=1;return a};return d.extend({instance:{insert:function(a){this.__root=g(this.__root,a,this.compare),this.__root.red=!1},remove:function(a){var b={done:!1},c=j(this.__root,a,b,this.compare);return null!==c&&(c.red=0),this.__root=c,a},__printNode:function(d,e){var f=[];d?(this.__printNode(d.right,e+1),f.push(c(" ",e)),f.push((d.red?a:b)+":"+d.data+"\n"),console.log(f.join("")),this.__printNode(d.left,e+1)):(f.push(c(" ",e)),f.push("~"),console.log(f.join("")))}}})}();return{Tree:d,AVLTree:e,AnderssonTree:f,BinaryTree:g,RedBlackTree:h,IN_ORDER:d.IN_ORDER,PRE_ORDER:d.PRE_ORDER,POST_ORDER:d.POST_ORDER,REVERSE_ORDER:d.REVERSE_ORDER}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")).register(a("string-extended")))):"function"==typeof define?define(["extended","declare.js","is-extended","array-extended","string-extended"],function(a,b,c,e,f){return d(a().register("declare",b).register(c).register(e).register(f))}):this.leafy=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended).register(this.stringExtended))}).call(this)},{"array-extended":52,"declare.js":55,extended:56,"is-extended":66,"string-extended":70}],68:[function(a,b,c){(function(){"use strict";function d(a,b,c){function d(a,b){var c,d;for(c in b)t.call(b,c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}function e(a,b){var c,d,f;for(c in b)t.call(b,c)&&(d=b[c],f=a[c],p(f,d)||(a[c]=r(f)&&r(d)?e(f,d):r(d)?e({},d):d));return a}function f(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)d(a,arguments[b]);return a}function g(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)e(a,arguments[b]);return a}function h(a,b){var c=a.prototype||a;return f(c,b),a}function i(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e=l(a),f=0,g=e.length;g>f;++f)d=e[f],b.call(c||a,a[d],d,a);return a}function j(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e,f=l(a),g={},h=0,i=f.length;i>h;++h)d=f[h],e=a[d],b.call(c||a,e,d,a)&&(g[d]=e);return g}function k(a){if(!r(a))throw new TypeError;for(var b=l(a),c=[],d=0,e=b.length;e>d;++d)c.push(a[b[d]]);return c}function l(a){var b;if(v)b=v(a);else{if(!r(a))throw new TypeError;b=[];for(var c in a)t.call(a,c)&&b.push(c)}return b}function m(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d={},e=0,f=c.length;f>e;++e)b=c[e],d[a[b]]=b;return d}function n(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d=[],e=0,f=c.length;f>e;++e)b=c[e],d.push([b,a[b]]);return d}function o(a,b){if(!r(a))throw new TypeError;q(b)&&(b=[b]);for(var c,d=s(l(a),b),e={},f=0,g=d.length;g>f;++f)c=d[f],e[c]=a[c];return e}var p=b.deepEqual,q=b.isString,r=b.isHash,s=c.difference,t=Object.prototype.hasOwnProperty,u=b.isFunction,v=Object.keys,w={forEach:i,filter:j,invert:m,values:k,toArray:n,keys:l,omit:o},x={extend:h,merge:f,deepMerge:g,omit:o},y=a.define(b.isObject,x).define(r,w).define(b.isFunction,{extend:h}).expose({hash:w}).expose(x),z=y.extend;return y.extend=function(){return 1===arguments.length?z.extend.apply(y,arguments):(h.apply(null,arguments),void 0)},y}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c)}):this.objectExtended=d(this.extended,this.isExtended,this.arrayExtended)}).call(this)},{"array-extended":52,extended:56,"is-extended":66}],69:[function(a,b,c){var d=a("__browserify_process");(function(){"use strict";function e(a,b,c,e,f,g){function h(a,b){return function(){try{l(a.apply(null,arguments)).addCallback(b).addErrback(b)}catch(c){b.errback(c)}}}function i(a,b,c){var d=(new G).callback();return v(a,function(a){d=d.then(c?a:B(null,a)),c||(d=d.then(function(a){return b.push(a),b}))}),d}function j(a){return!w(a)&&y(a.then)}function k(a){var b=new G;return a.then(A(b,"callback"),A(b,"errback")),b.promise()}function l(a){var b;return a=C(arguments),a.length?1===a.length?(a=a.pop(),j(a)?a.addCallback&&a.addErrback?(b=new G,a.addCallback(b.callback),a.addErrback(b.errback)):b=k(a):b=x(a)&&c.every(a,j)?new H(a,!0).promise():(new G).callback(a)):b=new H(c.map(a,function(a){return l(a)}),!0).promise():b=(new G).callback(a).promise(),b}function m(a,b){return function(){var c=new G,d=C(arguments);return d.push(c.resolve),a.apply(b||this,d),c.promise()}}function n(a){if(x(a))return i(a,[],!1);throw new Error("When calling promise.serial the first argument must be an array")}function o(a){if(x(a))return i(a,[],!0);throw new Error("When calling promise.serial the first argument must be an array")}function p(a,b){a=C(arguments);var c=!1;b=a.pop();var d=l(a);return function(){return c?l(b.apply(this,arguments)):(a=arguments,d.then(A(this,function(){return c=!0,b.apply(this,a)})))}}function q(){return new G}function r(a){return new H(a,!0).promise()}function s(a){return q().errback(a)}function t(a){return q().callback(a)}var u,v=c.forEach,w=e.isUndefinedOrNull,x=e.isArray,y=e.isFunction,z=e.isBoolean,A=f.bind,B=f.bindIgnore,C=g.argsToArray;if("function"==typeof setImmediate)u="undefined"!=typeof window?setImmediate.bind(window):setImmediate;else if("undefined"!=typeof d)u=function(a){d.nextTick(a)};else if("undefined"!=typeof MessageChannel){var D=new MessageChannel,E={},F=E;D.port1.onmessage=function(){E=E.next;var a=E.task;delete E.task,a()},u=function(a){F=F.next={task:a},D.port2.postMessage(0)}}else u=function(a){setTimeout(a,0)};var G=a({instance:{__fired:!1,__results:null,__error:null,__errorCbs:null,__cbs:null,constructor:function(){this.__errorCbs=[],this.__cbs=[],f.bindAll(this,["callback","errback","resolve","classic","__resolve","addCallback","addErrback"])},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__error?this.__errorCbs:this.__cbs,c=b.length,d=this.__error||this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(this,b)})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=a.callback),this.__fired&&this.__results?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=a.errback),this.__fired&&this.__error?this.__callNextTick(a,this.__error):this.__errorCbs.push(a)),this},callback:function(){return this.__fired||(this.__results=arguments,this.__resolve()),this.promise()},errback:function(){return this.__fired||(this.__error=arguments,this.__resolve()),this.promise()},resolve:function(a){return a?this.errback(a):this.callback.apply(this,C(arguments,1)),this},classic:function(a){return"function"==typeof a&&(this.addErrback(function(b){a(b)}),this.addCallback(function(){a.apply(this,[null].concat(C(arguments)))})),this},then:function(a,b){var c=new G,d=c;return y(b)&&(d=h(b,c)),this.addErrback(d),y(a)?this.addCallback(h(a,c)):this.addCallback(c),c.promise()},both:function(a){return this.then(a,a)},promise:function(){var a={then:A(this,"then"),both:A(this,"both"),promise:function(){return a}};return v(["addCallback","addErrback","classic"],function(b){a[b]=A(this,function(){return this[b].apply(this,arguments),a})},this),a}}}),H=G.extend({instance:{__results:null,__errors:null,__promiseLength:0,__defLength:0,__firedLength:0,normalizeResults:!1,constructor:function(a,b){this.__errors=[],this.__results=[],this.normalizeResults=z(b)?b:!1,this._super(arguments),a&&a.length?(this.__defLength=a.length,v(a,this.__addPromise,this)):this.__resolve()},__addPromise:function(a,b){a.then(A(this,function(){var a=C(arguments);a.unshift(b),this.callback.apply(this,a)}),A(this,function(){var a=C(arguments);a.unshift(b),this.errback.apply(this,a)}))},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__errors.length?this.__errorCbs:this.__cbs,c=b.length,d=this.__errors.length?this.__errors:this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(null,[b])})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=A(a,"callback")),this.__fired&&!this.__errors.length?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=A(a,"errback")),this.__fired&&this.__errors.length?this.__callNextTick(a,this.__errors):this.__errorCbs.push(a)),this},callback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__results[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()},errback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__errors[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()}}});return b.define({isPromiseLike:j}).expose({isPromiseLike:j,when:l,wrap:m,wait:p,serial:n,chain:o,Promise:G,PromiseList:H,promise:q,defer:q,deferredList:r,reject:s,resolve:t})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("declare.js"),a("extended"),a("array-extended"),a("is-extended"),a("function-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["declare","extended","array-extended","is-extended","function-extended","arguments-extended"],function(a,b,c,d,f,g){return e(a,b,c,d,f,g)}):this.promiseExtended=e(this.declare,this.extended,this.arrayExtended,this.isExtended,this.functionExtended,this.argumentsExtended)}).call(this)},{__browserify_process:64,"arguments-extended":51,"array-extended":52,"declare.js":55,extended:56,"function-extended":59,"is-extended":66}],70:[function(a,b,c){(function(){"use strict";function d(a,b,c,d){function e(a,b){var c=a;if(x.test(b)){var d=b.match(x),e=d[1],f=d[3],g=d[4];g&&(g=parseInt(g,10),c=c.length0?"+":"")+d),k&&(k=parseInt(k,10),d=d.lengthe;)d?a+=c:a=c+a,e++;return a}function i(a,c,d){var e=a;if(b.isString(e)){if(a.length>c)if(d){var f=a.length;e=a.substring(f-c,f)}else e=a.substring(0,c)}else e=i(""+e,c);return e}function j(a,d){if(d instanceof Array){var h=0,i=d.length;return a.replace(v,function(a,b,j){var k,l;if(!(i>h))return a;if(k=d[h++],"%s"===a||"%d"===a||"%D"===a)l=k+"";else if("%Z"===a)l=k.toUTCString();else if("%j"===a)try{l=s(k)}catch(m){throw new Error("stringExtended.format : Unable to parse json from ",k)}else switch(b=b.replace(/^\[|\]$/g,""),j){case"s":l=e(k,b);break;case"d":l=f(k,b);break;case"j":l=g(k,b);break;case"D":l=c.format(k,b);break;case"Z":l=c.format(k,b,!0)}return l})}if(t(d))return a.replace(w,function(a,h,i){if(i=d[i],!b.isUndefined(i)){if(!h)return""+i;if(b.isString(i))return e(i,h);if(b.isNumber(i))return f(i,h);if(b.isDate(i))return c.format(i,h);if(b.isObject(i))return g(i,h)}return a});var k=u.call(arguments).slice(1);return j(a,k)}function k(a,b){var c=[];return a&&(a.indexOf(b)>0?c=a.replace(/\s+/g,"").split(b):c.push(a)),c}function l(a,b){var c=[];if(b)for(var d=0;b>d;d++)c.push(a);return c.join("")}function m(a,c){var d,e,f;if(c)if(b.isArray(a))for(d=[],e=0,f=a.length;f>e;e++)d.push(m(a[e],c));else if(c instanceof Array)for(d=a,e=0,f=c.length;f>e;e++)d=m(d,c[e]);else c in z&&(d="["+z[c]+"m"+a+"");return d}function n(a,b){return a.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,function(a){return b&&-1!==d.indexOf(b,a)?a:"\\"+a})}function o(a){return a.replace(/^\s*|\s*$/g,"")}function p(a){return a.replace(/^\s*/,"")}function q(a){return a.replace(/\s*$/,"")}function r(a){return 0===a.length}var s;"undefined"==typeof JSON?!function(){function a(a){return 10>a?"0"+a:a}function c(c){return b.isDate(c)?isFinite(c.valueOf())?c.getUTCFullYear()+"-"+a(c.getUTCMonth()+1)+"-"+a(c.getUTCDate())+"T"+a(c.getUTCHours())+":"+a(c.getUTCMinutes())+":"+a(c.getUTCSeconds())+"Z":null:i(c)?c.valueOf():c}function d(a){return j.lastIndex=0,j.test(a)?'"'+a.replace(j,function(a){var b=k[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function e(a,b){var i,j,k,l,m,n=f,o=b[a];switch(o&&(o=c(o)),"function"==typeof h&&(o=h.call(b,a,o)),typeof o){case"string":return d(o);case"number":return isFinite(o)?String(o):"null";case"boolean":case"null":return String(o);case"object":if(!o)return"null";if(f+=g,m=[],"[object Array]"===Object.prototype.toString.apply(o)){for(l=o.length,i=0;l>i;i+=1)m[i]=e(i,o)||"null";return k=0===m.length?"[]":f?"[\n"+f+m.join(",\n"+f)+"\n"+n+"]":"["+m.join(",")+"]",f=n,k}if(h&&"object"==typeof h)for(l=h.length,i=0;l>i;i+=1)"string"==typeof h[i]&&(j=h[i],k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));else for(j in o)Object.prototype.hasOwnProperty.call(o,j)&&(k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));return k=0===m.length?"{}":f?"{\n"+f+m.join(",\n"+f)+"\n"+n+"}":"{"+m.join(",")+"}",f=n,k}}var f,g,h,i=b.tester().isString().isNumber().isBoolean().tester(),j=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,k={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};s=function(a,b,c){var d;if(f="",g="","number"==typeof c)for(d=0;c>d;d+=1)g+=" ";else"string"==typeof c&&(g=c);if(h=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return e("",{"":a})}}():s=JSON.stringify;var t=b.isHash,u=Array.prototype.slice,v=/%((?:-?\+?.?\d*)?|(?:\[[^\[|\]]*\]))?([sjdDZ])/g,w=/\{(?:\[([^\[|\]]*)\])?(\w+)\}/g,x=/(-?)(\+?)([A-Z|a-z|\W]?)([1-9][0-9]*)?$/,y=/([1-9][0-9]*)$/g,z={bold:1,bright:1,italic:3,underline:4,blink:5,inverse:7,crossedOut:9,red:31,green:32,yellow:33,blue:34,magenta:35,cyan:36,white:37,redBackground:41,greenBackground:42,yellowBackground:43,blueBackground:44,magentaBackground:45,cyanBackground:46,whiteBackground:47,encircled:52,overlined:53,grey:90,black:90},A={SMILEY:"☺",SOLID_SMILEY:"☻",HEART:"♥",DIAMOND:"♦",CLOVE:"♣",SPADE:"♠",DOT:"•",SQUARE_CIRCLE:"◘",CIRCLE:"○",FILLED_SQUARE_CIRCLE:"◙",MALE:"♂",FEMALE:"♀",EIGHT_NOTE:"♪",DOUBLE_EIGHTH_NOTE:"♫",SUN:"☼",PLAY:"►",REWIND:"◄",UP_DOWN:"↕",PILCROW:"¶",SECTION:"§",THICK_MINUS:"▬",SMALL_UP_DOWN:"↨",UP_ARROW:"↑",DOWN_ARROW:"↓",RIGHT_ARROW:"→",LEFT_ARROW:"←",RIGHT_ANGLE:"∟",LEFT_RIGHT_ARROW:"↔",TRIANGLE:"▲",DOWN_TRIANGLE:"▼",HOUSE:"⌂",C_CEDILLA:"Ç",U_UMLAUT:"ü",E_ACCENT:"é",A_LOWER_CIRCUMFLEX:"â",A_LOWER_UMLAUT:"ä",A_LOWER_GRAVE_ACCENT:"à",A_LOWER_CIRCLE_OVER:"å",C_LOWER_CIRCUMFLEX:"ç",E_LOWER_CIRCUMFLEX:"ê",E_LOWER_UMLAUT:"ë",E_LOWER_GRAVE_ACCENT:"è",I_LOWER_UMLAUT:"ï",I_LOWER_CIRCUMFLEX:"î",I_LOWER_GRAVE_ACCENT:"ì",A_UPPER_UMLAUT:"Ä",A_UPPER_CIRCLE:"Å",E_UPPER_ACCENT:"É",A_E_LOWER:"æ",A_E_UPPER:"Æ",O_LOWER_CIRCUMFLEX:"ô",O_LOWER_UMLAUT:"ö",O_LOWER_GRAVE_ACCENT:"ò",U_LOWER_CIRCUMFLEX:"û",U_LOWER_GRAVE_ACCENT:"ù",Y_LOWER_UMLAUT:"ÿ",O_UPPER_UMLAUT:"Ö",U_UPPER_UMLAUT:"Ü",CENTS:"¢",POUND:"£",YEN:"¥",CURRENCY:"¤",PTS:"₧",FUNCTION:"ƒ",A_LOWER_ACCENT:"á",I_LOWER_ACCENT:"í",O_LOWER_ACCENT:"ó",U_LOWER_ACCENT:"ú",N_LOWER_TILDE:"ñ",N_UPPER_TILDE:"Ñ",A_SUPER:"ª",O_SUPER:"º",UPSIDEDOWN_QUESTION:"¿",SIDEWAYS_L:"⌐",NEGATION:"¬",ONE_HALF:"½",ONE_FOURTH:"¼",UPSIDEDOWN_EXCLAMATION:"¡",DOUBLE_LEFT:"«",DOUBLE_RIGHT:"»",LIGHT_SHADED_BOX:"░",MEDIUM_SHADED_BOX:"▒",DARK_SHADED_BOX:"▓",VERTICAL_LINE:"│",MAZE__SINGLE_RIGHT_T:"┤",MAZE_SINGLE_RIGHT_TOP:"┐",MAZE_SINGLE_RIGHT_BOTTOM_SMALL:"┘",MAZE_SINGLE_LEFT_TOP_SMALL:"┌",MAZE_SINGLE_LEFT_BOTTOM_SMALL:"└",MAZE_SINGLE_LEFT_T:"├",MAZE_SINGLE_BOTTOM_T:"┴",MAZE_SINGLE_TOP_T:"┬",MAZE_SINGLE_CENTER:"┼",MAZE_SINGLE_HORIZONTAL_LINE:"─",MAZE_SINGLE_RIGHT_DOUBLECENTER_T:"╡",MAZE_SINGLE_RIGHT_DOUBLE_BL:"╛",MAZE_SINGLE_RIGHT_DOUBLE_T:"╢",MAZE_SINGLE_RIGHT_DOUBLEBOTTOM_TOP:"╖",MAZE_SINGLE_RIGHT_DOUBLELEFT_TOP:"╕",MAZE_SINGLE_LEFT_DOUBLE_T:"╞",MAZE_SINGLE_BOTTOM_DOUBLE_T:"╧",MAZE_SINGLE_TOP_DOUBLE_T:"╤",MAZE_SINGLE_TOP_DOUBLECENTER_T:"╥",MAZE_SINGLE_BOTTOM_DOUBLECENTER_T:"╨",MAZE_SINGLE_LEFT_DOUBLERIGHT_BOTTOM:"╘",MAZE_SINGLE_LEFT_DOUBLERIGHT_TOP:"╒",MAZE_SINGLE_LEFT_DOUBLEBOTTOM_TOP:"╓",MAZE_SINGLE_LEFT_DOUBLETOP_BOTTOM:"╙",MAZE_SINGLE_LEFT_TOP:"Γ",MAZE_SINGLE_RIGHT_BOTTOM:"╜",MAZE_SINGLE_LEFT_CENTER:"╟",MAZE_SINGLE_DOUBLECENTER_CENTER:"╫",MAZE_SINGLE_DOUBLECROSS_CENTER:"╪",MAZE_DOUBLE_LEFT_CENTER:"╣",MAZE_DOUBLE_VERTICAL:"║",MAZE_DOUBLE_RIGHT_TOP:"╗",MAZE_DOUBLE_RIGHT_BOTTOM:"╝",MAZE_DOUBLE_LEFT_BOTTOM:"╚",MAZE_DOUBLE_LEFT_TOP:"╔",MAZE_DOUBLE_BOTTOM_T:"╩",MAZE_DOUBLE_TOP_T:"╦",MAZE_DOUBLE_LEFT_T:"╠",MAZE_DOUBLE_HORIZONTAL:"═",MAZE_DOUBLE_CROSS:"╬",SOLID_RECTANGLE:"█",THICK_LEFT_VERTICAL:"▌",THICK_RIGHT_VERTICAL:"▐",SOLID_SMALL_RECTANGLE_BOTTOM:"▄",SOLID_SMALL_RECTANGLE_TOP:"▀",PHI_UPPER:"Φ",INFINITY:"∞",INTERSECTION:"∩",DEFINITION:"≡",PLUS_MINUS:"±",GT_EQ:"≥",LT_EQ:"≤",THEREFORE:"⌠",SINCE:"∵",DOESNOT_EXIST:"∄",EXISTS:"∃",FOR_ALL:"∀",EXCLUSIVE_OR:"⊕",BECAUSE:"⌡",DIVIDE:"÷",APPROX:"≈",DEGREE:"°",BOLD_DOT:"∙",DOT_SMALL:"·",CHECK:"√",ITALIC_X:"✗",SUPER_N:"ⁿ",SQUARED:"²",CUBED:"³",SOLID_BOX:"■",PERMILE:"‰",REGISTERED_TM:"®",COPYRIGHT:"©",TRADEMARK:"™",BETA:"β",GAMMA:"γ",ZETA:"ζ",ETA:"η",IOTA:"ι",KAPPA:"κ",LAMBDA:"λ",NU:"ν",XI:"ξ",OMICRON:"ο",RHO:"ρ",UPSILON:"υ",CHI_LOWER:"φ",CHI_UPPER:"χ",PSI:"ψ",ALPHA:"α",ESZETT:"ß",PI:"π",SIGMA_UPPER:"Σ",SIGMA_LOWER:"σ",MU:"µ",TAU:"τ",THETA:"Θ",OMEGA:"Ω",DELTA:"δ",PHI_LOWER:"φ",EPSILON:"ε"},B={toArray:k,pad:h,truncate:i,multiply:l,format:j,style:m,escape:n,trim:o,trimLeft:p,trimRight:q,isEmpty:r}; +return a.define(b.isString,B).define(b.isArray,{style:m}).expose(B).expose({characters:A})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("date-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","date-extended","array-extended"],function(a,b,c,e){return d(a,b,c,e)}):this.stringExtended=d(this.extended,this.isExtended,this.dateExtended,this.arrayExtended)}).call(this)},{"array-extended":52,"date-extended":53,extended:56,"is-extended":66}]},{},[1]); \ No newline at end of file diff --git a/examples/browser/rules/diagnosis.nools b/examples/browser/rules/diagnosis.nools index 1ddc22c..9bd7054 100644 --- a/examples/browser/rules/diagnosis.nools +++ b/examples/browser/rules/diagnosis.nools @@ -22,6 +22,18 @@ define Treatment { } +rule Cold { + when { + p : Patient p.fever in ['mild', 'high'] {name : n}; + not(d : Diagnosis d.name == n && d.diagnosis == 'flu'); + } + then { + var d = new Diagnosis({name : n, diagnosis : "cold"}); + emit("diagnosis", d); + assert(d); + } +} + rule Measels { when { p : Patient p.fever == 'high' && p.spots == true && p.innoculated == true {name : n}; @@ -68,18 +80,6 @@ rule Flu { } } -rule Cold { - when { - p : Patient p.fever in ['mild', 'high'] {name : n}; - not(d : Diagnosis d.name == n && d.diagnosis == 'flu'); - } - then { - var d = new Diagnosis({name : n, diagnosis : "cold"}); - emit("diagnosis", d); - assert(d); - } -} - rule Healthy { when { p: Patient {name : n}; diff --git a/examples/browser/src/conway_3d.js b/examples/browser/src/conway_3d.js index fb9e8a3..a828e96 100644 --- a/examples/browser/src/conway_3d.js +++ b/examples/browser/src/conway_3d.js @@ -21,7 +21,7 @@ container.css({width: innerWidth + "px", height: innerHeight + "px"}); var camera = this.camera = new THREE.PerspectiveCamera(100, innerWidth / innerHeight, 1, 10000); - camera.position.set(0.01,(dimension || this.defaultDimensions) * 25, 0.01); + camera.position.set(0.01, (dimension || this.defaultDimensions) * 25, 0.01); var controls = this.controls = new THREE.OrbitControls(camera, container[0]); @@ -77,7 +77,6 @@ __disposeAndReset: function () { this.session.dispose(); if (!this.stopped) { - console.profileEnd(); this.reset(); this.__matchPromise = null; return this.run(); @@ -89,7 +88,6 @@ var session; if (this.stopped && !this.__matchPromise) { this.stopped = false; - console.profile(); this.__matchPromise = this.statsListener.listen(this.session = this.flow .getSession(this.cells)) .focus("populate") diff --git a/examples/browser/waltzDb.html b/examples/browser/waltzDb.html index 7b95b11..4e14157 100644 --- a/examples/browser/waltzDb.html +++ b/examples/browser/waltzDb.html @@ -71,7 +71,6 @@

    WaltzDB Benchmark

    function run() { stop(); - console.profile(); var data = loadData(flow, dataset); session = statsListener.listen(flow.getSession()); for (var i = 0, l = data.length; i < l; i++) { @@ -84,7 +83,6 @@

    WaltzDB Benchmark

    resultsContainer.scrollTop(resultsContainer.prop("scrollHeight")); }) .match().then(function () { - console.profileEnd(); console.log("done"); }, function (e) { console.log(e.stack); diff --git a/examples/counter/index.js b/examples/counter/index.js index 7715a42..7efad58 100644 --- a/examples/counter/index.js +++ b/examples/counter/index.js @@ -5,6 +5,6 @@ var flow = nools.compile(require.resolve("./counter.nools")); flow.getSession().matchUntilHalt().then(function () { //halt finally invoked console.log("done"); -}, function () { +}, function (err) { console.log(err); }); diff --git a/examples/sudoku/index.js b/examples/sudoku/index.js index 1524f48..1e8fa67 100644 --- a/examples/sudoku/index.js +++ b/examples/sudoku/index.js @@ -92,7 +92,7 @@ var hard4 = [ var sud = new sudoku.Sudoku(flow); var repl = require("repl"); -sud.setCellValues(hard4).then(function () { +sud.setCellValues(hard3).then(function () { var sudokuRepl = repl.start("sudoku>>"); sudokuRepl.context.print = sud.dumpGrid.bind(sud); sudokuRepl.context.step = function () { diff --git a/history.md b/history.md index 8b9af4e..a884058 100644 --- a/history.md +++ b/history.md @@ -1,3 +1,12 @@ +#0.2.3 + +* Added new `getFacts` method to allow for querying of facts currently in session. [#52](https://github.com/C2FO/nools/issues/52); +* Added indexing on comparison operators (i.e. `>, <, >=, <=`). +* Updated documentation. + * Added new section about retrieving facts from a session. + * Created new section for async actions to address [#94](https://github.com/C2FO/nools/issues/94) + + #0.2.2 * Performance Upgrades diff --git a/lib/agenda.js b/lib/agenda.js index 1158181..99fd57e 100644 --- a/lib/agenda.js +++ b/lib/agenda.js @@ -3,6 +3,7 @@ var extd = require("./extended"), declare = extd.declare, AVLTree = extd.AVLTree, LinkedList = extd.LinkedList, + isPromise = extd.isPromiseLike, EventEmitter = require("events").EventEmitter; @@ -110,7 +111,7 @@ module.exports = declare(EventEmitter, { var activation = this.pop(); this.emit("fire", activation.rule.name, activation.match.factHash); var fired = activation.rule.fire(this.flow, activation.match); - if (extd.isPromiseLike(fired)) { + if (isPromise(fired)) { ret = fired.then(function () { //return true if an activation fired return true; diff --git a/lib/compile/common.js b/lib/compile/common.js index af5ec25..2f7a527 100644 --- a/lib/compile/common.js +++ b/lib/compile/common.js @@ -4,7 +4,7 @@ var extd = require("../extended"), forEach = extd.forEach, isString = extd.isString; -exports.modifiers = ["assert", "modify", "retract", "emit", "halt", "focus"]; +exports.modifiers = ["assert", "modify", "retract", "emit", "halt", "focus", "getFacts"]; var createFunction = function (body, defined, scope, scopeNames, definedNames) { var declares = []; diff --git a/lib/compile/index.js b/lib/compile/index.js index d0e4c39..4dea5c2 100644 --- a/lib/compile/index.js +++ b/lib/compile/index.js @@ -12,6 +12,7 @@ var extd = require("../extended"), merge = extd.merge, rules = require("../rule"), common = require("./common"), + modifiers = common.modifiers, createDefined = common.createDefined, createFunction = common.createFunction; @@ -43,7 +44,7 @@ var parseAction = function (action, identifiers, defined, scope) { declares.push("var " + i + "= scope." + i + ";"); } }); - extd(["halt", "assert", "retract", "modify", "focus", "emit"]).forEach(function (i) { + extd(modifiers).forEach(function (i) { if (action.indexOf(i) !== -1) { declares.push("if(!" + i + "){ var " + i + "= flow." + i + ";}"); } diff --git a/lib/compile/transpile.js b/lib/compile/transpile.js index fa5b550..4b8761b 100644 --- a/lib/compile/transpile.js +++ b/lib/compile/transpile.js @@ -3,6 +3,7 @@ var extd = require("../extended"), indexOf = extd.indexOf, merge = extd.merge, isString = extd.isString, + modifiers = require("./common").modifiers, constraintMatcher = require("../constraintMatcher"), parser = require("../parser"); @@ -30,30 +31,38 @@ function definedToJs(options) { } function actionToJs(action, identifiers, defined, scope) { - var declares = []; + var declares = [], usedVars = {}; forEach(identifiers, function (i) { if (action.indexOf(i) !== -1) { + usedVars[i] = true; declares.push("var " + i + "= facts." + i + ";"); } }); extd(defined).keys().forEach(function (i) { - if (action.indexOf(i) !== -1) { + if (action.indexOf(i) !== -1 && !usedVars[i]) { + usedVars[i] = true; declares.push("var " + i + "= defined." + i + ";"); } }); extd(scope).keys().forEach(function (i) { - if (action.indexOf(i) !== -1) { + if (action.indexOf(i) !== -1 && !usedVars[i]) { + usedVars[i] = true; declares.push("var " + i + "= scope." + i + ";"); } }); + extd(modifiers).forEach(function (i) { + if (action.indexOf(i) !== -1 && !usedVars[i]) { + declares.push("var " + i + "= flow." + i + ";"); + } + }); var params = ["facts", 'flow']; if (/next\(.*\)/.test(action)) { params.push("next"); } action = declares.join("") + action; try { - return ["function(", params.join(","), "){with(flow){", action, "}}"].join(""); + return ["function(", params.join(","), "){", action, "}"].join(""); } catch (e) { throw new Error("Invalid action : " + action + "\n" + e.message); } @@ -127,7 +136,8 @@ exports.transpile = function (flowObj, options) { ret.push("(function(){"); ret.push("return function(options){"); ret.push("options = options || {};"); - ret.push("var bind = function(scope, fn){return function(){return fn.apply(scope, arguments);};}, defined = options.defined || {}, scope = options.scope || {};"); + ret.push("var bind = function(scope, fn){return function(){return fn.apply(scope, arguments);};}, defined = {Array: Array, String: String, Number: Number, Boolean: Boolean, RegExp: RegExp, Date: Date, Object: Object}, scope = options.scope || {};"); + ret.push("var optDefined = options.defined || {}; for(var i in optDefined){defined[i] = optDefined[i];}"); var defined = merge({Array: Array, String: String, Number: Number, Boolean: Boolean, RegExp: RegExp, Date: Date, Object: Object}, options.define || {}); if (typeof Buffer !== "undefined") { defined.Buffer = Buffer; diff --git a/lib/constraint.js b/lib/constraint.js index b3aab84..3bf3452 100644 --- a/lib/constraint.js +++ b/lib/constraint.js @@ -178,7 +178,11 @@ ReferenceConstraint.extend({instance: { return constraintMatcher.getIndexableProperties(this.constraint); } }}).as(exports, "ReferenceEqualityConstraint") - .extend({instance: {type: "reference_inequality", op: "neq"}}).as(exports, "ReferenceInequalityConstraint"); + .extend({instance: {type: "reference_inequality", op: "neq"}}).as(exports, "ReferenceInequalityConstraint") + .extend({instance: {type: "reference_gt", op: "gt"}}).as(exports, "ReferenceGTConstraint") + .extend({instance: {type: "reference_gte", op: "gte"}}).as(exports, "ReferenceGTEConstraint") + .extend({instance: {type: "reference_lt", op: "lt"}}).as(exports, "ReferenceLTConstraint") + .extend({instance: {type: "reference_lte", op: "lte"}}).as(exports, "ReferenceLTEConstraint"); Constraint.extend({ diff --git a/lib/constraintMatcher.js b/lib/constraintMatcher.js index 3155abf..c981f88 100644 --- a/lib/constraintMatcher.js +++ b/lib/constraintMatcher.js @@ -136,7 +136,7 @@ var lang = { getIndexableProperties: function (rule) { if (rule[2] === "composite") { return this.getIndexableProperties(rule[0]); - } else if (/^(\w+(\['[^']*'])*) *[!=]== (\w+(\['[^']*'])*)$/.test(this.parse(rule))) { + } else if (/^(\w+(\['[^']*'])*) *([!=]==|[<>]=?) (\w+(\['[^']*'])*)$/.test(this.parse(rule))) { return getProps(this.__getProperties(rule)).flatten().value(); } else { return []; @@ -217,11 +217,26 @@ var lang = { var isReference = some(this.getIdentifiers(rule), function (i) { return i !== alias && !(i in definedFuncs) && !(i in scope); }); - if (rule2 === "eq") { + switch (rule2) { + case "eq": ret.push(new atoms[isReference ? "ReferenceEqualityConstraint" : "EqualityConstraint"](rule, options)); - } else if (rule2 === "neq") { + break; + case "neq": ret.push(new atoms[isReference ? "ReferenceInequalityConstraint" : "InequalityConstraint"](rule, options)); - } else { + break; + case "gt": + ret.push(new atoms[isReference ? "ReferenceGTConstraint" : "ComparisonConstraint"](rule, options)); + break; + case "gte": + ret.push(new atoms[isReference ? "ReferenceGTEConstraint" : "ComparisonConstraint"](rule, options)); + break; + case "lt": + ret.push(new atoms[isReference ? "ReferenceLTConstraint" : "ComparisonConstraint"](rule, options)); + break; + case "lte": + ret.push(new atoms[isReference ? "ReferenceLTEConstraint" : "ComparisonConstraint"](rule, options)); + break; + default: ret.push(new atoms[isReference ? "ReferenceConstraint" : "ComparisonConstraint"](rule, options)); } @@ -440,4 +455,4 @@ exports.getIdentifiers = function (constraint) { exports.getIndexableProperties = function (constraint) { return lang.getIndexableProperties(constraint); -}; +}; \ No newline at end of file diff --git a/lib/context.js b/lib/context.js index ec06216..cc876aa 100644 --- a/lib/context.js +++ b/lib/context.js @@ -2,54 +2,77 @@ var extd = require("./extended"), isBoolean = extd.isBoolean, declare = extd.declare, - merge = extd.merge, - union = extd.union, - pSlice = Array.prototype.slice; + indexOf = extd.indexOf, + pPush = Array.prototype.push; function createContextHash(paths, hashCode) { - var ret = [], + var ret = "", i = -1, l = paths.length; while (++i < l) { - ret.push(paths[i].id); + ret += paths[i].id + ":"; + } + ret += hashCode; + return ret; +} + +function merge(h1, h2, aliases) { + var i = -1, l = aliases.length, alias; + while (++i < l) { + alias = aliases[i]; + h1[alias] = h2[alias]; + } +} + +function unionRecency(arr, arr1, arr2) { + pPush.apply(arr, arr1); + var i = -1, l = arr2.length, val, j = arr.length; + while (++i < l) { + val = arr2[i]; + if (indexOf(arr, val) === -1) { + arr[j++] = val; + } } - ret.push(hashCode); - return ret.join(":"); } var Match = declare({ instance: { - constructor: function (assertable) { - this.isMatch = true; - if (assertable instanceof this._static) { - this.isMatch = assertable.isMatch; - this.facts = pSlice.call(assertable.facts); - this.factIds = pSlice.call(assertable.factIds); - this.hashCode = this.factIds.join(":"); - this.factHash = merge({}, assertable.factHash); - this.recency = pSlice.call(assertable.recency); - } else if (assertable) { - this.facts = [assertable]; - this.factIds = [assertable.id]; - this.recency = [assertable.recency]; - this.hashCode = assertable.id + ""; - this.factHash = assertable.factHash || {}; - } else { - this.facts = []; - this.factIds = []; - this.factHash = {}; - this.hashCode = ""; - } + + isMatch: true, + hashCode: "", + facts: null, + factIds: null, + factHash: null, + recency: null, + aliases: null, + + constructor: function () { + this.facts = []; + this.factIds = []; + this.factHash = {}; + this.recency = []; + this.aliases = []; + }, + + addFact: function (assertable) { + pPush.call(this.facts, assertable); + pPush.call(this.recency, assertable.recency); + pPush.call(this.factIds, assertable.id); + this.hashCode = this.factIds.join(":"); + return this; }, merge: function (mr) { - var ret = new this._static(); + var ret = new Match(); ret.isMatch = mr.isMatch; - ret.facts = this.facts.concat(mr.facts); - ret.factIds = this.factIds.concat(mr.factIds); - ret.hashCode = ret.factIds.join(":"); - ret.factHash = merge({}, this.factHash, mr.factHash); - ret.recency = union(this.recency, mr.recency); + pPush.apply(ret.facts, this.facts); + pPush.apply(ret.facts, mr.facts); + pPush.apply(ret.aliases, this.aliases); + pPush.apply(ret.aliases, mr.aliases); + ret.hashCode = this.hashCode + ":" + mr.hashCode; + merge(ret.factHash, this.factHash, this.aliases); + merge(ret.factHash, mr.factHash, mr.aliases); + unionRecency(ret.recency, this.recency, mr.recency); return ret; } } @@ -59,22 +82,33 @@ var Context = declare({ instance: { match: null, factHash: null, + aliases: null, fact: null, hashCode: null, paths: null, + pathsHash: null, constructor: function (fact, paths, mr) { this.fact = fact; - this.paths = paths || null; - var match = this.match = mr || new Match(fact); - this.factHash = match.factHash; - var hashCode = this.hashCode = match.hashCode; - this.pathsHash = paths ? createContextHash(paths || [], hashCode) : hashCode; - this.factIds = match.factIds; + if (mr) { + this.match = mr; + } else { + this.match = new Match().addFact(fact); + } + this.factHash = this.match.factHash; + this.aliases = this.match.aliases; + this.hashCode = this.match.hashCode; + if (paths) { + this.paths = paths; + this.pathsHash = createContextHash(paths, this.hashCode); + } else { + this.pathsHash = this.hashCode; + } }, "set": function (key, value) { this.factHash[key] = value; + this.aliases.push(key); return this; }, @@ -91,7 +125,7 @@ var Context = declare({ var match = this.match = this.match.merge(merge); this.factHash = match.factHash; this.hashCode = match.hashCode; - this.factIds = match.factIds; + this.aliases = match.aliases; return this; }, diff --git a/lib/executionStrategy.js b/lib/executionStrategy.js index 12c0f8b..914b165 100644 --- a/lib/executionStrategy.js +++ b/lib/executionStrategy.js @@ -48,7 +48,7 @@ Promise.extend({ __handleAsyncNext: function (next) { var self = this, agenda = self.agenda; - return next.addCallback(function () { + return next.then(function () { self.looping = false; if (!agenda.isEmpty()) { if (self.flowAltered) { @@ -64,7 +64,7 @@ Promise.extend({ self.callback(); } self = null; - }).addErrback(this.errback); + }, this.errback); }, __handleSyncNext: function (next) { @@ -92,7 +92,7 @@ Promise.extend({ callNext: function () { this.looping = true; var next = this.agenda.fireNext(); - return isPromiseLike(next) ? this.__handleAsyncNext(next): this.__handleSyncNext(next); + return isPromiseLike(next) ? this.__handleAsyncNext(next) : this.__handleSyncNext(next); }, execute: function () { diff --git a/lib/extended.js b/lib/extended.js index ad77279..3468567 100644 --- a/lib/extended.js +++ b/lib/extended.js @@ -52,6 +52,32 @@ function intersection(a, b) { return a; } +function inPlaceIntersection(a, b) { + var aOne, i = -1, l; + l = a.length; + while (++i < l) { + aOne = a[i]; + if (indexOf(b, aOne) === -1) { + pSplice.call(a, i--, 1); + l--; + } + } + return a; +} + +function inPlaceDifference(a, b) { + var aOne, i = -1, l; + l = a.length; + while (++i < l) { + aOne = a[i]; + if (indexOf(b, aOne) !== -1) { + pSplice.call(a, i--, 1); + l--; + } + } + return a; +} + function diffArr(arr1, arr2) { var ret = [], i = -1, j, l2 = arr2.length, l1 = arr1.length, a, found; if (l2 > l1) { @@ -86,6 +112,17 @@ function diffArr(arr1, arr2) { return ret; } +function diffHash(h1, h2) { + var ret = {}; + for (var i in h1) { + if (!hasOwnProperty.call(h2, i)) { + ret[i] = h1[i]; + } + } + return ret; +} + + function union(arr1, arr2) { return unique(arr1.concat(arr2)); } @@ -99,7 +136,10 @@ module.exports = require("extended")() .register(require("function-extended")) .register(require("is-extended")) .register("intersection", intersection) + .register("inPlaceIntersection", inPlaceIntersection) + .register("inPlaceDifference", inPlaceDifference) .register("diffArr", diffArr) + .register("diffHash", diffHash) .register("unionArr", union) .register("plucker", plucker) .register("HashTable", require("ht")) diff --git a/lib/flow.js b/lib/flow.js index 38a762d..9c1ed49 100644 --- a/lib/flow.js +++ b/lib/flow.js @@ -27,7 +27,17 @@ module.exports = declare(EventEmitter, { this.agenda.on("fire", bind(this, "emit", "fire")); this.agenda.on("focused", bind(this, "emit", "focused")); this.rootNode = new nodes.RootNode(this.workingMemory, this.agenda); - extd.bindAll(this, "halt", "assert", "retract", "modify", "focus", "emit"); + extd.bindAll(this, "halt", "assert", "retract", "modify", "focus", "emit", "getFacts"); + }, + + getFacts: function (Type) { + var ret; + if (Type) { + ret = this.workingMemory.getFactsByType(Type); + } else { + ret = this.workingMemory.getFacts(); + } + return ret; }, focus: function (focused) { diff --git a/lib/nodes/adapterNode.js b/lib/nodes/adapterNode.js index b49eb49..dbefbab 100644 --- a/lib/nodes/adapterNode.js +++ b/lib/nodes/adapterNode.js @@ -1,6 +1,5 @@ var Node = require("./node"), - intersection = require("../extended").intersection, - Context = require("../context"); + intersection = require("../extended").intersection; Node.extend({ instance: { @@ -12,7 +11,7 @@ Node.extend({ outNode = entry.key; paths = entry.value; if ((continuingPaths = intersection(paths, context.paths)).length) { - outNode[method](new Context(context.fact, continuingPaths, context.match)); + outNode[method](context.clone(null, continuingPaths, null)); } } }, diff --git a/lib/nodes/betaNode.js b/lib/nodes/betaNode.js index 2c7887b..81a1c8c 100644 --- a/lib/nodes/betaNode.js +++ b/lib/nodes/betaNode.js @@ -1,5 +1,4 @@ var extd = require("../extended"), - values = extd.hash.values, keys = extd.hash.keys, Node = require("./node"), LeftMemory = require("./misc/leftMemory"), RightMemory = require("./misc/rightMemory"); @@ -56,21 +55,23 @@ Node.extend({ retractLeft: function (context) { context = this.removeFromLeftMemory(context).data; - var rightMathces = values(context.rightMatches), + var rightMatches = context.rightMatches, + hashCodes = keys(rightMatches), i = -1, - l = rightMathces.length; + l = hashCodes.length; while (++i < l) { - this.__propagate("retract", rightMathces[i].clone()); + this.__propagate("retract", rightMatches[hashCodes[i]].clone()); } }, retractRight: function (context) { context = this.removeFromRightMemory(context).data; - var leftMatches = values(context.leftMatches), + var leftMatches = context.leftMatches, + hashCodes = keys(leftMatches), i = -1, - l = leftMatches.length; + l = hashCodes.length; while (++i < l) { - this.__propagate("retract", leftMatches[i].clone()); + this.__propagate("retract", leftMatches[hashCodes[i]].clone()); } }, @@ -93,12 +94,11 @@ Node.extend({ modifyLeft: function (context) { var previousContext = this.removeFromLeftMemory(context).data; this.__addToLeftMemory(context); - var rm = this.rightTuples.getRightMemory(context), l = rm.length; + var rm = this.rightTuples.getRightMemory(context), l = rm.length, i = -1, rightMatches; if (!l) { - this.propagateRetract(context); + this.propagateRetractModifyFromLeft(previousContext); } else { - var i = -1, - rightMatches = previousContext.rightMatches; + rightMatches = previousContext.rightMatches; while (++i < l) { this.propagateAssertModifyFromLeft(context, rightMatches, rm[i].data); } @@ -111,7 +111,7 @@ Node.extend({ this.__addToRightMemory(context); var lm = this.leftTuples.getLeftMemory(context); if (!lm.length) { - this.propagateRetract(context); + this.propagateRetractModifyFromRight(previousContext); } else { var leftMatches = previousContext.leftMatches, i = -1, l = lm.length; while (++i < l) { @@ -128,6 +128,26 @@ Node.extend({ this.__propagate("assert", this.__addToMemoryMatches(context, lc, lc.clone(null, null, lc.match.merge(context.match)))); }, + propagateRetractModifyFromLeft: function (context) { + var rightMatches = context.rightMatches, + hashCodes = keys(rightMatches), + l = hashCodes.length, + i = -1; + while (++i < l) { + this.__propagate("retract", rightMatches[hashCodes[i]].clone()); + } + }, + + propagateRetractModifyFromRight: function (context) { + var leftMatches = context.leftMatches, + hashCodes = keys(leftMatches), + l = hashCodes.length, + i = -1; + while (++i < l) { + this.__propagate("retract", leftMatches[hashCodes[i]].clone()); + } + }, + propagateAssertModifyFromLeft: function (context, rightMatches, rm) { var factId = rm.hashCode; if (factId in rightMatches) { @@ -171,8 +191,9 @@ Node.extend({ var rightMemory = this.rightMemory; var rightMatches = context.data.rightMatches; this.leftTuples.remove(context); - for (var i in rightMatches) { - delete rightMemory[i].data.leftMatches[hashCode]; + var hashCodes = keys(rightMatches), i = -1, l = hashCodes.length; + while (++i < l) { + delete rightMemory[hashCodes[i]].data.leftMatches[hashCode]; } delete this.leftMemory[hashCode]; } diff --git a/lib/nodes/existsFromNode.js b/lib/nodes/existsFromNode.js index 474011a..3a44898 100644 --- a/lib/nodes/existsFromNode.js +++ b/lib/nodes/existsFromNode.js @@ -66,7 +66,7 @@ FromNotNode.extend({ var ret = false; if (this.type(o)) { var createdFact = this.workingMemory.getFactHandle(o); - var context = new Context(createdFact, null) + var context = new Context(createdFact, null, null) .mergeMatch(oc.match) .set(this.alias, o); if (add) { diff --git a/lib/nodes/fromNode.js b/lib/nodes/fromNode.js index 031c5cc..3b2135c 100644 --- a/lib/nodes/fromNode.js +++ b/lib/nodes/fromNode.js @@ -64,7 +64,7 @@ JoinNode.extend({ if (this.type(o)) { var createdFact = this.workingMemory.getFactHandle(o, true), createdContext, - rc = new Context(createdFact) + rc = new Context(createdFact, null, null) .set(this.alias, o), createdFactId = createdFact.id; var fh = rc.factHash, lcFh = lc.factHash; diff --git a/lib/nodes/joinReferenceNode.js b/lib/nodes/joinReferenceNode.js index e9a27fd..b8e144f 100644 --- a/lib/nodes/joinReferenceNode.js +++ b/lib/nodes/joinReferenceNode.js @@ -13,6 +13,29 @@ var DEFUALT_CONSTRAINT = { } }; +var inversions = { + "gt": "lte", + "gte": "lte", + "lt": "gte", + "lte": "gte", + "eq": "eq", + "neq": "neq" +}; + +function normalizeRightIndexConstraint(rightIndex, indexes, op) { + if (rightIndex === indexes[1]) { + op = inversions[op]; + } + return op; +} + +function normalizeLeftIndexConstraint(leftIndex, indexes, op) { + if (leftIndex === indexes[1]) { + op = inversions[op]; + } + return op; +} + Node.extend({ instance: { @@ -35,18 +58,22 @@ Node.extend({ var identifiers = constraint.getIndexableProperties(); var alias = constraint.get("alias"); if (identifiers.length === 2 && alias) { - var leftIndex, rightIndex, i = -1; + var leftIndex, rightIndex, i = -1, indexes = []; while (++i < 2) { var index = identifiers[i]; if (index.match(new RegExp("^" + alias + "(\\.?)")) === null) { + indexes.push(index); leftIndex = index; } else { + indexes.push(index); rightIndex = index; } } if (leftIndex && rightIndex) { - this.rightMemory.addIndex(rightIndex, leftIndex, constraint.op); - this.leftMemory.addIndex(leftIndex, rightIndex, constraint.op); + var leftOp = normalizeLeftIndexConstraint(leftIndex, indexes, constraint.op), + rightOp = normalizeRightIndexConstraint(rightIndex, indexes, constraint.op); + this.rightMemory.addIndex(rightIndex, leftIndex, rightOp); + this.leftMemory.addIndex(leftIndex, rightIndex, leftOp); } } } diff --git a/lib/nodes/misc/helpers.js b/lib/nodes/misc/helpers.js new file mode 100644 index 0000000..648c995 --- /dev/null +++ b/lib/nodes/misc/helpers.js @@ -0,0 +1,151 @@ +exports.getMemory = (function () { + + var pPush = Array.prototype.push, NPL = 0, EMPTY_ARRAY = [], NOT_POSSIBLES_HASH = {}, POSSIBLES_HASH = {}, PL = 0; + + function mergePossibleTuples(ret, a, l) { + var val, j = 0, i = -1; + if (PL < l) { + while (PL && ++i < l) { + if (POSSIBLES_HASH[(val = a[i]).hashCode]) { + ret[j++] = val; + PL--; + } + } + } else { + pPush.apply(ret, a); + } + PL = 0; + POSSIBLES_HASH = {}; + } + + + function mergeNotPossibleTuples(ret, a, l) { + var val, j = 0, i = -1; + if (NPL < l) { + while (++i < l) { + if (!NPL) { + ret[j++] = a[i]; + } else if (!NOT_POSSIBLES_HASH[(val = a[i]).hashCode]) { + ret[j++] = val; + } else { + NPL--; + } + } + } + NPL = 0; + NOT_POSSIBLES_HASH = {}; + } + + function mergeBothTuples(ret, a, l) { + if (PL === l) { + mergeNotPossibles(ret, a, l); + } else if (NPL < l) { + var val, j = 0, i = -1, hashCode; + while (++i < l) { + if (!NOT_POSSIBLES_HASH[(hashCode = (val = a[i]).hashCode)] && POSSIBLES_HASH[hashCode]) { + ret[j++] = val; + } + } + } + NPL = 0; + NOT_POSSIBLES_HASH = {}; + PL = 0; + POSSIBLES_HASH = {}; + } + + function mergePossiblesAndNotPossibles(a, l) { + var ret = EMPTY_ARRAY; + if (l) { + if (NPL || PL) { + ret = []; + if (!NPL) { + mergePossibleTuples(ret, a, l); + } else if (!PL) { + mergeNotPossibleTuples(ret, a, l); + } else { + mergeBothTuples(ret, a, l); + } + }else{ + ret = a; + } + } + return ret; + } + + function getRangeTuples(op, currEntry, val) { + var ret; + if (op === "gt") { + ret = currEntry.findGT(val); + } else if (op === "gte") { + ret = currEntry.findGTE(val); + } else if (op === "lt") { + ret = currEntry.findLT(val); + } else if (op === "lte") { + ret = currEntry.findLTE(val); + } + return ret; + } + + function mergeNotPossibles(tuples, tl) { + if (tl) { + var j = -1, hashCode; + while (++j < tl) { + hashCode = tuples[j].hashCode; + if (!NOT_POSSIBLES_HASH[hashCode]) { + NOT_POSSIBLES_HASH[hashCode] = true; + NPL++; + } + } + } + } + + function mergePossibles(tuples, tl) { + if (tl) { + var j = -1, hashCode; + while (++j < tl) { + hashCode = tuples[j].hashCode; + if (!POSSIBLES_HASH[hashCode]) { + POSSIBLES_HASH[hashCode] = true; + PL++; + } + } + } + } + + return function _getMemory(entry, factHash, indexes) { + var i = -1, l = indexes.length, + ret = entry.tuples, + rl = ret.length, + intersected = false, + tables = entry.tables, + index, val, op, nextEntry, currEntry, tuples, tl; + while (++i < l && rl) { + index = indexes[i]; + val = index[3](factHash); + op = index[4]; + currEntry = tables[index[0]]; + if (op === "eq") { + if ((nextEntry = currEntry.get(val))) { + rl = (ret = (entry = nextEntry).tuples).length; + tables = nextEntry.tables; + } else { + rl = (ret = EMPTY_ARRAY).length; + } + } else if (op === "neq") { + if ((nextEntry = currEntry.get(val))) { + tl = (tuples = nextEntry.tuples).length; + mergeNotPossibles(tuples, tl); + } + } else if (!intersected) { + rl = (ret = getRangeTuples(op, currEntry, val)).length; + intersected = true; + } else if ((tl = (tuples = getRangeTuples(op, currEntry, val)).length)) { + mergePossibles(tuples, tl); + } else { + ret = tuples; + rl = tl; + } + } + return mergePossiblesAndNotPossibles(ret, rl); + }; +}()); \ No newline at end of file diff --git a/lib/nodes/misc/memory.js b/lib/nodes/misc/memory.js index 6ec9045..30347e3 100644 --- a/lib/nodes/misc/memory.js +++ b/lib/nodes/misc/memory.js @@ -1,25 +1,26 @@ var extd = require("../../extended"), - indexOf = extd.indexOf, plucker = extd.plucker, - difference = extd.diffArr, - pPush = Array.prototype.push, declare = extd.declare, - HashTable = extd.HashTable; + getMemory = require("./helpers").getMemory, + Table = require("./table"), + TupleEntry = require("./tupleEntry"); + + +var id = 0; declare({ instance: { + length: 0, + constructor: function () { this.head = null; this.tail = null; - this.length = null; this.indexes = []; - this.tables = {tuples: [], tables: []}; + this.tables = new TupleEntry(null, new Table(), false); }, - inequalityThreshold: 0.5, - push: function (data) { - var tail = this.tail, head = this.head, node = {data: data, prev: tail, next: null}; + var tail = this.tail, head = this.head, node = {data: data, tuples: [], hashCode: id++, prev: tail, next: null}; if (tail) { this.tail.next = node; } @@ -29,7 +30,7 @@ declare({ } this.length++; this.__index(node); - this.tables.tuples.push(node); + this.tables.addNode(node); return node; }, @@ -44,10 +45,7 @@ declare({ } else { this.tail = node.prev; } - var index = indexOf(this.tables.tuples, node); - if (index !== -1) { - this.tables.tuples.splice(index, 1); - } + this.tables.removeNode(node); this.__removeFromIndex(node); this.length--; }, @@ -60,11 +58,7 @@ declare({ }, toArray: function () { - var head = {next: this.head}, ret = []; - while ((head = head.next)) { - ret.push(head); - } - return ret; + return this.tables.tuples.slice(); }, clear: function () { @@ -90,118 +84,42 @@ declare({ val = index[2](factHash); path = index[0]; tables = entry.tables; - currEntry = tables[path]; - if (!currEntry) { - currEntry = tables[path] = new HashTable(); - tuples = {tuples: [node], tables: {}}; - currEntry.put(val, tuples); - } else if (!(tuples = currEntry.get(val))) { - tuples = {tuples: [node], tables: {}}; - currEntry.put(val, tuples); - } else if (prevLookup !== path) { - tuples.tuples.push(node); + if (!(tuples = (currEntry = tables[path] || (tables[path] = new Table())).get(val))) { + tuples = new TupleEntry(val, currEntry, true); + currEntry.set(val, tuples); + } + if (currEntry !== prevLookup) { + node.tuples.push(tuples.addNode(node)); } - prevLookup = path; + prevLookup = currEntry; if (index[4] === "eq") { entry = tuples; } } }, - getSimilarMemory: function (tuple) { - return this.getMemory(tuple, true); - }, - __removeFromIndex: function (node) { - var data = node.data, - factHash = data.factHash, - indexes = this.indexes, - entry = this.tables, - i = -1, l = indexes.length; - while (++i < l) { - var index = indexes[i], - val = index[2](factHash); - var currEntry = entry.tables[index[0]]; - if (currEntry) { - var tuples = currEntry.get(val); - if (tuples) { - var currTuples = tuples.tuples, ind = indexOf(currTuples, node); - if (ind !== -1) { - currTuples.splice(ind, 1); - } - if (index[4] === "eq") { - entry = tuples; - } - } - } + var tuples = node.tuples, i = tuples.length; + while (--i >= 0) { + tuples[i].removeNode(node); } + node.tuples.length = 0; }, - getMemory: function (tuple, usePrimary) { - var factHash = tuple.factHash, - indexes = this.indexes, - entry = this.tables, - i = -1, l = indexes.length, - ret = entry.tuples, - lookup = usePrimary ? 2 : 3, - inequalityThreshold = this.inequalityThreshold, - notPossibles = [], npl = 0, rl; - - while (++i < l) { - var index = indexes[i], - val = index[lookup](factHash), - currEntry = entry.tables[index[0]]; - if (currEntry) { - var nextEntry = currEntry.get(val), tuples, tl; - if (index[4] === "neq") { - rl = ret.length; - if (!nextEntry) { - ret = rl ? ret : entry.tuples; - } else { - tuples = nextEntry.tuples; - tl = tuples.length; - if (!tl || !rl) { - ret = entry.tuples; - } else if (tl === entry.tuples.length) { - ret = []; - i = l; - } else if (tl) { - pPush.apply(notPossibles, tuples); - npl += tl; - } - } - } else if (nextEntry) { - tuples = nextEntry.tuples; - tl = tuples.length; - if (tl) { - ret = nextEntry.tuples; - entry = nextEntry; - } else { - i = l; - ret = []; - } - } else { - i = l; - ret = []; - } - } else { - ret = []; - i = l; - } - } - rl = ret.length; - if (npl && rl && (npl / rl) > inequalityThreshold) { - //console.log(npl); - ret = difference(ret, notPossibles); + getMemory: function (tuple) { + var ret; + if (!this.length) { + ret = []; + } else { + ret = getMemory(this.tables, tuple.factHash, this.indexes); } - return ret.slice(); + return ret; }, __createIndexTree: function () { var table = this.tables.tables = {}; var indexes = this.indexes; - table[indexes[0][0]] = new HashTable(); - + table[indexes[0][0]] = new Table(); }, @@ -209,11 +127,12 @@ declare({ this.indexes.push([primary, lookup, plucker(primary), plucker(lookup), op || "eq"]); this.indexes.sort(function (a, b) { var aOp = a[4], bOp = b[4]; - return aOp === bOp ? 0 : aOp > bOp ? 1 : -1; + return aOp === bOp ? 0 : aOp > bOp ? 1 : aOp === bOp ? 0 : -1; }); this.__createIndexTree(); + } } -}).as(module); +}).as(module); \ No newline at end of file diff --git a/lib/nodes/misc/table.js b/lib/nodes/misc/table.js new file mode 100644 index 0000000..bda090b --- /dev/null +++ b/lib/nodes/misc/table.js @@ -0,0 +1,174 @@ +var extd = require("../../extended"), + pPush = Array.prototype.push, + HashTable = extd.HashTable, + AVLTree = extd.AVLTree; + +function compare(a, b) { + a = a.key; + b = b.key; + var ret; + if (a === b) { + ret = 0; + } else if (a > b) { + ret = 1; + } else if (a < b) { + ret = -1; + } else { + ret = 1; + } + return ret; +} + +function compareGT(v1, v2) { + return compare(v1, v2) === 1; +} +function compareGTE(v1, v2) { + return compare(v1, v2) !== -1; +} + +function compareLT(v1, v2) { + return compare(v1, v2) === -1; +} +function compareLTE(v1, v2) { + return compare(v1, v2) !== 1; +} + +var STACK = [], + VALUE = {key: null}; +function traverseInOrder(tree, key, comparator) { + VALUE.key = key; + var ret = []; + var i = 0, current = tree.__root, v; + while (true) { + if (current) { + current = (STACK[i++] = current).left; + } else { + if (i > 0) { + v = (current = STACK[--i]).data; + if (comparator(v, VALUE)) { + pPush.apply(ret, v.value.tuples); + current = current.right; + } else { + break; + } + } else { + break; + } + } + } + STACK.length = 0; + return ret; +} + +function traverseReverseOrder(tree, key, comparator) { + VALUE.key = key; + var ret = []; + var i = 0, current = tree.__root, v; + while (true) { + if (current) { + current = (STACK[i++] = current).right; + } else { + if (i > 0) { + v = (current = STACK[--i]).data; + if (comparator(v, VALUE)) { + pPush.apply(ret, v.value.tuples); + current = current.left; + } else { + break; + } + } else { + break; + } + } + } + STACK.length = 0; + return ret; +} + +AVLTree.extend({ + instance: { + + constructor: function () { + this._super([ + { + compare: compare + } + ]); + this.gtCache = new HashTable(); + this.gteCache = new HashTable(); + this.ltCache = new HashTable(); + this.lteCache = new HashTable(); + this.hasGTCache = false; + this.hasGTECache = false; + this.hasLTCache = false; + this.hasLTECache = false; + }, + + clearCache: function () { + this.hasGTCache && this.gtCache.clear() && (this.hasGTCache = false); + this.hasGTECache && this.gteCache.clear() && (this.hasGTECache = false); + this.hasLTCache && this.ltCache.clear() && (this.hasLTCache = false); + this.hasLTECache && this.lteCache.clear() && (this.hasLTECache = false); + }, + + contains: function (key) { + return this._super([ + {key: key} + ]); + }, + + "set": function (key, value) { + this.insert({key: key, value: value}); + this.clearCache(); + }, + + "get": function (key) { + var ret = this.find({key: key}); + return ret && ret.value; + }, + + "remove": function (key) { + this.clearCache(); + return this._super([ + {key: key} + ]); + }, + + findGT: function (key) { + var ret = this.gtCache.get(key); + if (!ret) { + this.hasGTCache = true; + this.gtCache.put(key, (ret = traverseReverseOrder(this, key, compareGT))); + } + return ret; + }, + + findGTE: function (key) { + var ret = this.gteCache.get(key); + if (!ret) { + this.hasGTECache = true; + this.gteCache.put(key, (ret = traverseReverseOrder(this, key, compareGTE))); + } + return ret; + }, + + findLT: function (key) { + var ret = this.ltCache.get(key); + if (!ret) { + this.hasLTCache = true; + this.ltCache.put(key, (ret = traverseInOrder(this, key, compareLT))); + } + return ret; + }, + + findLTE: function (key) { + var ret = this.lteCache.get(key); + if (!ret) { + this.hasLTECache = true; + this.lteCache.put(key, (ret = traverseInOrder(this, key, compareLTE))); + } + return ret; + } + + } +}).as(module); \ No newline at end of file diff --git a/lib/nodes/misc/tupleEntry.js b/lib/nodes/misc/tupleEntry.js new file mode 100644 index 0000000..44ccf7c --- /dev/null +++ b/lib/nodes/misc/tupleEntry.js @@ -0,0 +1,46 @@ +var extd = require("../../extended"), + indexOf = extd.indexOf; +// HashSet = require("./hashSet"); + + +var TUPLE_ID = 0; +extd.declare({ + + instance: { + tuples: null, + tupleMap: null, + hashCode: null, + tables: null, + entry: null, + constructor: function (val, entry, canRemove) { + this.val = val; + this.canRemove = canRemove; + this.tuples = []; + this.tupleMap = {}; + this.hashCode = TUPLE_ID++; + this.tables = {}; + this.length = 0; + this.entry = entry; + }, + + addNode: function (node) { + this.tuples[this.length++] = node; + if (this.length > 1) { + this.entry.clearCache(); + } + return this; + }, + + removeNode: function (node) { + var tuples = this.tuples, index = indexOf(tuples, node); + if (index !== -1) { + tuples.splice(index, 1); + this.length--; + this.entry.clearCache(); + } + if (this.canRemove && !this.length) { + this.entry.remove(this.val); + } + } + } +}).as(module); \ No newline at end of file diff --git a/lib/nodes/notNode.js b/lib/nodes/notNode.js index a6e5ec5..e788862 100644 --- a/lib/nodes/notNode.js +++ b/lib/nodes/notNode.js @@ -27,11 +27,11 @@ JoinNode.extend({ blocking = rightContext.blocking; if (blocking.length) { //if we are blocking left contexts - var rm = this.rightTuples.getSimilarMemory(rightContext), l = rm.length, i; var leftContext, thisConstraint = this.constraint, blockingNode = {next: blocking.head}, rc; while ((blockingNode = blockingNode.next)) { leftContext = blockingNode.data; - //this.removeFromLeftBlockedMemory(leftContext); + this.removeFromLeftBlockedMemory(leftContext); + var rm = this.rightTuples.getRightMemory(leftContext), l = rm.length, i; i = -1; while (++i < l) { if (thisConstraint.isMatch(leftContext, rc = rm[i].data)) { @@ -108,7 +108,7 @@ JoinNode.extend({ assertRight: function (context) { this.__addToRightMemory(context); context.blocking = new LinkedList(); - var fl = this.leftTuples.getLeftMemory(context), + var fl = this.leftTuples.getLeftMemory(context).slice(), i = -1, l = fl.length, leftContext, thisConstraint = this.constraint; while (++i < l) { @@ -157,6 +157,7 @@ JoinNode.extend({ if (leftContext && leftContext.blocker) { //we were blocked before so only check nodes previous to our blocker blocker = this.rightMemory[leftContext.blocker.hashCode]; + leftContext.blocker = null; } if (blocker) { if (thisConstraint.isMatch(context, rc = blocker.data)) { @@ -209,7 +210,7 @@ JoinNode.extend({ var ctx = this.removeFromRightMemory(context); if (ctx) { var rightContext = ctx.data, - leftTuples = this.leftTuples.getLeftMemory(context), + leftTuples = this.leftTuples.getLeftMemory(context).slice(), leftTuplesLength = leftTuples.length, leftContext, thisConstraint = this.constraint, @@ -246,22 +247,19 @@ JoinNode.extend({ this.__propagate("assert", this.__cloneContext(leftContext)); } } - - if (leftTuplesLength) { - //check currently left tuples in memory - i = -1; - while (++i < leftTuplesLength) { - leftContext = leftTuples[i].data; - if (thisConstraint.isMatch(leftContext, context)) { - this.__propagate("retract", this.__cloneContext(leftContext)); - this.removeFromLeftMemory(leftContext); - this.addToLeftBlockedMemory(context.blocking.push(leftContext)); - leftContext.blocker = context; - } + } + if (leftTuplesLength) { + //check currently left tuples in memory + i = -1; + while (++i < leftTuplesLength) { + leftContext = leftTuples[i].data; + if (thisConstraint.isMatch(leftContext, context)) { + this.__propagate("retract", this.__cloneContext(leftContext)); + this.removeFromLeftMemory(leftContext); + this.addToLeftBlockedMemory(context.blocking.push(leftContext)); + leftContext.blocker = context; } } - - } } else { throw new Error(); diff --git a/lib/workingMemory.js b/lib/workingMemory.js index c3c9287..0e7df66 100644 --- a/lib/workingMemory.js +++ b/lib/workingMemory.js @@ -1,6 +1,7 @@ "use strict"; var declare = require("declare.js"), LinkedList = require("./linkedList"), + InitialFact = require("./pattern").InitialFact, id = 0; var Fact = declare({ @@ -36,6 +37,27 @@ declare({ this.facts.clear(); }, + getFacts: function () { + var head = {next: this.facts.head}, ret = [], i = 0, val; + while ((head = head.next)) { + if (!((val = head.data.object) instanceof InitialFact)) { + ret[i++] = val; + } + } + return ret; + }, + + getFactsByType: function (Type) { + var head = {next: this.facts.head}, ret = [], i = 0; + while ((head = head.next)) { + var val = head.data.object; + if (!(val instanceof InitialFact) && (val instanceof Type || val.constructor === Type)) { + ret[i++] = val; + } + } + return ret; + }, + getFactHandle: function (o) { var head = {next: this.facts.head}, ret; while ((head = head.next)) { @@ -70,20 +92,6 @@ declare({ ret.recency = this.recency++; this.facts.push(ret); return ret; -// var head = {next: this.facts.head}, ret; -// while ((head = head.next)) { -// var existingFact = head.data; -// if (existingFact.equals(fact)) { -// ret = existingFact; -// break; -// } -// } -// if (!ret) { -// ret = new Fact(fact); -// ret.recency = this.recency++; -// this.facts.push(ret); -// } -// return ret; }, retractFact: function (fact) { diff --git a/nools.js b/nools.js index 24444d4..3620596 100644 --- a/nools.js +++ b/nools.js @@ -31,6 +31,7 @@ var extd = require("./extended"), declare = extd.declare, AVLTree = extd.AVLTree, LinkedList = extd.LinkedList, + isPromise = extd.isPromiseLike, EventEmitter = require("events").EventEmitter; @@ -138,7 +139,7 @@ module.exports = declare(EventEmitter, { var activation = this.pop(); this.emit("fire", activation.rule.name, activation.match.factHash); var fired = activation.rule.fire(this.flow, activation.match); - if (extd.isPromiseLike(fired)) { + if (isPromise(fired)) { ret = fired.then(function () { //return true if an activation fired return true; @@ -217,14 +218,14 @@ module.exports = declare(EventEmitter, { } }); -},{"./extended":12,"events":64}],4:[function(require,module,exports){ +},{"./extended":12,"events":60}],4:[function(require,module,exports){ /*jshint evil:true*/ "use strict"; var extd = require("../extended"), forEach = extd.forEach, isString = extd.isString; -exports.modifiers = ["assert", "modify", "retract", "emit", "halt", "focus"]; +exports.modifiers = ["assert", "modify", "retract", "emit", "halt", "focus", "getFacts"]; var createFunction = function (body, defined, scope, scopeNames, definedNames) { var declares = []; @@ -289,6 +290,7 @@ var extd = require("../extended"), merge = extd.merge, rules = require("../rule"), common = require("./common"), + modifiers = common.modifiers, createDefined = common.createDefined, createFunction = common.createFunction; @@ -320,7 +322,7 @@ var parseAction = function (action, identifiers, defined, scope) { declares.push("var " + i + "= scope." + i + ";"); } }); - extd(["halt", "assert", "retract", "modify", "focus", "emit"]).forEach(function (i) { + extd(modifiers).forEach(function (i) { if (action.indexOf(i) !== -1) { declares.push("if(!" + i + "){ var " + i + "= flow." + i + ";}"); } @@ -473,12 +475,13 @@ exports.transpile = require("./transpile").transpile; -},{"../constraintMatcher.js":9,"../extended":12,"../parser":41,"../rule":46,"./common":4,"./transpile":6,"__browserify_Buffer":67}],6:[function(require,module,exports){ +},{"../constraintMatcher.js":9,"../extended":12,"../parser":44,"../rule":49,"./common":4,"./transpile":6,"__browserify_Buffer":63}],6:[function(require,module,exports){ var Buffer=require("__browserify_Buffer").Buffer;var extd = require("../extended"), forEach = extd.forEach, indexOf = extd.indexOf, merge = extd.merge, isString = extd.isString, + modifiers = require("./common").modifiers, constraintMatcher = require("../constraintMatcher"), parser = require("../parser"); @@ -506,30 +509,38 @@ function definedToJs(options) { } function actionToJs(action, identifiers, defined, scope) { - var declares = []; + var declares = [], usedVars = {}; forEach(identifiers, function (i) { if (action.indexOf(i) !== -1) { + usedVars[i] = true; declares.push("var " + i + "= facts." + i + ";"); } }); extd(defined).keys().forEach(function (i) { - if (action.indexOf(i) !== -1) { + if (action.indexOf(i) !== -1 && !usedVars[i]) { + usedVars[i] = true; declares.push("var " + i + "= defined." + i + ";"); } }); extd(scope).keys().forEach(function (i) { - if (action.indexOf(i) !== -1) { + if (action.indexOf(i) !== -1 && !usedVars[i]) { + usedVars[i] = true; declares.push("var " + i + "= scope." + i + ";"); } }); + extd(modifiers).forEach(function (i) { + if (action.indexOf(i) !== -1 && !usedVars[i]) { + declares.push("var " + i + "= flow." + i + ";"); + } + }); var params = ["facts", 'flow']; if (/next\(.*\)/.test(action)) { params.push("next"); } action = declares.join("") + action; try { - return ["function(", params.join(","), "){with(flow){", action, "}}"].join(""); + return ["function(", params.join(","), "){", action, "}"].join(""); } catch (e) { throw new Error("Invalid action : " + action + "\n" + e.message); } @@ -603,7 +614,8 @@ exports.transpile = function (flowObj, options) { ret.push("(function(){"); ret.push("return function(options){"); ret.push("options = options || {};"); - ret.push("var bind = function(scope, fn){return function(){return fn.apply(scope, arguments);};}, defined = options.defined || {}, scope = options.scope || {};"); + ret.push("var bind = function(scope, fn){return function(){return fn.apply(scope, arguments);};}, defined = {Array: Array, String: String, Number: Number, Boolean: Boolean, RegExp: RegExp, Date: Date, Object: Object}, scope = options.scope || {};"); + ret.push("var optDefined = options.defined || {}; for(var i in optDefined){defined[i] = optDefined[i];}"); var defined = merge({Array: Array, String: String, Number: Number, Boolean: Boolean, RegExp: RegExp, Date: Date, Object: Object}, options.define || {}); if (typeof Buffer !== "undefined") { defined.Buffer = Buffer; @@ -646,7 +658,7 @@ exports.transpile = function (flowObj, options) { -},{"../constraintMatcher":9,"../extended":12,"../parser":41,"__browserify_Buffer":67}],7:[function(require,module,exports){ +},{"../constraintMatcher":9,"../extended":12,"../parser":44,"./common":4,"__browserify_Buffer":63}],7:[function(require,module,exports){ var map = require("./extended").map; function salience(a, b) { @@ -883,7 +895,11 @@ ReferenceConstraint.extend({instance: { return constraintMatcher.getIndexableProperties(this.constraint); } }}).as(exports, "ReferenceEqualityConstraint") - .extend({instance: {type: "reference_inequality", op: "neq"}}).as(exports, "ReferenceInequalityConstraint"); + .extend({instance: {type: "reference_inequality", op: "neq"}}).as(exports, "ReferenceInequalityConstraint") + .extend({instance: {type: "reference_gt", op: "gt"}}).as(exports, "ReferenceGTConstraint") + .extend({instance: {type: "reference_gte", op: "gte"}}).as(exports, "ReferenceGTEConstraint") + .extend({instance: {type: "reference_lt", op: "lt"}}).as(exports, "ReferenceLTConstraint") + .extend({instance: {type: "reference_lte", op: "lte"}}).as(exports, "ReferenceLTEConstraint"); Constraint.extend({ @@ -1079,7 +1095,7 @@ var lang = { getIndexableProperties: function (rule) { if (rule[2] === "composite") { return this.getIndexableProperties(rule[0]); - } else if (/^(\w+(\['[^']*'])*) *[!=]== (\w+(\['[^']*'])*)$/.test(this.parse(rule))) { + } else if (/^(\w+(\['[^']*'])*) *([!=]==|[<>]=?) (\w+(\['[^']*'])*)$/.test(this.parse(rule))) { return getProps(this.__getProperties(rule)).flatten().value(); } else { return []; @@ -1160,11 +1176,26 @@ var lang = { var isReference = some(this.getIdentifiers(rule), function (i) { return i !== alias && !(i in definedFuncs) && !(i in scope); }); - if (rule2 === "eq") { + switch (rule2) { + case "eq": ret.push(new atoms[isReference ? "ReferenceEqualityConstraint" : "EqualityConstraint"](rule, options)); - } else if (rule2 === "neq") { + break; + case "neq": ret.push(new atoms[isReference ? "ReferenceInequalityConstraint" : "InequalityConstraint"](rule, options)); - } else { + break; + case "gt": + ret.push(new atoms[isReference ? "ReferenceGTConstraint" : "ComparisonConstraint"](rule, options)); + break; + case "gte": + ret.push(new atoms[isReference ? "ReferenceGTEConstraint" : "ComparisonConstraint"](rule, options)); + break; + case "lt": + ret.push(new atoms[isReference ? "ReferenceLTConstraint" : "ComparisonConstraint"](rule, options)); + break; + case "lte": + ret.push(new atoms[isReference ? "ReferenceLTEConstraint" : "ComparisonConstraint"](rule, options)); + break; + default: ret.push(new atoms[isReference ? "ReferenceConstraint" : "ComparisonConstraint"](rule, options)); } @@ -1384,60 +1415,82 @@ exports.getIdentifiers = function (constraint) { exports.getIndexableProperties = function (constraint) { return lang.getIndexableProperties(constraint); }; - },{"./constraint":8,"./extended":12}],10:[function(require,module,exports){ "use strict"; var extd = require("./extended"), isBoolean = extd.isBoolean, declare = extd.declare, - merge = extd.merge, - union = extd.union, - pSlice = Array.prototype.slice; + indexOf = extd.indexOf, + pPush = Array.prototype.push; function createContextHash(paths, hashCode) { - var ret = [], + var ret = "", i = -1, l = paths.length; while (++i < l) { - ret.push(paths[i].id); + ret += paths[i].id + ":"; + } + ret += hashCode; + return ret; +} + +function merge(h1, h2, aliases) { + var i = -1, l = aliases.length, alias; + while (++i < l) { + alias = aliases[i]; + h1[alias] = h2[alias]; + } +} + +function unionRecency(arr, arr1, arr2) { + pPush.apply(arr, arr1); + var i = -1, l = arr2.length, val, j = arr.length; + while (++i < l) { + val = arr2[i]; + if (indexOf(arr, val) === -1) { + arr[j++] = val; + } } - ret.push(hashCode); - return ret.join(":"); } var Match = declare({ instance: { - constructor: function (assertable) { - this.isMatch = true; - if (assertable instanceof this._static) { - this.isMatch = assertable.isMatch; - this.facts = pSlice.call(assertable.facts); - this.factIds = pSlice.call(assertable.factIds); - this.hashCode = this.factIds.join(":"); - this.factHash = merge({}, assertable.factHash); - this.recency = pSlice.call(assertable.recency); - } else if (assertable) { - this.facts = [assertable]; - this.factIds = [assertable.id]; - this.recency = [assertable.recency]; - this.hashCode = assertable.id + ""; - this.factHash = assertable.factHash || {}; - } else { - this.facts = []; - this.factIds = []; - this.factHash = {}; - this.hashCode = ""; - } + + isMatch: true, + hashCode: "", + facts: null, + factIds: null, + factHash: null, + recency: null, + aliases: null, + + constructor: function () { + this.facts = []; + this.factIds = []; + this.factHash = {}; + this.recency = []; + this.aliases = []; + }, + + addFact: function (assertable) { + pPush.call(this.facts, assertable); + pPush.call(this.recency, assertable.recency); + pPush.call(this.factIds, assertable.id); + this.hashCode = this.factIds.join(":"); + return this; }, merge: function (mr) { - var ret = new this._static(); + var ret = new Match(); ret.isMatch = mr.isMatch; - ret.facts = this.facts.concat(mr.facts); - ret.factIds = this.factIds.concat(mr.factIds); - ret.hashCode = ret.factIds.join(":"); - ret.factHash = merge({}, this.factHash, mr.factHash); - ret.recency = union(this.recency, mr.recency); + pPush.apply(ret.facts, this.facts); + pPush.apply(ret.facts, mr.facts); + pPush.apply(ret.aliases, this.aliases); + pPush.apply(ret.aliases, mr.aliases); + ret.hashCode = this.hashCode + ":" + mr.hashCode; + merge(ret.factHash, this.factHash, this.aliases); + merge(ret.factHash, mr.factHash, mr.aliases); + unionRecency(ret.recency, this.recency, mr.recency); return ret; } } @@ -1447,22 +1500,33 @@ var Context = declare({ instance: { match: null, factHash: null, + aliases: null, fact: null, hashCode: null, paths: null, + pathsHash: null, constructor: function (fact, paths, mr) { this.fact = fact; - this.paths = paths || null; - var match = this.match = mr || new Match(fact); - this.factHash = match.factHash; - var hashCode = this.hashCode = match.hashCode; - this.pathsHash = paths ? createContextHash(paths || [], hashCode) : hashCode; - this.factIds = match.factIds; + if (mr) { + this.match = mr; + } else { + this.match = new Match().addFact(fact); + } + this.factHash = this.match.factHash; + this.aliases = this.match.aliases; + this.hashCode = this.match.hashCode; + if (paths) { + this.paths = paths; + this.pathsHash = createContextHash(paths, this.hashCode); + } else { + this.pathsHash = this.hashCode; + } }, "set": function (key, value) { this.factHash[key] = value; + this.aliases.push(key); return this; }, @@ -1479,7 +1543,7 @@ var Context = declare({ var match = this.match = this.match.merge(merge); this.factHash = match.factHash; this.hashCode = match.hashCode; - this.factIds = match.factIds; + this.aliases = match.aliases; return this; }, @@ -1542,7 +1606,7 @@ Promise.extend({ __handleAsyncNext: function (next) { var self = this, agenda = self.agenda; - return next.addCallback(function () { + return next.then(function () { self.looping = false; if (!agenda.isEmpty()) { if (self.flowAltered) { @@ -1558,7 +1622,7 @@ Promise.extend({ self.callback(); } self = null; - }).addErrback(this.errback); + }, this.errback); }, __handleSyncNext: function (next) { @@ -1586,7 +1650,7 @@ Promise.extend({ callNext: function () { this.looping = true; var next = this.agenda.fireNext(); - return isPromiseLike(next) ? this.__handleAsyncNext(next): this.__handleSyncNext(next); + return isPromiseLike(next) ? this.__handleAsyncNext(next) : this.__handleSyncNext(next); }, execute: function () { @@ -1651,6 +1715,32 @@ function intersection(a, b) { return a; } +function inPlaceIntersection(a, b) { + var aOne, i = -1, l; + l = a.length; + while (++i < l) { + aOne = a[i]; + if (indexOf(b, aOne) === -1) { + pSplice.call(a, i--, 1); + l--; + } + } + return a; +} + +function inPlaceDifference(a, b) { + var aOne, i = -1, l; + l = a.length; + while (++i < l) { + aOne = a[i]; + if (indexOf(b, aOne) !== -1) { + pSplice.call(a, i--, 1); + l--; + } + } + return a; +} + function diffArr(arr1, arr2) { var ret = [], i = -1, j, l2 = arr2.length, l1 = arr1.length, a, found; if (l2 > l1) { @@ -1685,6 +1775,17 @@ function diffArr(arr1, arr2) { return ret; } +function diffHash(h1, h2) { + var ret = {}; + for (var i in h1) { + if (!hasOwnProperty.call(h2, i)) { + ret[i] = h1[i]; + } + } + return ret; +} + + function union(arr1, arr2) { return unique(arr1.concat(arr2)); } @@ -1698,7 +1799,10 @@ module.exports = require("extended")() .register(require("function-extended")) .register(require("is-extended")) .register("intersection", intersection) + .register("inPlaceIntersection", inPlaceIntersection) + .register("inPlaceDifference", inPlaceDifference) .register("diffArr", diffArr) + .register("diffHash", diffHash) .register("unionArr", union) .register("plucker", plucker) .register("HashTable", require("ht")) @@ -1707,7 +1811,7 @@ module.exports = require("extended")() .register("LinkedList", require("./linkedList")); -},{"./linkedList":16,"array-extended":49,"date-extended":50,"declare.js":52,"extended":53,"function-extended":56,"ht":69,"is-extended":70,"leafy":71,"object-extended":72,"promise-extended":73,"string-extended":74}],13:[function(require,module,exports){ +},{"./linkedList":16,"array-extended":52,"date-extended":53,"declare.js":55,"extended":56,"function-extended":59,"ht":65,"is-extended":66,"leafy":67,"object-extended":68,"promise-extended":69,"string-extended":70}],13:[function(require,module,exports){ "use strict"; var extd = require("./extended"), bind = extd.bind, @@ -1737,7 +1841,17 @@ module.exports = declare(EventEmitter, { this.agenda.on("fire", bind(this, "emit", "fire")); this.agenda.on("focused", bind(this, "emit", "focused")); this.rootNode = new nodes.RootNode(this.workingMemory, this.agenda); - extd.bindAll(this, "halt", "assert", "retract", "modify", "focus", "emit"); + extd.bindAll(this, "halt", "assert", "retract", "modify", "focus", "emit", "getFacts"); + }, + + getFacts: function (Type) { + var ret; + if (Type) { + ret = this.workingMemory.getFactsByType(Type); + } else { + ret = this.workingMemory.getFacts(); + } + return ret; }, focus: function (focused) { @@ -1807,7 +1921,7 @@ module.exports = declare(EventEmitter, { } }); -},{"./agenda":3,"./executionStrategy":11,"./extended":12,"./nodes":27,"./workingMemory":47,"events":64}],14:[function(require,module,exports){ +},{"./agenda":3,"./executionStrategy":11,"./extended":12,"./nodes":27,"./workingMemory":50,"events":60}],14:[function(require,module,exports){ "use strict"; var extd = require("./extended"), instanceOf = extd.instanceOf, @@ -1916,7 +2030,7 @@ var FlowContainer = declare({ } }).as(module); -},{"./conflict":7,"./extended":12,"./flow":13,"./pattern":45,"./rule":46}],15:[function(require,module,exports){ +},{"./conflict":7,"./extended":12,"./flow":13,"./pattern":48,"./rule":49}],15:[function(require,module,exports){ /** * * @projectName nools @@ -1992,7 +2106,7 @@ exports.transpile = function (file, options) { }; exports.parse = parse; -},{"./compile":5,"./extended":12,"./flowContainer":14,"fs":65,"path":66}],16:[function(require,module,exports){ +},{"./compile":5,"./extended":12,"./flowContainer":14,"fs":61,"path":62}],16:[function(require,module,exports){ var declare = require("declare.js"); declare({ @@ -2074,7 +2188,7 @@ declare({ }).as(module); -},{"declare.js":52}],17:[function(require,module,exports){ +},{"declare.js":55}],17:[function(require,module,exports){ var process=require("__browserify_process");/*global setImmediate, window, MessageChannel*/ var extd = require("./extended"); var nextTick; @@ -2112,10 +2226,9 @@ if (typeof setImmediate === "function") { } module.exports = nextTick; -},{"./extended":12,"__browserify_process":68}],18:[function(require,module,exports){ +},{"./extended":12,"__browserify_process":64}],18:[function(require,module,exports){ var Node = require("./node"), - intersection = require("../extended").intersection, - Context = require("../context"); + intersection = require("../extended").intersection; Node.extend({ instance: { @@ -2127,7 +2240,7 @@ Node.extend({ outNode = entry.key; paths = entry.value; if ((continuingPaths = intersection(paths, context.paths)).length) { - outNode[method](new Context(context.fact, continuingPaths, context.match)); + outNode[method](context.clone(null, continuingPaths, null)); } } }, @@ -2148,7 +2261,7 @@ Node.extend({ } } }).as(module); -},{"../context":10,"../extended":12,"./node":34}],19:[function(require,module,exports){ +},{"../extended":12,"./node":37}],19:[function(require,module,exports){ var AlphaNode = require("./alphaNode"); AlphaNode.extend({ @@ -2201,9 +2314,8 @@ Node.extend({ } } }).as(module); -},{"./node":34}],21:[function(require,module,exports){ +},{"./node":37}],21:[function(require,module,exports){ var extd = require("../extended"), - values = extd.hash.values, keys = extd.hash.keys, Node = require("./node"), LeftMemory = require("./misc/leftMemory"), RightMemory = require("./misc/rightMemory"); @@ -2260,21 +2372,23 @@ Node.extend({ retractLeft: function (context) { context = this.removeFromLeftMemory(context).data; - var rightMathces = values(context.rightMatches), + var rightMatches = context.rightMatches, + hashCodes = keys(rightMatches), i = -1, - l = rightMathces.length; + l = hashCodes.length; while (++i < l) { - this.__propagate("retract", rightMathces[i].clone()); + this.__propagate("retract", rightMatches[hashCodes[i]].clone()); } }, retractRight: function (context) { context = this.removeFromRightMemory(context).data; - var leftMatches = values(context.leftMatches), + var leftMatches = context.leftMatches, + hashCodes = keys(leftMatches), i = -1, - l = leftMatches.length; + l = hashCodes.length; while (++i < l) { - this.__propagate("retract", leftMatches[i].clone()); + this.__propagate("retract", leftMatches[hashCodes[i]].clone()); } }, @@ -2297,12 +2411,11 @@ Node.extend({ modifyLeft: function (context) { var previousContext = this.removeFromLeftMemory(context).data; this.__addToLeftMemory(context); - var rm = this.rightTuples.getRightMemory(context), l = rm.length; + var rm = this.rightTuples.getRightMemory(context), l = rm.length, i = -1, rightMatches; if (!l) { - this.propagateRetract(context); + this.propagateRetractModifyFromLeft(previousContext); } else { - var i = -1, - rightMatches = previousContext.rightMatches; + rightMatches = previousContext.rightMatches; while (++i < l) { this.propagateAssertModifyFromLeft(context, rightMatches, rm[i].data); } @@ -2315,7 +2428,7 @@ Node.extend({ this.__addToRightMemory(context); var lm = this.leftTuples.getLeftMemory(context); if (!lm.length) { - this.propagateRetract(context); + this.propagateRetractModifyFromRight(previousContext); } else { var leftMatches = previousContext.leftMatches, i = -1, l = lm.length; while (++i < l) { @@ -2332,6 +2445,26 @@ Node.extend({ this.__propagate("assert", this.__addToMemoryMatches(context, lc, lc.clone(null, null, lc.match.merge(context.match)))); }, + propagateRetractModifyFromLeft: function (context) { + var rightMatches = context.rightMatches, + hashCodes = keys(rightMatches), + l = hashCodes.length, + i = -1; + while (++i < l) { + this.__propagate("retract", rightMatches[hashCodes[i]].clone()); + } + }, + + propagateRetractModifyFromRight: function (context) { + var leftMatches = context.leftMatches, + hashCodes = keys(leftMatches), + l = hashCodes.length, + i = -1; + while (++i < l) { + this.__propagate("retract", leftMatches[hashCodes[i]].clone()); + } + }, + propagateAssertModifyFromLeft: function (context, rightMatches, rm) { var factId = rm.hashCode; if (factId in rightMatches) { @@ -2375,8 +2508,9 @@ Node.extend({ var rightMemory = this.rightMemory; var rightMatches = context.data.rightMatches; this.leftTuples.remove(context); - for (var i in rightMatches) { - delete rightMemory[i].data.leftMatches[hashCode]; + var hashCodes = keys(rightMatches), i = -1, l = hashCodes.length; + while (++i < l) { + delete rightMemory[hashCodes[i]].data.leftMatches[hashCode]; } delete this.leftMemory[hashCode]; } @@ -2436,7 +2570,7 @@ Node.extend({ } }).as(module); -},{"../extended":12,"./misc/leftMemory":31,"./misc/rightMemory":33,"./node":34}],22:[function(require,module,exports){ +},{"../extended":12,"./misc/leftMemory":32,"./misc/rightMemory":34,"./node":37}],22:[function(require,module,exports){ var AlphaNode = require("./alphaNode"); AlphaNode.extend({ @@ -2548,7 +2682,7 @@ FromNotNode.extend({ var ret = false; if (this.type(o)) { var createdFact = this.workingMemory.getFactHandle(o); - var context = new Context(createdFact, null) + var context = new Context(createdFact, null, null) .mergeMatch(oc.match) .set(this.alias, o); if (add) { @@ -2753,7 +2887,7 @@ NotNode.extend({ } } }).as(module); -},{"../linkedList":16,"./notNode":35}],25:[function(require,module,exports){ +},{"../linkedList":16,"./notNode":38}],25:[function(require,module,exports){ var JoinNode = require("./joinNode"), extd = require("../extended"), constraint = require("../constraint"), @@ -2820,7 +2954,7 @@ JoinNode.extend({ if (this.type(o)) { var createdFact = this.workingMemory.getFactHandle(o, true), createdContext, - rc = new Context(createdFact) + rc = new Context(createdFact, null, null) .set(this.alias, o), createdFactId = createdFact.id; var fh = rc.factHash, lcFh = lc.factHash; @@ -3388,7 +3522,7 @@ declare({ -},{"../constraint":8,"../extended":12,"../pattern.js":45,"./aliasNode":19,"./betaNode":21,"./equalityNode":22,"./existsFromNode":23,"./existsNode":24,"./fromNode":25,"./fromNotNode":26,"./joinNode":28,"./leftAdapterNode":30,"./notNode":35,"./propertyNode":36,"./rightAdapterNode":37,"./terminalNode":38,"./typeNode":39}],28:[function(require,module,exports){ +},{"../constraint":8,"../extended":12,"../pattern.js":48,"./aliasNode":19,"./betaNode":21,"./equalityNode":22,"./existsFromNode":23,"./existsNode":24,"./fromNode":25,"./fromNotNode":26,"./joinNode":28,"./leftAdapterNode":30,"./notNode":38,"./propertyNode":39,"./rightAdapterNode":40,"./terminalNode":41,"./typeNode":42}],28:[function(require,module,exports){ var BetaNode = require("./betaNode"), JoinReferenceNode = require("./joinReferenceNode"); @@ -3466,6 +3600,29 @@ var DEFUALT_CONSTRAINT = { } }; +var inversions = { + "gt": "lte", + "gte": "lte", + "lt": "gte", + "lte": "gte", + "eq": "eq", + "neq": "neq" +}; + +function normalizeRightIndexConstraint(rightIndex, indexes, op) { + if (rightIndex === indexes[1]) { + op = inversions[op]; + } + return op; +} + +function normalizeLeftIndexConstraint(leftIndex, indexes, op) { + if (leftIndex === indexes[1]) { + op = inversions[op]; + } + return op; +} + Node.extend({ instance: { @@ -3488,18 +3645,22 @@ Node.extend({ var identifiers = constraint.getIndexableProperties(); var alias = constraint.get("alias"); if (identifiers.length === 2 && alias) { - var leftIndex, rightIndex, i = -1; + var leftIndex, rightIndex, i = -1, indexes = []; while (++i < 2) { var index = identifiers[i]; if (index.match(new RegExp("^" + alias + "(\\.?)")) === null) { + indexes.push(index); leftIndex = index; } else { + indexes.push(index); rightIndex = index; } } if (leftIndex && rightIndex) { - this.rightMemory.addIndex(rightIndex, leftIndex, constraint.op); - this.leftMemory.addIndex(leftIndex, rightIndex, constraint.op); + var leftOp = normalizeLeftIndexConstraint(leftIndex, indexes, constraint.op), + rightOp = normalizeRightIndexConstraint(rightIndex, indexes, constraint.op); + this.rightMemory.addIndex(rightIndex, leftIndex, rightOp); + this.leftMemory.addIndex(leftIndex, rightIndex, leftOp); } } } @@ -3532,7 +3693,7 @@ Node.extend({ } }).as(module); -},{"../constraint":8,"./node":34}],30:[function(require,module,exports){ +},{"../constraint":8,"./node":37}],30:[function(require,module,exports){ var Node = require("./adapterNode"); Node.extend({ @@ -3568,6 +3729,158 @@ Node.extend({ }).as(module); },{"./adapterNode":18}],31:[function(require,module,exports){ +exports.getMemory = (function () { + + var pPush = Array.prototype.push, NPL = 0, EMPTY_ARRAY = [], NOT_POSSIBLES_HASH = {}, POSSIBLES_HASH = {}, PL = 0; + + function mergePossibleTuples(ret, a, l) { + var val, j = 0, i = -1; + if (PL < l) { + while (PL && ++i < l) { + if (POSSIBLES_HASH[(val = a[i]).hashCode]) { + ret[j++] = val; + PL--; + } + } + } else { + pPush.apply(ret, a); + } + PL = 0; + POSSIBLES_HASH = {}; + } + + + function mergeNotPossibleTuples(ret, a, l) { + var val, j = 0, i = -1; + if (NPL < l) { + while (++i < l) { + if (!NPL) { + ret[j++] = a[i]; + } else if (!NOT_POSSIBLES_HASH[(val = a[i]).hashCode]) { + ret[j++] = val; + } else { + NPL--; + } + } + } + NPL = 0; + NOT_POSSIBLES_HASH = {}; + } + + function mergeBothTuples(ret, a, l) { + if (PL === l) { + mergeNotPossibles(ret, a, l); + } else if (NPL < l) { + var val, j = 0, i = -1, hashCode; + while (++i < l) { + if (!NOT_POSSIBLES_HASH[(hashCode = (val = a[i]).hashCode)] && POSSIBLES_HASH[hashCode]) { + ret[j++] = val; + } + } + } + NPL = 0; + NOT_POSSIBLES_HASH = {}; + PL = 0; + POSSIBLES_HASH = {}; + } + + function mergePossiblesAndNotPossibles(a, l) { + var ret = EMPTY_ARRAY; + if (l) { + if (NPL || PL) { + ret = []; + if (!NPL) { + mergePossibleTuples(ret, a, l); + } else if (!PL) { + mergeNotPossibleTuples(ret, a, l); + } else { + mergeBothTuples(ret, a, l); + } + }else{ + ret = a; + } + } + return ret; + } + + function getRangeTuples(op, currEntry, val) { + var ret; + if (op === "gt") { + ret = currEntry.findGT(val); + } else if (op === "gte") { + ret = currEntry.findGTE(val); + } else if (op === "lt") { + ret = currEntry.findLT(val); + } else if (op === "lte") { + ret = currEntry.findLTE(val); + } + return ret; + } + + function mergeNotPossibles(tuples, tl) { + if (tl) { + var j = -1, hashCode; + while (++j < tl) { + hashCode = tuples[j].hashCode; + if (!NOT_POSSIBLES_HASH[hashCode]) { + NOT_POSSIBLES_HASH[hashCode] = true; + NPL++; + } + } + } + } + + function mergePossibles(tuples, tl) { + if (tl) { + var j = -1, hashCode; + while (++j < tl) { + hashCode = tuples[j].hashCode; + if (!POSSIBLES_HASH[hashCode]) { + POSSIBLES_HASH[hashCode] = true; + PL++; + } + } + } + } + + return function _getMemory(entry, factHash, indexes) { + var i = -1, l = indexes.length, + ret = entry.tuples, + rl = ret.length, + intersected = false, + tables = entry.tables, + index, val, op, nextEntry, currEntry, tuples, tl; + while (++i < l && rl) { + index = indexes[i]; + val = index[3](factHash); + op = index[4]; + currEntry = tables[index[0]]; + if (op === "eq") { + if ((nextEntry = currEntry.get(val))) { + rl = (ret = (entry = nextEntry).tuples).length; + tables = nextEntry.tables; + } else { + rl = (ret = EMPTY_ARRAY).length; + } + } else if (op === "neq") { + if ((nextEntry = currEntry.get(val))) { + tl = (tuples = nextEntry.tuples).length; + mergeNotPossibles(tuples, tl); + } + } else if (!intersected) { + rl = (ret = getRangeTuples(op, currEntry, val)).length; + intersected = true; + } else if ((tl = (tuples = getRangeTuples(op, currEntry, val)).length)) { + mergePossibles(tuples, tl); + } else { + ret = tuples; + rl = tl; + } + } + return mergePossiblesAndNotPossibles(ret, rl); + }; +}()); +},{}],32:[function(require,module,exports){ var Memory = require("./memory"); Memory.extend({ @@ -3580,29 +3893,30 @@ Memory.extend({ } }).as(module); -},{"./memory":32}],32:[function(require,module,exports){ +},{"./memory":33}],33:[function(require,module,exports){ var extd = require("../../extended"), - indexOf = extd.indexOf, plucker = extd.plucker, - difference = extd.diffArr, - pPush = Array.prototype.push, declare = extd.declare, - HashTable = extd.HashTable; + getMemory = require("./helpers").getMemory, + Table = require("./table"), + TupleEntry = require("./tupleEntry"); + + +var id = 0; declare({ instance: { + length: 0, + constructor: function () { this.head = null; this.tail = null; - this.length = null; this.indexes = []; - this.tables = {tuples: [], tables: []}; + this.tables = new TupleEntry(null, new Table(), false); }, - inequalityThreshold: 0.5, - push: function (data) { - var tail = this.tail, head = this.head, node = {data: data, prev: tail, next: null}; + var tail = this.tail, head = this.head, node = {data: data, tuples: [], hashCode: id++, prev: tail, next: null}; if (tail) { this.tail.next = node; } @@ -3612,7 +3926,7 @@ declare({ } this.length++; this.__index(node); - this.tables.tuples.push(node); + this.tables.addNode(node); return node; }, @@ -3627,10 +3941,7 @@ declare({ } else { this.tail = node.prev; } - var index = indexOf(this.tables.tuples, node); - if (index !== -1) { - this.tables.tuples.splice(index, 1); - } + this.tables.removeNode(node); this.__removeFromIndex(node); this.length--; }, @@ -3643,11 +3954,7 @@ declare({ }, toArray: function () { - var head = {next: this.head}, ret = []; - while ((head = head.next)) { - ret.push(head); - } - return ret; + return this.tables.tuples.slice(); }, clear: function () { @@ -3673,118 +3980,42 @@ declare({ val = index[2](factHash); path = index[0]; tables = entry.tables; - currEntry = tables[path]; - if (!currEntry) { - currEntry = tables[path] = new HashTable(); - tuples = {tuples: [node], tables: {}}; - currEntry.put(val, tuples); - } else if (!(tuples = currEntry.get(val))) { - tuples = {tuples: [node], tables: {}}; - currEntry.put(val, tuples); - } else if (prevLookup !== path) { - tuples.tuples.push(node); + if (!(tuples = (currEntry = tables[path] || (tables[path] = new Table())).get(val))) { + tuples = new TupleEntry(val, currEntry, true); + currEntry.set(val, tuples); + } + if (currEntry !== prevLookup) { + node.tuples.push(tuples.addNode(node)); } - prevLookup = path; + prevLookup = currEntry; if (index[4] === "eq") { entry = tuples; } } }, - getSimilarMemory: function (tuple) { - return this.getMemory(tuple, true); - }, - __removeFromIndex: function (node) { - var data = node.data, - factHash = data.factHash, - indexes = this.indexes, - entry = this.tables, - i = -1, l = indexes.length; - while (++i < l) { - var index = indexes[i], - val = index[2](factHash); - var currEntry = entry.tables[index[0]]; - if (currEntry) { - var tuples = currEntry.get(val); - if (tuples) { - var currTuples = tuples.tuples, ind = indexOf(currTuples, node); - if (ind !== -1) { - currTuples.splice(ind, 1); - } - if (index[4] === "eq") { - entry = tuples; - } - } - } + var tuples = node.tuples, i = tuples.length; + while (--i >= 0) { + tuples[i].removeNode(node); } + node.tuples.length = 0; }, - getMemory: function (tuple, usePrimary) { - var factHash = tuple.factHash, - indexes = this.indexes, - entry = this.tables, - i = -1, l = indexes.length, - ret = entry.tuples, - lookup = usePrimary ? 2 : 3, - inequalityThreshold = this.inequalityThreshold, - notPossibles = [], npl = 0, rl; - - while (++i < l) { - var index = indexes[i], - val = index[lookup](factHash), - currEntry = entry.tables[index[0]]; - if (currEntry) { - var nextEntry = currEntry.get(val), tuples, tl; - if (index[4] === "neq") { - rl = ret.length; - if (!nextEntry) { - ret = rl ? ret : entry.tuples; - } else { - tuples = nextEntry.tuples; - tl = tuples.length; - if (!tl || !rl) { - ret = entry.tuples; - } else if (tl === entry.tuples.length) { - ret = []; - i = l; - } else if (tl) { - pPush.apply(notPossibles, tuples); - npl += tl; - } - } - } else if (nextEntry) { - tuples = nextEntry.tuples; - tl = tuples.length; - if (tl) { - ret = nextEntry.tuples; - entry = nextEntry; - } else { - i = l; - ret = []; - } - } else { - i = l; - ret = []; - } - } else { - ret = []; - i = l; - } - } - rl = ret.length; - if (npl && rl && (npl / rl) > inequalityThreshold) { - //console.log(npl); - ret = difference(ret, notPossibles); + getMemory: function (tuple) { + var ret; + if (!this.length) { + ret = []; + } else { + ret = getMemory(this.tables, tuple.factHash, this.indexes); } - return ret.slice(); + return ret; }, __createIndexTree: function () { var table = this.tables.tables = {}; var indexes = this.indexes; - table[indexes[0][0]] = new HashTable(); - + table[indexes[0][0]] = new Table(); }, @@ -3792,16 +4023,16 @@ declare({ this.indexes.push([primary, lookup, plucker(primary), plucker(lookup), op || "eq"]); this.indexes.sort(function (a, b) { var aOp = a[4], bOp = b[4]; - return aOp === bOp ? 0 : aOp > bOp ? 1 : -1; + return aOp === bOp ? 0 : aOp > bOp ? 1 : aOp === bOp ? 0 : -1; }); this.__createIndexTree(); + } } }).as(module); - -},{"../../extended":12}],33:[function(require,module,exports){ +},{"../../extended":12,"./helpers":31,"./table":35,"./tupleEntry":36}],34:[function(require,module,exports){ var Memory = require("./memory"); Memory.extend({ @@ -3814,55 +4045,277 @@ Memory.extend({ } }).as(module); -},{"./memory":32}],34:[function(require,module,exports){ -var extd = require("../extended"), - forEach = extd.forEach, - indexOf = extd.indexOf, - intersection = extd.intersection, - declare = extd.declare, +},{"./memory":33}],35:[function(require,module,exports){ +var extd = require("../../extended"), + pPush = Array.prototype.push, HashTable = extd.HashTable, - Context = require("../context"); + AVLTree = extd.AVLTree; -var count = 0; -declare({ - instance: { - constructor: function () { - this.nodes = new HashTable(); - this.rules = []; - this.parentNodes = []; - this.__count = count++; - this.__entrySet = []; - }, +function compare(a, b) { + a = a.key; + b = b.key; + var ret; + if (a === b) { + ret = 0; + } else if (a > b) { + ret = 1; + } else if (a < b) { + ret = -1; + } else { + ret = 1; + } + return ret; +} - addRule: function (rule) { - if (indexOf(this.rules, rule) === -1) { - this.rules.push(rule); - } - return this; - }, +function compareGT(v1, v2) { + return compare(v1, v2) === 1; +} +function compareGTE(v1, v2) { + return compare(v1, v2) !== -1; +} - merge: function (that) { - that.nodes.forEach(function (entry) { - var patterns = entry.value, node = entry.key; - for (var i = 0, l = patterns.length; i < l; i++) { - this.addOutNode(node, patterns[i]); +function compareLT(v1, v2) { + return compare(v1, v2) === -1; +} +function compareLTE(v1, v2) { + return compare(v1, v2) !== 1; +} + +var STACK = [], + VALUE = {key: null}; +function traverseInOrder(tree, key, comparator) { + VALUE.key = key; + var ret = []; + var i = 0, current = tree.__root, v; + while (true) { + if (current) { + current = (STACK[i++] = current).left; + } else { + if (i > 0) { + v = (current = STACK[--i]).data; + if (comparator(v, VALUE)) { + pPush.apply(ret, v.value.tuples); + current = current.right; + } else { + break; } - that.nodes.remove(node); - }, this); - var thatParentNodes = that.parentNodes; - for (var i = 0, l = that.parentNodes.l; i < l; i++) { - var parentNode = thatParentNodes[i]; - this.addParentNode(parentNode); - parentNode.nodes.remove(that); + } else { + break; } - return this; - }, - - resolve: function (mr1, mr2) { - return mr1.hashCode === mr2.hashCode; - }, + } + } + STACK.length = 0; + return ret; +} - print: function (tab) { +function traverseReverseOrder(tree, key, comparator) { + VALUE.key = key; + var ret = []; + var i = 0, current = tree.__root, v; + while (true) { + if (current) { + current = (STACK[i++] = current).right; + } else { + if (i > 0) { + v = (current = STACK[--i]).data; + if (comparator(v, VALUE)) { + pPush.apply(ret, v.value.tuples); + current = current.left; + } else { + break; + } + } else { + break; + } + } + } + STACK.length = 0; + return ret; +} + +AVLTree.extend({ + instance: { + + constructor: function () { + this._super([ + { + compare: compare + } + ]); + this.gtCache = new HashTable(); + this.gteCache = new HashTable(); + this.ltCache = new HashTable(); + this.lteCache = new HashTable(); + this.hasGTCache = false; + this.hasGTECache = false; + this.hasLTCache = false; + this.hasLTECache = false; + }, + + clearCache: function () { + this.hasGTCache && this.gtCache.clear() && (this.hasGTCache = false); + this.hasGTECache && this.gteCache.clear() && (this.hasGTECache = false); + this.hasLTCache && this.ltCache.clear() && (this.hasLTCache = false); + this.hasLTECache && this.lteCache.clear() && (this.hasLTECache = false); + }, + + contains: function (key) { + return this._super([ + {key: key} + ]); + }, + + "set": function (key, value) { + this.insert({key: key, value: value}); + this.clearCache(); + }, + + "get": function (key) { + var ret = this.find({key: key}); + return ret && ret.value; + }, + + "remove": function (key) { + this.clearCache(); + return this._super([ + {key: key} + ]); + }, + + findGT: function (key) { + var ret = this.gtCache.get(key); + if (!ret) { + this.hasGTCache = true; + this.gtCache.put(key, (ret = traverseReverseOrder(this, key, compareGT))); + } + return ret; + }, + + findGTE: function (key) { + var ret = this.gteCache.get(key); + if (!ret) { + this.hasGTECache = true; + this.gteCache.put(key, (ret = traverseReverseOrder(this, key, compareGTE))); + } + return ret; + }, + + findLT: function (key) { + var ret = this.ltCache.get(key); + if (!ret) { + this.hasLTCache = true; + this.ltCache.put(key, (ret = traverseInOrder(this, key, compareLT))); + } + return ret; + }, + + findLTE: function (key) { + var ret = this.lteCache.get(key); + if (!ret) { + this.hasLTECache = true; + this.lteCache.put(key, (ret = traverseInOrder(this, key, compareLTE))); + } + return ret; + } + + } +}).as(module); +},{"../../extended":12}],36:[function(require,module,exports){ +var extd = require("../../extended"), + indexOf = extd.indexOf; +// HashSet = require("./hashSet"); + + +var TUPLE_ID = 0; +extd.declare({ + + instance: { + tuples: null, + tupleMap: null, + hashCode: null, + tables: null, + entry: null, + constructor: function (val, entry, canRemove) { + this.val = val; + this.canRemove = canRemove; + this.tuples = []; + this.tupleMap = {}; + this.hashCode = TUPLE_ID++; + this.tables = {}; + this.length = 0; + this.entry = entry; + }, + + addNode: function (node) { + this.tuples[this.length++] = node; + if (this.length > 1) { + this.entry.clearCache(); + } + return this; + }, + + removeNode: function (node) { + var tuples = this.tuples, index = indexOf(tuples, node); + if (index !== -1) { + tuples.splice(index, 1); + this.length--; + this.entry.clearCache(); + } + if (this.canRemove && !this.length) { + this.entry.remove(this.val); + } + } + } +}).as(module); +},{"../../extended":12}],37:[function(require,module,exports){ +var extd = require("../extended"), + forEach = extd.forEach, + indexOf = extd.indexOf, + intersection = extd.intersection, + declare = extd.declare, + HashTable = extd.HashTable, + Context = require("../context"); + +var count = 0; +declare({ + instance: { + constructor: function () { + this.nodes = new HashTable(); + this.rules = []; + this.parentNodes = []; + this.__count = count++; + this.__entrySet = []; + }, + + addRule: function (rule) { + if (indexOf(this.rules, rule) === -1) { + this.rules.push(rule); + } + return this; + }, + + merge: function (that) { + that.nodes.forEach(function (entry) { + var patterns = entry.value, node = entry.key; + for (var i = 0, l = patterns.length; i < l; i++) { + this.addOutNode(node, patterns[i]); + } + that.nodes.remove(node); + }, this); + var thatParentNodes = that.parentNodes; + for (var i = 0, l = that.parentNodes.l; i < l; i++) { + var parentNode = thatParentNodes[i]; + this.addParentNode(parentNode); + parentNode.nodes.remove(that); + } + return this; + }, + + resolve: function (mr1, mr2) { + return mr1.hashCode === mr2.hashCode; + }, + + print: function (tab) { console.log(tab + this.toString()); forEach(this.parentNodes, function (n) { n.print(" " + tab); @@ -3941,7 +4394,7 @@ declare({ }).as(module); -},{"../context":10,"../extended":12}],35:[function(require,module,exports){ +},{"../context":10,"../extended":12}],38:[function(require,module,exports){ var JoinNode = require("./joinNode"), LinkedList = require("../linkedList"), Context = require("../context"), @@ -3971,11 +4424,11 @@ JoinNode.extend({ blocking = rightContext.blocking; if (blocking.length) { //if we are blocking left contexts - var rm = this.rightTuples.getSimilarMemory(rightContext), l = rm.length, i; var leftContext, thisConstraint = this.constraint, blockingNode = {next: blocking.head}, rc; while ((blockingNode = blockingNode.next)) { leftContext = blockingNode.data; - //this.removeFromLeftBlockedMemory(leftContext); + this.removeFromLeftBlockedMemory(leftContext); + var rm = this.rightTuples.getRightMemory(leftContext), l = rm.length, i; i = -1; while (++i < l) { if (thisConstraint.isMatch(leftContext, rc = rm[i].data)) { @@ -4052,7 +4505,7 @@ JoinNode.extend({ assertRight: function (context) { this.__addToRightMemory(context); context.blocking = new LinkedList(); - var fl = this.leftTuples.getLeftMemory(context), + var fl = this.leftTuples.getLeftMemory(context).slice(), i = -1, l = fl.length, leftContext, thisConstraint = this.constraint; while (++i < l) { @@ -4101,6 +4554,7 @@ JoinNode.extend({ if (leftContext && leftContext.blocker) { //we were blocked before so only check nodes previous to our blocker blocker = this.rightMemory[leftContext.blocker.hashCode]; + leftContext.blocker = null; } if (blocker) { if (thisConstraint.isMatch(context, rc = blocker.data)) { @@ -4153,7 +4607,7 @@ JoinNode.extend({ var ctx = this.removeFromRightMemory(context); if (ctx) { var rightContext = ctx.data, - leftTuples = this.leftTuples.getLeftMemory(context), + leftTuples = this.leftTuples.getLeftMemory(context).slice(), leftTuplesLength = leftTuples.length, leftContext, thisConstraint = this.constraint, @@ -4190,22 +4644,19 @@ JoinNode.extend({ this.__propagate("assert", this.__cloneContext(leftContext)); } } - - if (leftTuplesLength) { - //check currently left tuples in memory - i = -1; - while (++i < leftTuplesLength) { - leftContext = leftTuples[i].data; - if (thisConstraint.isMatch(leftContext, context)) { - this.__propagate("retract", this.__cloneContext(leftContext)); - this.removeFromLeftMemory(leftContext); - this.addToLeftBlockedMemory(context.blocking.push(leftContext)); - leftContext.blocker = context; - } + } + if (leftTuplesLength) { + //check currently left tuples in memory + i = -1; + while (++i < leftTuplesLength) { + leftContext = leftTuples[i].data; + if (thisConstraint.isMatch(leftContext, context)) { + this.__propagate("retract", this.__cloneContext(leftContext)); + this.removeFromLeftMemory(leftContext); + this.addToLeftBlockedMemory(context.blocking.push(leftContext)); + leftContext.blocker = context; } } - - } } else { throw new Error(); @@ -4215,7 +4666,7 @@ JoinNode.extend({ } } }).as(module); -},{"../context":10,"../linkedList":16,"../pattern":45,"./joinNode":28}],36:[function(require,module,exports){ +},{"../context":10,"../linkedList":16,"../pattern":48,"./joinNode":28}],39:[function(require,module,exports){ var AlphaNode = require("./alphaNode"), Context = require("../context"), extd = require("../extended"); @@ -4266,7 +4717,7 @@ AlphaNode.extend({ -},{"../context":10,"../extended":12,"./alphaNode":20}],37:[function(require,module,exports){ +},{"../context":10,"../extended":12,"./alphaNode":20}],40:[function(require,module,exports){ var Node = require("./adapterNode"); Node.extend({ @@ -4301,7 +4752,7 @@ Node.extend({ } } }).as(module); -},{"./adapterNode":18}],38:[function(require,module,exports){ +},{"./adapterNode":18}],41:[function(require,module,exports){ var Node = require("./node"), extd = require("../extended"), bind = extd.bind; @@ -4369,7 +4820,7 @@ Node.extend({ } } }).as(module); -},{"../extended":12,"./node":34}],39:[function(require,module,exports){ +},{"../extended":12,"./node":37}],42:[function(require,module,exports){ var AlphaNode = require("./alphaNode"), Context = require("../context"); @@ -4417,7 +4868,7 @@ AlphaNode.extend({ }).as(module); -},{"../context":10,"./alphaNode":20}],40:[function(require,module,exports){ +},{"../context":10,"./alphaNode":20}],43:[function(require,module,exports){ var process=require("__browserify_process");/* parser generated by jison 0.4.6 */ /* Returns a Parser object of the following structure: @@ -5166,7 +5617,7 @@ if (typeof module !== 'undefined' && require.main === module) { exports.main(process.argv.slice(1)); } } -},{"__browserify_process":68,"fs":65,"path":66}],41:[function(require,module,exports){ +},{"__browserify_process":64,"fs":61,"path":62}],44:[function(require,module,exports){ (function () { "use strict"; var constraintParser = require("./constraint/parser"), @@ -5184,7 +5635,7 @@ if (typeof module !== 'undefined' && require.main === module) { return noolParser.parse(source, file); }; })(); -},{"./constraint/parser":40,"./nools/nool.parser":42}],42:[function(require,module,exports){ +},{"./constraint/parser":43,"./nools/nool.parser":45}],45:[function(require,module,exports){ "use strict"; var tokens = require("./tokens.js"), @@ -5224,7 +5675,7 @@ exports.parse = function (src, file) { }; -},{"../../extended":12,"./tokens.js":43,"./util.js":44}],43:[function(require,module,exports){ +},{"../../extended":12,"./tokens.js":46,"./util.js":47}],46:[function(require,module,exports){ var process=require("__browserify_process");"use strict"; var utils = require("./util.js"), @@ -5576,7 +6027,7 @@ var topLevelTokens = { module.exports = topLevelTokens; -},{"../../extended":12,"./util.js":44,"__browserify_process":68,"fs":65}],44:[function(require,module,exports){ +},{"../../extended":12,"./util.js":47,"__browserify_process":64,"fs":61}],47:[function(require,module,exports){ var process=require("__browserify_process");"use strict"; var path = require("path"); @@ -5668,7 +6119,7 @@ var findNextTokenIndex = exports.findNextTokenIndex = function (str, startIndex, exports.findNextToken = function (str, startIndex, endIndex) { return str.charAt(findNextTokenIndex(str, startIndex, endIndex)); }; -},{"__browserify_process":68,"path":66}],45:[function(require,module,exports){ +},{"__browserify_process":64,"path":62}],48:[function(require,module,exports){ "use strict"; var extd = require("./extended"), isEmpty = extd.isEmpty, @@ -5821,7 +6272,7 @@ ObjectPattern.extend({ -},{"./constraint":8,"./constraintMatcher":9,"./extended":12}],46:[function(require,module,exports){ +},{"./constraint":8,"./constraintMatcher":9,"./extended":12}],49:[function(require,module,exports){ "use strict"; var extd = require("./extended"), isArray = extd.isArray, @@ -6119,10 +6570,11 @@ exports.createRule = createRule; -},{"./extended":12,"./parser":41,"./pattern":45}],47:[function(require,module,exports){ +},{"./extended":12,"./parser":44,"./pattern":48}],50:[function(require,module,exports){ "use strict"; var declare = require("declare.js"), LinkedList = require("./linkedList"), + InitialFact = require("./pattern").InitialFact, id = 0; var Fact = declare({ @@ -6158,6 +6610,27 @@ declare({ this.facts.clear(); }, + getFacts: function () { + var head = {next: this.facts.head}, ret = [], i = 0, val; + while ((head = head.next)) { + if (!((val = head.data.object) instanceof InitialFact)) { + ret[i++] = val; + } + } + return ret; + }, + + getFactsByType: function (Type) { + var head = {next: this.facts.head}, ret = [], i = 0; + while ((head = head.next)) { + var val = head.data.object; + if (!(val instanceof InitialFact) && (val instanceof Type || val.constructor === Type)) { + ret[i++] = val; + } + } + return ret; + }, + getFactHandle: function (o) { var head = {next: this.facts.head}, ret; while ((head = head.next)) { @@ -6192,20 +6665,6 @@ declare({ ret.recency = this.recency++; this.facts.push(ret); return ret; -// var head = {next: this.facts.head}, ret; -// while ((head = head.next)) { -// var existingFact = head.data; -// if (existingFact.equals(fact)) { -// ret = existingFact; -// break; -// } -// } -// if (!ret) { -// ret = new Fact(fact); -// ret.recency = this.recency++; -// this.facts.push(ret); -// } -// return ret; }, retractFact: function (fact) { @@ -6227,7 +6686,7 @@ declare({ }).as(exports, "WorkingMemory"); -},{"./linkedList":16,"declare.js":52}],48:[function(require,module,exports){ +},{"./linkedList":16,"./pattern":48,"declare.js":55}],51:[function(require,module,exports){ (function () { "use strict"; @@ -6272,7 +6731,7 @@ declare({ }).call(this); -},{"extended":53,"is-extended":70}],49:[function(require,module,exports){ +},{"extended":56,"is-extended":66}],52:[function(require,module,exports){ (function () { "use strict"; /*global define*/ @@ -6942,7 +7401,7 @@ declare({ -},{"arguments-extended":48,"extended":53,"is-extended":70}],50:[function(require,module,exports){ +},{"arguments-extended":51,"extended":56,"is-extended":66}],53:[function(require,module,exports){ (function () { "use strict"; @@ -7890,7 +8349,7 @@ declare({ -},{"array-extended":49,"extended":53,"is-extended":70}],51:[function(require,module,exports){ +},{"array-extended":52,"extended":56,"is-extended":66}],54:[function(require,module,exports){ (function () { /** @@ -8817,9 +9276,9 @@ declare({ -},{}],52:[function(require,module,exports){ +},{}],55:[function(require,module,exports){ module.exports = require("./declare.js"); -},{"./declare.js":51}],53:[function(require,module,exports){ +},{"./declare.js":54}],56:[function(require,module,exports){ (function () { "use strict"; /*global extender is, dateExtended*/ @@ -8918,7 +9377,7 @@ module.exports = require("./declare.js"); -},{"extender":55}],54:[function(require,module,exports){ +},{"extender":58}],57:[function(require,module,exports){ (function () { /*jshint strict:false*/ @@ -9459,9 +9918,9 @@ module.exports = require("./declare.js"); } }).call(this); -},{"declare.js":52}],55:[function(require,module,exports){ +},{"declare.js":55}],58:[function(require,module,exports){ module.exports = require("./extender.js"); -},{"./extender.js":54}],56:[function(require,module,exports){ +},{"./extender.js":57}],59:[function(require,module,exports){ (function () { "use strict"; @@ -9500,2326 +9959,226 @@ module.exports = require("./extender.js"); throw new Error(method + " property not defined in scope"); } else if (!isString(method) && !isFunction(method)) { throw new Error(method + " is not a function"); - } - if (isString(method)) { - return function () { - var func = scope[method]; - if (isFunction(func)) { - var scopeArgs = args.concat(argsToArray(arguments)); - return func.apply(scope, scopeArgs); - } else { - return func; - } - }; - } else { - if (args.length) { - return function () { - var scopeArgs = args.concat(argsToArray(arguments)); - return spreadArgs(method, arguments, scope); - }; - } else { - - return function () { - return spreadArgs(method, arguments, scope); - }; - } - } - } - - - function applyFirst(method, args) { - args = argsToArray(arguments, 1); - if (!isString(method) && !isFunction(method)) { - throw new Error(method + " must be the name of a property or function to execute"); - } - if (isString(method)) { - return function () { - var scopeArgs = argsToArray(arguments), scope = scopeArgs.shift(); - var func = scope[method]; - if (isFunction(func)) { - scopeArgs = args.concat(scopeArgs); - return func.apply(scope, scopeArgs); - } else { - return func; - } - }; - } else { - return function () { - var scopeArgs = argsToArray(arguments), scope = scopeArgs.shift(); - scopeArgs = args.concat(scopeArgs); - return method.apply(scope, scopeArgs); - }; - } - } - - - function hitchIgnore(scope, method, args) { - args = argsToArray(arguments, 2); - if ((isString(method) && !(method in scope))) { - throw new Error(method + " property not defined in scope"); - } else if (!isString(method) && !isFunction(method)) { - throw new Error(method + " is not a function"); - } - if (isString(method)) { - return function () { - var func = scope[method]; - if (isFunction(func)) { - return func.apply(scope, args); - } else { - return func; - } - }; - } else { - return function () { - return method.apply(scope, args); - }; - } - } - - - function hitchAll(scope) { - var funcs = argsToArray(arguments, 1); - if (!isObject(scope) && !isFunction(scope)) { - throw new TypeError("scope must be an object"); - } - if (funcs.length === 1 && isArray(funcs[0])) { - funcs = funcs[0]; - } - if (!funcs.length) { - funcs = []; - for (var k in scope) { - if (scope.hasOwnProperty(k) && isFunction(scope[k])) { - funcs.push(k); - } - } - } - for (var i = 0, l = funcs.length; i < l; i++) { - scope[funcs[i]] = hitch(scope, scope[funcs[i]]); - } - return scope; - } - - - function partial(method, args) { - args = argsToArray(arguments, 1); - if (!isString(method) && !isFunction(method)) { - throw new Error(method + " must be the name of a property or function to execute"); - } - if (isString(method)) { - return function () { - var func = this[method]; - if (isFunction(func)) { - var scopeArgs = args.concat(argsToArray(arguments)); - return func.apply(this, scopeArgs); - } else { - return func; - } - }; - } else { - return function () { - var scopeArgs = args.concat(argsToArray(arguments)); - return method.apply(this, scopeArgs); - }; - } - } - - function curryFunc(f, execute) { - return function () { - var args = argsToArray(arguments); - return execute ? f.apply(this, arguments) : function () { - return f.apply(this, args.concat(argsToArray(arguments))); - }; - }; - } - - - function curry(depth, cb, scope) { - var f; - if (scope) { - f = hitch(scope, cb); - } else { - f = cb; - } - if (depth) { - var len = depth - 1; - for (var i = len; i >= 0; i--) { - f = curryFunc(f, i === len); - } - } - return f; - } - - return extended - .define(isObject, { - bind: hitch, - bindAll: hitchAll, - bindIgnore: hitchIgnore, - curry: function (scope, depth, fn) { - return curry(depth, fn, scope); - } - }) - .define(isFunction, { - bind: function (fn, obj) { - return hitch.apply(this, [obj, fn].concat(argsToArray(arguments, 2))); - }, - bindIgnore: function (fn, obj) { - return hitchIgnore.apply(this, [obj, fn].concat(argsToArray(arguments, 2))); - }, - partial: partial, - applyFirst: applyFirst, - curry: function (fn, num, scope) { - return curry(num, fn, scope); - }, - noWrap: { - f: function () { - return this.value(); - } - } - }) - .define(isString, { - bind: function (str, scope) { - return hitch(scope, str); - }, - bindIgnore: function (str, scope) { - return hitchIgnore(scope, str); - }, - partial: partial, - applyFirst: applyFirst, - curry: function (fn, depth, scope) { - return curry(depth, fn, scope); - } - }) - .expose({ - bind: hitch, - bindAll: hitchAll, - bindIgnore: hitchIgnore, - partial: partial, - applyFirst: applyFirst, - curry: curry - }); - - } - - if ("undefined" !== typeof exports) { - if ("undefined" !== typeof module && module.exports) { - module.exports = defineFunction(require("extended"), require("is-extended"), require("arguments-extended")); - - } - } else if ("function" === typeof define && define.amd) { - define(["extended", "is-extended", "arguments-extended"], function (extended, is, args) { - return defineFunction(extended, is, args); - }); - } else { - this.functionExtended = defineFunction(this.extended, this.isExtended, this.argumentsExtended); - } - -}).call(this); - - - - - - - -},{"arguments-extended":57,"extended":58,"is-extended":63}],57:[function(require,module,exports){ -(function () { - "use strict"; - - function defineArgumentsExtended(extended, is) { - - var pSlice = Array.prototype.slice, - isArguments = is.isArguments; - - function argsToArray(args, slice) { - var i = -1, j = 0, l = args.length, ret = []; - slice = slice || 0; - i += slice; - while (++i < l) { - ret[j++] = args[i]; - } - return ret; - } - - - return extended - .define(isArguments, { - toArray: argsToArray - }) - .expose({ - argsToArray: argsToArray - }); - } - - if ("undefined" !== typeof exports) { - if ("undefined" !== typeof module && module.exports) { - module.exports = defineArgumentsExtended(require("extended"), require("is-extended")); - - } - } else if ("function" === typeof define && define.amd) { - define(["extended", "is-extended"], function (extended, is) { - return defineArgumentsExtended(extended, is); - }); - } else { - this.argumentsExtended = defineArgumentsExtended(this.extended, this.isExtended); - } - -}).call(this); - - -},{"extended":58,"is-extended":63}],58:[function(require,module,exports){ -(function () { - "use strict"; - /*global extender is, dateExtended*/ - - function defineExtended(extender) { - - - var merge = (function merger() { - function _merge(target, source) { - var name, s; - for (name in source) { - if (source.hasOwnProperty(name)) { - s = source[name]; - if (!(name in target) || (target[name] !== s)) { - target[name] = s; - } - } - } - return target; - } - - return function merge(obj) { - if (!obj) { - obj = {}; - } - for (var i = 1, l = arguments.length; i < l; i++) { - _merge(obj, arguments[i]); - } - return obj; // Object - }; - }()); - - function getExtended() { - - var loaded = {}; - - - //getInitial instance; - var extended = extender.define(); - extended.expose({ - register: function register(alias, extendWith) { - if (!extendWith) { - extendWith = alias; - alias = null; - } - var type = typeof extendWith; - if (alias) { - extended[alias] = extendWith; - } else if (extendWith && type === "function") { - extended.extend(extendWith); - } else if (type === "object") { - extended.expose(extendWith); - } else { - throw new TypeError("extended.register must be called with an extender function"); - } - return extended; - }, - - define: function () { - return extender.define.apply(extender, arguments); - } - }); - - return extended; - } - - function extended() { - return getExtended(); - } - - extended.define = function define() { - return extender.define.apply(extender, arguments); - }; - - return extended; - } - - if ("undefined" !== typeof exports) { - if ("undefined" !== typeof module && module.exports) { - module.exports = defineExtended(require("extender")); - - } - } else if ("function" === typeof define && define.amd) { - define(["extender"], function (extender) { - return defineExtended(extender); - }); - } else { - this.extended = defineExtended(this.extender); - } - -}).call(this); - - - - - - - -},{"extender":60}],59:[function(require,module,exports){ -(function () { - /*jshint strict:false*/ - - - /** - * - * @projectName extender - * @github http://github.com/doug-martin/extender - * @header - * [![build status](https://secure.travis-ci.org/doug-martin/extender.png)](http://travis-ci.org/doug-martin/extender) - * # Extender - * - * `extender` is a library that helps in making chainable APIs, by creating a function that accepts different values and returns an object decorated with functions based on the type. - * - * ## Why Is Extender Different? - * - * Extender is different than normal chaining because is does more than return `this`. It decorates your values in a type safe manner. - * - * For example if you return an array from a string based method then the returned value will be decorated with array methods and not the string methods. This allow you as the developer to focus on your API and not worrying about how to properly build and connect your API. - * - * - * ## Installation - * - * ``` - * npm install extender - * ``` - * - * Or [download the source](https://raw.github.com/doug-martin/extender/master/extender.js) ([minified](https://raw.github.com/doug-martin/extender/master/extender-min.js)) - * - * **Note** `extender` depends on [`declare.js`](http://doug-martin.github.com/declare.js/). - * - * ### Requirejs - * - * To use with requirejs place the `extend` source in the root scripts directory - * - * ```javascript - * - * define(["extender"], function(extender){ - * }); - * - * ``` - * - * - * ## Usage - * - * **`extender.define(tester, decorations)`** - * - * To create your own extender call the `extender.define` function. - * - * This function accepts an optional tester which is used to determine a value should be decorated with the specified `decorations` - * - * ```javascript - * function isString(obj) { - * return !isUndefinedOrNull(obj) && (typeof obj === "string" || obj instanceof String); - * } - * - * - * var myExtender = extender.define(isString, { - * multiply: function (str, times) { - * var ret = str; - * for (var i = 1; i < times; i++) { - * ret += str; - * } - * return ret; - * }, - * toArray: function (str, delim) { - * delim = delim || ""; - * return str.split(delim); - * } - * }); - * - * myExtender("hello").multiply(2).value(); //hellohello - * - * ``` - * - * If you do not specify a tester function and just pass in an object of `functions` then all values passed in will be decorated with methods. - * - * ```javascript - * - * function isUndefined(obj) { - * var undef; - * return obj === undef; - * } - * - * function isUndefinedOrNull(obj) { - * var undef; - * return obj === undef || obj === null; - * } - * - * function isArray(obj) { - * return Object.prototype.toString.call(obj) === "[object Array]"; - * } - * - * function isBoolean(obj) { - * var undef, type = typeof obj; - * return !isUndefinedOrNull(obj) && type === "boolean" || type === "Boolean"; - * } - * - * function isString(obj) { - * return !isUndefinedOrNull(obj) && (typeof obj === "string" || obj instanceof String); - * } - * - * var myExtender = extender.define({ - * isUndefined : isUndefined, - * isUndefinedOrNull : isUndefinedOrNull, - * isArray : isArray, - * isBoolean : isBoolean, - * isString : isString - * }); - * - * ``` - * - * To use - * - * ``` - * var undef; - * myExtender("hello").isUndefined().value(); //false - * myExtender(undef).isUndefined().value(); //true - * ``` - * - * You can also chain extenders so that they accept multiple types and decorates accordingly. - * - * ```javascript - * myExtender - * .define(isArray, { - * pluck: function (arr, m) { - * var ret = []; - * for (var i = 0, l = arr.length; i < l; i++) { - * ret.push(arr[i][m]); - * } - * return ret; - * } - * }) - * .define(isBoolean, { - * invert: function (val) { - * return !val; - * } - * }); - * - * myExtender([{a: "a"},{a: "b"},{a: "c"}]).pluck("a").value(); //["a", "b", "c"] - * myExtender("I love javascript!").toArray(/\s+/).pluck("0"); //["I", "l", "j"] - * - * ``` - * - * Notice that we reuse the same extender as defined above. - * - * **Return Values** - * - * When creating an extender if you return a value from one of the decoration functions then that value will also be decorated. If you do not return any values then the extender will be returned. - * - * **Default decoration methods** - * - * By default every value passed into an extender is decorated with the following methods. - * - * * `value` : The value this extender represents. - * * `eq(otherValue)` : Tests strict equality of the currently represented value to the `otherValue` - * * `neq(oterValue)` : Tests strict inequality of the currently represented value. - * * `print` : logs the current value to the console. - * - * **Extender initialization** - * - * When creating an extender you can also specify a constructor which will be invoked with the current value. - * - * ```javascript - * myExtender.define(isString, { - * constructor : function(val){ - * //set our value to the string trimmed - * this._value = val.trimRight().trimLeft(); - * } - * }); - * ``` - * - * **`noWrap`** - * - * `extender` also allows you to specify methods that should not have the value wrapped providing a cleaner exit function other than `value()`. - * - * For example suppose you have an API that allows you to build a validator, rather than forcing the user to invoke the `value` method you could add a method called `validator` which makes more syntactic sense. - * - * ``` - * - * var myValidator = extender.define({ - * //chainable validation methods - * //... - * //end chainable validation methods - * - * noWrap : { - * validator : function(){ - * //return your validator - * } - * } - * }); - * - * myValidator().isNotNull().isEmailAddress().validator(); //now you dont need to call .value() - * - * - * ``` - * **`extender.extend(extendr)`** - * - * You may also compose extenders through the use of `extender.extend(extender)`, which will return an entirely new extender that is the composition of extenders. - * - * Suppose you have the following two extenders. - * - * ```javascript - * var myExtender = extender - * .define({ - * isFunction: is.function, - * isNumber: is.number, - * isString: is.string, - * isDate: is.date, - * isArray: is.array, - * isBoolean: is.boolean, - * isUndefined: is.undefined, - * isDefined: is.defined, - * isUndefinedOrNull: is.undefinedOrNull, - * isNull: is.null, - * isArguments: is.arguments, - * isInstanceOf: is.instanceOf, - * isRegExp: is.regExp - * }); - * var myExtender2 = extender.define(is.array, { - * pluck: function (arr, m) { - * var ret = []; - * for (var i = 0, l = arr.length; i < l; i++) { - * ret.push(arr[i][m]); - * } - * return ret; - * }, - * - * noWrap: { - * pluckPlain: function (arr, m) { - * var ret = []; - * for (var i = 0, l = arr.length; i < l; i++) { - * ret.push(arr[i][m]); - * } - * return ret; - * } - * } - * }); - * - * - * ``` - * - * And you do not want to alter either of them but instead what to create a third that is the union of the two. - * - * - * ```javascript - * var composed = extender.extend(myExtender).extend(myExtender2); - * ``` - * So now you can use the new extender with the joined functionality if `myExtender` and `myExtender2`. - * - * ```javascript - * var extended = composed([ - * {a: "a"}, - * {a: "b"}, - * {a: "c"} - * ]); - * extended.isArray().value(); //true - * extended.pluck("a").value(); // ["a", "b", "c"]); - * - * ``` - * - * **Note** `myExtender` and `myExtender2` will **NOT** be altered. - * - * **`extender.expose(methods)`** - * - * The `expose` method allows you to add methods to your extender that are not wrapped or automatically chained by exposing them on the extender directly. - * - * ``` - * var isMethods = { - * isFunction: is.function, - * isNumber: is.number, - * isString: is.string, - * isDate: is.date, - * isArray: is.array, - * isBoolean: is.boolean, - * isUndefined: is.undefined, - * isDefined: is.defined, - * isUndefinedOrNull: is.undefinedOrNull, - * isNull: is.null, - * isArguments: is.arguments, - * isInstanceOf: is.instanceOf, - * isRegExp: is.regExp - * }; - * - * var myExtender = extender.define(isMethods).expose(isMethods); - * - * myExtender.isArray([]); //true - * myExtender([]).isArray([]).value(); //true - * - * ``` - * - * - * **Using `instanceof`** - * - * When using extenders you can test if a value is an `instanceof` of an extender by using the instanceof operator. - * - * ```javascript - * var str = myExtender("hello"); - * - * str instanceof myExtender; //true - * ``` - * - * ## Examples - * - * To see more examples click [here](https://github.com/doug-martin/extender/tree/master/examples) - */ - function defineExtender(declare) { - - - var slice = Array.prototype.slice, undef; - - function indexOf(arr, item) { - if (arr && arr.length) { - for (var i = 0, l = arr.length; i < l; i++) { - if (arr[i] === item) { - return i; - } - } - } - return -1; - } - - function isArray(obj) { - return Object.prototype.toString.call(obj) === "[object Array]"; - } - - var merge = (function merger() { - function _merge(target, source, exclude) { - var name, s; - for (name in source) { - if (source.hasOwnProperty(name) && indexOf(exclude, name) === -1) { - s = source[name]; - if (!(name in target) || (target[name] !== s)) { - target[name] = s; - } - } - } - return target; - } - - return function merge(obj) { - if (!obj) { - obj = {}; - } - var l = arguments.length; - var exclude = arguments[arguments.length - 1]; - if (isArray(exclude)) { - l--; - } else { - exclude = []; - } - for (var i = 1; i < l; i++) { - _merge(obj, arguments[i], exclude); - } - return obj; // Object - }; - }()); - - - function extender(supers) { - supers = supers || []; - var Base = declare({ - instance: { - constructor: function (value) { - this._value = value; - }, - - value: function () { - return this._value; - }, - - eq: function eq(val) { - return this["__extender__"](this._value === val); - }, - - neq: function neq(other) { - return this["__extender__"](this._value !== other); - }, - print: function () { - console.log(this._value); - return this; - } - } - }), defined = []; - - function addMethod(proto, name, func) { - if ("function" !== typeof func) { - throw new TypeError("when extending type you must provide a function"); - } - var extendedMethod; - if (name === "constructor") { - extendedMethod = function () { - this._super(arguments); - func.apply(this, arguments); - }; - } else { - extendedMethod = function extendedMethod() { - var args = slice.call(arguments); - args.unshift(this._value); - var ret = func.apply(this, args); - return ret !== undef ? this["__extender__"](ret) : this; - }; - } - proto[name] = extendedMethod; - } - - function addNoWrapMethod(proto, name, func) { - if ("function" !== typeof func) { - throw new TypeError("when extending type you must provide a function"); - } - var extendedMethod; - if (name === "constructor") { - extendedMethod = function () { - this._super(arguments); - func.apply(this, arguments); - }; - } else { - extendedMethod = function extendedMethod() { - var args = slice.call(arguments); - args.unshift(this._value); - return func.apply(this, args); - }; - } - proto[name] = extendedMethod; - } - - function decorateProto(proto, decoration, nowrap) { - for (var i in decoration) { - if (decoration.hasOwnProperty(i)) { - if (i !== "getters" && i !== "setters") { - if (i === "noWrap") { - decorateProto(proto, decoration[i], true); - } else if (nowrap) { - addNoWrapMethod(proto, i, decoration[i]); - } else { - addMethod(proto, i, decoration[i]); - } - } else { - proto[i] = decoration[i]; - } - } - } - } - - function _extender(obj) { - var ret = obj, i, l; - if (!(obj instanceof Base)) { - var OurBase = Base; - for (i = 0, l = defined.length; i < l; i++) { - var definer = defined[i]; - if (definer[0](obj)) { - OurBase = OurBase.extend({instance: definer[1]}); - } - } - ret = new OurBase(obj); - ret["__extender__"] = _extender; - } - return ret; - } - - function always() { - return true; - } - - function define(tester, decorate) { - if (arguments.length) { - if (typeof tester === "object") { - decorate = tester; - tester = always; - } - decorate = decorate || {}; - var proto = {}; - decorateProto(proto, decorate); - //handle browsers like which skip over the constructor while looping - if (!proto.hasOwnProperty("constructor")) { - if (decorate.hasOwnProperty("constructor")) { - addMethod(proto, "constructor", decorate.constructor); - } else { - proto.constructor = function () { - this._super(arguments); - }; - } - } - defined.push([tester, proto]); - } - return _extender; - } - - function extend(supr) { - if (supr && supr.hasOwnProperty("__defined__")) { - _extender["__defined__"] = defined = defined.concat(supr["__defined__"]); - } - merge(_extender, supr, ["define", "extend", "expose", "__defined__"]); - return _extender; - } - - _extender.define = define; - _extender.extend = extend; - _extender.expose = function expose() { - var methods; - for (var i = 0, l = arguments.length; i < l; i++) { - methods = arguments[i]; - if (typeof methods === "object") { - merge(_extender, methods, ["define", "extend", "expose", "__defined__"]); - } - } - return _extender; - }; - _extender["__defined__"] = defined; - - - return _extender; - } - - return { - define: function () { - return extender().define.apply(extender, arguments); - }, - - extend: function (supr) { - return extender().define().extend(supr); - } - }; - - } - - if ("undefined" !== typeof exports) { - if ("undefined" !== typeof module && module.exports) { - module.exports = defineExtender(require("declare.js")); - - } - } else if ("function" === typeof define && define.amd) { - define(["declare"], function (declare) { - return defineExtender(declare); - }); - } else { - this.extender = defineExtender(this.declare); - } - -}).call(this); -},{"declare.js":62}],60:[function(require,module,exports){ -module.exports = require("./extender.js"); -},{"./extender.js":59}],61:[function(require,module,exports){ -(function () { - - /** - * @projectName declare - * @github http://github.com/doug-martin/declare.js - * @header - * - * Declare is a library designed to allow writing object oriented code the same way in both the browser and node.js. - * - * ##Installation - * - * `npm install declare.js` - * - * Or [download the source](https://raw.github.com/doug-martin/declare.js/master/declare.js) ([minified](https://raw.github.com/doug-martin/declare.js/master/declare-min.js)) - * - * ###Requirejs - * - * To use with requirejs place the `declare` source in the root scripts directory - * - * ``` - * - * define(["declare"], function(declare){ - * return declare({ - * instance : { - * hello : function(){ - * return "world"; - * } - * } - * }); - * }); - * - * ``` - * - * - * ##Usage - * - * declare.js provides - * - * Class methods - * - * * `as(module | object, name)` : exports the object to module or the object with the name - * * `mixin(mixin)` : mixes in an object but does not inherit directly from the object. **Note** this does not return a new class but changes the original class. - * * `extend(proto)` : extend a class with the given properties. A shortcut to `declare(Super, {})`; - * - * Instance methods - * - * * `_super(arguments)`: calls the super of the current method, you can pass in either the argments object or an array with arguments you want passed to super - * * `_getSuper()`: returns a this methods direct super. - * * `_static` : use to reference class properties and methods. - * * `get(prop)` : gets a property invoking the getter if it exists otherwise it just returns the named property on the object. - * * `set(prop, val)` : sets a property invoking the setter if it exists otherwise it just sets the named property on the object. - * - * - * ###Declaring a new Class - * - * Creating a new class with declare is easy! - * - * ``` - * - * var Mammal = declare({ - * //define your instance methods and properties - * instance : { - * - * //will be called whenever a new instance is created - * constructor: function(options) { - * options = options || {}; - * this._super(arguments); - * this._type = options.type || "mammal"; - * }, - * - * speak : function() { - * return "A mammal of type " + this._type + " sounds like"; - * }, - * - * //Define your getters - * getters : { - * - * //can be accessed by using the get method. (mammal.get("type")) - * type : function() { - * return this._type; - * } - * }, - * - * //Define your setters - * setters : { - * - * //can be accessed by using the set method. (mammal.set("type", "mammalType")) - * type : function(t) { - * this._type = t; - * } - * } - * }, - * - * //Define your static methods - * static : { - * - * //Mammal.soundOff(); //"Im a mammal!!" - * soundOff : function() { - * return "Im a mammal!!"; - * } - * } - * }); - * - * - * ``` - * - * You can use Mammal just like you would any other class. - * - * ``` - * Mammal.soundOff("Im a mammal!!"); - * - * var myMammal = new Mammal({type : "mymammal"}); - * myMammal.speak(); // "A mammal of type mymammal sounds like" - * myMammal.get("type"); //"mymammal" - * myMammal.set("type", "mammal"); - * myMammal.get("type"); //"mammal" - * - * - * ``` - * - * ###Extending a class - * - * If you want to just extend a single class use the .extend method. - * - * ``` - * - * var Wolf = Mammal.extend({ - * - * //define your instance method - * instance: { - * - * //You can override super constructors just be sure to call `_super` - * constructor: function(options) { - * options = options || {}; - * this._super(arguments); //call our super constructor. - * this._sound = "growl"; - * this._color = options.color || "grey"; - * }, - * - * //override Mammals `speak` method by appending our own data to it. - * speak : function() { - * return this._super(arguments) + " a " + this._sound; - * }, - * - * //add new getters for sound and color - * getters : { - * - * //new Wolf().get("type") - * //notice color is read only as we did not define a setter - * color : function() { - * return this._color; - * }, - * - * //new Wolf().get("sound") - * sound : function() { - * return this._sound; - * } - * }, - * - * setters : { - * - * //new Wolf().set("sound", "howl") - * sound : function(s) { - * this._sound = s; - * } - * } - * - * }, - * - * static : { - * - * //You can override super static methods also! And you can still use _super - * soundOff : function() { - * //You can even call super in your statics!!! - * //should return "I'm a mammal!! that growls" - * return this._super(arguments) + " that growls"; - * } - * } - * }); - * - * Wolf.soundOff(); //Im a mammal!! that growls - * - * var myWolf = new Wolf(); - * myWolf instanceof Mammal //true - * myWolf instanceof Wolf //true - * - * ``` - * - * You can also extend a class by using the declare method and just pass in the super class. - * - * ``` - * //Typical hierarchical inheritance - * // Mammal->Wolf->Dog - * var Dog = declare(Wolf, { - * instance: { - * constructor: function(options) { - * options = options || {}; - * this._super(arguments); - * //override Wolfs initialization of sound to woof. - * this._sound = "woof"; - * - * }, - * - * speak : function() { - * //Should return "A mammal of type mammal sounds like a growl thats domesticated" - * return this._super(arguments) + " thats domesticated"; - * } - * }, - * - * static : { - * soundOff : function() { - * //should return "I'm a mammal!! that growls but now barks" - * return this._super(arguments) + " but now barks"; - * } - * } - * }); - * - * Dog.soundOff(); //Im a mammal!! that growls but now barks - * - * var myDog = new Dog(); - * myDog instanceof Mammal //true - * myDog instanceof Wolf //true - * myDog instanceof Dog //true - * - * - * //Notice you still get the extend method. - * - * // Mammal->Wolf->Dog->Breed - * var Breed = Dog.extend({ - * instance: { - * - * //initialize outside of constructor - * _pitch : "high", - * - * constructor: function(options) { - * options = options || {}; - * this._super(arguments); - * this.breed = options.breed || "lab"; - * }, - * - * speak : function() { - * //Should return "A mammal of type mammal sounds like a - * //growl thats domesticated with a high pitch!" - * return this._super(arguments) + " with a " + this._pitch + " pitch!"; - * }, - * - * getters : { - * pitch : function() { - * return this._pitch; - * } - * } - * }, - * - * static : { - * soundOff : function() { - * //should return "I'M A MAMMAL!! THAT GROWLS BUT NOW BARKS!" - * return this._super(arguments).toUpperCase() + "!"; - * } - * } - * }); - * - * - * Breed.soundOff()//"IM A MAMMAL!! THAT GROWLS BUT NOW BARKS!" - * - * var myBreed = new Breed({color : "gold", type : "lab"}), - * myBreed instanceof Dog //true - * myBreed instanceof Wolf //true - * myBreed instanceof Mammal //true - * myBreed.speak() //"A mammal of type lab sounds like a woof thats domesticated with a high pitch!" - * myBreed.get("type") //"lab" - * myBreed.get("color") //"gold" - * myBreed.get("sound")" //"woof" - * ``` - * - * ###Multiple Inheritance / Mixins - * - * declare also allows the use of multiple super classes. - * This is useful if you have generic classes that provide functionality but shouldnt be used on their own. - * - * Lets declare a mixin that allows us to watch for property changes. - * - * ``` - * //Notice that we set up the functions outside of declare because we can reuse them - * - * function _set(prop, val) { - * //get the old value - * var oldVal = this.get(prop); - * //call super to actually set the property - * var ret = this._super(arguments); - * //call our handlers - * this.__callHandlers(prop, oldVal, val); - * return ret; - * } - * - * function _callHandlers(prop, oldVal, newVal) { - * //get our handlers for the property - * var handlers = this.__watchers[prop], l; - * //if the handlers exist and their length does not equal 0 then we call loop through them - * if (handlers && (l = handlers.length) !== 0) { - * for (var i = 0; i < l; i++) { - * //call the handler - * handlers[i].call(null, prop, oldVal, newVal); - * } - * } - * } - * - * - * //the watch function - * function _watch(prop, handler) { - * if ("function" !== typeof handler) { - * //if its not a function then its an invalid handler - * throw new TypeError("Invalid handler."); - * } - * if (!this.__watchers[prop]) { - * //create the watchers if it doesnt exist - * this.__watchers[prop] = [handler]; - * } else { - * //otherwise just add it to the handlers array - * this.__watchers[prop].push(handler); - * } - * } - * - * function _unwatch(prop, handler) { - * if ("function" !== typeof handler) { - * throw new TypeError("Invalid handler."); - * } - * var handlers = this.__watchers[prop], index; - * if (handlers && (index = handlers.indexOf(handler)) !== -1) { - * //remove the handler if it is found - * handlers.splice(index, 1); - * } - * } - * - * declare({ - * instance:{ - * constructor:function () { - * this._super(arguments); - * //set up our watchers - * this.__watchers = {}; - * }, - * - * //override the default set function so we can watch values - * "set":_set, - * //set up our callhandlers function - * __callHandlers:_callHandlers, - * //add the watch function - * watch:_watch, - * //add the unwatch function - * unwatch:_unwatch - * }, - * - * "static":{ - * - * init:function () { - * this._super(arguments); - * this.__watchers = {}; - * }, - * //override the default set function so we can watch values - * "set":_set, - * //set our callHandlers function - * __callHandlers:_callHandlers, - * //add the watch - * watch:_watch, - * //add the unwatch function - * unwatch:_unwatch - * } - * }) - * - * ``` - * - * Now lets use the mixin - * - * ``` - * var WatchDog = declare([Dog, WatchMixin]); - * - * var watchDog = new WatchDog(); - * //create our handler - * function watch(id, oldVal, newVal) { - * console.log("watchdog's %s was %s, now %s", id, oldVal, newVal); - * } - * - * //watch for property changes - * watchDog.watch("type", watch); - * watchDog.watch("color", watch); - * watchDog.watch("sound", watch); - * - * //now set the properties each handler will be called - * watchDog.set("type", "newDog"); - * watchDog.set("color", "newColor"); - * watchDog.set("sound", "newSound"); - * - * - * //unwatch the property changes - * watchDog.unwatch("type", watch); - * watchDog.unwatch("color", watch); - * watchDog.unwatch("sound", watch); - * - * //no handlers will be called this time - * watchDog.set("type", "newDog"); - * watchDog.set("color", "newColor"); - * watchDog.set("sound", "newSound"); - * - * - * ``` - * - * ###Accessing static methods and properties witin an instance. - * - * To access static properties on an instance use the `_static` property which is a reference to your constructor. - * - * For example if your in your constructor and you want to have configurable default values. - * - * ``` - * consturctor : function constructor(opts){ - * this.opts = opts || {}; - * this._type = opts.type || this._static.DEFAULT_TYPE; - * } - * ``` - * - * - * - * ###Creating a new instance of within an instance. - * - * Often times you want to create a new instance of an object within an instance. If your subclassed however you cannot return a new instance of the parent class as it will not be the right sub class. `declare` provides a way around this by setting the `_static` property on each isntance of the class. - * - * Lets add a reproduce method `Mammal` - * - * ``` - * reproduce : function(options){ - * return new this._static(options); - * } - * ``` - * - * Now in each subclass you can call reproduce and get the proper type. - * - * ``` - * var myDog = new Dog(); - * var myDogsChild = myDog.reproduce(); - * - * myDogsChild instanceof Dog; //true - * ``` - * - * ###Using the `as` - * - * `declare` also provides an `as` method which allows you to add your class to an object or if your using node.js you can pass in `module` and the class will be exported as the module. - * - * ``` - * var animals = {}; - * - * Mammal.as(animals, "Dog"); - * Wolf.as(animals, "Wolf"); - * Dog.as(animals, "Dog"); - * Breed.as(animals, "Breed"); - * - * var myDog = new animals.Dog(); - * - * ``` - * - * Or in node - * - * ``` - * Mammal.as(exports, "Dog"); - * Wolf.as(exports, "Wolf"); - * Dog.as(exports, "Dog"); - * Breed.as(exports, "Breed"); - * - * ``` - * - * To export a class as the `module` in node - * - * ``` - * Mammal.as(module); - * ``` - * - * - */ - function createDeclared() { - var arraySlice = Array.prototype.slice, classCounter = 0, Base, forceNew = new Function(); - - var SUPER_REGEXP = /(super)/g; - - function argsToArray(args, slice) { - slice = slice || 0; - return arraySlice.call(args, slice); - } - - function isArray(obj) { - return Object.prototype.toString.call(obj) === "[object Array]"; - } - - function isObject(obj) { - var undef; - return obj !== null && obj !== undef && typeof obj === "object"; - } - - function isHash(obj) { - var ret = isObject(obj); - return ret && obj.constructor === Object; - } - - var isArguments = function _isArguments(object) { - return Object.prototype.toString.call(object) === '[object Arguments]'; - }; - - if (!isArguments(arguments)) { - isArguments = function _isArguments(obj) { - return !!(obj && obj.hasOwnProperty("callee")); - }; - } - - function indexOf(arr, item) { - if (arr && arr.length) { - for (var i = 0, l = arr.length; i < l; i++) { - if (arr[i] === item) { - return i; - } - } - } - return -1; - } - - function merge(target, source, exclude) { - var name, s; - for (name in source) { - if (source.hasOwnProperty(name) && indexOf(exclude, name) === -1) { - s = source[name]; - if (!(name in target) || (target[name] !== s)) { - target[name] = s; - } - } - } - return target; - } - - function callSuper(args, a) { - var meta = this.__meta, - supers = meta.supers, - l = supers.length, superMeta = meta.superMeta, pos = superMeta.pos; - if (l > pos) { - args = !args ? [] : (!isArguments(args) && !isArray(args)) ? [args] : args; - var name = superMeta.name, f = superMeta.f, m; - do { - m = supers[pos][name]; - if ("function" === typeof m && (m = m._f || m) !== f) { - superMeta.pos = 1 + pos; - return m.apply(this, args); - } - } while (l > ++pos); - } - - return null; - } - - function getSuper() { - var meta = this.__meta, - supers = meta.supers, - l = supers.length, superMeta = meta.superMeta, pos = superMeta.pos; - if (l > pos) { - var name = superMeta.name, f = superMeta.f, m; - do { - m = supers[pos][name]; - if ("function" === typeof m && (m = m._f || m) !== f) { - superMeta.pos = 1 + pos; - return m.bind(this); - } - } while (l > ++pos); - } - return null; - } - - function getter(name) { - var getters = this.__getters__; - if (getters.hasOwnProperty(name)) { - return getters[name].apply(this); - } else { - return this[name]; - } - } - - function setter(name, val) { - var setters = this.__setters__; - if (isHash(name)) { - for (var i in name) { - var prop = name[i]; - if (setters.hasOwnProperty(i)) { - setters[name].call(this, prop); - } else { - this[i] = prop; - } - } - } else { - if (setters.hasOwnProperty(name)) { - return setters[name].apply(this, argsToArray(arguments, 1)); - } else { - return this[name] = val; - } - } - } - - - function defaultFunction() { - var meta = this.__meta || {}, - supers = meta.supers, - l = supers.length, superMeta = meta.superMeta, pos = superMeta.pos; - if (l > pos) { - var name = superMeta.name, f = superMeta.f, m; - do { - m = supers[pos][name]; - if ("function" === typeof m && (m = m._f || m) !== f) { - superMeta.pos = 1 + pos; - return m.apply(this, arguments); - } - } while (l > ++pos); - } - return null; - } - - - function functionWrapper(f, name) { - if (f.toString().match(SUPER_REGEXP)) { - var wrapper = function wrapper() { - var ret, meta = this.__meta || {}; - var orig = meta.superMeta; - meta.superMeta = {f: f, pos: 0, name: name}; - switch (arguments.length) { - case 0: - ret = f.call(this); - break; - case 1: - ret = f.call(this, arguments[0]); - break; - case 2: - ret = f.call(this, arguments[0], arguments[1]); - break; - - case 3: - ret = f.call(this, arguments[0], arguments[1], arguments[2]); - break; - default: - ret = f.apply(this, arguments); - } - meta.superMeta = orig; - return ret; - }; - wrapper._f = f; - return wrapper; - } else { - f._f = f; - return f; - } - } - - function defineMixinProps(child, proto) { - - var operations = proto.setters || {}, __setters = child.__setters__, __getters = child.__getters__; - for (var i in operations) { - if (!__setters.hasOwnProperty(i)) { //make sure that the setter isnt already there - __setters[i] = operations[i]; - } - } - operations = proto.getters || {}; - for (i in operations) { - if (!__getters.hasOwnProperty(i)) { //make sure that the setter isnt already there - __getters[i] = operations[i]; - } - } - for (var j in proto) { - if (j !== "getters" && j !== "setters") { - var p = proto[j]; - if ("function" === typeof p) { - if (!child.hasOwnProperty(j)) { - child[j] = functionWrapper(defaultFunction, j); - } - } else { - child[j] = p; - } - } - } - } - - function mixin() { - var args = argsToArray(arguments), l = args.length; - var child = this.prototype; - var childMeta = child.__meta, thisMeta = this.__meta, bases = child.__meta.bases, staticBases = bases.slice(), - staticSupers = thisMeta.supers || [], supers = childMeta.supers || []; - for (var i = 0; i < l; i++) { - var m = args[i], mProto = m.prototype; - var protoMeta = mProto.__meta, meta = m.__meta; - !protoMeta && (protoMeta = (mProto.__meta = {proto: mProto || {}})); - !meta && (meta = (m.__meta = {proto: m.__proto__ || {}})); - defineMixinProps(child, protoMeta.proto || {}); - defineMixinProps(this, meta.proto || {}); - //copy the bases for static, - - mixinSupers(m.prototype, supers, bases); - mixinSupers(m, staticSupers, staticBases); - } - return this; - } - - function mixinSupers(sup, arr, bases) { - var meta = sup.__meta; - !meta && (meta = (sup.__meta = {})); - var unique = sup.__meta.unique; - !unique && (meta.unique = "declare" + ++classCounter); - //check it we already have this super mixed into our prototype chain - //if true then we have already looped their supers! - if (indexOf(bases, unique) === -1) { - //add their id to our bases - bases.push(unique); - var supers = sup.__meta.supers || [], i = supers.length - 1 || 0; - while (i >= 0) { - mixinSupers(supers[i--], arr, bases); - } - arr.unshift(sup); - } - } - - function defineProps(child, proto) { - var operations = proto.setters, - __setters = child.__setters__, - __getters = child.__getters__; - if (operations) { - for (var i in operations) { - __setters[i] = operations[i]; - } - } - operations = proto.getters || {}; - if (operations) { - for (i in operations) { - __getters[i] = operations[i]; - } - } - for (i in proto) { - if (i != "getters" && i != "setters") { - var f = proto[i]; - if ("function" === typeof f) { - var meta = f.__meta || {}; - if (!meta.isConstructor) { - child[i] = functionWrapper(f, i); - } else { - child[i] = f; - } - } else { - child[i] = f; - } - } - } - - } - - function _export(obj, name) { - if (obj && name) { - obj[name] = this; - } else { - obj.exports = obj = this; - } - return this; - } - - function extend(proto) { - return declare(this, proto); - } - - function getNew(ctor) { - // create object with correct prototype using a do-nothing - // constructor - forceNew.prototype = ctor.prototype; - var t = new forceNew(); - forceNew.prototype = null; // clean up - return t; - } - - - function __declare(child, sup, proto) { - var childProto = {}, supers = []; - var unique = "declare" + ++classCounter, bases = [], staticBases = []; - var instanceSupers = [], staticSupers = []; - var meta = { - supers: instanceSupers, - unique: unique, - bases: bases, - superMeta: { - f: null, - pos: 0, - name: null - } - }; - var childMeta = { - supers: staticSupers, - unique: unique, - bases: staticBases, - isConstructor: true, - superMeta: { - f: null, - pos: 0, - name: null - } - }; - - if (isHash(sup) && !proto) { - proto = sup; - sup = Base; - } - - if ("function" === typeof sup || isArray(sup)) { - supers = isArray(sup) ? sup : [sup]; - sup = supers.shift(); - child.__meta = childMeta; - childProto = getNew(sup); - childProto.__meta = meta; - childProto.__getters__ = merge({}, childProto.__getters__ || {}); - childProto.__setters__ = merge({}, childProto.__setters__ || {}); - child.__getters__ = merge({}, child.__getters__ || {}); - child.__setters__ = merge({}, child.__setters__ || {}); - mixinSupers(sup.prototype, instanceSupers, bases); - mixinSupers(sup, staticSupers, staticBases); - } else { - child.__meta = childMeta; - childProto.__meta = meta; - childProto.__getters__ = childProto.__getters__ || {}; - childProto.__setters__ = childProto.__setters__ || {}; - child.__getters__ = child.__getters__ || {}; - child.__setters__ = child.__setters__ || {}; - } - child.prototype = childProto; - if (proto) { - var instance = meta.proto = proto.instance || {}; - var stat = childMeta.proto = proto.static || {}; - stat.init = stat.init || defaultFunction; - defineProps(childProto, instance); - defineProps(child, stat); - if (!instance.hasOwnProperty("constructor")) { - childProto.constructor = instance.constructor = functionWrapper(defaultFunction, "constructor"); - } else { - childProto.constructor = functionWrapper(instance.constructor, "constructor"); - } - } else { - meta.proto = {}; - childMeta.proto = {}; - child.init = functionWrapper(defaultFunction, "init"); - childProto.constructor = functionWrapper(defaultFunction, "constructor"); - } - if (supers.length) { - mixin.apply(child, supers); - } - if (sup) { - //do this so we mixin our super methods directly but do not ov - merge(child, merge(merge({}, sup), child)); - } - childProto._super = child._super = callSuper; - childProto._getSuper = child._getSuper = getSuper; - childProto._static = child; - } - - function declare(sup, proto) { - function declared() { - this.constructor.apply(this, arguments); - } - - __declare(declared, sup, proto); - return declared.init() || declared; - } - - function singleton(sup, proto) { - var retInstance; - - function declaredSingleton() { - if (!retInstance) { - this.constructor.apply(this, arguments); - retInstance = this; - } - return retInstance; - } - - __declare(declaredSingleton, sup, proto); - return declaredSingleton.init() || declaredSingleton; - } - - Base = declare({ - instance: { - "get": getter, - "set": setter - }, - - "static": { - "get": getter, - "set": setter, - mixin: mixin, - extend: extend, - as: _export - } - }); - - declare.singleton = singleton; - return declare; - } - - if ("undefined" !== typeof exports) { - if ("undefined" !== typeof module && module.exports) { - module.exports = createDeclared(); - } - } else if ("function" === typeof define && define.amd) { - define(createDeclared); - } else { - this.declare = createDeclared(); - } -}()); - - - - -},{}],62:[function(require,module,exports){ -module.exports = require("./declare.js"); -},{"./declare.js":61}],63:[function(require,module,exports){ -var Buffer=require("__browserify_Buffer").Buffer;(function () { - "use strict"; - - function defineIsa(extended) { - - var pSlice = Array.prototype.slice; - - var hasOwn = Object.prototype.hasOwnProperty; - var toStr = Object.prototype.toString; - - function argsToArray(args, slice) { - slice = slice || 0; - return pSlice.call(args, slice); - } - - function keys(obj) { - var ret = []; - for (var i in obj) { - if (hasOwn.call(obj, i)) { - ret.push(i); - } - } - return ret; - } - - //taken from node js assert.js - //https://github.com/joyent/node/blob/master/lib/assert.js - function deepEqual(actual, expected) { - // 7.1. All identical values are equivalent, as determined by ===. - if (actual === expected) { - return true; - - } else if (typeof Buffer !== "undefined" && Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) { - if (actual.length !== expected.length) { - return false; - } - for (var i = 0; i < actual.length; i++) { - if (actual[i] !== expected[i]) { - return false; - } - } - return true; - - // 7.2. If the expected value is a Date object, the actual value is - // equivalent if it is also a Date object that refers to the same time. - } else if (isDate(actual) && isDate(expected)) { - return actual.getTime() === expected.getTime(); - - // 7.3 If the expected value is a RegExp object, the actual value is - // equivalent if it is also a RegExp object with the same source and - // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`). - } else if (isRegExp(actual) && isRegExp(expected)) { - return actual.source === expected.source && - actual.global === expected.global && - actual.multiline === expected.multiline && - actual.lastIndex === expected.lastIndex && - actual.ignoreCase === expected.ignoreCase; - - // 7.4. Other pairs that do not both pass typeof value == 'object', - // equivalence is determined by ==. - } else if (isString(actual) && isString(expected) && actual !== expected) { - return false; - } else if (typeof actual !== 'object' && typeof expected !== 'object') { - return actual === expected; - - // 7.5 For all other Object pairs, including Array objects, equivalence is - // determined by having the same number of owned properties (as verified - // with Object.prototype.hasOwnProperty.call), the same set of keys - // (although not necessarily the same order), equivalent values for every - // corresponding key, and an identical 'prototype' property. Note: this - // accounts for both named and indexed properties on Arrays. - } else { - return objEquiv(actual, expected); - } - } - - - function objEquiv(a, b) { - var key; - if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) { - return false; - } - // an identical 'prototype' property. - if (a.prototype !== b.prototype) { - return false; - } - //~~~I've managed to break Object.keys through screwy arguments passing. - // Converting to array solves the problem. - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } - a = pSlice.call(a); - b = pSlice.call(b); - return deepEqual(a, b); - } - try { - var ka = keys(a), - kb = keys(b), - i; - // having the same number of owned properties (keys incorporates - // hasOwnProperty) - if (ka.length !== kb.length) { - return false; - } - //the same set of keys (although not necessarily the same order), - ka.sort(); - kb.sort(); - //~~~cheap key test - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] !== kb[i]) { - return false; - } - } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!deepEqual(a[key], b[key])) { - return false; - } - } - } catch (e) {//happens when one is a string literal and the other isn't - return false; - } - return true; - } - - - var isFunction = function (obj) { - return toStr.call(obj) === '[object Function]'; - }; - - //ie hack - if ("undefined" !== typeof window && !isFunction(window.alert)) { - (function (alert) { - isFunction = function (obj) { - return toStr.call(obj) === '[object Function]' || obj === alert; - }; - }(window.alert)); - } - - function isObject(obj) { - var undef; - return obj !== null && typeof obj === "object"; - } - - function isHash(obj) { - var ret = isObject(obj); - return ret && obj.constructor === Object && !obj.nodeType && !obj.setInterval; - } - - function isEmpty(object) { - if (isArguments(object)) { - return object.length === 0; - } else if (isObject(object)) { - return keys(object).length === 0; - } else if (isString(object) || isArray(object)) { - return object.length === 0; - } - return true; - } - - function isBoolean(obj) { - return obj === true || obj === false || toStr.call(obj) === "[object Boolean]"; - } - - function isUndefined(obj) { - return typeof obj === 'undefined'; - } - - function isDefined(obj) { - return !isUndefined(obj); - } - - function isUndefinedOrNull(obj) { - return isUndefined(obj) || isNull(obj); - } - - function isNull(obj) { - return obj === null; - } - - - var isArguments = function _isArguments(object) { - return toStr.call(object) === '[object Arguments]'; - }; - - if (!isArguments(arguments)) { - isArguments = function _isArguments(obj) { - return !!(obj && hasOwn.call(obj, "callee")); - }; - } - - - function isInstanceOf(obj, clazz) { - if (isFunction(clazz)) { - return obj instanceof clazz; - } else { - return false; - } - } - - function isRegExp(obj) { - return toStr.call(obj) === '[object RegExp]'; - } - - var isArray = Array.isArray || function isArray(obj) { - return toStr.call(obj) === "[object Array]"; - }; - - function isDate(obj) { - return toStr.call(obj) === '[object Date]'; - } - - function isString(obj) { - return toStr.call(obj) === '[object String]'; - } - - function isNumber(obj) { - return toStr.call(obj) === '[object Number]'; - } - - function isTrue(obj) { - return obj === true; - } - - function isFalse(obj) { - return obj === false; - } - - function isNotNull(obj) { - return !isNull(obj); - } - - function isEq(obj, obj2) { - /*jshint eqeqeq:false*/ - return obj == obj2; - } - - function isNeq(obj, obj2) { - /*jshint eqeqeq:false*/ - return obj != obj2; - } - - function isSeq(obj, obj2) { - return obj === obj2; - } - - function isSneq(obj, obj2) { - return obj !== obj2; - } - - function isIn(obj, arr) { - if ((isArray(arr) && Array.prototype.indexOf) || isString(arr)) { - return arr.indexOf(obj) > -1; - } else if (isArray(arr)) { - for (var i = 0, l = arr.length; i < l; i++) { - if (isEq(obj, arr[i])) { - return true; - } - } - } - return false; - } - - function isNotIn(obj, arr) { - return !isIn(obj, arr); - } - - function isLt(obj, obj2) { - return obj < obj2; - } - - function isLte(obj, obj2) { - return obj <= obj2; - } - - function isGt(obj, obj2) { - return obj > obj2; - } - - function isGte(obj, obj2) { - return obj >= obj2; - } - - function isLike(obj, reg) { - if (isString(reg)) { - return ("" + obj).match(reg) !== null; - } else if (isRegExp(reg)) { - return reg.test(obj); - } - return false; - } - - function isNotLike(obj, reg) { - return !isLike(obj, reg); - } - - function contains(arr, obj) { - return isIn(obj, arr); - } - - function notContains(arr, obj) { - return !isIn(obj, arr); - } - - function containsAt(arr, obj, index) { - if (isArray(arr) && arr.length > index) { - return isEq(arr[index], obj); - } - return false; - } - - function notContainsAt(arr, obj, index) { - if (isArray(arr)) { - return !isEq(arr[index], obj); - } - return false; - } - - function has(obj, prop) { - return hasOwn.call(obj, prop); - } - - function notHas(obj, prop) { - return !has(obj, prop); - } - - function length(obj, l) { - if (has(obj, "length")) { - return obj.length === l; - } - return false; - } - - function notLength(obj, l) { - if (has(obj, "length")) { - return obj.length !== l; - } - return false; - } - - var isa = { - isFunction: isFunction, - isObject: isObject, - isEmpty: isEmpty, - isHash: isHash, - isNumber: isNumber, - isString: isString, - isDate: isDate, - isArray: isArray, - isBoolean: isBoolean, - isUndefined: isUndefined, - isDefined: isDefined, - isUndefinedOrNull: isUndefinedOrNull, - isNull: isNull, - isArguments: isArguments, - instanceOf: isInstanceOf, - isRegExp: isRegExp, - deepEqual: deepEqual, - isTrue: isTrue, - isFalse: isFalse, - isNotNull: isNotNull, - isEq: isEq, - isNeq: isNeq, - isSeq: isSeq, - isSneq: isSneq, - isIn: isIn, - isNotIn: isNotIn, - isLt: isLt, - isLte: isLte, - isGt: isGt, - isGte: isGte, - isLike: isLike, - isNotLike: isNotLike, - contains: contains, - notContains: notContains, - has: has, - notHas: notHas, - isLength: length, - isNotLength: notLength, - containsAt: containsAt, - notContainsAt: notContainsAt - }; - - var tester = { - constructor: function () { - this._testers = []; - }, + } + if (isString(method)) { + return function () { + var func = scope[method]; + if (isFunction(func)) { + return spreadArgs(func, args.concat(argsToArray(arguments)), scope); + } else { + return func; + } + }; + } else { + if (args.length) { + return function () { + return spreadArgs(method, args.concat(argsToArray(arguments)), scope); + }; + } else { - noWrap: { - tester: function () { - var testers = this._testers; - return function tester(value) { - var isa = false; - for (var i = 0, l = testers.length; i < l && !isa; i++) { - isa = testers[i](value); - } - return isa; + return function () { + return spreadArgs(method, arguments, scope); }; } } - }; - - var switcher = { - constructor: function () { - this._cases = []; - this.__default = null; - }, + } - def: function (val, fn) { - this.__default = fn; - }, - noWrap: { - switcher: function () { - var testers = this._cases, __default = this.__default; - return function tester() { - var handled = false, args = argsToArray(arguments), caseRet; - for (var i = 0, l = testers.length; i < l && !handled; i++) { - caseRet = testers[i](args); - if (caseRet.length > 1) { - if (caseRet[1] || caseRet[0]) { - return caseRet[1]; - } - } - } - if (!handled && __default) { - return __default.apply(this, args); - } - }; - } + function applyFirst(method, args) { + args = argsToArray(arguments, 1); + if (!isString(method) && !isFunction(method)) { + throw new Error(method + " must be the name of a property or function to execute"); } - }; + if (isString(method)) { + return function () { + var scopeArgs = argsToArray(arguments), scope = scopeArgs.shift(); + var func = scope[method]; + if (isFunction(func)) { + scopeArgs = args.concat(scopeArgs); + return spreadArgs(func, scopeArgs, scope); + } else { + return func; + } + }; + } else { + return function () { + var scopeArgs = argsToArray(arguments), scope = scopeArgs.shift(); + scopeArgs = args.concat(scopeArgs); + return spreadArgs(method, scopeArgs, scope); + }; + } + } - function addToTester(func) { - tester[func] = function isaTester() { - this._testers.push(isa[func]); - }; + + function hitchIgnore(scope, method, args) { + args = argsToArray(arguments, 2); + if ((isString(method) && !(method in scope))) { + throw new Error(method + " property not defined in scope"); + } else if (!isString(method) && !isFunction(method)) { + throw new Error(method + " is not a function"); + } + if (isString(method)) { + return function () { + var func = scope[method]; + if (isFunction(func)) { + return spreadArgs(func, args, scope); + } else { + return func; + } + }; + } else { + return function () { + return spreadArgs(method, args, scope); + }; + } } - function addToSwitcher(func) { - switcher[func] = function isaTester() { - var args = argsToArray(arguments, 1), isFunc = isa[func], handler, doBreak = true; - if (args.length <= isFunc.length - 1) { - throw new TypeError("A handler must be defined when calling using switch"); - } else { - handler = args.pop(); - if (isBoolean(handler)) { - doBreak = handler; - handler = args.pop(); + + function hitchAll(scope) { + var funcs = argsToArray(arguments, 1); + if (!isObject(scope) && !isFunction(scope)) { + throw new TypeError("scope must be an object"); + } + if (funcs.length === 1 && isArray(funcs[0])) { + funcs = funcs[0]; + } + if (!funcs.length) { + funcs = []; + for (var k in scope) { + if (scope.hasOwnProperty(k) && isFunction(scope[k])) { + funcs.push(k); } } - if (!isFunction(handler)) { - throw new TypeError("handler must be defined"); - } - this._cases.push(function (testArgs) { - if (isFunc.apply(isa, testArgs.concat(args))) { - return [doBreak, handler.apply(this, testArgs)]; + } + for (var i = 0, l = funcs.length; i < l; i++) { + scope[funcs[i]] = hitch(scope, scope[funcs[i]]); + } + return scope; + } + + + function partial(method, args) { + args = argsToArray(arguments, 1); + if (!isString(method) && !isFunction(method)) { + throw new Error(method + " must be the name of a property or function to execute"); + } + if (isString(method)) { + return function () { + var func = this[method]; + if (isFunction(func)) { + var scopeArgs = args.concat(argsToArray(arguments)); + return spreadArgs(func, scopeArgs, this); + } else { + return func; } - return [false]; - }); + }; + } else { + return function () { + var scopeArgs = args.concat(argsToArray(arguments)); + return spreadArgs(method, scopeArgs, this); + }; + } + } + + function curryFunc(f, execute) { + return function () { + var args = argsToArray(arguments); + return execute ? spreadArgs(f, arguments, this) : function () { + return spreadArgs(f, args.concat(argsToArray(arguments)), this); + }; }; } - for (var i in isa) { - if (hasOwn.call(isa, i)) { - addToSwitcher(i); - addToTester(i); + + function curry(depth, cb, scope) { + var f; + if (scope) { + f = hitch(scope, cb); + } else { + f = cb; + } + if (depth) { + var len = depth - 1; + for (var i = len; i >= 0; i--) { + f = curryFunc(f, i === len); + } } + return f; } - var is = extended.define(isa).expose(isa); - is.tester = extended.define(tester); - is.switcher = extended.define(switcher); - return is; + return extended + .define(isObject, { + bind: hitch, + bindAll: hitchAll, + bindIgnore: hitchIgnore, + curry: function (scope, depth, fn) { + return curry(depth, fn, scope); + } + }) + .define(isFunction, { + bind: function (fn, obj) { + return spreadArgs(hitch, [obj, fn].concat(argsToArray(arguments, 2)), this); + }, + bindIgnore: function (fn, obj) { + return spreadArgs(hitchIgnore, [obj, fn].concat(argsToArray(arguments, 2)), this); + }, + partial: partial, + applyFirst: applyFirst, + curry: function (fn, num, scope) { + return curry(num, fn, scope); + }, + noWrap: { + f: function () { + return this.value(); + } + } + }) + .define(isString, { + bind: function (str, scope) { + return hitch(scope, str); + }, + bindIgnore: function (str, scope) { + return hitchIgnore(scope, str); + }, + partial: partial, + applyFirst: applyFirst, + curry: function (fn, depth, scope) { + return curry(depth, fn, scope); + } + }) + .expose({ + bind: hitch, + bindAll: hitchAll, + bindIgnore: hitchIgnore, + partial: partial, + applyFirst: applyFirst, + curry: curry + }); } if ("undefined" !== typeof exports) { if ("undefined" !== typeof module && module.exports) { - module.exports = defineIsa(require("extended")); + module.exports = defineFunction(require("extended"), require("is-extended"), require("arguments-extended")); } } else if ("function" === typeof define && define.amd) { - define(["extended"], function (extended) { - return defineIsa(extended); + define(["extended", "is-extended", "arguments-extended"], function (extended, is, args) { + return defineFunction(extended, is, args); }); } else { - this.isExtended = defineIsa(this.extended); + this.functionExtended = defineFunction(this.extended, this.isExtended, this.argumentsExtended); } }).call(this); -},{"__browserify_Buffer":67,"extended":58}],64:[function(require,module,exports){ + + + + + +},{"arguments-extended":51,"extended":56,"is-extended":66}],60:[function(require,module,exports){ var process=require("__browserify_process");if (!process.EventEmitter) process.EventEmitter = function () {}; var EventEmitter = exports.EventEmitter = process.EventEmitter; @@ -12015,10 +10374,10 @@ EventEmitter.listenerCount = function(emitter, type) { return ret; }; -},{"__browserify_process":68}],65:[function(require,module,exports){ +},{"__browserify_process":64}],61:[function(require,module,exports){ // nothing to see here... no file methods for the browser -},{}],66:[function(require,module,exports){ +},{}],62:[function(require,module,exports){ var process=require("__browserify_process");function filter (xs, fn) { var res = []; for (var i = 0; i < xs.length; i++) { @@ -12197,7 +10556,7 @@ exports.relative = function(from, to) { exports.sep = '/'; -},{"__browserify_process":68}],67:[function(require,module,exports){ +},{"__browserify_process":64}],63:[function(require,module,exports){ require=(function(e,t,n,r){function i(r){if(!n[r]){if(!t[r]){if(e)return e(r);throw new Error("Cannot find module '"+r+"'")}var s=n[r]={exports:{}};t[r][0](function(e){var n=t[r][1][e];return i(n?n:e)},s,s.exports)}return n[r].exports}for(var s=0;sc&&g>c&&c++;);var h=d[c]-e[c];return h||(h=f-g),h}function g(a,b){return a.recency-b.recency}var h=a("./extended").map,i={salience:d,bucketCounter:e,factRecency:f,activationRecency:g};c.strategies=i,c.strategy=function(a){a=h(a,function(a){return i[a]});var b=a.length;return function(c,d){var e=-1,f=0,g=c===d||c.name===d.name&&c.hashCode===d.hashCode;if(!g){for(;++e0?1:-1}return f}}},{"./extended":12}],8:[function(a,b,c){"use strict";var d,e=a("./extended"),f=e.deepEqual,g=e.merge,h=e.instanceOf,i=e.filter,j=e.declare,k=0,l=j({type:null,instance:{constructor:function(b){d||(d=a("./constraintMatcher")),this.id=k++,this.constraint=b,e.bindAll(this,["assert"])},assert:function(){throw new Error("not implemented")},getIndexableProperties:function(){return[]},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return[this.get("alias")]}}}});l.extend({instance:{type:"object",constructor:function(a){this._super([a])},assert:function(a){return a instanceof this.constraint||a.constructor===this.constraint},equal:function(a){return h(a,this._static)&&this.constraint===a.constraint}}}).as(c,"ObjectConstraint");var m=l.extend({instance:{type:"equality",constructor:function(a,b){this._super([a]),b=b||{},this.pattern=b.pattern,this._matcher=d.getMatcher(a,b,!0)},assert:function(a){return this._matcher(a)}}}).as(c,"EqualityConstraint");m.extend({instance:{type:"inequality"}}).as(c,"InequalityConstraint"),m.extend({instance:{type:"comparison"}}).as(c,"ComparisonConstraint"),l.extend({instance:{type:"equality",constructor:function(){this._super([[!0]])},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")},assert:function(){return!0}}}).as(c,"TrueConstraint");var n=l.extend({instance:{type:"reference",constructor:function(a,b){this.cache={},this._super([a]),b=b||{},this.values=[],this.pattern=b.pattern,this._options=b,this._matcher=d.getMatcher(a,b,!1)},assert:function(a,b){try{return this._matcher(a,b)}catch(c){throw new Error("Error with evaluating pattern "+this.pattern+" "+c.message)}},merge:function(a){var b=this;return a instanceof n&&(b=new this._static([this.constraint,a.constraint,"and"],g({},this._options,this._options)),b._alias=this._alias||a._alias,b.vars=this.vars.concat(a.vars)),b},equal:function(a){return h(a,this._static)&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return this.vars},alias:function(){return this._alias}},setters:{alias:function(a){this._alias=a,this.vars=i(d.getIdentifiers(this.constraint),function(b){return b!==a})}}}}).as(c,"ReferenceConstraint");n.extend({instance:{type:"reference_equality",op:"eq",getIndexableProperties:function(){return d.getIndexableProperties(this.constraint)}}}).as(c,"ReferenceEqualityConstraint").extend({instance:{type:"reference_inequality",op:"neq"}}).as(c,"ReferenceInequalityConstraint"),l.extend({instance:{type:"hash",constructor:function(a){this._super([a])},equal:function(a){return e.instanceOf(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},assert:function(){return!0},getters:{variables:function(){return this.constraint}}}}).as(c,"HashConstraint"),l.extend({instance:{constructor:function(a,b){this.type="from",this.constraints=d.getSourceMatcher(a,b||{},!0),e.bindAll(this,["assert"])},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")&&f(this.constraints,a.constraints)},assert:function(a,b){return this.constraints(a,b)},getters:{variables:function(){return this.constraint}}}}).as(c,"FromConstraint")},{"./constraintMatcher":9,"./extended":12}],9:[function(a,b,c){"use strict";function d(a){return e(a).map(function(a){return f(a)?f(a[0])?d(a).value():a.reverse().join("."):a}).flatten().filter(function(a){return!!a})}var e=a("./extended"),f=e.isArray,g=e.forEach,h=e.some,i=e.indexOf,j=e.isNumber,k=e.removeDuplicates,l=a("./constraint"),m={indexOf:e.indexOf,now:function(){return new Date},Date:function(a,b,c,d,e,f,g){var h=new Date;return j(a)&&h.setYear(a),j(b)&&h.setMonth(b),j(c)&&h.setDate(c),j(d)&&h.setHours(d),j(e)&&h.setMinutes(e),j(f)&&h.setSeconds(f),j(g)&&h.setMilliseconds(g),h},lengthOf:function(a,b){return a.length===b},isTrue:function(a){return a===!0},isFalse:function(a){return a===!1},isNotNull:function(a){return null!==a},dateCmp:function(a,b){return e.compare(a,b)}};g(["years","days","months","hours","minutes","seconds"],function(a){m[a+"FromNow"]=e[a+"FromNow"],m[a+"Ago"]=e[a+"Ago"]}),g(["isArray","isNumber","isHash","isObject","isDate","isBoolean","isString","isRegExp","isNull","isEmpty","isUndefined","isDefined","isUndefinedOrNull","isPromiseLike","isFunction","deepEqual"],function(a){var b=e[a];m[a]=function(){return b.apply(e,arguments)}});var n={equal:function(a,b){var c=!1;return a===b?c=!0:a[2]===b[2]&&(c=-1!==i(["string","number","boolean","regexp","identifier","null"],a[2])?a[0]===b[0]:"unary"===a[2]||"logicalNot"===a[2]?this.equal(a[0],b[0]):this.equal(a[0],b[0])&&this.equal(a[1],b[1])),c},__getProperties:function(a){var b=[];if(a){var c=a[2];if(!c)return b;"prop"!==c&&"identifier"!==c&&"string"!==c&&"number"!==c&&"boolean"!==c&&"regexp"!==c&&"unary"!==c&&"unary"!==c?(b[0]=this.__getProperties(a[0]),b[1]=this.__getProperties(a[1])):b="identifier"===c?[a[0]]:n.__getProperties(a[1]).concat(n.__getProperties(a[0]))}return b},getIndexableProperties:function(a){return"composite"===a[2]?this.getIndexableProperties(a[0]):/^(\w+(\['[^']*'])*) *[!=]== (\w+(\['[^']*'])*)$/.test(this.parse(a))?d(this.__getProperties(a)).flatten().value():[]},getIdentifiers:function(a){var b=[],c=a[2];if("identifier"===c)return[a[0]];if("function"===c)b=b.concat(this.getIdentifiers(a[0])).concat(this.getIdentifiers(a[1]));else if("string"!==c&&"number"!==c&&"boolean"!==c&&"regexp"!==c&&"unary"!==c&&"unary"!==c)if("prop"===c){if(b=b.concat(this.getIdentifiers(a[0])),a[1])for(var d=a[1];f(d);){if("function"===d[2]){b=b.concat(this.getIdentifiers(d[1]));break}d=d[1]}}else a[0]&&(b=b.concat(this.getIdentifiers(a[0]))),a[1]&&(b=b.concat(this.getIdentifiers(a[1])));return k(b)},toConstraints:function(a,b){var c=[],d=b.alias,e=b.scope||{},f=a[2];if("and"===f)c=c.concat(this.toConstraints(a[0],b)).concat(this.toConstraints(a[1],b));else if("composite"===f||"or"===f||"lt"===f||"gt"===f||"lte"===f||"gte"===f||"like"===f||"notLike"===f||"eq"===f||"neq"===f||"in"===f||"notIn"===f||"prop"===f||"propLookup"===f||"function"===f||"logicalNot"===f){var g=h(this.getIdentifiers(a),function(a){return!(a===d||a in m||a in e)});"eq"===f?c.push(new l[g?"ReferenceEqualityConstraint":"EqualityConstraint"](a,b)):"neq"===f?c.push(new l[g?"ReferenceInequalityConstraint":"InequalityConstraint"](a,b)):c.push(new l[g?"ReferenceConstraint":"ComparisonConstraint"](a,b))}return c},parse:function(a){return this[a[2]](a[0],a[1])},composite:function(a){return this.parse(a)},and:function(a,b){return["(",this.parse(a),"&&",this.parse(b),")"].join(" ")},or:function(a,b){return["(",this.parse(a),"||",this.parse(b),")"].join(" ")},prop:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"['",this.parse(b),"']"].join("")},propLookup:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"[",this.parse(b),"]"].join("")},unary:function(a){return-1*this.parse(a)},plus:function(a,b){return[this.parse(a),"+",this.parse(b)].join(" ")},minus:function(a,b){return[this.parse(a),"-",this.parse(b)].join(" ")},mult:function(a,b){return[this.parse(a),"*",this.parse(b)].join(" ")},div:function(a,b){return[this.parse(a),"/",this.parse(b)].join(" ")},mod:function(a,b){return[this.parse(a),"%",this.parse(b)].join(" ")},lt:function(a,b){return[this.parse(a),"<",this.parse(b)].join(" ")},gt:function(a,b){return[this.parse(a),">",this.parse(b)].join(" ")},lte:function(a,b){return[this.parse(a),"<=",this.parse(b)].join(" ")},gte:function(a,b){return[this.parse(a),">=",this.parse(b)].join(" ")},like:function(a,b){return[this.parse(b),".test(",this.parse(a),")"].join("")},notLike:function(a,b){return["!",this.parse(b),".test(",this.parse(a),")"].join("")},eq:function(a,b){return[this.parse(a),"===",this.parse(b)].join(" ")},neq:function(a,b){return[this.parse(a),"!==",this.parse(b)].join(" ")},"in":function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) != -1"].join("")},notIn:function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) == -1"].join("")},arguments:function(a,b){var c=[];return a&&c.push(this.parse(a)),b&&c.push(this.parse(b)),c.join(",")},array:function(a){var b=[];return a?(b=this.parse(a),f(b)?b:["[",b,"]"].join("")):["[",b.join(","),"]"].join("")},"function":function(a,b){var c=this.parse(b);return[this.parse(a),"(",c,")"].join("")},string:function(a){return"'"+a+"'"},number:function(a){return a},"boolean":function(a){return a},regexp:function(a){return a},identifier:function(a){return a},"null":function(){return"null"},logicalNot:function(a){return["!(",this.parse(a),")"].join("")}},o=0,p=c.toJs=function(a,b,c,d,f){var g=n.parse(a);b=b||{};var h=n.getIdentifiers(a),i=["var indexOf = definedFuncs.indexOf; var hasOwnProperty = Object.prototype.hasOwnProperty;"],j=[];e(h).filter(function(a){var c=["var ",a," = "];if(m.hasOwnProperty(a))c.push("definedFuncs['",a,"']");else{if(!b.hasOwnProperty(a))return!0;c.push("scope['",a,"']")}return c.push(";"),i.push(c.join("")),!1}).forEach(function(a){var b=["var ",a," = "];d||a!==c?b.push("fact."+a):a===c&&b.push("hash.",a,""),b.push(";"),j.push(b.join(""))});var k=i.join("")+"return function matcher"+o++ +(d?"(fact){":"(fact, hash){")+j.join("")+" return "+(f?f(g):g)+";}",l=new Function("definedFuncs, scope",k)(m,b);return l};c.getMatcher=function(a,b,c){return b=b||{},p(a,b.scope,b.alias,c,function(a){return"!!("+a+")"})},c.getSourceMatcher=function(a,b,c){return b=b||{},p(a,b.scope,b.alias,c,function(a){return a})},c.toConstraints=function(a,b){return n.toConstraints(a,b)},c.equal=function(a,b){return n.equal(a,b)},c.getIdentifiers=function(a){return n.getIdentifiers(a)},c.getIndexableProperties=function(a){return n.getIndexableProperties(a)}},{"./constraint":8,"./extended":12}],10:[function(a,b){"use strict";function c(a,b){for(var c=[],d=-1,e=a.length;++di){for(f=a.slice();++gb;b++)a.assert(arguments[b]);return a},containsRule:function(a){return c.some(this.__rules,function(b){return b.name===a})}},"static":{getFlow:function(a){return l[a]},hasFlow:function(a){return c.has(l,a)},deleteFlow:function(a){return d(a,m)&&(a=a.name),delete l[a],m},deleteFlows:function(){for(var a in l)a in l&&delete l[a];return m},create:function(a,b){return new m(a,b)}}}).as(b)},{"./conflict":7,"./extended":12,"./flow":13,"./pattern":45,"./rule":46}],15:[function(a,b,c){"use strict";function d(a){return/\.nools$/.test(a)}function e(a){var b;return b=d(a)?i.parse(g.readFileSync(a,"utf8"),a):i.parse(a)}var f=a("./extended"),g=a("fs"),h=a("path"),i=a("./compile"),j=a("./flowContainer");c.Flow=j,c.getFlow=j.getFlow,c.hasFlow=j.hasFlow,c.deleteFlow=function(a){return j.deleteFlow(a),this},c.deleteFlows=function(){return j.deleteFlows(),this},c.flow=j.create,c.compile=function(a,b,c){if(f.isFunction(b)?(c=b,b={}):(b=b||{},c=null),f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),!b.name)throw new Error("Name required when compiling nools source");return i.compile(a,b,c,j)},c.transpile=function(a,b){return b=b||{},f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),i.transpile(a,b)},c.parse=e},{"./compile":5,"./extended":12,"./flowContainer":14,fs:65,path:66}],16:[function(a,b){var c=a("declare.js");c({instance:{constructor:function(){this.head=null,this.tail=null,this.length=null},push:function(a){var b=this.tail,c=this.head,d={data:a,prev:b,next:null};return b&&(this.tail.next=d),this.tail=d,c||(this.head=d),this.length++,d},remove:function(a){a.prev?a.prev.next=a.next:this.head=a.next,a.next?a.next.prev=a.prev:this.tail=a.prev,this.length--},forEach:function(a){for(var b={next:this.head};b=b.next;)a(b.data)},toArray:function(){for(var a={next:this.head},b=[];a=a.next;)b.push(a);return b},removeByData:function(a){for(var b={next:this.head};b=b.next;)if(b.data===a){this.remove(b);break}},getByData:function(a){for(var b={next:this.head};b=b.next;)if(b.data===a)return b},clear:function(){this.head=this.tail=null,this.length=0}}}).as(b)},{"declare.js":52}],17:[function(a,b){var c,d=a("__browserify_process"),e=a("./extended");if("function"==typeof setImmediate)c="undefined"!=typeof window?e.bind(window,setImmediate):setImmediate;else if("undefined"!=typeof d)c=d.nextTick;else if("undefined"!=typeof MessageChannel){var f=new MessageChannel,g={},h=g;f.port1.onmessage=function(){g=g.next;var a=g.task;delete g.task,a()},c=function(a){h=h.next={task:a},f.port2.postMessage(0)}}else c=function(a){setTimeout(a,0)};b.exports=c},{"./extended":12,__browserify_process:68}],18:[function(a,b){var c=a("./node"),d=a("../extended").intersection,e=a("../context");c.extend({instance:{__propagatePaths:function(a,b){for(var c,f,g,h,i=this.__entrySet,j=i.length;--j>-1;)c=i[j],f=c.key,g=c.value,(h=d(g,b.paths)).length&&f[a](new e(b.fact,h,b.match))},__propagateNoPaths:function(a,b){for(var c=this.__entrySet,d=c.length;--d>-1;)c[d].key[a](b)},__propagate:function(a,b){b.paths?this.__propagatePaths(a,b):this.__propagateNoPaths(a,b)}}}).as(b)},{"../context":10,"../extended":12,"./node":34}],19:[function(a,b){var c=a("./alphaNode");c.extend({instance:{constructor:function(){this._super(arguments),this.alias=this.constraint.get("alias")},toString:function(){return"AliasNode"+this.__count -},assert:function(a){return this.__propagate("assert",a.set(this.alias,a.fact.object))},modify:function(a){return this.__propagate("modify",a.set(this.alias,a.fact.object))},retract:function(a){return this.__propagate("retract",a.set(this.alias,a.fact.object))},equal:function(a){return a instanceof this._static&&this.alias===a.alias}}}).as(b)},{"./alphaNode":20}],20:[function(a,b){"use strict";var c=a("./node");c.extend({instance:{constructor:function(a){this._super([]),this.constraint=a,this.constraintAssert=this.constraint.assert},toString:function(){return"AlphaNode "+this.__count},equal:function(a){return this.constraint.equal(a.constraint)}}}).as(b)},{"./node":34}],21:[function(a,b){var c=a("../extended"),d=c.hash.values,e=c.hash.keys,f=a("./node"),g=a("./misc/leftMemory"),h=a("./misc/rightMemory");f.extend({instance:{nodeType:"BetaNode",constructor:function(){this._super([]),this.leftMemory={},this.rightMemory={},this.leftTuples=new g,this.rightTuples=new h},__propagate:function(a,b){for(var c,d,e=this.__entrySet,f=e.length;--f>-1;)c=e[f],d=c.key,d[a](b)},dispose:function(){this.leftMemory={},this.rightMemory={},this.leftTuples.clear(),this.rightTuples.clear()},disposeLeft:function(a){this.leftMemory={},this.leftTuples.clear(),this.propagateDispose(a)},disposeRight:function(a){this.rightMemory={},this.rightTuples.clear(),this.propagateDispose(a)},hashCode:function(){return this.nodeType+" "+this.__count},toString:function(){return this.nodeType+" "+this.__count},retractLeft:function(a){a=this.removeFromLeftMemory(a).data;for(var b=d(a.rightMatches),c=-1,e=b.length;++ch;h++)if(this.__isMatch(a,e[h],!0)){a.blocked=!0;break}}else f(e)&&(a.blocked=this.__isMatch(a,e,!0));var j=a.blocked;j?c?this.__propagate("modify",a.clone()):this.__propagate("assert",a.clone()):c&&this.__propagate("retract",a.clone())},__findMatches:function(a){var b=a.factHash,c=this.from(b),d=!1;if(g(c)){for(var e=0,h=c.length;h>e;e++)if(this.__isMatch(a,c[e],!0))return a.blocked=!0,this.__propagate("assert",a.clone()),void 0}else f(c)&&this.__isMatch(a,c,!0)&&(a.blocked=!0,this.__propagate("assert",a.clone()));return d},__isMatch:function(a,b,c){var d=!1;if(this.type(b)){var f=this.workingMemory.getFactHandle(b),g=new e(f,null).mergeMatch(a.match).set(this.alias,b);if(c){var h=this.fromMemory[f.id];h||(h=this.fromMemory[f.id]={}),h[a.hashCode]=a}for(var i=g.factHash,j=this.__equalityConstraints,k=0,l=j.length;l>k;k++){if(!j[k](i)){d=!1;break}d=!0}}return d},assertLeft:function(a){this.__addToLeftMemory(a),this.__findMatches(a)}}}).as(b)},{"../context":10,"../extended":12,"./fromNotNode":26}],24:[function(a,b){var c=a("./notNode"),d=a("../linkedList");c.extend({instance:{nodeType:"ExistsNode",blockedContext:function(a,b){a.blocker=b,this.removeFromLeftMemory(a),this.addToLeftBlockedMemory(b.blocking.push(a)),this.__propagate("assert",this.__cloneContext(a))},notBlockedContext:function(a,b){this.__addToLeftMemory(a),b&&this.__propagate("retract",this.__cloneContext(a))},propagateFromLeft:function(a){this.notBlockedContext(a,!1)},retractLeft:function(a){var b;if(!this.removeFromLeftMemory(a)){if(!(b=this.removeFromLeftBlockedMemory(a)))throw new Error;this.__propagate("retract",this.__cloneContext(b.data))}},modifyLeft:function(a){var b,c,d,e,f=this.removeFromLeftMemory(a),g=this.constraint,h=this.rightTuples,i=h.length,j=!1;if(f||(f=this.removeFromLeftBlockedMemory(a),j=!0),!f)throw new Error;if(b=f.data,b&&b.blocker&&(e=this.rightMemory[b.blocker.hashCode]),e?(g.isMatch(a,d=e.data)&&(this.__propagate(j?"modify":"assert",this.__cloneContext(b)),a.blocker=d,this.addToLeftBlockedMemory(d.blocking.push(a)),a=null),a&&(c={next:e.next})):c={next:h.head},a&&i)for(c={next:h.head};c=c.next;)if(g.isMatch(a,d=c.data)){this.__propagate(j?"modify":"assert",this.__cloneContext(b)),this.addToLeftBlockedMemory(d.blocking.push(a)),a.blocker=d,a=null;break}a&&(this.__addToLeftMemory(a),j&&this.__propagate("retract",this.__cloneContext(a)))},modifyRight:function(a){var b=this.removeFromRightMemory(a);if(!b)throw new Error;var c,e,f=b.data,g=this.leftTuples,h=g.length,i=this.constraint,j=f.blocking;if(this.__addToRightMemory(a),a.blocking=new d,h||j.length){if(j.length)for(var k,l={next:j.head};l=l.next;)if(c=l.data,c.blocker=null,i.isMatch(c,a))c.blocker=a,this.addToLeftBlockedMemory(a.blocking.push(c)),this.__propagate("assert",this.__cloneContext(c)),c=null;else{for(c.blocker=null,e=b;e=e.next;)if(i.isMatch(c,k=e.data)){c.blocker=k,this.addToLeftBlockedMemory(k.blocking.push(c)),this.__propagate("assert",this.__cloneContext(c)),c=null;break}c&&this.__addToLeftMemory(c)}if(h)for(e={next:g.head};e=e.next;)c=e.data,i.isMatch(c,a)&&(this.__propagate("assert",this.__cloneContext(c)),this.removeFromLeftMemory(c),this.addToLeftBlockedMemory(a.blocking.push(c)),c.blocker=a)}}}}).as(b)},{"../linkedList":16,"./notNode":35}],25:[function(a,b){var c=a("./joinNode"),d=a("../extended"),e=a("../constraint"),f=e.EqualityConstraint,g=e.HashConstraint,h=e.ReferenceConstraint,i=a("../context"),j=d.isDefined,k=d.isEmpty,l=d.forEach,m=d.isArray,n={isMatch:function(){return!1}};c.extend({instance:{nodeType:"FromNode",constructor:function(a,b){this._super(arguments),this.workingMemory=b,this.fromMemory={},this.pattern=a,this.type=a.get("constraints")[0].assert,this.alias=a.get("alias"),this.from=a.from.assert;var c=this.__equalityConstraints=[],d=[];l(this.constraints=this.pattern.get("constraints").slice(1),function(a){a instanceof f||a instanceof h?c.push(a.assert):a instanceof g&&(d=d.concat(a.get("variables")))}),this.__variables=d},__createMatches:function(a){var b=a.factHash,c=this.from(b);if(m(c))for(var d=0,e=c.length;e>d;d++)this.__checkMatch(a,c[d],!0);else j(c)&&this.__checkMatch(a,c,!0)},__checkMatch:function(a,b,c){var d;return(d=this.__createMatch(a,b)).isMatch()&&c&&this.__propagate("assert",d.clone()),d},__createMatch:function(a,b){if(this.type(b)){var c,d=this.workingMemory.getFactHandle(b,!0),e=new i(d).set(this.alias,b),f=d.id,g=e.factHash,h=a.factHash;for(var j in h)g[j]=h[j];for(var k=this.__equalityConstraints,l=this.__variables,m=-1,o=k.length;++mc;c++)b=this.__checkMatch(a,l[c],!1),b.isMatch()&&(e=b.fact.id,e in k?this.__propagate("modify",b.clone()):this.__propagate("assert",b.clone()));else j(l)&&(b=this.__checkMatch(a,l,!1),b.isMatch()&&(e=b.fact.id,e in k?this.__propagate("modify",b.clone()):this.__propagate("assert",b.clone())));for(c in k)c in i||(this.removeFromFromMemory(k[c]),this.__propagate("retract",k[c].clone()))}else this.assertLeft(a);f=a.fact,e=f.id;var n=this.fromMemory[e];if(this.fromMemory[e]={},n){var o,p,q,r,s=f.object;for(c in n)p=n[c],o=p[0],q=p[1],r=q.isMatch(),o.hashCode!==a.hashCode&&(b=this.__createMatch(o,s,!1),r&&this.__propagate("retract",q.clone()),b.isMatch()&&this.__propagate(r?"modify":"assert",b.clone()))}},assertLeft:function(a){this.__addToLeftMemory(a),a.fromMatches={},this.__createMatches(a)},assertRight:function(){throw new Error("Shouldnt have gotten here")}}}).as(b)},{"../constraint":8,"../context":10,"../extended":12,"./joinNode":28}],26:[function(a,b){var c=a("./joinNode"),d=a("../extended"),e=a("../constraint"),f=e.EqualityConstraint,g=e.HashConstraint,h=e.ReferenceConstraint,i=a("../context"),j=d.isDefined,k=d.forEach,l=d.isArray;c.extend({instance:{nodeType:"FromNotNode",constructor:function(a,b){this._super(arguments),this.workingMemory=b,this.pattern=a,this.type=a.get("constraints")[0].assert,this.alias=a.get("alias"),this.from=a.from.assert,this.fromMemory={};var c=this.__equalityConstraints=[],d=[];k(this.constraints=this.pattern.get("constraints").slice(1),function(a){a instanceof f||a instanceof h?c.push(a.assert):a instanceof g&&(d=d.concat(a.get("variables")))}),this.__variables=d},retractLeft:function(a){var b=this.removeFromLeftMemory(a);b&&(b=b.data,b.blocked||this.__propagate("retract",b.clone()))},__modify:function(a,b){var c=b.blocked,d=a.factHash,e=this.from(d);if(l(e)){for(var f=0,g=e.length;g>f;f++)if(this.__isMatch(a,e[f],!0)){a.blocked=!0;break}}else j(e)&&(a.blocked=this.__isMatch(a,e,!0));var h=a.blocked;h?c||this.__propagate("retract",b.clone()):c?this.__propagate("assert",a.clone()):this.__propagate("modify",a.clone())},modifyLeft:function(a){var b=this.removeFromLeftMemory(a);if(!b)throw new Error;this.__addToLeftMemory(a),this.__modify(a,b.data);var c=this.fromMemory[a.fact.id];if(this.fromMemory[a.fact.id]={},c)for(var d in c)if(d!==a.hashCode){var e=c[d];b=this.removeFromLeftMemory(e),b&&(e=e.clone(),e.blocked=!1,this.__addToLeftMemory(e),this.__modify(e,b.data))}},__findMatches:function(a){var b=a.factHash,c=this.from(b),d=!1;if(l(c)){for(var e=0,f=c.length;f>e;e++)if(this.__isMatch(a,c[e],!0))return a.blocked=!0,void 0;this.__propagate("assert",a.clone())}else j(c)&&!(a.blocked=this.__isMatch(a,c,!0))&&this.__propagate("assert",a.clone());return d},__isMatch:function(a,b,c){var d=!1;if(this.type(b)){var e=this.workingMemory.getFactHandle(b),f=new i(e,null).mergeMatch(a.match).set(this.alias,b);if(c){var g=this.fromMemory[e.id];g||(g=this.fromMemory[e.id]={}),g[a.hashCode]=a}for(var h=f.factHash,j=this.__equalityConstraints,k=0,l=j.length;l>k;k++){if(!j[k](h,h)){d=!1;break}d=!0}}return d},assertLeft:function(a){this.__addToLeftMemory(a),this.__findMatches(a)},assertRight:function(){throw new Error("Shouldnt have gotten here")},retractRight:function(){throw new Error("Shouldnt have gotten here")}}}).as(b)},{"../constraint":8,"../context":10,"../extended":12,"./joinNode":28}],27:[function(a,b,c){"use strict";function d(a){return g(a.constraints||[],function(a){return a instanceof t})}var e=a("../extended"),f=e.forEach,g=e.some,h=e.declare,i=a("../pattern.js"),j=i.ObjectPattern,k=i.FromPattern,l=i.FromNotPattern,m=i.ExistsPattern,n=i.FromExistsPattern,o=i.NotPattern,p=i.CompositePattern,q=i.InitialFactPattern,r=a("../constraint"),s=r.HashConstraint,t=r.ReferenceConstraint,u=a("./aliasNode"),v=a("./equalityNode"),w=a("./joinNode"),x=a("./betaNode"),y=a("./notNode"),z=a("./fromNode"),A=a("./fromNotNode"),B=a("./existsNode"),C=a("./existsFromNode"),D=a("./leftAdapterNode"),E=a("./rightAdapterNode"),F=a("./typeNode"),G=a("./terminalNode"),H=a("./propertyNode");h({instance:{constructor:function(a,b){this.terminalNodes=[],this.joinNodes=[],this.nodes=[],this.constraints=[],this.typeNodes=[],this.__ruleCount=0,this.bucket={counter:0,recency:0},this.agendaTree=b,this.workingMemory=a},assertRule:function(a){var b=new G(this.bucket,this.__ruleCount++,a,this.agendaTree);this.__addToNetwork(a,a.pattern,b),this.__mergeJoinNodes(),this.terminalNodes.push(b)},resetCounter:function(){this.bucket.counter=0},incrementCounter:function(){this.bucket.counter++},assertFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].assert(a)},retractFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].retract(a)},modifyFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].modify(a)},containsRule:function(a){return g(this.terminalNodes,function(b){return b.rule.name===a})},dispose:function(){for(var a=this.typeNodes,b=a.length-1;b>=0;b--)a[b].dispose()},__mergeJoinNodes:function(){for(var a=this.joinNodes,b=0;b=0;c--){var d=b[c];if(a.equal(d))return d}return b.push(a),a},__createTypeNode:function(a,b){for(var c=new F(b.get("constraints")[0]),d=this.typeNodes,e=d.length-1;e>=0;e--){var f=d[e];if(c.equal(f))return f}return d.push(c),c},__createEqualityNode:function(a,b){return this.__checkEqual(new v(b)).addRule(a)},__createPropertyNode:function(a,b){return this.__checkEqual(new H(b)).addRule(a)},__createAliasNode:function(a,b){return this.__checkEqual(new u(b)).addRule(a)},__createAdapterNode:function(a,b){return("left"===b?new D:new E).addRule(a)},__createJoinNode:function(a,b,c,e){var f;b.rightPattern instanceof o?f=new y:b.rightPattern instanceof n?f=new C(b.rightPattern,this.workingMemory):b.rightPattern instanceof m?f=new B:b.rightPattern instanceof l?f=new A(b.rightPattern,this.workingMemory):b.rightPattern instanceof k?f=new z(b.rightPattern,this.workingMemory):b instanceof p&&!d(b.leftPattern)&&!d(b.rightPattern)?(f=new x,this.joinNodes.push(f)):(f=new w,this.joinNodes.push(f)),f.__rule__=a;var g=f;if(c instanceof x){var h=this.__createAdapterNode(a,e);g.addOutNode(h,b),g=h}return g.addOutNode(c,b),f.addRule(a)},__addToNetwork:function(a,b,c,d){b instanceof j?b instanceof q||d&&"left"!==d?this.__createAlphaNode(a,b,c,d):this.__createBetaNode(a,new p(new q,b),c,d):b instanceof p&&this.__createBetaNode(a,b,c,d)},__createBetaNode:function(a,b,c,d){var e=this.__createJoinNode(a,b,c,d);return this.__addToNetwork(a,b.rightPattern,e,"right"),this.__addToNetwork(a,b.leftPattern,e,"left"),c.addParentNode(e),e},__createAlphaNode:function(a,b,c,d){var e,f;if(!(b instanceof k)){var g=b.get("constraints");e=this.__createTypeNode(a,b);var h=this.__createAliasNode(a,b);e.addOutNode(h,b),h.addParentNode(e),f=h;for(var i=g.length-1;i>0;i--){var j,l=g[i];if(l instanceof s)j=this.__createPropertyNode(a,l);else{if(l instanceof t){c.constraint.addConstraint(l);continue}j=this.__createEqualityNode(a,l)}f.addOutNode(j,b),j.addParentNode(f),f=j}if(c instanceof x){var m=this.__createAdapterNode(a,d);m.addParentNode(f),f.addOutNode(m,b),f=m}return c.addParentNode(f),f.addOutNode(c,b),e}},print:function(){f(this.terminalNodes,function(a){a.print(" ")})}}}).as(c,"RootNode")},{"../constraint":8,"../extended":12,"../pattern.js":45,"./aliasNode":19,"./betaNode":21,"./equalityNode":22,"./existsFromNode":23,"./existsNode":24,"./fromNode":25,"./fromNotNode":26,"./joinNode":28,"./leftAdapterNode":30,"./notNode":35,"./propertyNode":36,"./rightAdapterNode":37,"./terminalNode":38,"./typeNode":39}],28:[function(a,b){var c=a("./betaNode"),d=a("./joinReferenceNode");c.extend({instance:{constructor:function(){this._super(arguments),this.constraint=new d(this.leftTuples,this.rightTuples)},nodeType:"JoinNode",propagateFromLeft:function(a,b){var c;return(c=this.constraint.match(a,b)).isMatch&&this.__propagate("assert",this.__addToMemoryMatches(b,a,a.clone(null,null,c))),this},propagateFromRight:function(a,b){var c;return(c=this.constraint.match(b,a)).isMatch&&this.__propagate("assert",this.__addToMemoryMatches(a,b,a.clone(null,null,c))),this},propagateAssertModifyFromLeft:function(a,b,c){var d,e=c.hashCode;if(e in b){d=this.constraint.match(a,c);var f=d.isMatch;f?this.__propagate("modify",this.__addToMemoryMatches(c,a,a.clone(null,null,d))):this.__propagate("retract",b[e].clone())}else this.propagateFromLeft(a,c)},propagateAssertModifyFromRight:function(a,b,c){var d,e=c.hashCode;if(e in b){d=this.constraint.match(c,a);var f=d.isMatch;f?this.__propagate("modify",this.__addToMemoryMatches(a,c,a.clone(null,null,d))):this.__propagate("retract",b[e].clone())}else this.propagateFromRight(a,c)}}}).as(b)},{"./betaNode":21,"./joinReferenceNode":29}],29:[function(a,b){var c=a("./node"),d=a("../constraint"),e=d.ReferenceEqualityConstraint,f={isDefault:!0,assert:function(){return!0},equal:function(){return!1}};c.extend({instance:{constraint:f,constructor:function(a,b){this._super(arguments),this.constraint=f,this.constraintAssert=f.assert,this.rightIndexes=[],this.leftIndexes=[],this.constraintLength=0,this.leftMemory=a,this.rightMemory=b},addConstraint:function(a){if(a instanceof e){var b=a.getIndexableProperties(),c=a.get("alias");if(2===b.length&&c){for(var d,f,g=-1;++g<2;){var h=b[g];null===h.match(new RegExp("^"+c+"(\\.?)"))?d=h:f=h}d&&f&&(this.rightMemory.addIndex(f,d,a.op),this.leftMemory.addIndex(d,f,a.op))}}this.constraint.isDefault?(this.constraint=a,this.isDefault=!1):this.constraint=this.constraint.merge(a),this.constraintAssert=this.constraint.assert},equal:function(a){return this.constraint.equal(a.constraint)},isMatch:function(a,b){return this.constraintAssert(a.factHash,b.factHash)},match:function(a,b){var c={isMatch:!1};return this.constraintAssert(a.factHash,b.factHash)&&(c=a.match.merge(b.match)),c}}}).as(b)},{"../constraint":8,"./node":34}],30:[function(a,b){var c=a("./adapterNode");c.extend({instance:{propagateAssert:function(a){this.__propagate("assertLeft",a)},propagateRetract:function(a){this.__propagate("retractLeft",a)},propagateResolve:function(a){this.__propagate("retractResolve",a)},propagateModify:function(a){this.__propagate("modifyLeft",a)},retractResolve:function(a){this.__propagate("retractResolve",a)},dispose:function(a){this.propagateDispose(a)},toString:function(){return"LeftAdapterNode "+this.__count}}}).as(b)},{"./adapterNode":18}],31:[function(a,b){var c=a("./memory");c.extend({instance:{getLeftMemory:function(a){return this.getMemory(a)}}}).as(b)},{"./memory":32}],32:[function(a,b){var c=a("../../extended"),d=c.indexOf,e=c.plucker,f=c.diffArr,g=Array.prototype.push,h=c.declare,i=c.HashTable;h({instance:{constructor:function(){this.head=null,this.tail=null,this.length=null,this.indexes=[],this.tables={tuples:[],tables:[]}},inequalityThreshold:.5,push:function(a){var b=this.tail,c=this.head,d={data:a,prev:b,next:null};return b&&(this.tail.next=d),this.tail=d,c||(this.head=d),this.length++,this.__index(d),this.tables.tuples.push(d),d},remove:function(a){a.prev?a.prev.next=a.next:this.head=a.next,a.next?a.next.prev=a.prev:this.tail=a.prev;var b=d(this.tables.tuples,a);-1!==b&&this.tables.tuples.splice(b,1),this.__removeFromIndex(a),this.length--},forEach:function(a){for(var b={next:this.head};b=b.next;)a(b.data)},toArray:function(){for(var a={next:this.head},b=[];a=a.next;)b.push(a);return b},clear:function(){this.head=this.tail=null,this.length=0,this.clearIndexes()},clearIndexes:function(){this.tables={},this.indexes.length=0},__index:function(a){for(var b,c,d,e,f,g,h,j=a.data,k=j.factHash,l=this.indexes,m=this.tables,n=-1,o=l.length;++nm&&(k=f(k,n)),k.slice()},__createIndexTree:function(){var a=this.tables.tables={},b=this.indexes;a[b[0][0]]=new i},addIndex:function(a,b,c){this.indexes.push([a,b,e(a),e(b),c||"eq"]),this.indexes.sort(function(a,b){var c=a[4],d=b[4];return c===d?0:c>d?1:-1}),this.__createIndexTree()}}}).as(b)},{"../../extended":12}],33:[function(a,b){var c=a("./memory");c.extend({instance:{getRightMemory:function(a){return this.getMemory(a)}}}).as(b)},{"./memory":32}],34:[function(a,b){var c=a("../extended"),d=c.forEach,e=c.indexOf,f=c.intersection,g=c.declare,h=c.HashTable,i=a("../context"),j=0;g({instance:{constructor:function(){this.nodes=new h,this.rules=[],this.parentNodes=[],this.__count=j++,this.__entrySet=[]},addRule:function(a){return-1===e(this.rules,a)&&this.rules.push(a),this},merge:function(a){a.nodes.forEach(function(b){for(var c=b.value,d=b.key,e=0,f=c.length;f>e;e++)this.addOutNode(d,c[e]);a.nodes.remove(d)},this);for(var b=a.parentNodes,c=0,d=a.parentNodes.l;d>c;c++){var e=b[c];this.addParentNode(e),e.nodes.remove(a)}return this},resolve:function(a,b){return a.hashCode===b.hashCode},print:function(a){console.log(a+this.toString()),d(this.parentNodes,function(b){b.print(" "+a)})},addOutNode:function(a,b){this.nodes.contains(a)||this.nodes.put(a,[]),this.nodes.get(a).push(b),this.__entrySet=this.nodes.entrySet()},addParentNode:function(a){-1===e(this.parentNodes,a)&&this.parentNodes.push(a)},shareable:function(){return!1},__propagate:function(a,b){for(var c,d,e,g,h=this.__entrySet,j=h.length;--j>-1;)c=h[j],d=c.key,e=c.value,(g=f(e,b.paths)).length&&d[a](new i(b.fact,g,b.match))},dispose:function(a){this.propagateDispose(a)},retract:function(a){this.propagateRetract(a)},propagateDispose:function(a,b){b=b||this.nodes;for(var c=this.__entrySet,d=c.length-1;d>=0;d--){var e=c[d],f=e.key;f.dispose(a)}},propagateAssert:function(a){this.__propagate("assert",a)},propagateRetract:function(a){this.__propagate("retract",a)},assert:function(a){this.propagateAssert(a)},modify:function(a){this.propagateModify(a)},propagateModify:function(a){this.__propagate("modify",a)}}}).as(b)},{"../context":10,"../extended":12}],35:[function(a,b){var c=a("./joinNode"),d=a("../linkedList"),e=a("../context"),f=a("../pattern").InitialFact;c.extend({instance:{nodeType:"NotNode",constructor:function(){this._super(arguments),this.leftTupleMemory={},this.notMatch=new e(new f).match},__cloneContext:function(a){return a.clone(null,null,a.match.merge(this.notMatch))},retractRight:function(a){var b=this.removeFromRightMemory(a),c=b.data,d=c.blocking;if(d.length){for(var e,f,g,h=this.rightTuples.getSimilarMemory(c),i=h.length,j=this.constraint,k={next:d.head};k=k.next;){for(f=k.data,e=-1;++eg;g++)b=e[g],c.set(b[1],f[b[0]]);this.__propagate("assert",c)},retract:function(a){this.__propagate("retract",new d(a.fact,a.paths))},modify:function(a){var b,c=new d(a.fact,a.paths),e=this.variables,f=a.fact.object;c.set(this.alias,f);for(var g=0,h=this.varLength;h>g;g++)b=e[g],c.set(b[1],f[b[0]]);this.__propagate("modify",c)},toString:function(){return"PropertyNode"+this.__count}}}).as(b)},{"../context":10,"../extended":12,"./alphaNode":20}],37:[function(a,b){var c=a("./adapterNode");c.extend({instance:{retractResolve:function(a){this.__propagate("retractResolve",a)},dispose:function(a){this.propagateDispose(a)},propagateAssert:function(a){this.__propagate("assertRight",a)},propagateRetract:function(a){this.__propagate("retractRight",a)},propagateResolve:function(a){this.__propagate("retractResolve",a)},propagateModify:function(a){this.__propagate("modifyRight",a)},toString:function(){return"RightAdapterNode "+this.__count}}}).as(b)},{"./adapterNode":18}],38:[function(a,b){var c=a("./node"),d=a("../extended"),e=d.bind;c.extend({instance:{constructor:function(a,b,c,d){this._super([]),this.resolve=e(this,this.resolve),this.rule=c,this.index=b,this.name=this.rule.name,this.agenda=d,this.bucket=a,d.register(this)},__assertModify:function(a){var b=a.match;if(b.isMatch){var c=this.rule,d=this.bucket;this.agenda.insert(this,{rule:c,hashCode:a.hashCode,index:this.index,name:c.name,recency:d.recency++,match:b,counter:d.counter})}},assert:function(a){this.__assertModify(a)},modify:function(a){this.agenda.retract(this,a),this.__assertModify(a)},retract:function(a){this.agenda.retract(this,a)},retractRight:function(a){this.agenda.retract(this,a)},retractLeft:function(a){this.agenda.retract(this,a)},assertLeft:function(a){this.__assertModify(a)},assertRight:function(a){this.__assertModify(a)},toString:function(){return"TerminalNode "+this.rule.name}}}).as(b)},{"../extended":12,"./node":34}],39:[function(a,b){var c=a("./alphaNode"),d=a("../context"); -c.extend({instance:{assert:function(a){this.constraintAssert(a.object)&&this.__propagate("assert",a)},modify:function(a){this.constraintAssert(a.object)&&this.__propagate("modify",a)},retract:function(a){this.constraintAssert(a.object)&&this.__propagate("retract",a)},toString:function(){return"TypeNode"+this.__count},dispose:function(){for(var a=this.__entrySet,b=a.length-1;b>=0;b--){var c=a[b],d=c.key,e=c.value;d.dispose({paths:e})}},__propagate:function(a,b){for(var c=this.__entrySet,e=-1,f=c.length;++e":20,"<=":21,">=":22,EQUALITY_EXPRESSION:23,"==":24,"!=":25,"=~":26,"!=~":27,IN_EXPRESSION:28,"in":29,ARRAY_EXPRESSION:30,notIn:31,OBJECT_EXPRESSION:32,AND_EXPRESSION:33,"&&":34,OR_EXPRESSION:35,"||":36,ARGUMENT_LIST:37,",":38,IDENTIFIER_EXPRESSION:39,IDENTIFIER:40,".":41,"[":42,STRING_EXPRESSION:43,"]":44,NUMBER_EXPRESSION:45,"(":46,")":47,STRING:48,NUMBER:49,REGEXP_EXPRESSION:50,REGEXP:51,BOOLEAN_EXPRESSION:52,BOOLEAN:53,NULL_EXPRESSION:54,NULL:55,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:"-",9:"!",11:"*",12:"/",13:"%",15:"+",17:"^",19:"<",20:">",21:"<=",22:">=",24:"==",25:"!=",26:"=~",27:"!=~",29:"in",31:"notIn",34:"&&",36:"||",38:",",40:"IDENTIFIER",41:".",42:"[",44:"]",46:"(",47:")",48:"STRING",49:"NUMBER",51:"REGEXP",53:"BOOLEAN",55:"NULL"},productions_:[0,[3,2],[6,1],[6,2],[6,2],[10,1],[10,3],[10,3],[10,3],[14,1],[14,3],[14,3],[16,1],[16,3],[18,1],[18,3],[18,3],[18,3],[18,3],[23,1],[23,3],[23,3],[23,3],[23,3],[28,1],[28,3],[28,3],[28,3],[28,3],[33,1],[33,3],[35,1],[35,3],[37,1],[37,3],[39,1],[32,1],[32,3],[32,4],[32,4],[32,4],[32,3],[32,4],[43,1],[45,1],[50,1],[52,1],[54,1],[30,2],[30,3],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,3],[4,1]],performAction:function(a,b,c,d,e,f){var g=f.length-1;switch(e){case 1:return f[g-1];case 3:this.$=[f[g],null,"unary"];break;case 4:this.$=[f[g],null,"logicalNot"];break;case 6:this.$=[f[g-2],f[g],"mult"];break;case 7:this.$=[f[g-2],f[g],"div"];break;case 8:this.$=[f[g-2],f[g],"mod"];break;case 10:this.$=[f[g-2],f[g],"plus"];break;case 11:this.$=[f[g-2],f[g],"minus"];break;case 13:this.$=[f[g-2],f[g],"pow"];break;case 15:this.$=[f[g-2],f[g],"lt"];break;case 16:this.$=[f[g-2],f[g],"gt"];break;case 17:this.$=[f[g-2],f[g],"lte"];break;case 18:this.$=[f[g-2],f[g],"gte"];break;case 20:this.$=[f[g-2],f[g],"eq"];break;case 21:this.$=[f[g-2],f[g],"neq"];break;case 22:this.$=[f[g-2],f[g],"like"];break;case 23:this.$=[f[g-2],f[g],"notLike"];break;case 25:this.$=[f[g-2],f[g],"in"];break;case 26:this.$=[f[g-2],f[g],"notIn"];break;case 27:this.$=[f[g-2],f[g],"in"];break;case 28:this.$=[f[g-2],f[g],"notIn"];break;case 30:this.$=[f[g-2],f[g],"and"];break;case 32:this.$=[f[g-2],f[g],"or"];break;case 34:this.$=[f[g-2],f[g],"arguments"];break;case 35:this.$=[String(a),null,"identifier"];break;case 37:this.$=[f[g-2],f[g],"prop"];break;case 38:this.$=[f[g-3],f[g-1],"propLookup"];break;case 39:this.$=[f[g-3],f[g-1],"propLookup"];break;case 40:this.$=[f[g-3],f[g-1],"propLookup"];break;case 41:this.$=[f[g-2],[null,null,"arguments"],"function"];break;case 42:this.$=[f[g-3],f[g-1],"function"];break;case 43:this.$=[String(a.replace(/^['|"]|['|"]$/g,"")),null,"string"];break;case 44:this.$=[Number(a),null,"number"];break;case 45:this.$=[a,null,"regexp"];break;case 46:this.$=["true"==a.replace(/^\s+/,""),null,"boolean"];break;case 47:this.$=[null,null,"null"];break;case 48:this.$=[null,null,"array"];break;case 49:this.$=[f[g-1],null,"array"];break;case 57:this.$=[f[g-1],null,"composite"]}},table:[{3:1,4:2,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[3]},{5:[1,31]},{5:[2,58],36:[1,32],47:[2,58]},{5:[2,31],34:[1,33],36:[2,31],47:[2,31]},{5:[2,29],34:[2,29],36:[2,29],47:[2,29]},{5:[2,24],24:[1,34],25:[1,35],26:[1,36],27:[1,37],34:[2,24],36:[2,24],47:[2,24]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],29:[1,38],31:[1,39],34:[2,2],36:[2,2],47:[2,2]},{5:[2,19],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,19],25:[2,19],26:[2,19],27:[2,19],34:[2,19],36:[2,19],47:[2,19]},{5:[2,50],8:[2,50],11:[2,50],12:[2,50],13:[2,50],15:[2,50],17:[2,50],19:[2,50],20:[2,50],21:[2,50],22:[2,50],24:[2,50],25:[2,50],26:[2,50],27:[2,50],29:[2,50],31:[2,50],34:[2,50],36:[2,50],38:[2,50],44:[2,50],47:[2,50]},{5:[2,51],8:[2,51],11:[2,51],12:[2,51],13:[2,51],15:[2,51],17:[2,51],19:[2,51],20:[2,51],21:[2,51],22:[2,51],24:[2,51],25:[2,51],26:[2,51],27:[2,51],29:[2,51],31:[2,51],34:[2,51],36:[2,51],38:[2,51],44:[2,51],47:[2,51]},{5:[2,52],8:[2,52],11:[2,52],12:[2,52],13:[2,52],15:[2,52],17:[2,52],19:[2,52],20:[2,52],21:[2,52],22:[2,52],24:[2,52],25:[2,52],26:[2,52],27:[2,52],29:[2,52],31:[2,52],34:[2,52],36:[2,52],38:[2,52],44:[2,52],47:[2,52]},{5:[2,53],8:[2,53],11:[2,53],12:[2,53],13:[2,53],15:[2,53],17:[2,53],19:[2,53],20:[2,53],21:[2,53],22:[2,53],24:[2,53],25:[2,53],26:[2,53],27:[2,53],29:[2,53],31:[2,53],34:[2,53],36:[2,53],38:[2,53],44:[2,53],47:[2,53]},{5:[2,54],8:[2,54],11:[2,54],12:[2,54],13:[2,54],15:[2,54],17:[2,54],19:[2,54],20:[2,54],21:[2,54],22:[2,54],24:[2,54],25:[2,54],26:[2,54],27:[2,54],29:[2,54],31:[2,54],34:[2,54],36:[2,54],38:[2,54],44:[2,54],47:[2,54]},{5:[2,55],8:[2,55],11:[2,55],12:[2,55],13:[2,55],15:[2,55],17:[2,55],19:[2,55],20:[2,55],21:[2,55],22:[2,55],24:[2,55],25:[2,55],26:[2,55],27:[2,55],29:[2,55],31:[2,55],34:[2,55],36:[2,55],38:[2,55],41:[1,44],42:[1,45],44:[2,55],46:[1,46],47:[2,55]},{5:[2,56],8:[2,56],11:[2,56],12:[2,56],13:[2,56],15:[2,56],17:[2,56],19:[2,56],20:[2,56],21:[2,56],22:[2,56],24:[2,56],25:[2,56],26:[2,56],27:[2,56],29:[2,56],31:[2,56],34:[2,56],36:[2,56],38:[2,56],44:[2,56],47:[2,56]},{4:47,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,14],17:[1,48],19:[2,14],20:[2,14],21:[2,14],22:[2,14],24:[2,14],25:[2,14],26:[2,14],27:[2,14],34:[2,14],36:[2,14],47:[2,14]},{5:[2,43],8:[2,43],11:[2,43],12:[2,43],13:[2,43],15:[2,43],17:[2,43],19:[2,43],20:[2,43],21:[2,43],22:[2,43],24:[2,43],25:[2,43],26:[2,43],27:[2,43],29:[2,43],31:[2,43],34:[2,43],36:[2,43],38:[2,43],44:[2,43],47:[2,43]},{5:[2,44],8:[2,44],11:[2,44],12:[2,44],13:[2,44],15:[2,44],17:[2,44],19:[2,44],20:[2,44],21:[2,44],22:[2,44],24:[2,44],25:[2,44],26:[2,44],27:[2,44],29:[2,44],31:[2,44],34:[2,44],36:[2,44],38:[2,44],44:[2,44],47:[2,44]},{5:[2,45],8:[2,45],11:[2,45],12:[2,45],13:[2,45],15:[2,45],17:[2,45],19:[2,45],20:[2,45],21:[2,45],22:[2,45],24:[2,45],25:[2,45],26:[2,45],27:[2,45],29:[2,45],31:[2,45],34:[2,45],36:[2,45],38:[2,45],44:[2,45],47:[2,45]},{5:[2,46],8:[2,46],11:[2,46],12:[2,46],13:[2,46],15:[2,46],17:[2,46],19:[2,46],20:[2,46],21:[2,46],22:[2,46],24:[2,46],25:[2,46],26:[2,46],27:[2,46],29:[2,46],31:[2,46],34:[2,46],36:[2,46],38:[2,46],44:[2,46],47:[2,46]},{5:[2,47],8:[2,47],11:[2,47],12:[2,47],13:[2,47],15:[2,47],17:[2,47],19:[2,47],20:[2,47],21:[2,47],22:[2,47],24:[2,47],25:[2,47],26:[2,47],27:[2,47],29:[2,47],31:[2,47],34:[2,47],36:[2,47],38:[2,47],44:[2,47],47:[2,47]},{5:[2,36],8:[2,36],11:[2,36],12:[2,36],13:[2,36],15:[2,36],17:[2,36],19:[2,36],20:[2,36],21:[2,36],22:[2,36],24:[2,36],25:[2,36],26:[2,36],27:[2,36],29:[2,36],31:[2,36],34:[2,36],36:[2,36],38:[2,36],41:[2,36],42:[2,36],44:[2,36],46:[2,36],47:[2,36]},{7:51,30:15,32:14,37:50,39:23,40:[1,26],42:[1,24],43:9,44:[1,49],45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,12],8:[1,53],15:[1,52],17:[2,12],19:[2,12],20:[2,12],21:[2,12],22:[2,12],24:[2,12],25:[2,12],26:[2,12],27:[2,12],34:[2,12],36:[2,12],47:[2,12]},{5:[2,35],8:[2,35],11:[2,35],12:[2,35],13:[2,35],15:[2,35],17:[2,35],19:[2,35],20:[2,35],21:[2,35],22:[2,35],24:[2,35],25:[2,35],26:[2,35],27:[2,35],29:[2,35],31:[2,35],34:[2,35],36:[2,35],38:[2,35],41:[2,35],42:[2,35],44:[2,35],46:[2,35],47:[2,35]},{5:[2,9],8:[2,9],11:[1,54],12:[1,55],13:[1,56],15:[2,9],17:[2,9],19:[2,9],20:[2,9],21:[2,9],22:[2,9],24:[2,9],25:[2,9],26:[2,9],27:[2,9],34:[2,9],36:[2,9],47:[2,9]},{5:[2,5],8:[2,5],11:[2,5],12:[2,5],13:[2,5],15:[2,5],17:[2,5],19:[2,5],20:[2,5],21:[2,5],22:[2,5],24:[2,5],25:[2,5],26:[2,5],27:[2,5],34:[2,5],36:[2,5],47:[2,5]},{6:57,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:59,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[2,1]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:60,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:61,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:62,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:63,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:64,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:65,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{30:66,32:67,39:23,40:[1,26],42:[1,24]},{30:68,32:69,39:23,40:[1,26],42:[1,24]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:70,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:71,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:72,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:73,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{39:74,40:[1,26]},{32:77,39:23,40:[1,26],43:75,45:76,48:[1,18],49:[1,19]},{7:51,30:15,32:14,37:79,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],47:[1,78],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{47:[1,80]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:81,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,48],8:[2,48],11:[2,48],12:[2,48],13:[2,48],15:[2,48],17:[2,48],19:[2,48],20:[2,48],21:[2,48],22:[2,48],24:[2,48],25:[2,48],26:[2,48],27:[2,48],29:[2,48],31:[2,48],34:[2,48],36:[2,48],38:[2,48],44:[2,48],47:[2,48]},{38:[1,83],44:[1,82]},{38:[2,33],44:[2,33],47:[2,33]},{6:28,7:58,8:[1,29],9:[1,30],10:84,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:85,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:86,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:87,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:88,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,3],8:[2,3],11:[2,3],12:[2,3],13:[2,3],15:[2,3],17:[2,3],19:[2,3],20:[2,3],21:[2,3],22:[2,3],24:[2,3],25:[2,3],26:[2,3],27:[2,3],34:[2,3],36:[2,3],47:[2,3]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],34:[2,2],36:[2,2],47:[2,2]},{5:[2,4],8:[2,4],11:[2,4],12:[2,4],13:[2,4],15:[2,4],17:[2,4],19:[2,4],20:[2,4],21:[2,4],22:[2,4],24:[2,4],25:[2,4],26:[2,4],27:[2,4],34:[2,4],36:[2,4],47:[2,4]},{5:[2,32],34:[1,33],36:[2,32],47:[2,32]},{5:[2,30],34:[2,30],36:[2,30],47:[2,30]},{5:[2,20],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,20],25:[2,20],26:[2,20],27:[2,20],34:[2,20],36:[2,20],47:[2,20]},{5:[2,21],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,21],25:[2,21],26:[2,21],27:[2,21],34:[2,21],36:[2,21],47:[2,21]},{5:[2,22],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,22],25:[2,22],26:[2,22],27:[2,22],34:[2,22],36:[2,22],47:[2,22]},{5:[2,23],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,23],25:[2,23],26:[2,23],27:[2,23],34:[2,23],36:[2,23],47:[2,23]},{5:[2,25],34:[2,25],36:[2,25],47:[2,25]},{5:[2,27],34:[2,27],36:[2,27],41:[1,44],42:[1,45],46:[1,46],47:[2,27]},{5:[2,26],34:[2,26],36:[2,26],47:[2,26]},{5:[2,28],34:[2,28],36:[2,28],41:[1,44],42:[1,45],46:[1,46],47:[2,28]},{5:[2,15],17:[1,48],19:[2,15],20:[2,15],21:[2,15],22:[2,15],24:[2,15],25:[2,15],26:[2,15],27:[2,15],34:[2,15],36:[2,15],47:[2,15]},{5:[2,16],17:[1,48],19:[2,16],20:[2,16],21:[2,16],22:[2,16],24:[2,16],25:[2,16],26:[2,16],27:[2,16],34:[2,16],36:[2,16],47:[2,16]},{5:[2,17],17:[1,48],19:[2,17],20:[2,17],21:[2,17],22:[2,17],24:[2,17],25:[2,17],26:[2,17],27:[2,17],34:[2,17],36:[2,17],47:[2,17]},{5:[2,18],17:[1,48],19:[2,18],20:[2,18],21:[2,18],22:[2,18],24:[2,18],25:[2,18],26:[2,18],27:[2,18],34:[2,18],36:[2,18],47:[2,18]},{5:[2,37],8:[2,37],11:[2,37],12:[2,37],13:[2,37],15:[2,37],17:[2,37],19:[2,37],20:[2,37],21:[2,37],22:[2,37],24:[2,37],25:[2,37],26:[2,37],27:[2,37],29:[2,37],31:[2,37],34:[2,37],36:[2,37],38:[2,37],41:[2,37],42:[2,37],44:[2,37],46:[2,37],47:[2,37]},{44:[1,89]},{44:[1,90]},{41:[1,44],42:[1,45],44:[1,91],46:[1,46]},{5:[2,41],8:[2,41],11:[2,41],12:[2,41],13:[2,41],15:[2,41],17:[2,41],19:[2,41],20:[2,41],21:[2,41],22:[2,41],24:[2,41],25:[2,41],26:[2,41],27:[2,41],29:[2,41],31:[2,41],34:[2,41],36:[2,41],38:[2,41],41:[2,41],42:[2,41],44:[2,41],46:[2,41],47:[2,41]},{38:[1,83],47:[1,92]},{5:[2,57],8:[2,57],11:[2,57],12:[2,57],13:[2,57],15:[2,57],17:[2,57],19:[2,57],20:[2,57],21:[2,57],22:[2,57],24:[2,57],25:[2,57],26:[2,57],27:[2,57],29:[2,57],31:[2,57],34:[2,57],36:[2,57],38:[2,57],44:[2,57],47:[2,57]},{5:[2,13],8:[1,53],15:[1,52],17:[2,13],19:[2,13],20:[2,13],21:[2,13],22:[2,13],24:[2,13],25:[2,13],26:[2,13],27:[2,13],34:[2,13],36:[2,13],47:[2,13]},{5:[2,49],8:[2,49],11:[2,49],12:[2,49],13:[2,49],15:[2,49],17:[2,49],19:[2,49],20:[2,49],21:[2,49],22:[2,49],24:[2,49],25:[2,49],26:[2,49],27:[2,49],29:[2,49],31:[2,49],34:[2,49],36:[2,49],38:[2,49],44:[2,49],47:[2,49]},{7:93,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,10],8:[2,10],11:[1,54],12:[1,55],13:[1,56],15:[2,10],17:[2,10],19:[2,10],20:[2,10],21:[2,10],22:[2,10],24:[2,10],25:[2,10],26:[2,10],27:[2,10],34:[2,10],36:[2,10],47:[2,10]},{5:[2,11],8:[2,11],11:[1,54],12:[1,55],13:[1,56],15:[2,11],17:[2,11],19:[2,11],20:[2,11],21:[2,11],22:[2,11],24:[2,11],25:[2,11],26:[2,11],27:[2,11],34:[2,11],36:[2,11],47:[2,11]},{5:[2,6],8:[2,6],11:[2,6],12:[2,6],13:[2,6],15:[2,6],17:[2,6],19:[2,6],20:[2,6],21:[2,6],22:[2,6],24:[2,6],25:[2,6],26:[2,6],27:[2,6],34:[2,6],36:[2,6],47:[2,6]},{5:[2,7],8:[2,7],11:[2,7],12:[2,7],13:[2,7],15:[2,7],17:[2,7],19:[2,7],20:[2,7],21:[2,7],22:[2,7],24:[2,7],25:[2,7],26:[2,7],27:[2,7],34:[2,7],36:[2,7],47:[2,7]},{5:[2,8],8:[2,8],11:[2,8],12:[2,8],13:[2,8],15:[2,8],17:[2,8],19:[2,8],20:[2,8],21:[2,8],22:[2,8],24:[2,8],25:[2,8],26:[2,8],27:[2,8],34:[2,8],36:[2,8],47:[2,8]},{5:[2,38],8:[2,38],11:[2,38],12:[2,38],13:[2,38],15:[2,38],17:[2,38],19:[2,38],20:[2,38],21:[2,38],22:[2,38],24:[2,38],25:[2,38],26:[2,38],27:[2,38],29:[2,38],31:[2,38],34:[2,38],36:[2,38],38:[2,38],41:[2,38],42:[2,38],44:[2,38],46:[2,38],47:[2,38]},{5:[2,39],8:[2,39],11:[2,39],12:[2,39],13:[2,39],15:[2,39],17:[2,39],19:[2,39],20:[2,39],21:[2,39],22:[2,39],24:[2,39],25:[2,39],26:[2,39],27:[2,39],29:[2,39],31:[2,39],34:[2,39],36:[2,39],38:[2,39],41:[2,39],42:[2,39],44:[2,39],46:[2,39],47:[2,39]},{5:[2,40],8:[2,40],11:[2,40],12:[2,40],13:[2,40],15:[2,40],17:[2,40],19:[2,40],20:[2,40],21:[2,40],22:[2,40],24:[2,40],25:[2,40],26:[2,40],27:[2,40],29:[2,40],31:[2,40],34:[2,40],36:[2,40],38:[2,40],41:[2,40],42:[2,40],44:[2,40],46:[2,40],47:[2,40]},{5:[2,42],8:[2,42],11:[2,42],12:[2,42],13:[2,42],15:[2,42],17:[2,42],19:[2,42],20:[2,42],21:[2,42],22:[2,42],24:[2,42],25:[2,42],26:[2,42],27:[2,42],29:[2,42],31:[2,42],34:[2,42],36:[2,42],38:[2,42],41:[2,42],42:[2,42],44:[2,42],46:[2,42],47:[2,42]},{38:[2,34],44:[2,34],47:[2,34]}],defaultActions:{31:[2,1]},parseError:function(a,b){if(!b.recoverable)throw new Error(a);this.trace(a)},parse:function(a){function b(){var a;return a=c.lexer.lex()||m,"number"!=typeof a&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(a),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n);var o=this.lexer.options&&this.lexer.options.ranges;this.parseError="function"==typeof this.yy.parseError?this.yy.parseError:Object.getPrototypeOf(this).parseError;for(var p,q,r,s,t,u,v,w,x,y={};;){if(r=d[d.length-1],this.defaultActions[r]?s=this.defaultActions[r]:((null===p||"undefined"==typeof p)&&(p=b()),s=g[r]&&g[r][p]),"undefined"==typeof s||!s.length||!s[0]){var z="";x=[];for(u in g[r])this.terminals_[u]&&u>l&&x.push("'"+this.terminals_[u]+"'");z=this.lexer.showPosition?"Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+x.join(", ")+", got '"+(this.terminals_[p]||p)+"'":"Parse error on line "+(i+1)+": Unexpected "+(p==m?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(z,{text:this.lexer.match,token:this.terminals_[p]||p,line:this.lexer.yylineno,loc:n,expected:x})}if(s[0]instanceof Array&&s.length>1)throw new Error("Parse Error: multiple actions possible at state: "+r+", token: "+p);switch(s[0]){case 1:d.push(p),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(s[1]),p=null,q?(p=q,q=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:if(v=this.productions_[s[1]][1],y.$=e[e.length-v],y._$={first_line:f[f.length-(v||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(v||1)].first_column,last_column:f[f.length-1].last_column},o&&(y._$.range=[f[f.length-(v||1)].range[0],f[f.length-1].range[1]]),t=this.performAction.call(y,h,j,i,this.yy,s[1],e,f),"undefined"!=typeof t)return t;v&&(d=d.slice(0,2*-1*v),e=e.slice(0,-1*v),f=f.slice(0,-1*v)),d.push(this.productions_[s[1]][0]),e.push(y.$),f.push(y._$),w=g[d[d.length-2]][d[d.length-1]],d.push(w);break;case 3:return!0}}return!0}},c=function(){var a={EOF:1,parseError:function(a,b){if(!this.yy.parser)throw new Error(a);this.yy.parser.parseError(a,b)},setInput:function(a){return this._input=a,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var b=a.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},unput:function(a){var b=a.length,c=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b-1),this.offset-=b;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),c.length-1&&(this.yylineno-=c.length-1);var e=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===d.length?this.yylloc.first_column:0)+d[d.length-c.length].length-c[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[e[0],e[0]+this.yyleng-b]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=new Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},test_match:function(a,b){var c,d,e;if(this.options.backtrack_lexer&&(e={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(e.yylloc.range=this.yylloc.range.slice(0))),d=a[0].match(/(?:\r\n?|\n).*/g),d&&(this.yylineno+=d.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:d?d[d.length-1].length-d[d.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+a[0].length},this.yytext+=a[0],this.match+=a[0],this.matches=a,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(a[0].length),this.matched+=a[0],c=this.performAction.call(this,this.yy,this,b,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),c)return c;if(this._backtrack){for(var f in e)this[f]=e[f];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d;this._more||(this.yytext="",this.match="");for(var e=this._currentRules(),f=0;fb[0].length)){if(b=c,d=f,this.options.backtrack_lexer){if(a=this.test_match(c,e[f]),a!==!1)return a;if(this._backtrack){b=!1;continue}return!1}if(!this.options.flex)break}return b?(a=this.test_match(b,e[d]),a!==!1?a:!1):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){var a=this.conditionStack.length-1;return a>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(a){return a=this.conditionStack.length-1-Math.abs(a||0),a>=0?this.conditionStack[a]:"INITIAL"},pushState:function(a){this.begin(a)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(a,b,c,d){switch(c){case 0:return 29;case 1:return 31;case 2:return"from";case 3:return 24;case 4:return 25;case 5:return 21;case 6:return 19;case 7:return 22;case 8:return 20;case 9:return 26;case 10:return 27;case 11:return 34;case 12:return 36;case 13:return 55;case 14:return 53;case 15:break;case 16:return 49;case 17:return 48;case 18:return 48;case 19:return 40;case 20:return 51;case 21:return 41;case 22:return 11;case 23:return 12;case 24:return 13;case 25:return 38;case 26:return 8;case 27:return 26;case 28:return 27;case 29:return 24;case 30:return 24;case 31:return 25;case 32:return 25;case 33:return 21;case 34:return 22;case 35:return 20;case 36:return 19;case 37:return 34;case 38:return 36;case 39:return 15;case 40:return 17;case 41:return 46;case 42:return 44;case 43:return 42;case 44:return 47;case 45:return 9;case 46:return 5}},rules:[/^(?:\s+in\b)/,/^(?:\s+notIn\b)/,/^(?:\s+from\b)/,/^(?:\s+(eq|EQ)\b)/,/^(?:\s+(neq|NEQ)\b)/,/^(?:\s+(lte|LTE)\b)/,/^(?:\s+(lt|LT)\b)/,/^(?:\s+(gte|GTE)\b)/,/^(?:\s+(gt|GT)\b)/,/^(?:\s+(like|LIKE)\b)/,/^(?:\s+(notLike|NOT_LIKE)\b)/,/^(?:\s+(and|AND)\b)/,/^(?:\s+(or|OR)\b)/,/^(?:\s+null\b)/,/^(?:\s+(true|false)\b)/,/^(?:\s+)/,/^(?:-?[0-9]+(?:\.[0-9]+)?\b)/,/^(?:'[^']*')/,/^(?:"[^"]*")/,/^(?:([a-zA-Z_$][0-9a-zA-Z_$]*))/,/^(?:^\/((?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/[imgy]{0,4})(?!\w))/,/^(?:\.)/,/^(?:\*)/,/^(?:\/)/,/^(?:\%)/,/^(?:,)/,/^(?:-)/,/^(?:=~)/,/^(?:!=~)/,/^(?:==)/,/^(?:===)/,/^(?:!=)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:>)/,/^(?:<)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\])/,/^(?:\[)/,/^(?:\))/,/^(?:!)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0}}};return a}();return b.lexer=c,a.prototype=b,b.Parser=a,new a}();"undefined"!=typeof a&&"undefined"!=typeof c&&(c.parser=e,c.Parser=e.Parser,c.parse=function(){return e.parse.apply(e,arguments)},c.main=function(b){b[1]||(console.log("Usage: "+b[0]+" FILE"),d.exit(1));var e=a("fs").readFileSync(a("path").normalize(b[1]),"utf8");return c.parser.parse(e)},"undefined"!=typeof b&&a.main===b&&c.main(d.argv.slice(1)))},{__browserify_process:68,fs:65,path:66}],41:[function(a,b,c){!function(){"use strict";var b=a("./constraint/parser"),d=a("./nools/nool.parser");c.parseConstraint=function(a){try{return b.parse(a)}catch(c){throw new Error("Invalid expression '"+a+"'")}},c.parseRuleSet=function(a,b){return d.parse(a,b)}}()},{"./constraint/parser":40,"./nools/nool.parser":42}],42:[function(a,b,c){"use strict";var d=a("./tokens.js"),e=a("../../extended"),f=e.hash.keys,g=a("./util.js"),h=function(a,b,c){var d=a;a=a.replace(/\/\/(.*)/g,"").replace(/\n|\r|\r\n/g," ");for(var e,i=new RegExp("^("+f(b).join("|")+")");a&&-1!==(e=g.findNextTokenIndex(a));){a=a.substr(e);var j=a.match(i);if(null===j)throw new Error("Error parsing "+a);if(j=j[1],!(j in b))throw new Error("Unknown token"+j);try{a=b[j](a,c,h).replace(/^\s*|\s*$/g,"")}catch(k){throw new Error("Invalid "+j+" definition \n"+k.message+"; \nstarting at : "+d)}}};c.parse=function(a,b){var c={define:[],rules:[],scope:[],loaded:[],file:b};return h(a,d,c),c}},{"../../extended":12,"./tokens.js":43,"./util.js":44}],43:[function(require,module,exports){var process=require("__browserify_process"),utils=require("./util.js"),fs=require("fs"),extd=require("../../extended"),filter=extd.filter,indexOf=extd.indexOf,predicates=["not","or","exists"],predicateRegExp=new RegExp("^("+predicates.join("|")+") *\\((.*)\\)$","m"),predicateBeginExp=new RegExp(" *("+predicates.join("|")+") *\\(","g"),isWhiteSpace=function(a){return 0===a.replace(/[\s|\n|\r|\t]/g,"").length},joinFunc=function(a,b){return"; "+b},splitRuleLineByPredicateExpressions=function(a){var b=a.replace(/,\s*(\$?\w+\s*:)/g,joinFunc),c=filter(b.split(predicateBeginExp),function(a){return""!==a}),d=c.length,e=[];if(!d)return b;for(var f=0;d>f;f++)-1!==indexOf(predicates,c[f])?e.push([c[f],"(",c[++f].replace(/, *$/,"")].join("")):e.push(c[f].replace(/, *$/,""));return e.join(";")},ruleTokens={salience:function(){var a=/^(salience|priority)\s*:\s*(-?\d+)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=parseInt(d[2],10);if(isNaN(e))throw new Error("Invalid salience/priority "+d[2]);return c.options.priority=e,b.replace(d[0],"")}throw new Error("invalid format")}}(),agendaGroup:function(){var a=/^(agenda-group|agendaGroup)\s*:\s*([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid agenda-group "+d[2]);return c.options.agendaGroup=e.replace(/^["']|["']$/g,""),b.replace(d[0],"")}throw new Error("invalid format")}}(),autoFocus:function(){var a=/^(auto-focus|autoFocus)\s*:\s*(true|false)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid auto-focus "+d[2]);return c.options.autoFocus="true"===e?!0:!1,b.replace(d[0],"")}throw new Error("invalid format")}}(),"agenda-group":function(){return this.agendaGroup.apply(this,arguments)},"auto-focus":function(){return this.autoFocus.apply(this,arguments)},priority:function(){return this.salience.apply(this,arguments)},when:function(){var ruleRegExp=/^(\$?\w+) *: *(\w+)(.*)/,constraintRegExp=/(\{ *(?:["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']? *(?:, *["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']?)*)+ *\})/,fromRegExp=/(\bfrom\s+.*)/,parseRules=function(str){for(var rules=[],ruleLines=str.split(";"),l=ruleLines.length,ruleLine,i=0;l>i&&(ruleLine=ruleLines[i].replace(/^\s*|\s*$/g,"").replace(/\n/g,""));i++)if(!isWhiteSpace(ruleLine)){var rule=[];if(predicateRegExp.test(ruleLine)){var m=ruleLine.match(predicateRegExp),pred=m[1].replace(/^\s*|\s*$/g,"");if(rule.push(pred),ruleLine=m[2].replace(/^\s*|\s*$/g,""),"or"===pred){rule=rule.concat(parseRules(splitRuleLineByPredicateExpressions(ruleLine))),rules.push(rule);continue}}var parts=ruleLine.match(ruleRegExp);if(!parts||!parts.length)throw new Error("Invalid constraint "+ruleLine);rule.push(parts[2],parts[1]);var constraints=parts[3].replace(/^\s*|\s*$/g,""),hashParts=constraints.match(constraintRegExp),from=null,fromMatch;if(hashParts){var hash=hashParts[1],constraint=constraints.replace(hash,"");fromRegExp.test(constraint)&&(fromMatch=constraint.match(fromRegExp),from=fromMatch[0],constraint=constraint.replace(fromMatch[0],"")),constraint&&rule.push(constraint.replace(/^\s*|\s*$/g,"")),hash&&rule.push(eval("("+hash.replace(/(\$?\w+)\s*:\s*(\$?\w+)/g,'"$1" : "$2"')+")"))}else constraints&&!isWhiteSpace(constraints)&&(fromRegExp.test(constraints)&&(fromMatch=constraints.match(fromRegExp),from=fromMatch[0],constraints=constraints.replace(fromMatch[0],"")),rule.push(constraints));from&&rule.push(from),rules.push(rule)}return rules};return function(a,b){var c=a.replace(/^when\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(d,""),b.constraints=parseRules(d.replace(/^\{\s*|\}\s*$/g,"")),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}(),then:function(){return function(a,b){if(b.action)throw new Error("action already defined for rule"+b.name);var c=a.replace(/^then\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join(""); -if(c=c.replace(d,""),b.action||(b.action=d.replace(/^\{\s*|\}\s*$/g,"")),!isWhiteSpace(c))throw new Error("Error parsing then block "+a);return c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}()},topLevelTokens={"/":function(a){return a.match(/^\/\*/)?a.replace(/\/\*.*?\*\//,""):a},define:function(a,b){var c=a.replace(/^define\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){d=d[1];var e=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(e,""),b.define.push({name:d,properties:"("+e+")"}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"import":function(a,b,c){if("undefined"!=typeof window)throw new Error("import cannot be used in a browser");var d=a.replace(/^import\s*/,"");if("("===utils.findNextToken(d)){var e=utils.getParamList(d);if(d=d.replace(e,"").replace(/^\s*|\s*$/g,""),";"===utils.findNextToken(d)&&(d=d.replace(/\s*;/,"")),e=e.replace(/[\(|\)]/g,"").split(","),1===e.length){if(e=utils.resolve(b.file||process.cwd(),e[0].replace(/["|']/g,"")),-1===indexOf(b.loaded,e)){var f=b.file;b.file=e,c(fs.readFileSync(e,"utf8"),topLevelTokens,b),b.loaded.push(e),b.file=f}return d}throw new Error("import accepts a single file")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(d)+"'")},global:function(a,b){var c=a.replace(/^global\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*\s*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"="===utils.findNextToken(c)){d=d[1].replace(/^\s+|\s+$/g,"");var e=utils.getTokensBetween(c,"=",";",!0).join(""),f=e.substring(1,e.length-1);if(f=f.replace(/^\s+|\s+$/g,""),/^require\(/.test(f)){var g=utils.getParamList(f.replace("require")).replace(/[\(|\)]/g,"").split(",");1===g.length&&(g=g[0].replace(/["|']/g,""),f=["require('",utils.resolve(b.file||process.cwd(),g),"')"].join(""))}return b.scope.push({name:d,body:f}),c=c.replace(e,"")}throw new Error("unexpected token : expected : '=' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"function":function(a,b){var c=a.replace(/^function\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)\s*/);if(d){if(c=c.replace(d[0],""),"("===utils.findNextToken(c)){d=d[1];var e=utils.getParamList(c);if(c=c.replace(e,"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){var f=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(f,""),b.scope.push({name:d,body:"function"+e+f}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},rule:function(a,b,c){var d=a.replace(/^rule\s*/,""),e=d.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')/);if(e){if(d=d.replace(e[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(d)){e=e[1].replace(/^["']|["']$/g,"");var f={name:e,options:{},constraints:null,action:null},g=utils.getTokensBetween(d,"{","}",!0).join("");return d=d.replace(g,""),c(g.replace(/^\{\s*|\}\s*$/g,""),ruleTokens,f),b.rules.push(f),d}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(d)+"'")}throw new Error("missing name")}};module.exports=topLevelTokens},{"../../extended":12,"./util.js":44,__browserify_process:68,fs:65}],44:[function(a,b,c){var d=a("__browserify_process"),e=a("path"),f=/[\s|\n|\r|\t]/,g=e.sep||("win32"===d.platform?"\\":"/"),h={"{":"}","}":"{","(":")",")":"(","[":"]"},i=c.getTokensBetween=function(a,b,c,d){var e=0,f=[];b||(b=h[c],e=1),c||(c=h[b]),a=Object(a);for(var g,i=!1,j=0,k=!1;g=a.charAt(j++);)if(g===b)e++,i?f.push(g):(i=!0,d&&f.push(g));else if(g===c&&j){if(e--,0===e){d&&f.push(g),k=!0;break}f.push(g)}else i&&f.push(g);if(!k)throw new Error("Unable to match "+b+" in "+a);return f};c.getParamList=function(a){return i(a,"(",")",!0).join("")},c.resolve=function(a,b){return""!==e.extname(a)&&(a=e.dirname(a)),1===b.split(g).length?b:e.resolve(a,b)};var j=c.findNextTokenIndex=function(a,b,c){b=b||0,c=c||a.length;var d=-1,e=a.length;for((!c||c>e)&&(c=e);c>b;b++){var g=a.charAt(b);if(!f.test(g)){d=b;break}}return d};c.findNextToken=function(a,b,c){return a.charAt(j(a,b,c))}},{__browserify_process:68,path:66}],45:[function(a,b,c){"use strict";var d=a("./extended"),e=d.isEmpty,f=d.merge,g=d.forEach,h=d.declare,i=a("./constraintMatcher"),j=a("./constraint"),k=j.EqualityConstraint,l=j.FromConstraint,m=0,n=h({}),o=n.extend({instance:{constructor:function(a,b,c,d,h){h=h||{},this.id=m++,this.type=a,this.alias=b,this.conditions=c,this.pattern=h.pattern;var k=[new j.ObjectConstraint(a)],l=i.toConstraints(c,f({alias:b},h));if(l.length)k=k.concat(l);else{var n=new j.TrueConstraint;k.push(n)}if(d&&!e(d)){var o=new j.HashConstraint(d);k.push(o)}g(k,function(a){a.set("alias",b)}),this.constraints=k},getSpecificity:function(){for(var a=this.constraints,b=0,c=0,d=a.length;d>c;c++)a[c]instanceof k&&b++;return b},hasConstraint:function(a){return d.some(this.constraints,function(b){return b instanceof a})},hashCode:function(){return[this.type,this.alias,d.format("%j",this.conditions)].join(":")},toString:function(){return d.format("%j",this.constraints)}}}).as(c,"ObjectPattern"),p=o.extend({instance:{constructor:function(a,b,c,d,e,f){this._super([a,b,c,d,f]),this.from=new l(e,f)},hasConstraint:function(a){return d.some(this.constraints,function(b){return b instanceof a})},getSpecificity:function(){return this._super(arguments)+1},hashCode:function(){return[this.type,this.alias,d.format("%j",this.conditions),this.from.from].join(":")},toString:function(){return d.format("%j from %s",this.constraints,this.from.from)}}}).as(c,"FromPattern");p.extend().as(c,"FromNotPattern"),o.extend().as(c,"NotPattern"),o.extend().as(c,"ExistsPattern"),p.extend().as(c,"FromExistsPattern"),n.extend({instance:{constructor:function(a,b){this.id=m++,this.leftPattern=a,this.rightPattern=b},hashCode:function(){return[this.leftPattern.hashCode(),this.rightPattern.hashCode()].join(":")},getSpecificity:function(){return this.rightPattern.getSpecificity()+this.leftPattern.getSpecificity()},getters:{constraints:function(){return this.leftPattern.constraints.concat(this.rightPattern.constraints)}}}}).as(c,"CompositePattern");var q=h({instance:{constructor:function(){this.id=m++,this.recency=0}}}).as(c,"InitialFact");o.extend({instance:{constructor:function(){this._super([q,"__i__",[],{}])},assert:function(){return!0}}}).as(c,"InitialFactPattern")},{"./constraint":8,"./constraintMatcher":9,"./extended":12}],46:[function(a,b,c){"use strict";function d(a,b,c,d){f(b)?(d=c,c=b):b=b||{};var g=e.every(c,function(a){return f(a)});g&&1===c.length&&(c=c[0],g=!1);var h=[],i=b.scope||{};if(c.scope=i,g){for(var j,k=function(a,b){m[b]?e(m).forEach(function(b){b.push(a)}):(m[b]=0===b?[]:m[b-1].slice(),0!==b&&m[b].pop(),m[b].push(a))},l=c.length,m=[],n=0;l>n;n++)j=c[n],j.scope=i,e.forEach(y(j),k);h=e.map(m,function(c){for(var e=null,f=0;f>>0;if(0===d)return-1;var e=d;arguments.length>2&&(e=Number(arguments[2]),e!==e?e=0:0!==e&&e!==1/0&&e!==-(1/0)&&(e=(e>0||-1)*P(Q(e))));for(var f=e>=0?R(e,d-1):d-Q(e);f>=0;f--)if(f in c&&c[f]===b)return f;return-1}function i(a,b,c){if(a&&X&&X===a.filter)return a.filter(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)if(g in d){var h=d[g];b.call(c,h,g,d)&&f.push(h)}return f}function j(a,b,c){if(!N(a)||"function"!=typeof b)throw new TypeError;if(a&&T&&T===a.forEach)return a.forEach(b,c),a;for(var d=0,e=a.length;e>d;++d)b.call(c||a,a[d],d,a);return a}function k(a,b,c){if(a&&Y&&Y===a.every)return a.every(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&!b.call(c,d[f],f,d))return!1;return!0}function l(a,b,c){if(a&&Z&&Z===a.some)return a.some(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&b.call(c,d[f],f,d))return!0;return!1}function m(a,b,c){if(a&&U&&U===a.map)return a.map(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)g in d&&f.push(b.call(c,d[g],g,d));return f}function n(a,b,c){var d=arguments.length>2;if(a&&V&&V===a.reduce)return d?a.reduce(b,c):a.reduce(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=0,f=a.length>>0;if(arguments.length<3){if(0===f)throw new TypeError("Array length is 0 and no second argument");c=a[0],e=1}else c=arguments[2];for(;f>e;)e in a&&(c=b.call(void 0,c,a[e],e,a)),++e;return c}function o(a,b,c){var d=arguments.length>2;if(a&&W&&W===a.reduceRight)return d?a.reduceRight(b,c):a.reduceRight(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=Object(a),f=e.length>>>0;if(0===f&&2===arguments.length)throw new TypeError;var g=f-1;if(arguments.length>=3)c=arguments[2];else for(;;)if(g in a){c=a[g--];break}for(;g>=0;)g in e&&(c=b.call(void 0,c,e[g],g,e)),g--;return c}function p(a){var c=[];if(null!==a){var d=$(arguments);if(1===d.length)if(N(a))c=a;else if(b.isHash(a))for(var e in a)a.hasOwnProperty(e)&&c.push([e,a[e]]);else c.push(a);else j(d,function(a){c=c.concat(p(a))})}return c}function q(a){return a=a||[],a.length?n(a,function(a,b){return a+b}):0}function r(a){if(a=a||[],a.length){var c=q(a);if(b.isNumber(c))return c/a.length;throw new Error("Cannot average an array of non numbers.")}return 0}function s(a,b){return _(a,b)}function t(a,b){return _(a,b)[0]}function u(a,b){return _(a,b)[a.length-1]}function v(a){var b=a,c=J($(arguments,1));return N(a)&&(b=i(a,function(a){return-1===g(c,a)})),b}function w(a){var b,c=[],d=-1,e=0;if(a)for(b=a.length;++d0?(c.push(c.shift()),b--):(c.unshift(c.pop()),b++),y(c,b)):c}function z(a,b){var c=[];if(N(a)){var d=a.slice(0);"number"!=typeof b&&(b=a.length),b?b<=a.length&&(c=n(a,function(a,c,f){var g;return g=b>1?e(c,y(d,f).slice(1),b):[[c]],a.concat(g)},[])):c=[[]]}return c}function A(){var a=[],c=$(arguments);if(c.length>1){var d=c.shift();N(d)&&(a=n(d,function(a,d,e){for(var f=[d],g=0;gd;d++)c.push(a[b[d]]||null);return c}function D(){var a=[],b=$(arguments);if(b.length>1){for(var c=0,d=b.length;d>c;c++)a=a.concat(b[c]);a=w(a)}return a}function E(){var a,b,c=[],d=-1;if(a=arguments.length>1?$(arguments):arguments[0],N(a))for(c=a[0],d=0,b=a.length;++d1?c:p(a),n(b,function(a,b){return a.concat(b)},[])}function K(a,b){b=b.split(".");var c=a.slice(0);return j(b,function(a){var b=a.match(/(\w+)\(\)$/);c=m(c,function(c){return b?c[b[1]]():c[a]})}),c}function L(a,b,c){return c=$(arguments,2),m(a,function(a){var d=M(b)?a[b]:b;return d.apply(a,c)})}var M=b.isString,N=Array.isArray||b.isArray,O=b.isDate,P=Math.floor,Q=Math.abs,R=(Math.max,Math.min),S=Array.prototype,T=(S.indexOf,S.forEach),U=S.map,V=S.reduce,W=S.reduceRight,X=S.filter,Y=S.every,Z=S.some,$=c.argsToArray,_=function(){var a=function(a,b){return k(a,b)},b=function(a,b){return a-b},c=function(a,b){return a.getTime()-b.getTime()};return function(d,e){var f=[];return N(d)&&(f=d.slice(),e?"function"==typeof e?f.sort(e):f.sort(function(a,b){var c=a[e],d=b[e];return M(c)&&M(d)?c>d?1:d>c?-1:0:O(c)&&O(d)?c.getTime()-d.getTime():c-d}):a(f,M)?f.sort():a(f,O)?f.sort(c):f.sort(b)),f}}(),ab={toArray:p,sum:q,avg:r,sort:s,min:t,max:u,difference:v,removeDuplicates:w,unique:x,rotate:y,permutations:z,zip:A,transpose:B,valuesAt:C,union:D,intersect:E,powerSet:F,cartesian:G,compact:H,multiply:I,flatten:J,pluck:K,invoke:L,forEach:j,map:m,filter:i,reduce:n,reduceRight:o,some:l,every:k,indexOf:g,lastIndexOf:h};return a.define(N,ab).expose(ab)}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.arrayExtended=d(this.extended,this.isExtended,this.argumentsExtended)}.call(this)},{"arguments-extended":48,extended:53,"is-extended":70}],50:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b,c,d){a=""+a,c=c||" ";for(var e=a.length;b>e;)d?a+=c:a=c+a,e++;return a}function e(a,c,d){var f=a;if(b.isString(f)){if(a.length>c)if(d){var g=a.length;f=a.substring(g-c,g)}else f=a.substring(0,c)}else f=e(""+f,c);return f}function f(a,c,d){if(!b.isArray(a)||"function"!=typeof c)throw new TypeError;for(var e=Object(a),f=e.length>>>0,g=0;f>g;g++)if(g in e&&!c.call(d,e[g],g,e))return!1;return!0}function g(a,b){return A.difference(new Date(a.getFullYear(),0,1,a.getHours()),a,null,b)+1}function h(a,b,c){b=b||0;var d=a[c?"getUTCFullYear":"getFullYear"](),e=new Date(d,0,1).getDay(),f=(e-b+7)%7,h=o((g(a)+f-1)/7);return e===b&&h++,h}function i(a){var b=a.toString(),c="",d=b.indexOf("(");return d>-1&&(c=b.substring(++d,b.indexOf(")"))),c}function j(a,b){return a.replace(/([a-z])\1*/gi,function(a){var c,d=a.charAt(0),e=a.length,f="0?",g="0{0,2}";if("y"===d)c="\\d{2,4}";else if("M"===d)c=e>2?"\\S+?":"1[0-2]|"+f+"[1-9]";else if("D"===d)c="[12][0-9][0-9]|3[0-5][0-9]|36[0-6]|"+g+"[1-9][0-9]|"+f+"[1-9]";else if("d"===d)c="3[01]|[12]\\d|"+f+"[1-9]";else if("w"===d)c="[1-4][0-9]|5[0-3]|"+f+"[1-9]";else if("E"===d)c="\\S+";else if("h"===d)c="1[0-2]|"+f+"[1-9]";else if("K"===d)c="1[01]|"+f+"\\d";else if("H"===d)c="1\\d|2[0-3]|"+f+"\\d";else if("k"===d)c="1\\d|2[0-4]|"+f+"[1-9]";else if("m"===d||"s"===d)c="[0-5]\\d";else if("S"===d)c="\\d{"+e+"}";else if("a"===d){var h="AM",i="PM";c=h+"|"+i,h!==h.toLowerCase()&&(c+="|"+h.toLowerCase()),i!==i.toLowerCase()&&(c+="|"+i.toLowerCase()),c=c.replace(/\./g,"\\.")}else c="v"===d||"z"===d||"Z"===d||"G"===d||"q"===d||"Q"===d?".*":" "===d?"\\s*":d+"*";return b&&b.push(a),"("+c+")"}).replace(/[\xa0 ]/g,"[\\s\\xa0]")}function k(a){B[a+"sFromNow"]=function(b){return A.add(new Date,a,b)},B[a+"sAgo"]=function(b){return A.add(new Date,a,-b)}}for(var l=function(){function a(a,b,c){return a=a.replace(/s$/,""),e.hasOwnProperty(a)?e[a](b,c):[c,"UTC"+a.charAt(0).toUpperCase()+a.substring(1)+"s",!1]}function b(a,b,c,e){return a=a.replace(/s$/,""),d(f[a](b,c,e))}var c=Math.floor,d=Math.round,e={day:function(a,b){return[b,"Date",!1]},weekday:function(a,b){var c,d,e=b%5,f=a.getDay(),g=0;e?(c=e,d=parseInt(b/5,10)):(c=b>0?5:-5,d=b>0?(b-5)/5:(b+5)/5),6===f&&b>0?g=1:0===f&&0>b&&(g=-1);var h=f+c;return(0===h||6===h)&&(g=b>0?2:-2),[7*d+c+g,"Date",!1]},year:function(a,b){return[b,"FullYear",!0]},week:function(a,b){return[7*b,"Date",!1]},quarter:function(a,b){return[3*b,"Month",!0]},month:function(a,b){return[b,"Month",!0]}},f={quarter:function(a,b,d){var e=b.getFullYear()-a.getFullYear(),f=a[d?"getUTCMonth":"getMonth"](),g=b[d?"getUTCMonth":"getMonth"](),h=c(f/3)+1,i=c(g/3)+1;return i+=4*e,i-h},weekday:function(a,c,d){var e,f=b("day",a,c,d),g=f%7;if(0===g)f=5*b("week",a,c,d);else{var h=0,i=a[d?"getUTCDay":"getDay"](),j=c[d?"getUTCDay":"getDay"]();e=parseInt(f/7,10);var k=new Date(+a);k.setDate(k[d?"getUTCDate":"getDate"]()+7*e);var l=k[d?"getUTCDay":"getDay"]();f>0?6===i||6===j?h=-1:0===i?h=0:(0===j||l+g>5)&&(h=-2):0>f&&(6===i?h=0:0===i||0===j?h=1:(6===j||0>l+g)&&(h=2)),f+=h,f-=2*e}return f},year:function(a,b){return b.getFullYear()-a.getFullYear()},month:function(a,b,c){var d=a[c?"getUTCMonth":"getMonth"](),e=b[c?"getUTCMonth":"getMonth"]();return e-d+12*(b.getFullYear()-a.getFullYear())},week:function(a,c,e){return d(b("day",a,c,e)/7)},day:function(a,b){return 1.1574074074074074e-8*(b.getTime()-a.getTime())},hour:function(a,b){return 2.7777777777777776e-7*(b.getTime()-a.getTime())},minute:function(a,b){return 16666666666666667e-21*(b.getTime()-a.getTime())},second:function(a,b){return.001*(b.getTime()-a.getTime())},millisecond:function(a,b){return b.getTime()-a.getTime()}};return{addTransform:a,differenceTransform:b}}(),m=l.addTransform,n=l.differenceTransform,o=Math.floor,p=Math.round,q=Math.min,r=Math.pow,s=Math.ceil,t=Math.abs,u=["January","February","March","April","May","June","July","August","September","October","November","December"],v=["Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."],w=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],x=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],y=["Before Christ","Anno Domini"],z=["BC","AD"],A={getDaysInMonth:function(a){var b=a.getMonth(),c=[31,28,31,30,31,30,31,31,30,31,30,31];return 1===b&&A.isLeapYear(a)?29:c[b]},isLeapYear:function(a,b){var c=a[b?"getUTCFullYear":"getFullYear"]();return 0===c%400||0===c%4&&0!==c%100},isWeekend:function(a,b){var c=(a||new Date)[b?"getUTCDay":"getDay"]();return 0===c||6===c},getTimezoneName:i,compare:function(a,b,c){return a=new Date(+a),b=new Date(+(b||new Date)),"date"===c?(a.setHours(0,0,0,0),b.setHours(0,0,0,0)):"time"===c&&(a.setFullYear(0,0,0),b.setFullYear(0,0,0)),a>b?1:b>a?-1:0},add:function(a,b,c){var d=m(b,a,c||0);c=d[0];var e=d[1],f=new Date(+a),g=d[2];return e&&f["set"+e](f["get"+e]()+c),g&&f.getDate()E?z:y)[0>f?0:1];else if("y"===D)B=f,E>1&&(2===E?B=e(""+B,2,!0):C=!0);else if("Q"===D.toUpperCase())B=s((j+1)/3),C=!0;else if("M"===D)3>E?(B=j+1,C=!0):B=(3===E?v:u)[j];else if("w"===D)B=h(a,0,c),C=!0;else if("D"===D)B=g(a,c),C=!0;else if("E"===D)3>E?(B=k+1,C=!0):B=(-3===E?x:w)[k];else if("a"===D)B=12>m?"AM":"PM";else if("h"===D)B=m%12||12,C=!0;else if("K"===D)B=m%12,C=!0;else if("k"===D)B=m||24,C=!0;else if("S"===D)B=p(A*r(10,E-3)),C=!0;else if("z"===D||"v"===D||"Z"===D){if(B=i(a),"z"!==D&&"v"!==D||B||(E=4),!B||"Z"===D){var F=a.getTimezoneOffset(),G=[F>=0?"-":"+",d(o(t(F)/60),2,"0"),d(t(F)%60,2,"0")];4===E&&(G.splice(0,0,"GMT"),G.splice(3,0,":")),B=G.join("")}}else B=b;else B=""+n,C=!0;else B=""+m,C=!0;return C&&(B=d(B,E,"0")),B})}},B={},C=["year","month","day","hour","minute","second"],D=0,E=C.length;E>D;D++)k(C[D]);var F={parseDate:function(a,b){if(!b)throw new Error("format required when calling dateExtender.parse");var d=[],e=j(b,d),g=new RegExp("^"+e+"$","i"),h=g.exec(a);if(!h)return null;var i=[1970,0,1,0,0,0,0],k="",l=f(h,function(a,b){if(b){var e=d[b-1],f=e.length,g=e.charAt(0);if("y"===g)if(100>a){a=parseInt(a,10);var h=""+(new Date).getFullYear(),j=100*h.substring(0,2),l=q(h.substring(2,4)+20,99);i[0]=l>a?j+a:j-100+a}else i[0]=a;else if("M"===g){if(f>2){var m,n,o=u;3===f&&(o=v),a=a.replace(".","").toLowerCase();var p=!1;for(m=0,n=o.length;n>m&&!p;m++){var r=o[m].replace(".","").toLocaleLowerCase();r===a&&(a=m,p=!0)}if(!p)return!1}else a--;i[1]=a}else if("E"===g||"e"===g){var s=w;3===f&&(s=x),a=a.toLowerCase(),s=c.map(s,function(a){return a.toLowerCase()});var t=c.indexOf(s,a);if(-1===t){if(a=parseInt(a,10),isNaN(a)||a>s.length)return!1}else a=t}else if("D"===g||"d"===g)"D"===g&&(i[1]=0),i[2]=a;else if("a"===g){var y="am",z="pm",A=/\./g;a=a.replace(A,"").toLowerCase(),k=a===z?"p":a===y?"a":""}else"k"===g||"h"===g||"H"===g||"K"===g?("k"===g&&24===+a&&(a=0),i[3]=a):"m"===g?i[4]=a:"s"===g?i[5]=a:"S"===g&&(i[6]=a)}return!0});if(l){var m=+i[3];"p"===k&&12>m?i[3]=m+12:"a"===k&&12===m&&(i[3]=0);var n=new Date(i[0],i[1],i[2],i[3],i[4],i[5],i[6]),o=-1!==c.indexOf(d,"d"),p=-1!==c.indexOf(d,"M"),r=i[1],s=i[2],t=n.getMonth(),y=n.getDate();return p&&t>r||o&&y>s?null:n}return null}},G=a.define(b.isDate,A).define(b.isString,F).define(b.isNumber,B);for(D in A)A.hasOwnProperty(D)&&(G[D]=A[D]);for(D in F)F.hasOwnProperty(D)&&(G[D]=F[D]);for(D in B)B.hasOwnProperty(D)&&(G[D]=B[D]);return G}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c)}):this.dateExtended=d(this.extended,this.isExtended,this.arrayExtended)}.call(this)},{"array-extended":49,extended:53,"is-extended":70}],51:[function(a,b,c){!function(){function a(){function a(a,b){return b=b||0,x.call(a,b)}function b(a){return"[object Array]"===Object.prototype.toString.call(a)}function c(a){var b;return null!==a&&a!==b&&"object"==typeof a}function d(a){var b=c(a);return b&&a.constructor===Object}function e(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function f(a,b,c){var d,f;for(d in b)b.hasOwnProperty(d)&&-1===e(c,d)&&(f=b[d],d in a&&a[d]===f||(a[d]=f));return a}function g(a){var c=this.__meta,d=c.supers,e=d.length,f=c.superMeta,g=f.pos;if(e>g){a=a?B(a)||b(a)?a:[a]:[];var h,i=f.name,j=f.f;do if(h=d[g][i],"function"==typeof h&&(h=h._f||h)!==j)return f.pos=1+g,h.apply(this,a);while(e>++g)}return null}function h(){var a=this.__meta,b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.bind(this);while(c>++e)}return null}function i(a){var b=this.__getters__;return b.hasOwnProperty(a)?b[a].apply(this):this[a]}function j(b,c){var e=this.__setters__;if(!d(b))return e.hasOwnProperty(b)?e[b].apply(this,a(arguments,1)):this[b]=c;for(var f in b){var g=b[f];e.hasOwnProperty(f)?e[b].call(this,g):this[f]=g}}function k(){var a=this.__meta||{},b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.apply(this,arguments);while(c>++e)}return null}function l(a,b){if(a.toString().match(A)){var c=function(){var c,d=this.__meta||{},e=d.superMeta;switch(d.superMeta={f:a,pos:0,name:b},arguments.length){case 0:c=a.call(this);break;case 1:c=a.call(this,arguments[0]);break;case 2:c=a.call(this,arguments[0],arguments[1]);break;case 3:c=a.call(this,arguments[0],arguments[1],arguments[2]);break;default:c=a.apply(this,arguments)}return d.superMeta=e,c};return c._f=a,c}return a._f=a,a}function m(a,b){var c=b.setters||{},d=a.__setters__,e=a.__getters__;for(var f in c)d.hasOwnProperty(f)||(d[f]=c[f]);c=b.getters||{};for(f in c)e.hasOwnProperty(f)||(e[f]=c[f]);for(var g in b)if("getters"!==g&&"setters"!==g){var h=b[g];"function"==typeof h?a.hasOwnProperty(g)||(a[g]=l(k,g)):a[g]=h}}function n(){for(var b=a(arguments),c=b.length,d=this.prototype,e=d.__meta,f=this.__meta,g=d.__meta.bases,h=g.slice(),i=f.supers||[],j=e.supers||[],k=0;c>k;k++){var l=b[k],n=l.prototype,p=n.__meta,q=l.__meta;!p&&(p=n.__meta={proto:n||{}}),!q&&(q=l.__meta={proto:l.__proto__||{}}),m(d,p.proto||{}),m(this,q.proto||{}),o(l.prototype,j,g),o(l,i,h)}return this}function o(a,b,c){var d=a.__meta;!d&&(d=a.__meta={});var f=a.__meta.unique;if(!f&&(d.unique="declare"+ ++y),-1===e(c,f)){c.push(f);for(var g=a.__meta.supers||[],h=g.length-1||0;h>=0;)o(g[h--],b,c);b.unshift(a)}}function p(a,b){var c=b.setters,d=a.__setters__,e=a.__getters__;if(c)for(var f in c)d[f]=c[f];if(c=b.getters||{})for(f in c)e[f]=c[f];for(f in b)if("getters"!=f&&"setters"!=f){var g=b[f];if("function"==typeof g){var h=g.__meta||{};a[f]=h.isConstructor?g:l(g,f)}else a[f]=g}}function q(a,b){return a&&b?a[b]=this:a.exports=a=this,this}function r(a){return u(this,a)}function s(a){z.prototype=a.prototype;var b=new z;return z.prototype=null,b}function t(a,c,e){var i={},j=[],m="declare"+ ++y,q=[],r=[],t=[],u=[],v={supers:t,unique:m,bases:q,superMeta:{f:null,pos:0,name:null}},x={supers:u,unique:m,bases:r,isConstructor:!0,superMeta:{f:null,pos:0,name:null}};if(d(c)&&!e&&(e=c,c=w),"function"==typeof c||b(c)?(j=b(c)?c:[c],c=j.shift(),a.__meta=x,i=s(c),i.__meta=v,i.__getters__=f({},i.__getters__||{}),i.__setters__=f({},i.__setters__||{}),a.__getters__=f({},a.__getters__||{}),a.__setters__=f({},a.__setters__||{}),o(c.prototype,t,q),o(c,u,r)):(a.__meta=x,i.__meta=v,i.__getters__=i.__getters__||{},i.__setters__=i.__setters__||{},a.__getters__=a.__getters__||{},a.__setters__=a.__setters__||{}),a.prototype=i,e){var z=v.proto=e.instance||{},A=x.proto=e.static||{};A.init=A.init||k,p(i,z),p(a,A),i.constructor=z.hasOwnProperty("constructor")?l(z.constructor,"constructor"):z.constructor=l(k,"constructor")}else v.proto={},x.proto={},a.init=l(k,"init"),i.constructor=l(k,"constructor");j.length&&n.apply(a,j),c&&f(a,f(f({},c),a)),i._super=a._super=g,i._getSuper=a._getSuper=h,i._static=a}function u(a,b){function c(){switch(arguments.length){case 0:this.constructor.call(this);break;case 1:this.constructor.call(this,arguments[0]);break;case 2:this.constructor.call(this,arguments[0],arguments[1]);break;case 3:this.constructor.call(this,arguments[0],arguments[1],arguments[2]);break;default:this.constructor.apply(this,arguments)}}return t(c,a,b),c.init()||c}function v(a,b){function c(){return d||(this.constructor.apply(this,arguments),d=this),d}var d;return t(c,a,b),c.init()||c}var w,x=Array.prototype.slice,y=0,z=new Function,A=/(super)/g,B=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};return B(arguments)||(B=function(a){return!(!a||!a.hasOwnProperty("callee"))}),w=u({instance:{get:i,set:j},"static":{get:i,set:j,mixin:n,extend:r,as:q}}),u.singleton=v,u}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=a()):"function"==typeof define&&define.amd?define(a):this.declare=a()}()},{}],52:[function(a,b){b.exports=a("./declare.js")},{"./declare.js":51}],53:[function(a,b,c){!function(){"use strict";function d(a){function b(){var b=a.define(); -return b.expose({register:function(a,c){c||(c=a,a=null);var d=typeof c;if(a)b[a]=c;else if(c&&"function"===d)b.extend(c);else{if("object"!==d)throw new TypeError("extended.register must be called with an extender function");b.expose(c)}return b},define:function(){return a.define.apply(a,arguments)}}),b}function c(){return b()}return function(){function a(a,b){var c,d;for(c in b)b.hasOwnProperty(c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}return function(b){b||(b={});for(var c=1,d=arguments.length;d>c;c++)a(b,arguments[c]);return b}}(),c.define=function(){return a.define.apply(a,arguments)},c}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extender"))):"function"==typeof define&&define.amd?define(["extender"],function(a){return d(a)}):this.extended=d(this.extender)}.call(this)},{extender:55}],54:[function(a,b,c){!function(){function d(a){function b(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function c(a){return"[object Array]"===Object.prototype.toString.call(a)}function d(b){function c(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);a.unshift(this._value);var b=c.apply(this,a);return b!==e?this.__extender__(b):this},a[b]=d}function d(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);return a.unshift(this._value),c.apply(this,a)},a[b]=d}function h(a,b,e){for(var f in b)b.hasOwnProperty(f)&&("getters"!==f&&"setters"!==f?"noWrap"===f?h(a,b[f],!0):e?d(a,f,b[f]):c(a,f,b[f]):a[f]=b[f])}function i(a){var b,c,d=a;if(!(a instanceof m)){var e=m;for(b=0,c=n.length;c>b;b++){var f=n[b];f[0](a)&&(e=e.extend({instance:f[1]}))}d=new e(a),d.__extender__=i}return d}function j(){return!0}function k(a,b){if(arguments.length){"object"==typeof a&&(b=a,a=j),b=b||{};var d={};h(d,b),d.hasOwnProperty("constructor")||(b.hasOwnProperty("constructor")?c(d,"constructor",b.constructor):d.constructor=function(){this._super(arguments)}),n.push([a,d])}return i}function l(a){return a&&a.hasOwnProperty("__defined__")&&(i.__defined__=n=n.concat(a.__defined__)),g(i,a,["define","extend","expose","__defined__"]),i}b=b||[];var m=a({instance:{constructor:function(a){this._value=a},value:function(){return this._value},eq:function(a){return this.__extender__(this._value===a)},neq:function(a){return this.__extender__(this._value!==a)},print:function(){return console.log(this._value),this}}}),n=[];return i.define=k,i.extend=l,i.expose=function(){for(var a,b=0,c=arguments.length;c>b;b++)a=arguments[b],"object"==typeof a&&g(i,a,["define","extend","expose","__defined__"]);return i},i.__defined__=n,i}var e,f=Array.prototype.slice,g=function(){function a(a,c,d){var e,f;for(e in c)c.hasOwnProperty(e)&&-1===b(d,e)&&(f=c[e],e in a&&a[e]===f||(a[e]=f));return a}return function(b){b||(b={});var d=arguments.length,e=arguments[arguments.length-1];c(e)?d--:e=[];for(var f=1;d>f;f++)a(b,arguments[f],e);return b}}();return{define:function(){return d().define.apply(d,arguments)},extend:function(a){return d().define().extend(a)}}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("declare.js"))):"function"==typeof define&&define.amd?define(["declare"],function(a){return d(a)}):this.extender=d(this.declare)}.call(this)},{"declare.js":52}],55:[function(a,b){b.exports=a("./extender.js")},{"./extender.js":54}],56:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b,c){var d;switch((b||[]).length){case 0:d=a.call(c);break;case 1:d=a.call(c,b[0]);break;case 2:d=a.call(c,b[0],b[1]);break;case 3:d=a.call(c,b[0],b[1],b[2]);break;default:d=a.apply(c,b)}return d}function e(a,b,c){if(c=p(arguments,2),n(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!n(b)&&!o(b))throw new Error(b+" is not a function");return n(b)?function(){var d=a[b];if(o(d)){var e=c.concat(p(arguments));return d.apply(a,e)}return d}:c.length?function(){return c.concat(p(arguments)),d(b,arguments,a)}:function(){return d(b,arguments,a)}}function f(a,b){if(b=p(arguments,1),!n(a)&&!o(a))throw new Error(a+" must be the name of a property or function to execute");return n(a)?function(){var c=p(arguments),d=c.shift(),e=d[a];return o(e)?(c=b.concat(c),e.apply(d,c)):e}:function(){var c=p(arguments),d=c.shift();return c=b.concat(c),a.apply(d,c)}}function g(a,b,c){if(c=p(arguments,2),n(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!n(b)&&!o(b))throw new Error(b+" is not a function");return n(b)?function(){var d=a[b];return o(d)?d.apply(a,c):d}:function(){return b.apply(a,c)}}function h(a){var b=p(arguments,1);if(!m(a)&&!o(a))throw new TypeError("scope must be an object");if(1===b.length&&l(b[0])&&(b=b[0]),!b.length){b=[];for(var c in a)a.hasOwnProperty(c)&&o(a[c])&&b.push(c)}for(var d=0,f=b.length;f>d;d++)a[b[d]]=e(a,a[b[d]]);return a}function i(a,b){if(b=p(arguments,1),!n(a)&&!o(a))throw new Error(a+" must be the name of a property or function to execute");return n(a)?function(){var c=this[a];if(o(c)){var d=b.concat(p(arguments));return c.apply(this,d)}return c}:function(){var c=b.concat(p(arguments));return a.apply(this,c)}}function j(a,b){return function(){var c=p(arguments);return b?a.apply(this,arguments):function(){return a.apply(this,c.concat(p(arguments)))}}}function k(a,b,c){var d;if(d=c?e(c,b):b,a)for(var f=a-1,g=f;g>=0;g--)d=j(d,g===f);return d}var l=b.isArray,m=b.isObject,n=b.isString,o=b.isFunction,p=c.argsToArray;return a.define(m,{bind:e,bindAll:h,bindIgnore:g,curry:function(a,b,c){return k(b,c,a)}}).define(o,{bind:function(a,b){return e.apply(this,[b,a].concat(p(arguments,2)))},bindIgnore:function(a,b){return g.apply(this,[b,a].concat(p(arguments,2)))},partial:i,applyFirst:f,curry:function(a,b,c){return k(b,a,c)},noWrap:{f:function(){return this.value()}}}).define(n,{bind:function(a,b){return e(b,a)},bindIgnore:function(a,b){return g(b,a)},partial:i,applyFirst:f,curry:function(a,b,c){return k(b,a,c)}}).expose({bind:e,bindAll:h,bindIgnore:g,partial:i,applyFirst:f,curry:k})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.functionExtended=d(this.extended,this.isExtended,this.argumentsExtended)}.call(this)},{"arguments-extended":57,extended:58,"is-extended":63}],57:[function(a,b,c){!function(){"use strict";function d(a,b){function c(a,b){var c=-1,d=0,e=a.length,f=[];for(b=b||0,c+=b;++cc;c++)a(b,arguments[c]);return b}}(),c.define=function(){return a.define.apply(a,arguments)},c}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extender"))):"function"==typeof define&&define.amd?define(["extender"],function(a){return d(a)}):this.extended=d(this.extender)}.call(this)},{extender:60}],59:[function(a,b,c){!function(){function d(a){function b(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function c(a){return"[object Array]"===Object.prototype.toString.call(a)}function d(b){function c(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);a.unshift(this._value);var b=c.apply(this,a);return b!==e?this.__extender__(b):this},a[b]=d}function d(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);return a.unshift(this._value),c.apply(this,a)},a[b]=d}function h(a,b,e){for(var f in b)b.hasOwnProperty(f)&&("getters"!==f&&"setters"!==f?"noWrap"===f?h(a,b[f],!0):e?d(a,f,b[f]):c(a,f,b[f]):a[f]=b[f])}function i(a){var b,c,d=a;if(!(a instanceof m)){var e=m;for(b=0,c=n.length;c>b;b++){var f=n[b];f[0](a)&&(e=e.extend({instance:f[1]}))}d=new e(a),d.__extender__=i}return d}function j(){return!0}function k(a,b){if(arguments.length){"object"==typeof a&&(b=a,a=j),b=b||{};var d={};h(d,b),d.hasOwnProperty("constructor")||(b.hasOwnProperty("constructor")?c(d,"constructor",b.constructor):d.constructor=function(){this._super(arguments)}),n.push([a,d])}return i}function l(a){return a&&a.hasOwnProperty("__defined__")&&(i.__defined__=n=n.concat(a.__defined__)),g(i,a,["define","extend","expose","__defined__"]),i}b=b||[];var m=a({instance:{constructor:function(a){this._value=a},value:function(){return this._value},eq:function(a){return this.__extender__(this._value===a)},neq:function(a){return this.__extender__(this._value!==a)},print:function(){return console.log(this._value),this}}}),n=[];return i.define=k,i.extend=l,i.expose=function(){for(var a,b=0,c=arguments.length;c>b;b++)a=arguments[b],"object"==typeof a&&g(i,a,["define","extend","expose","__defined__"]);return i},i.__defined__=n,i}var e,f=Array.prototype.slice,g=function(){function a(a,c,d){var e,f;for(e in c)c.hasOwnProperty(e)&&-1===b(d,e)&&(f=c[e],e in a&&a[e]===f||(a[e]=f));return a}return function(b){b||(b={});var d=arguments.length,e=arguments[arguments.length-1];c(e)?d--:e=[];for(var f=1;d>f;f++)a(b,arguments[f],e);return b}}();return{define:function(){return d().define.apply(d,arguments)},extend:function(a){return d().define().extend(a)}}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("declare.js"))):"function"==typeof define&&define.amd?define(["declare"],function(a){return d(a)}):this.extender=d(this.declare)}.call(this)},{"declare.js":62}],60:[function(a,b){b.exports=a("./extender.js")},{"./extender.js":59}],61:[function(a,b,c){!function(){function a(){function a(a,b){return b=b||0,x.call(a,b)}function b(a){return"[object Array]"===Object.prototype.toString.call(a)}function c(a){var b;return null!==a&&a!==b&&"object"==typeof a}function d(a){var b=c(a);return b&&a.constructor===Object}function e(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function f(a,b,c){var d,f;for(d in b)b.hasOwnProperty(d)&&-1===e(c,d)&&(f=b[d],d in a&&a[d]===f||(a[d]=f));return a}function g(a){var c=this.__meta,d=c.supers,e=d.length,f=c.superMeta,g=f.pos;if(e>g){a=a?B(a)||b(a)?a:[a]:[];var h,i=f.name,j=f.f;do if(h=d[g][i],"function"==typeof h&&(h=h._f||h)!==j)return f.pos=1+g,h.apply(this,a);while(e>++g)}return null}function h(){var a=this.__meta,b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.bind(this);while(c>++e)}return null}function i(a){var b=this.__getters__;return b.hasOwnProperty(a)?b[a].apply(this):this[a]}function j(b,c){var e=this.__setters__;if(!d(b))return e.hasOwnProperty(b)?e[b].apply(this,a(arguments,1)):this[b]=c;for(var f in b){var g=b[f];e.hasOwnProperty(f)?e[b].call(this,g):this[f]=g}}function k(){var a=this.__meta||{},b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.apply(this,arguments);while(c>++e)}return null}function l(a,b){if(a.toString().match(A)){var c=function(){var c,d=this.__meta||{},e=d.superMeta;switch(d.superMeta={f:a,pos:0,name:b},arguments.length){case 0:c=a.call(this);break;case 1:c=a.call(this,arguments[0]);break;case 2:c=a.call(this,arguments[0],arguments[1]);break;case 3:c=a.call(this,arguments[0],arguments[1],arguments[2]);break;default:c=a.apply(this,arguments)}return d.superMeta=e,c};return c._f=a,c}return a._f=a,a}function m(a,b){var c=b.setters||{},d=a.__setters__,e=a.__getters__;for(var f in c)d.hasOwnProperty(f)||(d[f]=c[f]);c=b.getters||{};for(f in c)e.hasOwnProperty(f)||(e[f]=c[f]);for(var g in b)if("getters"!==g&&"setters"!==g){var h=b[g];"function"==typeof h?a.hasOwnProperty(g)||(a[g]=l(k,g)):a[g]=h}}function n(){for(var b=a(arguments),c=b.length,d=this.prototype,e=d.__meta,f=this.__meta,g=d.__meta.bases,h=g.slice(),i=f.supers||[],j=e.supers||[],k=0;c>k;k++){var l=b[k],n=l.prototype,p=n.__meta,q=l.__meta;!p&&(p=n.__meta={proto:n||{}}),!q&&(q=l.__meta={proto:l.__proto__||{}}),m(d,p.proto||{}),m(this,q.proto||{}),o(l.prototype,j,g),o(l,i,h)}return this}function o(a,b,c){var d=a.__meta;!d&&(d=a.__meta={});var f=a.__meta.unique;if(!f&&(d.unique="declare"+ ++y),-1===e(c,f)){c.push(f);for(var g=a.__meta.supers||[],h=g.length-1||0;h>=0;)o(g[h--],b,c);b.unshift(a)}}function p(a,b){var c=b.setters,d=a.__setters__,e=a.__getters__;if(c)for(var f in c)d[f]=c[f];if(c=b.getters||{})for(f in c)e[f]=c[f];for(f in b)if("getters"!=f&&"setters"!=f){var g=b[f];if("function"==typeof g){var h=g.__meta||{};a[f]=h.isConstructor?g:l(g,f)}else a[f]=g}}function q(a,b){return a&&b?a[b]=this:a.exports=a=this,this}function r(a){return u(this,a)}function s(a){z.prototype=a.prototype;var b=new z;return z.prototype=null,b}function t(a,c,e){var i={},j=[],m="declare"+ ++y,q=[],r=[],t=[],u=[],v={supers:t,unique:m,bases:q,superMeta:{f:null,pos:0,name:null}},x={supers:u,unique:m,bases:r,isConstructor:!0,superMeta:{f:null,pos:0,name:null}};if(d(c)&&!e&&(e=c,c=w),"function"==typeof c||b(c)?(j=b(c)?c:[c],c=j.shift(),a.__meta=x,i=s(c),i.__meta=v,i.__getters__=f({},i.__getters__||{}),i.__setters__=f({},i.__setters__||{}),a.__getters__=f({},a.__getters__||{}),a.__setters__=f({},a.__setters__||{}),o(c.prototype,t,q),o(c,u,r)):(a.__meta=x,i.__meta=v,i.__getters__=i.__getters__||{},i.__setters__=i.__setters__||{},a.__getters__=a.__getters__||{},a.__setters__=a.__setters__||{}),a.prototype=i,e){var z=v.proto=e.instance||{},A=x.proto=e.static||{};A.init=A.init||k,p(i,z),p(a,A),i.constructor=z.hasOwnProperty("constructor")?l(z.constructor,"constructor"):z.constructor=l(k,"constructor")}else v.proto={},x.proto={},a.init=l(k,"init"),i.constructor=l(k,"constructor");j.length&&n.apply(a,j),c&&f(a,f(f({},c),a)),i._super=a._super=g,i._getSuper=a._getSuper=h,i._static=a}function u(a,b){function c(){this.constructor.apply(this,arguments)}return t(c,a,b),c.init()||c}function v(a,b){function c(){return d||(this.constructor.apply(this,arguments),d=this),d}var d;return t(c,a,b),c.init()||c}var w,x=Array.prototype.slice,y=0,z=new Function,A=/(super)/g,B=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};return B(arguments)||(B=function(a){return!(!a||!a.hasOwnProperty("callee"))}),w=u({instance:{get:i,set:j},"static":{get:i,set:j,mixin:n,extend:r,as:q}}),u.singleton=v,u}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=a()):"function"==typeof define&&define.amd?define(a):this.declare=a()}()},{}],62:[function(a,b){b.exports=a("./declare.js")},{"./declare.js":61}],63:[function(a,b,c){var d=a("__browserify_Buffer").Buffer;!function(){"use strict";function e(a){function b(a,b){return b=b||0,S.call(a,b)}function c(a){var b=[];for(var c in a)T.call(a,c)&&b.push(c);return b}function e(a,b){if(a===b)return!0;if("undefined"!=typeof d&&d.isBuffer(a)&&d.isBuffer(b)){if(a.length!==b.length)return!1;for(var c=0;c=0;f--)if(g[f]!==h[f])return!1;for(f=g.length-1;f>=0;f--)if(d=g[f],!e(a[d],b[d]))return!1}catch(i){return!1}return!0}function g(a){return null!==a&&"object"==typeof a}function h(a){var b=g(a);return b&&a.constructor===Object&&!a.nodeType&&!a.setInterval}function i(a){return W(a)?0===a.length:g(a)?0===c(a).length:r(a)||X(a)?0===a.length:!0}function j(a){return a===!0||a===!1||"[object Boolean]"===U.call(a)}function k(a){return"undefined"==typeof a}function l(a){return!k(a)}function m(a){return k(a)||n(a)}function n(a){return null===a}function o(a,b){return V(b)?a instanceof b:!1}function p(a){return"[object RegExp]"===U.call(a)}function q(a){return"[object Date]"===U.call(a)}function r(a){return"[object String]"===U.call(a)}function s(a){return"[object Number]"===U.call(a)}function t(a){return a===!0}function u(a){return a===!1}function v(a){return!n(a)}function w(a,b){return a==b}function x(a,b){return a!=b}function y(a,b){return a===b}function z(a,b){return a!==b}function A(a,b){if(X(b)&&Array.prototype.indexOf||r(b))return b.indexOf(a)>-1;if(X(b))for(var c=0,d=b.length;d>c;c++)if(w(a,b[c]))return!0;return!1}function B(a,b){return!A(a,b)}function C(a,b){return b>a}function D(a,b){return b>=a}function E(a,b){return a>b}function F(a,b){return a>=b}function G(a,b){return r(b)?null!==(""+a).match(b):p(b)?b.test(a):!1}function H(a,b){return!G(a,b)}function I(a,b){return A(b,a)}function J(a,b){return!A(b,a)}function K(a,b,c){return X(a)&&a.length>c?w(a[c],b):!1}function L(a,b,c){return X(a)?!w(a[c],b):!1}function M(a,b){return T.call(a,b)}function N(a,b){return!M(a,b)}function O(a,b){return M(a,"length")?a.length===b:!1}function P(a,b){return M(a,"length")?a.length!==b:!1}function Q(a){Z[a]=function(){this._testers.push(Y[a])}}function R(a){$[a]=function(){var c,d=b(arguments,1),e=Y[a],f=!0;if(d.length<=e.length-1)throw new TypeError("A handler must be defined when calling using switch");if(c=d.pop(),j(c)&&(f=c,c=d.pop()),!V(c))throw new TypeError("handler must be defined");this._cases.push(function(a){return e.apply(Y,a.concat(d))?[f,c.apply(this,a)]:[!1]})}}var S=Array.prototype.slice,T=Object.prototype.hasOwnProperty,U=Object.prototype.toString,V=function(a){return"[object Function]"===U.call(a)};"undefined"==typeof window||V(window.alert)||function(a){V=function(b){return"[object Function]"===U.call(b)||b===a}}(window.alert);var W=function(a){return"[object Arguments]"===U.call(a)};W(arguments)||(W=function(a){return!(!a||!T.call(a,"callee"))});var X=Array.isArray||function(a){return"[object Array]"===U.call(a)},Y={isFunction:V,isObject:g,isEmpty:i,isHash:h,isNumber:s,isString:r,isDate:q,isArray:X,isBoolean:j,isUndefined:k,isDefined:l,isUndefinedOrNull:m,isNull:n,isArguments:W,instanceOf:o,isRegExp:p,deepEqual:e,isTrue:t,isFalse:u,isNotNull:v,isEq:w,isNeq:x,isSeq:y,isSneq:z,isIn:A,isNotIn:B,isLt:C,isLte:D,isGt:E,isGte:F,isLike:G,isNotLike:H,contains:I,notContains:J,has:M,notHas:N,isLength:O,isNotLength:P,containsAt:K,notContainsAt:L},Z={constructor:function(){this._testers=[]},noWrap:{tester:function(){var a=this._testers;return function(b){for(var c=!1,d=0,e=a.length;e>d&&!c;d++)c=a[d](b);return c}}}},$={constructor:function(){this._cases=[],this.__default=null},def:function(a,b){this.__default=b},noWrap:{switcher:function(){var a=this._cases,c=this.__default;return function(){for(var d,e=!1,f=b(arguments),g=0,h=a.length;h>g&&!e;g++)if(d=a[g](f),d.length>1&&(d[1]||d[0]))return d[1];return!e&&c?c.apply(this,f):void 0}}}};for(var _ in Y)T.call(Y,_)&&(R(_),Q(_));var ab=a.define(Y).expose(Y);return ab.tester=a.define(Z),ab.switcher=a.define($),ab}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("extended"))):"function"==typeof define&&define.amd?define(["extended"],function(a){return e(a)}):this.isExtended=e(this.extended)}.call(this)},{__browserify_Buffer:67,extended:58}],64:[function(a,b,c){function d(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;ce;e++)d[e].apply(this,c);return!0}return!1},f.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(g(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:h,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},f.prototype.on=f.prototype.addListener,f.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},f.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(g(c)){var e=d(c,b);if(0>e)return this;c.splice(e,1),0==c.length&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},f.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},f.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),g(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]},f.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?"function"==typeof a._events[b]?1:a._events[b].length:0}},{__browserify_process:68}],65:[function(){},{}],66:[function(a,b,c){function d(a,b){for(var c=[],d=0;d=0;d--){var e=a[d];"."==e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var f=a("__browserify_process"),g=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){for(var a="",b=!1,c=arguments.length;c>=-1&&!b;c--){var g=c>=0?arguments[c]:f.cwd();"string"==typeof g&&g&&(a=g+"/"+a,b="/"===g.charAt(0))}return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b="/"===a.charAt(0),c="/"===a.slice(-1);return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),a||b||(a="."),a&&c&&(a+="/"),(b?"/":"")+a},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(d(a,function(a){return a&&"string"==typeof a}).join("/"))},c.dirname=function(a){var b=g.exec(a)[1]||"",c=!1;return b?1===b.length||c&&b.length<=3&&":"===b.charAt(1)?b:b.substring(0,b.length-1):"."},c.basename=function(a,b){var c=g.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return g.exec(a)[3]||""},c.relative=function(a,b){function d(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;i=0;e--)if(f[e]!=g[e])return!1;for(e=f.length-1;e>=0;e--)if(d=f[e],!h(a[d],b[d]))return!1;return!0}function l(a,b){return a&&b?b instanceof RegExp?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function m(a,b,c,d){var e;"string"==typeof c&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f("Missing expected exception"+d),!a&&l(e,c)&&f("Got unwanted exception"+d),a&&e&&c&&!l(e,c)||!a&&e)throw e}var n=a("util"),o=a("buffer").Buffer,p=Array.prototype.slice,q=b.exports=g;q.AssertionError=function(a){this.name="AssertionError",this.message=a.message,this.actual=a.actual,this.expected=a.expected,this.operator=a.operator;var b=a.stackStartFunction||f;Error.captureStackTrace&&Error.captureStackTrace(this,b)},n.inherits(q.AssertionError,Error),q.AssertionError.prototype.toString=function(){return this.message?[this.name+":",this.message].join(" "):[this.name+":",e(JSON.stringify(this.actual,d),128),this.operator,e(JSON.stringify(this.expected,d),128)].join(" ")},q.AssertionError.__proto__=Error.prototype,q.fail=f,q.ok=g,q.equal=function(a,b,c){a!=b&&f(a,b,c,"==",q.equal)},q.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",q.notEqual)},q.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",q.deepEqual)},q.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",q.notDeepEqual)},q.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",q.strictEqual)},q.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",q.notStrictEqual)},q.throws=function(){m.apply(this,[!0].concat(p.call(arguments)))},q.doesNotThrow=function(){m.apply(this,[!1].concat(p.call(arguments)))},q.ifError=function(a){if(a)throw a}},{util:2,buffer:3}],2:[function(a,b,c){function d(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&d(a.__proto__)}function e(a){return a instanceof RegExp||"object"==typeof a&&"[object RegExp]"===Object.prototype.toString.call(a)}function f(a){if(a instanceof Date)return!0;if("object"!=typeof a)return!1;var b=Date.prototype&&h(Date.prototype),c=a.__proto__&&h(a.__proto__);return JSON.stringify(c)===JSON.stringify(b)}a("events"),c.isArray=d,c.isDate=function(a){return"[object Date]"===Object.prototype.toString.call(a)},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)},c.print=function(){},c.puts=function(){},c.debug=function(){},c.inspect=function(a,b,i,j){function k(a,i){if(a&&"function"==typeof a.inspect&&a!==c&&(!a.constructor||a.constructor.prototype!==a))return a.inspect(i);switch(typeof a){case"undefined":return m("undefined","undefined");case"string":var j="'"+JSON.stringify(a).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return m(j,"string");case"number":return m(""+a,"number");case"boolean":return m(""+a,"boolean")}if(null===a)return m("null","null");var n=g(a),o=b?h(a):n;if("function"==typeof a&&0===o.length){if(e(a))return m(""+a,"regexp");var p=a.name?": "+a.name:"";return m("[Function"+p+"]","special")}if(f(a)&&0===o.length)return m(a.toUTCString(),"date");var q,r,s;if(d(a)?(r="Array",s=["[","]"]):(r="Object",s=["{","}"]),"function"==typeof a){var t=a.name?": "+a.name:"";q=e(a)?" "+a:" [Function"+t+"]"}else q="";if(f(a)&&(q=" "+a.toUTCString()),0===o.length)return s[0]+q+s[1];if(0>i)return e(a)?m(""+a,"regexp"):m("[Object]","special");l.push(a);var u=o.map(function(b){var c,e;if(a.__lookupGetter__&&(a.__lookupGetter__(b)?e=a.__lookupSetter__(b)?m("[Getter/Setter]","special"):m("[Getter]","special"):a.__lookupSetter__(b)&&(e=m("[Setter]","special"))),n.indexOf(b)<0&&(c="["+b+"]"),e||(l.indexOf(a[b])<0?(e=null===i?k(a[b]):k(a[b],i-1),e.indexOf("\n")>-1&&(e=d(a)?e.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+e.split("\n").map(function(a){return" "+a}).join("\n"))):e=m("[Circular]","special")),"undefined"==typeof c){if("Array"===r&&b.match(/^\d+$/))return e;c=JSON.stringify(""+b),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=m(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=m(c,"string"))}return c+": "+e});l.pop();var v=0,w=u.reduce(function(a,b){return v++,b.indexOf("\n")>=0&&v++,a+b.length+1},0);return u=w>50?s[0]+(""===q?"":q+"\n ")+" "+u.join(",\n ")+" "+s[1]:s[0]+q+" "+u.join(", ")+" "+s[1]}var l=[],m=function(a,b){var c={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[b];return d?"["+c[d][0]+"m"+a+"["+c[d][1]+"m":a};return j||(m=function(a){return a}),k(a,"undefined"==typeof i?2:i)},c.log=function(){},c.pump=null;var g=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},h=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.hasOwnProperty.call(a,c)&&b.push(c);return b},i=Object.create||function(a,b){var c;if(null===a)c={__proto__:null};else{if("object"!=typeof a)throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}return"undefined"!=typeof b&&Object.defineProperties&&Object.defineProperties(c,b),c};c.inherits=function(a,b){a.super_=b,a.prototype=i(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}) -};var j=/%[sdj%]/g;c.format=function(a){if("string"!=typeof a){for(var b=[],d=0;d=f)return a;switch(a){case"%s":return String(e[d++]);case"%d":return Number(e[d++]);case"%j":return JSON.stringify(e[d++]);default:return a}}),h=e[d];f>d;h=e[++d])g+=null===h||"object"!=typeof h?" "+h:" "+c.inspect(h);return g}},{events:4}],5:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],6:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],4:[function(a,b,c){!function(a){function b(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;cf;f++)d[f].apply(this,c);return!0}return!1},d.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(e(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:f,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},d.prototype.removeListener=function(a,c){if("function"!=typeof c)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var d=this._events[a];if(e(d)){var f=b(d,c);if(0>f)return this;d.splice(f,1),0==d.length&&delete this._events[a]}else this._events[a]===c&&delete this._events[a];return this},d.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},d.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),e(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}(a("__browserify_process"))},{__browserify_process:6}],"buffer-browserify":[function(a,b){b.exports=a("q9TxCC")},{}],q9TxCC:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used=a.length?0:(c?(e=a.parent[a.offset+b]<<8,b+1=a.length?0:(c?(b+1>>0):(b+2>>0)),e)}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8*(d?1-f:f)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>8*(d?3-f:f)}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fthis.length)throw new Error("oob");if(b>c)throw new Error("oob");for(var d=b;c>d;d++)this[d]=a},c.SlowBuffer=d,c.Buffer=l,l.poolSize=8192;var E;l.isBuffer=function(a){return a instanceof l||a instanceof d},l.concat=function(a,b){if(!Array.isArray(a))throw new Error("Usage: Buffer.concat(list, [totalLength])\n list should be an Array.");if(0===a.length)return new l(0);if(1===a.length)return a[0];if("number"!=typeof b){b=0;for(var c=0;cd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=c.length?void 0:c.parent[c.offset+a]},l.prototype.readUInt16LE=function(a,b){return o(this,a,!1,b)},l.prototype.readUInt16BE=function(a,b){return o(this,a,!0,b)},l.prototype.readUInt32LE=function(a,b){return p(this,a,!1,b)},l.prototype.readUInt32BE=function(a,b){return p(this,a,!0,b)},l.prototype.readInt8=function(a,b){var c,d=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=d.length?void 0:(c=128&d.parent[d.offset+a],c?-1*(255-d.parent[d.offset+a]+1):d.parent[d.offset+a])},l.prototype.readInt16LE=function(a,b){return q(this,a,!1,b)},l.prototype.readInt16BE=function(a,b){return q(this,a,!0,b)},l.prototype.readInt32LE=function(a,b){return r(this,a,!1,b)},l.prototype.readInt32BE=function(a,b){return r(this,a,!0,b)},l.prototype.readFloatLE=function(a,b){return s(this,a,!1,b)},l.prototype.readFloatBE=function(a,b){return s(this,a,!0,b)},l.prototype.readDoubleLE=function(a,b){return t(this,a,!1,b)},l.prototype.readDoubleBE=function(a,b){return t(this,a,!0,b)},l.prototype.writeUInt8=function(a,b,c){var d=this;c||(D.ok(void 0!==a&&null!==a,"missing value"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":5,"base64-js":7}],7:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(255&f>>8),h.push(255&f)),h}function c(a){function b(a){return d[63&a>>18]+d[63&a>>12]+d[63&a>>6]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[63&e<<4],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[63&e>>4],h+=d[63&e<<2],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}],8:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],3:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used>>0):(e=a.parent[a.offset+b+2]<<16,e|=a.parent[a.offset+b+1]<<8,e|=a.parent[a.offset+b],e+=a.parent[a.offset+b+3]<<24>>>0),e}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8,a.parent[a.offset+c+1]=255&b):(a.parent[a.offset+c+1]=(65280&b)>>>8,a.parent[a.offset+c]=255&b)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>24,a.parent[a.offset+c+1]=255&b>>>16,a.parent[a.offset+c+2]=255&b>>>8,a.parent[a.offset+c+3]=255&b):(a.parent[a.offset+c+3]=255&b>>>24,a.parent[a.offset+c+2]=255&b>>>16,a.parent[a.offset+c+1]=255&b>>>8,a.parent[a.offset+c]=255&b)}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob"); -if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":8,"base64-js":9}],9:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(255&f>>8),h.push(255&f)),h}function c(a){function b(a){return d[63&a>>18]+d[63&a>>12]+d[63&a>>6]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[63&e<<4],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[63&e>>4],h+=d[63&e<<2],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}]},{},[]),b.exports=a("buffer-browserify")},{}],68:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],69:[function(a,b,c){!function(){"use strict";function d(a){var b=function(a){return"string"==typeof a?a:"object"==typeof a?a.hashCode?a.hashCode():""+a:""+a},c=a.declare({instance:{constructor:function(){this.__entries=[],this.__keys=[],this.__values=[]},pushValue:function(a,b){return this.__keys.push(a),this.__values.push(b),this.__entries.push({key:a,value:b}),b},remove:function(a){for(var b,c=null,d=this.__entries,e=this.__keys,f=this.__values,g=d.length-1;g>=0;g--)if((b=d[g])&&b.key===a)return d.splice(g,1),e.splice(g,1),f.splice(g,1),b.value;return c},set:function(a,b){for(var c=null,d=this.__entries,e=this.__values,f=d.length-1;f>=0;f--){var g=d[f];if(g&&a===g.key){e[f]=b,g.value=b,c=b;break}}return c||d.push({key:a,value:b}),c},find:function(a){for(var b,c=null,d=this.__entries,e=d.length-1;e>=0;e--)if(b=d[e],b&&a===b.key){c=b.value;break}return c},getEntrySet:function(){return this.__entries},getKeys:function(){return this.__keys},getValues:function(){return this.__values}}});return a.declare({instance:{constructor:function(){this.__map={}},entrySet:function(){var a=[],b=this.__map;for(var c in b)b.hasOwnProperty(c)&&(a=a.concat(b[c].getEntrySet()));return a},put:function(a,d){var e=b(a),f=null;return(f=this.__map[e])||(f=this.__map[e]=new c),f.pushValue(a,d),d},remove:function(a){var c=b(a),d=null,e=this.__map[c];return e&&(d=e.remove(a)),d},get:function(a){var c,d=b(a),e=null;return(c=this.__map[d])&&(e=c.find(a)),e},set:function(a,d){var e=b(a),f=null,g=null,h=this.__map;return f=(g=h[e])?g.set(a,d):(h[e]=new c).pushValue(a,d)},contains:function(a){var c=b(a),d=!1,e=null;return(e=this.__map[c])&&(d=!!e.find(a)),d},concat:function(a){if(a instanceof this._static){for(var b=new this._static,c=a.entrySet().concat(this.entrySet()),d=c.length-1;d>=0;d--){var e=c[d];b.put(e.key,e.value)}return b}throw new TypeError("When joining hashtables the joining arg must be a HashTable")},filter:function(b,c){var d=this.entrySet(),e=new this._static;d=a.filter(d,b,c);for(var f=d.length-1;f>=0;f--){var g=d[f];e.put(g.key,g.value)}return e},forEach:function(b,c){var d=this.entrySet();a.forEach(d,b,c)},every:function(b,c){var d=this.entrySet();return a.every(d,b,c)},map:function(b,c){var d=this.entrySet();return a.map(d,b,c)},some:function(b,c){var d=this.entrySet();return a.some(d,b,c)},reduce:function(b,c){var d=this.entrySet();return a.reduce(d,b,c)},reduceRight:function(b,c){var d=this.entrySet();return a.reduceRight(d,b,c)},clear:function(){this.__map={}},keys:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getKeys());return a},values:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getValues());return a},isEmpty:function(){return 0===this.keys().length}}})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")))):"function"==typeof define?define(["extended","declare","is-extended","array-extended"],function(a,b,c,e){return d(a().register("declare",b).register(c).register(e))}):this.Ht=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended))}.call(this)},{"array-extended":49,"declare.js":52,extended:53,"is-extended":70}],70:[function(a,b,c){var d=a("__browserify_Buffer").Buffer;!function(){"use strict";function e(a){function b(a,b){var c=-1,d=0,e=a.length,f=[];for(b=b||0,c+=b;++c=0;f--)if(g[f]!==h[f])return!1;for(f=g.length-1;f>=0;f--)if(d=g[f],!e(a[d],b[d]))return!1}catch(i){return!1}return!0}function g(a){return null!==a&&"object"==typeof a}function h(a){var b=g(a);return b&&a.constructor===Object&&!a.nodeType&&!a.setInterval}function i(a){return W(a)?0===a.length:g(a)?0===c(a).length:r(a)||X(a)?0===a.length:!0}function j(a){return a===!0||a===!1||"[object Boolean]"===U.call(a)}function k(a){return"undefined"==typeof a}function l(a){return!k(a)}function m(a){return k(a)||n(a)}function n(a){return null===a}function o(a,b){return V(b)?a instanceof b:!1}function p(a){return"[object RegExp]"===U.call(a)}function q(a){return"[object Date]"===U.call(a)}function r(a){return"[object String]"===U.call(a)}function s(a){return"[object Number]"===U.call(a)}function t(a){return a===!0}function u(a){return a===!1}function v(a){return!n(a)}function w(a,b){return a==b}function x(a,b){return a!=b}function y(a,b){return a===b}function z(a,b){return a!==b}function A(a,b){if(X(b)&&Array.prototype.indexOf||r(b))return b.indexOf(a)>-1;if(X(b))for(var c=0,d=b.length;d>c;c++)if(w(a,b[c]))return!0;return!1}function B(a,b){return!A(a,b)}function C(a,b){return b>a}function D(a,b){return b>=a}function E(a,b){return a>b}function F(a,b){return a>=b}function G(a,b){return r(b)?null!==(""+a).match(b):p(b)?b.test(a):!1}function H(a,b){return!G(a,b)}function I(a,b){return A(b,a)}function J(a,b){return!A(b,a)}function K(a,b,c){return X(a)&&a.length>c?w(a[c],b):!1}function L(a,b,c){return X(a)?!w(a[c],b):!1}function M(a,b){return T.call(a,b)}function N(a,b){return!M(a,b)}function O(a,b){return M(a,"length")?a.length===b:!1}function P(a,b){return M(a,"length")?a.length!==b:!1}function Q(a){Z[a]=function(){this._testers.push(Y[a])}}function R(a){$[a]=function(){var c,d=b(arguments,1),e=Y[a],f=!0;if(d.length<=e.length-1)throw new TypeError("A handler must be defined when calling using switch");if(c=d.pop(),j(c)&&(f=c,c=d.pop()),!V(c))throw new TypeError("handler must be defined");this._cases.push(function(a){return e.apply(Y,a.concat(d))?[f,c.apply(this,a)]:[!1]})}}var S=Array.prototype.slice,T=Object.prototype.hasOwnProperty,U=Object.prototype.toString,V=function(a){return"[object Function]"===U.call(a)};"undefined"==typeof window||V(window.alert)||function(a){V=function(b){return"[object Function]"===U.call(b)||b===a}}(window.alert);var W=function(a){return"[object Arguments]"===U.call(a)};W(arguments)||(W=function(a){return!(!a||!T.call(a,"callee"))});var X=Array.isArray||function(a){return"[object Array]"===U.call(a)},Y={isFunction:V,isObject:g,isEmpty:i,isHash:h,isNumber:s,isString:r,isDate:q,isArray:X,isBoolean:j,isUndefined:k,isDefined:l,isUndefinedOrNull:m,isNull:n,isArguments:W,instanceOf:o,isRegExp:p,deepEqual:e,isTrue:t,isFalse:u,isNotNull:v,isEq:w,isNeq:x,isSeq:y,isSneq:z,isIn:A,isNotIn:B,isLt:C,isLte:D,isGt:E,isGte:F,isLike:G,isNotLike:H,contains:I,notContains:J,has:M,notHas:N,isLength:O,isNotLength:P,containsAt:K,notContainsAt:L},Z={constructor:function(){this._testers=[]},noWrap:{tester:function(){var a=this._testers;return function(b){for(var c=!1,d=0,e=a.length;e>d&&!c;d++)c=a[d](b);return c}}}},$={constructor:function(){this._cases=[],this.__default=null},def:function(a,b){this.__default=b},noWrap:{switcher:function(){var a=this._cases,c=this.__default;return function(){for(var d,e=!1,f=b(arguments),g=0,h=a.length;h>g&&!e;g++)if(d=a[g](f),d.length>1&&(d[1]||d[0]))return d[1];return!e&&c?c.apply(this,f):void 0}}}};for(var _ in Y)T.call(Y,_)&&(R(_),Q(_));var ab=a.define(Y).expose(Y);return ab.tester=a.define(Z),ab.switcher=a.define($),ab}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("extended"))):"function"==typeof define&&define.amd?define(["extended"],function(a){return e(a)}):this.isExtended=e(this.extended)}.call(this)},{__browserify_Buffer:67,extended:53}],71:[function(a,b,c){!function(){"use strict";function d(a){function b(a,b){var c=0;return a>b?1:b>a?-1:b?c:1}var c=a.multiply,d=a.declare({instance:{__printNode:function(b,d){var e=[];a.isUndefinedOrNull(b)?(e.push(c(" ",d)),e.push("~"),console.log(e.join(""))):(this.__printNode(b.right,d+1),e.push(c(" ",d)),e.push(b.data+"\n"),console.log(e.join("")),this.__printNode(b.left,d+1))},constructor:function(a){a=a||{},this.compare=a.compare||b,this.__root=null},insert:function(){throw new Error("Not Implemented")},remove:function(){throw new Error("Not Implemented")},clear:function(){this.__root=null},isEmpty:function(){return!this.__root},traverseWithCondition:function(a,b,c){var e=!0;return a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.IN_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.POST_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e&&(e=this.traverseWithCondition(a.right,b,c)),e&&(e=c(a.data)))):b===d.REVERSE_ORDER&&(e=this.traverseWithCondition(a.right,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c))))),e},traverse:function(a,b,c){a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(c(a.data),this.traverse(a.left,b,c),this.traverse(a.right,b,c)):b===d.IN_ORDER?(this.traverse(a.left,b,c),c(a.data),this.traverse(a.right,b,c)):b===d.POST_ORDER?(this.traverse(a.left,b,c),this.traverse(a.right,b,c),c(a.data)):b===d.REVERSE_ORDER&&(this.traverse(a.right,b,c),c(a.data),this.traverse(a.left,b,c)))},forEach:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this,this.traverse(this.__root,c,function(c){a.call(b,c,this)})},map:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){e.insert(a.call(b,c,this))}),e},filter:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){a.call(b,c,this)&&e.insert(c)}),e},reduce:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduce.apply(a,f)},reduceRight:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduceRight.apply(a,f)},every:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=!1;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this)}),e},some:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this),!e}),e},toArray:function(a){a=a||d.IN_ORDER;var b=[];return this.traverse(this.__root,a,function(a){b.push(a)}),b},contains:function(a){for(var b=!1,c=this.__root;null!==c;){var d=this.compare(a,c.data);d?c=c[-1===d?"left":"right"]:(b=!0,c=null)}return b},find:function(a){for(var b,c=this.__root;c;){var d=this.compare(a,c.data);if(!d){b=c.data;break}c=c[-1===d?"left":"right"]}return b},findLessThan:function(a,b){var c=[],e=this.compare;return this.traverseWithCondition(this.__root,d.IN_ORDER,function(d){var f=e(a,d);return!b&&0===f||1===f?(c.push(d),!0):!1}),c},findGreaterThan:function(a,b){var c=[],e=this.compare;return this.traverse(this.__root,d.REVERSE_ORDER,function(d){var f=e(a,d);return!b&&0===f||-1===f?(c.push(d),!0):!1}),c},print:function(){this.__printNode(this.__root,0)}},"static":{PRE_ORDER:"pre_order",IN_ORDER:"in_order",POST_ORDER:"post_order",REVERSE_ORDER:"reverse_order"}}),e=function(){function a(a,b,c){var d=a.__root;if(null===d||void 0===d)a.__root=f(b);else{for(var g,h=d,i=[],k=[],l=0;;){if(g=i[l]=-1===c(b,h.data)?"left":"right",k[l++]=h,!h[g]){h[g]=f(b);break}h=h[g]}if(!h[g])return null;for(;--l>=0&&(k[l].balance+="right"===i[l]?-1:1,0!==k[l].balance);)if(e(k[l].balance)>1){k[l]=j(k[l],i[l]),0!==l?k[l-1][i[l-1]]=k[l]:a.__root=k[0];break}}}function b(a,b,c){var d=a.__root;if(null!==d&&void 0!==d){for(var f,g,h=d,i=0,j=[],l=[],m={done:!1};;){if(!h)return;if(0===(g=c(b,h.data)))break;f=l[i]=-1===g?"left":"right",j[i++]=h,h=h[f]}var n=h.left,o=h.right;if(n&&o){var p=n;for(l[i]="left",j[i++]=h;p.right;)l[i]="right",j[i++]=p,p=p.right;h.data=p.data,j[i-1][j[i-1]===h?"left":"right"]=p.left}else f=n?"left":"right",0!==i?j[i-1][l[i-1]]=h[f]:a.__root=h[f];for(;--i>=0&&!m.done&&(j[i].balance+="left"===l[i]?-1:1,1!==e(j[i].balance));)e(j[i].balance)>1&&(j[i]=k(j[i],l[i],m),0!==i?j[i-1][l[i-1]]=j[i]:a.__root=j[0])}}var e=Math.abs,f=function(a){return{data:a,balance:0,left:null,right:null}},g=function(a,b,c){var d=a[c];return a[c]=d[b],d[b]=a,d},h=function(a,b,c){return a[c]=g(a[c],c,b),g(a,b,c)},i=function(a,b,c){var d="left"===b?"right":"left",e=a[b],f=e[d];0===f.balance?a.balance=e.balance=0:f.balance===c?(a.balance=-c,e.balance=0):(a.balance=0,e.balance=c),f.balance=0},j=function(a,b){var c="left"===b?"right":"left",d=a[b],e="right"===b?-1:1;return d.balance===e?(a.balance=d.balance=0,a=g(a,c,b)):(i(a,b,e),a=h(a,c,b)),a},k=function(a,b,c){var d="left"===b?"right":"left",e=a[d],f="right"===b?-1:1;return e.balance===-f?(a.balance=e.balance=0,a=g(a,b,d)):e.balance===f?(i(a,d,-f),a=h(a,b,d)):(a.balance=-f,e.balance=f,a=g(a,b,d),c.done=!0),a};return d.extend({instance:{insert:function(b){a(this,b,this.compare)},remove:function(a){b(this,a,this.compare)},__printNode:function(a,b){var d=[];a?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.balance+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),f=function(){function a(a,b){return{data:a,level:b,left:g,right:g}}function b(a){if(0!==a.level&&a.left.level===a.level){var b=a.left;a.left=b.right,b.right=a,a=b}return a}function e(a){if(0!==a.level&&a.right.right.level===a.level){var b=a.right;a.right=b.left,b.left=a,a=b,a.level++}return a}function f(c,d,h){if(c===g)c=a(d,1);else{var i=-1===h(d,c.data)?"left":"right";c[i]=f(c[i],d,h),c=b(c),c=e(c)}return c}var g={level:0,data:null},h=function(a,c,d){var f,i;if(a!==g){var j=d(c,a.data);if(0===j)if(f=a.left,i=a.right,f!==g&&i!==g){for(var k=f;k.right!==g;)k=k.right;a.data=k.data,a.left=h(f,k.data,d)}else a=a[f===g?"right":"left"];else{var l=-1===j?"left":"right";a[l]=h(a[l],c,d)}}if(a!==g){var m=a.level,n=a.left.level,o=a.right.level;(m-1>n||m-1>o)&&(o>--a.level&&(a.right.level=a.level),a=b(a),a=e(a))}return a};return d.extend({instance:{isEmpty:function(){return this.__root===g||this._super(arguments)},insert:function(a){this.__root||(this.__root=g),this.__root=f(this.__root,a,this.compare)},remove:function(a){this.__root=h(this.__root,a,this.compare)},traverseWithCondition:function(a){var b=!0;return a!==g?this._super(arguments):b},traverse:function(a){a!==g&&this._super(arguments)},contains:function(){return this.__root!==g?this._super(arguments):!1},__printNode:function(a,b){var d=[];a&&a.data?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.level+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),g=d.extend({instance:{insert:function(a){if(!this.__root)return this.__root={data:a,parent:null,left:null,right:null},this.__root;for(var b=this.compare,c=this.__root;null!==c;){var d=b(a,c.data);if(!d)return;var e=-1===d?"left":"right",f=c[e];if(!f)return c[e]={data:a,parent:c,left:null,right:null};c=f}},remove:function(a){if(null!==this.__root){for(var b,c={right:this.__root},d=c,e=null,f="right";null!==d[f];){b=d,d=d[f];var g=this.compare(a,d.data);g||(e=d),f=-1===g?"left":"right"}null!==e&&(e.data=d.data,b[b.right===d?"right":"left"]=d[null===d.left?"right":"left"]),this.__root=c.right}}}}),h=function(){var a="RED",b="BLACK",e=function(a){return null!==a&&a.red},f=function(a){return{data:a,red:!0,left:null,right:null}},g=function(a,b,c){if(!a)return f(b);var d=c(b,a.data);if(d){var j=-1===d?"left":"right",k="left"===j?"right":"left";a[j]=g(a[j],b,c);var l=a[j];if(e(l)){var m=a[k];e(m)?(a.red=!0,l.red=!1,m.red=!1):e(l[j])?a=h(a,k):e(l[k])&&(a=i(a,k))}}return a},h=function(a,b){var c="left"===b?"right":"left",d=a[c];return a[c]=d[b],d[b]=a,a.red=!0,d.red=!1,d},i=function(a,b){var c="left"===b?"right":"left";return a[c]=h(a[c],c),h(a,b)},j=function(a,b,c,d){if(a){var f;if(0===d(b,a.data)){if(!a.left||!a.right){var g=a[a.left?"left":"right"];return e(a)?c.done=!0:e(g)&&(g.red=!1,c.done=!0),g}for(var h,i=a.right;null!==i.left;)h=i,i=i.left;h&&(h.left=null),a.data=i.data,b=i.data}f=-1===d(b,a.data)?"left":"right",a[f]=j(a[f],b,c,d),c.done||(a=k(a,f,c))}else c.done=!0;return a},k=function(a,b,c){var d="left"===b?"right":"left",f=a,g=f[d];if(e(g)&&(a=h(a,b),g=f[d]),null!==g)if(e(g.left)||e(g.right)){var j=f.red,k=a===f;f=(e(g[d])?h:i)(f,b),f.red=j,f.left.red=f.right.red=0,k?a=f:a[b]=f,c.done=!0}else e(f)&&(c.done=!0),f.red=0,g.red=1;return a};return d.extend({instance:{insert:function(a){this.__root=g(this.__root,a,this.compare),this.__root.red=!1},remove:function(a){var b={done:!1},c=j(this.__root,a,b,this.compare);return null!==c&&(c.red=0),this.__root=c,a},__printNode:function(d,e){var f=[];d?(this.__printNode(d.right,e+1),f.push(c(" ",e)),f.push((d.red?a:b)+":"+d.data+"\n"),console.log(f.join("")),this.__printNode(d.left,e+1)):(f.push(c(" ",e)),f.push("~"),console.log(f.join("")))}}})}();return{Tree:d,AVLTree:e,AnderssonTree:f,BinaryTree:g,RedBlackTree:h,IN_ORDER:d.IN_ORDER,PRE_ORDER:d.PRE_ORDER,POST_ORDER:d.POST_ORDER,REVERSE_ORDER:d.REVERSE_ORDER}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")).register(a("string-extended")))):"function"==typeof define?define(["extended","declare.js","is-extended","array-extended","string-extended"],function(a,b,c,e,f){return d(a().register("declare",b).register(c).register(e).register(f))}):this.leafy=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended).register(this.stringExtended))}.call(this)},{"array-extended":49,"declare.js":52,extended:53,"is-extended":70,"string-extended":74}],72:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b){var c,d;for(c in b)t.call(b,c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}function e(a,b){var c,d,f;for(c in b)t.call(b,c)&&(d=b[c],f=a[c],p(f,d)||(a[c]=r(f)&&r(d)?e(f,d):r(d)?e({},d):d));return a}function f(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)d(a,arguments[b]);return a}function g(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)e(a,arguments[b]);return a}function h(a,b){var c=a.prototype||a;return f(c,b),a}function i(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e=l(a),f=0,g=e.length;g>f;++f)d=e[f],b.call(c||a,a[d],d,a);return a}function j(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e,f=l(a),g={},h=0,i=f.length;i>h;++h)d=f[h],e=a[d],b.call(c||a,e,d,a)&&(g[d]=e);return g}function k(a){if(!r(a))throw new TypeError;for(var b=l(a),c=[],d=0,e=b.length;e>d;++d)c.push(a[b[d]]);return c}function l(a){if(!r(a))throw new TypeError;var b=[];for(var c in a)t.call(a,c)&&b.push(c);return b}function m(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d={},e=0,f=c.length;f>e;++e)b=c[e],d[a[b]]=b;return d}function n(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d=[],e=0,f=c.length;f>e;++e)b=c[e],d.push([b,a[b]]);return d}function o(a,b){if(!r(a))throw new TypeError;q(b)&&(b=[b]);for(var c,d=s(l(a),b),e={},f=0,g=d.length;g>f;++f)c=d[f],e[c]=a[c];return e}var p=b.deepEqual,q=b.isString,r=b.isHash,s=c.difference,t=Object.prototype.hasOwnProperty,u=b.isFunction,v={forEach:i,filter:j,invert:m,values:k,toArray:n,keys:l,omit:o},w={extend:h,merge:f,deepMerge:g,omit:o},x=a.define(b.isObject,w).define(r,v).define(b.isFunction,{extend:h}).expose({hash:v}).expose(w),y=x.extend;return x.extend=function(){return 1===arguments.length?y.extend.apply(x,arguments):(h.apply(null,arguments),void 0)},x}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c)}):this.objectExtended=d(this.extended,this.isExtended,this.arrayExtended)}.call(this)},{"array-extended":49,extended:53,"is-extended":70}],73:[function(a,b,c){var d=a("__browserify_process");!function(){"use strict";function e(a,b,c,e,f,g){function h(a,b){return function(){try{l(a.apply(null,arguments)).addCallback(b).addErrback(b)}catch(c){b.errback(c)}}}function i(a,b,c){var d=(new G).callback();return v(a,function(a){d=d.then(c?a:B(null,a)),c||(d=d.then(function(a){return b.push(a),b}))}),d}function j(a){return!w(a)&&y(a.then)}function k(a){var b=new G;return a.then(A(b,"callback"),A(b,"errback")),b.promise()}function l(a){var b;return a=C(arguments),a.length?1===a.length?(a=a.pop(),j(a)?a.addCallback&&a.addErrback?(b=new G,a.addCallback(b.callback),a.addErrback(b.errback)):b=k(a):b=x(a)&&c.every(a,j)?new H(a,!0).promise():(new G).callback(a)):b=new H(c.map(a,function(a){return l(a)}),!0).promise():b=(new G).callback(a).promise(),b}function m(a,b){return function(){var c=new G,d=C(arguments);return d.push(c.resolve),a.apply(b||this,d),c.promise()}}function n(a){if(x(a))return i(a,[],!1);throw new Error("When calling promise.serial the first argument must be an array")}function o(a){if(x(a))return i(a,[],!0);throw new Error("When calling promise.serial the first argument must be an array")}function p(a,b){a=C(arguments);var c=!1;b=a.pop();var d=l(a);return function(){return c?l(b.apply(this,arguments)):(a=arguments,d.then(A(this,function(){return c=!0,b.apply(this,a)})))}}function q(){return new G}function r(a){return new H(a,!0).promise()}function s(a){return q().errback(a)}function t(a){return q().callback(a)}var u,v=c.forEach,w=e.isUndefinedOrNull,x=e.isArray,y=e.isFunction,z=e.isBoolean,A=f.bind,B=f.bindIgnore,C=g.argsToArray;if("function"==typeof setImmediate)u="undefined"!=typeof window?setImmediate.bind(window):setImmediate;else if("undefined"!=typeof d)u=function(a){d.nextTick(a)};else if("undefined"!=typeof MessageChannel){var D=new MessageChannel,E={},F=E;D.port1.onmessage=function(){E=E.next; -var a=E.task;delete E.task,a()},u=function(a){F=F.next={task:a},D.port2.postMessage(0)}}else u=function(a){setTimeout(a,0)};var G=a({instance:{__fired:!1,__results:null,__error:null,__errorCbs:null,__cbs:null,constructor:function(){this.__errorCbs=[],this.__cbs=[],f.bindAll(this,["callback","errback","resolve","classic","__resolve","addCallback","addErrback"])},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__error?this.__errorCbs:this.__cbs,c=b.length,d=this.__error||this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(this,b)})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=a.callback),this.__fired&&this.__results?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=a.errback),this.__fired&&this.__error?this.__callNextTick(a,this.__error):this.__errorCbs.push(a)),this},callback:function(){return this.__fired||(this.__results=arguments,this.__resolve()),this.promise()},errback:function(){return this.__fired||(this.__error=arguments,this.__resolve()),this.promise()},resolve:function(a){return a?this.errback(a):this.callback.apply(this,C(arguments,1)),this},classic:function(a){return"function"==typeof a&&(this.addErrback(function(b){a(b)}),this.addCallback(function(){a.apply(this,[null].concat(C(arguments)))})),this},then:function(a,b){var c=new G,d=c;return y(b)&&(d=h(b,c)),this.addErrback(d),y(a)?this.addCallback(h(a,c)):this.addCallback(c),c.promise()},both:function(a){return this.then(a,a)},promise:function(){var a={then:A(this,"then"),both:A(this,"both"),promise:function(){return a}};return v(["addCallback","addErrback","classic"],function(b){a[b]=A(this,function(){return this[b].apply(this,arguments),a})},this),a}}}),H=G.extend({instance:{__results:null,__errors:null,__promiseLength:0,__defLength:0,__firedLength:0,normalizeResults:!1,constructor:function(a,b){this.__errors=[],this.__results=[],this.normalizeResults=z(b)?b:!1,this._super(arguments),a&&a.length?(this.__defLength=a.length,v(a,this.__addPromise,this)):this.__resolve()},__addPromise:function(a,b){a.then(A(this,function(){var a=C(arguments);a.unshift(b),this.callback.apply(this,a)}),A(this,function(){var a=C(arguments);a.unshift(b),this.errback.apply(this,a)}))},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__errors.length?this.__errorCbs:this.__cbs,c=b.length,d=this.__errors.length?this.__errors:this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(null,[b])})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=A(a,"callback")),this.__fired&&!this.__errors.length?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=A(a,"errback")),this.__fired&&this.__errors.length?this.__callNextTick(a,this.__errors):this.__errorCbs.push(a)),this},callback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__results[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()},errback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__errors[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()}}});return b.define({isPromiseLike:j}).expose({isPromiseLike:j,when:l,wrap:m,wait:p,serial:n,chain:o,Promise:G,PromiseList:H,promise:q,defer:q,deferredList:r,reject:s,resolve:t})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("declare.js"),a("extended"),a("array-extended"),a("is-extended"),a("function-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["declare","extended","array-extended","is-extended","function-extended","arguments-extended"],function(a,b,c,d,f,g){return e(a,b,c,d,f,g)}):this.promiseExtended=e(this.declare,this.extended,this.arrayExtended,this.isExtended,this.functionExtended,this.argumentsExtended)}.call(this)},{__browserify_process:68,"arguments-extended":48,"array-extended":49,"declare.js":52,extended:53,"function-extended":56,"is-extended":70}],74:[function(a,b,c){!function(){"use strict";function d(a,b,c,d){function e(a,b){var c=a;if(x.test(b)){var d=b.match(x),e=d[1],f=d[3],g=d[4];g&&(g=parseInt(g,10),c=c.length0?"+":"")+d),k&&(k=parseInt(k,10),d=d.lengthe;)d?a+=c:a=c+a,e++;return a}function i(a,c,d){var e=a;if(b.isString(e)){if(a.length>c)if(d){var f=a.length;e=a.substring(f-c,f)}else e=a.substring(0,c)}else e=i(""+e,c);return e}function j(a,d){if(d instanceof Array){var h=0,i=d.length;return a.replace(v,function(a,b,j){var k,l;if(!(i>h))return a;if(k=d[h++],"%s"===a||"%d"===a||"%D"===a)l=k+"";else if("%Z"===a)l=k.toUTCString();else if("%j"===a)try{l=s(k)}catch(m){throw new Error("stringExtended.format : Unable to parse json from ",k)}else switch(b=b.replace(/^\[|\]$/g,""),j){case"s":l=e(k,b);break;case"d":l=f(k,b);break;case"j":l=g(k,b);break;case"D":l=c.format(k,b);break;case"Z":l=c.format(k,b,!0)}return l})}if(t(d))return a.replace(w,function(a,h,i){if(i=d[i],!b.isUndefined(i)){if(!h)return""+i;if(b.isString(i))return e(i,h);if(b.isNumber(i))return f(i,h);if(b.isDate(i))return c.format(i,h);if(b.isObject(i))return g(i,h)}return a});var k=u.call(arguments).slice(1);return j(a,k)}function k(a,b){var c=[];return a&&(a.indexOf(b)>0?c=a.replace(/\s+/g,"").split(b):c.push(a)),c}function l(a,b){var c=[];if(b)for(var d=0;b>d;d++)c.push(a);return c.join("")}function m(a,c){var d,e,f;if(c)if(b.isArray(a))for(d=[],e=0,f=a.length;f>e;e++)d.push(m(a[e],c));else if(c instanceof Array)for(d=a,e=0,f=c.length;f>e;e++)d=m(d,c[e]);else c in z&&(d="["+z[c]+"m"+a+"");return d}function n(a,b){return a.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,function(a){return b&&-1!==d.indexOf(b,a)?a:"\\"+a})}function o(a){return a.replace(/^\s*|\s*$/g,"")}function p(a){return a.replace(/^\s*/,"")}function q(a){return a.replace(/\s*$/,"")}function r(a){return 0===a.length}var s;"undefined"==typeof JSON?function(){function a(a){return 10>a?"0"+a:a}function c(c){return b.isDate(c)?isFinite(c.valueOf())?c.getUTCFullYear()+"-"+a(c.getUTCMonth()+1)+"-"+a(c.getUTCDate())+"T"+a(c.getUTCHours())+":"+a(c.getUTCMinutes())+":"+a(c.getUTCSeconds())+"Z":null:i(c)?c.valueOf():c}function d(a){return j.lastIndex=0,j.test(a)?'"'+a.replace(j,function(a){var b=k[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function e(a,b){var i,j,k,l,m,n=f,o=b[a];switch(o&&(o=c(o)),"function"==typeof h&&(o=h.call(b,a,o)),typeof o){case"string":return d(o);case"number":return isFinite(o)?String(o):"null";case"boolean":case"null":return String(o);case"object":if(!o)return"null";if(f+=g,m=[],"[object Array]"===Object.prototype.toString.apply(o)){for(l=o.length,i=0;l>i;i+=1)m[i]=e(i,o)||"null";return k=0===m.length?"[]":f?"[\n"+f+m.join(",\n"+f)+"\n"+n+"]":"["+m.join(",")+"]",f=n,k}if(h&&"object"==typeof h)for(l=h.length,i=0;l>i;i+=1)"string"==typeof h[i]&&(j=h[i],k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));else for(j in o)Object.prototype.hasOwnProperty.call(o,j)&&(k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));return k=0===m.length?"{}":f?"{\n"+f+m.join(",\n"+f)+"\n"+n+"}":"{"+m.join(",")+"}",f=n,k}}var f,g,h,i=b.tester().isString().isNumber().isBoolean().tester(),j=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,k={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};s=function(a,b,c){var d;if(f="",g="","number"==typeof c)for(d=0;c>d;d+=1)g+=" ";else"string"==typeof c&&(g=c);if(h=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return e("",{"":a})}}():s=JSON.stringify;var t=b.isHash,u=Array.prototype.slice,v=/%((?:-?\+?.?\d*)?|(?:\[[^\[|\]]*\]))?([sjdDZ])/g,w=/\{(?:\[([^\[|\]]*)\])?(\w+)\}/g,x=/(-?)(\+?)([A-Z|a-z|\W]?)([1-9][0-9]*)?$/,y=/([1-9][0-9]*)$/g,z={bold:1,bright:1,italic:3,underline:4,blink:5,inverse:7,crossedOut:9,red:31,green:32,yellow:33,blue:34,magenta:35,cyan:36,white:37,redBackground:41,greenBackground:42,yellowBackground:43,blueBackground:44,magentaBackground:45,cyanBackground:46,whiteBackground:47,encircled:52,overlined:53,grey:90,black:90},A={SMILEY:"☺",SOLID_SMILEY:"☻",HEART:"♥",DIAMOND:"♦",CLOVE:"♣",SPADE:"♠",DOT:"•",SQUARE_CIRCLE:"◘",CIRCLE:"○",FILLED_SQUARE_CIRCLE:"◙",MALE:"♂",FEMALE:"♀",EIGHT_NOTE:"♪",DOUBLE_EIGHTH_NOTE:"♫",SUN:"☼",PLAY:"►",REWIND:"◄",UP_DOWN:"↕",PILCROW:"¶",SECTION:"§",THICK_MINUS:"▬",SMALL_UP_DOWN:"↨",UP_ARROW:"↑",DOWN_ARROW:"↓",RIGHT_ARROW:"→",LEFT_ARROW:"←",RIGHT_ANGLE:"∟",LEFT_RIGHT_ARROW:"↔",TRIANGLE:"▲",DOWN_TRIANGLE:"▼",HOUSE:"⌂",C_CEDILLA:"Ç",U_UMLAUT:"ü",E_ACCENT:"é",A_LOWER_CIRCUMFLEX:"â",A_LOWER_UMLAUT:"ä",A_LOWER_GRAVE_ACCENT:"à",A_LOWER_CIRCLE_OVER:"å",C_LOWER_CIRCUMFLEX:"ç",E_LOWER_CIRCUMFLEX:"ê",E_LOWER_UMLAUT:"ë",E_LOWER_GRAVE_ACCENT:"è",I_LOWER_UMLAUT:"ï",I_LOWER_CIRCUMFLEX:"î",I_LOWER_GRAVE_ACCENT:"ì",A_UPPER_UMLAUT:"Ä",A_UPPER_CIRCLE:"Å",E_UPPER_ACCENT:"É",A_E_LOWER:"æ",A_E_UPPER:"Æ",O_LOWER_CIRCUMFLEX:"ô",O_LOWER_UMLAUT:"ö",O_LOWER_GRAVE_ACCENT:"ò",U_LOWER_CIRCUMFLEX:"û",U_LOWER_GRAVE_ACCENT:"ù",Y_LOWER_UMLAUT:"ÿ",O_UPPER_UMLAUT:"Ö",U_UPPER_UMLAUT:"Ü",CENTS:"¢",POUND:"£",YEN:"¥",CURRENCY:"¤",PTS:"₧",FUNCTION:"ƒ",A_LOWER_ACCENT:"á",I_LOWER_ACCENT:"í",O_LOWER_ACCENT:"ó",U_LOWER_ACCENT:"ú",N_LOWER_TILDE:"ñ",N_UPPER_TILDE:"Ñ",A_SUPER:"ª",O_SUPER:"º",UPSIDEDOWN_QUESTION:"¿",SIDEWAYS_L:"⌐",NEGATION:"¬",ONE_HALF:"½",ONE_FOURTH:"¼",UPSIDEDOWN_EXCLAMATION:"¡",DOUBLE_LEFT:"«",DOUBLE_RIGHT:"»",LIGHT_SHADED_BOX:"░",MEDIUM_SHADED_BOX:"▒",DARK_SHADED_BOX:"▓",VERTICAL_LINE:"│",MAZE__SINGLE_RIGHT_T:"┤",MAZE_SINGLE_RIGHT_TOP:"┐",MAZE_SINGLE_RIGHT_BOTTOM_SMALL:"┘",MAZE_SINGLE_LEFT_TOP_SMALL:"┌",MAZE_SINGLE_LEFT_BOTTOM_SMALL:"└",MAZE_SINGLE_LEFT_T:"├",MAZE_SINGLE_BOTTOM_T:"┴",MAZE_SINGLE_TOP_T:"┬",MAZE_SINGLE_CENTER:"┼",MAZE_SINGLE_HORIZONTAL_LINE:"─",MAZE_SINGLE_RIGHT_DOUBLECENTER_T:"╡",MAZE_SINGLE_RIGHT_DOUBLE_BL:"╛",MAZE_SINGLE_RIGHT_DOUBLE_T:"╢",MAZE_SINGLE_RIGHT_DOUBLEBOTTOM_TOP:"╖",MAZE_SINGLE_RIGHT_DOUBLELEFT_TOP:"╕",MAZE_SINGLE_LEFT_DOUBLE_T:"╞",MAZE_SINGLE_BOTTOM_DOUBLE_T:"╧",MAZE_SINGLE_TOP_DOUBLE_T:"╤",MAZE_SINGLE_TOP_DOUBLECENTER_T:"╥",MAZE_SINGLE_BOTTOM_DOUBLECENTER_T:"╨",MAZE_SINGLE_LEFT_DOUBLERIGHT_BOTTOM:"╘",MAZE_SINGLE_LEFT_DOUBLERIGHT_TOP:"╒",MAZE_SINGLE_LEFT_DOUBLEBOTTOM_TOP:"╓",MAZE_SINGLE_LEFT_DOUBLETOP_BOTTOM:"╙",MAZE_SINGLE_LEFT_TOP:"Γ",MAZE_SINGLE_RIGHT_BOTTOM:"╜",MAZE_SINGLE_LEFT_CENTER:"╟",MAZE_SINGLE_DOUBLECENTER_CENTER:"╫",MAZE_SINGLE_DOUBLECROSS_CENTER:"╪",MAZE_DOUBLE_LEFT_CENTER:"╣",MAZE_DOUBLE_VERTICAL:"║",MAZE_DOUBLE_RIGHT_TOP:"╗",MAZE_DOUBLE_RIGHT_BOTTOM:"╝",MAZE_DOUBLE_LEFT_BOTTOM:"╚",MAZE_DOUBLE_LEFT_TOP:"╔",MAZE_DOUBLE_BOTTOM_T:"╩",MAZE_DOUBLE_TOP_T:"╦",MAZE_DOUBLE_LEFT_T:"╠",MAZE_DOUBLE_HORIZONTAL:"═",MAZE_DOUBLE_CROSS:"╬",SOLID_RECTANGLE:"█",THICK_LEFT_VERTICAL:"▌",THICK_RIGHT_VERTICAL:"▐",SOLID_SMALL_RECTANGLE_BOTTOM:"▄",SOLID_SMALL_RECTANGLE_TOP:"▀",PHI_UPPER:"Φ",INFINITY:"∞",INTERSECTION:"∩",DEFINITION:"≡",PLUS_MINUS:"±",GT_EQ:"≥",LT_EQ:"≤",THEREFORE:"⌠",SINCE:"∵",DOESNOT_EXIST:"∄",EXISTS:"∃",FOR_ALL:"∀",EXCLUSIVE_OR:"⊕",BECAUSE:"⌡",DIVIDE:"÷",APPROX:"≈",DEGREE:"°",BOLD_DOT:"∙",DOT_SMALL:"·",CHECK:"√",ITALIC_X:"✗",SUPER_N:"ⁿ",SQUARED:"²",CUBED:"³",SOLID_BOX:"■",PERMILE:"‰",REGISTERED_TM:"®",COPYRIGHT:"©",TRADEMARK:"™",BETA:"β",GAMMA:"γ",ZETA:"ζ",ETA:"η",IOTA:"ι",KAPPA:"κ",LAMBDA:"λ",NU:"ν",XI:"ξ",OMICRON:"ο",RHO:"ρ",UPSILON:"υ",CHI_LOWER:"φ",CHI_UPPER:"χ",PSI:"ψ",ALPHA:"α",ESZETT:"ß",PI:"π",SIGMA_UPPER:"Σ",SIGMA_LOWER:"σ",MU:"µ",TAU:"τ",THETA:"Θ",OMEGA:"Ω",DELTA:"δ",PHI_LOWER:"φ",EPSILON:"ε"},B={toArray:k,pad:h,truncate:i,multiply:l,format:j,style:m,escape:n,trim:o,trimLeft:p,trimRight:q,isEmpty:r};return a.define(b.isString,B).define(b.isArray,{style:m}).expose(B).expose({characters:A})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("date-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","date-extended","array-extended"],function(a,b,c,e){return d(a,b,c,e)}):this.stringExtended=d(this.extended,this.isExtended,this.dateExtended,this.arrayExtended)}.call(this)},{"array-extended":49,"date-extended":50,extended:53,"is-extended":70}]},{},[1]); \ No newline at end of file +!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gc&&g>c&&c++;);var h=d[c]-e[c];return h||(h=f-g),h}function g(a,b){return a.recency-b.recency}var h=a("./extended").map,i={salience:d,bucketCounter:e,factRecency:f,activationRecency:g};c.strategies=i,c.strategy=function(a){a=h(a,function(a){return i[a]});var b=a.length;return function(c,d){var e=-1,f=0,g=c===d||c.name===d.name&&c.hashCode===d.hashCode;if(!g){for(;++e0?1:-1}return f}}},{"./extended":12}],8:[function(a,b,c){"use strict";var d,e=a("./extended"),f=e.deepEqual,g=e.merge,h=e.instanceOf,i=e.filter,j=e.declare,k=0,l=j({type:null,instance:{constructor:function(b){d||(d=a("./constraintMatcher")),this.id=k++,this.constraint=b,e.bindAll(this,["assert"])},assert:function(){throw new Error("not implemented")},getIndexableProperties:function(){return[]},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return[this.get("alias")]}}}});l.extend({instance:{type:"object",constructor:function(a){this._super([a])},assert:function(a){return a instanceof this.constraint||a.constructor===this.constraint},equal:function(a){return h(a,this._static)&&this.constraint===a.constraint}}}).as(c,"ObjectConstraint");var m=l.extend({instance:{type:"equality",constructor:function(a,b){this._super([a]),b=b||{},this.pattern=b.pattern,this._matcher=d.getMatcher(a,b,!0)},assert:function(a){return this._matcher(a)}}}).as(c,"EqualityConstraint");m.extend({instance:{type:"inequality"}}).as(c,"InequalityConstraint"),m.extend({instance:{type:"comparison"}}).as(c,"ComparisonConstraint"),l.extend({instance:{type:"equality",constructor:function(){this._super([[!0]])},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")},assert:function(){return!0}}}).as(c,"TrueConstraint");var n=l.extend({instance:{type:"reference",constructor:function(a,b){this.cache={},this._super([a]),b=b||{},this.values=[],this.pattern=b.pattern,this._options=b,this._matcher=d.getMatcher(a,b,!1)},assert:function(a,b){try{return this._matcher(a,b)}catch(c){throw new Error("Error with evaluating pattern "+this.pattern+" "+c.message)}},merge:function(a){var b=this;return a instanceof n&&(b=new this._static([this.constraint,a.constraint,"and"],g({},this._options,this._options)),b._alias=this._alias||a._alias,b.vars=this.vars.concat(a.vars)),b},equal:function(a){return h(a,this._static)&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return this.vars},alias:function(){return this._alias}},setters:{alias:function(a){this._alias=a,this.vars=i(d.getIdentifiers(this.constraint),function(b){return b!==a})}}}}).as(c,"ReferenceConstraint");n.extend({instance:{type:"reference_equality",op:"eq",getIndexableProperties:function(){return d.getIndexableProperties(this.constraint)}}}).as(c,"ReferenceEqualityConstraint").extend({instance:{type:"reference_inequality",op:"neq"}}).as(c,"ReferenceInequalityConstraint").extend({instance:{type:"reference_gt",op:"gt"}}).as(c,"ReferenceGTConstraint").extend({instance:{type:"reference_gte",op:"gte"}}).as(c,"ReferenceGTEConstraint").extend({instance:{type:"reference_lt",op:"lt"}}).as(c,"ReferenceLTConstraint").extend({instance:{type:"reference_lte",op:"lte"}}).as(c,"ReferenceLTEConstraint"),l.extend({instance:{type:"hash",constructor:function(a){this._super([a])},equal:function(a){return e.instanceOf(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},assert:function(){return!0},getters:{variables:function(){return this.constraint}}}}).as(c,"HashConstraint"),l.extend({instance:{constructor:function(a,b){this.type="from",this.constraints=d.getSourceMatcher(a,b||{},!0),e.bindAll(this,["assert"])},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")&&f(this.constraints,a.constraints)},assert:function(a,b){return this.constraints(a,b)},getters:{variables:function(){return this.constraint}}}}).as(c,"FromConstraint")},{"./constraintMatcher":9,"./extended":12}],9:[function(a,b,c){"use strict";function d(a){return e(a).map(function(a){return f(a)?f(a[0])?d(a).value():a.reverse().join("."):a}).flatten().filter(function(a){return!!a})}var e=a("./extended"),f=e.isArray,g=e.forEach,h=e.some,i=e.indexOf,j=e.isNumber,k=e.removeDuplicates,l=a("./constraint"),m={indexOf:e.indexOf,now:function(){return new Date},Date:function(a,b,c,d,e,f,g){var h=new Date;return j(a)&&h.setYear(a),j(b)&&h.setMonth(b),j(c)&&h.setDate(c),j(d)&&h.setHours(d),j(e)&&h.setMinutes(e),j(f)&&h.setSeconds(f),j(g)&&h.setMilliseconds(g),h},lengthOf:function(a,b){return a.length===b},isTrue:function(a){return a===!0},isFalse:function(a){return a===!1},isNotNull:function(a){return null!==a},dateCmp:function(a,b){return e.compare(a,b)}};g(["years","days","months","hours","minutes","seconds"],function(a){m[a+"FromNow"]=e[a+"FromNow"],m[a+"Ago"]=e[a+"Ago"]}),g(["isArray","isNumber","isHash","isObject","isDate","isBoolean","isString","isRegExp","isNull","isEmpty","isUndefined","isDefined","isUndefinedOrNull","isPromiseLike","isFunction","deepEqual"],function(a){var b=e[a];m[a]=function(){return b.apply(e,arguments)}});var n={equal:function(a,b){var c=!1;return a===b?c=!0:a[2]===b[2]&&(c=-1!==i(["string","number","boolean","regexp","identifier","null"],a[2])?a[0]===b[0]:"unary"===a[2]||"logicalNot"===a[2]?this.equal(a[0],b[0]):this.equal(a[0],b[0])&&this.equal(a[1],b[1])),c},__getProperties:function(a){var b=[];if(a){var c=a[2];if(!c)return b;"prop"!==c&&"identifier"!==c&&"string"!==c&&"number"!==c&&"boolean"!==c&&"regexp"!==c&&"unary"!==c&&"unary"!==c?(b[0]=this.__getProperties(a[0]),b[1]=this.__getProperties(a[1])):b="identifier"===c?[a[0]]:n.__getProperties(a[1]).concat(n.__getProperties(a[0]))}return b},getIndexableProperties:function(a){return"composite"===a[2]?this.getIndexableProperties(a[0]):/^(\w+(\['[^']*'])*) *([!=]==|[<>]=?) (\w+(\['[^']*'])*)$/.test(this.parse(a))?d(this.__getProperties(a)).flatten().value():[]},getIdentifiers:function(a){var b=[],c=a[2];if("identifier"===c)return[a[0]];if("function"===c)b=b.concat(this.getIdentifiers(a[0])).concat(this.getIdentifiers(a[1]));else if("string"!==c&&"number"!==c&&"boolean"!==c&&"regexp"!==c&&"unary"!==c&&"unary"!==c)if("prop"===c){if(b=b.concat(this.getIdentifiers(a[0])),a[1])for(var d=a[1];f(d);){if("function"===d[2]){b=b.concat(this.getIdentifiers(d[1]));break}d=d[1]}}else a[0]&&(b=b.concat(this.getIdentifiers(a[0]))),a[1]&&(b=b.concat(this.getIdentifiers(a[1])));return k(b)},toConstraints:function(a,b){var c=[],d=b.alias,e=b.scope||{},f=a[2];if("and"===f)c=c.concat(this.toConstraints(a[0],b)).concat(this.toConstraints(a[1],b));else if("composite"===f||"or"===f||"lt"===f||"gt"===f||"lte"===f||"gte"===f||"like"===f||"notLike"===f||"eq"===f||"neq"===f||"in"===f||"notIn"===f||"prop"===f||"propLookup"===f||"function"===f||"logicalNot"===f){var g=h(this.getIdentifiers(a),function(a){return!(a===d||a in m||a in e)});switch(f){case"eq":c.push(new l[g?"ReferenceEqualityConstraint":"EqualityConstraint"](a,b));break;case"neq":c.push(new l[g?"ReferenceInequalityConstraint":"InequalityConstraint"](a,b));break;case"gt":c.push(new l[g?"ReferenceGTConstraint":"ComparisonConstraint"](a,b));break;case"gte":c.push(new l[g?"ReferenceGTEConstraint":"ComparisonConstraint"](a,b));break;case"lt":c.push(new l[g?"ReferenceLTConstraint":"ComparisonConstraint"](a,b));break;case"lte":c.push(new l[g?"ReferenceLTEConstraint":"ComparisonConstraint"](a,b));break;default:c.push(new l[g?"ReferenceConstraint":"ComparisonConstraint"](a,b))}}return c},parse:function(a){return this[a[2]](a[0],a[1])},composite:function(a){return this.parse(a)},and:function(a,b){return["(",this.parse(a),"&&",this.parse(b),")"].join(" ")},or:function(a,b){return["(",this.parse(a),"||",this.parse(b),")"].join(" ")},prop:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"['",this.parse(b),"']"].join("")},propLookup:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"[",this.parse(b),"]"].join("")},unary:function(a){return-1*this.parse(a)},plus:function(a,b){return[this.parse(a),"+",this.parse(b)].join(" ")},minus:function(a,b){return[this.parse(a),"-",this.parse(b)].join(" ")},mult:function(a,b){return[this.parse(a),"*",this.parse(b)].join(" ")},div:function(a,b){return[this.parse(a),"/",this.parse(b)].join(" ")},mod:function(a,b){return[this.parse(a),"%",this.parse(b)].join(" ")},lt:function(a,b){return[this.parse(a),"<",this.parse(b)].join(" ")},gt:function(a,b){return[this.parse(a),">",this.parse(b)].join(" ")},lte:function(a,b){return[this.parse(a),"<=",this.parse(b)].join(" ")},gte:function(a,b){return[this.parse(a),">=",this.parse(b)].join(" ")},like:function(a,b){return[this.parse(b),".test(",this.parse(a),")"].join("")},notLike:function(a,b){return["!",this.parse(b),".test(",this.parse(a),")"].join("")},eq:function(a,b){return[this.parse(a),"===",this.parse(b)].join(" ")},neq:function(a,b){return[this.parse(a),"!==",this.parse(b)].join(" ")},"in":function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) != -1"].join("")},notIn:function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) == -1"].join("")},arguments:function(a,b){var c=[];return a&&c.push(this.parse(a)),b&&c.push(this.parse(b)),c.join(",")},array:function(a){var b=[];return a?(b=this.parse(a),f(b)?b:["[",b,"]"].join("")):["[",b.join(","),"]"].join("")},"function":function(a,b){var c=this.parse(b);return[this.parse(a),"(",c,")"].join("")},string:function(a){return"'"+a+"'"},number:function(a){return a},"boolean":function(a){return a},regexp:function(a){return a},identifier:function(a){return a},"null":function(){return"null"},logicalNot:function(a){return["!(",this.parse(a),")"].join("")}},o=0,p=c.toJs=function(a,b,c,d,f){var g=n.parse(a);b=b||{};var h=n.getIdentifiers(a),i=["var indexOf = definedFuncs.indexOf; var hasOwnProperty = Object.prototype.hasOwnProperty;"],j=[];e(h).filter(function(a){var c=["var ",a," = "];if(m.hasOwnProperty(a))c.push("definedFuncs['",a,"']");else{if(!b.hasOwnProperty(a))return!0;c.push("scope['",a,"']")}return c.push(";"),i.push(c.join("")),!1}).forEach(function(a){var b=["var ",a," = "];d||a!==c?b.push("fact."+a):a===c&&b.push("hash.",a,""),b.push(";"),j.push(b.join(""))});var k=i.join("")+"return function matcher"+o++ +(d?"(fact){":"(fact, hash){")+j.join("")+" return "+(f?f(g):g)+";}",l=new Function("definedFuncs, scope",k)(m,b);return l};c.getMatcher=function(a,b,c){return b=b||{},p(a,b.scope,b.alias,c,function(a){return"!!("+a+")"})},c.getSourceMatcher=function(a,b,c){return b=b||{},p(a,b.scope,b.alias,c,function(a){return a})},c.toConstraints=function(a,b){return n.toConstraints(a,b)},c.equal=function(a,b){return n.equal(a,b)},c.getIdentifiers=function(a){return n.getIdentifiers(a)},c.getIndexableProperties=function(a){return n.getIndexableProperties(a)}},{"./constraint":8,"./extended":12}],10:[function(a,b){"use strict";function c(a,b){for(var c="",d=-1,e=a.length;++di){for(f=a.slice();++gb;b++)a.assert(arguments[b]);return a},containsRule:function(a){return c.some(this.__rules,function(b){return b.name===a})}},"static":{getFlow:function(a){return l[a]},hasFlow:function(a){return c.has(l,a)},deleteFlow:function(a){return d(a,m)&&(a=a.name),delete l[a],m},deleteFlows:function(){for(var a in l)a in l&&delete l[a];return m},create:function(a,b){return new m(a,b)}}}).as(b)},{"./conflict":7,"./extended":12,"./flow":13,"./pattern":48,"./rule":49}],15:[function(a,b,c){"use strict";function d(a){return/\.nools$/.test(a)}function e(a){var b;return b=d(a)?i.parse(g.readFileSync(a,"utf8"),a):i.parse(a)}var f=a("./extended"),g=a("fs"),h=a("path"),i=a("./compile"),j=a("./flowContainer");c.Flow=j,c.getFlow=j.getFlow,c.hasFlow=j.hasFlow,c.deleteFlow=function(a){return j.deleteFlow(a),this},c.deleteFlows=function(){return j.deleteFlows(),this},c.flow=j.create,c.compile=function(a,b,c){if(f.isFunction(b)?(c=b,b={}):(b=b||{},c=null),f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),!b.name)throw new Error("Name required when compiling nools source");return i.compile(a,b,c,j)},c.transpile=function(a,b){return b=b||{},f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),i.transpile(a,b)},c.parse=e},{"./compile":5,"./extended":12,"./flowContainer":14,fs:61,path:62}],16:[function(a,b){var c=a("declare.js");c({instance:{constructor:function(){this.head=null,this.tail=null,this.length=null},push:function(a){var b=this.tail,c=this.head,d={data:a,prev:b,next:null};return b&&(this.tail.next=d),this.tail=d,c||(this.head=d),this.length++,d +},remove:function(a){a.prev?a.prev.next=a.next:this.head=a.next,a.next?a.next.prev=a.prev:this.tail=a.prev,this.length--},forEach:function(a){for(var b={next:this.head};b=b.next;)a(b.data)},toArray:function(){for(var a={next:this.head},b=[];a=a.next;)b.push(a);return b},removeByData:function(a){for(var b={next:this.head};b=b.next;)if(b.data===a){this.remove(b);break}},getByData:function(a){for(var b={next:this.head};b=b.next;)if(b.data===a)return b},clear:function(){this.head=this.tail=null,this.length=0}}}).as(b)},{"declare.js":55}],17:[function(a,b){var c,d=a("__browserify_process"),e=a("./extended");if("function"==typeof setImmediate)c="undefined"!=typeof window?e.bind(window,setImmediate):setImmediate;else if("undefined"!=typeof d)c=d.nextTick;else if("undefined"!=typeof MessageChannel){var f=new MessageChannel,g={},h=g;f.port1.onmessage=function(){g=g.next;var a=g.task;delete g.task,a()},c=function(a){h=h.next={task:a},f.port2.postMessage(0)}}else c=function(a){setTimeout(a,0)};b.exports=c},{"./extended":12,__browserify_process:64}],18:[function(a,b){var c=a("./node"),d=a("../extended").intersection;c.extend({instance:{__propagatePaths:function(a,b){for(var c,e,f,g,h=this.__entrySet,i=h.length;--i>-1;)c=h[i],e=c.key,f=c.value,(g=d(f,b.paths)).length&&e[a](b.clone(null,g,null))},__propagateNoPaths:function(a,b){for(var c=this.__entrySet,d=c.length;--d>-1;)c[d].key[a](b)},__propagate:function(a,b){b.paths?this.__propagatePaths(a,b):this.__propagateNoPaths(a,b)}}}).as(b)},{"../extended":12,"./node":37}],19:[function(a,b){var c=a("./alphaNode");c.extend({instance:{constructor:function(){this._super(arguments),this.alias=this.constraint.get("alias")},toString:function(){return"AliasNode"+this.__count},assert:function(a){return this.__propagate("assert",a.set(this.alias,a.fact.object))},modify:function(a){return this.__propagate("modify",a.set(this.alias,a.fact.object))},retract:function(a){return this.__propagate("retract",a.set(this.alias,a.fact.object))},equal:function(a){return a instanceof this._static&&this.alias===a.alias}}}).as(b)},{"./alphaNode":20}],20:[function(a,b){"use strict";var c=a("./node");c.extend({instance:{constructor:function(a){this._super([]),this.constraint=a,this.constraintAssert=this.constraint.assert},toString:function(){return"AlphaNode "+this.__count},equal:function(a){return this.constraint.equal(a.constraint)}}}).as(b)},{"./node":37}],21:[function(a,b){var c=a("../extended"),d=c.hash.keys,e=a("./node"),f=a("./misc/leftMemory"),g=a("./misc/rightMemory");e.extend({instance:{nodeType:"BetaNode",constructor:function(){this._super([]),this.leftMemory={},this.rightMemory={},this.leftTuples=new f,this.rightTuples=new g},__propagate:function(a,b){for(var c,d,e=this.__entrySet,f=e.length;--f>-1;)c=e[f],d=c.key,d[a](b)},dispose:function(){this.leftMemory={},this.rightMemory={},this.leftTuples.clear(),this.rightTuples.clear()},disposeLeft:function(a){this.leftMemory={},this.leftTuples.clear(),this.propagateDispose(a)},disposeRight:function(a){this.rightMemory={},this.rightTuples.clear(),this.propagateDispose(a)},hashCode:function(){return this.nodeType+" "+this.__count},toString:function(){return this.nodeType+" "+this.__count},retractLeft:function(a){a=this.removeFromLeftMemory(a).data;for(var b=a.rightMatches,c=d(b),e=-1,f=c.length;++eh;h++)if(this.__isMatch(a,e[h],!0)){a.blocked=!0;break}}else f(e)&&(a.blocked=this.__isMatch(a,e,!0));var j=a.blocked;j?c?this.__propagate("modify",a.clone()):this.__propagate("assert",a.clone()):c&&this.__propagate("retract",a.clone())},__findMatches:function(a){var b=a.factHash,c=this.from(b),d=!1;if(g(c)){for(var e=0,h=c.length;h>e;e++)if(this.__isMatch(a,c[e],!0))return a.blocked=!0,this.__propagate("assert",a.clone()),void 0}else f(c)&&this.__isMatch(a,c,!0)&&(a.blocked=!0,this.__propagate("assert",a.clone()));return d},__isMatch:function(a,b,c){var d=!1;if(this.type(b)){var f=this.workingMemory.getFactHandle(b),g=new e(f,null,null).mergeMatch(a.match).set(this.alias,b);if(c){var h=this.fromMemory[f.id];h||(h=this.fromMemory[f.id]={}),h[a.hashCode]=a}for(var i=g.factHash,j=this.__equalityConstraints,k=0,l=j.length;l>k;k++){if(!j[k](i)){d=!1;break}d=!0}}return d},assertLeft:function(a){this.__addToLeftMemory(a),this.__findMatches(a)}}}).as(b)},{"../context":10,"../extended":12,"./fromNotNode":26}],24:[function(a,b){var c=a("./notNode"),d=a("../linkedList");c.extend({instance:{nodeType:"ExistsNode",blockedContext:function(a,b){a.blocker=b,this.removeFromLeftMemory(a),this.addToLeftBlockedMemory(b.blocking.push(a)),this.__propagate("assert",this.__cloneContext(a))},notBlockedContext:function(a,b){this.__addToLeftMemory(a),b&&this.__propagate("retract",this.__cloneContext(a))},propagateFromLeft:function(a){this.notBlockedContext(a,!1)},retractLeft:function(a){var b;if(!this.removeFromLeftMemory(a)){if(!(b=this.removeFromLeftBlockedMemory(a)))throw new Error;this.__propagate("retract",this.__cloneContext(b.data))}},modifyLeft:function(a){var b,c,d,e,f=this.removeFromLeftMemory(a),g=this.constraint,h=this.rightTuples,i=h.length,j=!1;if(f||(f=this.removeFromLeftBlockedMemory(a),j=!0),!f)throw new Error;if(b=f.data,b&&b.blocker&&(e=this.rightMemory[b.blocker.hashCode]),e?(g.isMatch(a,d=e.data)&&(this.__propagate(j?"modify":"assert",this.__cloneContext(b)),a.blocker=d,this.addToLeftBlockedMemory(d.blocking.push(a)),a=null),a&&(c={next:e.next})):c={next:h.head},a&&i)for(c={next:h.head};c=c.next;)if(g.isMatch(a,d=c.data)){this.__propagate(j?"modify":"assert",this.__cloneContext(b)),this.addToLeftBlockedMemory(d.blocking.push(a)),a.blocker=d,a=null;break}a&&(this.__addToLeftMemory(a),j&&this.__propagate("retract",this.__cloneContext(a)))},modifyRight:function(a){var b=this.removeFromRightMemory(a);if(!b)throw new Error;var c,e,f=b.data,g=this.leftTuples,h=g.length,i=this.constraint,j=f.blocking;if(this.__addToRightMemory(a),a.blocking=new d,h||j.length){if(j.length)for(var k,l={next:j.head};l=l.next;)if(c=l.data,c.blocker=null,i.isMatch(c,a))c.blocker=a,this.addToLeftBlockedMemory(a.blocking.push(c)),this.__propagate("assert",this.__cloneContext(c)),c=null;else{for(c.blocker=null,e=b;e=e.next;)if(i.isMatch(c,k=e.data)){c.blocker=k,this.addToLeftBlockedMemory(k.blocking.push(c)),this.__propagate("assert",this.__cloneContext(c)),c=null;break}c&&this.__addToLeftMemory(c)}if(h)for(e={next:g.head};e=e.next;)c=e.data,i.isMatch(c,a)&&(this.__propagate("assert",this.__cloneContext(c)),this.removeFromLeftMemory(c),this.addToLeftBlockedMemory(a.blocking.push(c)),c.blocker=a)}}}}).as(b)},{"../linkedList":16,"./notNode":38}],25:[function(a,b){var c=a("./joinNode"),d=a("../extended"),e=a("../constraint"),f=e.EqualityConstraint,g=e.HashConstraint,h=e.ReferenceConstraint,i=a("../context"),j=d.isDefined,k=d.isEmpty,l=d.forEach,m=d.isArray,n={isMatch:function(){return!1}};c.extend({instance:{nodeType:"FromNode",constructor:function(a,b){this._super(arguments),this.workingMemory=b,this.fromMemory={},this.pattern=a,this.type=a.get("constraints")[0].assert,this.alias=a.get("alias"),this.from=a.from.assert;var c=this.__equalityConstraints=[],d=[];l(this.constraints=this.pattern.get("constraints").slice(1),function(a){a instanceof f||a instanceof h?c.push(a.assert):a instanceof g&&(d=d.concat(a.get("variables")))}),this.__variables=d},__createMatches:function(a){var b=a.factHash,c=this.from(b);if(m(c))for(var d=0,e=c.length;e>d;d++)this.__checkMatch(a,c[d],!0);else j(c)&&this.__checkMatch(a,c,!0)},__checkMatch:function(a,b,c){var d;return(d=this.__createMatch(a,b)).isMatch()&&c&&this.__propagate("assert",d.clone()),d},__createMatch:function(a,b){if(this.type(b)){var c,d=this.workingMemory.getFactHandle(b,!0),e=new i(d,null,null).set(this.alias,b),f=d.id,g=e.factHash,h=a.factHash;for(var j in h)g[j]=h[j];for(var k=this.__equalityConstraints,l=this.__variables,m=-1,o=k.length;++mc;c++)b=this.__checkMatch(a,l[c],!1),b.isMatch()&&(e=b.fact.id,e in k?this.__propagate("modify",b.clone()):this.__propagate("assert",b.clone()));else j(l)&&(b=this.__checkMatch(a,l,!1),b.isMatch()&&(e=b.fact.id,e in k?this.__propagate("modify",b.clone()):this.__propagate("assert",b.clone())));for(c in k)c in i||(this.removeFromFromMemory(k[c]),this.__propagate("retract",k[c].clone()))}else this.assertLeft(a);f=a.fact,e=f.id;var n=this.fromMemory[e];if(this.fromMemory[e]={},n){var o,p,q,r,s=f.object;for(c in n)p=n[c],o=p[0],q=p[1],r=q.isMatch(),o.hashCode!==a.hashCode&&(b=this.__createMatch(o,s,!1),r&&this.__propagate("retract",q.clone()),b.isMatch()&&this.__propagate(r?"modify":"assert",b.clone()))}},assertLeft:function(a){this.__addToLeftMemory(a),a.fromMatches={},this.__createMatches(a)},assertRight:function(){throw new Error("Shouldnt have gotten here")}}}).as(b)},{"../constraint":8,"../context":10,"../extended":12,"./joinNode":28}],26:[function(a,b){var c=a("./joinNode"),d=a("../extended"),e=a("../constraint"),f=e.EqualityConstraint,g=e.HashConstraint,h=e.ReferenceConstraint,i=a("../context"),j=d.isDefined,k=d.forEach,l=d.isArray;c.extend({instance:{nodeType:"FromNotNode",constructor:function(a,b){this._super(arguments),this.workingMemory=b,this.pattern=a,this.type=a.get("constraints")[0].assert,this.alias=a.get("alias"),this.from=a.from.assert,this.fromMemory={};var c=this.__equalityConstraints=[],d=[];k(this.constraints=this.pattern.get("constraints").slice(1),function(a){a instanceof f||a instanceof h?c.push(a.assert):a instanceof g&&(d=d.concat(a.get("variables")))}),this.__variables=d},retractLeft:function(a){var b=this.removeFromLeftMemory(a);b&&(b=b.data,b.blocked||this.__propagate("retract",b.clone()))},__modify:function(a,b){var c=b.blocked,d=a.factHash,e=this.from(d);if(l(e)){for(var f=0,g=e.length;g>f;f++)if(this.__isMatch(a,e[f],!0)){a.blocked=!0;break}}else j(e)&&(a.blocked=this.__isMatch(a,e,!0));var h=a.blocked;h?c||this.__propagate("retract",b.clone()):c?this.__propagate("assert",a.clone()):this.__propagate("modify",a.clone())},modifyLeft:function(a){var b=this.removeFromLeftMemory(a);if(!b)throw new Error;this.__addToLeftMemory(a),this.__modify(a,b.data);var c=this.fromMemory[a.fact.id];if(this.fromMemory[a.fact.id]={},c)for(var d in c)if(d!==a.hashCode){var e=c[d];b=this.removeFromLeftMemory(e),b&&(e=e.clone(),e.blocked=!1,this.__addToLeftMemory(e),this.__modify(e,b.data))}},__findMatches:function(a){var b=a.factHash,c=this.from(b),d=!1;if(l(c)){for(var e=0,f=c.length;f>e;e++)if(this.__isMatch(a,c[e],!0))return a.blocked=!0,void 0;this.__propagate("assert",a.clone())}else j(c)&&!(a.blocked=this.__isMatch(a,c,!0))&&this.__propagate("assert",a.clone());return d},__isMatch:function(a,b,c){var d=!1;if(this.type(b)){var e=this.workingMemory.getFactHandle(b),f=new i(e,null).mergeMatch(a.match).set(this.alias,b);if(c){var g=this.fromMemory[e.id];g||(g=this.fromMemory[e.id]={}),g[a.hashCode]=a}for(var h=f.factHash,j=this.__equalityConstraints,k=0,l=j.length;l>k;k++){if(!j[k](h,h)){d=!1;break}d=!0}}return d},assertLeft:function(a){this.__addToLeftMemory(a),this.__findMatches(a)},assertRight:function(){throw new Error("Shouldnt have gotten here")},retractRight:function(){throw new Error("Shouldnt have gotten here")}}}).as(b)},{"../constraint":8,"../context":10,"../extended":12,"./joinNode":28}],27:[function(a,b,c){"use strict";function d(a){return g(a.constraints||[],function(a){return a instanceof t})}var e=a("../extended"),f=e.forEach,g=e.some,h=e.declare,i=a("../pattern.js"),j=i.ObjectPattern,k=i.FromPattern,l=i.FromNotPattern,m=i.ExistsPattern,n=i.FromExistsPattern,o=i.NotPattern,p=i.CompositePattern,q=i.InitialFactPattern,r=a("../constraint"),s=r.HashConstraint,t=r.ReferenceConstraint,u=a("./aliasNode"),v=a("./equalityNode"),w=a("./joinNode"),x=a("./betaNode"),y=a("./notNode"),z=a("./fromNode"),A=a("./fromNotNode"),B=a("./existsNode"),C=a("./existsFromNode"),D=a("./leftAdapterNode"),E=a("./rightAdapterNode"),F=a("./typeNode"),G=a("./terminalNode"),H=a("./propertyNode");h({instance:{constructor:function(a,b){this.terminalNodes=[],this.joinNodes=[],this.nodes=[],this.constraints=[],this.typeNodes=[],this.__ruleCount=0,this.bucket={counter:0,recency:0},this.agendaTree=b,this.workingMemory=a},assertRule:function(a){var b=new G(this.bucket,this.__ruleCount++,a,this.agendaTree);this.__addToNetwork(a,a.pattern,b),this.__mergeJoinNodes(),this.terminalNodes.push(b)},resetCounter:function(){this.bucket.counter=0},incrementCounter:function(){this.bucket.counter++},assertFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].assert(a)},retractFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].retract(a)},modifyFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].modify(a)},containsRule:function(a){return g(this.terminalNodes,function(b){return b.rule.name===a})},dispose:function(){for(var a=this.typeNodes,b=a.length-1;b>=0;b--)a[b].dispose()},__mergeJoinNodes:function(){for(var a=this.joinNodes,b=0;b=0;c--){var d=b[c];if(a.equal(d))return d}return b.push(a),a},__createTypeNode:function(a,b){for(var c=new F(b.get("constraints")[0]),d=this.typeNodes,e=d.length-1;e>=0;e--){var f=d[e];if(c.equal(f))return f}return d.push(c),c},__createEqualityNode:function(a,b){return this.__checkEqual(new v(b)).addRule(a)},__createPropertyNode:function(a,b){return this.__checkEqual(new H(b)).addRule(a)},__createAliasNode:function(a,b){return this.__checkEqual(new u(b)).addRule(a)},__createAdapterNode:function(a,b){return("left"===b?new D:new E).addRule(a)},__createJoinNode:function(a,b,c,e){var f;b.rightPattern instanceof o?f=new y:b.rightPattern instanceof n?f=new C(b.rightPattern,this.workingMemory):b.rightPattern instanceof m?f=new B:b.rightPattern instanceof l?f=new A(b.rightPattern,this.workingMemory):b.rightPattern instanceof k?f=new z(b.rightPattern,this.workingMemory):b instanceof p&&!d(b.leftPattern)&&!d(b.rightPattern)?(f=new x,this.joinNodes.push(f)):(f=new w,this.joinNodes.push(f)),f.__rule__=a;var g=f;if(c instanceof x){var h=this.__createAdapterNode(a,e);g.addOutNode(h,b),g=h}return g.addOutNode(c,b),f.addRule(a)},__addToNetwork:function(a,b,c,d){b instanceof j?b instanceof q||d&&"left"!==d?this.__createAlphaNode(a,b,c,d):this.__createBetaNode(a,new p(new q,b),c,d):b instanceof p&&this.__createBetaNode(a,b,c,d)},__createBetaNode:function(a,b,c,d){var e=this.__createJoinNode(a,b,c,d);return this.__addToNetwork(a,b.rightPattern,e,"right"),this.__addToNetwork(a,b.leftPattern,e,"left"),c.addParentNode(e),e},__createAlphaNode:function(a,b,c,d){var e,f;if(!(b instanceof k)){var g=b.get("constraints");e=this.__createTypeNode(a,b);var h=this.__createAliasNode(a,b);e.addOutNode(h,b),h.addParentNode(e),f=h;for(var i=g.length-1;i>0;i--){var j,l=g[i];if(l instanceof s)j=this.__createPropertyNode(a,l);else{if(l instanceof t){c.constraint.addConstraint(l);continue}j=this.__createEqualityNode(a,l)}f.addOutNode(j,b),j.addParentNode(f),f=j}if(c instanceof x){var m=this.__createAdapterNode(a,d);m.addParentNode(f),f.addOutNode(m,b),f=m}return c.addParentNode(f),f.addOutNode(c,b),e}},print:function(){f(this.terminalNodes,function(a){a.print(" ")})}}}).as(c,"RootNode")},{"../constraint":8,"../extended":12,"../pattern.js":48,"./aliasNode":19,"./betaNode":21,"./equalityNode":22,"./existsFromNode":23,"./existsNode":24,"./fromNode":25,"./fromNotNode":26,"./joinNode":28,"./leftAdapterNode":30,"./notNode":38,"./propertyNode":39,"./rightAdapterNode":40,"./terminalNode":41,"./typeNode":42}],28:[function(a,b){var c=a("./betaNode"),d=a("./joinReferenceNode");c.extend({instance:{constructor:function(){this._super(arguments),this.constraint=new d(this.leftTuples,this.rightTuples)},nodeType:"JoinNode",propagateFromLeft:function(a,b){var c;return(c=this.constraint.match(a,b)).isMatch&&this.__propagate("assert",this.__addToMemoryMatches(b,a,a.clone(null,null,c))),this},propagateFromRight:function(a,b){var c;return(c=this.constraint.match(b,a)).isMatch&&this.__propagate("assert",this.__addToMemoryMatches(a,b,a.clone(null,null,c))),this},propagateAssertModifyFromLeft:function(a,b,c){var d,e=c.hashCode;if(e in b){d=this.constraint.match(a,c);var f=d.isMatch;f?this.__propagate("modify",this.__addToMemoryMatches(c,a,a.clone(null,null,d))):this.__propagate("retract",b[e].clone())}else this.propagateFromLeft(a,c)},propagateAssertModifyFromRight:function(a,b,c){var d,e=c.hashCode;if(e in b){d=this.constraint.match(c,a);var f=d.isMatch;f?this.__propagate("modify",this.__addToMemoryMatches(a,c,a.clone(null,null,d))):this.__propagate("retract",b[e].clone())}else this.propagateFromRight(a,c)}}}).as(b)},{"./betaNode":21,"./joinReferenceNode":29}],29:[function(a,b){function c(a,b,c){return a===b[1]&&(c=i[c]),c}function d(a,b,c){return a===b[1]&&(c=i[c]),c}var e=a("./node"),f=a("../constraint"),g=f.ReferenceEqualityConstraint,h={isDefault:!0,assert:function(){return!0},equal:function(){return!1}},i={gt:"lte",gte:"lte",lt:"gte",lte:"gte",eq:"eq",neq:"neq"};e.extend({instance:{constraint:h,constructor:function(a,b){this._super(arguments),this.constraint=h,this.constraintAssert=h.assert,this.rightIndexes=[],this.leftIndexes=[],this.constraintLength=0,this.leftMemory=a,this.rightMemory=b},addConstraint:function(a){if(a instanceof g){var b=a.getIndexableProperties(),e=a.get("alias");if(2===b.length&&e){for(var f,h,i=-1,j=[];++i<2;){var k=b[i];null===k.match(new RegExp("^"+e+"(\\.?)"))?(j.push(k),f=k):(j.push(k),h=k)}if(f&&h){var l=d(f,j,a.op),m=c(h,j,a.op);this.rightMemory.addIndex(h,f,m),this.leftMemory.addIndex(f,h,l)}}}this.constraint.isDefault?(this.constraint=a,this.isDefault=!1):this.constraint=this.constraint.merge(a),this.constraintAssert=this.constraint.assert},equal:function(a){return this.constraint.equal(a.constraint)},isMatch:function(a,b){return this.constraintAssert(a.factHash,b.factHash)},match:function(a,b){var c={isMatch:!1};return this.constraintAssert(a.factHash,b.factHash)&&(c=a.match.merge(b.match)),c}}}).as(b)},{"../constraint":8,"./node":37}],30:[function(a,b){var c=a("./adapterNode");c.extend({instance:{propagateAssert:function(a){this.__propagate("assertLeft",a)},propagateRetract:function(a){this.__propagate("retractLeft",a)},propagateResolve:function(a){this.__propagate("retractResolve",a)},propagateModify:function(a){this.__propagate("modifyLeft",a)},retractResolve:function(a){this.__propagate("retractResolve",a)},dispose:function(a){this.propagateDispose(a)},toString:function(){return"LeftAdapterNode "+this.__count}}}).as(b)},{"./adapterNode":18}],31:[function(a,b,c){c.getMemory=function(){function a(a,b,c){var d,e=0,f=-1;if(c>m)for(;m&&++fi)for(;++fi)for(var d,e,g=0,h=-1;++h=0;)b[c].removeNode(a);a.tuples.length=0},getMemory:function(a){var b;return b=this.length?f(this.tables,a.factHash,this.indexes):[]},__createIndexTree:function(){var a=this.tables.tables={},b=this.indexes;a[b[0][0]]=new g},addIndex:function(a,b,c){this.indexes.push([a,b,d(a),d(b),c||"eq"]),this.indexes.sort(function(a,b){var c=a[4],d=b[4];return c===d?0:c>d?1:c===d?0:-1}),this.__createIndexTree()}}}).as(b)},{"../../extended":12,"./helpers":31,"./table":35,"./tupleEntry":36}],34:[function(a,b){var c=a("./memory");c.extend({instance:{getRightMemory:function(a){return this.getMemory(a)}}}).as(b)},{"./memory":33}],35:[function(a,b){function c(a,b){a=a.key,b=b.key;var c;return c=a===b?0:a>b?1:b>a?-1:1}function d(a,b){return 1===c(a,b)}function e(a,b){return-1!==c(a,b)}function f(a,b){return-1===c(a,b)}function g(a,b){return 1!==c(a,b)}function h(a,b,c){o.key=b;for(var d,e=[],f=0,g=a.__root;;)if(g)g=(n[f++]=g).left;else{if(!(f>0))break;if(d=(g=n[--f]).data,!c(d,o))break;k.apply(e,d.value.tuples),g=g.right}return n.length=0,e}function i(a,b,c){o.key=b;for(var d,e=[],f=0,g=a.__root;;)if(g)g=(n[f++]=g).right;else{if(!(f>0))break;if(d=(g=n[--f]).data,!c(d,o))break;k.apply(e,d.value.tuples),g=g.left}return n.length=0,e}var j=a("../../extended"),k=Array.prototype.push,l=j.HashTable,m=j.AVLTree,n=[],o={key:null};m.extend({instance:{constructor:function(){this._super([{compare:c}]),this.gtCache=new l,this.gteCache=new l,this.ltCache=new l,this.lteCache=new l,this.hasGTCache=!1,this.hasGTECache=!1,this.hasLTCache=!1,this.hasLTECache=!1},clearCache:function(){this.hasGTCache&&this.gtCache.clear()&&(this.hasGTCache=!1),this.hasGTECache&&this.gteCache.clear()&&(this.hasGTECache=!1),this.hasLTCache&&this.ltCache.clear()&&(this.hasLTCache=!1),this.hasLTECache&&this.lteCache.clear()&&(this.hasLTECache=!1)},contains:function(a){return this._super([{key:a}])},set:function(a,b){this.insert({key:a,value:b}),this.clearCache()},get:function(a){var b=this.find({key:a});return b&&b.value},remove:function(a){return this.clearCache(),this._super([{key:a}])},findGT:function(a){var b=this.gtCache.get(a);return b||(this.hasGTCache=!0,this.gtCache.put(a,b=i(this,a,d))),b},findGTE:function(a){var b=this.gteCache.get(a);return b||(this.hasGTECache=!0,this.gteCache.put(a,b=i(this,a,e))),b},findLT:function(a){var b=this.ltCache.get(a);return b||(this.hasLTCache=!0,this.ltCache.put(a,b=h(this,a,f))),b},findLTE:function(a){var b=this.lteCache.get(a);return b||(this.hasLTECache=!0,this.lteCache.put(a,b=h(this,a,g))),b}}}).as(b)},{"../../extended":12}],36:[function(a,b){var c=a("../../extended"),d=c.indexOf,e=0;c.declare({instance:{tuples:null,tupleMap:null,hashCode:null,tables:null,entry:null,constructor:function(a,b,c){this.val=a,this.canRemove=c,this.tuples=[],this.tupleMap={},this.hashCode=e++,this.tables={},this.length=0,this.entry=b},addNode:function(a){return this.tuples[this.length++]=a,this.length>1&&this.entry.clearCache(),this},removeNode:function(a){var b=this.tuples,c=d(b,a);-1!==c&&(b.splice(c,1),this.length--,this.entry.clearCache()),this.canRemove&&!this.length&&this.entry.remove(this.val)}}}).as(b)},{"../../extended":12}],37:[function(a,b){var c=a("../extended"),d=c.forEach,e=c.indexOf,f=c.intersection,g=c.declare,h=c.HashTable,i=a("../context"),j=0;g({instance:{constructor:function(){this.nodes=new h,this.rules=[],this.parentNodes=[],this.__count=j++,this.__entrySet=[]},addRule:function(a){return-1===e(this.rules,a)&&this.rules.push(a),this},merge:function(a){a.nodes.forEach(function(b){for(var c=b.value,d=b.key,e=0,f=c.length;f>e;e++)this.addOutNode(d,c[e]);a.nodes.remove(d)},this);for(var b=a.parentNodes,c=0,d=a.parentNodes.l;d>c;c++){var e=b[c];this.addParentNode(e),e.nodes.remove(a)}return this},resolve:function(a,b){return a.hashCode===b.hashCode},print:function(a){console.log(a+this.toString()),d(this.parentNodes,function(b){b.print(" "+a)})},addOutNode:function(a,b){this.nodes.contains(a)||this.nodes.put(a,[]),this.nodes.get(a).push(b),this.__entrySet=this.nodes.entrySet()},addParentNode:function(a){-1===e(this.parentNodes,a)&&this.parentNodes.push(a)},shareable:function(){return!1},__propagate:function(a,b){for(var c,d,e,g,h=this.__entrySet,j=h.length;--j>-1;)c=h[j],d=c.key,e=c.value,(g=f(e,b.paths)).length&&d[a](new i(b.fact,g,b.match))},dispose:function(a){this.propagateDispose(a)},retract:function(a){this.propagateRetract(a)},propagateDispose:function(a,b){b=b||this.nodes;for(var c=this.__entrySet,d=c.length-1;d>=0;d--){var e=c[d],f=e.key;f.dispose(a)}},propagateAssert:function(a){this.__propagate("assert",a)},propagateRetract:function(a){this.__propagate("retract",a)},assert:function(a){this.propagateAssert(a)},modify:function(a){this.propagateModify(a)},propagateModify:function(a){this.__propagate("modify",a)}}}).as(b)},{"../context":10,"../extended":12}],38:[function(a,b){var c=a("./joinNode"),d=a("../linkedList"),e=a("../context"),f=a("../pattern").InitialFact;c.extend({instance:{nodeType:"NotNode",constructor:function(){this._super(arguments),this.leftTupleMemory={},this.notMatch=new e(new f).match},__cloneContext:function(a){return a.clone(null,null,a.match.merge(this.notMatch))},retractRight:function(a){var b=this.removeFromRightMemory(a),c=b.data,d=c.blocking;if(d.length){for(var e,f,g=this.constraint,h={next:d.head};h=h.next;){e=h.data,this.removeFromLeftBlockedMemory(e);var i,j=this.rightTuples.getRightMemory(e),k=j.length;for(i=-1;++ig;g++)b=e[g],c.set(b[1],f[b[0]]);this.__propagate("assert",c)},retract:function(a){this.__propagate("retract",new d(a.fact,a.paths))},modify:function(a){var b,c=new d(a.fact,a.paths),e=this.variables,f=a.fact.object;c.set(this.alias,f);for(var g=0,h=this.varLength;h>g;g++)b=e[g],c.set(b[1],f[b[0]]);this.__propagate("modify",c)},toString:function(){return"PropertyNode"+this.__count}}}).as(b)},{"../context":10,"../extended":12,"./alphaNode":20}],40:[function(a,b){var c=a("./adapterNode");c.extend({instance:{retractResolve:function(a){this.__propagate("retractResolve",a)},dispose:function(a){this.propagateDispose(a)},propagateAssert:function(a){this.__propagate("assertRight",a)},propagateRetract:function(a){this.__propagate("retractRight",a)},propagateResolve:function(a){this.__propagate("retractResolve",a)},propagateModify:function(a){this.__propagate("modifyRight",a)},toString:function(){return"RightAdapterNode "+this.__count}}}).as(b)},{"./adapterNode":18}],41:[function(a,b){var c=a("./node"),d=a("../extended"),e=d.bind;c.extend({instance:{constructor:function(a,b,c,d){this._super([]),this.resolve=e(this,this.resolve),this.rule=c,this.index=b,this.name=this.rule.name,this.agenda=d,this.bucket=a,d.register(this)},__assertModify:function(a){var b=a.match;if(b.isMatch){var c=this.rule,d=this.bucket;this.agenda.insert(this,{rule:c,hashCode:a.hashCode,index:this.index,name:c.name,recency:d.recency++,match:b,counter:d.counter})}},assert:function(a){this.__assertModify(a)},modify:function(a){this.agenda.retract(this,a),this.__assertModify(a)},retract:function(a){this.agenda.retract(this,a)},retractRight:function(a){this.agenda.retract(this,a)},retractLeft:function(a){this.agenda.retract(this,a)},assertLeft:function(a){this.__assertModify(a)},assertRight:function(a){this.__assertModify(a)},toString:function(){return"TerminalNode "+this.rule.name}}}).as(b)},{"../extended":12,"./node":37}],42:[function(a,b){var c=a("./alphaNode"),d=a("../context");c.extend({instance:{assert:function(a){this.constraintAssert(a.object)&&this.__propagate("assert",a)},modify:function(a){this.constraintAssert(a.object)&&this.__propagate("modify",a)},retract:function(a){this.constraintAssert(a.object)&&this.__propagate("retract",a)},toString:function(){return"TypeNode"+this.__count},dispose:function(){for(var a=this.__entrySet,b=a.length-1;b>=0;b--){var c=a[b],d=c.key,e=c.value;d.dispose({paths:e})}},__propagate:function(a,b){for(var c=this.__entrySet,e=-1,f=c.length;++e":20,"<=":21,">=":22,EQUALITY_EXPRESSION:23,"==":24,"!=":25,"=~":26,"!=~":27,IN_EXPRESSION:28,"in":29,ARRAY_EXPRESSION:30,notIn:31,OBJECT_EXPRESSION:32,AND_EXPRESSION:33,"&&":34,OR_EXPRESSION:35,"||":36,ARGUMENT_LIST:37,",":38,IDENTIFIER_EXPRESSION:39,IDENTIFIER:40,".":41,"[":42,STRING_EXPRESSION:43,"]":44,NUMBER_EXPRESSION:45,"(":46,")":47,STRING:48,NUMBER:49,REGEXP_EXPRESSION:50,REGEXP:51,BOOLEAN_EXPRESSION:52,BOOLEAN:53,NULL_EXPRESSION:54,NULL:55,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:"-",9:"!",11:"*",12:"/",13:"%",15:"+",17:"^",19:"<",20:">",21:"<=",22:">=",24:"==",25:"!=",26:"=~",27:"!=~",29:"in",31:"notIn",34:"&&",36:"||",38:",",40:"IDENTIFIER",41:".",42:"[",44:"]",46:"(",47:")",48:"STRING",49:"NUMBER",51:"REGEXP",53:"BOOLEAN",55:"NULL"},productions_:[0,[3,2],[6,1],[6,2],[6,2],[10,1],[10,3],[10,3],[10,3],[14,1],[14,3],[14,3],[16,1],[16,3],[18,1],[18,3],[18,3],[18,3],[18,3],[23,1],[23,3],[23,3],[23,3],[23,3],[28,1],[28,3],[28,3],[28,3],[28,3],[33,1],[33,3],[35,1],[35,3],[37,1],[37,3],[39,1],[32,1],[32,3],[32,4],[32,4],[32,4],[32,3],[32,4],[43,1],[45,1],[50,1],[52,1],[54,1],[30,2],[30,3],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,3],[4,1]],performAction:function(a,b,c,d,e,f){var g=f.length-1;switch(e){case 1:return f[g-1];case 3:this.$=[f[g],null,"unary"];break;case 4:this.$=[f[g],null,"logicalNot"];break;case 6:this.$=[f[g-2],f[g],"mult"];break;case 7:this.$=[f[g-2],f[g],"div"];break;case 8:this.$=[f[g-2],f[g],"mod"];break;case 10:this.$=[f[g-2],f[g],"plus"];break;case 11:this.$=[f[g-2],f[g],"minus"];break;case 13:this.$=[f[g-2],f[g],"pow"];break;case 15:this.$=[f[g-2],f[g],"lt"];break;case 16:this.$=[f[g-2],f[g],"gt"];break;case 17:this.$=[f[g-2],f[g],"lte"];break;case 18:this.$=[f[g-2],f[g],"gte"];break;case 20:this.$=[f[g-2],f[g],"eq"];break;case 21:this.$=[f[g-2],f[g],"neq"];break;case 22:this.$=[f[g-2],f[g],"like"];break;case 23:this.$=[f[g-2],f[g],"notLike"];break;case 25:this.$=[f[g-2],f[g],"in"];break;case 26:this.$=[f[g-2],f[g],"notIn"];break;case 27:this.$=[f[g-2],f[g],"in"];break;case 28:this.$=[f[g-2],f[g],"notIn"];break;case 30:this.$=[f[g-2],f[g],"and"];break;case 32:this.$=[f[g-2],f[g],"or"];break;case 34:this.$=[f[g-2],f[g],"arguments"];break;case 35:this.$=[String(a),null,"identifier"];break;case 37:this.$=[f[g-2],f[g],"prop"];break;case 38:this.$=[f[g-3],f[g-1],"propLookup"];break;case 39:this.$=[f[g-3],f[g-1],"propLookup"];break;case 40:this.$=[f[g-3],f[g-1],"propLookup"];break;case 41:this.$=[f[g-2],[null,null,"arguments"],"function"];break;case 42:this.$=[f[g-3],f[g-1],"function"];break;case 43:this.$=[String(a.replace(/^['|"]|['|"]$/g,"")),null,"string"];break;case 44:this.$=[Number(a),null,"number"];break;case 45:this.$=[a,null,"regexp"];break;case 46:this.$=["true"==a.replace(/^\s+/,""),null,"boolean"];break;case 47:this.$=[null,null,"null"];break;case 48:this.$=[null,null,"array"];break;case 49:this.$=[f[g-1],null,"array"];break;case 57:this.$=[f[g-1],null,"composite"]}},table:[{3:1,4:2,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[3]},{5:[1,31]},{5:[2,58],36:[1,32],47:[2,58]},{5:[2,31],34:[1,33],36:[2,31],47:[2,31]},{5:[2,29],34:[2,29],36:[2,29],47:[2,29]},{5:[2,24],24:[1,34],25:[1,35],26:[1,36],27:[1,37],34:[2,24],36:[2,24],47:[2,24]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],29:[1,38],31:[1,39],34:[2,2],36:[2,2],47:[2,2]},{5:[2,19],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,19],25:[2,19],26:[2,19],27:[2,19],34:[2,19],36:[2,19],47:[2,19]},{5:[2,50],8:[2,50],11:[2,50],12:[2,50],13:[2,50],15:[2,50],17:[2,50],19:[2,50],20:[2,50],21:[2,50],22:[2,50],24:[2,50],25:[2,50],26:[2,50],27:[2,50],29:[2,50],31:[2,50],34:[2,50],36:[2,50],38:[2,50],44:[2,50],47:[2,50]},{5:[2,51],8:[2,51],11:[2,51],12:[2,51],13:[2,51],15:[2,51],17:[2,51],19:[2,51],20:[2,51],21:[2,51],22:[2,51],24:[2,51],25:[2,51],26:[2,51],27:[2,51],29:[2,51],31:[2,51],34:[2,51],36:[2,51],38:[2,51],44:[2,51],47:[2,51]},{5:[2,52],8:[2,52],11:[2,52],12:[2,52],13:[2,52],15:[2,52],17:[2,52],19:[2,52],20:[2,52],21:[2,52],22:[2,52],24:[2,52],25:[2,52],26:[2,52],27:[2,52],29:[2,52],31:[2,52],34:[2,52],36:[2,52],38:[2,52],44:[2,52],47:[2,52]},{5:[2,53],8:[2,53],11:[2,53],12:[2,53],13:[2,53],15:[2,53],17:[2,53],19:[2,53],20:[2,53],21:[2,53],22:[2,53],24:[2,53],25:[2,53],26:[2,53],27:[2,53],29:[2,53],31:[2,53],34:[2,53],36:[2,53],38:[2,53],44:[2,53],47:[2,53]},{5:[2,54],8:[2,54],11:[2,54],12:[2,54],13:[2,54],15:[2,54],17:[2,54],19:[2,54],20:[2,54],21:[2,54],22:[2,54],24:[2,54],25:[2,54],26:[2,54],27:[2,54],29:[2,54],31:[2,54],34:[2,54],36:[2,54],38:[2,54],44:[2,54],47:[2,54]},{5:[2,55],8:[2,55],11:[2,55],12:[2,55],13:[2,55],15:[2,55],17:[2,55],19:[2,55],20:[2,55],21:[2,55],22:[2,55],24:[2,55],25:[2,55],26:[2,55],27:[2,55],29:[2,55],31:[2,55],34:[2,55],36:[2,55],38:[2,55],41:[1,44],42:[1,45],44:[2,55],46:[1,46],47:[2,55]},{5:[2,56],8:[2,56],11:[2,56],12:[2,56],13:[2,56],15:[2,56],17:[2,56],19:[2,56],20:[2,56],21:[2,56],22:[2,56],24:[2,56],25:[2,56],26:[2,56],27:[2,56],29:[2,56],31:[2,56],34:[2,56],36:[2,56],38:[2,56],44:[2,56],47:[2,56]},{4:47,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,14],17:[1,48],19:[2,14],20:[2,14],21:[2,14],22:[2,14],24:[2,14],25:[2,14],26:[2,14],27:[2,14],34:[2,14],36:[2,14],47:[2,14]},{5:[2,43],8:[2,43],11:[2,43],12:[2,43],13:[2,43],15:[2,43],17:[2,43],19:[2,43],20:[2,43],21:[2,43],22:[2,43],24:[2,43],25:[2,43],26:[2,43],27:[2,43],29:[2,43],31:[2,43],34:[2,43],36:[2,43],38:[2,43],44:[2,43],47:[2,43]},{5:[2,44],8:[2,44],11:[2,44],12:[2,44],13:[2,44],15:[2,44],17:[2,44],19:[2,44],20:[2,44],21:[2,44],22:[2,44],24:[2,44],25:[2,44],26:[2,44],27:[2,44],29:[2,44],31:[2,44],34:[2,44],36:[2,44],38:[2,44],44:[2,44],47:[2,44]},{5:[2,45],8:[2,45],11:[2,45],12:[2,45],13:[2,45],15:[2,45],17:[2,45],19:[2,45],20:[2,45],21:[2,45],22:[2,45],24:[2,45],25:[2,45],26:[2,45],27:[2,45],29:[2,45],31:[2,45],34:[2,45],36:[2,45],38:[2,45],44:[2,45],47:[2,45]},{5:[2,46],8:[2,46],11:[2,46],12:[2,46],13:[2,46],15:[2,46],17:[2,46],19:[2,46],20:[2,46],21:[2,46],22:[2,46],24:[2,46],25:[2,46],26:[2,46],27:[2,46],29:[2,46],31:[2,46],34:[2,46],36:[2,46],38:[2,46],44:[2,46],47:[2,46]},{5:[2,47],8:[2,47],11:[2,47],12:[2,47],13:[2,47],15:[2,47],17:[2,47],19:[2,47],20:[2,47],21:[2,47],22:[2,47],24:[2,47],25:[2,47],26:[2,47],27:[2,47],29:[2,47],31:[2,47],34:[2,47],36:[2,47],38:[2,47],44:[2,47],47:[2,47]},{5:[2,36],8:[2,36],11:[2,36],12:[2,36],13:[2,36],15:[2,36],17:[2,36],19:[2,36],20:[2,36],21:[2,36],22:[2,36],24:[2,36],25:[2,36],26:[2,36],27:[2,36],29:[2,36],31:[2,36],34:[2,36],36:[2,36],38:[2,36],41:[2,36],42:[2,36],44:[2,36],46:[2,36],47:[2,36]},{7:51,30:15,32:14,37:50,39:23,40:[1,26],42:[1,24],43:9,44:[1,49],45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,12],8:[1,53],15:[1,52],17:[2,12],19:[2,12],20:[2,12],21:[2,12],22:[2,12],24:[2,12],25:[2,12],26:[2,12],27:[2,12],34:[2,12],36:[2,12],47:[2,12]},{5:[2,35],8:[2,35],11:[2,35],12:[2,35],13:[2,35],15:[2,35],17:[2,35],19:[2,35],20:[2,35],21:[2,35],22:[2,35],24:[2,35],25:[2,35],26:[2,35],27:[2,35],29:[2,35],31:[2,35],34:[2,35],36:[2,35],38:[2,35],41:[2,35],42:[2,35],44:[2,35],46:[2,35],47:[2,35]},{5:[2,9],8:[2,9],11:[1,54],12:[1,55],13:[1,56],15:[2,9],17:[2,9],19:[2,9],20:[2,9],21:[2,9],22:[2,9],24:[2,9],25:[2,9],26:[2,9],27:[2,9],34:[2,9],36:[2,9],47:[2,9]},{5:[2,5],8:[2,5],11:[2,5],12:[2,5],13:[2,5],15:[2,5],17:[2,5],19:[2,5],20:[2,5],21:[2,5],22:[2,5],24:[2,5],25:[2,5],26:[2,5],27:[2,5],34:[2,5],36:[2,5],47:[2,5]},{6:57,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:59,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[2,1]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:60,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:61,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:62,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:63,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:64,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:65,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{30:66,32:67,39:23,40:[1,26],42:[1,24]},{30:68,32:69,39:23,40:[1,26],42:[1,24]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:70,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:71,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:72,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:73,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{39:74,40:[1,26]},{32:77,39:23,40:[1,26],43:75,45:76,48:[1,18],49:[1,19]},{7:51,30:15,32:14,37:79,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],47:[1,78],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{47:[1,80]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:81,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,48],8:[2,48],11:[2,48],12:[2,48],13:[2,48],15:[2,48],17:[2,48],19:[2,48],20:[2,48],21:[2,48],22:[2,48],24:[2,48],25:[2,48],26:[2,48],27:[2,48],29:[2,48],31:[2,48],34:[2,48],36:[2,48],38:[2,48],44:[2,48],47:[2,48]},{38:[1,83],44:[1,82]},{38:[2,33],44:[2,33],47:[2,33]},{6:28,7:58,8:[1,29],9:[1,30],10:84,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:85,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:86,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:87,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:88,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,3],8:[2,3],11:[2,3],12:[2,3],13:[2,3],15:[2,3],17:[2,3],19:[2,3],20:[2,3],21:[2,3],22:[2,3],24:[2,3],25:[2,3],26:[2,3],27:[2,3],34:[2,3],36:[2,3],47:[2,3]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],34:[2,2],36:[2,2],47:[2,2]},{5:[2,4],8:[2,4],11:[2,4],12:[2,4],13:[2,4],15:[2,4],17:[2,4],19:[2,4],20:[2,4],21:[2,4],22:[2,4],24:[2,4],25:[2,4],26:[2,4],27:[2,4],34:[2,4],36:[2,4],47:[2,4]},{5:[2,32],34:[1,33],36:[2,32],47:[2,32]},{5:[2,30],34:[2,30],36:[2,30],47:[2,30]},{5:[2,20],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,20],25:[2,20],26:[2,20],27:[2,20],34:[2,20],36:[2,20],47:[2,20]},{5:[2,21],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,21],25:[2,21],26:[2,21],27:[2,21],34:[2,21],36:[2,21],47:[2,21]},{5:[2,22],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,22],25:[2,22],26:[2,22],27:[2,22],34:[2,22],36:[2,22],47:[2,22]},{5:[2,23],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,23],25:[2,23],26:[2,23],27:[2,23],34:[2,23],36:[2,23],47:[2,23]},{5:[2,25],34:[2,25],36:[2,25],47:[2,25]},{5:[2,27],34:[2,27],36:[2,27],41:[1,44],42:[1,45],46:[1,46],47:[2,27]},{5:[2,26],34:[2,26],36:[2,26],47:[2,26]},{5:[2,28],34:[2,28],36:[2,28],41:[1,44],42:[1,45],46:[1,46],47:[2,28]},{5:[2,15],17:[1,48],19:[2,15],20:[2,15],21:[2,15],22:[2,15],24:[2,15],25:[2,15],26:[2,15],27:[2,15],34:[2,15],36:[2,15],47:[2,15]},{5:[2,16],17:[1,48],19:[2,16],20:[2,16],21:[2,16],22:[2,16],24:[2,16],25:[2,16],26:[2,16],27:[2,16],34:[2,16],36:[2,16],47:[2,16]},{5:[2,17],17:[1,48],19:[2,17],20:[2,17],21:[2,17],22:[2,17],24:[2,17],25:[2,17],26:[2,17],27:[2,17],34:[2,17],36:[2,17],47:[2,17]},{5:[2,18],17:[1,48],19:[2,18],20:[2,18],21:[2,18],22:[2,18],24:[2,18],25:[2,18],26:[2,18],27:[2,18],34:[2,18],36:[2,18],47:[2,18]},{5:[2,37],8:[2,37],11:[2,37],12:[2,37],13:[2,37],15:[2,37],17:[2,37],19:[2,37],20:[2,37],21:[2,37],22:[2,37],24:[2,37],25:[2,37],26:[2,37],27:[2,37],29:[2,37],31:[2,37],34:[2,37],36:[2,37],38:[2,37],41:[2,37],42:[2,37],44:[2,37],46:[2,37],47:[2,37]},{44:[1,89]},{44:[1,90]},{41:[1,44],42:[1,45],44:[1,91],46:[1,46]},{5:[2,41],8:[2,41],11:[2,41],12:[2,41],13:[2,41],15:[2,41],17:[2,41],19:[2,41],20:[2,41],21:[2,41],22:[2,41],24:[2,41],25:[2,41],26:[2,41],27:[2,41],29:[2,41],31:[2,41],34:[2,41],36:[2,41],38:[2,41],41:[2,41],42:[2,41],44:[2,41],46:[2,41],47:[2,41]},{38:[1,83],47:[1,92]},{5:[2,57],8:[2,57],11:[2,57],12:[2,57],13:[2,57],15:[2,57],17:[2,57],19:[2,57],20:[2,57],21:[2,57],22:[2,57],24:[2,57],25:[2,57],26:[2,57],27:[2,57],29:[2,57],31:[2,57],34:[2,57],36:[2,57],38:[2,57],44:[2,57],47:[2,57]},{5:[2,13],8:[1,53],15:[1,52],17:[2,13],19:[2,13],20:[2,13],21:[2,13],22:[2,13],24:[2,13],25:[2,13],26:[2,13],27:[2,13],34:[2,13],36:[2,13],47:[2,13]},{5:[2,49],8:[2,49],11:[2,49],12:[2,49],13:[2,49],15:[2,49],17:[2,49],19:[2,49],20:[2,49],21:[2,49],22:[2,49],24:[2,49],25:[2,49],26:[2,49],27:[2,49],29:[2,49],31:[2,49],34:[2,49],36:[2,49],38:[2,49],44:[2,49],47:[2,49]},{7:93,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,10],8:[2,10],11:[1,54],12:[1,55],13:[1,56],15:[2,10],17:[2,10],19:[2,10],20:[2,10],21:[2,10],22:[2,10],24:[2,10],25:[2,10],26:[2,10],27:[2,10],34:[2,10],36:[2,10],47:[2,10]},{5:[2,11],8:[2,11],11:[1,54],12:[1,55],13:[1,56],15:[2,11],17:[2,11],19:[2,11],20:[2,11],21:[2,11],22:[2,11],24:[2,11],25:[2,11],26:[2,11],27:[2,11],34:[2,11],36:[2,11],47:[2,11]},{5:[2,6],8:[2,6],11:[2,6],12:[2,6],13:[2,6],15:[2,6],17:[2,6],19:[2,6],20:[2,6],21:[2,6],22:[2,6],24:[2,6],25:[2,6],26:[2,6],27:[2,6],34:[2,6],36:[2,6],47:[2,6]},{5:[2,7],8:[2,7],11:[2,7],12:[2,7],13:[2,7],15:[2,7],17:[2,7],19:[2,7],20:[2,7],21:[2,7],22:[2,7],24:[2,7],25:[2,7],26:[2,7],27:[2,7],34:[2,7],36:[2,7],47:[2,7]},{5:[2,8],8:[2,8],11:[2,8],12:[2,8],13:[2,8],15:[2,8],17:[2,8],19:[2,8],20:[2,8],21:[2,8],22:[2,8],24:[2,8],25:[2,8],26:[2,8],27:[2,8],34:[2,8],36:[2,8],47:[2,8]},{5:[2,38],8:[2,38],11:[2,38],12:[2,38],13:[2,38],15:[2,38],17:[2,38],19:[2,38],20:[2,38],21:[2,38],22:[2,38],24:[2,38],25:[2,38],26:[2,38],27:[2,38],29:[2,38],31:[2,38],34:[2,38],36:[2,38],38:[2,38],41:[2,38],42:[2,38],44:[2,38],46:[2,38],47:[2,38]},{5:[2,39],8:[2,39],11:[2,39],12:[2,39],13:[2,39],15:[2,39],17:[2,39],19:[2,39],20:[2,39],21:[2,39],22:[2,39],24:[2,39],25:[2,39],26:[2,39],27:[2,39],29:[2,39],31:[2,39],34:[2,39],36:[2,39],38:[2,39],41:[2,39],42:[2,39],44:[2,39],46:[2,39],47:[2,39]},{5:[2,40],8:[2,40],11:[2,40],12:[2,40],13:[2,40],15:[2,40],17:[2,40],19:[2,40],20:[2,40],21:[2,40],22:[2,40],24:[2,40],25:[2,40],26:[2,40],27:[2,40],29:[2,40],31:[2,40],34:[2,40],36:[2,40],38:[2,40],41:[2,40],42:[2,40],44:[2,40],46:[2,40],47:[2,40]},{5:[2,42],8:[2,42],11:[2,42],12:[2,42],13:[2,42],15:[2,42],17:[2,42],19:[2,42],20:[2,42],21:[2,42],22:[2,42],24:[2,42],25:[2,42],26:[2,42],27:[2,42],29:[2,42],31:[2,42],34:[2,42],36:[2,42],38:[2,42],41:[2,42],42:[2,42],44:[2,42],46:[2,42],47:[2,42]},{38:[2,34],44:[2,34],47:[2,34]}],defaultActions:{31:[2,1]},parseError:function(a,b){if(!b.recoverable)throw new Error(a);this.trace(a)},parse:function(a){function b(){var a;return a=c.lexer.lex()||m,"number"!=typeof a&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(a),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n);var o=this.lexer.options&&this.lexer.options.ranges;this.parseError="function"==typeof this.yy.parseError?this.yy.parseError:Object.getPrototypeOf(this).parseError;for(var p,q,r,s,t,u,v,w,x,y={};;){if(r=d[d.length-1],this.defaultActions[r]?s=this.defaultActions[r]:((null===p||"undefined"==typeof p)&&(p=b()),s=g[r]&&g[r][p]),"undefined"==typeof s||!s.length||!s[0]){var z="";x=[];for(u in g[r])this.terminals_[u]&&u>l&&x.push("'"+this.terminals_[u]+"'");z=this.lexer.showPosition?"Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+x.join(", ")+", got '"+(this.terminals_[p]||p)+"'":"Parse error on line "+(i+1)+": Unexpected "+(p==m?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(z,{text:this.lexer.match,token:this.terminals_[p]||p,line:this.lexer.yylineno,loc:n,expected:x})}if(s[0]instanceof Array&&s.length>1)throw new Error("Parse Error: multiple actions possible at state: "+r+", token: "+p);switch(s[0]){case 1:d.push(p),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(s[1]),p=null,q?(p=q,q=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:if(v=this.productions_[s[1]][1],y.$=e[e.length-v],y._$={first_line:f[f.length-(v||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(v||1)].first_column,last_column:f[f.length-1].last_column},o&&(y._$.range=[f[f.length-(v||1)].range[0],f[f.length-1].range[1]]),t=this.performAction.call(y,h,j,i,this.yy,s[1],e,f),"undefined"!=typeof t)return t;v&&(d=d.slice(0,-1*v*2),e=e.slice(0,-1*v),f=f.slice(0,-1*v)),d.push(this.productions_[s[1]][0]),e.push(y.$),f.push(y._$),w=g[d[d.length-2]][d[d.length-1]],d.push(w);break;case 3:return!0}}return!0}},c=function(){var a={EOF:1,parseError:function(a,b){if(!this.yy.parser)throw new Error(a);this.yy.parser.parseError(a,b)},setInput:function(a){return this._input=a,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var b=a.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},unput:function(a){var b=a.length,c=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b-1),this.offset-=b;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),c.length-1&&(this.yylineno-=c.length-1);var e=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===d.length?this.yylloc.first_column:0)+d[d.length-c.length].length-c[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[e[0],e[0]+this.yyleng-b]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=new Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},test_match:function(a,b){var c,d,e;if(this.options.backtrack_lexer&&(e={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(e.yylloc.range=this.yylloc.range.slice(0))),d=a[0].match(/(?:\r\n?|\n).*/g),d&&(this.yylineno+=d.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:d?d[d.length-1].length-d[d.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+a[0].length},this.yytext+=a[0],this.match+=a[0],this.matches=a,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(a[0].length),this.matched+=a[0],c=this.performAction.call(this,this.yy,this,b,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),c)return c;if(this._backtrack){for(var f in e)this[f]=e[f];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d;this._more||(this.yytext="",this.match="");for(var e=this._currentRules(),f=0;fb[0].length)){if(b=c,d=f,this.options.backtrack_lexer){if(a=this.test_match(c,e[f]),a!==!1)return a;if(this._backtrack){b=!1;continue}return!1}if(!this.options.flex)break}return b?(a=this.test_match(b,e[d]),a!==!1?a:!1):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){var a=this.conditionStack.length-1;return a>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(a){return a=this.conditionStack.length-1-Math.abs(a||0),a>=0?this.conditionStack[a]:"INITIAL"},pushState:function(a){this.begin(a)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(a,b,c,d){switch(c){case 0:return 29;case 1:return 31;case 2:return"from";case 3:return 24;case 4:return 25;case 5:return 21;case 6:return 19;case 7:return 22;case 8:return 20;case 9:return 26;case 10:return 27;case 11:return 34;case 12:return 36;case 13:return 55;case 14:return 53;case 15:break;case 16:return 49;case 17:return 48;case 18:return 48;case 19:return 40;case 20:return 51;case 21:return 41;case 22:return 11;case 23:return 12;case 24:return 13;case 25:return 38;case 26:return 8;case 27:return 26;case 28:return 27;case 29:return 24;case 30:return 24;case 31:return 25;case 32:return 25;case 33:return 21;case 34:return 22;case 35:return 20;case 36:return 19;case 37:return 34;case 38:return 36;case 39:return 15;case 40:return 17;case 41:return 46;case 42:return 44;case 43:return 42;case 44:return 47;case 45:return 9;case 46:return 5}},rules:[/^(?:\s+in\b)/,/^(?:\s+notIn\b)/,/^(?:\s+from\b)/,/^(?:\s+(eq|EQ)\b)/,/^(?:\s+(neq|NEQ)\b)/,/^(?:\s+(lte|LTE)\b)/,/^(?:\s+(lt|LT)\b)/,/^(?:\s+(gte|GTE)\b)/,/^(?:\s+(gt|GT)\b)/,/^(?:\s+(like|LIKE)\b)/,/^(?:\s+(notLike|NOT_LIKE)\b)/,/^(?:\s+(and|AND)\b)/,/^(?:\s+(or|OR)\b)/,/^(?:\s+null\b)/,/^(?:\s+(true|false)\b)/,/^(?:\s+)/,/^(?:-?[0-9]+(?:\.[0-9]+)?\b)/,/^(?:'[^']*')/,/^(?:"[^"]*")/,/^(?:([a-zA-Z_$][0-9a-zA-Z_$]*))/,/^(?:^\/((?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/[imgy]{0,4})(?!\w))/,/^(?:\.)/,/^(?:\*)/,/^(?:\/)/,/^(?:\%)/,/^(?:,)/,/^(?:-)/,/^(?:=~)/,/^(?:!=~)/,/^(?:==)/,/^(?:===)/,/^(?:!=)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:>)/,/^(?:<)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\])/,/^(?:\[)/,/^(?:\))/,/^(?:!)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0}}};return a}();return b.lexer=c,a.prototype=b,b.Parser=a,new a}();"undefined"!=typeof a&&"undefined"!=typeof c&&(c.parser=e,c.Parser=e.Parser,c.parse=function(){return e.parse.apply(e,arguments)},c.main=function(b){b[1]||(console.log("Usage: "+b[0]+" FILE"),d.exit(1));var e=a("fs").readFileSync(a("path").normalize(b[1]),"utf8"); +return c.parser.parse(e)},"undefined"!=typeof b&&a.main===b&&c.main(d.argv.slice(1)))},{__browserify_process:64,fs:61,path:62}],44:[function(a,b,c){!function(){"use strict";var b=a("./constraint/parser"),d=a("./nools/nool.parser");c.parseConstraint=function(a){try{return b.parse(a)}catch(c){throw new Error("Invalid expression '"+a+"'")}},c.parseRuleSet=function(a,b){return d.parse(a,b)}}()},{"./constraint/parser":43,"./nools/nool.parser":45}],45:[function(a,b,c){"use strict";var d=a("./tokens.js"),e=a("../../extended"),f=e.hash.keys,g=a("./util.js"),h=function(a,b,c){var d=a;a=a.replace(/\/\/(.*)/g,"").replace(/\n|\r|\r\n/g," ");for(var e,i=new RegExp("^("+f(b).join("|")+")");a&&-1!==(e=g.findNextTokenIndex(a));){a=a.substr(e);var j=a.match(i);if(null===j)throw new Error("Error parsing "+a);if(j=j[1],!(j in b))throw new Error("Unknown token"+j);try{a=b[j](a,c,h).replace(/^\s*|\s*$/g,"")}catch(k){throw new Error("Invalid "+j+" definition \n"+k.message+"; \nstarting at : "+d)}}};c.parse=function(a,b){var c={define:[],rules:[],scope:[],loaded:[],file:b};return h(a,d,c),c}},{"../../extended":12,"./tokens.js":46,"./util.js":47}],46:[function(require,module,exports){var process=require("__browserify_process"),utils=require("./util.js"),fs=require("fs"),extd=require("../../extended"),filter=extd.filter,indexOf=extd.indexOf,predicates=["not","or","exists"],predicateRegExp=new RegExp("^("+predicates.join("|")+") *\\((.*)\\)$","m"),predicateBeginExp=new RegExp(" *("+predicates.join("|")+") *\\(","g"),isWhiteSpace=function(a){return 0===a.replace(/[\s|\n|\r|\t]/g,"").length},joinFunc=function(a,b){return"; "+b},splitRuleLineByPredicateExpressions=function(a){var b=a.replace(/,\s*(\$?\w+\s*:)/g,joinFunc),c=filter(b.split(predicateBeginExp),function(a){return""!==a}),d=c.length,e=[];if(!d)return b;for(var f=0;d>f;f++)-1!==indexOf(predicates,c[f])?e.push([c[f],"(",c[++f].replace(/, *$/,"")].join("")):e.push(c[f].replace(/, *$/,""));return e.join(";")},ruleTokens={salience:function(){var a=/^(salience|priority)\s*:\s*(-?\d+)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=parseInt(d[2],10);if(isNaN(e))throw new Error("Invalid salience/priority "+d[2]);return c.options.priority=e,b.replace(d[0],"")}throw new Error("invalid format")}}(),agendaGroup:function(){var a=/^(agenda-group|agendaGroup)\s*:\s*([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid agenda-group "+d[2]);return c.options.agendaGroup=e.replace(/^["']|["']$/g,""),b.replace(d[0],"")}throw new Error("invalid format")}}(),autoFocus:function(){var a=/^(auto-focus|autoFocus)\s*:\s*(true|false)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid auto-focus "+d[2]);return c.options.autoFocus="true"===e?!0:!1,b.replace(d[0],"")}throw new Error("invalid format")}}(),"agenda-group":function(){return this.agendaGroup.apply(this,arguments)},"auto-focus":function(){return this.autoFocus.apply(this,arguments)},priority:function(){return this.salience.apply(this,arguments)},when:function(){var ruleRegExp=/^(\$?\w+) *: *(\w+)(.*)/,constraintRegExp=/(\{ *(?:["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']? *(?:, *["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']?)*)+ *\})/,fromRegExp=/(\bfrom\s+.*)/,parseRules=function(str){for(var rules=[],ruleLines=str.split(";"),l=ruleLines.length,ruleLine,i=0;l>i&&(ruleLine=ruleLines[i].replace(/^\s*|\s*$/g,"").replace(/\n/g,""));i++)if(!isWhiteSpace(ruleLine)){var rule=[];if(predicateRegExp.test(ruleLine)){var m=ruleLine.match(predicateRegExp),pred=m[1].replace(/^\s*|\s*$/g,"");if(rule.push(pred),ruleLine=m[2].replace(/^\s*|\s*$/g,""),"or"===pred){rule=rule.concat(parseRules(splitRuleLineByPredicateExpressions(ruleLine))),rules.push(rule);continue}}var parts=ruleLine.match(ruleRegExp);if(!parts||!parts.length)throw new Error("Invalid constraint "+ruleLine);rule.push(parts[2],parts[1]);var constraints=parts[3].replace(/^\s*|\s*$/g,""),hashParts=constraints.match(constraintRegExp),from=null,fromMatch;if(hashParts){var hash=hashParts[1],constraint=constraints.replace(hash,"");fromRegExp.test(constraint)&&(fromMatch=constraint.match(fromRegExp),from=fromMatch[0],constraint=constraint.replace(fromMatch[0],"")),constraint&&rule.push(constraint.replace(/^\s*|\s*$/g,"")),hash&&rule.push(eval("("+hash.replace(/(\$?\w+)\s*:\s*(\$?\w+)/g,'"$1" : "$2"')+")"))}else constraints&&!isWhiteSpace(constraints)&&(fromRegExp.test(constraints)&&(fromMatch=constraints.match(fromRegExp),from=fromMatch[0],constraints=constraints.replace(fromMatch[0],"")),rule.push(constraints));from&&rule.push(from),rules.push(rule)}return rules};return function(a,b){var c=a.replace(/^when\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(d,""),b.constraints=parseRules(d.replace(/^\{\s*|\}\s*$/g,"")),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}(),then:function(){return function(a,b){if(b.action)throw new Error("action already defined for rule"+b.name);var c=a.replace(/^then\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join("");if(c=c.replace(d,""),b.action||(b.action=d.replace(/^\{\s*|\}\s*$/g,"")),!isWhiteSpace(c))throw new Error("Error parsing then block "+a);return c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}()},topLevelTokens={"/":function(a){return a.match(/^\/\*/)?a.replace(/\/\*.*?\*\//,""):a},define:function(a,b){var c=a.replace(/^define\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){d=d[1];var e=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(e,""),b.define.push({name:d,properties:"("+e+")"}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"import":function(a,b,c){if("undefined"!=typeof window)throw new Error("import cannot be used in a browser");var d=a.replace(/^import\s*/,"");if("("===utils.findNextToken(d)){var e=utils.getParamList(d);if(d=d.replace(e,"").replace(/^\s*|\s*$/g,""),";"===utils.findNextToken(d)&&(d=d.replace(/\s*;/,"")),e=e.replace(/[\(|\)]/g,"").split(","),1===e.length){if(e=utils.resolve(b.file||process.cwd(),e[0].replace(/["|']/g,"")),-1===indexOf(b.loaded,e)){var f=b.file;b.file=e,c(fs.readFileSync(e,"utf8"),topLevelTokens,b),b.loaded.push(e),b.file=f}return d}throw new Error("import accepts a single file")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(d)+"'")},global:function(a,b){var c=a.replace(/^global\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*\s*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"="===utils.findNextToken(c)){d=d[1].replace(/^\s+|\s+$/g,"");var e=utils.getTokensBetween(c,"=",";",!0).join(""),f=e.substring(1,e.length-1);if(f=f.replace(/^\s+|\s+$/g,""),/^require\(/.test(f)){var g=utils.getParamList(f.replace("require")).replace(/[\(|\)]/g,"").split(",");1===g.length&&(g=g[0].replace(/["|']/g,""),f=["require('",utils.resolve(b.file||process.cwd(),g),"')"].join(""))}return b.scope.push({name:d,body:f}),c=c.replace(e,"")}throw new Error("unexpected token : expected : '=' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"function":function(a,b){var c=a.replace(/^function\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)\s*/);if(d){if(c=c.replace(d[0],""),"("===utils.findNextToken(c)){d=d[1];var e=utils.getParamList(c);if(c=c.replace(e,"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){var f=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(f,""),b.scope.push({name:d,body:"function"+e+f}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},rule:function(a,b,c){var d=a.replace(/^rule\s*/,""),e=d.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')/);if(e){if(d=d.replace(e[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(d)){e=e[1].replace(/^["']|["']$/g,"");var f={name:e,options:{},constraints:null,action:null},g=utils.getTokensBetween(d,"{","}",!0).join("");return d=d.replace(g,""),c(g.replace(/^\{\s*|\}\s*$/g,""),ruleTokens,f),b.rules.push(f),d}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(d)+"'")}throw new Error("missing name")}};module.exports=topLevelTokens},{"../../extended":12,"./util.js":47,__browserify_process:64,fs:61}],47:[function(a,b,c){var d=a("__browserify_process"),e=a("path"),f=/[\s|\n|\r|\t]/,g=e.sep||("win32"===d.platform?"\\":"/"),h={"{":"}","}":"{","(":")",")":"(","[":"]"},i=c.getTokensBetween=function(a,b,c,d){var e=0,f=[];b||(b=h[c],e=1),c||(c=h[b]),a=Object(a);for(var g,i=!1,j=0,k=!1;g=a.charAt(j++);)if(g===b)e++,i?f.push(g):(i=!0,d&&f.push(g));else if(g===c&&j){if(e--,0===e){d&&f.push(g),k=!0;break}f.push(g)}else i&&f.push(g);if(!k)throw new Error("Unable to match "+b+" in "+a);return f};c.getParamList=function(a){return i(a,"(",")",!0).join("")},c.resolve=function(a,b){return""!==e.extname(a)&&(a=e.dirname(a)),1===b.split(g).length?b:e.resolve(a,b)};var j=c.findNextTokenIndex=function(a,b,c){b=b||0,c=c||a.length;var d=-1,e=a.length;for((!c||c>e)&&(c=e);c>b;b++){var g=a.charAt(b);if(!f.test(g)){d=b;break}}return d};c.findNextToken=function(a,b,c){return a.charAt(j(a,b,c))}},{__browserify_process:64,path:62}],48:[function(a,b,c){"use strict";var d=a("./extended"),e=d.isEmpty,f=d.merge,g=d.forEach,h=d.declare,i=a("./constraintMatcher"),j=a("./constraint"),k=j.EqualityConstraint,l=j.FromConstraint,m=0,n=h({}),o=n.extend({instance:{constructor:function(a,b,c,d,h){h=h||{},this.id=m++,this.type=a,this.alias=b,this.conditions=c,this.pattern=h.pattern;var k=[new j.ObjectConstraint(a)],l=i.toConstraints(c,f({alias:b},h));if(l.length)k=k.concat(l);else{var n=new j.TrueConstraint;k.push(n)}if(d&&!e(d)){var o=new j.HashConstraint(d);k.push(o)}g(k,function(a){a.set("alias",b)}),this.constraints=k},getSpecificity:function(){for(var a=this.constraints,b=0,c=0,d=a.length;d>c;c++)a[c]instanceof k&&b++;return b},hasConstraint:function(a){return d.some(this.constraints,function(b){return b instanceof a})},hashCode:function(){return[this.type,this.alias,d.format("%j",this.conditions)].join(":")},toString:function(){return d.format("%j",this.constraints)}}}).as(c,"ObjectPattern"),p=o.extend({instance:{constructor:function(a,b,c,d,e,f){this._super([a,b,c,d,f]),this.from=new l(e,f)},hasConstraint:function(a){return d.some(this.constraints,function(b){return b instanceof a})},getSpecificity:function(){return this._super(arguments)+1},hashCode:function(){return[this.type,this.alias,d.format("%j",this.conditions),this.from.from].join(":")},toString:function(){return d.format("%j from %s",this.constraints,this.from.from)}}}).as(c,"FromPattern");p.extend().as(c,"FromNotPattern"),o.extend().as(c,"NotPattern"),o.extend().as(c,"ExistsPattern"),p.extend().as(c,"FromExistsPattern"),n.extend({instance:{constructor:function(a,b){this.id=m++,this.leftPattern=a,this.rightPattern=b},hashCode:function(){return[this.leftPattern.hashCode(),this.rightPattern.hashCode()].join(":")},getSpecificity:function(){return this.rightPattern.getSpecificity()+this.leftPattern.getSpecificity()},getters:{constraints:function(){return this.leftPattern.constraints.concat(this.rightPattern.constraints)}}}}).as(c,"CompositePattern");var q=h({instance:{constructor:function(){this.id=m++,this.recency=0}}}).as(c,"InitialFact");o.extend({instance:{constructor:function(){this._super([q,"__i__",[],{}])},assert:function(){return!0}}}).as(c,"InitialFactPattern")},{"./constraint":8,"./constraintMatcher":9,"./extended":12}],49:[function(a,b,c){"use strict";function d(a,b,c,d){f(b)?(d=c,c=b):b=b||{};var g=e.every(c,function(a){return f(a)});g&&1===c.length&&(c=c[0],g=!1);var h=[],i=b.scope||{};if(c.scope=i,g){for(var j,k=function(a,b){m[b]?e(m).forEach(function(b){b.push(a)}):(m[b]=0===b?[]:m[b-1].slice(),0!==b&&m[b].pop(),m[b].push(a))},l=c.length,m=[],n=0;l>n;n++)j=c[n],j.scope=i,e.forEach(y(j),k);h=e.map(m,function(c){for(var e=null,f=0;f>>0;if(0===d)return-1;var e=d;arguments.length>2&&(e=Number(arguments[2]),e!==e?e=0:0!==e&&e!==1/0&&e!==-(1/0)&&(e=(e>0||-1)*P(Q(e))));for(var f=e>=0?R(e,d-1):d-Q(e);f>=0;f--)if(f in c&&c[f]===b)return f;return-1}function i(a,b,c){if(a&&X&&X===a.filter)return a.filter(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)if(g in d){var h=d[g];b.call(c,h,g,d)&&f.push(h)}return f}function j(a,b,c){if(!N(a)||"function"!=typeof b)throw new TypeError;if(a&&T&&T===a.forEach)return a.forEach(b,c),a;for(var d=0,e=a.length;e>d;++d)b.call(c||a,a[d],d,a);return a}function k(a,b,c){if(a&&Y&&Y===a.every)return a.every(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&!b.call(c,d[f],f,d))return!1;return!0}function l(a,b,c){if(a&&Z&&Z===a.some)return a.some(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&b.call(c,d[f],f,d))return!0;return!1}function m(a,b,c){if(a&&U&&U===a.map)return a.map(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)g in d&&f.push(b.call(c,d[g],g,d));return f}function n(a,b,c){var d=arguments.length>2;if(a&&V&&V===a.reduce)return d?a.reduce(b,c):a.reduce(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=0,f=a.length>>0;if(arguments.length<3){if(0===f)throw new TypeError("Array length is 0 and no second argument");c=a[0],e=1}else c=arguments[2];for(;f>e;)e in a&&(c=b.call(void 0,c,a[e],e,a)),++e;return c}function o(a,b,c){var d=arguments.length>2;if(a&&W&&W===a.reduceRight)return d?a.reduceRight(b,c):a.reduceRight(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=Object(a),f=e.length>>>0;if(0===f&&2===arguments.length)throw new TypeError;var g=f-1;if(arguments.length>=3)c=arguments[2];else for(;;)if(g in a){c=a[g--];break}for(;g>=0;)g in e&&(c=b.call(void 0,c,e[g],g,e)),g--;return c}function p(a){var c=[];if(null!==a){var d=$(arguments);if(1===d.length)if(N(a))c=a;else if(b.isHash(a))for(var e in a)a.hasOwnProperty(e)&&c.push([e,a[e]]);else c.push(a);else j(d,function(a){c=c.concat(p(a))})}return c}function q(a){return a=a||[],a.length?n(a,function(a,b){return a+b}):0}function r(a){if(a=a||[],a.length){var c=q(a);if(b.isNumber(c))return c/a.length;throw new Error("Cannot average an array of non numbers.")}return 0}function s(a,b){return _(a,b)}function t(a,b){return _(a,b)[0]}function u(a,b){return _(a,b)[a.length-1]}function v(a){var b=a,c=J($(arguments,1));return N(a)&&(b=i(a,function(a){return-1===g(c,a)})),b}function w(a){var b,c=[],d=-1,e=0;if(a)for(b=a.length;++d0?(c.push(c.shift()),b--):(c.unshift(c.pop()),b++),y(c,b)):c}function z(a,b){var c=[];if(N(a)){var d=a.slice(0);"number"!=typeof b&&(b=a.length),b?b<=a.length&&(c=n(a,function(a,c,f){var g;return g=b>1?e(c,y(d,f).slice(1),b):[[c]],a.concat(g)},[])):c=[[]]}return c}function A(){var a=[],c=$(arguments);if(c.length>1){var d=c.shift();N(d)&&(a=n(d,function(a,d,e){for(var f=[d],g=0;gd;d++)c.push(a[b[d]]||null);return c}function D(){var a=[],b=$(arguments);if(b.length>1){for(var c=0,d=b.length;d>c;c++)a=a.concat(b[c]);a=w(a)}return a}function E(){var a,b,c=[],d=-1;if(a=arguments.length>1?$(arguments):arguments[0],N(a))for(c=a[0],d=0,b=a.length;++d1?c:p(a),n(b,function(a,b){return a.concat(b)},[])}function K(a,b){b=b.split(".");var c=a.slice(0);return j(b,function(a){var b=a.match(/(\w+)\(\)$/);c=m(c,function(c){return b?c[b[1]]():c[a]})}),c}function L(a,b,c){return c=$(arguments,2),m(a,function(a){var d=M(b)?a[b]:b;return d.apply(a,c)})}var M=b.isString,N=Array.isArray||b.isArray,O=b.isDate,P=Math.floor,Q=Math.abs,R=(Math.max,Math.min),S=Array.prototype,T=(S.indexOf,S.forEach),U=S.map,V=S.reduce,W=S.reduceRight,X=S.filter,Y=S.every,Z=S.some,$=c.argsToArray,_=function(){var a=function(a,b){return k(a,b)},b=function(a,b){return a-b},c=function(a,b){return a.getTime()-b.getTime()};return function(d,e){var f=[];return N(d)&&(f=d.slice(),e?"function"==typeof e?f.sort(e):f.sort(function(a,b){var c=a[e],d=b[e];return M(c)&&M(d)?c>d?1:d>c?-1:0:O(c)&&O(d)?c.getTime()-d.getTime():c-d}):a(f,M)?f.sort():a(f,O)?f.sort(c):f.sort(b)),f}}(),ab={toArray:p,sum:q,avg:r,sort:s,min:t,max:u,difference:v,removeDuplicates:w,unique:x,rotate:y,permutations:z,zip:A,transpose:B,valuesAt:C,union:D,intersect:E,powerSet:F,cartesian:G,compact:H,multiply:I,flatten:J,pluck:K,invoke:L,forEach:j,map:m,filter:i,reduce:n,reduceRight:o,some:l,every:k,indexOf:g,lastIndexOf:h};return a.define(N,ab).expose(ab)}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.arrayExtended=d(this.extended,this.isExtended,this.argumentsExtended)}).call(this)},{"arguments-extended":51,extended:56,"is-extended":66}],53:[function(a,b,c){(function(){"use strict";function d(a,b,c){function d(a,b,c,d){a=""+a,c=c||" ";for(var e=a.length;b>e;)d?a+=c:a=c+a,e++;return a}function e(a,c,d){var f=a;if(b.isString(f)){if(a.length>c)if(d){var g=a.length;f=a.substring(g-c,g)}else f=a.substring(0,c)}else f=e(""+f,c);return f}function f(a,c,d){if(!b.isArray(a)||"function"!=typeof c)throw new TypeError;for(var e=Object(a),f=e.length>>>0,g=0;f>g;g++)if(g in e&&!c.call(d,e[g],g,e))return!1;return!0}function g(a,b){return A.difference(new Date(a.getFullYear(),0,1,a.getHours()),a,null,b)+1}function h(a,b,c){b=b||0;var d=a[c?"getUTCFullYear":"getFullYear"](),e=new Date(d,0,1).getDay(),f=(e-b+7)%7,h=o((g(a)+f-1)/7);return e===b&&h++,h}function i(a){var b=a.toString(),c="",d=b.indexOf("(");return d>-1&&(c=b.substring(++d,b.indexOf(")"))),c}function j(a,b){return a.replace(/([a-z])\1*/gi,function(a){var c,d=a.charAt(0),e=a.length,f="0?",g="0{0,2}";if("y"===d)c="\\d{2,4}";else if("M"===d)c=e>2?"\\S+?":"1[0-2]|"+f+"[1-9]";else if("D"===d)c="[12][0-9][0-9]|3[0-5][0-9]|36[0-6]|"+g+"[1-9][0-9]|"+f+"[1-9]";else if("d"===d)c="3[01]|[12]\\d|"+f+"[1-9]";else if("w"===d)c="[1-4][0-9]|5[0-3]|"+f+"[1-9]";else if("E"===d)c="\\S+";else if("h"===d)c="1[0-2]|"+f+"[1-9]";else if("K"===d)c="1[01]|"+f+"\\d";else if("H"===d)c="1\\d|2[0-3]|"+f+"\\d";else if("k"===d)c="1\\d|2[0-4]|"+f+"[1-9]";else if("m"===d||"s"===d)c="[0-5]\\d";else if("S"===d)c="\\d{"+e+"}";else if("a"===d){var h="AM",i="PM";c=h+"|"+i,h!==h.toLowerCase()&&(c+="|"+h.toLowerCase()),i!==i.toLowerCase()&&(c+="|"+i.toLowerCase()),c=c.replace(/\./g,"\\.")}else c="v"===d||"z"===d||"Z"===d||"G"===d||"q"===d||"Q"===d?".*":" "===d?"\\s*":d+"*";return b&&b.push(a),"("+c+")"}).replace(/[\xa0 ]/g,"[\\s\\xa0]")}function k(a){B[a+"sFromNow"]=function(b){return A.add(new Date,a,b)},B[a+"sAgo"]=function(b){return A.add(new Date,a,-b)}}for(var l=function(){function a(a,b,c){return a=a.replace(/s$/,""),e.hasOwnProperty(a)?e[a](b,c):[c,"UTC"+a.charAt(0).toUpperCase()+a.substring(1)+"s",!1]}function b(a,b,c,e){return a=a.replace(/s$/,""),d(f[a](b,c,e))}var c=Math.floor,d=Math.round,e={day:function(a,b){return[b,"Date",!1]},weekday:function(a,b){var c,d,e=b%5,f=a.getDay(),g=0;e?(c=e,d=parseInt(b/5,10)):(c=b>0?5:-5,d=b>0?(b-5)/5:(b+5)/5),6===f&&b>0?g=1:0===f&&0>b&&(g=-1);var h=f+c;return(0===h||6===h)&&(g=b>0?2:-2),[7*d+c+g,"Date",!1]},year:function(a,b){return[b,"FullYear",!0]},week:function(a,b){return[7*b,"Date",!1]},quarter:function(a,b){return[3*b,"Month",!0]},month:function(a,b){return[b,"Month",!0]}},f={quarter:function(a,b,d){var e=b.getFullYear()-a.getFullYear(),f=a[d?"getUTCMonth":"getMonth"](),g=b[d?"getUTCMonth":"getMonth"](),h=c(f/3)+1,i=c(g/3)+1;return i+=4*e,i-h},weekday:function(a,c,d){var e,f=b("day",a,c,d),g=f%7;if(0===g)f=5*b("week",a,c,d);else{var h=0,i=a[d?"getUTCDay":"getDay"](),j=c[d?"getUTCDay":"getDay"]();e=parseInt(f/7,10);var k=new Date(+a);k.setDate(k[d?"getUTCDate":"getDate"]()+7*e);var l=k[d?"getUTCDay":"getDay"]();f>0?6===i||6===j?h=-1:0===i?h=0:(0===j||l+g>5)&&(h=-2):0>f&&(6===i?h=0:0===i||0===j?h=1:(6===j||0>l+g)&&(h=2)),f+=h,f-=2*e}return f},year:function(a,b){return b.getFullYear()-a.getFullYear()},month:function(a,b,c){var d=a[c?"getUTCMonth":"getMonth"](),e=b[c?"getUTCMonth":"getMonth"]();return e-d+12*(b.getFullYear()-a.getFullYear())},week:function(a,c,e){return d(b("day",a,c,e)/7)},day:function(a,b){return 1.1574074074074074e-8*(b.getTime()-a.getTime())},hour:function(a,b){return 2.7777777777777776e-7*(b.getTime()-a.getTime())},minute:function(a,b){return 16666666666666667e-21*(b.getTime()-a.getTime())},second:function(a,b){return.001*(b.getTime()-a.getTime())},millisecond:function(a,b){return b.getTime()-a.getTime()}};return{addTransform:a,differenceTransform:b}}(),m=l.addTransform,n=l.differenceTransform,o=Math.floor,p=Math.round,q=Math.min,r=Math.pow,s=Math.ceil,t=Math.abs,u=["January","February","March","April","May","June","July","August","September","October","November","December"],v=["Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."],w=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],x=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],y=["Before Christ","Anno Domini"],z=["BC","AD"],A={getDaysInMonth:function(a){var b=a.getMonth(),c=[31,28,31,30,31,30,31,31,30,31,30,31];return 1===b&&A.isLeapYear(a)?29:c[b]},isLeapYear:function(a,b){var c=a[b?"getUTCFullYear":"getFullYear"]();return c%400===0||c%4===0&&c%100!==0},isWeekend:function(a,b){var c=(a||new Date)[b?"getUTCDay":"getDay"]();return 0===c||6===c},getTimezoneName:i,compare:function(a,b,c){return a=new Date(+a),b=new Date(+(b||new Date)),"date"===c?(a.setHours(0,0,0,0),b.setHours(0,0,0,0)):"time"===c&&(a.setFullYear(0,0,0),b.setFullYear(0,0,0)),a>b?1:b>a?-1:0},add:function(a,b,c){var d=m(b,a,c||0);c=d[0];var e=d[1],f=new Date(+a),g=d[2];return e&&f["set"+e](f["get"+e]()+c),g&&f.getDate()E?z:y)[0>f?0:1];else if("y"===D)B=f,E>1&&(2===E?B=e(""+B,2,!0):C=!0);else if("Q"===D.toUpperCase())B=s((j+1)/3),C=!0;else if("M"===D)3>E?(B=j+1,C=!0):B=(3===E?v:u)[j];else if("w"===D)B=h(a,0,c),C=!0;else if("D"===D)B=g(a,c),C=!0;else if("E"===D)3>E?(B=k+1,C=!0):B=(-3===E?x:w)[k];else if("a"===D)B=12>m?"AM":"PM";else if("h"===D)B=m%12||12,C=!0;else if("K"===D)B=m%12,C=!0;else if("k"===D)B=m||24,C=!0;else if("S"===D)B=p(A*r(10,E-3)),C=!0;else if("z"===D||"v"===D||"Z"===D){if(B=i(a),"z"!==D&&"v"!==D||B||(E=4),!B||"Z"===D){var F=a.getTimezoneOffset(),G=[F>=0?"-":"+",d(o(t(F)/60),2,"0"),d(t(F)%60,2,"0")];4===E&&(G.splice(0,0,"GMT"),G.splice(3,0,":")),B=G.join("")}}else B=b;else B=""+n,C=!0;else B=""+m,C=!0;return C&&(B=d(B,E,"0")),B})}},B={},C=["year","month","day","hour","minute","second"],D=0,E=C.length;E>D;D++)k(C[D]);var F={parseDate:function(a,b){if(!b)throw new Error("format required when calling dateExtender.parse");var d=[],e=j(b,d),g=new RegExp("^"+e+"$","i"),h=g.exec(a);if(!h)return null;var i=[1970,0,1,0,0,0,0],k="",l=f(h,function(a,b){if(b){var e=d[b-1],f=e.length,g=e.charAt(0);if("y"===g)if(100>a){a=parseInt(a,10);var h=""+(new Date).getFullYear(),j=100*h.substring(0,2),l=q(h.substring(2,4)+20,99);i[0]=l>a?j+a:j-100+a}else i[0]=a;else if("M"===g){if(f>2){var m,n,o=u;3===f&&(o=v),a=a.replace(".","").toLowerCase();var p=!1;for(m=0,n=o.length;n>m&&!p;m++){var r=o[m].replace(".","").toLocaleLowerCase();r===a&&(a=m,p=!0)}if(!p)return!1}else a--;i[1]=a}else if("E"===g||"e"===g){var s=w;3===f&&(s=x),a=a.toLowerCase(),s=c.map(s,function(a){return a.toLowerCase()});var t=c.indexOf(s,a);if(-1===t){if(a=parseInt(a,10),isNaN(a)||a>s.length)return!1}else a=t}else if("D"===g||"d"===g)"D"===g&&(i[1]=0),i[2]=a;else if("a"===g){var y="am",z="pm",A=/\./g;a=a.replace(A,"").toLowerCase(),k=a===z?"p":a===y?"a":""}else"k"===g||"h"===g||"H"===g||"K"===g?("k"===g&&24===+a&&(a=0),i[3]=a):"m"===g?i[4]=a:"s"===g?i[5]=a:"S"===g&&(i[6]=a)}return!0});if(l){var m=+i[3];"p"===k&&12>m?i[3]=m+12:"a"===k&&12===m&&(i[3]=0);var n=new Date(i[0],i[1],i[2],i[3],i[4],i[5],i[6]),o=-1!==c.indexOf(d,"d"),p=-1!==c.indexOf(d,"M"),r=i[1],s=i[2],t=n.getMonth(),y=n.getDate();return p&&t>r||o&&y>s?null:n}return null}},G=a.define(b.isDate,A).define(b.isString,F).define(b.isNumber,B);for(D in A)A.hasOwnProperty(D)&&(G[D]=A[D]);for(D in F)F.hasOwnProperty(D)&&(G[D]=F[D]);for(D in B)B.hasOwnProperty(D)&&(G[D]=B[D]);return G}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c) +}):this.dateExtended=d(this.extended,this.isExtended,this.arrayExtended)}).call(this)},{"array-extended":52,extended:56,"is-extended":66}],54:[function(a,b,c){!function(){function a(){function a(a,b){return b=b||0,x.call(a,b)}function b(a){return"[object Array]"===Object.prototype.toString.call(a)}function c(a){var b;return null!==a&&a!==b&&"object"==typeof a}function d(a){var b=c(a);return b&&a.constructor===Object}function e(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function f(a,b,c){var d,f;for(d in b)b.hasOwnProperty(d)&&-1===e(c,d)&&(f=b[d],d in a&&a[d]===f||(a[d]=f));return a}function g(a){var c=this.__meta,d=c.supers,e=d.length,f=c.superMeta,g=f.pos;if(e>g){a=a?B(a)||b(a)?a:[a]:[];var h,i=f.name,j=f.f;do if(h=d[g][i],"function"==typeof h&&(h=h._f||h)!==j)return f.pos=1+g,h.apply(this,a);while(e>++g)}return null}function h(){var a=this.__meta,b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.bind(this);while(c>++e)}return null}function i(a){var b=this.__getters__;return b.hasOwnProperty(a)?b[a].apply(this):this[a]}function j(b,c){var e=this.__setters__;if(!d(b))return e.hasOwnProperty(b)?e[b].apply(this,a(arguments,1)):this[b]=c;for(var f in b){var g=b[f];e.hasOwnProperty(f)?e[b].call(this,g):this[f]=g}}function k(){var a=this.__meta||{},b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.apply(this,arguments);while(c>++e)}return null}function l(a,b){if(a.toString().match(A)){var c=function(){var c,d=this.__meta||{},e=d.superMeta;switch(d.superMeta={f:a,pos:0,name:b},arguments.length){case 0:c=a.call(this);break;case 1:c=a.call(this,arguments[0]);break;case 2:c=a.call(this,arguments[0],arguments[1]);break;case 3:c=a.call(this,arguments[0],arguments[1],arguments[2]);break;default:c=a.apply(this,arguments)}return d.superMeta=e,c};return c._f=a,c}return a._f=a,a}function m(a,b){var c=b.setters||{},d=a.__setters__,e=a.__getters__;for(var f in c)d.hasOwnProperty(f)||(d[f]=c[f]);c=b.getters||{};for(f in c)e.hasOwnProperty(f)||(e[f]=c[f]);for(var g in b)if("getters"!==g&&"setters"!==g){var h=b[g];"function"==typeof h?a.hasOwnProperty(g)||(a[g]=l(k,g)):a[g]=h}}function n(){for(var b=a(arguments),c=b.length,d=this.prototype,e=d.__meta,f=this.__meta,g=d.__meta.bases,h=g.slice(),i=f.supers||[],j=e.supers||[],k=0;c>k;k++){var l=b[k],n=l.prototype,p=n.__meta,q=l.__meta;!p&&(p=n.__meta={proto:n||{}}),!q&&(q=l.__meta={proto:l.__proto__||{}}),m(d,p.proto||{}),m(this,q.proto||{}),o(l.prototype,j,g),o(l,i,h)}return this}function o(a,b,c){var d=a.__meta;!d&&(d=a.__meta={});var f=a.__meta.unique;if(!f&&(d.unique="declare"+ ++y),-1===e(c,f)){c.push(f);for(var g=a.__meta.supers||[],h=g.length-1||0;h>=0;)o(g[h--],b,c);b.unshift(a)}}function p(a,b){var c=b.setters,d=a.__setters__,e=a.__getters__;if(c)for(var f in c)d[f]=c[f];if(c=b.getters||{})for(f in c)e[f]=c[f];for(f in b)if("getters"!=f&&"setters"!=f){var g=b[f];if("function"==typeof g){var h=g.__meta||{};a[f]=h.isConstructor?g:l(g,f)}else a[f]=g}}function q(a,b){return a&&b?a[b]=this:a.exports=a=this,this}function r(a){return u(this,a)}function s(a){z.prototype=a.prototype;var b=new z;return z.prototype=null,b}function t(a,c,e){var i={},j=[],m="declare"+ ++y,q=[],r=[],t=[],u=[],v={supers:t,unique:m,bases:q,superMeta:{f:null,pos:0,name:null}},x={supers:u,unique:m,bases:r,isConstructor:!0,superMeta:{f:null,pos:0,name:null}};if(d(c)&&!e&&(e=c,c=w),"function"==typeof c||b(c)?(j=b(c)?c:[c],c=j.shift(),a.__meta=x,i=s(c),i.__meta=v,i.__getters__=f({},i.__getters__||{}),i.__setters__=f({},i.__setters__||{}),a.__getters__=f({},a.__getters__||{}),a.__setters__=f({},a.__setters__||{}),o(c.prototype,t,q),o(c,u,r)):(a.__meta=x,i.__meta=v,i.__getters__=i.__getters__||{},i.__setters__=i.__setters__||{},a.__getters__=a.__getters__||{},a.__setters__=a.__setters__||{}),a.prototype=i,e){var z=v.proto=e.instance||{},A=x.proto=e.static||{};A.init=A.init||k,p(i,z),p(a,A),i.constructor=z.hasOwnProperty("constructor")?l(z.constructor,"constructor"):z.constructor=l(k,"constructor")}else v.proto={},x.proto={},a.init=l(k,"init"),i.constructor=l(k,"constructor");j.length&&n.apply(a,j),c&&f(a,f(f({},c),a)),i._super=a._super=g,i._getSuper=a._getSuper=h,i._static=a}function u(a,b){function c(){switch(arguments.length){case 0:this.constructor.call(this);break;case 1:this.constructor.call(this,arguments[0]);break;case 2:this.constructor.call(this,arguments[0],arguments[1]);break;case 3:this.constructor.call(this,arguments[0],arguments[1],arguments[2]);break;default:this.constructor.apply(this,arguments)}}return t(c,a,b),c.init()||c}function v(a,b){function c(){return d||(this.constructor.apply(this,arguments),d=this),d}var d;return t(c,a,b),c.init()||c}var w,x=Array.prototype.slice,y=0,z=new Function,A=/(super)/g,B=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};return B(arguments)||(B=function(a){return!(!a||!a.hasOwnProperty("callee"))}),w=u({instance:{get:i,set:j},"static":{get:i,set:j,mixin:n,extend:r,as:q}}),u.singleton=v,u}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=a()):"function"==typeof define&&define.amd?define(a):this.declare=a()}()},{}],55:[function(a,b){b.exports=a("./declare.js")},{"./declare.js":54}],56:[function(a,b,c){(function(){"use strict";function d(a){function b(){var b=a.define();return b.expose({register:function(a,c){c||(c=a,a=null);var d=typeof c;if(a)b[a]=c;else if(c&&"function"===d)b.extend(c);else{if("object"!==d)throw new TypeError("extended.register must be called with an extender function");b.expose(c)}return b},define:function(){return a.define.apply(a,arguments)}}),b}function c(){return b()}!function(){function a(a,b){var c,d;for(c in b)b.hasOwnProperty(c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}return function(b){b||(b={});for(var c=1,d=arguments.length;d>c;c++)a(b,arguments[c]);return b}}();return c.define=function(){return a.define.apply(a,arguments)},c}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extender"))):"function"==typeof define&&define.amd?define(["extender"],function(a){return d(a)}):this.extended=d(this.extender)}).call(this)},{extender:58}],57:[function(a,b,c){(function(){function d(a){function b(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function c(a){return"[object Array]"===Object.prototype.toString.call(a)}function d(b){function c(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);a.unshift(this._value);var b=c.apply(this,a);return b!==e?this.__extender__(b):this},a[b]=d}function d(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);return a.unshift(this._value),c.apply(this,a)},a[b]=d}function h(a,b,e){for(var f in b)b.hasOwnProperty(f)&&("getters"!==f&&"setters"!==f?"noWrap"===f?h(a,b[f],!0):e?d(a,f,b[f]):c(a,f,b[f]):a[f]=b[f])}function i(a){var b,c,d=a;if(!(a instanceof m)){var e=m;for(b=0,c=n.length;c>b;b++){var f=n[b];f[0](a)&&(e=e.extend({instance:f[1]}))}d=new e(a),d.__extender__=i}return d}function j(){return!0}function k(a,b){if(arguments.length){"object"==typeof a&&(b=a,a=j),b=b||{};var d={};h(d,b),d.hasOwnProperty("constructor")||(b.hasOwnProperty("constructor")?c(d,"constructor",b.constructor):d.constructor=function(){this._super(arguments)}),n.push([a,d])}return i}function l(a){return a&&a.hasOwnProperty("__defined__")&&(i.__defined__=n=n.concat(a.__defined__)),g(i,a,["define","extend","expose","__defined__"]),i}b=b||[];var m=a({instance:{constructor:function(a){this._value=a},value:function(){return this._value},eq:function(a){return this.__extender__(this._value===a)},neq:function(a){return this.__extender__(this._value!==a)},print:function(){return console.log(this._value),this}}}),n=[];return i.define=k,i.extend=l,i.expose=function(){for(var a,b=0,c=arguments.length;c>b;b++)a=arguments[b],"object"==typeof a&&g(i,a,["define","extend","expose","__defined__"]);return i},i.__defined__=n,i}var e,f=Array.prototype.slice,g=function(){function a(a,c,d){var e,f;for(e in c)c.hasOwnProperty(e)&&-1===b(d,e)&&(f=c[e],e in a&&a[e]===f||(a[e]=f));return a}return function(b){b||(b={});var d=arguments.length,e=arguments[arguments.length-1];c(e)?d--:e=[];for(var f=1;d>f;f++)a(b,arguments[f],e);return b}}();return{define:function(){return d().define.apply(d,arguments)},extend:function(a){return d().define().extend(a)}}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("declare.js"))):"function"==typeof define&&define.amd?define(["declare"],function(a){return d(a)}):this.extender=d(this.declare)}).call(this)},{"declare.js":55}],58:[function(a,b){b.exports=a("./extender.js")},{"./extender.js":57}],59:[function(a,b,c){(function(){"use strict";function d(a,b,c){function d(a,b,c){var d;switch((b||[]).length){case 0:d=a.call(c);break;case 1:d=a.call(c,b[0]);break;case 2:d=a.call(c,b[0],b[1]);break;case 3:d=a.call(c,b[0],b[1],b[2]);break;default:d=a.apply(c,b)}return d}function e(a,b,c){if(c=p(arguments,2),n(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!n(b)&&!o(b))throw new Error(b+" is not a function");return n(b)?function(){var e=a[b];return o(e)?d(e,c.concat(p(arguments)),a):e}:c.length?function(){return d(b,c.concat(p(arguments)),a)}:function(){return d(b,arguments,a)}}function f(a,b){if(b=p(arguments,1),!n(a)&&!o(a))throw new Error(a+" must be the name of a property or function to execute");return n(a)?function(){var c=p(arguments),e=c.shift(),f=e[a];return o(f)?(c=b.concat(c),d(f,c,e)):f}:function(){var c=p(arguments),e=c.shift();return c=b.concat(c),d(a,c,e)}}function g(a,b,c){if(c=p(arguments,2),n(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!n(b)&&!o(b))throw new Error(b+" is not a function");return n(b)?function(){var e=a[b];return o(e)?d(e,c,a):e}:function(){return d(b,c,a)}}function h(a){var b=p(arguments,1);if(!m(a)&&!o(a))throw new TypeError("scope must be an object");if(1===b.length&&l(b[0])&&(b=b[0]),!b.length){b=[];for(var c in a)a.hasOwnProperty(c)&&o(a[c])&&b.push(c)}for(var d=0,f=b.length;f>d;d++)a[b[d]]=e(a,a[b[d]]);return a}function i(a,b){if(b=p(arguments,1),!n(a)&&!o(a))throw new Error(a+" must be the name of a property or function to execute");return n(a)?function(){var c=this[a];if(o(c)){var e=b.concat(p(arguments));return d(c,e,this)}return c}:function(){var c=b.concat(p(arguments));return d(a,c,this)}}function j(a,b){return function(){var c=p(arguments);return b?d(a,arguments,this):function(){return d(a,c.concat(p(arguments)),this)}}}function k(a,b,c){var d;if(d=c?e(c,b):b,a)for(var f=a-1,g=f;g>=0;g--)d=j(d,g===f);return d}var l=b.isArray,m=b.isObject,n=b.isString,o=b.isFunction,p=c.argsToArray;return a.define(m,{bind:e,bindAll:h,bindIgnore:g,curry:function(a,b,c){return k(b,c,a)}}).define(o,{bind:function(a,b){return d(e,[b,a].concat(p(arguments,2)),this)},bindIgnore:function(a,b){return d(g,[b,a].concat(p(arguments,2)),this)},partial:i,applyFirst:f,curry:function(a,b,c){return k(b,a,c)},noWrap:{f:function(){return this.value()}}}).define(n,{bind:function(a,b){return e(b,a)},bindIgnore:function(a,b){return g(b,a)},partial:i,applyFirst:f,curry:function(a,b,c){return k(b,a,c)}}).expose({bind:e,bindAll:h,bindIgnore:g,partial:i,applyFirst:f,curry:k})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.functionExtended=d(this.extended,this.isExtended,this.argumentsExtended)}).call(this)},{"arguments-extended":51,extended:56,"is-extended":66}],60:[function(a,b,c){function d(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;ce;e++)d[e].apply(this,c);return!0}return!1},f.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(g(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:h,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},f.prototype.on=f.prototype.addListener,f.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},f.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(g(c)){var e=d(c,b);if(0>e)return this;c.splice(e,1),0==c.length&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},f.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},f.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),g(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]},f.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?"function"==typeof a._events[b]?1:a._events[b].length:0}},{__browserify_process:64}],61:[function(){},{}],62:[function(a,b,c){function d(a,b){for(var c=[],d=0;d=0;d--){var e=a[d];"."==e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var f=a("__browserify_process"),g=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){for(var a="",b=!1,c=arguments.length;c>=-1&&!b;c--){var g=c>=0?arguments[c]:f.cwd();"string"==typeof g&&g&&(a=g+"/"+a,b="/"===g.charAt(0))}return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b="/"===a.charAt(0),c="/"===a.slice(-1);return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),a||b||(a="."),a&&c&&(a+="/"),(b?"/":"")+a},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(d(a,function(a){return a&&"string"==typeof a}).join("/"))},c.dirname=function(a){var b=g.exec(a)[1]||"",c=!1;return b?1===b.length||c&&b.length<=3&&":"===b.charAt(1)?b:b.substring(0,b.length-1):"."},c.basename=function(a,b){var c=g.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return g.exec(a)[3]||""},c.relative=function(a,b){function d(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;i=0;e--)if(f[e]!=g[e])return!1;for(e=f.length-1;e>=0;e--)if(d=f[e],!h(a[d],b[d]))return!1;return!0}function l(a,b){return a&&b?b instanceof RegExp?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function m(a,b,c,d){var e;"string"==typeof c&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f("Missing expected exception"+d),!a&&l(e,c)&&f("Got unwanted exception"+d),a&&e&&c&&!l(e,c)||!a&&e)throw e}var n=a("util"),o=a("buffer").Buffer,p=Array.prototype.slice,q=b.exports=g;q.AssertionError=function(a){this.name="AssertionError",this.message=a.message,this.actual=a.actual,this.expected=a.expected,this.operator=a.operator;var b=a.stackStartFunction||f;Error.captureStackTrace&&Error.captureStackTrace(this,b)},n.inherits(q.AssertionError,Error),q.AssertionError.prototype.toString=function(){return this.message?[this.name+":",this.message].join(" "):[this.name+":",e(JSON.stringify(this.actual,d),128),this.operator,e(JSON.stringify(this.expected,d),128)].join(" ")},q.AssertionError.__proto__=Error.prototype,q.fail=f,q.ok=g,q.equal=function(a,b,c){a!=b&&f(a,b,c,"==",q.equal)},q.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",q.notEqual)},q.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",q.deepEqual)},q.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",q.notDeepEqual)},q.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",q.strictEqual)},q.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",q.notStrictEqual)},q.throws=function(){m.apply(this,[!0].concat(p.call(arguments)))},q.doesNotThrow=function(){m.apply(this,[!1].concat(p.call(arguments)))},q.ifError=function(a){if(a)throw a}},{util:2,buffer:3}],2:[function(a,b,c){function d(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&d(a.__proto__)}function e(a){return a instanceof RegExp||"object"==typeof a&&"[object RegExp]"===Object.prototype.toString.call(a)}function f(a){if(a instanceof Date)return!0;if("object"!=typeof a)return!1;var b=Date.prototype&&h(Date.prototype),c=a.__proto__&&h(a.__proto__);return JSON.stringify(c)===JSON.stringify(b)}a("events");c.isArray=d,c.isDate=function(a){return"[object Date]"===Object.prototype.toString.call(a)},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)},c.print=function(){},c.puts=function(){},c.debug=function(){},c.inspect=function(a,b,i,j){function k(a,i){if(a&&"function"==typeof a.inspect&&a!==c&&(!a.constructor||a.constructor.prototype!==a))return a.inspect(i);switch(typeof a){case"undefined":return m("undefined","undefined");case"string":var j="'"+JSON.stringify(a).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return m(j,"string");case"number":return m(""+a,"number");case"boolean":return m(""+a,"boolean")}if(null===a)return m("null","null");var n=g(a),o=b?h(a):n;if("function"==typeof a&&0===o.length){if(e(a))return m(""+a,"regexp");var p=a.name?": "+a.name:"";return m("[Function"+p+"]","special")}if(f(a)&&0===o.length)return m(a.toUTCString(),"date");var q,r,s;if(d(a)?(r="Array",s=["[","]"]):(r="Object",s=["{","}"]),"function"==typeof a){var t=a.name?": "+a.name:"";q=e(a)?" "+a:" [Function"+t+"]"}else q="";if(f(a)&&(q=" "+a.toUTCString()),0===o.length)return s[0]+q+s[1];if(0>i)return e(a)?m(""+a,"regexp"):m("[Object]","special");l.push(a);var u=o.map(function(b){var c,e;if(a.__lookupGetter__&&(a.__lookupGetter__(b)?e=a.__lookupSetter__(b)?m("[Getter/Setter]","special"):m("[Getter]","special"):a.__lookupSetter__(b)&&(e=m("[Setter]","special"))),n.indexOf(b)<0&&(c="["+b+"]"),e||(l.indexOf(a[b])<0?(e=null===i?k(a[b]):k(a[b],i-1),e.indexOf("\n")>-1&&(e=d(a)?e.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+e.split("\n").map(function(a){return" "+a}).join("\n"))):e=m("[Circular]","special")),"undefined"==typeof c){if("Array"===r&&b.match(/^\d+$/))return e;c=JSON.stringify(""+b),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=m(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=m(c,"string"))}return c+": "+e});l.pop();var v=0,w=u.reduce(function(a,b){return v++,b.indexOf("\n")>=0&&v++,a+b.length+1},0);return u=w>50?s[0]+(""===q?"":q+"\n ")+" "+u.join(",\n ")+" "+s[1]:s[0]+q+" "+u.join(", ")+" "+s[1]}var l=[],m=function(a,b){var c={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[b];return d?"["+c[d][0]+"m"+a+"["+c[d][1]+"m":a};return j||(m=function(a){return a}),k(a,"undefined"==typeof i?2:i)};c.log=function(){},c.pump=null;var g=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},h=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.hasOwnProperty.call(a,c)&&b.push(c);return b},i=Object.create||function(a,b){var c;if(null===a)c={__proto__:null};else{if("object"!=typeof a)throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}return"undefined"!=typeof b&&Object.defineProperties&&Object.defineProperties(c,b),c};c.inherits=function(a,b){a.super_=b,a.prototype=i(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})};var j=/%[sdj%]/g;c.format=function(a){if("string"!=typeof a){for(var b=[],d=0;d=f)return a;switch(a){case"%s":return String(e[d++]);case"%d":return Number(e[d++]);case"%j":return JSON.stringify(e[d++]);default:return a}}),h=e[d];f>d;h=e[++d])g+=null===h||"object"!=typeof h?" "+h:" "+c.inspect(h);return g}},{events:4}],5:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],6:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],4:[function(a,b,c){!function(a){function b(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;cf;f++)d[f].apply(this,c);return!0}return!1},d.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(e(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:f,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},d.prototype.removeListener=function(a,c){if("function"!=typeof c)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var d=this._events[a];if(e(d)){var f=b(d,c);if(0>f)return this;d.splice(f,1),0==d.length&&delete this._events[a]}else this._events[a]===c&&delete this._events[a];return this},d.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},d.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),e(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}(a("__browserify_process"))},{__browserify_process:6}],"buffer-browserify":[function(a,b){b.exports=a("q9TxCC")},{}],q9TxCC:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used=a.length?0:(c?(e=a.parent[a.offset+b]<<8,b+1=a.length?0:(c?(b+1>>0):(b+2>>0)),e)}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8*(d?1-f:f)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>8*(d?3-f:f)&255}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fthis.length)throw new Error("oob");if(b>c)throw new Error("oob");for(var d=b;c>d;d++)this[d]=a},c.SlowBuffer=d,c.Buffer=l,l.poolSize=8192;var E;l.isBuffer=function(a){return a instanceof l||a instanceof d},l.concat=function(a,b){if(!Array.isArray(a))throw new Error("Usage: Buffer.concat(list, [totalLength])\n list should be an Array.");if(0===a.length)return new l(0);if(1===a.length)return a[0];if("number"!=typeof b){b=0;for(var c=0;cd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=c.length?void 0:c.parent[c.offset+a]},l.prototype.readUInt16LE=function(a,b){return o(this,a,!1,b)},l.prototype.readUInt16BE=function(a,b){return o(this,a,!0,b)},l.prototype.readUInt32LE=function(a,b){return p(this,a,!1,b)},l.prototype.readUInt32BE=function(a,b){return p(this,a,!0,b)},l.prototype.readInt8=function(a,b){var c,d=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=d.length?void 0:(c=128&d.parent[d.offset+a],c?-1*(255-d.parent[d.offset+a]+1):d.parent[d.offset+a])},l.prototype.readInt16LE=function(a,b){return q(this,a,!1,b)},l.prototype.readInt16BE=function(a,b){return q(this,a,!0,b)},l.prototype.readInt32LE=function(a,b){return r(this,a,!1,b)},l.prototype.readInt32BE=function(a,b){return r(this,a,!0,b)},l.prototype.readFloatLE=function(a,b){return s(this,a,!1,b)},l.prototype.readFloatBE=function(a,b){return s(this,a,!0,b)},l.prototype.readDoubleLE=function(a,b){return t(this,a,!1,b)},l.prototype.readDoubleBE=function(a,b){return t(this,a,!0,b)},l.prototype.writeUInt8=function(a,b,c){var d=this;c||(D.ok(void 0!==a&&null!==a,"missing value"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":5,"base64-js":7}],7:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(f>>8&255),h.push(255&f)),h}function c(a){function b(a){return d[a>>18&63]+d[a>>12&63]+d[a>>6&63]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[e<<4&63],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[e>>4&63],h+=d[e<<2&63],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}],8:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],3:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used>>0):(e=a.parent[a.offset+b+2]<<16,e|=a.parent[a.offset+b+1]<<8,e|=a.parent[a.offset+b],e+=a.parent[a.offset+b+3]<<24>>>0),e}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8,a.parent[a.offset+c+1]=255&b):(a.parent[a.offset+c+1]=(65280&b)>>>8,a.parent[a.offset+c]=255&b)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>24&255,a.parent[a.offset+c+1]=b>>>16&255,a.parent[a.offset+c+2]=b>>>8&255,a.parent[a.offset+c+3]=255&b):(a.parent[a.offset+c+3]=b>>>24&255,a.parent[a.offset+c+2]=b>>>16&255,a.parent[a.offset+c+1]=b>>>8&255,a.parent[a.offset+c]=255&b)}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":8,"base64-js":9}],9:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(f>>8&255),h.push(255&f)),h}function c(a){function b(a){return d[a>>18&63]+d[a>>12&63]+d[a>>6&63]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[e<<4&63],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[e>>4&63],h+=d[e<<2&63],h+="=" +}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}]},{},[]),b.exports=a("buffer-browserify")},{}],64:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],65:[function(a,b,c){(function(){"use strict";function d(a){var b=function(a){return"string"==typeof a?a:"object"==typeof a?a.hashCode?a.hashCode():""+a:""+a},c=a.declare({instance:{constructor:function(){this.__entries=[],this.__keys=[],this.__values=[]},pushValue:function(a,b){return this.__keys.push(a),this.__values.push(b),this.__entries.push({key:a,value:b}),b},remove:function(a){for(var b,c=null,d=this.__entries,e=this.__keys,f=this.__values,g=d.length-1;g>=0;g--)if((b=d[g])&&b.key===a)return d.splice(g,1),e.splice(g,1),f.splice(g,1),b.value;return c},set:function(a,b){for(var c=null,d=this.__entries,e=this.__values,f=d.length-1;f>=0;f--){var g=d[f];if(g&&a===g.key){e[f]=b,g.value=b,c=b;break}}return c||d.push({key:a,value:b}),c},find:function(a){for(var b,c=null,d=this.__entries,e=d.length-1;e>=0;e--)if(b=d[e],b&&a===b.key){c=b.value;break}return c},getEntrySet:function(){return this.__entries},getKeys:function(){return this.__keys},getValues:function(){return this.__values}}});return a.declare({instance:{constructor:function(){this.__map={}},entrySet:function(){var a=[],b=this.__map;for(var c in b)b.hasOwnProperty(c)&&(a=a.concat(b[c].getEntrySet()));return a},put:function(a,d){var e=b(a),f=null;return(f=this.__map[e])||(f=this.__map[e]=new c),f.pushValue(a,d),d},remove:function(a){var c=b(a),d=null,e=this.__map[c];return e&&(d=e.remove(a)),d},get:function(a){var c,d=b(a),e=null;return(c=this.__map[d])&&(e=c.find(a)),e},set:function(a,d){var e=b(a),f=null,g=null,h=this.__map;return f=(g=h[e])?g.set(a,d):(h[e]=new c).pushValue(a,d)},contains:function(a){var c=b(a),d=!1,e=null;return(e=this.__map[c])&&(d=!!e.find(a)),d},concat:function(a){if(a instanceof this._static){for(var b=new this._static,c=a.entrySet().concat(this.entrySet()),d=c.length-1;d>=0;d--){var e=c[d];b.put(e.key,e.value)}return b}throw new TypeError("When joining hashtables the joining arg must be a HashTable")},filter:function(b,c){var d=this.entrySet(),e=new this._static;d=a.filter(d,b,c);for(var f=d.length-1;f>=0;f--){var g=d[f];e.put(g.key,g.value)}return e},forEach:function(b,c){var d=this.entrySet();a.forEach(d,b,c)},every:function(b,c){var d=this.entrySet();return a.every(d,b,c)},map:function(b,c){var d=this.entrySet();return a.map(d,b,c)},some:function(b,c){var d=this.entrySet();return a.some(d,b,c)},reduce:function(b,c){var d=this.entrySet();return a.reduce(d,b,c)},reduceRight:function(b,c){var d=this.entrySet();return a.reduceRight(d,b,c)},clear:function(){this.__map={}},keys:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getKeys());return a},values:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getValues());return a},isEmpty:function(){return 0===this.keys().length}}})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")))):"function"==typeof define?define(["extended","declare","is-extended","array-extended"],function(a,b,c,e){return d(a().register("declare",b).register(c).register(e))}):this.Ht=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended))}).call(this)},{"array-extended":52,"declare.js":55,extended:56,"is-extended":66}],66:[function(a,b,c){var d=a("__browserify_Buffer").Buffer;(function(){"use strict";function e(a){function b(a,b){var c=-1,d=0,e=a.length,f=[];for(b=b||0,c+=b;++c=0;f--)if(g[f]!==h[f])return!1;for(f=g.length-1;f>=0;f--)if(d=g[f],!e(a[d],b[d]))return!1}catch(i){return!1}return!0}function g(a){return null!==a&&"object"==typeof a}function h(a){var b=g(a);return b&&a.constructor===Object&&!a.nodeType&&!a.setInterval}function i(a){return W(a)?0===a.length:g(a)?0===c(a).length:r(a)||X(a)?0===a.length:!0}function j(a){return a===!0||a===!1||"[object Boolean]"===U.call(a)}function k(a){return"undefined"==typeof a}function l(a){return!k(a)}function m(a){return k(a)||n(a)}function n(a){return null===a}function o(a,b){return V(b)?a instanceof b:!1}function p(a){return"[object RegExp]"===U.call(a)}function q(a){return"[object Date]"===U.call(a)}function r(a){return"[object String]"===U.call(a)}function s(a){return"[object Number]"===U.call(a)}function t(a){return a===!0}function u(a){return a===!1}function v(a){return!n(a)}function w(a,b){return a==b}function x(a,b){return a!=b}function y(a,b){return a===b}function z(a,b){return a!==b}function A(a,b){if(X(b)&&Array.prototype.indexOf||r(b))return b.indexOf(a)>-1;if(X(b))for(var c=0,d=b.length;d>c;c++)if(w(a,b[c]))return!0;return!1}function B(a,b){return!A(a,b)}function C(a,b){return b>a}function D(a,b){return b>=a}function E(a,b){return a>b}function F(a,b){return a>=b}function G(a,b){return r(b)?null!==(""+a).match(b):p(b)?b.test(a):!1}function H(a,b){return!G(a,b)}function I(a,b){return A(b,a)}function J(a,b){return!A(b,a)}function K(a,b,c){return X(a)&&a.length>c?w(a[c],b):!1}function L(a,b,c){return X(a)?!w(a[c],b):!1}function M(a,b){return T.call(a,b)}function N(a,b){return!M(a,b)}function O(a,b){return M(a,"length")?a.length===b:!1}function P(a,b){return M(a,"length")?a.length!==b:!1}function Q(a){Z[a]=function(){this._testers.push(Y[a])}}function R(a){$[a]=function(){var c,d=b(arguments,1),e=Y[a],f=!0;if(d.length<=e.length-1)throw new TypeError("A handler must be defined when calling using switch");if(c=d.pop(),j(c)&&(f=c,c=d.pop()),!V(c))throw new TypeError("handler must be defined");this._cases.push(function(a){return e.apply(Y,a.concat(d))?[f,c.apply(this,a)]:[!1]})}}var S=Array.prototype.slice,T=Object.prototype.hasOwnProperty,U=Object.prototype.toString,V=function(a){return"[object Function]"===U.call(a)};"undefined"==typeof window||V(window.alert)||!function(a){V=function(b){return"[object Function]"===U.call(b)||b===a}}(window.alert);var W=function(a){return"[object Arguments]"===U.call(a)};W(arguments)||(W=function(a){return!(!a||!T.call(a,"callee"))});var X=Array.isArray||function(a){return"[object Array]"===U.call(a)},Y={isFunction:V,isObject:g,isEmpty:i,isHash:h,isNumber:s,isString:r,isDate:q,isArray:X,isBoolean:j,isUndefined:k,isDefined:l,isUndefinedOrNull:m,isNull:n,isArguments:W,instanceOf:o,isRegExp:p,deepEqual:e,isTrue:t,isFalse:u,isNotNull:v,isEq:w,isNeq:x,isSeq:y,isSneq:z,isIn:A,isNotIn:B,isLt:C,isLte:D,isGt:E,isGte:F,isLike:G,isNotLike:H,contains:I,notContains:J,has:M,notHas:N,isLength:O,isNotLength:P,containsAt:K,notContainsAt:L},Z={constructor:function(){this._testers=[]},noWrap:{tester:function(){var a=this._testers;return function(b){for(var c=!1,d=0,e=a.length;e>d&&!c;d++)c=a[d](b);return c}}}},$={constructor:function(){this._cases=[],this.__default=null},def:function(a,b){this.__default=b},noWrap:{switcher:function(){var a=this._cases,c=this.__default;return function(){for(var d,e=!1,f=b(arguments),g=0,h=a.length;h>g&&!e;g++)if(d=a[g](f),d.length>1&&(d[1]||d[0]))return d[1];return!e&&c?c.apply(this,f):void 0}}}};for(var _ in Y)T.call(Y,_)&&(R(_),Q(_));var ab=a.define(Y).expose(Y);return ab.tester=a.define(Z),ab.switcher=a.define($),ab}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("extended"))):"function"==typeof define&&define.amd?define(["extended"],function(a){return e(a)}):this.isExtended=e(this.extended)}).call(this)},{__browserify_Buffer:63,extended:56}],67:[function(a,b,c){(function(){"use strict";function d(a){function b(a,b){var c=0;return a>b?1:b>a?-1:b?c:1}var c=a.multiply,d=a.declare({instance:{__printNode:function(b,d){var e=[];a.isUndefinedOrNull(b)?(e.push(c(" ",d)),e.push("~"),console.log(e.join(""))):(this.__printNode(b.right,d+1),e.push(c(" ",d)),e.push(b.data+"\n"),console.log(e.join("")),this.__printNode(b.left,d+1))},constructor:function(a){a=a||{},this.compare=a.compare||b,this.__root=null},insert:function(){throw new Error("Not Implemented")},remove:function(){throw new Error("Not Implemented")},clear:function(){this.__root=null},isEmpty:function(){return!this.__root},traverseWithCondition:function(a,b,c){var e=!0;return a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.IN_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.POST_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e&&(e=this.traverseWithCondition(a.right,b,c)),e&&(e=c(a.data)))):b===d.REVERSE_ORDER&&(e=this.traverseWithCondition(a.right,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c))))),e},traverse:function(a,b,c){a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(c(a.data),this.traverse(a.left,b,c),this.traverse(a.right,b,c)):b===d.IN_ORDER?(this.traverse(a.left,b,c),c(a.data),this.traverse(a.right,b,c)):b===d.POST_ORDER?(this.traverse(a.left,b,c),this.traverse(a.right,b,c),c(a.data)):b===d.REVERSE_ORDER&&(this.traverse(a.right,b,c),c(a.data),this.traverse(a.left,b,c)))},forEach:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this,this.traverse(this.__root,c,function(c){a.call(b,c,this)})},map:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){e.insert(a.call(b,c,this))}),e},filter:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){a.call(b,c,this)&&e.insert(c)}),e},reduce:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduce.apply(a,f)},reduceRight:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduceRight.apply(a,f)},every:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=!1;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this)}),e},some:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this),!e}),e},toArray:function(a){a=a||d.IN_ORDER;var b=[];return this.traverse(this.__root,a,function(a){b.push(a)}),b},contains:function(a){for(var b=!1,c=this.__root;null!==c;){var d=this.compare(a,c.data);d?c=c[-1===d?"left":"right"]:(b=!0,c=null)}return b},find:function(a){for(var b,c=this.__root;c;){var d=this.compare(a,c.data);if(!d){b=c.data;break}c=c[-1===d?"left":"right"]}return b},findLessThan:function(a,b){var c=[],e=this.compare;return this.traverseWithCondition(this.__root,d.IN_ORDER,function(d){var f=e(a,d);return!b&&0===f||1===f?(c.push(d),!0):!1}),c},findGreaterThan:function(a,b){var c=[],e=this.compare;return this.traverse(this.__root,d.REVERSE_ORDER,function(d){var f=e(a,d);return!b&&0===f||-1===f?(c.push(d),!0):!1}),c},print:function(){this.__printNode(this.__root,0)}},"static":{PRE_ORDER:"pre_order",IN_ORDER:"in_order",POST_ORDER:"post_order",REVERSE_ORDER:"reverse_order"}}),e=function(){function a(a,b,c){var d=a.__root;if(null===d||void 0===d)a.__root=f(b);else{for(var g,h=d,i=[],k=[],l=0;;){if(g=i[l]=-1===c(b,h.data)?"left":"right",k[l++]=h,!h[g]){h[g]=f(b);break}h=h[g]}if(!h[g])return null;for(;--l>=0&&(k[l].balance+="right"===i[l]?-1:1,0!==k[l].balance);)if(e(k[l].balance)>1){k[l]=j(k[l],i[l]),0!==l?k[l-1][i[l-1]]=k[l]:a.__root=k[0];break}}}function b(a,b,c){var d=a.__root;if(null!==d&&void 0!==d){for(var f,g,h=d,i=0,j=[],l=[],m={done:!1};;){if(!h)return;if(0===(g=c(b,h.data)))break;f=l[i]=-1===g?"left":"right",j[i++]=h,h=h[f]}var n=h.left,o=h.right;if(n&&o){var p=n;for(l[i]="left",j[i++]=h;p.right;)l[i]="right",j[i++]=p,p=p.right;h.data=p.data,j[i-1][j[i-1]===h?"left":"right"]=p.left}else f=n?"left":"right",0!==i?j[i-1][l[i-1]]=h[f]:a.__root=h[f];for(;--i>=0&&!m.done&&(j[i].balance+="left"===l[i]?-1:1,1!==e(j[i].balance));)e(j[i].balance)>1&&(j[i]=k(j[i],l[i],m),0!==i?j[i-1][l[i-1]]=j[i]:a.__root=j[0])}}var e=Math.abs,f=function(a){return{data:a,balance:0,left:null,right:null}},g=function(a,b,c){var d=a[c];return a[c]=d[b],d[b]=a,d},h=function(a,b,c){return a[c]=g(a[c],c,b),g(a,b,c)},i=function(a,b,c){var d="left"===b?"right":"left",e=a[b],f=e[d];0===f.balance?a.balance=e.balance=0:f.balance===c?(a.balance=-c,e.balance=0):(a.balance=0,e.balance=c),f.balance=0},j=function(a,b){var c="left"===b?"right":"left",d=a[b],e="right"===b?-1:1;return d.balance===e?(a.balance=d.balance=0,a=g(a,c,b)):(i(a,b,e),a=h(a,c,b)),a},k=function(a,b,c){var d="left"===b?"right":"left",e=a[d],f="right"===b?-1:1;return e.balance===-f?(a.balance=e.balance=0,a=g(a,b,d)):e.balance===f?(i(a,d,-f),a=h(a,b,d)):(a.balance=-f,e.balance=f,a=g(a,b,d),c.done=!0),a};return d.extend({instance:{insert:function(b){a(this,b,this.compare)},remove:function(a){b(this,a,this.compare)},__printNode:function(a,b){var d=[];a?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.balance+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),f=function(){function a(a,b){return{data:a,level:b,left:g,right:g}}function b(a){if(0!==a.level&&a.left.level===a.level){var b=a.left;a.left=b.right,b.right=a,a=b}return a}function e(a){if(0!==a.level&&a.right.right.level===a.level){var b=a.right;a.right=b.left,b.left=a,a=b,a.level++}return a}function f(c,d,h){if(c===g)c=a(d,1);else{var i=-1===h(d,c.data)?"left":"right";c[i]=f(c[i],d,h),c=b(c),c=e(c)}return c}var g={level:0,data:null},h=function(a,c,d){var f,i;if(a!==g){var j=d(c,a.data);if(0===j)if(f=a.left,i=a.right,f!==g&&i!==g){for(var k=f;k.right!==g;)k=k.right;a.data=k.data,a.left=h(f,k.data,d)}else a=a[f===g?"right":"left"];else{var l=-1===j?"left":"right";a[l]=h(a[l],c,d)}}if(a!==g){var m=a.level,n=a.left.level,o=a.right.level;(m-1>n||m-1>o)&&(o>--a.level&&(a.right.level=a.level),a=b(a),a=e(a))}return a};return d.extend({instance:{isEmpty:function(){return this.__root===g||this._super(arguments)},insert:function(a){this.__root||(this.__root=g),this.__root=f(this.__root,a,this.compare)},remove:function(a){this.__root=h(this.__root,a,this.compare)},traverseWithCondition:function(a){var b=!0;return a!==g?this._super(arguments):b},traverse:function(a){a!==g&&this._super(arguments)},contains:function(){return this.__root!==g?this._super(arguments):!1},__printNode:function(a,b){var d=[];a&&a.data?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.level+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),g=d.extend({instance:{insert:function(a){if(!this.__root)return this.__root={data:a,parent:null,left:null,right:null},this.__root;for(var b=this.compare,c=this.__root;null!==c;){var d=b(a,c.data);if(!d)return;var e=-1===d?"left":"right",f=c[e];if(!f)return c[e]={data:a,parent:c,left:null,right:null};c=f}},remove:function(a){if(null!==this.__root){for(var b,c={right:this.__root},d=c,e=null,f="right";null!==d[f];){b=d,d=d[f];var g=this.compare(a,d.data);g||(e=d),f=-1===g?"left":"right"}null!==e&&(e.data=d.data,b[b.right===d?"right":"left"]=d[null===d.left?"right":"left"]),this.__root=c.right}}}}),h=function(){var a="RED",b="BLACK",e=function(a){return null!==a&&a.red},f=function(a){return{data:a,red:!0,left:null,right:null}},g=function(a,b,c){if(!a)return f(b);var d=c(b,a.data);if(d){var j=-1===d?"left":"right",k="left"===j?"right":"left";a[j]=g(a[j],b,c);var l=a[j];if(e(l)){var m=a[k];e(m)?(a.red=!0,l.red=!1,m.red=!1):e(l[j])?a=h(a,k):e(l[k])&&(a=i(a,k))}}return a},h=function(a,b){var c="left"===b?"right":"left",d=a[c];return a[c]=d[b],d[b]=a,a.red=!0,d.red=!1,d},i=function(a,b){var c="left"===b?"right":"left";return a[c]=h(a[c],c),h(a,b)},j=function(a,b,c,d){if(a){var f;if(0===d(b,a.data)){if(!a.left||!a.right){var g=a[a.left?"left":"right"];return e(a)?c.done=!0:e(g)&&(g.red=!1,c.done=!0),g}for(var h,i=a.right;null!==i.left;)h=i,i=i.left;h&&(h.left=null),a.data=i.data,b=i.data}f=-1===d(b,a.data)?"left":"right",a[f]=j(a[f],b,c,d),c.done||(a=k(a,f,c))}else c.done=!0;return a},k=function(a,b,c){var d="left"===b?"right":"left",f=a,g=f[d];if(e(g)&&(a=h(a,b),g=f[d]),null!==g)if(e(g.left)||e(g.right)){var j=f.red,k=a===f;f=(e(g[d])?h:i)(f,b),f.red=j,f.left.red=f.right.red=0,k?a=f:a[b]=f,c.done=!0}else e(f)&&(c.done=!0),f.red=0,g.red=1;return a};return d.extend({instance:{insert:function(a){this.__root=g(this.__root,a,this.compare),this.__root.red=!1},remove:function(a){var b={done:!1},c=j(this.__root,a,b,this.compare);return null!==c&&(c.red=0),this.__root=c,a},__printNode:function(d,e){var f=[];d?(this.__printNode(d.right,e+1),f.push(c(" ",e)),f.push((d.red?a:b)+":"+d.data+"\n"),console.log(f.join("")),this.__printNode(d.left,e+1)):(f.push(c(" ",e)),f.push("~"),console.log(f.join("")))}}})}();return{Tree:d,AVLTree:e,AnderssonTree:f,BinaryTree:g,RedBlackTree:h,IN_ORDER:d.IN_ORDER,PRE_ORDER:d.PRE_ORDER,POST_ORDER:d.POST_ORDER,REVERSE_ORDER:d.REVERSE_ORDER}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")).register(a("string-extended")))):"function"==typeof define?define(["extended","declare.js","is-extended","array-extended","string-extended"],function(a,b,c,e,f){return d(a().register("declare",b).register(c).register(e).register(f))}):this.leafy=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended).register(this.stringExtended))}).call(this)},{"array-extended":52,"declare.js":55,extended:56,"is-extended":66,"string-extended":70}],68:[function(a,b,c){(function(){"use strict";function d(a,b,c){function d(a,b){var c,d;for(c in b)t.call(b,c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}function e(a,b){var c,d,f;for(c in b)t.call(b,c)&&(d=b[c],f=a[c],p(f,d)||(a[c]=r(f)&&r(d)?e(f,d):r(d)?e({},d):d));return a}function f(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)d(a,arguments[b]);return a}function g(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)e(a,arguments[b]);return a}function h(a,b){var c=a.prototype||a;return f(c,b),a}function i(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e=l(a),f=0,g=e.length;g>f;++f)d=e[f],b.call(c||a,a[d],d,a);return a}function j(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e,f=l(a),g={},h=0,i=f.length;i>h;++h)d=f[h],e=a[d],b.call(c||a,e,d,a)&&(g[d]=e);return g}function k(a){if(!r(a))throw new TypeError;for(var b=l(a),c=[],d=0,e=b.length;e>d;++d)c.push(a[b[d]]);return c}function l(a){var b;if(v)b=v(a);else{if(!r(a))throw new TypeError;b=[];for(var c in a)t.call(a,c)&&b.push(c)}return b}function m(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d={},e=0,f=c.length;f>e;++e)b=c[e],d[a[b]]=b;return d}function n(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d=[],e=0,f=c.length;f>e;++e)b=c[e],d.push([b,a[b]]);return d}function o(a,b){if(!r(a))throw new TypeError;q(b)&&(b=[b]);for(var c,d=s(l(a),b),e={},f=0,g=d.length;g>f;++f)c=d[f],e[c]=a[c];return e}var p=b.deepEqual,q=b.isString,r=b.isHash,s=c.difference,t=Object.prototype.hasOwnProperty,u=b.isFunction,v=Object.keys,w={forEach:i,filter:j,invert:m,values:k,toArray:n,keys:l,omit:o},x={extend:h,merge:f,deepMerge:g,omit:o},y=a.define(b.isObject,x).define(r,w).define(b.isFunction,{extend:h}).expose({hash:w}).expose(x),z=y.extend;return y.extend=function(){return 1===arguments.length?z.extend.apply(y,arguments):(h.apply(null,arguments),void 0)},y}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c)}):this.objectExtended=d(this.extended,this.isExtended,this.arrayExtended)}).call(this)},{"array-extended":52,extended:56,"is-extended":66}],69:[function(a,b,c){var d=a("__browserify_process");(function(){"use strict";function e(a,b,c,e,f,g){function h(a,b){return function(){try{l(a.apply(null,arguments)).addCallback(b).addErrback(b)}catch(c){b.errback(c)}}}function i(a,b,c){var d=(new G).callback();return v(a,function(a){d=d.then(c?a:B(null,a)),c||(d=d.then(function(a){return b.push(a),b}))}),d}function j(a){return!w(a)&&y(a.then)}function k(a){var b=new G;return a.then(A(b,"callback"),A(b,"errback")),b.promise()}function l(a){var b;return a=C(arguments),a.length?1===a.length?(a=a.pop(),j(a)?a.addCallback&&a.addErrback?(b=new G,a.addCallback(b.callback),a.addErrback(b.errback)):b=k(a):b=x(a)&&c.every(a,j)?new H(a,!0).promise():(new G).callback(a)):b=new H(c.map(a,function(a){return l(a)}),!0).promise():b=(new G).callback(a).promise(),b}function m(a,b){return function(){var c=new G,d=C(arguments);return d.push(c.resolve),a.apply(b||this,d),c.promise()}}function n(a){if(x(a))return i(a,[],!1);throw new Error("When calling promise.serial the first argument must be an array")}function o(a){if(x(a))return i(a,[],!0);throw new Error("When calling promise.serial the first argument must be an array")}function p(a,b){a=C(arguments);var c=!1;b=a.pop();var d=l(a);return function(){return c?l(b.apply(this,arguments)):(a=arguments,d.then(A(this,function(){return c=!0,b.apply(this,a)})))}}function q(){return new G}function r(a){return new H(a,!0).promise()}function s(a){return q().errback(a)}function t(a){return q().callback(a)}var u,v=c.forEach,w=e.isUndefinedOrNull,x=e.isArray,y=e.isFunction,z=e.isBoolean,A=f.bind,B=f.bindIgnore,C=g.argsToArray;if("function"==typeof setImmediate)u="undefined"!=typeof window?setImmediate.bind(window):setImmediate;else if("undefined"!=typeof d)u=function(a){d.nextTick(a)};else if("undefined"!=typeof MessageChannel){var D=new MessageChannel,E={},F=E;D.port1.onmessage=function(){E=E.next;var a=E.task;delete E.task,a()},u=function(a){F=F.next={task:a},D.port2.postMessage(0)}}else u=function(a){setTimeout(a,0)};var G=a({instance:{__fired:!1,__results:null,__error:null,__errorCbs:null,__cbs:null,constructor:function(){this.__errorCbs=[],this.__cbs=[],f.bindAll(this,["callback","errback","resolve","classic","__resolve","addCallback","addErrback"])},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__error?this.__errorCbs:this.__cbs,c=b.length,d=this.__error||this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(this,b)})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=a.callback),this.__fired&&this.__results?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=a.errback),this.__fired&&this.__error?this.__callNextTick(a,this.__error):this.__errorCbs.push(a)),this},callback:function(){return this.__fired||(this.__results=arguments,this.__resolve()),this.promise()},errback:function(){return this.__fired||(this.__error=arguments,this.__resolve()),this.promise()},resolve:function(a){return a?this.errback(a):this.callback.apply(this,C(arguments,1)),this},classic:function(a){return"function"==typeof a&&(this.addErrback(function(b){a(b)}),this.addCallback(function(){a.apply(this,[null].concat(C(arguments)))})),this},then:function(a,b){var c=new G,d=c;return y(b)&&(d=h(b,c)),this.addErrback(d),y(a)?this.addCallback(h(a,c)):this.addCallback(c),c.promise()},both:function(a){return this.then(a,a)},promise:function(){var a={then:A(this,"then"),both:A(this,"both"),promise:function(){return a}};return v(["addCallback","addErrback","classic"],function(b){a[b]=A(this,function(){return this[b].apply(this,arguments),a})},this),a}}}),H=G.extend({instance:{__results:null,__errors:null,__promiseLength:0,__defLength:0,__firedLength:0,normalizeResults:!1,constructor:function(a,b){this.__errors=[],this.__results=[],this.normalizeResults=z(b)?b:!1,this._super(arguments),a&&a.length?(this.__defLength=a.length,v(a,this.__addPromise,this)):this.__resolve()},__addPromise:function(a,b){a.then(A(this,function(){var a=C(arguments);a.unshift(b),this.callback.apply(this,a)}),A(this,function(){var a=C(arguments);a.unshift(b),this.errback.apply(this,a)}))},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__errors.length?this.__errorCbs:this.__cbs,c=b.length,d=this.__errors.length?this.__errors:this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(null,[b])})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=A(a,"callback")),this.__fired&&!this.__errors.length?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=A(a,"errback")),this.__fired&&this.__errors.length?this.__callNextTick(a,this.__errors):this.__errorCbs.push(a)),this},callback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__results[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()},errback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__errors[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()}}});return b.define({isPromiseLike:j}).expose({isPromiseLike:j,when:l,wrap:m,wait:p,serial:n,chain:o,Promise:G,PromiseList:H,promise:q,defer:q,deferredList:r,reject:s,resolve:t})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("declare.js"),a("extended"),a("array-extended"),a("is-extended"),a("function-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["declare","extended","array-extended","is-extended","function-extended","arguments-extended"],function(a,b,c,d,f,g){return e(a,b,c,d,f,g)}):this.promiseExtended=e(this.declare,this.extended,this.arrayExtended,this.isExtended,this.functionExtended,this.argumentsExtended)}).call(this)},{__browserify_process:64,"arguments-extended":51,"array-extended":52,"declare.js":55,extended:56,"function-extended":59,"is-extended":66}],70:[function(a,b,c){(function(){"use strict";function d(a,b,c,d){function e(a,b){var c=a;if(x.test(b)){var d=b.match(x),e=d[1],f=d[3],g=d[4];g&&(g=parseInt(g,10),c=c.length0?"+":"")+d),k&&(k=parseInt(k,10),d=d.lengthe;)d?a+=c:a=c+a,e++;return a}function i(a,c,d){var e=a;if(b.isString(e)){if(a.length>c)if(d){var f=a.length;e=a.substring(f-c,f)}else e=a.substring(0,c)}else e=i(""+e,c);return e}function j(a,d){if(d instanceof Array){var h=0,i=d.length;return a.replace(v,function(a,b,j){var k,l;if(!(i>h))return a;if(k=d[h++],"%s"===a||"%d"===a||"%D"===a)l=k+"";else if("%Z"===a)l=k.toUTCString();else if("%j"===a)try{l=s(k)}catch(m){throw new Error("stringExtended.format : Unable to parse json from ",k)}else switch(b=b.replace(/^\[|\]$/g,""),j){case"s":l=e(k,b);break;case"d":l=f(k,b);break;case"j":l=g(k,b);break;case"D":l=c.format(k,b);break;case"Z":l=c.format(k,b,!0)}return l})}if(t(d))return a.replace(w,function(a,h,i){if(i=d[i],!b.isUndefined(i)){if(!h)return""+i;if(b.isString(i))return e(i,h);if(b.isNumber(i))return f(i,h);if(b.isDate(i))return c.format(i,h);if(b.isObject(i))return g(i,h)}return a});var k=u.call(arguments).slice(1);return j(a,k)}function k(a,b){var c=[];return a&&(a.indexOf(b)>0?c=a.replace(/\s+/g,"").split(b):c.push(a)),c}function l(a,b){var c=[];if(b)for(var d=0;b>d;d++)c.push(a);return c.join("")}function m(a,c){var d,e,f;if(c)if(b.isArray(a))for(d=[],e=0,f=a.length;f>e;e++)d.push(m(a[e],c));else if(c instanceof Array)for(d=a,e=0,f=c.length;f>e;e++)d=m(d,c[e]);else c in z&&(d="["+z[c]+"m"+a+"");return d}function n(a,b){return a.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,function(a){return b&&-1!==d.indexOf(b,a)?a:"\\"+a})}function o(a){return a.replace(/^\s*|\s*$/g,"")}function p(a){return a.replace(/^\s*/,"")}function q(a){return a.replace(/\s*$/,"")}function r(a){return 0===a.length}var s;"undefined"==typeof JSON?!function(){function a(a){return 10>a?"0"+a:a}function c(c){return b.isDate(c)?isFinite(c.valueOf())?c.getUTCFullYear()+"-"+a(c.getUTCMonth()+1)+"-"+a(c.getUTCDate())+"T"+a(c.getUTCHours())+":"+a(c.getUTCMinutes())+":"+a(c.getUTCSeconds())+"Z":null:i(c)?c.valueOf():c}function d(a){return j.lastIndex=0,j.test(a)?'"'+a.replace(j,function(a){var b=k[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function e(a,b){var i,j,k,l,m,n=f,o=b[a];switch(o&&(o=c(o)),"function"==typeof h&&(o=h.call(b,a,o)),typeof o){case"string":return d(o);case"number":return isFinite(o)?String(o):"null";case"boolean":case"null":return String(o);case"object":if(!o)return"null";if(f+=g,m=[],"[object Array]"===Object.prototype.toString.apply(o)){for(l=o.length,i=0;l>i;i+=1)m[i]=e(i,o)||"null";return k=0===m.length?"[]":f?"[\n"+f+m.join(",\n"+f)+"\n"+n+"]":"["+m.join(",")+"]",f=n,k}if(h&&"object"==typeof h)for(l=h.length,i=0;l>i;i+=1)"string"==typeof h[i]&&(j=h[i],k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));else for(j in o)Object.prototype.hasOwnProperty.call(o,j)&&(k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));return k=0===m.length?"{}":f?"{\n"+f+m.join(",\n"+f)+"\n"+n+"}":"{"+m.join(",")+"}",f=n,k}}var f,g,h,i=b.tester().isString().isNumber().isBoolean().tester(),j=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,k={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};s=function(a,b,c){var d;if(f="",g="","number"==typeof c)for(d=0;c>d;d+=1)g+=" ";else"string"==typeof c&&(g=c);if(h=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return e("",{"":a})}}():s=JSON.stringify;var t=b.isHash,u=Array.prototype.slice,v=/%((?:-?\+?.?\d*)?|(?:\[[^\[|\]]*\]))?([sjdDZ])/g,w=/\{(?:\[([^\[|\]]*)\])?(\w+)\}/g,x=/(-?)(\+?)([A-Z|a-z|\W]?)([1-9][0-9]*)?$/,y=/([1-9][0-9]*)$/g,z={bold:1,bright:1,italic:3,underline:4,blink:5,inverse:7,crossedOut:9,red:31,green:32,yellow:33,blue:34,magenta:35,cyan:36,white:37,redBackground:41,greenBackground:42,yellowBackground:43,blueBackground:44,magentaBackground:45,cyanBackground:46,whiteBackground:47,encircled:52,overlined:53,grey:90,black:90},A={SMILEY:"☺",SOLID_SMILEY:"☻",HEART:"♥",DIAMOND:"♦",CLOVE:"♣",SPADE:"♠",DOT:"•",SQUARE_CIRCLE:"◘",CIRCLE:"○",FILLED_SQUARE_CIRCLE:"◙",MALE:"♂",FEMALE:"♀",EIGHT_NOTE:"♪",DOUBLE_EIGHTH_NOTE:"♫",SUN:"☼",PLAY:"►",REWIND:"◄",UP_DOWN:"↕",PILCROW:"¶",SECTION:"§",THICK_MINUS:"▬",SMALL_UP_DOWN:"↨",UP_ARROW:"↑",DOWN_ARROW:"↓",RIGHT_ARROW:"→",LEFT_ARROW:"←",RIGHT_ANGLE:"∟",LEFT_RIGHT_ARROW:"↔",TRIANGLE:"▲",DOWN_TRIANGLE:"▼",HOUSE:"⌂",C_CEDILLA:"Ç",U_UMLAUT:"ü",E_ACCENT:"é",A_LOWER_CIRCUMFLEX:"â",A_LOWER_UMLAUT:"ä",A_LOWER_GRAVE_ACCENT:"à",A_LOWER_CIRCLE_OVER:"å",C_LOWER_CIRCUMFLEX:"ç",E_LOWER_CIRCUMFLEX:"ê",E_LOWER_UMLAUT:"ë",E_LOWER_GRAVE_ACCENT:"è",I_LOWER_UMLAUT:"ï",I_LOWER_CIRCUMFLEX:"î",I_LOWER_GRAVE_ACCENT:"ì",A_UPPER_UMLAUT:"Ä",A_UPPER_CIRCLE:"Å",E_UPPER_ACCENT:"É",A_E_LOWER:"æ",A_E_UPPER:"Æ",O_LOWER_CIRCUMFLEX:"ô",O_LOWER_UMLAUT:"ö",O_LOWER_GRAVE_ACCENT:"ò",U_LOWER_CIRCUMFLEX:"û",U_LOWER_GRAVE_ACCENT:"ù",Y_LOWER_UMLAUT:"ÿ",O_UPPER_UMLAUT:"Ö",U_UPPER_UMLAUT:"Ü",CENTS:"¢",POUND:"£",YEN:"¥",CURRENCY:"¤",PTS:"₧",FUNCTION:"ƒ",A_LOWER_ACCENT:"á",I_LOWER_ACCENT:"í",O_LOWER_ACCENT:"ó",U_LOWER_ACCENT:"ú",N_LOWER_TILDE:"ñ",N_UPPER_TILDE:"Ñ",A_SUPER:"ª",O_SUPER:"º",UPSIDEDOWN_QUESTION:"¿",SIDEWAYS_L:"⌐",NEGATION:"¬",ONE_HALF:"½",ONE_FOURTH:"¼",UPSIDEDOWN_EXCLAMATION:"¡",DOUBLE_LEFT:"«",DOUBLE_RIGHT:"»",LIGHT_SHADED_BOX:"░",MEDIUM_SHADED_BOX:"▒",DARK_SHADED_BOX:"▓",VERTICAL_LINE:"│",MAZE__SINGLE_RIGHT_T:"┤",MAZE_SINGLE_RIGHT_TOP:"┐",MAZE_SINGLE_RIGHT_BOTTOM_SMALL:"┘",MAZE_SINGLE_LEFT_TOP_SMALL:"┌",MAZE_SINGLE_LEFT_BOTTOM_SMALL:"└",MAZE_SINGLE_LEFT_T:"├",MAZE_SINGLE_BOTTOM_T:"┴",MAZE_SINGLE_TOP_T:"┬",MAZE_SINGLE_CENTER:"┼",MAZE_SINGLE_HORIZONTAL_LINE:"─",MAZE_SINGLE_RIGHT_DOUBLECENTER_T:"╡",MAZE_SINGLE_RIGHT_DOUBLE_BL:"╛",MAZE_SINGLE_RIGHT_DOUBLE_T:"╢",MAZE_SINGLE_RIGHT_DOUBLEBOTTOM_TOP:"╖",MAZE_SINGLE_RIGHT_DOUBLELEFT_TOP:"╕",MAZE_SINGLE_LEFT_DOUBLE_T:"╞",MAZE_SINGLE_BOTTOM_DOUBLE_T:"╧",MAZE_SINGLE_TOP_DOUBLE_T:"╤",MAZE_SINGLE_TOP_DOUBLECENTER_T:"╥",MAZE_SINGLE_BOTTOM_DOUBLECENTER_T:"╨",MAZE_SINGLE_LEFT_DOUBLERIGHT_BOTTOM:"╘",MAZE_SINGLE_LEFT_DOUBLERIGHT_TOP:"╒",MAZE_SINGLE_LEFT_DOUBLEBOTTOM_TOP:"╓",MAZE_SINGLE_LEFT_DOUBLETOP_BOTTOM:"╙",MAZE_SINGLE_LEFT_TOP:"Γ",MAZE_SINGLE_RIGHT_BOTTOM:"╜",MAZE_SINGLE_LEFT_CENTER:"╟",MAZE_SINGLE_DOUBLECENTER_CENTER:"╫",MAZE_SINGLE_DOUBLECROSS_CENTER:"╪",MAZE_DOUBLE_LEFT_CENTER:"╣",MAZE_DOUBLE_VERTICAL:"║",MAZE_DOUBLE_RIGHT_TOP:"╗",MAZE_DOUBLE_RIGHT_BOTTOM:"╝",MAZE_DOUBLE_LEFT_BOTTOM:"╚",MAZE_DOUBLE_LEFT_TOP:"╔",MAZE_DOUBLE_BOTTOM_T:"╩",MAZE_DOUBLE_TOP_T:"╦",MAZE_DOUBLE_LEFT_T:"╠",MAZE_DOUBLE_HORIZONTAL:"═",MAZE_DOUBLE_CROSS:"╬",SOLID_RECTANGLE:"█",THICK_LEFT_VERTICAL:"▌",THICK_RIGHT_VERTICAL:"▐",SOLID_SMALL_RECTANGLE_BOTTOM:"▄",SOLID_SMALL_RECTANGLE_TOP:"▀",PHI_UPPER:"Φ",INFINITY:"∞",INTERSECTION:"∩",DEFINITION:"≡",PLUS_MINUS:"±",GT_EQ:"≥",LT_EQ:"≤",THEREFORE:"⌠",SINCE:"∵",DOESNOT_EXIST:"∄",EXISTS:"∃",FOR_ALL:"∀",EXCLUSIVE_OR:"⊕",BECAUSE:"⌡",DIVIDE:"÷",APPROX:"≈",DEGREE:"°",BOLD_DOT:"∙",DOT_SMALL:"·",CHECK:"√",ITALIC_X:"✗",SUPER_N:"ⁿ",SQUARED:"²",CUBED:"³",SOLID_BOX:"■",PERMILE:"‰",REGISTERED_TM:"®",COPYRIGHT:"©",TRADEMARK:"™",BETA:"β",GAMMA:"γ",ZETA:"ζ",ETA:"η",IOTA:"ι",KAPPA:"κ",LAMBDA:"λ",NU:"ν",XI:"ξ",OMICRON:"ο",RHO:"ρ",UPSILON:"υ",CHI_LOWER:"φ",CHI_UPPER:"χ",PSI:"ψ",ALPHA:"α",ESZETT:"ß",PI:"π",SIGMA_UPPER:"Σ",SIGMA_LOWER:"σ",MU:"µ",TAU:"τ",THETA:"Θ",OMEGA:"Ω",DELTA:"δ",PHI_LOWER:"φ",EPSILON:"ε"},B={toArray:k,pad:h,truncate:i,multiply:l,format:j,style:m,escape:n,trim:o,trimLeft:p,trimRight:q,isEmpty:r}; +return a.define(b.isString,B).define(b.isArray,{style:m}).expose(B).expose({characters:A})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("date-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","date-extended","array-extended"],function(a,b,c,e){return d(a,b,c,e)}):this.stringExtended=d(this.extended,this.isExtended,this.dateExtended,this.arrayExtended)}).call(this)},{"array-extended":52,"date-extended":53,extended:56,"is-extended":66}]},{},[1]); \ No newline at end of file diff --git a/package.json b/package.json index 8776026..48155fa 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nools", "description": "A rules engine for node", - "version": "0.2.2", + "version": "0.2.3", "bin": { "nools": "./bin/nools" }, diff --git a/readme.md b/readme.md index b716374..505f7d9 100644 --- a/readme.md +++ b/readme.md @@ -23,6 +23,7 @@ Or [download the source](https://raw.github.com/C2FO/nools/master/nools.js) ([mi * [Assert](#facts-assert) * [Retract](#facts-retract) * [Modify](#facts-modify) + * [Retrieving Facts](#get-facts) * [Firing](#firing) * [Disposing](#disposing) * [Removing A Flow](#removing-flow) @@ -42,6 +43,7 @@ Or [download the source](https://raw.github.com/C2FO/nools/master/nools.js) ([mi * [From](#from-constraint) * [Exists](#exists-constraint) * [Actions](#action) + * [Async Actions](#action-async) * [Globals](#globals) * [Import](#import) * [Browser Support](#browser-support) @@ -311,6 +313,32 @@ session.modify(m); **Note** `modify` is typically used during the execution of the rules. + +### Retrieving Facts + +To get a list of facts currently in the session you can use the `getFacts()` method exposed on a session. + +```javascript +session.assert(1); +session.assert("A"); +session.assert("B"); +session.assert(2); + +session.getFacts(); //[1, "A", "B", 2]; +``` + +You may also pass in a `Type` to `getFacts` which will return facts only of the given type. + +```javascript +session.assert(1); +session.assert("A"); +session.assert("B"); +session.assert(2); + +session.getFacts(Number); //[1, 2]; +session.getFacts(String); //["A", "B"]; +``` + ## Firing the rules @@ -1411,8 +1439,25 @@ function (facts, session) { } ``` -If you have an async action that needs to take place an optional third argument can be passed in which is a function -to be called when the action is completed. +To define the actions with the nools DSL + +``` +then { + modify(f3, function(){ + this.value = f1.value + f2.value; + }); + retract(f1); +} +``` + +For rules defined using the rules language nools will automatically determine what parameters need to be passed in based on what is referenced in the action. + + + + +### Async Actions + +If your action is async you can use the third argument which should called when the action is completed. ```javascript function (facts, engine, next) { @@ -1424,23 +1469,27 @@ function (facts, engine, next) { engine.modify(f3); engine.retract(f1); next(); - }) + }); } ``` -If any arguments are passed into next it is assumed there was an error and the session will error out. -To define the action with the nools DSL +If an error occurs you can pass the error as the first argument to `next`. -``` -then { - modify(f3, function(){ - this.value = f1.value + f2.value; - }); - retract(f1); +```javascript +then{ + saveToDatabase(user, function(err){ + next(new Error("Something went BOOM!")); + }); } ``` -For rules defined using the rules language nools will automatically determine what parameters need to be passed in based on what is referenced in the action. +If you are using a [`Promises/A+`](http://promises-aplus.github.io/promises-spec/) compliant library you can just return a promise from your action and `nools` will wait for the promise to resolve before continuing. + +```javascript +then{ + return saveToDatabase(user); // assume saveToDatabase returns a promise +} +``` diff --git a/test/constraintMatcher.test.js b/test/constraintMatcher.test.js index 3f25984..d23e557 100644 --- a/test/constraintMatcher.test.js +++ b/test/constraintMatcher.test.js @@ -328,9 +328,31 @@ it.describe("constraint matcher", function (it) { assert.lengthOf(atoms, 1); assert.equal(atoms[0].type, "inequality"); + atoms = constraintMatcher.toConstraints(parser.parseConstraint("a > b"), {alias: "a"}); + assert.lengthOf(atoms, 1); + assert.equal(atoms[0].type, "reference_gt"); + assert.equal(atoms[0].op, "gt"); + + atoms = constraintMatcher.toConstraints(parser.parseConstraint("a >= b"), {alias: "a"}); + assert.lengthOf(atoms, 1); + assert.equal(atoms[0].type, "reference_gte"); + assert.equal(atoms[0].op, "gte"); + + atoms = constraintMatcher.toConstraints(parser.parseConstraint("a < b"), {alias: "a"}); + assert.lengthOf(atoms, 1); + assert.equal(atoms[0].type, "reference_lt"); + assert.equal(atoms[0].op, "lt"); + + atoms = constraintMatcher.toConstraints(parser.parseConstraint("a <= b"), {alias: "a"}); + assert.lengthOf(atoms, 1); + assert.equal(atoms[0].type, "reference_lte"); + assert.equal(atoms[0].op, "lte"); + + atoms = constraintMatcher.toConstraints(parser.parseConstraint("a == b"), {alias: "a"}); assert.lengthOf(atoms, 1); assert.equal(atoms[0].type, "reference_equality"); + assert.equal(atoms[0].op, "eq"); atoms = constraintMatcher.toConstraints(parser.parseConstraint("a != b"), {alias: "a"}); assert.lengthOf(atoms, 1); @@ -501,26 +523,22 @@ it.describe("constraint matcher", function (it) { it.describe(".getIndexableProperties", function (it) { it.should("get properties with no functions", function () { - var props = constraintMatcher.getIndexableProperties(parser.parseConstraint("a == b"), "a"); - assert.deepEqual(props, ["a", "b"]); - props = constraintMatcher.getIndexableProperties(parser.parseConstraint("a.b == b"), "a"); - assert.deepEqual(props, ["a.b", "b"]); - props = constraintMatcher.getIndexableProperties(parser.parseConstraint("a == b.c"), "a"); - assert.deepEqual(props, ["a", "b.c"]); - props = constraintMatcher.getIndexableProperties(parser.parseConstraint("a.b.c.d == b.c.d.e "), "a"); - assert.deepEqual(props, ["a.b.c.d", "b.c.d.e"]); - props = constraintMatcher.getIndexableProperties(parser.parseConstraint("(a == b)"), "a"); - assert.deepEqual(props, ["a", "b"]); - props = constraintMatcher.getIndexableProperties(parser.parseConstraint("a != b"), "a"); - assert.deepEqual(props, ["a", "b"]); - props = constraintMatcher.getIndexableProperties(parser.parseConstraint("a.b != b"), "a"); - assert.deepEqual(props, ["a.b", "b"]); - props = constraintMatcher.getIndexableProperties(parser.parseConstraint("a != b.c"), "a"); - assert.deepEqual(props, ["a", "b.c"]); - props = constraintMatcher.getIndexableProperties(parser.parseConstraint("a.b.c.d != b.c.d.e "), "a"); - assert.deepEqual(props, ["a.b.c.d", "b.c.d.e"]); - props = constraintMatcher.getIndexableProperties(parser.parseConstraint("(a != b)"), "a"); - assert.deepEqual(props, ["a", "b"]); + + var operators = ["==", "!=", ">", ">=", "<", "<="], props, op; + for (var i = 0, l = operators.length; i < l; i++) { + op = operators[i]; + props = constraintMatcher.getIndexableProperties(parser.parseConstraint("a " + op + " b"), "a"); + assert.deepEqual(props, ["a", "b"]); + props = constraintMatcher.getIndexableProperties(parser.parseConstraint("a.b " + op + " b"), "a"); + assert.deepEqual(props, ["a.b", "b"]); + props = constraintMatcher.getIndexableProperties(parser.parseConstraint("a " + op + " b.c"), "a"); + assert.deepEqual(props, ["a", "b.c"]); + props = constraintMatcher.getIndexableProperties(parser.parseConstraint("a.b.c.d " + op + " b.c.d.e "), "a"); + assert.deepEqual(props, ["a.b.c.d", "b.c.d.e"]); + props = constraintMatcher.getIndexableProperties(parser.parseConstraint("(a " + op + " b)"), "a"); + assert.deepEqual(props, ["a", "b"]); + } + }); it.should("not get non indexable constraints", function () { diff --git a/test/flow.compiled.test.js b/test/flow.compiled.test.js index 7b09dc1..7f0ca7c 100644 --- a/test/flow.compiled.test.js +++ b/test/flow.compiled.test.js @@ -329,6 +329,70 @@ it.describe("Flow compiled", function (it) { }); }); + + it.describe("getFacts from action", function (it) { + var flow; + + it.beforeAll(function () { + flow = require("./rules/getFacts-compiled")(); + }); + + it.should("get all facts", function () { + var session = flow.getSession().focus("get-facts"); + var facts = [ + {}, + 1, + "hello", + true, + new Date() + ]; + for (var i = 0; i < facts.length; i++) { + session.assert(facts[i]); + } + var called = 0; + return session.on("get-facts",function (gottenFacts) { + assert.deepEqual(gottenFacts, facts); + called++; + }).match().then(function () { + assert.equal(called, 1); + }); + }); + + it.should("get facts by type", function () { + var session = flow.getSession().focus("get-facts-by-type"); + var facts = [ + 1, + "hello", + true, + new Date() + ]; + for (var i = 0; i < facts.length; i++) { + session.assert(facts[i]); + } + var called = 0; + return session + .on("get-facts-number",function (fact) { + assert.deepEqual(fact, [facts[0]]); + called++; + }) + .on("get-facts-string",function (fact) { + assert.deepEqual(fact, [facts[1]]); + called++; + }) + .on("get-facts-boolean",function (fact) { + assert.deepEqual(fact, [facts[2]]); + called++; + }) + .on("get-facts-date",function (fact) { + assert.deepEqual(fact, [facts[3]]); + called++; + }) + .match().then(function () { + assert.equal(called, 4); + }); + }); + + }); }); diff --git a/test/flow.dsl.test.js b/test/flow.dsl.test.js index c2eab34..77139be 100644 --- a/test/flow.dsl.test.js +++ b/test/flow.dsl.test.js @@ -1,15 +1,20 @@ "use strict"; var it = require("it"), assert = require("assert"), - nools = require("../index"); + nools = require("../index"), + resolve = require("path").resolve; it.describe("Flow dsl", function (it) { it.describe("not rule", function (it) { - var flow = nools.compile(__dirname + "/rules/notRule.nools"), - Count = flow.getDefined("count"), + var flow, Count, called; + + it.beforeAll(function () { + flow = nools.compile(resolve(__dirname, "./rules/notRule.nools")); + Count = flow.getDefined("count"); called = new Count(); + }); it.should("call when a string that does not equal 'hello'", function () { @@ -35,10 +40,12 @@ it.describe("Flow dsl", function (it) { }); it.describe("or rule", function (it) { - - var flow = nools.compile(__dirname + "/rules/orRule.nools"), - Count = flow.getDefined("count"), + var flow, Count, called; + it.beforeAll(function () { + flow = nools.compile(resolve(__dirname, "./rules/orRule.nools")); + Count = flow.getDefined("count"); called = new Count(); + }); it.should("call when a string equals 'hello'", function () { return flow.getSession("world", called).match().then(function () { @@ -57,7 +64,7 @@ it.describe("Flow dsl", function (it) { it.describe("or rule with not conditions", function (it) { var flow, count; it.beforeAll(function () { - flow = nools.compile(__dirname + "/rules/orRule-notConditions.nools"); + flow = nools.compile(resolve(__dirname, "./rules/orRule-notConditions.nools")); var Count = flow.getDefined("count"); count = new Count(); }); @@ -94,9 +101,11 @@ it.describe("Flow dsl", function (it) { }); it.describe("scoped functions", function (it) { - var flow = nools.compile(__dirname + "/rules/scope.nools"), - Message = flow.getDefined("Message"), - session; + var flow, Message, session; + it.beforeAll(function () { + flow = nools.compile(resolve(__dirname, "./rules/scope.nools")); + Message = flow.getDefined("Message"); + }); it.beforeEach(function () { session = flow.getSession(); @@ -116,9 +125,11 @@ it.describe("Flow dsl", function (it) { var matches = function (str, regex) { return regex.test(str); }; - var flow = nools.compile(__dirname + "/rules/provided-scope.nools", {scope: {doesMatch: matches}}), - Message = flow.getDefined("Message"), - session; + var flow, Message, session; + it.beforeAll(function () { + flow = nools.compile(resolve(__dirname, "./rules/provided-scope.nools"), {scope: {doesMatch: matches}}); + Message = flow.getDefined("Message"); + }); it.beforeEach(function () { session = flow.getSession(); @@ -140,13 +151,15 @@ it.describe("Flow dsl", function (it) { this.message = message; } - var flow = nools.compile(__dirname + "/rules/simple-external-defined.nools", { + var flow, session; + it.beforeAll(function () { + flow = nools.compile(resolve(__dirname, "./rules/simple-external-defined.nools"), { define: { Message: Message } - }), - session; + }); + }); it.beforeEach(function () { session = flow.getSession(); @@ -167,11 +180,14 @@ it.describe("Flow dsl", function (it) { }); it.describe("globals", function (it) { - var flow = nools.compile(__dirname + "/rules/global.nools"), - session; + var flow, session; it.timeout(1000); + it.beforeAll(function () { + flow = nools.compile(resolve(__dirname, "./rules/global.nools")); + }); + it.beforeEach(function () { session = flow.getSession(); }); @@ -198,7 +214,10 @@ it.describe("Flow dsl", function (it) { it.describe("comments in dsl", function (it) { - var flow = nools.compile(__dirname + "/rules/comments.nools"); + var flow; + it.beforeAll(function () { + flow = nools.compile(resolve(__dirname, "./rules/comments.nools")); + }); it.should("remove all block comments", function () { assert.isFalse(flow.containsRule("Goodbye2")); @@ -212,9 +231,11 @@ it.describe("Flow dsl", function (it) { it.timeout(1000); - var flow = nools.compile(__dirname + "/rules/simple.nools"), - Message = flow.getDefined("Message"), - session; + var flow, Message, session; + it.beforeAll(function () { + flow = nools.compile(resolve(__dirname, "./rules/simple.nools")); + Message = flow.getDefined("Message"); + }); it.beforeEach(function () { session = flow.getSession(); @@ -279,9 +300,11 @@ it.describe("Flow dsl", function (it) { }); it.describe("agenda-groups", function (it) { - var flow = nools.compile(__dirname + "/rules/agenda-group.nools"), - Message = flow.getDefined("message"), - session; + var flow, Message, session; + it.beforeAll(function () { + flow = nools.compile(resolve(__dirname, "./rules/agenda-group.nools")); + Message = flow.getDefined("message"); + }); it.beforeEach(function () { session = flow.getSession(); @@ -336,10 +359,77 @@ it.describe("Flow dsl", function (it) { }); }); + it.describe("getFacts from action", function (it) { + var flow; + + it.beforeAll(function () { + flow = nools.compile(resolve(__dirname, "./rules/getFacts.nools")); + }); + + it.should("get all facts", function () { + var session = flow.getSession().focus("get-facts"); + var facts = [ + {}, + 1, + "hello", + true, + new Date() + ]; + for (var i = 0; i < facts.length; i++) { + session.assert(facts[i]); + } + var called = 0; + return session.on("get-facts",function (gottenFacts) { + assert.deepEqual(gottenFacts, facts); + called++; + }).match().then(function () { + assert.equal(called, 1); + }); + }); + + it.should("get facts by type", function () { + var session = flow.getSession().focus("get-facts-by-type"); + var facts = [ + 1, + "hello", + true, + new Date() + ]; + for (var i = 0; i < facts.length; i++) { + session.assert(facts[i]); + } + var called = 0; + return session + .on("get-facts-number", function (fact) { + assert.deepEqual(fact, [facts[0]]); + called++; + }) + .on("get-facts-string", function (fact) { + assert.deepEqual(fact, [facts[1]]); + called++; + }) + .on("get-facts-boolean", function (fact) { + assert.deepEqual(fact, [facts[2]]); + called++; + }) + .on("get-facts-date", function (fact) { + assert.deepEqual(fact, [facts[3]]); + called++; + }) + .match().then(function () { + assert.equal(called, 4); + }); + }); + + }); + it.describe("auto-focus", function (it) { - var flow = nools.compile(__dirname + "/rules/auto-focus.nools"), - State = flow.getDefined("state"), - session; + + var flow, State, session; + it.beforeAll(function () { + flow = nools.compile(resolve(__dirname, "./rules/auto-focus.nools")); + State = flow.getDefined("state"); + }); it.beforeEach(function () { session = flow.getSession(); @@ -360,11 +450,15 @@ it.describe("Flow dsl", function (it) { }); }); + it.describe("fibonacci nools dsl", function (it) { - var flow = nools.compile(__dirname + "/rules/fibonacci.nools"); - var Fibonacci = flow.getDefined("fibonacci"); - var Result = flow.getDefined("result"); + var flow, Fibonacci, Result; + it.beforeAll(function () { + flow = nools.compile(resolve(__dirname, "./rules/fibonacci.nools")); + Fibonacci = flow.getDefined("fibonacci"); + Result = flow.getDefined("result"); + }); it.should("calculate fibonacci 3", function () { var result = new Result(); @@ -402,8 +496,11 @@ it.describe("Flow dsl", function (it) { it.describe("diagnosis using dsl", function (it) { - var flow = nools.compile(__dirname + "/rules/diagnosis.nools"), + var flow, Patient; + it.beforeAll(function () { + flow = nools.compile(resolve(__dirname, "./rules/diagnosis.nools")); Patient = flow.getDefined("patient"); + }); it.should("treat properly", function () { @@ -414,9 +511,8 @@ it.describe("Flow dsl", function (it) { session.assert(new Patient({name: "Bob", fever: "high", spots: true, rash: false, soreThroat: false, innoculated: true})); session.assert(new Patient({name: "Tom", fever: "none", spots: false, rash: true, soreThroat: false, innoculated: false})); session.assert(results); - //flow.print(); return session.match().then(function () { - //session.dispose(); + session.dispose(); assert.deepEqual(results, [ {"name": "Tom", "treatment": "allergyShot"}, {"name": "Bob", "treatment": "penicillin"}, diff --git a/test/flow.test.js b/test/flow.test.js deleted file mode 100644 index e69de29..0000000 diff --git a/test/flow/exists.test.js b/test/flow/exists.test.js index 895fecb..ccfca9b 100644 --- a/test/flow/exists.test.js +++ b/test/flow/exists.test.js @@ -77,22 +77,22 @@ it.describe("exists rule", function (it) { str2 = new Str("Bob Yukon"), person = new Person("Bob Yukon"); session.assert(person); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 0); session.assert(str1); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 0); session.retract(str1); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 0); session.assert(str2); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 1); session.retract(str2); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 0); session.assert(str2); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 1); session.assert(str1); activations = activationTree.toArray() diff --git a/test/flow/facts.test.js b/test/flow/facts.test.js new file mode 100644 index 0000000..23296d9 --- /dev/null +++ b/test/flow/facts.test.js @@ -0,0 +1,49 @@ +"use strict"; +var it = require("it"), + assert = require("assert"), + declare = require("declare.js"), + nools = require("../../"); +it.describe("flow#getFacts", function (it) { + + var called = 0; + var HelloFact = declare({ + instance: { + value: true + } + }); + + var flow = nools.flow("facts() flow", function (flow) { + flow.rule("hello rule", [ + [HelloFact, "h"], + [String, "s"], + [Number, "n"], + [Object, "o"], + [Boolean, "b"] + ], function () { + called++; + }); + }); + + it.should("get all facts in the session", function () { + var session = flow.getSession(); + var facts = [new HelloFact(), "Hello", 1, {}, true], i = -1, l = facts.length; + while (++i < l) { + session.assert(facts[i]); + } + assert.deepEqual(session.getFacts(), facts); + }); + + it.should("get all facts in the session by Type", function () { + var session = flow.getSession(); + var facts = [new HelloFact(), "Hello", 1, {}, true], i = -1, l = facts.length; + while (++i < l) { + session.assert(facts[i]); + } + assert.deepEqual(session.getFacts(HelloFact), [facts[0]]); + assert.deepEqual(session.getFacts(String), [facts[1]]); + assert.deepEqual(session.getFacts(Number), [facts[2]]); + assert.deepEqual(session.getFacts(Object), [facts[0], facts[3]]); + assert.deepEqual(session.getFacts(Boolean), [facts[4]]); + }); + +}); \ No newline at end of file diff --git a/test/flow/index.js b/test/flow/index.js index 883c739..12cde2b 100644 --- a/test/flow/index.js +++ b/test/flow/index.js @@ -1,3 +1,4 @@ +require("./facts.test"); require("./agendaGroups.test"); require("./async.test"); require("./events.test"); diff --git a/test/flow/leftMemory.test.js b/test/flow/leftMemory.test.js index 0e4307e..56d4482 100644 --- a/test/flow/leftMemory.test.js +++ b/test/flow/leftMemory.test.js @@ -4,7 +4,7 @@ var it = require("it"), WorkingMemory = require("../../lib/workingMemory").WorkingMemory, LeftMemory = require("../../lib/nodes/misc/leftMemory"); -it.describe("BetaNode RightMemory", function (it) { +it.describe("BetaNode LeftMemory", function (it) { it.should("add a context to the memory", function () { var wm = new WorkingMemory(), @@ -79,7 +79,7 @@ it.describe("BetaNode RightMemory", function (it) { var node = rm.push(leftContext); assert.equal(rm.length, 1); rm.remove(node); - assert.deepEqual(rm.tables.tables["s.a"].get(1).tuples, []); + assert.isUndefined(rm.tables.tables["s.a"].get(1)); }); it.describe(".getLeftMemory", function (it) { @@ -114,18 +114,43 @@ it.describe("BetaNode RightMemory", function (it) { leftContext1.set("s", {a: 1, b: 2, c: 2}); rightContext2.set("a", {s: 1, b: 3, c: 3}); leftContext2.set("s", {a: 1, b: 4, c: 3}); - debugger; lm.addIndex("s.c", "a.c", "neq"); lm.addIndex("s.a", "a.s"); lm.addIndex("s.b", "a.b"); var node1 = lm.push(leftContext1); lm.push(leftContext2); assert.equal(lm.length, 2); + debugger; var nodes = lm.getLeftMemory(rightContext1); assert.lengthOf(nodes, 1); assert.deepEqual(nodes, [node1]); nodes = lm.getLeftMemory(rightContext2); assert.lengthOf(nodes, 0); }); + + it.should("find intersection of multiple neq", function () { + var wm = new WorkingMemory(), + rm = new LeftMemory(), + rightContext1 = new Context(wm.assertFact({s: 1})), + rightContext2 = new Context(wm.assertFact({s: 1})), + leftContext1 = new Context(wm.assertFact({a: 1})), + leftContext2 = new Context(wm.assertFact({a: 3})); + rightContext1.set("a", {s: 1}); + rightContext2.set("a", {s: 3}); + leftContext1.set("s", {a: 1, b: 2, c: 1}); + leftContext2.set("s", {a: 2, b: 3, c: 4}); + rm.addIndex("s.a", "a.s", "neq"); + rm.addIndex("s.b", "a.s", "neq"); + rm.addIndex("s.c", "a.s", "neq"); + var node1 = rm.push(leftContext1), + node2 = rm.push(leftContext2); + assert.equal(rm.length, 2); + var nodes = rm.getLeftMemory(rightContext1); + assert.lengthOf(nodes, 1); + assert.deepEqual(nodes, [node2]); + nodes = rm.getLeftMemory(rightContext2); + assert.lengthOf(nodes, 1); + assert.deepEqual(nodes, [node1]); + }); }); }); \ No newline at end of file diff --git a/test/flow/not.test.js b/test/flow/not.test.js index c114ea3..e925b10 100644 --- a/test/flow/not.test.js +++ b/test/flow/not.test.js @@ -110,56 +110,56 @@ it.describe("not rule", function (it) { session.modify(num1, function () { this.value = 6; }); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 1); assert.equal(activations[0].match.factHash.n1, num2); session.modify(num2, function () { this.value = 7; }); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 1); assert.equal(activations[0].match.factHash.n1, num3); session.modify(num3, function () { this.value = 8; }); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 1); assert.equal(activations[0].match.factHash.n1, num4); session.modify(num4, function () { this.value = 9; }); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 1); assert.equal(activations[0].match.factHash.n1, num5); session.modify(num5, function () { this.value = 10; }); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 1); assert.equal(activations[0].match.factHash.n1, num1); session.retract(num1); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 1); assert.equal(activations[0].match.factHash.n1, num2); session.retract(num2); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 1); assert.equal(activations[0].match.factHash.n1, num3); session.retract(num3); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 1); assert.equal(activations[0].match.factHash.n1, num4); session.retract(num4); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 1); assert.equal(activations[0].match.factHash.n1, num5); session.retract(num5); - activations = activationTree.toArray() + activations = activationTree.toArray(); assert.lengthOf(activations, 0); session.assert(num5); @@ -168,7 +168,6 @@ it.describe("not rule", function (it) { session.assert(num2); session.assert(num1); activations = activationTree.toArray(); - debugger; assert.lengthOf(activations, 1); assert.equal(activations[0].match.factHash.n1, num1); session.retract(num1); diff --git a/test/flow/rightMemory.test.js b/test/flow/rightMemory.test.js index bb0458c..88996bc 100644 --- a/test/flow/rightMemory.test.js +++ b/test/flow/rightMemory.test.js @@ -79,7 +79,7 @@ it.describe("BetaNode RightMemory", function (it) { var node = rm.push(rightContext); assert.equal(rm.length, 1); rm.remove(node); - assert.deepEqual(rm.tables.tables["a.s"].get(1).tuples, []); + assert.isUndefined(rm.tables.tables["a.s"].get(1)); }); it.describe(".getRightMemory", function (it) { @@ -126,5 +126,30 @@ it.describe("BetaNode RightMemory", function (it) { nodes = rm.getRightMemory(leftContext2); assert.lengthOf(nodes, 0); }); + + it.should("find intersection of multiple neq", function () { + var wm = new WorkingMemory(), + rm = new RightMemory(), + rightContext1 = new Context(wm.assertFact({s: 1})), + rightContext2 = new Context(wm.assertFact({s: 1})), + leftContext1 = new Context(wm.assertFact({a: 1})), + leftContext2 = new Context(wm.assertFact({a: 3})); + rightContext1.set("a", {s: 1}); + rightContext2.set("a", {s: 3}); + leftContext1.set("s", {a: 1, b: 2, c: 1}); + leftContext2.set("s", {a: 2, b: 3, c: 4}); + rm.addIndex("a.s", "s.a", "neq"); + rm.addIndex("a.s", "s.b", "neq"); + rm.addIndex("a.s", "s.c", "neq"); + var node1 = rm.push(rightContext1), + node2 = rm.push(rightContext2); + assert.equal(rm.length, 2); + var nodes = rm.getRightMemory(leftContext1); + assert.lengthOf(nodes, 1); + assert.deepEqual(nodes, [node2]); + nodes = rm.getRightMemory(leftContext2); + assert.lengthOf(nodes, 1); + assert.deepEqual(nodes, [node1]); + }); }); }); \ No newline at end of file diff --git a/test/rules/agenda-group-compiled.js b/test/rules/agenda-group-compiled.js index f5bd3c3..97ca772 100644 --- a/test/rules/agenda-group-compiled.js +++ b/test/rules/agenda-group-compiled.js @@ -1 +1 @@ -(function(){ function _getCompiled(nools){ return (function() { return function(options) { options = options || {}; var bind = function(scope, fn) { return function() { return fn.apply(scope, arguments); }; }, defined = options.defined || {}, scope = options.scope || {}; return nools.flow("agenda-group-compiled", function() { var Message = defined.Message = this.addDefined("Message", function() { var Defined = function(name) { this.name = name; }, proto = Defined.prototype; return proto.constructor = function(name) { this.name = name; }, Defined; }()); this.rule("Hello World", { agendaGroup: "ag1", scope: scope }, [ [ Message, "m", "m.name == 'hello'" ] ], function(facts, flow) { var m = facts.m, m = facts.m, modify = bind(flow, flow.modify); modify(m, function() { this.name = "goodbye"; }); }), this.rule("Hello World 2", { agendaGroup: "ag2", scope: scope }, [ [ Message, "m", "m.name == 'hello'" ] ], function(facts, flow) { var m = facts.m, m = facts.m, modify = bind(flow, flow.modify); modify(m, function() { this.name = "goodbye"; }); }), this.rule("GoodBye", { agendaGroup: "ag1", scope: scope }, [ [ Message, "m", "m.name == 'goodbye'" ] ], function() {}), this.rule("GoodBye 2", { agendaGroup: "ag2", scope: scope }, [ [ Message, "m", "m.name == 'goodbye'" ] ], function() {}); }); }; })(); } if ("undefined" !== typeof exports) { if ("undefined" !== typeof module && module.exports) { module.exports = _getCompiled(require("../../")); } } else if ("function" === typeof define && define.amd) { define(["../../"], function (nools) { return _getCompiled(nools); }); } else { _getCompiled(this.nools)(); } }).call(this); +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("agenda-group-compiled",function(){var Message=defined.Message=this.addDefined("Message",function(){var Defined=function(name){this.name=name},proto=Defined.prototype;return proto.constructor=function(name){this.name=name},Defined}());scope.console=console,this.rule("Hello World",{agendaGroup:"ag1",scope:scope},[[Message,"m","m.name == 'hello'"]],function(facts,flow){var m=facts.m,m=facts.m,modify=flow.modify;modify(m,function(){this.name="goodbye"})}),this.rule("Hello World 2",{agendaGroup:"ag2",scope:scope},[[Message,"m","m.name == 'hello'"]],function(facts,flow){var m=facts.m,m=facts.m,modify=flow.modify;modify(m,function(){this.name="goodbye"})}),this.rule("GoodBye",{agendaGroup:"ag1",scope:scope},[[Message,"m","m.name == 'goodbye'"]],function(){}),this.rule("GoodBye 2",{agendaGroup:"ag2",scope:scope},[[Message,"m","m.name == 'goodbye'"]],function(){})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file diff --git a/test/rules/auto-focus-compiled.js b/test/rules/auto-focus-compiled.js index f2f3c38..c005591 100644 --- a/test/rules/auto-focus-compiled.js +++ b/test/rules/auto-focus-compiled.js @@ -1 +1 @@ -(function(){ function _getCompiled(nools){ return (function() { return function(options) { options = options || {}; var bind = function(scope, fn) { return function() { return fn.apply(scope, arguments); }; }, defined = options.defined || {}, scope = options.scope || {}; return nools.flow("auto-focus-compiled", function() { var State = defined.State = this.addDefined("State", function() { var Defined = function(name, state) { this.name = name, this.state = state; }, proto = Defined.prototype; return proto.constructor = function(name, state) { this.name = name, this.state = state; }, Defined; }()); this.rule("Bootstrap", { scope: scope }, [ [ State, "a", "a.name == 'A' && a.state == 'NOT_RUN'" ] ], function(facts, flow) { var a = facts.a, a = facts.a, modify = bind(flow, flow.modify); modify(a, function() { this.state = "FINISHED"; }); }), this.rule("A to B", { scope: scope }, [ [ State, "a", "a.name == 'A' && a.state == 'FINISHED'" ], [ State, "b", "b.name == 'B' && b.state == 'NOT_RUN'" ] ], function(facts, flow) { facts.a, facts.a; var b = facts.b, b = facts.b, modify = bind(flow, flow.modify); modify(b, function() { this.state = "FINISHED"; }); }), this.rule("B to C", { agendaGroup: "B to C", autoFocus: !0, scope: scope }, [ [ State, "b", "b.name == 'B' && b.state == 'FINISHED'" ], [ State, "c", "c.name == 'C' && c.state == 'NOT_RUN'" ] ], function(facts, flow) { var c = facts.c, c = facts.c, modify = bind(flow, flow.modify), focus = bind(flow, flow.focus); modify(c, function() { this.state = "FINISHED"; }), focus("B to D"); }), this.rule("B to D", { agendaGroup: "B to D", scope: scope }, [ [ State, "b", "b.name == 'B' && b.state == 'FINISHED'" ], [ State, "d", "d.name == 'D' && d.state == 'NOT_RUN'" ] ], function(facts, flow) { var d = facts.d, d = facts.d, modify = bind(flow, flow.modify); modify(d, function() { this.state = "FINISHED"; }); }); }); }; })(); } if ("undefined" !== typeof exports) { if ("undefined" !== typeof module && module.exports) { module.exports = _getCompiled(require("../../")); } } else if ("function" === typeof define && define.amd) { define(["../../"], function (nools) { return _getCompiled(nools); }); } else { _getCompiled(this.nools)(); } }).call(this); +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("auto-focus-compiled",function(){var State=defined.State=this.addDefined("State",function(){var Defined=function(name,state){this.name=name,this.state=state},proto=Defined.prototype;return proto.constructor=function(name,state){this.name=name,this.state=state},Defined}());scope.console=console,this.rule("Bootstrap",{scope:scope},[[State,"a","a.name == 'A' && a.state == 'NOT_RUN'"]],function(facts,flow){var a=facts.a,a=facts.a,modify=flow.modify;modify(a,function(){this.state="FINISHED"})}),this.rule("A to B",{scope:scope},[[State,"a","a.name == 'A' && a.state == 'FINISHED'"],[State,"b","b.name == 'B' && b.state == 'NOT_RUN'"]],function(facts,flow){facts.a,facts.a;var b=facts.b,b=facts.b,modify=flow.modify;modify(b,function(){this.state="FINISHED"})}),this.rule("B to C",{agendaGroup:"B to C",autoFocus:!0,scope:scope},[[State,"b","b.name == 'B' && b.state == 'FINISHED'"],[State,"c","c.name == 'C' && c.state == 'NOT_RUN'"]],function(facts,flow){var c=facts.c,c=facts.c,modify=flow.modify,focus=flow.focus;modify(c,function(){this.state="FINISHED"}),focus("B to D")}),this.rule("B to D",{agendaGroup:"B to D",scope:scope},[[State,"b","b.name == 'B' && b.state == 'FINISHED'"],[State,"d","d.name == 'D' && d.state == 'NOT_RUN'"]],function(facts,flow){var d=facts.d,d=facts.d,modify=flow.modify;modify(d,function(){this.state="FINISHED"})})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file diff --git a/test/rules/comments-compiled.js b/test/rules/comments-compiled.js new file mode 100644 index 0000000..e8dfec0 --- /dev/null +++ b/test/rules/comments-compiled.js @@ -0,0 +1 @@ +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("comments-compiled",function(){var Message=defined.Message=this.addDefined("Message",function(){var Defined=function(message){this.message=message},proto=Defined.prototype;return proto.message="",proto.constructor=function(message){this.message=message},Defined}());scope.console=console,this.rule("Hello",{scope:scope},[[Message,"m","m.message =~ /^hello(\\s*world)?$/"]],function(facts,flow){var m=facts.m,m=facts.m,modify=flow.modify;modify(m,function(){this.message+=" goodbye"})}),this.rule("Goodbye",{scope:scope},[[Message,"m","m.message =~ /.*goodbye$/"]],function(facts,flow){var m=facts.m,m=facts.m,emit=flow.emit;emit("found-goodbye",m)})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file diff --git a/test/rules/diagnosis-compiled.js b/test/rules/diagnosis-compiled.js index b8a8248..01562c0 100644 --- a/test/rules/diagnosis-compiled.js +++ b/test/rules/diagnosis-compiled.js @@ -1 +1 @@ -(function(){ function _getCompiled(nools){ return (function() { return function(options) { options = options || {}; var bind = function(scope, fn) { return function() { return fn.apply(scope, arguments); }; }, defined = options.defined || {}, scope = options.scope || {}; return nools.flow("diagnosis-compiled", function() { var Patient = defined.Patient = this.addDefined("Patient", function() { var Defined = function(opts) { for (var i in opts) opts.hasOwnProperty(i) && (this[i] = opts[i]); }, proto = Defined.prototype; return proto.name = null, proto.fever = null, proto.spots = null, proto.rash = null, proto.soreThroat = null, proto.innoculated = null, Defined; }()), Diagnosis = defined.Diagnosis = this.addDefined("Diagnosis", function() { var Defined = function(opts) { for (var i in opts) opts.hasOwnProperty(i) && (this[i] = opts[i]); }, proto = Defined.prototype; return proto.name = null, proto.diagnosis = null, Defined; }()), Treatment = defined.Treatment = this.addDefined("Treatment", function() { var Defined = function(opts) { for (var i in opts) opts.hasOwnProperty(i) && (this[i] = opts[i]); }, proto = Defined.prototype; return proto.name = null, proto.treatment = null, Defined; }()); this.rule("Measels", { scope: scope }, [ [ Patient, "p", "p.fever == 'high' && p.spots == true && p.innoculated == true", { name: "n" } ], [ "not", Diagnosis, "d", "d.name == n && d.diagnosis == 'allergy'" ] ], function(facts, flow) { var n = facts.n; facts.d, facts.d; var n = facts.n, assert = bind(flow, flow.assert); assert(new Diagnosis({ name: n, diagnosis: "measles" })); }), this.rule("Allergy1", { scope: scope }, [ [ Patient, "p", "p.spots == true", { name: "n" } ], [ "not", Diagnosis, "d", "d.name == n && d.diagnosis == 'measles'" ] ], function(facts, flow) { var n = facts.n; facts.d, facts.d; var n = facts.n, assert = bind(flow, flow.assert); assert(new Diagnosis({ name: n, diagnosis: "allergy" })); }), this.rule("Allergy2", { scope: scope }, [ [ Patient, "p", "p.rash == true", { name: "n" } ] ], function(facts, flow) { var n = facts.n, assert = bind(flow, flow.assert); assert(new Diagnosis({ name: n, diagnosis: "allergy" })); }), this.rule("Flu", { scope: scope }, [ [ Patient, "p", "p.soreThroat == true && p.fever in ['mild', 'high']", { name: "n" } ] ], function(facts, flow) { var n = facts.n, assert = bind(flow, flow.assert); assert(new Diagnosis({ name: n, diagnosis: "flu" })); }), this.rule("Penicillin", { scope: scope }, [ [ Diagnosis, "d", "d.diagnosis == 'measles'", { name: "n" } ] ], function(facts, flow) { var n = facts.n, assert = bind(flow, flow.assert); assert(new Treatment({ name: n, treatment: "penicillin" })); }), this.rule("AllergyPills", { scope: scope }, [ [ Diagnosis, "d", "d.diagnosis == 'allergy'", { name: "n" } ] ], function(facts, flow) { var n = facts.n, assert = bind(flow, flow.assert); assert(new Treatment({ name: n, treatment: "allergyShot" })); }), this.rule("BedRest", { scope: scope }, [ [ Diagnosis, "d", "d.diagnosis == 'flu'", { name: "n" } ] ], function(facts, flow) { facts.d, facts.d; var n = facts.n, assert = bind(flow, flow.assert); assert(new Treatment({ name: n, treatment: "bedRest" })); }), this.rule("Collect", { scope: scope }, [ [ Treatment, "t" ], [ Array, "r" ] ], function(facts) { var t = facts.t, r = facts.r; r.push(t); }); }); }; })(); } if ("undefined" !== typeof exports) { if ("undefined" !== typeof module && module.exports) { module.exports = _getCompiled(require("../../")); } } else if ("function" === typeof define && define.amd) { define(["../../"], function (nools) { return _getCompiled(nools); }); } else { _getCompiled(this.nools)(); } }).call(this); +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("diagnosis-compiled",function(){var Patient=defined.Patient=this.addDefined("Patient",function(){var Defined=function(opts){for(var i in opts)opts.hasOwnProperty(i)&&(this[i]=opts[i])},proto=Defined.prototype;return proto.name=null,proto.fever=null,proto.spots=null,proto.rash=null,proto.soreThroat=null,proto.innoculated=null,Defined}()),Diagnosis=defined.Diagnosis=this.addDefined("Diagnosis",function(){var Defined=function(opts){for(var i in opts)opts.hasOwnProperty(i)&&(this[i]=opts[i])},proto=Defined.prototype;return proto.name=null,proto.diagnosis=null,Defined}()),Treatment=defined.Treatment=this.addDefined("Treatment",function(){var Defined=function(opts){for(var i in opts)opts.hasOwnProperty(i)&&(this[i]=opts[i])},proto=Defined.prototype;return proto.name=null,proto.treatment=null,Defined}());scope.console=console,this.rule("Measels",{scope:scope},[[Patient,"p","p.fever == 'high' && p.spots == true && p.innoculated == true",{name:"n"}],["not",Diagnosis,"d","d.name == n && d.diagnosis == 'allergy'"]],function(facts,flow){var n=facts.n;facts.d,facts.d;var n=facts.n,assert=flow.assert;assert(new Diagnosis({name:n,diagnosis:"measles"}))}),this.rule("Allergy1",{scope:scope},[[Patient,"p","p.spots == true",{name:"n"}],["not",Diagnosis,"d","d.name == n && d.diagnosis == 'measles'"]],function(facts,flow){var n=facts.n;facts.d,facts.d;var n=facts.n,assert=flow.assert;assert(new Diagnosis({name:n,diagnosis:"allergy"}))}),this.rule("Allergy2",{scope:scope},[[Patient,"p","p.rash == true",{name:"n"}]],function(facts,flow){var n=facts.n,assert=flow.assert;assert(new Diagnosis({name:n,diagnosis:"allergy"}))}),this.rule("Flu",{scope:scope},[[Patient,"p","p.soreThroat == true && p.fever in ['mild', 'high']",{name:"n"}]],function(facts,flow){var n=facts.n,assert=flow.assert;assert(new Diagnosis({name:n,diagnosis:"flu"}))}),this.rule("Penicillin",{scope:scope},[[Diagnosis,"d","d.diagnosis == 'measles'",{name:"n"}]],function(facts,flow){var n=facts.n,assert=flow.assert;assert(new Treatment({name:n,treatment:"penicillin"}))}),this.rule("AllergyPills",{scope:scope},[[Diagnosis,"d","d.diagnosis == 'allergy'",{name:"n"}]],function(facts,flow){var n=facts.n,assert=flow.assert;assert(new Treatment({name:n,treatment:"allergyShot"}))}),this.rule("BedRest",{scope:scope},[[Diagnosis,"d","d.diagnosis == 'flu'",{name:"n"}]],function(facts,flow){facts.d,facts.d;var n=facts.n,assert=flow.assert;assert(new Treatment({name:n,treatment:"bedRest"}))}),this.rule("Collect",{scope:scope},[[Treatment,"t"],[Array,"r"]],function(facts){var t=facts.t,r=facts.r;r.push(t)})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file diff --git a/test/rules/fibonacci-compiled.js b/test/rules/fibonacci-compiled.js index ee8d1d3..8f396ad 100644 --- a/test/rules/fibonacci-compiled.js +++ b/test/rules/fibonacci-compiled.js @@ -1 +1 @@ -(function(){ function _getCompiled(nools){ return (function() { return function(options) { options = options || {}; var bind = function(scope, fn) { return function() { return fn.apply(scope, arguments); }; }, defined = options.defined || {}, scope = options.scope || {}; return nools.flow("fibonacci-compiled", function() { var Fibonacci = defined.Fibonacci = this.addDefined("Fibonacci", function() { var Defined = function(sequence, value) { this.sequence = sequence, this.value = value || -1; }, proto = Defined.prototype; return proto.sequence = null, proto.value = -1, proto.constructor = function(sequence, value) { this.sequence = sequence, this.value = value || -1; }, Defined; }()), Result = defined.Result = this.addDefined("Result", function() { var Defined = function(value) { this.value = value; }, proto = Defined.prototype; return proto.value = 0, proto.constructor = function(value) { this.value = value; }, Defined; }()); this.rule("Recurse", { scope: scope }, [ [ "not", Fibonacci, "nf", "nf.sequence == 1" ], [ Fibonacci, "f", "f.value == -1 && f.sequence != 1" ] ], function(facts, flow) { var f = facts.f, f = facts.f, assert = bind(flow, flow.assert); assert(new Fibonacci(f.sequence - 1)); }), this.rule("Boostrap", { scope: scope }, [ [ Fibonacci, "f", "f.value == -1 && (f.sequence == 1 || f.sequence == 2)" ] ], function(facts, flow) { var f = facts.f, f = facts.f, modify = bind(flow, flow.modify); modify(f, function() { this.value = 1; }); }), this.rule("Calculate", { scope: scope }, [ [ Fibonacci, "f1", "f1.value != -1", { sequence: "s1" } ], [ Fibonacci, "f2", "f2.value != -1 && f2.sequence == s1 + 1", { sequence: "s2" } ], [ Fibonacci, "f3", "f3.value == -1 && f3.sequence == s2 + 1" ], [ Result, "r" ] ], function(facts, flow) { var f1 = facts.f1, f1 = facts.f1, f2 = facts.f2, f2 = facts.f2, f3 = facts.f3, f3 = facts.f3, r = facts.r, modify = bind(flow, flow.modify), v = f1.value + f2.value; modify(f3, function() { this.value = r.value = v; }); }); }); }; })(); } if ("undefined" !== typeof exports) { if ("undefined" !== typeof module && module.exports) { module.exports = _getCompiled(require("../../")); } } else if ("function" === typeof define && define.amd) { define(["../../"], function (nools) { return _getCompiled(nools); }); } else { _getCompiled(this.nools)(); } }).call(this); +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("fibonacci-compiled",function(){var Fibonacci=defined.Fibonacci=this.addDefined("Fibonacci",function(){var Defined=function(sequence,value){this.sequence=sequence,this.value=value||-1},proto=Defined.prototype;return proto.sequence=null,proto.value=-1,proto.constructor=function(sequence,value){this.sequence=sequence,this.value=value||-1},Defined}()),Result=defined.Result=this.addDefined("Result",function(){var Defined=function(value){this.value=value},proto=Defined.prototype;return proto.value=0,proto.constructor=function(value){this.value=value},Defined}());scope.console=console,this.rule("Recurse",{scope:scope},[["not",Fibonacci,"nf","nf.sequence == 1"],[Fibonacci,"f","f.value == -1 && f.sequence != 1"]],function(facts,flow){var f=facts.f,f=facts.f,assert=flow.assert;assert(new Fibonacci(f.sequence-1))}),this.rule("Boostrap",{scope:scope},[[Fibonacci,"f","f.value == -1 && (f.sequence == 1 || f.sequence == 2)"]],function(facts,flow){var f=facts.f,f=facts.f,modify=flow.modify;modify(f,function(){this.value=1})}),this.rule("Calculate",{scope:scope},[[Fibonacci,"f1","f1.value != -1",{sequence:"s1"}],[Fibonacci,"f2","f2.value != -1 && f2.sequence == s1 + 1",{sequence:"s2"}],[Fibonacci,"f3","f3.value == -1 && f3.sequence == s2 + 1"],[Result,"r"]],function(facts,flow){var f1=facts.f1,f1=facts.f1,f2=facts.f2,f2=facts.f2,f3=facts.f3,f3=facts.f3,r=facts.r,modify=flow.modify,v=f1.value+f2.value;modify(f3,function(){this.value=r.value=v})})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file diff --git a/test/rules/getFacts-compiled.js b/test/rules/getFacts-compiled.js new file mode 100644 index 0000000..2d7455a --- /dev/null +++ b/test/rules/getFacts-compiled.js @@ -0,0 +1 @@ +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("getFacts-compiled",function(){scope.console=console,this.rule("getFacts1",{agendaGroup:"get-facts",scope:scope},[[Number,"n"],[String,"s"],[Boolean,"b"],[Date,"d"]],function(facts,flow){var n=facts.n,s=facts.s,b=facts.b,d=facts.d,retract=flow.retract,emit=flow.emit,getFacts=flow.getFacts;emit("get-facts",getFacts()),retract(n),retract(s),retract(b),retract(d)}),this.rule("getFacts2",{agendaGroup:"get-facts-by-type",scope:scope},[[Number,"n"],[String,"s"],[Boolean,"b"],[Date,"d"]],function(facts,flow){var n=facts.n,s=facts.s,b=facts.b,d=facts.d,String=defined.String,Number=defined.Number,Boolean=defined.Boolean,Date=defined.Date,retract=flow.retract,emit=flow.emit,getFacts=flow.getFacts;emit("get-facts-number",getFacts(Number)),emit("get-facts-string",getFacts(String)),emit("get-facts-boolean",getFacts(Boolean)),emit("get-facts-date",getFacts(Date)),retract(n),retract(s),retract(b),retract(d)})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file diff --git a/test/rules/getFacts.nools b/test/rules/getFacts.nools new file mode 100644 index 0000000..d0ea18f --- /dev/null +++ b/test/rules/getFacts.nools @@ -0,0 +1,36 @@ +rule getFacts1{ + agenda-group: "get-facts"; + when { + n: Number; + s: String; + b: Boolean; + d: Date; + } + then { + emit("get-facts", getFacts()); + retract(n); + retract(s); + retract(b); + retract(d); + } +} + +rule getFacts2{ + agenda-group: "get-facts-by-type"; + when { + n: Number; + s: String; + b: Boolean; + d: Date; + } + then { + emit("get-facts-number", getFacts(Number)); + emit("get-facts-string", getFacts(String)); + emit("get-facts-boolean", getFacts(Boolean)); + emit("get-facts-date", getFacts(Date)); + retract(n); + retract(s); + retract(b); + retract(d); + } +} \ No newline at end of file diff --git a/test/rules/global-compiled.js b/test/rules/global-compiled.js new file mode 100644 index 0000000..1a59d83 --- /dev/null +++ b/test/rules/global-compiled.js @@ -0,0 +1 @@ +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("global-compiled",function(){scope.assert=require("assert"),scope.globalNools=require("/Users/doug/git/nools/test/rules/global.js"),scope.PI=Math.PI,scope.SOME_STRING="some string",scope.TRUE=!0,scope.NUM=1.23,scope.DATE=new Date,scope.console=console,this.rule("EmitGlobals",{scope:scope},[[String,"s"]],function(facts,flow){facts.s;var assert=scope.assert,globalNools=scope.globalNools,PI=scope.PI,SOME_STRING=scope.SOME_STRING,TRUE=scope.TRUE,NUM=scope.NUM,DATE=scope.DATE,retract=flow.retract,emit=flow.emit;emit("globals",{assert:assert,globalNools:globalNools,PI:PI,SOME_STRING:SOME_STRING,NUM:NUM,TRUE:TRUE,DATE:DATE}),retract(b)})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file diff --git a/test/rules/import-compiled.js b/test/rules/import-compiled.js new file mode 100644 index 0000000..f88b1c5 --- /dev/null +++ b/test/rules/import-compiled.js @@ -0,0 +1 @@ +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("import-compiled",function(){var Count=defined.Count=this.addDefined("Count",function(){var Defined=function(){this.called=0},proto=Defined.prototype;return proto.constructor=function(){this.called=0},Defined}());scope.console=console,this.rule("orRule",{scope:scope},[["or",[String,"s","s == 'hello'"],[String,"s","s == 'world'"]],[Count,"count"]],function(facts){var s=facts.s,s=facts.s,s=facts.s,s=facts.s,count=facts.count;count.called++,count.s=s}),this.rule("notRule",{scope:scope},[["not",String,"s","s == 'hello'"],[Count,"count"]],function(facts){var count=facts.count;count.called++})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file diff --git a/test/rules/notRule-compiled.js b/test/rules/notRule-compiled.js index 32bb707..2257964 100644 --- a/test/rules/notRule-compiled.js +++ b/test/rules/notRule-compiled.js @@ -1 +1 @@ -(function(){ function _getCompiled(nools){ return (function() { return function(options) { options = options || {}; var defined = options.defined || {}, scope = options.scope || {}; return nools.flow("notRule-compiled", function() { var Count = defined.Count = this.addDefined("Count", function() { var Defined = function() { this.called = 0; }, proto = Defined.prototype; return proto.constructor = function() { this.called = 0; }, Defined; }()); this.rule("hello", { scope: scope }, [ [ "not", String, "s", "s == 'hello'" ], [ Count, "count" ] ], function(facts) { var count = facts.count; count.called++; }); }); }; })(); } if ("undefined" !== typeof exports) { if ("undefined" !== typeof module && module.exports) { module.exports = _getCompiled(require("../../")); } } else if ("function" === typeof define && define.amd) { define(["../../"], function (nools) { return _getCompiled(nools); }); } else { _getCompiled(this.nools)(); } }).call(this); +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("notRule-compiled",function(){var Count=defined.Count=this.addDefined("Count",function(){var Defined=function(){this.called=0},proto=Defined.prototype;return proto.constructor=function(){this.called=0},Defined}());scope.console=console,this.rule("hello",{scope:scope},[["not",String,"s","s == 'hello'"],[Count,"count"]],function(facts){var count=facts.count;count.called++})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file diff --git a/test/rules/orRule-compiled.js b/test/rules/orRule-compiled.js index facf0b4..70747bc 100644 --- a/test/rules/orRule-compiled.js +++ b/test/rules/orRule-compiled.js @@ -1 +1 @@ -(function(){ function _getCompiled(nools){ return (function() { return function(options) { options = options || {}; var defined = options.defined || {}, scope = options.scope || {}; return nools.flow("orRule-compiled", function() { var Count = defined.Count = this.addDefined("Count", function() { var Defined = function() { this.called = 0; }, proto = Defined.prototype; return proto.constructor = function() { this.called = 0; }, Defined; }()); scope.console = console, this.rule("hello", { scope: scope }, [ [ "or", [ String, "s", "s == 'hello'" ], [ String, "s", "s == 'world'" ] ], [ Count, "count" ] ], function(facts, flow) { with (flow) { var s = facts.s, s = facts.s, s = facts.s, s = facts.s, count = facts.count; count.called++, count.s = s; } }); }); }; })(); } if ("undefined" !== typeof exports) { if ("undefined" !== typeof module && module.exports) { module.exports = _getCompiled(require("../../")); } } else if ("function" === typeof define && define.amd) { define(["../../"], function (nools) { return _getCompiled(nools); }); } else { _getCompiled(this.nools)(); } }).call(this); +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("orRule-compiled",function(){var Count=defined.Count=this.addDefined("Count",function(){var Defined=function(){this.called=0},proto=Defined.prototype;return proto.constructor=function(){this.called=0},Defined}());scope.console=console,this.rule("hello",{scope:scope},[["or",[String,"s","s == 'hello'"],[String,"s","s == 'world'"]],[Count,"count"]],function(facts){var s=facts.s,s=facts.s,s=facts.s,s=facts.s,count=facts.count;count.called++,count.s=s})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file diff --git a/test/rules/orRule-notConditions-compiled.js b/test/rules/orRule-notConditions-compiled.js index 7c50625..f7136f6 100644 --- a/test/rules/orRule-notConditions-compiled.js +++ b/test/rules/orRule-notConditions-compiled.js @@ -1,19 +1 @@ -(function(){ - function _getCompiled(nools){ - return (function(){return function(options){options = options || {};var bind = function(scope, fn){return function(){return fn.apply(scope, arguments);};}, defined = options.defined || {}, scope = options.scope || {};return nools.flow('orRule-notConditions-compiled', function(){var Count = defined.Count = this.addDefined('Count', (function(){var Defined = function (){ this.called = 0; };var proto = Defined.prototype;proto.constructor = function (){ this.called = 0; };return Defined;}()));scope.console = console; -this.rule('MultiNotOrRule',{"scope":scope}, [["or",["not", Number, "n1","n1 == 1"],["not", String, "s1","s1 == 'hello'"],["not", Date, "d1","d1.getDate() == now().getDate()"]],[Count, "c"]],function(facts,flow){with(flow){var c= facts.c;c.called++; }});});};}()); - } - - if ("undefined" !== typeof exports) { - if ("undefined" !== typeof module && module.exports) { - module.exports = _getCompiled(require("../../")); - } - } else if ("function" === typeof define && define.amd) { - define(["../../"], function (nools) { - return _getCompiled(nools); - }); - } else { - _getCompiled(this.nools)(); - } - -}).call(this); +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("orRule-notConditions-compiled",function(){var Count=defined.Count=this.addDefined("Count",function(){var Defined=function(){this.called=0},proto=Defined.prototype;return proto.constructor=function(){this.called=0},Defined}());scope.console=console,this.rule("MultiNotOrRule",{scope:scope},[["or",["not",Number,"n1","n1 == 1"],["not",String,"s1","s1 == 'hello'"],["not",Date,"d1","d1.getDate() == now().getDate()"]],[Count,"c"]],function(facts){var c=facts.c;c.called++})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file diff --git a/test/rules/provided-scope-compiled.js b/test/rules/provided-scope-compiled.js new file mode 100644 index 0000000..73738df --- /dev/null +++ b/test/rules/provided-scope-compiled.js @@ -0,0 +1 @@ +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("provided-scope-compiled",function(){var Message=defined.Message=this.addDefined("Message",function(){var Defined=function(message){this.message=message},proto=Defined.prototype;return proto.message="",proto.constructor=function(message){this.message=message},Defined}());scope.console=console,this.rule("Hello",{scope:scope},[[Message,"m","doesMatch(m.message, /^hello(\\s*world)?$/)"]],function(facts,flow){var m=facts.m,m=facts.m,modify=flow.modify;modify(m,function(){this.message+=" goodbye"})}),this.rule("Goodbye",{scope:scope},[[Message,"m","doesMatch(m.message, /.*goodbye$/)"]],function(){})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file diff --git a/test/rules/scope-compiled.js b/test/rules/scope-compiled.js index a7eadcd..bf7e0c5 100644 --- a/test/rules/scope-compiled.js +++ b/test/rules/scope-compiled.js @@ -1 +1 @@ -(function(){ function _getCompiled(nools){ return (function() { return function(options) { options = options || {}; var bind = function(scope, fn) { return function() { return fn.apply(scope, arguments); }; }, defined = options.defined || {}, scope = options.scope || {}; return nools.flow("scope-compiled", function() { var Message = defined.Message = this.addDefined("Message", function() { var Defined = function(message) { this.message = message; }, proto = Defined.prototype; return proto.message = "", proto.constructor = function(message) { this.message = message; }, Defined; }()); scope.matches = function(str, regex) { return regex.test(str); }, this.rule("Hello", { scope: scope }, [ [ Message, "m", "matches(m.message, /^hello(\\s*world)?$/)" ] ], function(facts, flow) { var m = facts.m, m = facts.m, modify = bind(flow, flow.modify); modify(m, function() { this.message += " goodbye"; }); }), this.rule("Goodbye", { scope: scope }, [ [ Message, "m", "matches(m.message, /.*goodbye$/)" ] ], function() {}); }); }; })(); } if ("undefined" !== typeof exports) { if ("undefined" !== typeof module && module.exports) { module.exports = _getCompiled(require("../../")); } } else if ("function" === typeof define && define.amd) { define(["../../"], function (nools) { return _getCompiled(nools); }); } else { _getCompiled(this.nools)(); } }).call(this); +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("scope-compiled",function(){var Message=defined.Message=this.addDefined("Message",function(){var Defined=function(message){this.message=message},proto=Defined.prototype;return proto.message="",proto.constructor=function(message){this.message=message},Defined}());scope.matches=function(str,regex){return regex.test(str)},scope.console=console,this.rule("Hello",{scope:scope},[[Message,"m","matches(m.message, /^hello(\\s*world)?$/)"]],function(facts,flow){var m=facts.m,m=facts.m,modify=flow.modify;modify(m,function(){this.message+=" goodbye"})}),this.rule("Goodbye",{scope:scope},[[Message,"m","matches(m.message, /.*goodbye$/)"]],function(){})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file diff --git a/test/rules/simple-compiled.js b/test/rules/simple-compiled.js index 1d68d63..4f6c29a 100644 --- a/test/rules/simple-compiled.js +++ b/test/rules/simple-compiled.js @@ -1 +1 @@ -(function(){ function _getCompiled(nools){ return (function() { return function(options) { options = options || {}; var bind = function(scope, fn) { return function() { return fn.apply(scope, arguments); }; }, defined = options.defined || {}, scope = options.scope || {}; return nools.flow("simple-compiled", function() { var Message = defined.Message = this.addDefined("Message", function() { var Defined = function(message) { this.message = message; }, proto = Defined.prototype; return proto.message = "", proto.constructor = function(message) { this.message = message; }, Defined; }()); this.rule("Hello", { scope: scope }, [ [ Message, "m", "m.message =~ /^hello(\\s*world)?$/" ] ], function(facts, flow) { var m = facts.m, m = facts.m, modify = bind(flow, flow.modify); modify(m, function() { this.message += " goodbye"; }); }), this.rule("Goodbye", { scope: scope }, [ [ Message, "m", "m.message =~ /.*goodbye$/" ] ], function(facts, flow) { var m = facts.m, m = facts.m, emit = bind(flow, flow.emit); emit("found-goodbye", m); }); }); }; })(); } if ("undefined" !== typeof exports) { if ("undefined" !== typeof module && module.exports) { module.exports = _getCompiled(require("../../")); } } else if ("function" === typeof define && define.amd) { define(["../../"], function (nools) { return _getCompiled(nools); }); } else { _getCompiled(this.nools)(); } }).call(this); +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("simple-compiled",function(){var Message=defined.Message=this.addDefined("Message",function(){var Defined=function(message){this.message=message},proto=Defined.prototype;return proto.message="",proto.constructor=function(message){this.message=message},Defined}());scope.console=console,this.rule("Hello",{scope:scope},[[Message,"m","m.message =~ /^hello(\\s*world)?$/"]],function(facts,flow){var m=facts.m,m=facts.m,modify=flow.modify;modify(m,function(){this.message+=" goodbye"})}),this.rule("Goodbye",{scope:scope},[[Message,"m","m.message =~ /.*goodbye$/"]],function(facts,flow){var m=facts.m,m=facts.m,emit=flow.emit;emit("found-goodbye",m)})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file diff --git a/test/rules/simple-external-defined-compiled.js b/test/rules/simple-external-defined-compiled.js new file mode 100644 index 0000000..0de1d94 --- /dev/null +++ b/test/rules/simple-external-defined-compiled.js @@ -0,0 +1 @@ +!function(){function _getCompiled(nools){return function(){return function(options){options=options||{};var defined={Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},scope=options.scope||{},optDefined=options.defined||{};for(var i in optDefined)defined[i]=optDefined[i];return nools.flow("simple-external-defined-compiled",function(){scope.console=console,this.rule("Hello",{scope:scope},[[Message,"m","m.message =~ /^hello(\\s*world)?$/"]],function(facts,flow){var m=facts.m,m=facts.m,modify=flow.modify;modify(m,function(){this.message+=" goodbye"})}),this.rule("Goodbye",{scope:scope},[[Message,"m","m.message =~ /.*goodbye$/"]],function(facts,flow){var m=facts.m,m=facts.m,emit=flow.emit;emit("found-goodbye",m)})})}}()}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=_getCompiled(require("../../"))):"function"==typeof define&&define.amd?define(["../../"],function(nools){return _getCompiled(nools)}):_getCompiled(this.nools)()}.call(this); \ No newline at end of file