13 lines
58 KiB
JavaScript
13 lines
58 KiB
JavaScript
|
/**
|
||
|
* UglifUI
|
||
|
* by Alex Sexton
|
||
|
*
|
||
|
* UglifyJS
|
||
|
* by Mihai Bazon, BSD license
|
||
|
*
|
||
|
* Underscore.js
|
||
|
* by Brad Dunbar
|
||
|
*
|
||
|
*/
|
||
|
(function(){})(),function(){var a=this,b=a._,c={},d=Array.prototype,e=Object.prototype,f=d.slice,g=d.unshift,h=e.toString,i=e.hasOwnProperty,j=d.forEach,k=d.map,l=d.reduce,m=d.reduceRight,n=d.filter,o=d.every,p=d.some,q=d.indexOf,r=d.lastIndexOf;e=Array.isArray;var s=Object.keys,t=function(a){return new y(a)};typeof module!="undefined"&&module.exports?(module.exports=t,t._=t):a._=t,t.VERSION="1.1.4";var u=t.each=t.forEach=function(a,b,d){if(a!=null)if(j&&a.forEach===j)a.forEach(b,d);else if(t.isNumber(a.length)){for(var e=0,f=a.length;e<f;e++)if(b.call(d,a[e],e,a)===c)break}else for(e in a)if(i.call(a,e)&&b.call(d,a[e],e,a)===c)break};t.map=function(a,b,c){var d=[];return a==null?d:k&&a.map===k?a.map(b,c):(u(a,function(a,e,f){d[d.length]=b.call(c,a,e,f)}),d)},t.reduce=t.foldl=t.inject=function(a,b,c,d){var e=c!==void 0;a==null&&(a=[]);if(l&&a.reduce===l)return d&&(b=t.bind(b,d)),e?a.reduce(b,c):a.reduce(b);u(a,function(a,f,g){!e&&f===0?(c=a,e=!0):c=b.call(d,c,a,f,g)});if(!e)throw new TypeError("Reduce of empty array with no initial value");return c},t.reduceRight=t.foldr=function(a,b,c,d){return a==null&&(a=[]),m&&a.reduceRight===m?(d&&(b=t.bind(b,d)),c!==void 0?a.reduceRight(b,c):a.reduceRight(b)):(a=(t.isArray(a)?a.slice():t.toArray(a)).reverse(),t.reduce(a,b,c,d))},t.find=t.detect=function(a,b,c){var d;return v(a,function(a,e,f){if(b.call(c,a,e,f))return d=a,!0}),d},t.filter=t.select=function(a,b,c){var d=[];return a==null?d:n&&a.filter===n?a.filter(b,c):(u(a,function(a,e,f){b.call(c,a,e,f)&&(d[d.length]=a)}),d)},t.reject=function(a,b,c){var d=[];return a==null?d:(u(a,function(a,e,f){b.call(c,a,e,f)||(d[d.length]=a)}),d)},t.every=t.all=function(a,b,d){b=b||t.identity;var e=!0;return a==null?e:o&&a.every===o?a.every(b,d):(u(a,function(a,f,g){if(!(e=e&&b.call(d,a,f,g)))return c}),e)};var v=t.some=t.any=function(a,b,d){b=b||t.identity;var e=!1;return a==null?e:p&&a.some===p?a.some(b,d):(u(a,function(a,f,g){if(e=b.call(d,a,f,g))return c}),e)};t.include=t.contains=function(a,b){var c=!1;return a==null?c:q&&a.indexOf===q?a.indexOf(b)!=-1:(v(a,function(a){if(c=a===b)return!0}),c)},t.invoke=function(a,b){var c=f.call(arguments,2);return t.map(a,function(a){return(b?a[b]:a).apply(a,c)})},t.pluck=function(a,b){return t.map(a,function(a){return a[b]})},t.max=function(a,b,c){if(!b&&t.isArray(a))return Math.max.apply(Math,a);var d={computed:-Infinity};return u(a,function(a,e,f){e=b?b.call(c,a,e,f):a,e>=d.computed&&(d={value:a,computed:e})}),d.value},t.min=function(a,b,c){if(!b&&t.isArray(a))return Math.min.apply(Math,a);var d={computed:Infinity};return u(a,function(a,e,f){e=b?b.call(c,a,e,f):a,e<d.computed&&(d={value:a,computed:e})}),d.value},t.sortBy=function(a,b,c){return t.pluck(t.map(a,function(a,d,e){return{value:a,criteria:b.call(c,a,d,e)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")},t.sortedIndex=function(a,b,c){c=c||t.identity;for(var d=0,e=a.length;d<e;){var f=d+e>>1;c(a[f])<c(b)?d=f+1:e=f}return d},t.toArray=function(a){return a?a.toArray?a.toArray():t.isArray(a)?a:t.isArguments(a)?f.call(a):t.values(a):[]},t.size=function(a){return t.toArray(a).length},t.first=t.head=function(a,b,c){return b&&!c?f.call(a,0,b):a[0]},t.rest=t.tail=function(a,b,c){return f.call(a,t.isUndefined(b)||c?1:b)},t.last=function(a){return a[a.length-1]},t.compact=function(a){return t.filter(a,function(a){return!!a})},t.flatten=function(a){return t.reduce(a,function(a,b){return t.isArray(b)?a.concat(t.flatten(b)):(a[a.length]=b,a)},[])},t.without=function(a){var b=f.call(arguments,1);return t.filter(a,function(a){return!t.include(b,a)})},t.uniq=t.unique=function(a,b){return t.reduce(a,function(a,c,d){if(0==d||(b===!0?t.last(a)!=c:!t.include(a,c)))a[a.length]=c;return a},[])},t.intersect=function(a){var b=f.call(arguments,1);return t.filter(t.uniq(a),function(a){return t.every(b,function(b){return t.indexOf(b,a)>=0})})},t.zip=function(){for(var a=f.call(arguments),b=t.max(t.pluck(a,"length")),c=Array(b),d=0;d<b;d++)c[d]=t.pluck(a,""+d);return c},t.indexOf=function(a,b,c){if(a==null)return-1;if(c)return c=t.so
|
||
|
:function(a,b){return[this[0],c(a),c(b)]},"do":function(a,b){return[this[0],c(a),c(b)]},"return":function(a){return[this[0],c(a)]},binary:function(a,b,d){return[this[0],a,c(b),c(d)]},"unary-prefix":function(a,b){return[this[0],a,c(b)]},"unary-postfix":function(a,b){return[this[0],a,c(b)]},sub:function(a,b){return[this[0],c(a),c(b)]},object:function(a){return[this[0],I(a,function(a){return a.length==2?[a[0],c(a[1])]:[a[0],c(a[1]),a[2]]})]},regexp:function(a,b){return[this[0],a,b]},array:function(a){return[this[0],I(a,c)]},stat:function(a){return[this[0],c(a)]},seq:function(){return[this[0]].concat(I(z(arguments),c))},label:function(a,b){return[this[0],a,c(b)]},"with":function(a,b){return[this[0],c(a),c(b)]},atom:function(a){return[this[0],a]}},g={},h=[];return{walk:c,dive:d,with_walkers:e,parent:function(){return h[h.length-2]},stack:function(){return h}}}function c(a){this.names={},this.mangled={},this.rev_mangled={},this.cname=-1,this.refs={},this.uses_with=!1,this.uses_eval=!1,this.parent=a,this.children=[],a?(this.level=a.level+1,a.children.push(this)):this.level=0}function d(a){function d(a){j=new c(j),j.labels=new c;var b=j.body=a();return b.scope=j,j=j.parent,b}function e(a,b){return j.define(a,b)}function f(a){j.refs[a]=!0}function g(a,b,c){var f=this[0]=="defun";return[this[0],f?e(a,"defun"):a,b,d(function(){return f||e(a,"lambda"),I(b,function(a){e(a,"arg")}),I(c,l)})]}function h(a){return function(b){I(b,function(b){e(b[0],a),b[1]&&f(b[0])})}}function i(a){a&&(j.labels.refs[a]=!0)}var j=null,k=b(),l=k.walk,m=[];return d(function(){function b(a,c){for(c=a.children.length;--c>=0;)b(a.children[c]);for(c in a.refs)if(x(a.refs,c))for(var d=a.has(c),e=a;e;e=e.parent){e.refs[c]=d;if(e===d)break}}var c=k.with_walkers({"function":g,defun:g,label:function(a,b){j.labels.define(a)},"break":i,"continue":i,"with":function(a,b){for(var c=j;c;c=c.parent)c.uses_with=!0},"var":h("var"),"const":h("const"),"try":function(a,b,c){if(b!=null)return[this[0],I(a,l),[e(b[0],"catch"),I(b[1],l)],c!=null?I(c,l):null]},name:function(a){a=="eval"&&m.push(j),f(a)}},function(){return l(a)});return I(m,function(a){if(!a.has("eval"))while(a)a.uses_eval=!0,a=a.parent}),b(j),c})}function e(a,c){function e(a,b){return!c.toplevel&&!m.parent?a:c.except&&A(a,c.except)?a:m.get_mangled(a,b)}function f(a){if(c.defines)return!m.has(a)&&x(c.defines,a)?c.defines[a]:null}function g(a,b,d){if(!c.no_functions){var f=this[0]=="defun",g;a&&(f?a=e(a):d.scope.references(a)?(g={},!m.uses_eval&&!m.uses_with?a=g[a]=m.next_mangled():g[a]=a):a=null)}return d=h(d.scope,function(){return b=I(b,function(a){return e(a)}),I(d,l)},g),[this[0],a,b,d]}function h(a,b,c){var d=m;m=a;if(c)for(var f in c)x(c,f)&&a.set_mangle(f,c[f]);for(var f in a.names)x(a.names,f)&&e(f,!0);var g=b();return g.scope=a,m=d,g}function i(a){return[this[0],I(a,function(a){return[e(a[0]),l(a[1])]})]}function j(a){if(a)return[this[0],m.labels.get_mangled(a)]}var k=b(),l=k.walk,m;return c=c||{},k.with_walkers({"function":g,defun:function(){var a=g.apply(this,arguments);switch(k.parent()[0]){case"toplevel":case"function":case"defun":return I.at_top(a)}return a},label:function(a,b){return m.labels.refs[a]?[this[0],m.labels.get_mangled(a,!0),l(b)]:l(b)},"break":j,"continue":j,"var":i,"const":i,name:function(a){return f(a)||[this[0],e(a)]},"try":function(a,b,c){return[this[0],I(a,l),b!=null?[e(b[0]),I(b[1],l)]:null,c!=null?I(c,l):null]},toplevel:function(a){var b=this;return h(b.scope,function(){return[b[0],I(a,l)]})}},function(){return l(d(a))})}function f(a,b){return s(a).length>s(b[0]=="stat"?b[1]:b).length?b:a}function g(a){return a[0]=="block"&&a[1]&&a[1].length>0?a[1][a[1].length-1]:a}function h(a){if(a)switch(g(a)[0]){case"return":case"break":case"continue":case"throw":return!0}}function i(a){return a[0]=="unary-prefix"&&A(a[1],["!","delete"])||a[0]=="binary"&&A(a[1],["in","instanceof","==","!=","===","!==","<","<=",">=",">"])||a[0]=="binary"&&A(a[1],["&&","||"])&&i(a[2])&&i(a[3])||a[0]=="conditional"&&i(a[2])&&i(a[3])||a[0]=="assign"&&a[1]===!0&&i(a[3])||a[0]=="seq"&&i(a[a.length-1])}function j(a){r
|