forked from xpl/gop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuseless.devtools.min.js
62 lines (62 loc) · 35 KB
/
useless.devtools.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
_.defineTagKeyword("required");_.defineTagKeyword("atom");_.defineKeyword("any",_.identity);
(function(){_.isMeta=function(a){return a===$any||!0===$atom.is(a)||!0===$required.is(a)};var a=function(a,b,c){var d=Tags.unwrapAll(_.filter2(a,$required.matches));a=_.nonempty(_.zip2(Tags.unwrapAll(a),b,c));if(_.isEmpty(d))return a;c=_.nonempty(_.zip2(d,b,c));return _.values2(d).length===_.values2(c).length?a:_.coerceToEmpty(b)},b=_.hyperOperator(_.binary,function(b,c,d){var g=Tags.unwrap(b);if(_.isArray(g)){if(_.isArray(c))return a(_.times(c.length,_.constant(g[0])),c,d)}else if(_.isStrictlyObject(g)&&
g["*"]){if(_.isStrictlyObject(c))return a(_.extend(_.map2(c,_.constant(g["*"])),_.omit(g,"*")),c,d)}else return a(b,c,d)}),c=function(a,b){var c=Tags.unwrap(a);return void 0===c&&void 0===b||_.isFunction(c)&&(_.isPrototypeConstructor(c)?_.isTypeOf(c,b):c(b))||typeof b===c||b===c};_.mismatches=function(a,c,d){return b(c,d,function(b,c){return a(b,c)?void 0:b})};_.omitMismatches=function(a,c,d){return b(c,d,function(b,c){return a(b,c)?c:void 0})};_.typeMismatches=_.partial(_.mismatches,c);_.omitTypeMismatches=
_.partial(_.omitMismatches,c);_.valueMismatches=_.partial(_.mismatches,function(a,b){return a===$any||b===$any||a===b});var d=function(a){if(_.isArray(a))return _.nonempty([_.reduce(_.rest(a),function(a,b){return _.undiff(a,b)},_.first(a)||void 0)]);if(_.isStrictlyObject(a)){var b=_.pairs(a),b=_.map(_.reduce(_.rest(b),function(a,b){return _.undiff(a,b)},_.first(b)||[void 0,void 0]),_.nonempty);return _.isEmpty(b)||_.isEmpty(b[1])?a:_.object([[b[0]||"*",b[1]]])}return a};_.decideType=function(a){return _.hyperOperator(_.unary,
function(a,b){return a&&a.constructor&&a.constructor.$definition?a.constructor:d(_.map2(a,b))})(a,function(a){return _.isPrototypeInstance(a)?a.constructor:_.isEmptyArray(a)?a:typeof a})}})();_.hasAsserts=!0;
_.extend(_,{tests:{},withTest:function(a,b,c){c();_.runTest(b);_.publishToTestsNamespace(a,b)},deferTest:function(a,b,c){c();_.publishToTestsNamespace(a,b)},runTest:function(a){_.isFunction(a)?a():_.each(a,function(a){a()})},publishToTestsNamespace:function(a,b){_.isArray(a)?(_.tests[a[0]]||(_.tests[a[0]]={}))[a[1]]=b:_.tests[a]=b}});
_.extend(_,_.asyncAssertions={assertCPS:function(a,b,c){var d=b&&(_.isArray(b)?b:[b])||[];a(function(){$assert([].splice.call(arguments,0),d);c&&c()})},assertCalls:function(a,b,c){var d=0,e=function(){d++};2<=b.length?b.call(this,e,function(){$assert(a,d);c&&c()}):(b.call(this,e),$assert(a,d),c&&c())}});
_.extend(_,_.assertions=_.extend({},_.asyncAssertions,{assert:function(a){var b=[].splice.call(arguments,0);1===b.length?!0!==b[0]&&_.assertionFailed({notMatching:b}):_.allEqual(b)||_.assertionFailed({notMatching:b});return!0},assertMatches:function(a,b){try{return _.assert(_.matches.apply(null,_.rest(arguments))(a))}catch(c){throw _.isAssertionError(c)?_.extend(c,{notMatching:[a,b]}):c;}},assertNotMatches:function(a,b){try{return _.assert(!_.matches.apply(null,_.rest(arguments))(a))}catch(c){throw _.isAssertionError(c)?
_.extend(c,{notMatching:[a,b]}):c;}},assertType:function(a,b){return _.assert(_.decideType(a),b)},assertTypeMatches:function(a,b){return _.isEmpty(_.typeMismatches(b,a))?!0:_.assertionFailed({asColumns:!0,notMatching:[{value:a},{type:_.decideType(a)},{contract:b},{mismatches:void 0}]})},assertFails:function(a){_.assertThrows.call(this,a,_.isAssertionError)},assertThrows:function(a,b){var c=void 0,d=!1;try{a.call(this)}catch(e){c=e,d=!0}_.assert.call(this,d);1===arguments.length&&_.assertMatches.apply(this,
[c].concat(_.rest(arguments)))},assertNotThrows:function(a){_.assertCalls.call(this,0,function(){a()})},assertArguments:function(a,b,c){b=(b||a.callee).toString();var d=b.match(/.*function[^\(]\(([^\)]+)\)/);if(d){a=_.asArray(a);var d=_.map(d[1].split(","),function(a){a="_"===a.trim()[0]?a.replace(/_/g," ").trim():void 0;var b=parseInt(a,10);return _.isFinite(b)?b:a}),e=_.zipWith([d,a],function(a,b){return void 0===a?!0:a===b});_.every(e)||_.assertionFailed({notMatching:_.nonempty([[c,b].join(": "),
d,a])})}},fail:function(){_.assertionFailed()},fails:_.constant(function(){_.assertionFailed()}),stub:function(){_.assertionFailed()}}));_.extend(_,{assertionError:function(a){return _.extend(Error("assertion failed"),a,{assertion:!0})},assertionFailed:function(a){throw _.extend(_.assertionError(a),{stack:_.rest(Error().stack.split("\n"),3).join("\n")});},isAssertionError:function(a){return!0===a.assertion}});
_.extend(_,{allEqual:function(a){return _.reduce(a,function(b,c){return b&&_.isEqual(a[0],c)},!0)}});_.each(_.keys(_.assertions),function(a){_.defineGlobalProperty("$"+a,_[a],{configurable:!0})});
_.mixin({log:function(a,b){console.log.apply(console.log,_.times(arguments.callee.depth||0,_.constant("\u2192 ")).concat([b||"_.log:",a]));return a},logs:function(a,b){return function(){_.log.depth=(_.log.depth||0)+1;_.log(_.first(arguments,b),"inp:");var c=_.log(a.apply(this,arguments),"out:");console.log("\n");_.log.depth--;return c}}});
(function(){var a=function(a){var c=arguments.callee.chain;arguments.callee.chain=_.reject(c,_.property("catchesOnce"));if(c.length)for(var d=0,e=c.length;d<e;d++)try{c[d](a);break}catch(f){if(d===e-1)throw f;f&&"object"===typeof f&&(f.originalError=a);a=f}else throw console.log("Uncaught exception: ",a),a;};_.withUncaughtExceptionHandler=function(b,c){var d=c||_.identity;c&&(b.catchesOnce=!0);a.chain.unshift(b);d(function(){a.chain.remove(b)})};a.chain=[];switch(Platform.engine){case "node":require("process").on("uncaughtException",
a);break;case "browser":window.addEventListener("error",function(b){b.error?a(b.error):a(_.extend(Error(b.message),{stub:!0,stack:"at "+b.filename+":"+b.lineno+":"+b.colno}))})}})();_.hasReflection=!0;_.defineKeyword("callStack",function(){return CallStack.fromRawString(CallStack.currentAsRawString).offset(Platform.NodeJS?1:0)});_.defineKeyword("currentFile",function(){return(CallStack.rawStringToArray(CallStack.currentAsRawString)[Platform.NodeJS?3:1]||{file:""}).file});
_.defineKeyword("uselessPath",_.memoize(function(){return _.initial($currentFile.split("/"),Platform.NodeJS?2:1).join("/")+"/"}));_.defineKeyword("sourcePath",_.memoize(function(){var a=($uselessPath.match(/(.+)\/node_modules\/(.+)/)||[])[1];return a?a+"/":$uselessPath}));
SourceFiles=$singleton(Component,{apiConfig:{},line:function(a,b,c){SourceFiles.read(a,function(a){c((a.split("\n")[b]||"").trimmed)})},read:$memoizeCPS(function(a,b){if(0>a.indexOf("<"))try{Platform.NodeJS?b(require("fs").readFileSync(a,{encoding:"utf8"})||""):jQuery.get(a,b,"text")}catch(c){b("")}else b("")}),write:function(a,b,c){Platform.NodeJS?this.read(a,function(d){var e=require("fs"),f={encoding:"utf8"};try{e.mkdirSync(a+".backups")}catch(h){}e.writeFileSync(a+".backups/"+Date.now(),d,f);
e.writeFileSync(a,b,f);c()}):API.post("source/"+a,_.extend2({},this.apiConfig,{what:{text:b},failure:Panic,success:function(){log.ok(a,"\u2014 successfully saved");c&&c()}}))}});_.readSourceLine=SourceFiles.line;_.readSource=SourceFiles.read;_.writeSource=SourceFiles.write;
CallStack=$extends(Array,{current:$static($property(function(){return CallStack.fromRawString(CallStack.currentAsRawString).offset(1)})),fromError:$static(function(a){return a&&a.parsedStack?CallStack.fromParsedArray(a.parsedStack).offset(a.stackOffset||0):a&&a.stack?CallStack.fromRawString(a.stack).offset(a.stackOffset||0):CallStack.fromParsedArray([])}),locationEquals:$static(function(a,b){return a.file===b.file&&a.line===b.line&&a.column===b.column}),safeLocation:function(a){return this[a]||{callee:"",
calleeShort:"",file:"",fileName:"",fileShort:"",thirdParty:!1,source:"??? WRONG LOCATION ???",sourceReady:_.barrier("??? WRONG LOCATION ???")}},mergeDuplicateLines:$property(function(){return CallStack.fromParsedArray(_.map(_.partition2(this,function(a){return a.file+a.line}),function(a){return _.reduce(_.rest(a),function(a,c){a.callee+=" \u2192\u00a0"+c.callee;a.calleeShort+=" \u2192 "+c.calleeShort;return a},_.clone(a[0]))}))}),clean:$property(function(){return this.mergeDuplicateLines.reject(_.property("thirdParty"))}),
asArray:$property(function(){return _.asArray(this)}),offset:function(a){return a&&CallStack.fromParsedArray(_.rest(this,a))||this},initial:function(a){return a&&CallStack.fromParsedArray(_.initial(this,a))||this},concat:function(a){return CallStack.fromParsedArray(this.asArray.concat(a.asArray))},filter:function(a){return CallStack.fromParsedArray(_.filter(this,a))},reject:function(a){return CallStack.fromParsedArray(_.reject(this,a))},reversed:$property(function(){return CallStack.fromParsedArray(_.reversed(this))}),
sourcesReady:function(a){return _.allTriggered(_.pluck(this,"sourceReady"),a)},constructor:function(a){Array.prototype.constructor.call(this);_.each(a,function(a){a.sourceReady||(a.sourceReady=_.barrier(),SourceFiles.line((a.remote?"api/source/":"")+a.file,a.line-1,function(c){a.sourceReady(a.source=c)}));this.push(a)},this)},fromParsedArray:$static(function(a){return new CallStack(a)}),currentAsRawString:$static($property(function(){var a=Platform.Browser?3:2;return _.rest((Error().stack||"").split("\n"),
a).join("\n")})),shortenPath:$static(function(a){return a.replace($uselessPath,"").replace($sourcePath,"")}),isThirdParty:$static(_.bindable(function(a){var b=a.replace($sourcePath,"");return Platform.NodeJS&&"/"!==a[0]||0<=b.indexOf("/node_modules/")||0<=a.indexOf("/node_modules/")&&!b||0<=b.indexOf("underscore")||0<=b.indexOf("jquery")})),fromRawString:$static(_.sequence(function(a){return CallStack.rawStringToArray(a)},function(a){return _.map(a,function(a){return _.extend(a,{calleeShort:_.last(a.callee.split(".")),
fileName:_.last(a.file.split("/")),fileShort:CallStack.shortenPath(a.file),thirdParty:CallStack.isThirdParty(a.file)})})},function(a){return CallStack.fromParsedArray(a)})),rawStringToArray:$static(function(a){a=(a||"").split("\n");return _.filter2(a,function(a){a=a.trimmed;var c,d=[],e=!1,d=d=void 0;if((d=a.match(/at (.+) \((.+)\)/))||(d=a.match(/(.+)@(.+)/)))c=d[1],e="native"===d[2],d=_.rest(d[2].match(/(.*):(.+):(.+)/)||[]);else if(d=a.match(/^(at\s+)*(.+):([0-9]+):([0-9]+)/))d=_.rest(d,2);else return!1;
return 0<=(c||"").indexOf("__supressErrorReporting")?!1:{beforeParse:a,callee:c||"",index:Platform.Browser&&d[0]===window.location.href,"native":e,file:d[0]||"",line:(d[1]||"").integerValue,column:(d[2]||"").integerValue}})})});
$prototype.macro(function(a,b){var c=CallStack.currentAsRawString;a.$meta||(a.$meta=$static(_.cps.memoize(function(a){_.cps.find(CallStack.fromRawString(c).reversed,function(a,b){a.sourceReady(function(c){c=(c||"").match(/([A-z]+)\s*=\s*\$(prototype|singleton|component|extends|trait|aspect)/);b(c&&{name:c[1],type:c[2],file:a.fileShort}||!1)})},function(b){a(b||{})})})));return a});_.hasLog=!0;
_.extend(log=function(){return log.write.apply(this,arguments)},{Color:$prototype(),Config:$prototype(),cleanArgs:function(a){return _.reject(a,_.or(log.Color.isTypeOf,log.Config.isTypeOf))},read:function(a,b){return _.find(b,a.isTypeOf)||new a({})},modify:function(a,b,c){return _.reject(b,a.isTypeOf).concat(c(log.read(a,b)))}});
_.extend(log,{config:function(a){return new log.Config(a)},indent:function(a){return log.config({indent:a})},color:{red:new log.Color({shell:"\u001b[31m",css:"crimson"}),blue:new log.Color({shell:"\u001b[36m",css:"royalblue"}),orange:new log.Color({shell:"\u001b[33m",css:"saddlebrown"}),green:new log.Color({shell:"\u001b[32m",css:"forestgreen"})},readColor:log.read.partial(log.Color),readConfig:log.read.partial(log.Config),modifyColor:log.modify.partial(log.Color),modifyConfig:log.modify.partial(log.Config),
boldLine:"======================================",line:"--------------------------------------",thinLine:"......................................",withCustomWriteBackend:function(a,b,c){var d=log.impl.writeBackend;log.impl.writeBackend=a;b(function(){log.impl.writeBackend=d;c&&c()})},writeUsingDefaultBackend:function(){var a=arguments;log.withCustomWriteBackend(log.impl.defaultWriteBackend,function(b){log.write.apply(null,a);b()})},impl:{write:function(a){return $restArg(function(){var b=_.asArray(arguments),
c=log.cleanArgs(b),d=_.extend({indent:0},a,log.readConfig(b)),e=Platform.NodeJS?3:2,f=(log.impl.writeBackend.indent||0)+d.indent,h=log.impl.stringifyArguments(c,d),f=_.times(f,_.constant("\t")).join(""),h=h.reversed.match(/(\n*)([^]*)/),d=d.location&&log.impl.location(d.where||$callStack[e+(d.stackOffset||0)])||"",b={color:log.readColor(b),indentedText:h[2].reversed.split("\n").map(_.prepends(f)).join("\n"),trailNewlines:h[1],codeLocation:d};log.impl.writeBackend(b);return c[0]})},defaultWriteBackend:function(a){var b=
a.color,c=a.indentedText,d=a.codeLocation;a=a.trailNewlines;(b=b&&(Platform.NodeJS?b.shell:b.css))?Platform.NodeJS?console.log(b+c+"\u001b[0m",d,a):(c=c.split("\n"),c=[_.first(c)||""].concat(_.rest(c).map(_.prepends(" "))),console.log("%c"+c.join("\n"),"color: "+b,d,a)):console.log(c,d,a)},location:function(a){return _.quoteWith("()",_.nonempty([a.calleeShort,a.fileName+":"+a.line]).join(" @ "))},stringifyArguments:function(a,b){return _.map(a,log.impl.stringify.tails2(b)).join(" ")},stringify:function(a,
b){b=b||{};if(_.isTypeOf(Error,a)){var c=log.impl.stringifyError(a);return a.originalError?c+"\n\n"+log.impl.stringify(a.originalError):c}return _.isTypeOf(CallStack,a)?log.impl.stringifyCallStack(a):"object"===typeof a?_.isArray(a)&&1<a.length&&_.isObject(a[0])&&b.table?log.asTable(a):_.stringify(a,b):"string"===typeof a?a:_.stringify(a)},stringifyError:function(a){try{var b=CallStack.fromError(a).clean.offset(a.stackOffset||0);return"[EXCEPTION] "+(a.message||"").replace(/\r|\n/g,"").trimmed.first(120)+
"\n\n"+log.impl.stringifyCallStack(b)+"\n"}catch(c){return"YO DAWG I HEARD YOU LIKE EXCEPTIONS... SO WE THREW EXCEPTION WHILE PRINTING YOUR EXCEPTION:\n\n"+c.stack+"\n\nORIGINAL EXCEPTION:\n\n"+a.stack+"\n\n"}},stringifyCallStack:function(a){return log.columns(a.map(function(a){return["\tat "+a.calleeShort.first(30),_.nonempty([a.fileShort,":",a.line]).join(""),(a.source||"").first(80)]})).join("\n")}}});
_.extend(log,log.printAPI={newline:log.impl.write().partial(""),write:log.impl.write(),red:log.impl.write().partial(log.color.red),blue:log.impl.write().partial(log.color.blue),orange:log.impl.write().partial(log.color.orange),green:log.impl.write().partial(log.color.green),failure:log.impl.write({location:!0}).partial(log.color.red),error:log.impl.write({location:!0}).partial(log.color.red),e:log.impl.write({location:!0}).partial(log.color.red),info:log.impl.write({location:!0}).partial(log.color.blue),
i:log.impl.write({location:!0}).partial(log.color.blue),w:log.impl.write({location:!0}).partial(log.color.orange),warn:log.impl.write({location:!0}).partial(log.color.orange),warning:log.impl.write({location:!0}).partial(log.color.orange),success:log.impl.write({location:!0}).partial(log.color.green),ok:log.impl.write({location:!0}).partial(log.color.green)});log.writes=log.printAPI.writes=_.higherOrder(log.write);log.impl.writeBackend=log.impl.defaultWriteBackend;
_.extend(log,{asTable:function(a){var b=a.map(_.keys.arity1).reduce(_.union.arity2,[]);a=log.columns([b].concat(_.map(a,function(a){return b.map(_.propertyOf(a))})),{maxTotalWidth:120,minColumnWidths:b.map(_.property("length"))});return[a[0],log.thinLine[0].repeats(a[0].length),_.rest(a)].flat.join("\n")},columns:function(a,b){if(0===a.length)return[];var c=a.map(_.map.tails2(function(a){return(a+"").split("\n")[0]})),d=c.map(_.map.tails2(_.property("length"))),e=d.zip(_.largest),f=b||{minColumnWidths:e,
maxTotalWidth:0},h=_.reduce(e,_.sum,0),g=_.map(e,_.muls(1/h)),k=Math.max(0,h-f.maxTotalWidth),l=_.map(e,function(a,b){return Math.max(f.minColumnWidths[b],Math.floor(a-k*g[b]))}),d=d.map(function(a){return[l,a].zip(_.subtract)});return[c,d].zip(_.zap.tails(function(a,b){return 0<=b?a+" ".repeats(b):_.initial(a,-b).join("")}).then(_.joinsWith(" ")))}});Platform.NodeJS&&(module.exports=log);_.defineTagKeyword("shouldFail");_.defineTagKeyword("async");_.defineTagKeyword("assertion");
Testosterone=$singleton({prototypeTests:[],isRunning:$property(function(){return void 0!==this.currentTest}),constructor:function(){this.defineAssertion("assertFails",$shouldFail(function(a){a.call(this)}));_.each(_.omit(_.assertions,"assertFails"),function(a,b){this.defineAssertion(b,b in _.asyncAssertions?$async(a):a)},this);(function(a){$prototype.macro("$test",a);$prototype.macro("$tests",a)})(this.$(function(a,b,c){this.prototypeTests.push({readPrototypeMeta:Tags.unwrap(a.$meta),tests:b});a[c]=
$static($property($constant(a[c])));return a}));this.run=this.$(this.run)},run:$interlocked(function(a,b){var c=_.last(arguments),d=3===arguments.length?b:_.identity,e=this.runConfig=_.extend({silent:!0,verbose:!1,timeout:2E3,testStarted:function(a){},testComplete:function(a){}},a),f=_.map(e.suites||[],this.$(function(a){return this.testSuite(a.name,a.tests,e.context)}));(!1===e.codebase?_.cps.constant([]):this.$(this.collectPrototypeTests))(this.$(function(a){var b=!1===e.codebase?[]:this.collectTests();
a=_.flatten(_.pluck(b.concat(f).concat(a),"tests"));a=_.filter(a,e.shouldRun||_.constant(!0));this.runningTests=_.map(a,function(a,b){return _.extend(a,{index:b})});_.cps.each(a,this.$(this.runTest),this.$(function(){_.assert(!0!==e.done);e.done=!0;this.printLog(e);this.failedTests=_.filter(this.runningTests,_.property("failed"));this.failed=0<this.failedTests.length;d(!this.failed);c()}))}))}),defineAssertions:function(a){_.each(a,function(a,c){this.defineAssertion(c,a)},this)},runTest:function(a,
b,c){var d=this,e=this.runConfig;this.currentTest=a;e.testStarted(a);a.verbose=e.verbose;a.timeout=e.timeout;a.run(function(){e.testComplete(a);delete d.currentTest;c()})},collectTests:function(){return _.map(_.tests,this.$(function(a,b){return this.testSuite(b,a)}))},collectPrototypeTests:function(a){_.cps.map(this.prototypeTests,this.$(function(a,c){a.readPrototypeMeta(this.$(function(d){c(this.testSuite(d.name,a.tests))}))}),a)},testSuite:function(a,b,c){return{name:a||"",tests:_(_.pairs("function"===
typeof b&&_.object([[a,b]])||b)).map(function(b){return new Test({name:b[0],routine:b[1],suite:a,context:c})})}},defineAssertion:function(a,b){var c=this;_.deleteKeyword(a);_.defineKeyword(a,Tags.modifySubject(b,function(d){return _.withSameArgs(d,function(){return c.currentTest?c.currentTest.runAssertion(a,b,d,arguments):d.apply(c,arguments)})}))},printLog:function(a){var b=_.filter(this.runningTests,function(b){return b.failed||!a.silent&&b.hasLog}),c=_.filter(this.runningTests,_.property("failed"));
_.invoke(a.verbose?this.runningTests:b,"printLog");c.length?log.orange("\n"+log.boldLine+"\nSOME TESTS FAILED:",_.pluck(c,"name").join(", "),"\n\n"):!0!==a.silent&&log.green("\n"+log.boldLine+"\nALL TESTS PASS\n\n")}});
Test=$prototype({constructor:function(a){_.extend(this,a,{assertionStack:_.observableRef([])});_.defaults(this,{name:"youre so dumb you cannot even think of a name?",failed:!1,routine:void 0,verbose:!1,depth:1,context:this})},currentAssertion:$property(function(){return this.assertionStack.value[0]}),waitUntilPreviousAssertionComplete:function(a){this.currentAssertion&&this.currentAssertion.async?this.assertionStack.when(_.isEmpty,function(){a()}):a()},runAssertion:function(a,b,c,d){var e=this,f=
{name:a,async:b.$async,shouldFail:b.$shouldFail,depth:e.depth+e.assertionStack.value.length+1,location:b.$async?$callStack.safeLocation(2):void 0};this.waitUntilPreviousAssertionComplete(function(){if(f.async)f=new Test(_.extend(f,{context:e.context,timeout:e.timeout/2,routine:Tags.modifySubject(b,function(a){return function(b){_.cps.apply(a,e.context,d,function(a,c){!f.failed&&c&&c.apply(e.context,a);b()})}})})),e.beginAssertion(f),f.run(function(){f.failed&&e.fail()?f.location.sourceReady(function(a){log.red(a,
log.config({location:f.location,where:f.location}));f.evalLogCalls();e.endAssertion(f)}):e.endAssertion(f)});else{e.beginAssertion(f);try{var a=c.apply(e.context,d);e.endAssertion(f);return a}catch(g){e.onException(g),e.endAssertion(f)}}})},beginAssertion:function(a){a.async&&(Testosterone.currentTest=a);this.assertionStack([a].concat(this.assertionStack.value))},endAssertion:function(a){Testosterone.currentTest===a&&(Testosterone.currentTest=this);if(a.shouldFail&&!a.failed)this.onException(_.assertionError({notMatching:"not failed (as should)"}));
this.assertionStack(_.without(this.assertionStack.value,a))},fail:function(){var a=_.find(_.rest(this.assertionStack.value),_.matches({shouldFail:!0}));return a?(a.failed=!0,!1):this.failed=!0},mapStackLocations:function(a,b){var c=this.assertionStack.value.copy,d=CallStack.fromError(a);d.sourcesReady(function(){b(_.map(c,function(a){return _.find(d,function(b,c){if(a.location&&CallStack.locationEquals(b,a.location)||0<=b.source.indexOf("$"+a.name))return d=d.offset(c+1),!0})||a.location||d.safeLocation(5)}))})},
onException:function(a,b){var c=this;if(this.done)throw a;this.fail()?this.mapStackLocations(a,function(d){0<c.logCalls.length&&log.newline();_.each(d.reversed,function(a,b){a&&log.red(log.config({indent:b,location:!0,where:a}),a.source)});if(_.isAssertionError(a)){if("notMatching"in a){var e=_.coerceToArray(a.notMatching);a.asColumns?log.orange(log.indent(d.length),log.columns(_.map(e,function(a){return["\u2022 "+_.keys(a)[0],_.stringify(_.values(a)[0])]})).join("\n")):_.each(e,function(a,b){log.orange(log.indent(d.length),
"\u2022",a)})}}else 1<c.depth&&log.newline(),log.write(log.indent(d.length),a);log.newline();b&&b.call(c)}):b&&b.call(this)},tryCatch:function(a,b){var c=this;c.afterUnhandledException=b;a.call(c.context,function(){c.afterUnhandledException=void 0;b()})},onUnhandledException:function(a){this.onException(a,function(){if(this.afterUnhandledException){var a=this.afterUnhandledException;this.afterUnhandledException=void 0;a()}})},run:function(a){var b=this;this.hasLog=this.failed=!1;this.logCalls=[];
this.assertionStack([]);this.failureLocations={};var c=Tags.unwrap(this.routine),d=function(a){var d=function(){b.done=!0;a()};try{_.noArgs(c)?(c.call(b.context),d()):b.tryCatch(c,d)}catch(e){b.onException(e,a)}},e=function(a){b.assertionStack.when(_.isEmpty,a)},f=_.withTimeout.partial({maxTime:b.timeout,expired:function(a){b.failed=!0;log.error("TIMEOUT EXPIRED");a()}}),h=log.withCustomWriteBackend.partial(_.extendWith({indent:b.depth},function(a){b.logCalls.push(a)})),g=_.withUncaughtExceptionHandler.partial(b.$(b.onUnhandledException));
h(function(c){g(function(g){f(function(a){_.cps.sequence(d,e,a)()},function(){b.routine.$shouldFail&&(b.failed=!b.failed);(b.hasLog=0<b.logCalls.length)||(b.failed?log.red("FAIL"):b.verbose&&log.green("PASS"));g();c();a()})})})},printLog:function(){var a=this.suite&&this.suite!==this.name&&(this.suite||"").quote("[]")||"";log.write(log.color.blue,"\n"+log.boldLine,"\n"+_.nonempty([a,this.name]).join(" "),(this.index+" of "+Testosterone.runningTests.length).quote("()")+(this.failed?" FAILED":"")+":",
"\n");this.evalLogCalls()},evalLogCalls:function(){_.each(this.logCalls,function(a){log.impl.writeBackend(a)})}});Platform.NodeJS&&(module.exports=Testosterone);_.measure=function(a,b){if(b){var c=_.now();a(function(){b(_.now()-c)})}else return c=_.now(),a(),_.now()-c};_.perfTest=function(a,b){var c=_.isFunction(a)?{test:a}:a,d={};_.cps.each(c,function(a,b,c){var g=[],k=function(){for(var c=0;500>c;c++)g.push(a());console.log(b,g)};k();_.delay(function(){d[b]=_.measure(k)/500;c()},100)},function(){b(d)})};
(function(a){"undefined"===typeof UI&&(UI={});Panic=function(a,c){c=_.defaults(_.clone(c||{}),{dismiss:_.identity});if(null!==a){_.isTypeOf(Error,a)&&_.extend(c,_.pick(a,"retry","dismiss"));Panic.widget.append(a);if(_.isFunction(c.retry))Panic.widget.onRetry(c.retry);if(_.isFunction(c.dismiss))Panic.widget.onClose(c.dismiss)}};Panic.init=function(){Panic._initialized||(Panic._initialized=!0,_.withUncaughtExceptionHandler(Panic.arity1))};Panic.widget=$singleton(Component,{retryTriggered:$triggerOnce(),
closeTriggered:$triggerOnce(),el:$memoized($property(function(){var b=a('<div class="panic-modal-overlay" style="z-index:5000; display:none;">').append([this.bg=a('<div class="panic-modal-overlay-background">'),this.modal=a('<div class="panic-modal">').append([this.modalBody=a('<div class="panic-modal-body">').append(this.title=a('<div class="panic-modal-title">Now panic!</div>')),a('<div class="panic-modal-footer">').append([this.btnRetry=a('<button type="button" class="panic-btn panic-btn-warning" style="display:none;">Try again</button>').touchClick(this.retry),
this.btnClose=a('<button type="button" class="panic-btn panic-btn-danger" style="display:none;">Close</button>').touchClick(this.close)])])]);a(document).ready(function(){b.appendTo(document.body)});this.initAutosize();this.modal.enableScrollFaders({scroller:this.modalBody});a(document).keydown(this.$(function(a){27===a.keyCode&&this.toggleVisibility(!1)}));return b})),initAutosize:function(){a(window).resize(this.$(function(){this.modal.css("max-height",a(window).height()-100);this.modalBody.scroll()})).resize()},
toggleVisibility:function(a){a!==("none"!==this.el.css("display"))&&(a&&this.el.css("display",""),this.el.animateWith(a?"panic-modal-appear":"panic-modal-disappear",this.$(function(){a||this.el.css("display","none")})))},onRetry:function(a){this.retryTriggered(a);this.btnRetry.show()},onClose:function(a){this.closeTriggered(a);this.btnClose.show()},retry:function(){this._clean();this.closeTriggered.off();this.toggleVisibility(!1);this.retryTriggered()},close:function(){this._clean();this.retryTriggered.off();
this.toggleVisibility(!1);this.closeTriggered()},_clean:function(){this.modalBody.find(".panic-alert-error").remove();this.modalBody.scroll();this.btnRetry.hide();this.btnClose.hide()},append:function(b){var c="panic"+this.hash(b),d=a("#"+c+" .panic-alert-counter");d.length?d.text((d.text()||"1").parsedInt+1):a('<div class="panic-alert-error">').attr("id",c).append('<span class="panic-alert-counter">').append(_.isTypeOf(Error,b)?this.printError(b):log.impl.stringify(b)).insertAfter(this.el.find(".panic-modal-title"));
this.toggleVisibility(!0);this.modalBody.scroll()},hash:function(a){return((_.isTypeOf(Error,a)?a&&a.stack:a)||"").hash},printError:function(b){for(var c=CallStack.fromError(b),d=b.asyncContext;d;)c=c.concat(CallStack.fromRawString(d.stack)),d=d.asyncContext;c=c.mergeDuplicateLines;return[a('<div class="panic-alert-error-message" style="font-weight: bold;">').text(b.message).append(_.any(c,function(a,b){return(a.thirdParty||a["native"])&&0!==b})?'<a class="clean-toggle" href="javascript:{}"></a>':
"").click(this.$(function(b){a(b.delegateTarget).parent().toggleClass("all").transitionend(this.$(function(){this.modalBody.scroll()}))})),a('<ul class="callstack">').append(_.map(c,this.$(function(b){var c=a('<li class="callstack-entry">').toggleClass("third-party",b.thirdParty).toggleClass("native",b["native"]).append([a('<span class="file">').text(_.nonempty([b.index?"(index)":b.fileShort,b.line]).join(":")),a('<span class="callee">').text(b.calleeShort),a('<span class="src i-am-busy">').click(this.$(function(d){var g=
a(d.delegateTarget);g.waitUntil(_.readSource.partial((b.remote?"api/source/":"")+b.file),this.$(function(d){c.is(".full")?(c.removeClass("full"),c.transitionend(function(){c.is(".full")||g.text(b.source)})):(c.addClass("full"),g.html(_.map(d.split("\n"),function(b){return a('<div class="line">').text(b)})),d=g.find(".line").eq(b.line-1).addClass("hili"),d.length&&(d=d.offset().top-g.offset().top,g.scrollTop(d-100)),_.delay(this.$(function(){var a=g.outerBBox().bottom+242-this.modalBody.outerBBox().bottom;
0<a&&this.modalBody.animate({scrollTop:this.modalBody.scrollTop()+a},250)})))}))}))]);b.sourceReady(function(a){c.find(".src").removeClass("i-am-busy").text(a)});return c})))]}});a.fn.extend({enableScrollFaders:function(b){var c=b&&b.horizontal,d,e;b=this.find(b&&b.scroller||".scroller");this.css({position:"relative"});this.append(d=a('<div class="scroll-fader scroll-fader-'+(c?"left":"top")+'"></div>')).append(e=a('<div class="scroll-fader scroll-fader-'+(c?"right":"bottom")+'"></div>'));b.scroll(function(){var b=
c?a(this).scrollLeft():a(this).scrollTop(),h=c?a(this).width():a(this).height(),g=c?this.scrollWidth:this.scrollHeight;d.css({opacity:0<b?1:0});e.css({opacity:b+h<g?1:0})}).scroll();return this}})})(jQuery);(function(a){Panic.init();CallStack.isThirdParty.intercept(function(a,c){return 0<=a.indexOf("underscore")||0<=a.indexOf("jquery")||0<=a.indexOf("useless")||0<=a.indexOf("mootools")});a("head").append(a('<style type="text/css">').text("@-webkit-keyframes bombo-jumbo {\n 0% { -webkit-transform: scale(0); }\n 80% { -webkit-transform: scale(1.2); }\n 100% { -webkit-transform: scale(1); } }\n\n@keyframes bombo-jumbo {\n 0% { transform: scale(0); }\n 80% { transform: scale(1.2); }\n 100% { transform: scale(1); } }\n\n@-webkit-keyframes pulse-opacity {\n 0% { opacity: 0.5; }\n 50% { opacity: 0.25; }\n 100% { opacity: 0.5; } }\n\n@keyframes pulse-opacity {\n 0% { opacity: 0.5; }\n 50% { opacity: 0.25; }\n 100% { opacity: 0.5; } }\n\n.i-am-busy { -webkit-animation: pulse-opacity 1s ease-in infinite; animation: pulse-opacity 1s ease-in infinite; pointer-events: none; }\n\n.panic-modal .scroll-fader-top, .scroll-fader-bottom { left: 42px; right: 42px; position: absolute; height: 20px; pointer-events: none; }\n.panic-modal .scroll-fader-top { top: 36px; background: -webkit-linear-gradient(bottom, rgba(255,255,255,0), rgba(255,255,255,1)); }\n.panic-modal .scroll-fader-bottom { bottom: 128px; background: -webkit-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,1)); }\n\n.panic-modal-appear {\n -webkit-animation: bombo-jumbo 0.25s cubic-bezier(1,.03,.48,1);\n animation: bombo-jumbo 0.25s cubic-bezier(1,.03,.48,1); }\n\n.panic-modal-disappear {\n -webkit-animation: bombo-jumbo 0.25s cubic-bezier(1,.03,.48,1); -webkit-animation-direction: reverse;\n animation: bombo-jumbo 0.25s cubic-bezier(1,.03,.48,1); animation-direction: reverse; }\n\n.panic-modal-overlay {\n display: -ms-flexbox; display: -moz-flex; display: -webkit-flex; display: flex;\n -ms-flex-direction: column; -moz-flex-direction: column; -webkit-flex-direction: column; flex-direction: column;\n -ms-align-items: center; -moz-align-items: center; -webkit-align-items: center; align-items: center;\n -ms-flex-pack: center; -ms-align-content: center; -moz-align-content: center; -webkit-align-content: center; align-content: center;\n -ms-justify-content: center; -moz-justify-content: center; -webkit-justify-content: center; justify-content: center;\n position: fixed; left: 0; right: 0; top: 0; bottom: 0;\n font-family: Helvetica, sans-serif; }\n\n.panic-modal-overlay-background { z-index: 1; position: absolute; left: 0; right: 0; top: 0; bottom: 0; background: white; opacity: 0.75; }\n\n.panic-modal { box-sizing: border-box; display: -webkit-flex; display: flex; position: relative; border-radius: 4px; z-index: 2; width: 600px; background: white; padding: 36px 42px 128px 42px; box-shadow: 0px 30px 80px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.15); }\n.panic-alert-counter { float: left; background: #904C34; border-radius: 8px; width: 17px; height: 17px; display: inline-block; text-align: center; line-height: 16px; margin-right: 1em; margin-left: -2px; font-size: 10px; color: white; font-weight: bold; }\n.panic-alert-counter:empty { display: none; }\n\n.panic-modal-title { color: black; font-weight: 300; font-size: 30px; opacity: 0.5; margin-bottom: 1em; }\n.panic-modal-body { overflow-y: auto; width: 100%; }\n.panic-modal-footer { text-align: right; position: absolute; left: 0; right: 0; bottom: 0; padding: 42px; }\n\n.panic-btn { margin-left: 1em; font-weight: 300; font-family: Helvetica, sans-serif; -webkit-user-select: none; user-select: none; cursor: pointer; display: inline-block; padding: 1em 1.5em; border-radius: 4px; font-size: 14px; border: 1px solid black; color: white; }\n.panic-btn:focus { outline: none; }\n.panic-btn:focus { box-shadow: inset 0px 2px 10px rgba(0,0,0,0.25); }\n\n.panic-btn-danger { background-color: #d9534f; border-color: #d43f3a; }\n.panic-btn-danger:hover { background-color: #c9302c; border-color: #ac2925; }\n\n.panic-btn-warning { background-color: #f0ad4e; border-color: #eea236; }\n.panic-btn-warning:hover { background-color: #ec971f; border-color: #d58512; }\n\n.panic-alert-error { border-radius: 4px; background: #FFE8E2; color: #904C34; padding: 1em 1.2em 1.2em 1.2em; margin-bottom: 1em; font-size: 14px; }\n\n.panic-alert-error { position: relative; text-shadow: 0px 1px 0px rgba(255,255,255,0.25); }\n\n.panic-alert-error .clean-toggle { height: 2em; text-decoration: none; font-weight: 300; position: absolute; color: black; opacity: 0.25; right: 1.2em; left: 0; top: 1em; display: block; text-align: right; }\n.panic-alert-error .clean-toggle:hover { text-decoration: underline; }\n.panic-alert-error .clean-toggle:before,\n.panic-alert-error .clean-toggle:after { position: absolute; right: 0; transition: all 0.25s ease-in-out; display: inline-block; overflow: hidden; }\n.panic-alert-error .clean-toggle:before { -webkit-transform-origin: center left; transform-origin: center left; content: 'more'; }\n.panic-alert-error .clean-toggle:after { -webkit-transform-origin: center left; transform-origin: center right; content: 'less'; }\n.panic-alert-error.all .clean-toggle:before { -webkit-transform: scale(0); transform: scale(0); }\n.panic-alert-error:not(.all) .clean-toggle:after { -webkit-transform: scale(0); transform: scale(0); }\n\n.panic-alert-error:last-child { margin-bottom: 0; }\n\n.panic-alert-error-message { line-height: 1.2em; }\n\n.panic-alert-error .callstack { font-size: 12px; margin: 2em 0 0.1em 0; font-family: Menlo, monospace; padding: 0; }\n\n.panic-alert-error .callstack-entry { white-space: nowrap; opacity: 1; transition: all 0.25s ease-in-out; margin-top: 10px; list-style-type: none; max-height: 38px; overflow: hidden; }\n.panic-alert-error .callstack-entry .file { }\n.panic-alert-error .callstack-entry .file:not(:empty) + .callee:not(:empty):before { content: ' \u2192 '; }\n\n.panic-alert-error:not(.all) .callstack-entry.third-party:not(:first-child),\n.panic-alert-error:not(.all) .callstack-entry.native:not(:first-child) { max-height: 0; margin-top: 0; opacity: 0; }\n\n.panic-alert-error .callstack-entry,\n.panic-alert-error .callstack-entry * { line-height: initial; }\n.panic-alert-error .callstack-entry .src { overflow: hidden; transition: height 0.25s ease-in-out; height: 22px; border-radius: 2px; cursor: pointer; margin-top: 2px; white-space: pre; overflow: hidden; display: block; color: black; background: rgba(255,255,255,0.75); padding: 4px; }\n.panic-alert-error .callstack-entry.full .src { font-size: 12px; height: 200px; overflow: scroll; }\n.panic-alert-error .callstack-entry.full .src .line.hili { background: yellow; }\n.panic-alert-error .callstack-entry.full { max-height: 220px; }\n\n.panic-alert-error .callstack-entry .src.i-am-busy { background: white; }\n\n.panic-alert-error .callstack-entry .src:empty { pointer-events: none; }\n.panic-alert-error .callstack-entry .src:empty:before { content: '<< SOURCE NOT LOADED >>'; color: rgba(0,0,0,0.25); }\n.panic-alert-error .callstack-entry.native .src:empty:before { content: '<< NATIVE CODE >>'; color: rgba(0,0,0,0.25); }\n.panic-alert-error .callstack-entry .src.i-am-busy:empty:before { content: '<< SOURCE LOADING >>'; color: rgba(0,0,0,0.5); }\n\n.panic-alert-error .callstack-entry .line:after { content: ' '; }\n"))})(jQuery);