-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuseless.micro.min.js
130 lines (130 loc) · 57.7 KB
/
useless.micro.min.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
"undefined"!==typeof require&&(_=require("underscore"),$include=require);_=function(){_.mixin({zipWith:function(a,b){return _.reduce(_.rest(a),function(a,d){return _.times(Math.max(a&&a.length||0,d&&d.length||0),function(e){return b(a&&a[e],d&&d[e])})},_.first(a))}});if("a1 b2 c3"!==_.zipWith([["a","b","c"],[1,2,3]],function(a,b){return a+b}).join(" "))throw Error("_.zipWith broken");return _}();_.tests={};_.deferTest=_.withTest=function(a,b,c){c()};
_.platform=function(){return"undefined"!==typeof window&&window._.platform===arguments.callee&&navigator.platform&&navigator.platform.indexOf?_.extend({engine:"browser"},0<=navigator.platform.indexOf("Linux arm")||0<=navigator.platform.indexOf("Android")||0<=navigator.userAgent.indexOf("Android")?{touch:!0,system:"Android"}:0<=navigator.platform.indexOf("iPad")?{touch:!0,system:"iOS",device:"iPad"}:0<=navigator.platform.indexOf("iPhone")||0<=navigator.platform.indexOf("iPod")?{touch:!0,system:"iOS",
device:"iPhone"}:{}):"undefined"!==typeof global&&global._.platform===arguments.callee?{engine:"node"}:{}};_.global=function(){return"browser"===_.platform().engine?window:"node"===_.platform().engine?global:void 0};_.defineGlobalProperty=function(a,b,c){if(void 0!==_.global()[a])throw Error("cannot defineGlobalProperty: "+a+" is already there");Object.defineProperty(_.global(),a,_.extend({enumerable:!0,get:_.isFunction(b)&&0===b.length?b:_.constant(b)},c));return b};
$overrideUnderscore=function(a,b){return _[a]=b(_[a])};"browser"!==_.platform().engine&&_.defineGlobalProperty("alert",function(a){var b=_.global().log&&_.partial(log.warn,log.config({stackOffset:2}))||console.log;b.apply(b,["ALERT:"].concat(_.asArray(arguments)))});_.defineGlobalProperty("alert2",function(a){alert(_.map(arguments,_.stringify).join(", "));return arguments[0]});_.extend(_,{asArray:function(a){return[].splice.call(a,0)}});
_.extend(_,{numArgs:function(a){return void 0===a._ac?a.length:a._ac},restArg:function(a){return a._ra||!1},noArgs:function(a){return 0===_.numArgs(a)&&!a._ra},hasArgs:function(a){return 0<_.numArgs(a)&&!a._ra},oneArg:function(a){return 1===_.numArgs(a)&&!a._ra},withRestArg:_.defineGlobalProperty("$restArg",function(a){Object.defineProperty(a,"_ra",{enumerable:!1,writable:!0,value:!0});return a}),withArgs:function(a,b,c){void 0!==a&&Object.defineProperty(c,"_ac",{enumerable:!1,writable:!0,value:a});
void 0!==b&&Object.defineProperty(c,"_ra",{enumerable:!1,writable:!0,value:b});return c},withSameArgs:function(a,b){return _.withArgs(_.numArgs(a),_.restArg(a),b)}});$overrideUnderscore("memoize",function(a){return function(b){return _.withSameArgs(b,a(b))}});$overrideUnderscore("partial",function(a){return $restArg(function(b){return _.withArgs(Math.max(0,_.numArgs(b)-(arguments.length-1)),b._ra,a.apply(this,arguments))})});
$overrideUnderscore("bind",function(a){return $restArg(function(b,c){return _.withArgs(Math.max(0,_.numArgs(b)-(arguments.length-2)),b._ra,a.apply(this,arguments))})});_.arity=function(a,b){return function(){return b.apply(this,_.first(arguments,a))}};_.arity0=function(a){return function(){return a.call(this)}};_.arity1=function(a){return function(b){return a.call(this,b)}};_.arity2=function(a){return function(b,c){return a.call(this,b,c)}};
_.arity3=function(a){return function(b,c,d){return a.call(this,b,c,d)}};_.arityFn=function(a){return _["arity"+a]};_.tails=$restArg(function(a){var b=_.rest(arguments);return function(){return a.apply(this,_.asArray(arguments).concat(b))}});_.tails2=$restArg(function(a){var b=_.rest(arguments);return function(c){return a.apply(this,[c].concat(b))}});_.tails3=$restArg(function(a){var b=_.rest(arguments);return function(c,d){return a.apply(this,[c,d].concat(b))}});
_.flip=function(a){if(_.restArg(a))return $restArg(function(){return a.apply(this,_.asArray(arguments).reverse())});switch(_.numArgs(a)){case 0:case 1:return a;case 2:return _.flip2(a);case 3:return _.flip3(a);default:throw Error("flip: unsupported arity");}};_.flip2=function(a){return function(b,c){return a.call(this,c,b)}};_.flip3=function(a){return function(b,c,d){return a.call(this,d,c,b)}};_.or=function(a,b){return function(){return a.apply(this,arguments)||b.apply(this,arguments)}};
_.and=function(a,b){return function(){return a.apply(this,arguments)&&b.apply(this,arguments)}};_.not=function(a){return function(){return!a.apply(this,arguments)}};_.extend(_,{Y:function(a){var b=a(function(){return b.apply(this,arguments)});return b}});
(function(){_.hyperOperator=function(a,b,c,d){var e=_.arityFn(a)||_.identity,g=(c||_.goDeeperWhenFirstArgumentIsGood)(a,d||_.isNonTrivial);return function(){var a=_.last(arguments);return _.Y(function(c){var d=_.tails(b,e(c));return function(){return(g(arguments)?d:a).apply(this,arguments)}}).apply(this,_.initial(arguments))}};_.goDeeperWhenFirstArgumentIsGood=function(a,b){return function(a){return 0<a.length?b(a[0]):!1}};_.goDeeperAlwaysIfPossible=function(a,b){return 0===a?_.constant(!1):1===a?
function(a){return b(a[0])}:2===a?function(a){return b(a[0])||b(a[1])}:function(a){return _.some(_.asArray(a),b)}};_.goDeeperOnlyWhenNessesary=function(a,b){return 0===a?_.constant(!1):1===a?function(a){return b(a[0])}:2===a?function(a){return b(a[0])&&b(a[1])}:function(a){return _.every(_.asArray(a),b)}};_.isTrivial=function(a){return _.isEmpty(a)||_.isString(a)||_.isNumber(a)||!(_.isStrictlyObject(a)||_.isArray(a))||_.isPrototypeInstance(a)||_.isMeta(a)};_.isMeta=_.constant(!1);_.isNonTrivial=_.not(_.isTrivial);
_.binary=2;_.unary=1})();_.higherOrder=function(a){return _.partial(_.partial,a)};_.eval=function(a){return _.isFunction(a)?a.call(this):a};_.evals=function(a){var b=arguments;return function(a){return _.isFunction(a)?a.apply(this,b):a}};_.method=function(a){var b=_.rest(arguments);return function(c){return c[a].apply(c,b)}};_.asFreeFunction=function(a){return function(b,c){return a.apply(b,_.rest(arguments))}};_.asMethod=function(a){return function(){return a.apply(void 0,[this].concat(_.asArray(arguments)))}};
_.wrapper=function(a,b){return _.withSameArgs(a,function(){var c=this,d=arguments;return b(function(b){a.apply(c,_.asArray(d).concat(b))})})};_.once=function(a){var b=!1;return function(){if(!b)return b=!0,a.apply(this,arguments)}};_.withTimeout=function(a,b,c){var d=!1,e=setTimeout(function(){d=!0;a.expired&&a.expired(c)},a.maxTime);b(function(){d||(clearTimeout(e),c&&c.apply(this,arguments))})};
_.sequence=function(a){var b=_.isArray(a)?a:_.asArray(arguments),c=b.length;return 0===c?_.identity:function(a){for(var e=0;e<c;e++)a=b[e].call(this,a);return a}};_.seq=_.sequence;_.then=function(a,b){return function(c){return b.call(this,a.apply(this,arguments))}};_.makes=function(a){return function(){switch(arguments.length){case 0:return new a;case 1:return new a(arguments[0]);case 2:return new a(arguments[0],arguments[1]);default:throw Error("not supported");}}};
_.asString=function(a){return a+""};_.typeOf=function(a){return typeof a};_.count=function(a){return a.length};_.array=_.tuple=function(){return _.asArray(arguments)};_.concat=function(a,b){return _.isArray(a)?a.concat([b]):a+b};_.atIndex=function(a){return function(b){return b[a]}};_.applies=function(a,b,c){return function(){return a.apply(b,c)}};_.prepends=function(a){return function(b){return a+b}};_.appends=function(a){return function(b){return b+a}};_.join=function(a,b){return a.join(b)};
_.joinWith=_.flip2(_.join);_.joinsWith=_.higherOrder(_.joinWith);_.sum=function(a,b){return(a||0)+(b||0)};_.subtract=function(a,b){return(a||0)-(b||0)};_.mul=function(a,b){return(a||0)*(b||0)};_.equal=function(a,b){return a===b};_.sums=_.plus=_.higherOrder(_.sum);_.subtracts=_.minus=_.higherOrder(_.subtract);_.muls=_.higherOrder(_.mul);_.equals=_.higherOrder(_.equal);_.largest=function(a,b){return isNaN(a)&&isNaN(b)?NaN:isNaN(a)?b:isNaN(b)?a:Math.max(a,b)};_.notZero=function(a){return 0!==a};
_.propertyOf=function(a){return function(b){return a[b]}};_.isInstanceofSyntaxAvailable=function(){var a=Error();try{return a instanceof Error}catch(b){return!1}};_.isTypeOf_ES4=function(a,b){for(;b;){if(b.constructor===a)return!0;b=b.constructor.$base}return!1};_.isTypeOf_ES5=function(a,b){return b instanceof a};_.isTypeOf=_.isInstanceofSyntaxAvailable()?_.isTypeOf_ES5:_.isTypeOf_ES4;_.isPrototypeInstance=function(a){return a&&a.constructor&&_.isPrototypeConstructor(a.constructor)};
_.isPrototypeConstructor=function(a){return a&&void 0!==a.$definition||!1};_.coerceToArray=function(a){return void 0===a?[]:_.isArray(a)?a:[a]};$overrideUnderscore("isArray",function(a){return function(b){return _.isTypeOf(Array,b)||a(b)}});
_.mixin({matches:function(a){return 0===arguments.length&&_.constant(!0)||_.tails2(_.match,a)},match:function(a,b){return a===b||_.isArray(a)&&_.isArray(b)&&_.arrayMatch(a,b)||_.isObject(a)&&_.isObject(b)&&_.objectMatch(a,b)||_.isTypeOf(RegExp,b)&&_.isString(a)&&null!==a.match(b)},arrayMatch:function(a,b){return _.every(b,_.propertyOf(_.index(a)))},objectMatch:function(a,b){return _.reduce(_.pairs(b),function(b,d){return b&&_.match(a[d[0]],d[1])},!0)}});
_.extend(_,{isNonPOD:function(a){return a&&a.constructor&&a.constructor!==Object&&a.constructor!==Array&&a.constructor!==String&&a.constructor!==Number&&a.constructor!==Boolean},isPOD:function(a){return!_.isNonPOD(a)}});"undefined"===typeof Number.EPSILON&&Object.defineProperty(Number,"EPSILON",{enumerable:!0,get:_.constant(2.220446049250313E-16)});_.extend(_,{isDecimal:function(a,b){return!_.isNumber(a)||_.isNaN(a)?!1:Math.abs(Math.floor(a)-a)>(b||Number.EPSILON)}});
_.extend(_,{isEmpty:function(a){return void 0===_.coerceToUndefined(a)},isNonempty:function(a){return void 0!==_.coerceToUndefined(a)},isEmptyObject:function(a){return!_.isArray(a)&&!_.isFunction(a)&&_.isObject(a)&&0===_.keys(a).length},isStrictlyObject:function(a){return a&&"object"===typeof a?!0:!1},isEmptyArray:function(a){return _.isArray(a)&&0===a.length},isNonemptyString:function(a){return"string"===typeof a&&0<a.length},coerceToEmpty:function(a){if(_.isArray(a))return[];if(_.isStrictlyObject(a))return{}},
coerceToUndefined:function(a){return void 0===a||null===a||a===Math.NaN||""===a||_.isPOD(a)&&(_.isEmptyObject(a)||0===a.length)?void 0:a}});_.json=function(a){if("string"===typeof a)try{return JSON.parse(a)}catch(b){return{}}else return JSON.stringify(a)};_.stringify=function(a,b){return _.stringifyImpl(a,[],[],0,b||{},-1)};
_.stringifyImpl=function(a,b,c,d,e,g){if(a===$global)return"$global";var f=e.formatter&&e.formatter(a);if(f)return f;if(0<=b.indexOf(a))return e.pure?void 0:"<cyclic>";if(0<=c.indexOf(a))return e.pure?void 0:"<ref:"+c.indexOf(a)+">";if(void 0===a)return"undefined";if(null===a)return"null";if(_.isFunction(a))return e.pure?a.toString():_.isPrototypeConstructor(a)?"<prototype>":"<function>";if("string"===typeof a)return _.quoteWith('"',a);if(!_.isObject(a)||"undefined"!==typeof $atom&&$atom.is(a))return _.isDecimal(a)&&
0<e.precision?_.toFixed(a,e.precision):a+"";var h=_.isArray(a),f=e.pretty||!1;if("browser"===_.platform().engine){if(_.isTypeOf(Element,a))return"<"+a.tagName.lowercase+">";if(_.isTypeOf(Text,a))return"@"+a.wholeText}if(a.toJSON)return _.quoteWith('"',a.toJSON());if(!e.pure&&(d>(e.maxDepth||5)||h&&a.length>(e.maxArrayLength||30)))return h?"<array["+a.length+"]>":"<object>";var k=b.concat([a]);c.push(a);b=_.pairs(a);var m=!f||2>b.length,l=g+1,n=m?"":"\t".repeats(l);if(f&&!h){var p=_.reduce(_.map(_.keys(a),
_.count),_.largest,0);b=_.map(b,function(a){return[a[0],a[1]," ".repeats(p-a[0].length)]})}return _.quoteWith(h?m?"[]":"[\n ]":m?"{ }":"{\n }",_.joinWith(m?", ":",\n",_.map(b,function(a){return n+(h?"":a[0]+": "+(a[2]||""))+_.stringifyImpl(a[1],k,c,d+1,e,l)})))};_.toFixed=function(a,b){return a&&a.toFixed&&a.toFixed(b)||void 0};_.toFixed2=function(a){return _.toFixed(a,2)};_.toFixed3=function(a){return _.toFixed(a,3)};_.hasStdlib=!0;
_.extend(_,{throwsError:function(a){return function(){throw Error(a);}}});_.overrideThis=_.throwsError("override this");_.notImplemented=_.throwsError("not implemented");_.mixin({tryEval:function(a,b,c){var d=void 0;try{d=a()}catch(e){d=b&&b(e)}return c?c(d):d}});_.mixin({values2:function(a){return _.isArray(a)?a:_.isStrictlyObject(a)?_.values(a):_.isEmpty(a)?[]:[a]}});_.mixin({map2:function(a,b,c){return _.isArray(a)?_.map(a,b,c):_.isStrictlyObject(a)?_.mapObject(a,b,c):b.call(c,a)}});
_.mixin({mapMap:_.hyperOperator(_.unary,_.map2)});_.mixin({reject2:function(a,b){return _.filter2(a,_.not(b))},filter2:function(a,b){if(_.isArray(a)){for(var c=[],d=0,e=a.length;d<e;d++){var g=a[d],f=b(g,d);!0===f?c.push(g):!1!==f&&c.push(f)}return c}if(_.isStrictlyObject(a))return c={},_.each(Object.keys(a),function(d){var e=a[d],g=b(e,d);!0===g?c[d]=e:!1!==g&&(c[d]=g)}),c;f=b(a);if(!0===f)return a;if(!1!==f)return f}});_.mixin({filterFilter:_.hyperOperator(_.unary,_.filter2)});
_.reduce2=function(a,b,c){var d=_.last(arguments),e=function(a,b){var c=void 0!==b,e=c?d(a,b):a;return void 0===e?c?b:a:e};if(_.isArray(a))for(var g=0,f=a.length;g<f;g++)b=e(a[g],b);else _.isStrictlyObject(a)?_.each(Object.keys(a),function(c){b=e(a[c],b)}):b=e(a,b);return b};_.reduceReduce=function(a,b,c){return _.hyperOperator(_.binary,_.reduce2,_.goDeeperAlwaysIfPossible)(b,a,c.flip2)};
_.mixin({zipObjectsWith:function(a,b){return _.reduce(_.rest(a),function(a,d){_.each(_.union(_.keys(d),_.keys(a)),function(e){var g=b(a&&a[e],d&&d[e]);void 0===g?delete a[e]:a[e]=g});return a},_.clone(a[0]))},zip2:function(a,b){var c=2===arguments.length?a:_.initial(arguments),d=2===arguments.length?b:_.last(arguments);return _.isArray(c)&&0!==c.length?_.isArray(c[0])?_.zipWith(c,d):_.isStrictlyObject(c[0])?_.zipObjectsWith(c,d):_.reduce(c,d):c}});_.mixin({zipZip:_.hyperOperator(_.binary,_.zip2)});
_.findFind=function(a,b){return _.hyperOperator(_.unary,function(a,d){if(_.isArray(a))for(var e=0,g=a.length;e<g;e++){var f=d(a[e]);if("boolean"!==typeof f)return f;if(!0===f)return a[e]}else if(_.isStrictlyObject(a))for(var e=0,h=Object.keys(a),g=h.length;e<g;e++){var k=h[e],f=d(a[k]);if("boolean"!==typeof f)return f;if(!0===f)return a[k]}f=b(a);return"boolean"!==typeof f?f:!0===f?a:!1})(a,b)};_.extend=$restArg(_.extend);_.extendWith=_.flip(_.extend);_.extendsWith=_.flip(_.partial(_.partial,_.flip(_.extend)));
_.extend2=$restArg(function(a){return _.extend(a,_.reduceRight(arguments,function(a,c){return _.object(_.map(_.union(_.keys(c),_.keys(a)),function(d){var e=c[d];return[d,d in a?"object"===typeof e?_.extend(e,a[d]):a[d]:e]}))},{}))});_.nonempty=function(a){return _.filter2(a,_.isNonempty)};_.extend(_,{cloneDeep:_.tails2(_.mapMap,_.clone)});_.hyperMatch=_.hyperOperator(_.binary,function(a,b,c){return _.coerceToUndefined(_.nonempty(_.zip2(a,b,c)))});
_.diff=_.tails3(_.hyperMatch,function(a,b){return $atom.unwrap(a)===$atom.unwrap(b)||a===$any||b===$any?void 0:b});_.hyperMatch=_.hyperOperator(_.binary,function(a,b,c){return _.coerceToUndefined(_.zip2(a,b,c))});_.undiff=_.tails3(_.hyperMatch,function(a,b){return $atom.unwrap(a)===$atom.unwrap(b)||a===$any||b===$any?b:void 0});_.extend(_,{index:function(a){for(var b={},c=0,d=a.length;c<d;c++)b[a[c]]=!0;return b}});
_.quote=function(a,b){var c=b||'"',d=c.slice(0,Math.floor(c.length/2+c.length%2)),c=c.slice(c.length/2)||d;return d+a+c};_.quoteWith=_.flip2(_.quote);_.quotesWith=_.higherOrder(_.quoteWith);_.partition2=function(a,b){var c=void 0,d=[],e=[];_.each(a,function(a){var f=b(a);c!=f&&e.length&&(d.push(e),e=[]);e.push(a);c=f});e.length&&d.push(e);return d};_.key=function(a){return function(b,c){return a(c)}};_.filterKeys=function(a,b){return _.filter(a,function(a,d){return b(d)})};
_.rejectKeys=function(a,b){return _.reject(a,function(a,d){return b(d)})};_.pickKeys=function(a,b){return _.pick(a,function(a,d){return b(d)})};_.omitKeys=function(a,b){return _.omit(a,function(a,d){return b(d)})};
_.extend(_,{defineProperty:function(a,b,c,d){if(Object.hasOwnProperty(a,b))throw Error("_.defineProperty: targetObject already has property "+b);Object.defineProperty(a,b,_.extend({enumerable:!0},d,_.coerceToPropertyDefinition(c,b)))},defineHiddenProperty:function(a,b,c,d){return _.defineProperty(a,b,c,_.extend({enumerable:!1},d))},defineMemoizedProperty:function(a,b,c,d){c=_.coerceToPropertyDefinition(c,b);return _.defineProperty(a,b,_.extend({},c,{get:_.memoizeToThis("_"+b,c.get)}),d)},defineProperties:function(a,
b){_.each(b,_.defineProperty.partial(a).flip2)},memoizeToThis:function(a,b){return function(){var c=this[a];return void 0!==c?c:this[a]=b.call(this)}},coerceToPropertyDefinition:function(a,b){var c=a||{},d="undefined"===typeof Tags?a:Tags.unwrap(a);return!c.$constant&&!c.$get&&_.isPropertyDefinition(d)&&d||(c.$get||!c.$constant&&_.isFunction(d)&&_.noArgs(d))&&{get:d,set:_.throwsError("cannot change "+(b||"property")+" (as it's an accessor function)")}||!c.$get&&{get:_.constant(d),set:_.throwsError("cannot change "+
(b||"property")+" (as it's sealed to "+d+")")}||_.throwsError("coerceToPropertyDefinition: crazy input, unable to match")()},isPropertyDefinition:function(a){return _.isObject(a)&&(_.isFunction(a.get)||_.isFunction(a.set))},ownProperties:function(a){return a&&_.pickKeys(a,a.hasOwnProperty.bind(a))||{}}});
Tags=_.extend2(function(a){void 0!==a&&(this.subject=a)},{$definition:{},prototype:{add:function(a){return this[_.keyword(a)]=!0,this},clone:function(){return _.extend(new Tags(this.subject),_.pick(this,_.keyIsKeyword))},modifySubject:function(a){this.subject=a(this.subject);return _.isTypeOf(Tags,this.subject)?_.extend(this.subject,_.pick(this,_.keyIsKeyword)):this}},get:function(a){return _.isTypeOf(Tags,a)?_.pick(a,_.keyIsKeyword):{}},hasSubject:function(a){return _.isTypeOf(Tags,a)&&"subject"in
a},matches:function(a){return _.matches(_.object([[_.keyword(a),!0]]))},unwrapAll:function(a){return _.map2(a,Tags.unwrap)},unwrap:function(a){return _.isTypeOf(Tags,a)?a.subject:a},wrap:function(a){return _.isTypeOf(Tags,a)?a:0===arguments.length?new Tags:new Tags(a)},modifySubject:function(a,b){return _.isTypeOf(Tags,a)?a.clone().modifySubject(b):b(a)},map:function(a,b){return Tags.modifySubject(a,function(a){return _.map2(a,function(a,c){return Tags.modifySubject(a,function(g){return b(g,c,_.isTypeOf(Tags,
a)?a:void 0)})})})},add:function(a,b){return Tags.wrap.apply(null,_.rest(arguments,1)).add(a)}});_.keyword=function(a){return"$"+a};_.isKeyword=function(a){return"$"==a[0]};_.keywordName=function(a){return _.isKeyword(a)?a.slice(1):a};_.keywords=function(a){return _.pick(a,_.keyIsKeyword)};_.tagKeywords={};_.isTagKeyword=function(a){return _.keywordName(a)in _.tagKeywords};_.keyIsKeyword=function(a,b){return _.isKeyword(b[0])};
_.defineKeyword=function(a,b){_.defineProperty(_.global(),_.keyword(a),b)};_.defineKeyword("global",_.global);_.defineKeyword("platform",_.platform);
_.defineTagKeyword=function(a){_.keyword(a)in $global||(_.defineKeyword(a,Tags.add("constant",_.extend(_.partial(Tags.add,a),{matches:Tags.matches(a)}))),_.tagKeywords[a]=!0);var b=_.keyword(a);return _.extend($global[b],{is:function(a){return _.isTypeOf(Tags,a)&&b in a||!1},isNot:function(a){return!(_.isTypeOf(Tags,a)&&b in a)||!1},unwrap:function(a){return!0===$atom.matches(a)?Tags.unwrap(a):a}})};_(["constant","get"]).each(_.defineTagKeyword);
_.defineModifierKeyword=function(a,b){_.defineKeyword(a,function(a){return Tags.modifySubject(a,b)})};_.deleteKeyword=function(a){delete $global[_.keyword(a)]};_.cps=function(){return _.cps.sequence.apply(null,arguments)};_.cps.apply=function(a,b,c,d){c=_.asArray(c);var e=_.numArgs(a)-1,g=c[e];c[e]=function(){d.call(this,arguments,g)};return a.apply(b,c)};
_.extend(_.cps,{each:function(a,b,c,d,e,g){var f=arguments.callee,h=d||0,k=0===h?void 0===a.length?_.keys(a):void 0:g,m=0===h?k?k.length:a.length:e,l=2!==_.numArgs(b);if(!a||h>=(m||0))c&&c();else{var n=k?k[h]:h,p=function(){f(a,b,c,h+1,m,k)};l?b(a[n],n,p,c,a):b(a[n],p,c,a)}}});_.extend(_.cps,{map:function(a,b,c){var d=_.isArray(a)?[]:{};_.cps.each(a,2==_.numArgs(b)?function(a,c,f){b(a,function(a){d[c]=a;f()})}:function(a,c,f){b(a,c,function(a){d[c]=a;f()})},function(){c(d)})}});
_.extend(_.cps,{find:function(a,b,c){var d=2!==_.numArgs(b);_.cps.each(a,function(a,c,f,h){var k=function(b){!1===b?f():h(!0===b?a:b,c)};d?b(a,c,k):b(a,k)},c)}});
_.extend(_.cps,{memoize:function(a){return _.barrier?_.cps._betterMemoize(a):_.cps._poorMemoize(a)},_poorMemoize:function(a){var b={};return function(c,d){c in b?d(b[c]):a.call(this,c,function(a){d(b[c]=a)})}},_betterMemoize:function(a){var b={};switch(_.numArgs(a)){case 1:return function(c){b.already||a.call(this,b=_.barrier());b(c)};case 2:return b={},function(c,d){c in b||a.call(this,c,b[c]=_.barrier());b[c](d)};default:throw Error("_.cps.memoize: unsupported number of arguments");}}});
(function(){var a=function(b,c,d,e,g){!b||g>=(b.length||0)?d(e):c(e,b[g],function(e){a(b,c,d,e,g+1)})};_.cps.reduce=function(b,c,d,e){4>arguments.length?a(b,c,d,b[0],1):a(b,c,d,e,0)}})();_.extend(_.cps,{noop:$restArg(function(){return _.last(arguments).call(this)}),identity:$restArg(function(){var a=_.initial(arguments),b=_.last(arguments);if(b)return b.apply(this,a)}),constant:$restArg(function(){var a=arguments;return function(){return _.last(arguments).apply(this,a)}})});
_.cps.arity0=function(a){return function(){a.call(this,_.last(arguments))}};_.cps.arity1=function(a){return function(){a.call(this,arguments[0],_.last(arguments))}};_.cps.arity2=function(a){return function(){a.call(this,arguments[0],arguments[1],_.last(arguments))}};_.cps.transformResult=function(a,b){return function(c){b.apply(this,_.initial(arguments).concat(a(_.last(arguments))))}};_.cps.resultArity2=_.partial(_.cps.transformResult,_.arity2);_.cps.resultArity1=_.partial(_.cps.transformResult,_.arity1);
_.cps.resultArity0=_.partial(_.cps.transformResult,_.arity0);_.cps.sequence=$restArg(function(a){var b=_.isArray(a)&&a||_.asArray(arguments);return _.reduceRight(b,function(a,b){return function(){return b.apply(this,_.asArray(arguments).concat(a))}},_.cps.identity)});_.cps.compose=$restArg(function(a){var b=_.isArray(a)&&a||_.asArray(arguments);return _.cps.sequence(b.slice().reverse())});
_.cps.trySequence=function(a,b,c){_.reduceRight(a,function(a,e){return function(g){if(_.isTypeOf(Error,g))return(c||b)(g);try{return e.apply(this,_.asArray(arguments).concat(a))}catch(f){return(c||b)(f)}}},b)()};_(["method","property","flipped"]).each(_.defineTagKeyword);
$extensionMethods=function(a,b){_.each(b,function(b,d){var e=Tags.unwrap(b);d in _||(_[d]=_[d]||e);if(b.$method||!b.$property&&!_.oneArg(e)){if(b.$property)throw Error("$extensionMethods: crazy input, unable to match");d in a.prototype||(a.prototype[d]=_.asMethod(b.$flipped?_.flip(e):e))}else d in a.prototype||_.defineHiddenProperty(a.prototype,d,function(){return e(this)})})};
$extensionMethods(Function,{bind:_.bind,partial:_.partial,tails:_.tails,tails2:_.tails2,tails3:_.tails3,compose:_.compose,then:_.then,flip:_.flip,flip2:_.flip2,flip3:_.flip3,asFreeFunction:_.asFreeFunction,asMethod:_.asMethod,asContinuation:function(a){return $restArg(function(){_.last(arguments)(a.apply(this,_.initial(arguments)))})},wraps:function(a,b){a._wrapped=_.withSameArgs(a,b);return a},wrapped:function(a){return a._wrapped||a},original:function(a){for(;a&&a._wrapped;)a=a._wrapped;return a},
arity0:_.arity0,arity1:_.arity1,arity2:_.arity2,arity3:_.arity3,or:_.or,and:_.and,not:_.not,applies:_.applies,memoized:_.memoize,throttled:_.throttle,debounced:function(a,b,c){var d,e,g,f,h,k=function(){var l=Date.now()-d;l<b&&0<l?e=setTimeout(k,b-l):(e=null,c||(g=a.apply(h,f),e||(h=f=null)))},m=function(){h=this;f=arguments;d=Date.now();var l=c&&!e;e||(e=setTimeout(k,b));l&&(g=a.apply(h,f),h=f=null);return g};m.callImmediately=function(){e&&(clearTimeout(e),e=null);a.apply(h,f)};return m},postpone:$method(function(a){var b=
_.rest(arguments);a._postponed||(a._postponed=!0,_.delay(function(){a._postponed=!1;a.apply(null,b)}))}),delay:_.delay,delayed:function(a,b){return function(){var c=arguments,d=this;_.delay(function(){a.apply(d,c)},b)}}});
$extensionMethods(Array,{last:function(a){return _.last(a)},random:function(a){return a[_.random(0,a.length-1)]},copy:function(a){return a.slice(0)},removeAll:$method(function(a){return a.splice(0,a.length),a}),remove:function(a,b){for(var c;-1!==(c=a.indexOf(b));)a.splice(c,1);return a},removeAt:function(a,b){a.splice(b,1);return a},insertAt:function(a,b,c){a.splice(c,0,b);return a},itemAtWrappedIndex:function(a,b){return a[b%a.length]},reversed:function(a){return a.slice().reverse()},flat:function(a){return _.flatten(a,
!0)},swap:$method(function(a,b,c){var d=a[b];a[b]=a[c];a[c]=d;return a}),zip:_.zipWith});_.zap=function(a){var b=_.last(arguments);return _.reduce(_.rest(_.initial(arguments)),function(a,d){return _.times(Math.max(a.length,d.length),function(e){return b(a[e],d[e])})},a)};
$extensionMethods(String,{quote:_.quote,cut:function(a,b,c){return a.substring(0,b-1)+a.substring(b,a.length)},insert:function(a,b,c){return a.substring(0,b)+c+a.substring(b,a.length)},lowercase:function(a){return a.toLowerCase()},uppercase:function(a){return a.toUpperCase()},trimmed:function(a){return a.trim()},escaped:function(a){return _.escape(a)},repeats:function(a,b){return _.times(b,_.constant(a)).join("")},prepend:function(a,b){return b+a},append:function(a,b){return a+b},first:function(a,
b){return _.first(a,b).join("")},reversed:function(a){return a.split("").reverse().join("")},capitalized:function(a){return a.charAt(0).toUpperCase()+a.slice(1)},decapitalized:function(a){return a.charAt(0).toLowerCase()+a.slice(1)},latinAlphanumericValue:function(a){return a.replace(/[^a-z0-9]/gi,"")},alphanumericValue:function(a){return a.replace(unicode_hack(/[^0-9\p{L}|^0-9\p{N}|^0-9\p{Pc}|^0-9\p{M}]/g),"")},numericValue:function(a){return a.replace(/[^0-9]/g,"")},integerValue:function(a){return a.numericValue.parsedInt},
parsedInt:function(a){a=parseInt(a,10);return _.isFinite(a)?a:void 0},bytes:function(a){for(var b=new Uint8Array(a.length),c=0;c<a.length;++c)b[c]=a.charCodeAt(c);return b},hash:function(a){var b=0,c,d,e;if(0===a.length)return b;c=0;for(e=a.length;c<e;c++)d=a.charCodeAt(c),b=(b<<5)-b+d,b|=0;return b},transliterate:function(){var a=_.extend({"\u0430":"a","\u0431":"b","\u0432":"v","\u0433":"g","\u0434":"d","\u0435":"e","\u0451":"yo","\u0436":"zh","\u0437":"z","\u0438":"i","\u0439":"y","\u043a":"k",
"\u043b":"l","\u043c":"m","\u043d":"n","\u043e":"o","\u043f":"p","\u0440":"r","\u0441":"s","\u0442":"t","\u0443":"u","\u0444":"ph","\u0445":"h","\u0446":"ts","\u0447":"ch","\u0448":"sh","\u0449":"sch","\u044c":"","\u044a":"","\u044b":"y","\u044d":"e","\u044e":"yu","\u044f":"ya"},_.object(_.map("_-1234567890qwertyuiopasdfghjklzxcvbnm",function(a){return[a,a]})));return function(b){var c="";b=(b||"").toLowerCase();for(var d=0,e=b.length;d<e;d++)c+=a[b[d]]||"";return c}}(),fixedEncodeURIComponent:function(a,
b){return encodeURIComponent(a).replace(b?b:/[!'().,*-]/g,function(a){return"%"+a.charCodeAt(0).toString(16)})}});
(function(){var a=["onceBefore","onceAfter","onBefore","onAfter","intercept"],b=function(b){return _.extend({},b,{_bindable:!0,impl:b,_wrapped:b},_.object(_.map(a,function(a){return[a,function(b){if(!_.isBindable(this))throw Error("wrong this");return this["_"+a].push(b),this}]})),_.object(_.map(a,function(a){return["_"+a,[]]})))};_.extend(_,_.mapObject(_.invert(a),function(a){return function(b,e,g){var f=b[e];return(_.isBindable(f)?f:b[e]=_.bindable(f))["_"+a].push(g)}}.flip2),{off:function(b,d,
e){var g=b[d];_.isBindable(g)&&_.each(a,function(a){g["_"+a]=_.without(g["_"+a],e)})},isBindable:function(a){return a&&a._bindable?!0:!1},bindable:function(a,d){return _.withSameArgs(a,_.extendWith(b(a),function(){var b=arguments.callee,g=b._onceBefore,f=b._onceAfter,h=b._onBefore,k=b._onAfter,m=b._intercept,b=d||this,l,n=void 0;if(g.length){l=0;for(n=g.length;l<n;l++)g[l].apply(b,arguments);g.removeAll()}l=0;for(n=h.length;l<n;l++)h[l].apply(b,arguments);g=(m.length?_.cps.compose([a].concat(m)):
a).apply(b,arguments);if(k.length||f.length){h=_.asArray(arguments).concat(g);l=0;for(n=k.length;l<n;l++)k[l].apply(b,h);if(f.length){l=0;for(n=f.length;l<n;l++)f[l].apply(b,h);f.removeAll()}}return g}))}})})();
_.extend(_,{gatherChanges:function(a){var b=_.isArray(a)?a:_.initial(arguments),c=_.last(arguments),d=function(a){c.apply(this,_.pluck(b,"value"))};_.each(b,function(a){a(d)})},allTriggered:function(a,b){var c=[];0<a.length?_.each(a,function(d){d(function(){c=_.union(c,[d]);b&&c.length===a.length&&(b(),b=void 0)})}):b()},observableRef:function(a){return _.extend(_.observable.apply(this,arguments),{trackReference:!0})},observable:function(a){var b=_.stream({hasValue:0<arguments.length,value:a,read:_.identity,
read:function(a){return function(d){b.hasValue&&d.call(this,b.value);a.call(this,d)}},write:function(a){return function(d){b.beforeWrite&&(d=b.beforeWrite(d));if(!b.hasValue||(b.trackReference?b.value!==d:!_.isEqual(b.value,d))){var e=b.value,g=b.hasValue;b.hasValue=!0;b.value=d;g?a.call(this,!1,b.value,e):a.call(this,!1,b.value)}}}});arguments.length&&b.apply(this,arguments);return _.extend(b,{force:function(a){b.hasValue=!1;b(a||b.value)},when:function(a,d){b(function(e){a(e)&&(b.off(arguments.callee),
d(e))})}})},barrier:function(a){var b=_.stream({already:void 0!==a,value:a,write:function(a){return function(d){b.already||(b.already=!0,b.value=d);a.call(this,!0,b.value)}},read:function(a){return function(d){b.already?d.call(this,b.value):a.call(this,d)}}});return b},triggerOnce:$restArg(function(){return _.stream({read:_.identity,write:function(a){return a.partial(!0)}}).apply(this,arguments)}),trigger:$restArg(function(){return _.stream({read:_.identity,write:function(a){return a.partial(!1)}}).apply(this,
arguments)}),off:function(a,b){a.queue&&(1===arguments.length?a.queue.off():a.queue.off(b));a.queuedBy&&(_.each(a.queuedBy,function(b){b.remove(a)}),delete a.queuedBy)},stream:function(a){a=a||{};var b=_.extend([],{off:function(a){this.length&&(0===arguments.length?(_.each(this,function(a){a.queuedBy.remove(this)},this),this.removeAll()):a.queuedBy&&(a.queuedBy.remove(this),this.remove(a)))}}),c=void 0,d=a.write(function(a,d){var e=_.rest(arguments),k=b.copy,m=c.context;a&&b.off();_.each(k,function(a){a.apply(this,
e)},m||this)}),e=a.read(function(a){0>b.indexOf(a)&&(a.queuedBy?a.queuedBy.push(b):a.queuedBy=[b],b.push(a))});return c=_.extend($restArg(function(a){_.isFunction(a)?e.call(this,a):d.apply(this,arguments);return arguments.callee}),a,{queue:b,once:function(a){e(function(b){_.off(c,arguments.callee);a(b)})},off:_.off.asMethod,read:e,write:d})}});_.hasOOP=!0;_("property static final alias memoized private builtin testArguments".split(" ")).each(_.defineTagKeyword);
$prototype=function(a,b){return $prototype.impl.compile.apply($prototype.impl,1<arguments.length?_.asArray(arguments).reverse():arguments)};$extends=function(a,b){return $prototype(a,b||{})};
_.extend($prototype,{isConstructor:function(a){return _.isPrototypeConstructor(a)},macro:function(a,b){1===arguments.length?$prototype.impl.alwaysTriggeredMacros.push(a):$prototype.impl.memberNameTriggeredMacros[a]=b},each:function(a){var b=$global,c;for(c in b)if(!_.isKeyword(c)){var d=b[c];$prototype.isConstructor(d)&&a(d,c)}},inheritanceChain:function(a){for(var b=[];a;)b.push(a),a=a.$base&&a.$base.constructor;return b},wrapMethods:function(a,b){return Tags.map(a,function(a,d,e){return _.isFunction(a)?
b(a,d,e).wraps(a):a})},impl:{alwaysTriggeredMacros:[],memberNameTriggeredMacros:{},compile:function(a,b){return Tags.unwrap(_.sequence(this.extendWithTags,this.flatten,this.generateArgumentContractsIfNeeded,this.ensureFinalContracts(b),this.generateConstructor(b),this.evalAlwaysTriggeredMacros(b),this.evalMemberNameTriggeredMacros(b),this.contributeTraits,this.generateBuiltInMembers(b),this.expandAliases,this.defineStaticMembers,this.defineInstanceMembers).call(this,a||{}).constructor)},evalAlwaysTriggeredMacros:function(a){return function(b){for(var c=
$prototype.impl.alwaysTriggeredMacros,d=0,e=c.length;d<e;d++)b=c[d](b,a);return b}},evalMemberNameTriggeredMacros:function(a){return function(b){var c=$prototype.impl.memberNameTriggeredMacros;_.each(b,function(d,e){c.hasOwnProperty(e)&&(b=c[e](b,d,e,a))});return b}},generateArgumentContractsIfNeeded:function(a){return a.$testArguments?$prototype.wrapMethods(a,function(a,c){return function(){var d=_.asArray(arguments);$assertArguments(d.copy,a.original,c);return a.apply(this,d)}}):a},contributeTraits:function(a){a.$trait&&
(a.$traits=[a.$trait],delete a.$trait);if(a.$traits){var b=a.$traits;_.each(b,function(b){_.defaults(a,_.omit(b.$definition,_.or($builtin.matches,_.key(_.equals("constructor")))))});a.$traits=$static($builtin($property(b)));a.hasTrait=$static($builtin(function(a){return 0<=b.indexOf(a)}))}return a},extendWithTags:function(a){return _.extendWith(Tags.unwrap(a),_.mapObject(Tags.get(a),$static))},generateConstructor:function(a){return function(b){return _.extend(b,{constructor:Tags.modifySubject(b.hasOwnProperty("constructor")?
b.constructor:this.defaultConstructor(a),function(b){a&&(b.prototype.__proto__=a.prototype);return b})})}},generateBuiltInMembers:function(a){return function(b){return _.defaults(b,{$base:$builtin($static($property(_.constant(a&&a.prototype)))),$definition:$builtin($static($property(_.constant(_.extend({},a&&a.$definition,b))))),isTypeOf:$builtin($static(_.partial(_.isTypeOf,Tags.unwrap(b.constructor)))),isInstanceOf:$builtin(function(a){return _.isTypeOf(a,this)}),$:$builtin(function(a){return _.$.apply(null,
[this].concat(_.asArray(arguments)))})})}},defaultConstructor:function(a){return a?function(){a.prototype.constructor.apply(this,arguments)}:function(a){_.extend(this,a||{})}},defineStaticMembers:function(a){this.defineMembers(Tags.unwrap(a.constructor),_.pick(a,$static.matches));return a},defineInstanceMembers:function(a){this.defineMembers(Tags.unwrap(a.constructor).prototype,_.omit(a,$static.matches));return a},defineMembers:function(a,b){_.each(b,function(c,d){"constructor"!==d&&b.hasOwnProperty(d)&&
this.defineMember(a,c,d)},this)},defineMember:function(a,b,c){b&&b.$property?b.$memoized?_.defineMemoizedProperty(a,c,b):_.defineProperty(a,c,b):(b=Tags.unwrap(b),a[c]=b)},ensureFinalContracts:function(a){return function(b){if(a){if(a.$final)throw Error("Cannot derive from $final-marked prototype");if(a.$definition){var c=_.intersection(_.keys(_.pick(a.$definition,$final.matches)),_.keys(b));if(c.length)throw Error("Cannot override $final "+c.join(", "));}}return b}},expandAliases:function(a){return _.mapObject(a,
function(b){return $alias.matches(b)?a[Tags.unwrap(b)]:b})},flatten:function(a){var b=_.pick(a,this.isTagKeywordGroup),b=_.object(_.flatten(_.map(b,function(a,b){return _.map(a,function(a,c){return[c,$global[b](a)]})}),!0));a=_.omit(a,this.isTagKeywordGroup);return _.extend(a,b)},isTagKeywordGroup:function(a,b){var c=Tags.unwrap(a);return _.isKeyword(b)&&_.isFunction($global[b])&&"object"===typeof c&&!_.isArray(c)}}});
_.isTraitOf=function(a,b){var c=b&&b.constructor;return c&&c.hasTrait&&c.hasTrait(a)||!1};_.isTypeOf=_.or(_.isTypeOf,_.isTraitOf);$trait=function(a,b){var c=void 0,d=_.extend(1<arguments.length?b:a,{constructor:_.throwsError("Traits are not instantiable (what for?)"),isTraitOf:$static($builtin(function(a){return _.isTraitOf(c,a)}))});return c=$prototype.impl.compile(d,1<arguments.length?a:b)};_.$=function(a,b){return _.bind.apply(void 0,[b,a].concat(_.rest(arguments,2)))};
"undefined"!==typeof jQuery&&jQuery.fn.extend({$:function(a){return _.$(this,a)}});_.defineKeyword("const",function(a){return $static($property(a))});$singleton=function(a,b){return new ($prototype.apply(null,arguments))};
Platform=$singleton({$property:{engine:_.platform().engine,system:_.platform().system,device:_.platform().device,touch:_.platform().touch||!1,Browser:"browser"===_.platform().engine,NodeJS:"node"===_.platform().engine,iPad:"iPad"===_.platform().device,iPhone:"iPhone"===_.platform().device,iOS:"iOS"===_.platform().system}});_.clamp=function(a,b,c){return Math.max(b,Math.min(c,a))};_.lerp=function(a,b,c){return b+(c-b)*a};
_.rescale=function(a,b,c,d){a=(a-b[0])/(b[1]-b[0]);return _.lerp(d&&d.clamp?_.clamp(a,0,1):a,c[0],c[1])};_.sqr=function(a){return a*a};Math.sign||(Math.sign=function(a){return 0>a?-1:0<a?1:0});Intersect={rayCircle:function(a,b,c,d){var e=a.sub(c);c=b.dot(b);var g=2*e.dot(b);d=e.dot(e)-d*d;e=g*g-4*c*d;if(!(0>e)){e=Math.sqrt(e);d=(-g-e)/(2*c);c=(-g+e)/(2*c);if(0<=d&&1>=d)return{time:d,where:a.add(b.scale(d))};if(0<=c&&1>=c)return{time:c,where:a.add(b.scale(c)),insideOut:!0}}}};
Vec2=$prototype({$static:{zero:$property(function(){return new Vec2(0,0)}),unit:$property(function(){return new Vec2(1,1)}),one:$alias("unit"),fromLT:function(a){return new Vec2(a.left,a.top)},fromWH:function(a){return new Vec2(a.width,a.height)},fromLeftTop:$alias("fromLT"),fromWidthHeight:$alias("fromWH"),lerp:function(a,b,c){return new Vec2(_.lerp(a,b.x,c.x),_.lerp(a,b.y,c.y))},clamp:function(a,b,c){return new Vec2(_.clamp(a.x,b.x,c.x),_.clamp(a.y,b.y,c.y))}},constructor:function(a,b){1===arguments.length?
_.isNumber(a)?this.x=this.y=a:(this.x=a.x,this.y=a.y):(this.x=a,this.y=b)},length:$property(function(){return Math.sqrt(this.lengthSquared)}),lengthSquared:$property(function(){return this.x*this.x+this.y*this.y}),aspect:$property(function(){return this.x/this.y}),add:function(a,b){return void 0===b?"number"===typeof a?new Vec2(this.x+a,this.y+a):new Vec2(this.x+a.x,this.y+a.y):new Vec2(this.x+a,this.y+b)},dot:function(a){return this.x*a.x+this.y*a.y},sub:function(a){return new Vec2(this.x-a.x,this.y-
a.y)},scale:function(a,b){return new Vec2(this.x*a,this.y*(void 0===b?a:b))},mul:function(a){return new Vec2(this.x*a.x,this.y*a.y)},divide:function(a){return new Vec2(this.x/a.x,this.y/a.y)},normal:$property(function(){return this.scale(1/this.length)}),perp:$property(function(){return new Vec2(this.y,-this.x)}),half:$property(function(){return new Vec2(.5*this.x,.5*this.y)}),inverse:$property(function(){return new Vec2(-this.x,-this.y)}),asArray:$property(function(){return[this.x,this.y]}),asLeftTop:$property(function(){return{left:this.x,
top:this.y}}),asLeftTopMargin:$property(function(){return{marginLeft:this.x,marginTop:this.y}}),asWidthHeight:$property(function(){return{width:this.x,height:this.y}}),asTranslate:$property(function(){return"translate("+this.x+" "+this.y+")"}),floor:$property(function(){return new Vec2(Math.floor(this.x),Math.floor(this.y))}),sum:$static(function(a){return _.reduce(_.isArray(a)&&a||_.asArray(arguments),function(a,c){return a.add(c||Vec2.zero)},Vec2.zero)}),toString:function(){return"{"+this.x+","+
this.y+"}"},projectOnCircle:function(a,b){return a.add(this.sub(a).normal.scale(b))},projectOnLineSegment:function(a,b){var c=b.sub(a),d=c.lengthSquared;if(0==d)return a;d=this.sub(a).dot(c)/d;return 0>d?a:1<d?b:a.add(c.scale(d))}});
Bezier={cubic:function(a,b,c,d,e){var g=a*a*a,f=a*a,h=3*(c.x-b.x),k=3*(c.y-b.y),m=3*(d.x-c.x)-h;c=3*(d.y-c.y)-k;return new Vec2((e.x-b.x-h-m)*g+m*f+h*a+b.x,(e.y-b.y-k-c)*g+c*f+k*a+b.y)},cubic1D:function(a,b,c,d,e){return Bezier.cubic(a,Vec2.zero,new Vec2(b,c),new Vec2(d,e),Vec2.one).y},make:{cubic:function(a,b,c,d){return function(e){return Bezier.cubic(e,a,b,c,d)}},cubic1D:function(a,b,c,d){return function(e){return Bezier.cubic1D(e,a,b,c,d)}}}};
BBox=$prototype({$static:{zero:$property(function(){return new BBox(0,0,0,0)}),unit:$property(function(){return new BBox(0,0,1,1)}),fromLeftTopAndSize:function(a,b){return BBox.fromLTWH({left:a.x,top:a.y,width:b.x,height:b.y})},fromLTWH:function(a){return new BBox(a.left+a.width/2,a.top+a.height/2,a.width,a.height)},fromLTRB:function(a){return new BBox(_.lerp(.5,a.left,a.right),_.lerp(.5,a.top,a.bottom),a.right-a.left,a.bottom-a.top)},fromSizeAndCenter:function(a,b){return new BBox(b.x-a.x/2,b.y-
a.y/2,a.x,a.y)},fromSize:function(a,b){return b?new BBox(-a/2,-b/2,a,b):new BBox(-a.x/2,-a.y/2,a.x,a.y)},fromPoints:function(a){var b=Number.MAX_VALUE,c=Number.MAX_VALUE,d=Number.MIN_VALUE,e=Number.MIN_VALUE;_.each(a,function(a){b=Math.min(a.x,b);c=Math.min(a.y,c);d=Math.max(a.x,d);e=Math.max(a.y,e)});return BBox.fromLTRB({left:b,top:c,right:d,bottom:e})}},constructor:function(a,b,c,d){4==arguments.length?(this.x=a,this.y=b,this.width=c,this.height=d):_.extend(this,a)},classifyPoint:function(a){a=
_.extend(a.x>this.right?{right:!0}:{},a.x<this.left?{left:!0}:{},a.y>this.bottom?{bottom:!0}:{},a.y<this.top?{top:!0}:{});return _.extend(a,a.left||a.right||a.bottom||a.top?{}:{inside:!0})},classifyRay:function(a,b,c){var d=this.size.half,e,g,f,h,k,m;e=1/b.x;g=1/b.y;k=Math.sign(e);m=Math.sign(g);f=(this.x-k*d.x-a.x)*e;h=(this.y-m*d.y-a.y)*g;e*=this.x+k*d.x-a.x;d=(this.y+m*d.y-a.y)*g;if(!(f>d||h>e||(g=f>h?f:h,1<=g||0>=(e<d?e:d))))return e={time:_.clamp(g,0,1)},e.normal=f>h?new Vec2(-k,0):new Vec2(0,
-m),e.delta=b.scale(e.time),e.where=a.add(e.delta),c&&(f=this.grow(-c),e.where.x>f.right?e.where.y<f.top?e=Intersect.rayCircle(a,b,f.rightTop,c):e.where.y>f.bottom&&(e=Intersect.rayCircle(a,b,f.rightBottom,c)):e.where.x<f.left&&(e.where.y<f.top?e=Intersect.rayCircle(a,b,f.leftTop,c):e.where.y>f.bottom&&(e=Intersect.rayCircle(a,b,f.leftBottom,c))),e&&e.insideOut&&(e.where=a)),e},nearestPointTo:function(a,b){var c=b||0,d=new Vec2(this.left,this.top),e=new Vec2(this.right,this.top),g=new Vec2(this.right,
this.bottom),f=new Vec2(this.left,this.bottom),c=[a.projectOnLineSegment(d.add(c,0),e.add(-c,0)),a.projectOnLineSegment(e.add(0,c),g.add(0,-c)),a.projectOnLineSegment(g.add(-c,0),f.add(c,0)),a.projectOnLineSegment(f.add(0,-c),d.add(0,c)),a.projectOnCircle(d.add(c,c),c),a.projectOnCircle(e.add(-c,c),c),a.projectOnCircle(g.add(-c,-c),c),a.projectOnCircle(f.add(c,-c),c)];return _.min(c,function(b){return a.sub(b).length})},clone:$property(function(){return new BBox(this.x,this.y,this.width,this.height)}),
floor:$property(function(){return new Vec2(Math.floor(this.x),Math.floor(this.y))}),css:$property(function(){return{left:this.left,top:this.top,width:this.width,height:this.height}}),leftTop:$property(function(){return new Vec2(this.left,this.top)}),leftBottom:$property(function(){return new Vec2(this.left,this.bottom)}),rightBottom:$property(function(){return new Vec2(this.right,this.bottom)}),rightTop:$property(function(){return new Vec2(this.right,this.top)}),left:$property(function(){return this.x-
this.width/2}),right:$property(function(){return this.x+this.width/2}),top:$property(function(){return this.y-this.height/2}),bottom:$property(function(){return this.y+this.height/2}),center:$property(function(){return new Vec2(this.x,this.y)}),size:$property(function(){return new Vec2(this.width,this.height)}),offset:function(a){return new BBox(this.x+a.x,this.y+a.y,this.width,this.height)},newWidth:function(a){return new BBox(this.x-(a-this.width)/2,this.y,a,this.height)},grow:function(a){return new BBox(this.x,
this.y,this.width+2*a,this.height+2*a)},shrink:function(a){return this.grow(-a)},area:$property(function(){return Math.abs(this.width*this.height)}),toString:function(){return"{"+this.x+","+this.y+":"+this.width+"\u00d7"+this.height+"}"}});
Transform=$prototype({svgMatrix:$static(function(a){return new Transform([[a.a,a.c,a.e],[a.b,a.d,a.f],[0,0,1]])}),constructor:function(a){this.components=a||[[1,0,0],[0,1,0],[0,0,1]]},multiply:function(a){var b=[[0,0,0],[0,0,0],[0,0,0]],c,d,e=this.components,g=a.components;for(a=0;3>a;a++)for(c=0;3>c;c++)for(d=0;3>d;d++)b[a][c]+=e[a][d]*g[d][c];return new Transform(b)},translate:function(a){return this.multiply(new Transform([[1,0,a.x],[0,1,a.y],[0,0,1]]))},scale:function(a){return this.multiply(new Transform([[a,
0,0],[0,a,0],[0,0,1]]))},inverse:$property($memoized(function(){var a=this.components,b=1/(a[0][0]*(a[1][1]*a[2][2]-a[2][1]*a[1][2])-a[0][1]*(a[1][0]*a[2][2]-a[1][2]*a[2][0])+a[0][2]*(a[1][0]*a[2][1]-a[1][1]*a[2][0]));return new Transform([[(a[1][1]*a[2][2]-a[2][1]*a[1][2])*b,-(a[0][1]*a[2][2]-a[0][2]*a[2][1])*b,(a[0][1]*a[1][2]-a[0][2]*a[1][1])*b],[(a[1][0]*a[2][2]-a[1][2]*a[2][0])*b,(a[0][0]*a[2][2]-a[0][2]*a[2][0])*b,-(a[0][0]*a[1][2]-a[1][0]*a[0][2])*b],[(a[1][0]*a[2][1]-a[2][0]*a[1][1])*b,-(a[0][0]*
a[2][1]-a[2][0]*a[0][1])*b,(a[0][0]*a[1][1]-a[1][0]*a[0][1])*b]])})),unproject:function(a){var b=this.components;return new Vec2(a.x*b[0][0]+a.y*b[0][1]+b[0][2],a.x*b[1][0]+a.y*b[1][1]+b[1][2])},project:function(a){return this.inverse.unproject(a)}});_.rng=function(a,b,c){var d=a,e=987654321;return function(){e=36969*(e&65535)+(e>>16)&4294967295;d=18E3*(d&65535)+(d>>16)&4294967295;var a=(e<<16)+d&4294967295,a=a/4294967296+.5;return void 0===b&&void 0===c?a:Math.round(b+a*(c-b))}};
_.equalDistribution=function(a,b){var c=a/b,d=0;return _.times(b,function(){var a=Math.round(d),b=Math.round(d+=c);return Math.floor(b-a)})};_.ptInRect=function(a,b){return a.x>=b.left&&a.y>=b.top&&a.x<b.right&&a.y<b.bottom};_.hue2CSS=function(a,b){return _.RGB2CSS(_.hue2RGB(a),b)};_.HSL2CSS=function(a,b){return _.RGB2CSS(_.HSL2RGB(a),b)};_.HSL2RGB=function(a){var b=a[1],c=a[2];a=_.hue2RGB(a[0]);b*=1-Math.abs(2*c-1);return[(a[0]-.5)*b+c,(a[1]-.5)*b+c,(a[2]-.5)*b+c]};
_.hue2RGB=function(a){return[Math.max(0,Math.min(1,Math.abs(6*a-3)-1)),Math.max(0,Math.min(1,2-Math.abs(6*a-2))),Math.max(0,Math.min(1,2-Math.abs(6*a-4)))]};_.RGB2CSS=function(a,b){return"rgba("+Math.round(255*a[0])+","+Math.round(255*a[1])+","+Math.round(255*a[2])+","+(void 0===b?void 0===a[3]?1:a[3]:b)+")"};
_.RGB2HSL=function(a,b){var c=a[0],d=a[1],e=a[2],g=void 0===b?a[3]:b,f=Math.max(c,d,e),h=Math.min(c,d,e),k,m=(f+h)/2;if(f==h)k=h=0;else{var l=f-h,h=.5<m?l/(2-f-h):l/(f+h);switch(f){case c:k=(d-e)/l+(d<e?6:0);break;case d:k=(e-c)/l+2;break;case e:k=(c-d)/l+4}k/=6}return void 0===g?[k,h,m]:[k,h,m,g]};
_.extend(Math,function(a){return{roundTo:function(a,c){return a-a%c},round10:function(b,c){return a("round",b,c)},floor10:function(b,c){return a("floor",b,c)},ceil10:function(b,c){return a("ceil",b,c)}}}(function(a,b,c){if("undefined"===typeof c||0===+c)return Math[a](b);b=+b;c=+c;if(isNaN(b)||"number"!==typeof c||0!==c%1)return NaN;b=b.toString().split("e");b=Math[a](+(b[0]+"e"+(b[1]?+b[1]-c:-c)));b=b.toString().split("e");return+(b[0]+"e"+(b[1]?+b[1]+c:c))}));
Format={javascript:function(a){return _.stringify(a,{pretty:!0,pure:!0,formatter:function(a){if(_.isTypeOf(Tags,a))return _.reduce(_.keys(_.pick(a,_.keyIsKeyword)),function(a,b){return b+" "+_.quote(a,"()")},_.stringify(Tags.unwrap(a)));if(_.isFunction(a))return a.toString()}})},progressPercents:function(a,b){return Math.floor(a/b*100)+"%"},randomHexString:function(a){for(var b="",c=0;c<a;c++)b+=Math.floor(16*Math.random()).toString(16);return b},leadingZero:function(a){return 10>a?"0"+a:a.toString()},
plural:function(a,b,c,d){_.isArray(b)&&(d=b[2],c=b[1],b=b[0]);b=[d,b,c,c,c,d];return a+" "+(4<a%100&&20>a%100?d:b[Math.min(a%10,5)])}};_.enumerate=_.cps.each;_.mapReduce=function(a,b){var c=0,d=!1,e=a&&a.length||0,g=b.maxConcurrency||e,f=0,h=b.memo;if(0===e)b.complete(b.memo||a);else{var k=function(){for(;c<e&&f<g;)f+=1,b.next(a[c],c++,function(){f--;d||(c>=e?0===f&&(setTimeout(function(){b.complete(b.memo||a)},0),d=!0):k())},function(){f--},h);!d&&c>=e&&0==f&&b.complete(b.memo||a)};k()}};
_.asyncJoin=function(a,b,c){_.mapReduce(a,{complete:b.bind(c),next:function(a,b,g,f){a.call(c,g,f)}})};Lock=$prototype({acquire:function(a){this.wait(this.$(function(){this.waitQueue||(this.waitQueue=[]);a()}))},acquired:function(){return void 0!==this.waitQueue},wait:function(a){this.acquired()?this.waitQueue.push(a):a()},release:function(){if(this.waitQueue.length){var a=_.first(this.waitQueue);this.waitQueue=_.rest(this.waitQueue);a()}else delete this.waitQueue}});
_.defineKeyword("interlocked",function(a){var b=new Lock;return _.wrapper(Tags.unwrap(a),function(a){b.acquire(function(){a(b.$(b.release))})})});Platform.NodeJS&&(module.exports=_);_("bindable trigger triggerOnce barrier observable observableProperty memoize memoizeCPS debounce throttle overrideThis".split(" ")).each(_.defineTagKeyword);_.defineKeyword("component",function(a){return $extends(Component,a)});
$prototype.inheritsBaseValues=function(a){$prototype.macro(a,function(b,c,d,e){_.defaults(c,e&&e[a]);(b.$trait||b.$traits)&&_.each(b.$trait&&[b.$trait]||b.$traits,function(b){_.defaults(c,b[a])});b[a]=$static($builtin($property(_.constant(c))));return b})};$prototype.inheritsBaseValues("$defaults");$prototype.inheritsBaseValues("$requires");
Component=$prototype({isStreamDefinition:$static(function(a){return _.isObject(a)&&(a.$trigger||a.$triggerOnce||a.$barrier||a.$observable||a.$observableProperty)}),enumMethods:function(a){for(var b in this){var c=this.constructor.$definition[b];c&&c.$property||(c=this[b],_.isFunction(c)&&!_.isPrototypeConstructor(c)&&a.call(this,c,b))}},constructor:$final(function(a,b){var c=this.cfg="object"===typeof a?a:{},d=this.constructor.$definition;this.constructor.$defaults&&_.defaults(this,_.cloneDeep(this.constructor.$defaults));
this.enumMethods(function(a,b){"$"!==b&&"init"!==b&&(this[b]=this.$(a))});_.onBefore(this,"destroy",this.beforeDestroy);_.onAfter(this,"destroy",this.afterDestroy);_.extend(this,{parent_:void 0,children_:[]},_.omit(_.omit(c,"init","attachTo","attach"),function(a,b){return Component.isStreamDefinition(d[b])},this));_.each(d,function(a,b){if(void 0!==a){if(a.$observableProperty){var d=this[b];defaultValue=b in c?c[b]:d;var h=this[b+"Change"]=_.observable();h.context=this;if(_.isPrototypeInstance(d)){var k=
d.constructor;h.beforeWrite=function(a){return k.isTypeOf(a)?a:new k(a)}}_.defineProperty(this,b,{get:function(){return h.value},set:function(a){h.call(this,a)}});void 0!==defaultValue&&h(_.isFunction(defaultValue)?this.$(defaultValue):defaultValue)}else if(Component.isStreamDefinition(a)){d=(a.$trigger?_.trigger:a.$triggerOnce?_.triggerOnce:a.$observable?_.observable:a.$barrier?_.barrier:void 0)(this[b]);this[b]=_.extend(d,{context:this});var m=c[b];m&&d(this.$(m))}a.$bindable&&(_.hasAsserts&&$assert(_.isFunction(this[b])),
this[b]=_.bindable(this[b],this));a.$debounce&&(d=this[b],this[b]=_.debounce(d,d.wait||500,d.immediate));a.$throttle&&(d=this[b],this[b]=_.throttle(d,d.wait||500,_.pick(d,"leading","trailing")));a.$memoize?this[b]=_.memoize(this[b]):a.$memoizeCPS&&(this[b]=_.cps.memoize(this[b]))}},this);_.intercept(this,"init",function(a){(_.hasArgs(this.constructor.prototype.init)?_.cps.sequence:_.sequence)([this._beforeInit,a.bind(this),this._afterInit]).call(this)});_.each(d,function(a,b){a&&a.$alias&&(this[b]=
this[Tags.unwrap(a)])},this);_.hasAsserts&&_.each(this.constructor.$requires,function(a,b){$assertTypeMatches(this[b],a)},this);!1===c.init||this.constructor.$defaults&&!1===this.constructor.$defaults.init||this.init()}),callTraitsMethod:function(a,b){_.isFunction(b)?_.cps.sequence(_.filter2(this.constructor.$traits||[],this.$(function(b){return(b=b.prototype[a])&&_.cps.arity0(_.noArgs(b)?b.asContinuation:b).bind(this)||!1})).concat(b.arity0))():_.sequence(_.filter2(this.constructor.$traits||[],this.$(function(b){return(b=
b.prototype[a])&&(_.hasArgs(b)?b.bind(this,_.identity):b.bind(this))||!1})))()},_beforeInit:function(a){if(this.initialized.already)throw Error("Component: I am already initialized. Probably you're doing it wrong.");this.callTraitsMethod("beforeInit",a)},init:function(){},_afterInit:function(a){var b=this.cfg;b.attach&&!_.isFunction(b.attach)&&this.attach(b.attach);b.attachTo&&!_.isFunction(b.attachTo)&&this.attachTo(b.attachTo);this.callTraitsMethod("afterInit",a);this.initialized(!0);_.each(this.constructor.$definition,
function(a,d){d+="Change";if(a&&a.$observableProperty){var e=b[d];if(_.isFunction(e))this[d](e)}},this)},initialized:$barrier(),beforeDestroy:function(){if(this.destroyed_)throw Error("Component: I am already destroyed. Probably you're doing it wrong.");if(this.destroying_)throw Error("Component: Recursive destroy() call detected. Probably you're doing it wrong.");this.destroying_=!0;this.enumMethods(_.off);_.each(this.children_,_.method("destroy"));this.children_=[]},destroy:function(){},afterDestroy:function(){_.each(this.constructor.$traits,
function(a){a.prototype.destroy&&a.prototype.destroy.call(this)},this);delete this.destroying_;this.parent_=void 0;this.destroyed_=!0},attachedTo:$property(function(){return this.parent_}),attachTo:function(a){if(a===this)throw Error("smells like time-travel paradox.. how else can I be parent of myself?");this.parent_!==a&&(void 0!==this.parent_&&this.parent_.children_.remove(this),void 0!==(this.parent_=a)&&this.parent_.children_.push(this));return this},detach:function(){return this.attachTo(void 0)},
attached:$property(function(){return this.children_}),attach:function(a){_.invoke(_.coerceToArray(a),"attachTo",this);return this},detachAll:function(){_.each(this.children_,function(a){a.parent_=void 0});this.children_=[];return this},destroyAll:function(){_.each(this.children_,function(a){a.parent_=void 0;a.destroy()});this.children_=[];return this}});
jQuery&&function(a){var b=function(b,d){return b.originalEvent.touches&&_.find(b.originalEvent.touches,function(b){return a(b.target).hasParent(d)})||b};a.svg=function(b){return a(document.createElementNS("http://www.w3.org/2000/svg",b))};a.fn.extend({item:function(a){return a?(this.length&&(this[0]._item=a),this):this.length?this[0]._item:void 0},hasWait:function(){return this.hasClass("i-am-busy")},waitUntil:function(a,b){this.addClass("i-am-busy").attr("disabled",!0);a(this.$(function(){this.removeClass("i-am-busy").removeAttr("disabled");
b&&b.apply(null,arguments)}));return this},hasParent:function(a){for(var b=this;0<b.length;){if(b[0]==(a[0]||a))return!0;b=b.parent()}return!1},nonemptyValue:function(){var b=a.trim(this.val());return 0==b.length?void 0:b},intValue:function(){var a=parseInt(this.nonemptyValue(),10);return isNaN(a)?void 0:a},hitTest:function(b){var d=this.offset(),e=b.clientX-d.left;b=b.clientY-d.top;return 0<=e&&0<=b&&e<a(this).width()&&b<a(this).height()},attrs:function(){return _.object(_.map(arguments,function(a){return[a,
this.attr(a)]},this))},belongsTo:function(a){return this.is(a)||this.parents(a).length},selectClass:function(a,b){return this.removeClass(_.values(b).join(" ")).addClass(b[a])},integerAttr:function(a){return(this.attr(a)||"").integerValue},eachChild:function(b,d){_.each(this.find(b),function(b){d(a(b))});return this},transitionend:function(a){return this.one("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd",a)},animationend:function(a){return this.one("animationend webkitAnimationEnd oAnimationEnd oanimation MSAnimationEnd",
a)},animateWith:function(a,b){this.addClass(a);this.animationend(this.$(function(){this.removeClass(a);b&&b.call(this)}));return this},drag:function(c){Platform.touch||window.__globalDragOverlay||(window.__globalDragOverlay=a("<div>").css({display:"none",position:"fixed",top:0,right:0,bottom:0,left:0,zIndex:999999}).appendTo(document.body));var d=window.__globalDragOverlay,e=this.$(function(e){var f=c.relativeTo||this;if(Platform.touch||1===e.which){var h=f.offset(),k=void 0;if(!c.start||!1!==(k=
c.start.call(this,new Vec2(e.pageX-h.left,e.pageY-h.top),e))){var m=void 0,l=void 0,n=void 0,k=_.clone(k),p=this.$(function(a){if(Platform.touch||1===a.which){a.preventDefault();a=b(a,this[0]);var d=f.offset();k=c.move.call(this,k,new Vec2(a.pageX-e.pageX,a.pageY-e.pageY),new Vec2(a.pageX-d.left,a.pageY-d.top),a)||k}else m(a)}),l=function(){a(d||document.body).css(d?{display:"none"}:{}).off("mouseup touchend",n).off("mousemove touchmove",p)},n=this.$(function(a){l();c.end&&(a=b(a,this[0]),c.end.call(this,
k,new Vec2(a.pageX-e.pageX,a.pageY-e.pageY),a))}),m=this.$(function(a){l();n(a)});a(d||document.body).css(d?{display:"",cursor:c.cursor||""}:{}).on("mousemove touchmove",p).one("mouseup touchend",n);c.callMoveAtStart&&c.move.call(this,k,Vec2.zero,new Vec2(e.pageX-h.left,e.pageY-h.top),e)}}});return this.on(Platform.touch?"touchstart":"mousedown",_.$(this,function(a){var d=_.extend({},b(a,this[0]));if(Platform.touch&&c.longPress){var h=void 0,k=window.setTimeout(_.$(this,function(){this.off("touchmove touchend",
h);e(d)}),300),h=this.$(function(){window.clearTimeout(k);this.off("touchmove touchend",h)});this.one("touchmove touchend",h)}else e(d),a.preventDefault(),a.stopPropagation()}))},selectorItem:function(b){var d=_.extend({detoggleable:!0},b);return this.touchClick(function(b){var c=a(this);if(b.target===b.delegateTarget||"BUTTON"!==b.target.tagName&&"A"!==b.target.tagName)d.detoggleable?c.toggleClass("active"):c.addClass("active"),d.multiByDefault||d.multi&&(b.altKey||b.ctrlKey||b.shiftKey)||(c.siblings().removeClass("active"),
c.hasClass("inner")&&c.parent().siblings().children().removeClass("active")),d.multi||d.multiByDefault?d.selectionChanged(c.parent().children(".active")):d.selectionChanged(c.hasClass("active")?c:a()),b.preventDefault();return!1},{disableTouch:d.touchClick?!1:!0})},transform:function(a){return this.css("-webkit-transform",(a.translate?"translate("+a.translate.x+"px,"+a.translate.y+"px) ":"")+(a.rotate?"rotate("+a.rotate+"rad) ":"")+(a.scale?"scale("+a.scale.x+","+a.scale.y+")":""))},outerExtent:function(){return new Vec2(this.outerWidth(),
this.outerHeight())},extent:function(){return new Vec2(this.width(),this.height())},innerExtent:function(){return new Vec2(this.innerWidth(),this.innerHeight())},outerBBox:function(){return BBox.fromLTWH(_.extend(this.offset(),this.outerExtent().asWidthHeight))},leftTop:function(){return new Vec2.fromLT(this.offset())},offsetInParent:function(){return Vec2.fromLeftTop(this.offset()).sub(Vec2.fromLeftTop(this.parent().offset()))},caret:function(){var a=this[0];if(a.selectionStart)return a.selectionStart;
if(!document.selection)return 0;var b=document.selection.createRange(),e=b.duplicate(),g=0;e.moveToElementText(a);b.text="\u0001";g=e.text.indexOf("\u0001");b.moveStart("character",-1);b.text="";return g},monitorInput:function(b){var d=function(){""===a.trim(a(this).val())?b.empty(!0):b.empty(!1)};return this.keyup(d).change(d).focus(_.bind(b.focus||_.noop,b,!0)).blur(_.bind(b.focus||_.noop,b,!1))},touchDoubleclick:function(a){if(Platform.touch){var b=Date.now();return this.on("touchend",function(){var e=
Date.now();200>e-b&&a.apply(this,arguments);b=e})}return this.dblclick(a)},touchClick:function(a,b){var e=this;b=b||{};if(!b.disableTouch&&Platform.touch){var g=function(b){a.apply(this,arguments);b.preventDefault();return!1},f=function(a){a.preventDefault();return!1};b.handler&&b.handler({unbind:function(){e.off("touchstart",g).off("click",f)}});return this.on("touchstart",g).on("click",f)}b.handler&&b.handler({unbind:function(){e.off("click",a)}});return this.click(a)},translate:function(a){return this.attr("transform",
"translate("+a.x+","+a.y+")")},transform:function(a){a=a.components;return this.attr("transform","matrix("+a[0][0]+","+a[1][0]+","+a[0][1]+","+a[1][1]+","+a[0][2]+","+a[1][2]+")")},clientBBox:function(){var a=this[0].getBoundingClientRect();return new BBox(a.left,a.top,a.width,a.height)}})}(jQuery);