node-vitals
Version:
Do more with less. A simple, high-performing, functional JavaScript library.
88 lines (87 loc) • 42.9 kB
JavaScript
/* vitals-base.js v4.1.3 (http://vitalsjs.com)
* Copyright (c) 2016 Adam A Smith <adam@imaginate.life>
* The Apache License (http://vitalsjs.com/license) */
(function(t,z){function w(a,r){return"object"===a||!r&&"function"===a}function r(a,r){return(a=a&&r&&a.nodeType?!1:a)&&!r&&a.Object!==Object?!1:!!a}function C(a){a.vitals=z;a.Vitals=z}var D=w(typeof exports)&&r(exports,!0),E=w(typeof module)&&r(module,!0),F=w(typeof global,!0)&&r(global),x=w(typeof window)&&r(window),a=w(typeof self)&&r(self),A=w(typeof t)&&r(t);t=D&&E&&F?global:x&&window!==(t&&t.window)?window:a?self:A?t:Function("return this")();x&&C(window);a&&C(self);C(t);D&&E&&(module.exports===
exports?module.exports=z:C(exports));"function"===typeof define&&define.amd&&"object"===typeof define.amd&&define(function(){return z})})(this,function(t){function z(a,g){var l,k;l=a.length;for(k=-1;++k<l;)if(a[k]===g)return!0;return!1}function w(a){a="vitals."+a;var g=function(g,k){var m;k=k?a:a+"."+k;m=Error(g+" for "+k+" call.");m.__vitals=!0;m.vitals=!0;return m};g.type=function(g,k){var m;k=k?a:a+"."+k;m=new TypeError("Invalid "+(g+" param")+" in "+k+" call.");m.__vitals=!0;m.vitals=!0;return m};
g.range=function(g,k,m){m=m?a:a+"."+m;g="The "+(g+" param")+" was out-of-range for a "+m+" call.";k=new RangeError(g+(k?" The valid options are: "+k:""));k.__vitals=!0;k.vitals=!0;return k};return g}function r(a,g,l){var k,m;k=a.length;g=g?0>g?k+g:g:0;g=0>g?0:g;l=l===t||l>k?k:0>l?k+l:l;if(g>=l)return[];k=Array(l-g);--g;for(m=0;++g<l;)k[m++]=a[g];return k}function C(a,g,l){var k;k=a.length;g=g?0>g?k+g:g:0;g=0>g?0:g;l=l===t||l>k?k:0>l?k+l:l;return g>=l?"":a.substring(g,l)}var D=function(){var a=/[\\^$.*+?|(){}[\]]/g;
return function(g){return g.replace(a,"\\$&")}}(),E=function(){var a=Object.prototype.hasOwnProperty;return function(g,l){for(var k in g)if(a.call(g,k)&&g[k]===l)return!0;return!1}}(),F=function(){var a=String.prototype.includes?function(a,c){return a.includes(c)}:function(a,c){return-1!==a.indexOf(c)};return function(g,l){l=String(l);return g?l?a(g,l):!0:!l}}(),x=function(){var a=Object.prototype.hasOwnProperty;return function(g,l){for(var k in l)a.call(l,k)&&(g[k]=l[k]);return g}}(),a=function(){var a=
{nil:function(a){return null===a},undefined:function(a){return a===t},bool:function(a){return"boolean"===typeof a},str:function(a){return"string"===typeof a},_str:function(a){return!!a&&"string"===typeof a},num:function(a){return"number"===typeof a&&a===a},_num:function(a){return!!a&&"number"===typeof a&&a===a},nan:function(a){return a!==a}},g=Object.prototype.toString;a.obj=function(a){return!!a&&"object"===typeof a};a._obj=function(a){return(a=!!a&&typeof a)&&("object"===a||"function"===a)};a.func=
function(a){return!!a&&"function"===typeof a};a.arr=function(a){return!!a&&"object"===typeof a&&"[object Array]"===g.call(a)};a._arr=function(m){if(!a.obj(m))return!1;m=g.call(m);return"[object Array]"===m||"[object Arguments]"===m};a.regex=function(a){return!!a&&"object"===typeof a&&"[object RegExp]"===g.call(a)};a.date=function(a){return!!a&&"object"===typeof a&&"[object Date]"===g.call(a)};a.err=function(a){return!!a&&"object"===typeof a&&"[object Error]"===g.call(a)};a.args=function(a){return!!a&&
"object"===typeof a&&"[object Arguments]"===g.call(a)};(function(){if(!a.args(arguments)){a._arr=function(a){return!!a&&"object"===typeof a&&("[object Array]"===g.call(a)||"callee"in a)};a.args=function(a){return!!a&&"object"===typeof a&&"callee"in a};try{a.args({})}catch(m){a._arr=a.arr,a.args=function(){return!1}}}})();a.doc=function(a){return!!a&&"object"===typeof a&&9===a.nodeType};a.elem=function(a){return!!a&&"object"===typeof a&&1===a.nodeType};var l=Object.prototype.hasOwnProperty;a.empty=
function(a){var c;if(!a)return!0;if("function"===typeof a)return!a.length;if("object"!==typeof a)return!1;if("[object Array]"===g.call(a))return!a.length;for(c in a)if(l.call(a,c))return!1;return!0};var k=/^(?:cr|lf|crlf)$/i;a.eol=function(a){return k.test(a)};a.frozen=function(){if(!Object.isFrozen)return function(a){return!1};try{return Object.isFrozen(function(){}),Object.isFrozen}catch(a){return function(a){return"object"===typeof a&&Object.isFrozen(a)}}}();a.whole=function(a){return!(a%1)};a.odd=
function(a){return!!(a%2)};a.even=function(a){return!(a%2)};a.un={};a.un.bool=function(a){return a===t||"boolean"===typeof a};a.un.str=function(a){return a===t||"string"===typeof a};a.un.num=function(a){return a===t||"number"===typeof a&&a===a};a.un.obj=function(a){return a===t||!!a&&"object"===typeof a};a.un.func=function(a){return a===t||!!a&&"function"===typeof a};a.un.arr=function(a){return a===t||!!a&&"object"===typeof a&&"[object Array]"===g.call(a)};a.un.regex=function(a){return a===t||!!a&&
"object"===typeof a&&"[object RegExp]"===g.call(a)};a.nil.bool=function(a){return null===a||"boolean"===typeof a};a.nil.str=function(a){return null===a||"string"===typeof a};a.nil.num=function(a){return null===a||"number"===typeof a&&a===a};a.nil.obj=function(a){return null===a||!!a&&"object"===typeof a};a.nil.func=function(a){return null===a||!!a&&"function"===typeof a};a.nil.arr=function(a){return null===a||!!a&&"object"===typeof a&&"[object Array]"===g.call(a)};a.nil.regex=function(a){return null===
a||!!a&&"object"===typeof a&&"[object RegExp]"===g.call(a)};a.nil.un={};a.nil.un.bool=function(a){return null===a||a===t||"boolean"===typeof a};a.nil.un.str=function(a){return null===a||a===t||"string"===typeof a};a.nil.un.num=function(a){return null===a||a===t||"number"===typeof a&&a===a};a.nil.un.obj=function(a){return null===a||a===t||!!a&&"object"===typeof a};a.nil.un.func=function(a){return null===a||a===t||!!a&&"undefined"===typeof a};a.nil.un.arr=function(a){return null===a||a===t||!!a&&"object"===
typeof a&&"[object Array]"===g.call(a)};a.nil.un.regex=function(a){return null===a||a===t||!!a&&"object"===typeof a&&"[object RegExp]"===g.call(a)};return a}(),A=function(){var a=Object.prototype.toString,g=String.prototype.includes?function(a,c){return a.includes(c)}:function(a,c){return-1!==a.indexOf(c)};return function(l,k){var m;k&&"object"===typeof k&&"[object RegExp]"===a.call(k)?m=k.test(l):(m=String(k),m=l?m?g(l,m):!0:!m);return m}}(),q=function(){var a=Object.prototype.hasOwnProperty;return function(g,
l){return!!g&&a.call(g,l)}}(),I=function(){var a=Object.prototype.propertyIsEnumerable;return function(g,l){return!!g&&a.call(g,l)}}(),y=function(){var a=String.prototype.includes?function(a,c){return a.includes(c)}:function(a,c){return-1!==a.indexOf(c)};return function(g){var l;if(!g)return[""];l=a(g,", ")?", ":a(g,",")?",":a(g,"|")?"|":" ";return g.split(l)}}(),B=function(){function c(c,g){var l,k;if(2>arguments.length)throw d("No type or val");if(!a._str(c))throw d.type("types");if(e["*"](c))return!0;
a:{k=c;var m;e["="](k)&&(k+="|undefined");k=k.toLowerCase();k=k.replace(b,"");k=k.split("|");for(l=k.length;l--;){m="_"+k[l];if(!q(f,m)){k=null;break a}k[l]=f[m]}k=k.length?k:null}if(!k)throw d.range("types",h);l=c;m=e["?"](l);l=e["!"](l);l=(m&&l?0:m||l)?!l&&m:t;if(2<arguments.length)a:{m=arguments;var n;for(n=m.length;--n;)if(!p(k,m[n],l)){k=!1;break a}k=!0}else k=p(k,g,l);return k}function g(a,b){var d;for(d=a.length;d--;)if(!b(a[d]))return!1;return!0}function l(b){if(a.nil(b))return!1;if(!a._obj(b))throw d.type("val",
"frozen");return a.frozen(b)}function k(b){if(!a.num(b))throw d.type("val","whole");return a.whole(b)}function m(b){if(!a.num(b))throw d.type("val","odd");if(!a.whole(b))throw d.range("val","whole numbers","odd");return a.odd(b)}function n(b){if(!a.num(b))throw d.type("val","even");if(!a.whole(b))throw d.range("val","whole numbers","even");return a.even(b)}function p(a,b,d){var e;for(e=a.length;e--;)if(a[e](b,d))return!0;return!1}c["null"]=function(b){switch(arguments.length){case 0:throw d("Missing a val",
"null");case 1:return a.nil(b);default:return g(arguments,a.nil)}};c.nil=c["null"];c.undefined=function(b){switch(arguments.length){case 0:throw d("Missing a val","undefined");case 1:return a.undefined(b);default:return g(arguments,a.undefined)}};c["boolean"]=function(b){switch(arguments.length){case 0:throw d("Missing a val","boolean");case 1:return a.bool(b);default:return g(arguments,a.bool)}};c.bool=c["boolean"];c.string=function(b){switch(arguments.length){case 0:throw d("Missing a val","string");
case 1:return a.str(b);default:return g(arguments,a.str)}};c.str=c.string;c._string=function(b){switch(arguments.length){case 0:throw d("Missing a val","_string");case 1:return a._str(b);default:return g(arguments,a._str)}};c._str=c._string;c.number=function(b){switch(arguments.length){case 0:throw d("Missing a val","number");case 1:return a.num(b);default:return g(arguments,a.num)}};c.num=c.number;c._number=function(b){switch(arguments.length){case 0:throw d("Missing a val","_number");case 1:return a._num(b);
default:return g(arguments,a._num)}};c._num=c._number;c.nan=function(b){switch(arguments.length){case 0:throw d("Missing a val","nan");case 1:return a.nan(b);default:return g(arguments,a.nan)}};c.object=function(b){switch(arguments.length){case 0:throw d("Missing a val","object");case 1:return a.obj(b);default:return g(arguments,a.obj)}};c.obj=c.object;c._object=function(b){switch(arguments.length){case 0:throw d("Missing a val","_object");case 1:return a._obj(b);default:return g(arguments,a._obj)}};
c._obj=c._object;c.func=function(b){switch(arguments.length){case 0:throw d("Missing a val","function");case 1:return a.func(b);default:return g(arguments,a.func)}};c.fn=c.func;try{c["function"]=c.func}catch(G){}c.array=function(b){switch(arguments.length){case 0:throw d("Missing a val","array");case 1:return a.arr(b);default:return g(arguments,a.arr)}};c.arr=c.array;c._array=function(b){switch(arguments.length){case 0:throw d("Missing a val","_array");case 1:return a._arr(b);default:return g(arguments,
a._arr)}};c._arr=c._array;c.regexp=function(b){switch(arguments.length){case 0:throw d("Missing a val","regexp");case 1:return a.regex(b);default:return g(arguments,a.regex)}};c.regex=c.regexp;c.re=c.regexp;c.date=function(b){switch(arguments.length){case 0:throw d("Missing a val","date");case 1:return a.date(b);default:return g(arguments,a.date)}};c.error=function(b){switch(arguments.length){case 0:throw d("Missing a val","error");case 1:return a.err(b);default:return g(arguments,a.err)}};c.err=
c.error;c.args=function(b){switch(arguments.length){case 0:throw d("Missing a val","args");case 1:return a.args(b);default:return g(arguments,a.args)}};c.document=function(b){switch(arguments.length){case 0:throw d("Missing a val","document");case 1:return a.doc(b);default:return g(arguments,a.doc)}};c.doc=c.document;c.element=function(b){switch(arguments.length){case 0:throw d("Missing a val","element");case 1:return a.elem(b);default:return g(arguments,a.elem)}};c.elem=c.element;c.empty=function(b){switch(arguments.length){case 0:throw d("Missing a val",
"empty");case 1:return a.empty(b);default:return g(arguments,a.empty)}};c.frozen=function(a){switch(arguments.length){case 0:throw d("Missing a val","frozen");case 1:return l(a);default:return g(arguments,l)}};c.whole=function(a){switch(arguments.length){case 0:throw d("Missing a val","whole");case 1:return k(a);default:return g(arguments,k)}};c.odd=function(a){switch(arguments.length){case 0:throw d("Missing a val","odd");case 1:return m(a);default:return g(arguments,m)}};c.even=function(a){switch(arguments.length){case 0:throw d("Missing a val",
"even");case 1:return n(a);default:return g(arguments,n)}};var f=function(){function b(a,f,h){for(var c in f)q(f,c)&&d(a,c,f[c],h);return e}function d(b,f,h,c){h=q(d,b)?d[b](h):h;c=!1!==c;e["_"+f]=function(b,d){d=a.bool(d)?d:c;return a.nil(b)?d:h(b)};return e}var e={};d.arrays=function(b){return function(d){var e;if(!a.arr(d))return!1;for(e=d.length;e--;)if(!b(d[e]))return!1;return!0}};d.maps=function(b){return function(d){var e;if(!a.obj(d))return!1;for(e in d)if(q(d,e)&&!b(d[e]))return!1;return!0}};
e=b("primitives",{undefined:a.undefined,"boolean":a.bool,string:a.str,number:a.num,nan:a.nan},!1);e=d("primitives","null",a.nil);e=b("js_objects",{object:a.obj,regexp:a.regex,array:a.arr,date:a.date,error:a.err});e=d("js_objects","arguments",a.args);e=d("js_objects","function",a.func,!1);e=b("dom_objects",{element:a.elem,document:a.doc});e=d("others","empty",a.empty);e=b("arrays",{nulls:a.nil,booleans:a.bool,strings:a.str,numbers:a.num,nans:a.nan,objects:a.obj,functions:a.func,regexps:a.regex,arrays:a.arr,
dates:a.date,errors:a.err,elements:a.elem,documents:a.doc});e=b("maps",{nullmap:a.nil,booleanmap:a.bool,stringmap:a.str,numbermap:a.num,nanmap:a.nan,objectmap:a.obj,functionmap:a.func,regexpmap:a.regex,arraymap:a.arr,datemap:a.date,errormap:a.err,elementmap:a.elem,documentmap:a.doc});return e=function(a){var b,d;for(b in a)q(a,b)&&(d="_"+a[b],b="_"+b,e[b]=e[d]);return e}({nil:"null",bool:"boolean",str:"string",num:"number",obj:"object",func:"function",fn:"function",regex:"regexp",re:"regexp",arr:"array",
err:"error",args:"arguments",elem:"element",doc:"document",nils:"nulls",strs:"strings",nums:"numbers",bools:"booleans",objs:"objects",funcs:"functions",fns:"functions",regexs:"regexps",res:"regexps",arrs:"arrays",errs:"errors",elems:"elements",docs:"documents",nilmap:"nullmap",strmap:"stringmap",nummap:"numbermap",boolmap:"booleanmap",objmap:"objectmap",funcmap:"functionmap",fnmap:"functionmap",regexmap:"regexpmap",remap:"regexpmap",arrmap:"arraymap",errmap:"errormap",elemmap:"elementmap",docmap:"documentmap"})}(),
b=/[^a-z\|]/g,e=function(a,b,d,e,f){return{"|":function(b){return a.test(b)},"!":function(a){return b.test(a)},"?":function(a){return d.test(a)},"=":function(a){return e.test(a)},"*":function(a){return f.test(a)}}}(/\|/,/\!/,/\?/,/\=/,/\*|any/),d=w("is"),h="https://github.com/imaginate/vitals/wiki/vitals.is-types";return c}(),v=function(){function c(e,d){if(!arguments.length)throw b("Missing a val");if(!a.un.bool(d))throw b.type("deep");return a._obj(e)?a.func(e)?m(e,d):a._arr(e)?l(e,d):a.regex(e)?
k(e):g(e,d):e}function g(a,b){return b?n({},a):x({},a)}function l(a,b){var f;f=Array(a.length);return b?n(f,a):x(f,a)}function k(b,d){var h,c;h=p(b.source);var g;c="";for(g in f)q(f,g)&&b[g]&&(c+=f[g]);c=a.undefined(d)?c:F(c,"g")?d?c:c.replace("g",""):d?c+"g":c;return c?new RegExp(h,c):new RegExp(h)}function m(a,b){var f;f=function(){return a.apply(null,arguments)};return b?n(f,a):x(f,a)}function n(a,b){for(var f in b)q(b,f)&&(a[f]=c(b[f],!0));return a}c.object=function(e,d){if(!a.obj(e))throw b.type("obj",
"object");if(!a.un.bool(d))throw b.type("deep","object");return g(e,d)};c.obj=c.object;c.array=function(e,d){if(!a.obj(e))throw b.type("obj","array");if(!a.num(e.length))throw b.type("obj.length","array");if(!a.un.bool(d))throw b.type("deep","array");return l(e,d)};c.arr=c.array;c.args=c.array;c.regexp=function(e,d){if(!a.regex(e))throw b.type("regex","regexp");if(!a.un.bool(d))throw b.type("forceGlobal","regexp");return k(e,d)};c.re=c.regexp;c.regex=c.regexp;c.func=function(e,d){if(!a.func(e))throw b.type("func",
"function");if(!a.un.bool(d))throw b.type("deep","function");return m(e,d)};try{c.fn=c.func,c["function"]=c.func}catch(e){}var p=function(){var a="\\n"!==/\n/.source?/\\/g:null;return a?function(b){return b.replace(a,"\\\\")}:function(a){return a}}(),f=x({ignoreCase:"i",multiline:"m",global:"g"},"sticky"in RegExp.prototype?{sticky:"y"}:null),b=w("copy");return c}(),J=function(){function c(b,d,e){if(2>arguments.length)throw u("No val defined");if(a.str(b))return d=2<arguments.length?r(arguments,1):
d,a.arr(d)?p(b,d):n(b,d);if(!a._obj(b))throw u.type("source");b=a.args(b)?r(b):b;if(a.func(d)){if(!a.nil.un.obj(e))throw u.type("thisArg");return a.arr(b)?x(b,d,e):t(b,d,e)}d=2<arguments.length?r(arguments,1):d;return a.arr(d)?l(b,d):g(b,d)}function g(e,c){return a.arr(e)?a.num(c)?d(e,c):G(e,c):B("!str|regex",c)?f(e,c):b(e,c)}function l(b,d){var c;if(a.arr(b))c=B("nums",d)?h(b,d):H(b,d);else if(B("!str|regex",d[0])){c=b;var g,l,p;g=a.regex(d[0]);l=d.length;for(p=-1;++p<l;)c=f(c,d[p],g)}else c=e(b,
d);return c}function k(b,d,e){var f;f=b.length;d=0>d?f+d:d;if(d>=f)return b;if(a.undefined(e)){if(0>d)return b;b.splice(d,1);return b}d=0>d?0:d;e=e>f?f:0>e?f+e:e;if(d>=e)return b;b.splice(d,e-d);return b}function m(d,e){return a.arr(d)?G(d,e):b(d,e)}function n(b,d){a.regex(d)||(d=String(d),d=D(d),d=new RegExp(d,"g"));return b.replace(d,"")}function p(a,b){var d,e;d=b.length;for(e=-1;++e<d;)a=n(a,b[e]);return a}function f(b,d,e){e=a.undefined(e)?a.regex(d):e;if(!e)return q(b,d)&&delete b[d],b;e=d;
for(d in b)q(b,d)&&A(d,e)&&delete b[d];return b}function b(a,b){for(var d in a)q(a,d)&&a[d]===b&&delete a[d];return a}function e(a,d){var e,f;e=d.length;for(f=-1;++f<e;)a=b(a,d[f]);return a}function d(a,b){var d;d=a.length;b=0>b?d+b:b;if(0>b||b>=d)return a;a.splice(b,1);return a}function h(a,b){var e,f,c,h;if(!a.length||!b.length)return a;if(2>b.length)return d(a,b[0]);e=z(b,a.length);for(h=e.first.length;h--;)f=e.first[h],c=e.last[h]-f+1,a.splice(f,c);return a}function G(a,b){var d;for(d=a.length;d--;)a[d]===
b&&a.splice(d,1);return a}function H(a,b){var d,e,f,c;e=b.length;for(c=a.length;c--;)for(d=a[c],f=e;f--;)if(b[f]===d){a.splice(c,1);break}return a}function t(b,d,e){var f;d=a.undefined(e)?d:y(d,e);e=2<d.length?v(b):b;switch(d.length){case 0:for(f in e)q(e,f)&&!d()&&delete b[f];break;case 1:for(f in e)q(e,f)&&!d(e[f])&&delete b[f];break;case 2:for(f in e)q(e,f)&&!d(e[f],f)&&delete b[f];break;default:for(f in e)q(e,f)&&!d(e[f],f,e)&&delete b[f]}return b}function x(b,d,e){var f;d=a.undefined(e)?d:y(d,
e);e=2<d.length?v.arr(b):b;f=e.length;switch(d.length){case 0:for(;f--;)d()||b.splice(f,1);break;case 1:for(;f--;)d(e[f])||b.splice(f,1);break;case 2:for(;f--;)d(e[f],f)||b.splice(f,1);break;default:for(;f--;)d(e[f],f,e)||b.splice(f,1)}return b}function y(a,b){switch(a.length){case 0:return function(){return a.call(b)};case 1:return function(d){return a.call(b,d)};case 2:return function(d,e){return a.call(b,d,e)}}return function(d,e,f){return a.call(b,d,e,f)}}c.property=function(b,d,e){if(!a._obj(b))throw u.type("source",
"property");if(2>arguments.length)throw u("No val defined","property");b=a.args(b)?r(b):b;if(a.func(d)){if(!a.nil.un.obj(e))throw u.type("thisArg","property");return a.arr(b)?x(b,d,e):t(b,d,e)}return g(b,d)};c.prop=c.property;c.key=function(b,d){if(!a._obj(b))throw u.type("source","key");if(2>arguments.length)throw u("No key defined","key");delete b[d];return b};c.index=function(b,d,e){if(!a._obj(b))throw u.type("source","index");if(!a.num(b.length))throw u.type("source.length","index");if(!a.num(d))throw u.type("index",
"index");if(!a.un.num(e))throw u.type("toIndex","index");b=a.arr(b)?b:r(b);return k(b,d,e)};c.i=c.index;c.type=function(b,d){if(!a._obj(b))throw u.type("source","type");if(!a.str(d))throw u.type("type","type");b=a.args(b)?r(b):b;if(a.empty(b))return B(d,""),b;var e=b;if(a.arr(e)){var f;for(f=e.length;f--;)B(d,e[f])&&e.splice(f,1)}else for(f in e)q(e,f)&&B(d,e[f])&&delete e[f];return e};c.value=function(b,d){if(!a._obj(b))throw u.type("source","value");if(2>arguments.length)throw u("No val defined",
"value");b=a.args(b)?r(b):b;return m(b,d)};c.val=c.value;c.pattern=function(b,d){if(!a.str(b))throw u.type("source","pattern");if(2>arguments.length)throw u("No pattern defined","pattern");return n(b,d)};c.properties=function(b,d){if(!a._obj(b))throw u.type("source","properties");if(2>arguments.length)throw u("No val defined","properties");b=a.args(b)?r(b):b;d=2<arguments.length?r(arguments,1):d;return a.arr(d)?l(b,d):g(b,d)};c.props=c.properties;c.keys=function(b,d){if(!a._obj(b))throw u.type("source",
"keys");if(2>arguments.length)throw u("No key defined","keys");d=2<arguments.length?r(arguments,1):d;var e;if(a.arr(d)){e=b;var f=d,c,h;c=f.length;for(h=-1;++h<c;)delete e[f[h]]}else e=b,delete e[d];return e};c.indexes=function(b,d){if(!a._obj(b))throw u.type("source","indexes");if(!a.num(b.length))throw u.type("source.length","indexes");if(2>arguments.length)throw u("No index defined","indexes");b=a.arr(b)?b:r(b);d=2<arguments.length?r(arguments,1):d;if(!a.arr(d)){if(!a.num(d))throw u.type("index",
"indexes");return k(b,d)}if(!B("!nums",d))throw u.type("index","indexes");return h(b,d)};c.ii=c.indexes;c.values=function(b,d){if(!a._obj(b))throw u.type("source","value");if(2>arguments.length)throw u("No val defined","value");b=a.args(b)?r(b):b;d=2<arguments.length?r(arguments,1):d;var f;if(a.arr(d)){f=b;var c=d;f=a.arr(f)?H(f,c):e(f,c)}else f=m(b,d);return f};c.vals=c.values;c.patterns=function(b,d){if(!a.str(b))throw u.type("source","patterns");if(2>arguments.length)throw u("No pattern defined",
"patterns");d=2<arguments.length?r(arguments,1):d;return a.arr(d)?p(b,d):n(b,d)};var z=function(){function a(b,d){b=0>b?d+b:b;return 0>b||b>=d?-1:b}function b(a,f,c){var h;h=f+c>>>1;if(a<d[h]){var g,l;g=d[h];h?(c=h-1,l=e[c],a===--g?a===++l?(e[c]=e[h],d.splice(h,1),e.splice(h,1)):d[h]=a:a>l?a===++l?e[c]=a:(d.splice(h,0,a),e.splice(h,0,a)):b(a,f,c)):a===--g?d[h]=a:(d.unshift(a),e.unshift(a))}else a>e[h]&&(f=h+1,l=e[h],f===e.length?a===++l?e[h]=a:(d.push(a),e.push(a)):(g=d[f],a===++l?a===--g?(e[h]=e[f],
d.splice(f,1),e.splice(f,1)):e[h]=a:a<g?a===--g?d[f]=a:(d.splice(f,0,a),e.splice(f,0,a)):b(a,f,c)))}var d,e;return function(f,c){var h,g,l;d=[];e=[];g=f.length;l=0;for(h=a(f[l],c);-1===h&&++l<g;)h=a(f[l],c);d.push(h);for(e.push(h);++l<g;)h=a(f[l],c),-1!==h&&b(h,0,e.length);return{first:d,last:e}}}(),u=w("cut");return c}(),K=function(){function c(c,f,b){if(!a.func(f))throw n.type("iteratee");if(!a.nil.un.obj(b))throw n.type("thisArg");if(a.num(c))return k(c,f,b);a.str(c)&&(c=y(c));if(!a._obj(c))throw n.type("source");
return a._arr(c)?l(c,f,b):g(c,f,b)}function g(c,f,b){var e;c=2<f.length?v(c):c;f=a.undefined(b)?f:m(f,b);switch(f.length){case 0:for(e in c)q(c,e)&&f();break;case 1:for(e in c)q(c,e)&&f(c[e]);break;case 2:for(e in c)q(c,e)&&f(c[e],e);break;default:for(e in c)q(c,e)&&f(c[e],e,c)}return c}function l(c,f,b){var e;c=2<f.length?v.arr(c):c;f=a.undefined(b)?f:m(f,b);b=c.length;e=-1;switch(f.length){case 0:for(;++e<b;)f();break;case 1:for(;++e<b;)f(c[e]);break;case 2:for(;++e<b;)f(c[e],e);break;default:for(;++e<
b;)f(c[e],e,c)}return c}function k(c,f,b){f=a.undefined(b)?f:m(f,b);if(f.length)for(b=0;c--;)f(b++);else for(;c--;)f()}function m(a,f){switch(a.length){case 0:return function(){a.call(f)};case 1:return function(b){a.call(f,b)};case 2:return function(b,e){a.call(f,b,e)}}return function(b,e,d){a.call(f,b,e,d)}}c.object=function(c,f,b){if(!a._obj(c))throw n.type("source","object");if(!a.func(f))throw n.type("iteratee","object");if(!a.nil.un.obj(b))throw n.type("thisArg","object");return g(c,f,b)};c.obj=
c.object;c.array=function(c,f,b){a.str(c)&&(c=y(c));if(!a._obj(c))throw n.type("source","array");if(!a.num(c.length))throw n.type("source.length","array");if(!a.func(f))throw n.type("iteratee","array");if(!a.nil.un.obj(b))throw n.type("thisArg","array");return l(c,f,b)};c.arr=c.array;c.cycle=function(c,f,b){if(!a.num(c))throw n.type("count","cycle");if(!a.func(f))throw n.type("iteratee","cycle");if(!a.nil.un.obj(b))throw n.type("thisArg","cycle");return k(c,f,b)};c.time=c.cycle;var n=w("each");return c}(),
L=function(){function c(c,f,b,e,d){if(2>arguments.length)throw n("No val defined");if(a.nil(c))return null;if(a.num(c))return m(c,f);if(!a._obj(c))throw n.type("source");if(a.arr(c)){d=e;e=b;b=f;if(!a.un.num(e))throw n.type("start");if(!a.un.num(d))throw n.type("end");return k(c,b,e,d)}if(2<arguments.length){f=a.str(f)?y(f):f;if(!a.arr(f))throw n.type("keys");return l(c,f,b)}return g(c,f)}function g(a,f){for(var b in a)q(a,b)&&(a[b]=f);return a}function l(a,f,b){var e,d;e=f.length;for(d=-1;++d<e;)a[f[d]]=
b;return a}function k(a,f,b,e){var d;d=a.length;b=b||0;b=0>b?d+b:b;b=0>b?0:b;e=e||d;e=e>d?d:0>e?d+e:e;if(b>=e)return a;for(--b;++b<e;)a[b]=f;return a}function m(a,f){var b;a=0>a?0:a;if(!a)return"";f=String(f);for(b="";a--;)b+=f;return b}c.object=function(c,f,b){if(!a._obj(c))throw n.type("obj","object");if(2>arguments.length)throw n("No val defined","object");if(2<arguments.length){f=a.str(f)?y(f):f;if(!a.arr(f))throw n.type("keys","object");return l(c,f,b)}return g(c,f)};c.obj=c.object;c.array=function(c,
f,b,e){c=a.num(c)?Array(c):c;if(2>arguments.length)throw n("No val defined","array");if(!a.arr(c))throw n.type("arr","array");if(!a.un.num(b))throw n.type("start","array");if(!a.un.num(e))throw n.type("end","array");return k(c,f,b,e)};c.arr=c.array;c.string=function(c,f){if(!a.num(c))throw n.type("count","string");if(2>arguments.length)throw n("No val defined","string");return m(c,f)};c.str=c.string;var n=w("fill");return c}(),M=function(){function c(b,e){if(2>arguments.length)throw f("No val defined");
if(a.str(b))return e=2<arguments.length?r(arguments,1):e,a.arr(e)?p(b,e):b+e;if(!a._obj(b))throw f.type("dest");b=a.args(b)?r(b):b;if(a.arr(b))return 2<arguments.length?(e=r(arguments,1),n(b,e)):m(b,e);e=2<arguments.length?r(arguments,1):e;return a.arr(e)?l(b,e):g(b,e)}function g(b,e){if(a._obj(e))return x(b,e);a.nil(e)||(b[e]=t);return b}function l(a,e){var d,f;d=e.length;for(f=-1;++f<d;)a=g(a,e[f]);return a}function k(a,e){q(a,e)||(a[e]=t);return a}function m(b,e){if(a.arr(e))return b.concat(e);
a.nil(e)||b.push(e);return b}function n(a,e){var d,f;d=e.length;for(f=-1;++f<d;)a=m(a,e[f]);return a}function p(a,e){var d,f;d=e.length;for(f=-1;++f<d;)a+=e[f];return a}c.value=function(b,e){if(2>arguments.length)throw f("No val defined","value");if(a.str(b)){if(3>arguments.length)return b+e;e=r(arguments,1);return p(b,e)}if(!a._obj(b))throw f.type("dest","value");b=a.args(b)?r(b):b;if(3>arguments.length){var d;a.arr(b)?(d=b,d.push(e)):(d=b,d[e]=t);return d}e=r(arguments,1);if(a.arr(b)){d=b;var c=
e,g,l;g=c.length;for(l=-1;++l<g;)d.push(c[l])}else{d=b;var c=e,k;l=c.length;for(k=-1;++k<l;)g=c[k],d[g]=t}return d};c.val=c.value;c.value.start=function(b,e){if(2>arguments.length)throw f("No val defined","value.start");if(a.str(b)){if(3>arguments.length)return e+b;e=r(arguments,1);var d=b,c,g;c=e.length;for(g=-1;++g<c;)d=e[g]+d;return d}if(!a._obj(b))throw f.type("dest","value.start");b=a.args(b)?r(b):b;if(3>arguments.length)return a.arr(b)?(d=b,d.unshift(e)):d=k(b,e),d;e=r(arguments,1);if(a.arr(b)){d=
b;c=e;var l;g=c.length;for(l=-1;++l<g;)d.unshift(c[l])}else for(d=b,c=e,g=c.length,l=-1;++l<g;)d=k(d,c[l]);return d};c.val.start=c.value.start;c.value.top=c.value.start;c.val.top=c.value.start;c.object=function(b,e){if(!a._obj(b))throw f.type("dest","object");if(2>arguments.length)throw f("No val defined","object");e=2<arguments.length?r(arguments,1):e;return a.arr(e)?l(b,e):g(b,e)};c.obj=c.object;c.array=function(b,e){if(!a._arr(b))throw f.type("dest","array");if(2>arguments.length)throw f("No val defined",
"array");b=a.args(b)?r(b):b;return 2<arguments.length?(e=r(arguments,1),n(b,e)):m(b,e)};c.arr=c.array;c.string=function(b,e){if(!a.str(b))throw f.type("dest","string");if(2>arguments.length)throw f("No val defined","string");e=2<arguments.length?r(arguments,1):e;return a.arr(e)?p(b,e):b+e};c.str=c.string;var f=w("fuse");return c}(),N=function(){function c(d,c){if(a.str(d)){if(2>arguments.length)throw e("No val defined");return a.regex(c)?b(d,c):f(d,c)}if(!a._obj(d))throw e.type("source");return 2>
arguments.length?a._arr(d)?n(d):g(d):a._arr(d)?p(d,c):a.regex(c)?m(d,c):k(d,c)}function g(a){var b,e;b=[];for(e in a)q(a,e)&&b.push(e);return b}function l(b,e){var f,c;e=a.regex(e)?e:String(e);f=[];for(c in b)q(b,c)&&A(c,e)&&f.push(c);return f}function k(a,b){var e,f;e=[];for(f in a)q(a,f)&&a[f]===b&&e.push(f);return e}function m(b,e){var f,c;e=a.regex(e)?e:String(e);f=[];for(c in b)q(b,c)&&A(c,e)&&f.push(b[c]);return f}function n(a){var b,e;b=a.length;a=Array(b);for(e=-1;++e<b;)a[e]=e;return a}function p(a,
b){var e,f,c;f=a.length;e=[];for(c=-1;++c<f;)a[c]===b&&e.push(c);return e}function f(b,e){var f;if(A(b,e)){if(a.regex(e)){var c,g;f=v.regex(e,!0);c=[];for(g=f.exec(b);g;)c.push(g.index),g=f.exec(b)}else for(f=String(e),c=[],g=b.indexOf(f);-1!==g;)c.push(g),g=b.indexOf(f,++g);f=c}else f=[];return f}function b(b,e){var f;if(A(b,e)){if(a.regex(e)){var c,g;f=v.regex(e,!0);c=[];for(g=f.exec(b);g;)c.push(g[0]),g=f.exec(b)}else for(f=String(e),c=[],g=b.indexOf(f);-1!==g;)c.push(f),g=b.indexOf(f,++g);f=c}else f=
[];return f}c.keys=function(b,f){if(!a._obj(b))throw e.type("source","keys");return 2>arguments.length?g(b):a.regex(f)?l(b,f):k(b,f)};c.keys.byKey=function(b,f){if(!a._obj(b))throw e.type("source","keys.byKey");if(2>arguments.length)throw e("No pattern defined","keys.byKey");return l(b,f)};c.keys.byValue=function(b,f){if(!a._obj(b))throw e.type("source","keys.byValue");if(2>arguments.length)throw e("No val defined","keys.byValue");return k(b,f)};c.keys.byVal=c.keys.byValue;c.indexes=function(b,c){if(a.str(b)){if(2>
arguments.length)throw e("No val defined","indexes");return f(b,c)}if(!a._obj(b))throw e.type("source","indexes");if(!a.num(b.length))throw e.type("source.length","indexes");return 2>arguments.length?n(b):p(b,c)};c.ii=c.indexes;c.values=function(d,f){if(a.str(d)){if(2>arguments.length)throw e("No val defined","values");return b(d,f)}if(!a._obj(d))throw e.type("source","values");var c;if(2>arguments.length){var g;c=[];for(g in d)q(d,g)&&c.push(d[g])}else c=m(d,f);return c};c.vals=c.values;var e=w("get");
return c}(),O=function(){function c(c,k){if(2>arguments.length)throw g("No val defined");if(a.nil(c))return!1;if(a.str(c))return A(c,k);if(!a._obj(c))throw g.type("source");return a._arr(c)?z(c,k):q(c,k)}c.key=function(c,k){if(2>arguments.length)throw g("No key defined","key");if(a.nil(c))return!1;if(!a._obj(c))throw g.type("source","key");return q(c,k)};c.value=function(c,k){if(2>arguments.length)throw g("No val defined","value");if(a.nil(c))return!1;if(!a._obj(c))throw g.type("source","value");
return a._arr(c)?z(c,k):E(c,k)};c.val=c.value;c.pattern=function(c,k){if(!a.str(c))throw g.type("source","pattern");if(2>arguments.length)throw g("No pattern defined","pattern");return A(c,k)};c.substring=function(c,k){if(!a.str(c))throw g.type("source","substring");if(2>arguments.length)throw g("No val defined","substring");return F(c,k)};c.substr=c.substring;c.enumerable=function(c,k){if(2>arguments.length)throw g("No key defined","enumerable");if(a.nil(c))return!1;if(!a._obj(c))throw g.type("source",
"enumerable");return I(c,k)};try{c["enum"]=c.enumerable}catch(l){}var g=w("has");return c}(),P=function(){function c(f,b,e,d){if(a.str(f)){if(2>arguments.length)throw p("No iteratee defined");if(3>arguments.length)throw p("No replacement defined");if(!a.nil.un.obj(d))throw p.type("thisArg");return k(f,b,e,d)}d=e;if(!a._obj(f))throw p.type("source");if(!a.func(b))throw p.type("iteratee");if(!a.nil.un.obj(d))throw p.type("thisArg");return a._arr(f)?l(f,b,d):g(f,b,d)}function g(f,b,e){var d,c;d={};f=
2<b.length?v(f):f;b=a.undefined(e)?b:m(b,e);switch(b.length){case 0:for(c in f)q(f,c)&&(d[c]=b());break;case 1:for(c in f)q(f,c)&&(d[c]=b(f[c]));break;case 2:for(c in f)q(f,c)&&(d[c]=b(f[c],c));break;default:for(c in f)q(f,c)&&(d[c]=b(f[c],c,f))}return d}function l(c,b,e){var d,g;c=2<b.length?v.arr(c):c;b=a.undefined(e)?b:m(b,e);d=c.length;e=Array(d);g=-1;switch(b.length){case 0:for(;++g<d;)e[g]=b();break;case 1:for(;++g<d;)e[g]=b(c[g]);break;case 2:for(;++g<d;)e[g]=b(c[g],g);break;default:for(;++g<
d;)e[g]=b(c[g],g,c)}return e}function k(c,b,e,d){if(!c)return c;a.regex(b)||(b=String(b),b=D(b),b=new RegExp(b,"g"));e=a.func(e)?a.undefined(d)?e:n(e,d):String(e);return c.replace(b,e)}function m(a,b){switch(a.length){case 0:return function(){return a.call(b)};case 1:return function(e){return a.call(b,e)};case 2:return function(e,d){return a.call(b,e,d)}}return function(e,d,c){return a.call(b,e,d,c)}}function n(a,b){switch(a.length){case 0:return function(){return a.call(b)};case 1:return function(e){return a.call(b,
e)};case 2:return function(e,d){return a.call(b,e,d)};case 3:return function(e,d,c){return a.call(b,e,d,c)};case 4:return function(e,d,c,g){return a.call(b,e,d,c,g)};case 5:return function(e,d,c,g,l){return a.call(b,e,d,c,g,l)}}return function(){return a.apply(b,arguments)}}c.object=function(c,b,e){if(!a._obj(c))throw p.type("source","object");if(!a.func(b))throw p.type("iteratee","object");if(!a.nil.un.obj(e))throw p.type("thisArg","object");return g(c,b,e)};c.obj=c.object;c.array=function(c,b,e){a.str(c)&&
(c=y(c));if(!a._obj(c))throw p.type("source","array");if(!a.num(c.length))throw p.type("source.length","array");if(!a.func(b))throw p.type("iteratee","array");if(!a.nil.un.obj(e))throw p.type("thisArg","array");return l(c,b,e)};c.arr=c.array;c.string=function(c,b,e,d){if(2>arguments.length)throw p("No pattern defined","string");if(3>arguments.length)throw p("No replacement defined","string");if(!a.str(c))throw p.type("source","string");if(!a.nil.un.obj(d))throw p.type("thisArg","string");return k(c,
b,e,d)};c.str=c.string;var p=w("remap");return c}(),Q=function(){function c(c,m,n,p){var f;if(2>arguments.length)throw l("No source or iteratee defined");2===arguments.length?(n=m,m=c):3!==arguments.length||a.func(n)?f=!0:(p=n,n=m,m=c);if(!a.func(n))throw l.type("iteratee");if(!a.nil.un.obj(p))throw l.type("thisArg");if(a.num(m)){if(!f)throw l("No base defined");var b=c,e=m,d=n,h=p,d=a.undefined(h)?d:g(d,h);if(1<d.length)for(h=0;e--;)b=d(b,h++);else for(;e--;)b=d(b);return b}if(!a._obj(m))throw l.type("source");
if(a._arr(m))if(f)switch(b=c,e=m,d=n,h=p,e=3<d.length?v.arr(e):e,d=a.undefined(h)?d:g(d,h),h=e.length,f=-1,d.length){case 0:case 1:for(;++f<h;)b=d(b);break;case 2:for(;++f<h;)b=d(b,e[f]);break;case 3:for(;++f<h;)b=d(b,e[f],f);break;default:for(;++f<h;)b=d(b,e[f],f,e)}else{b=m;e=n;d=p;b=3<e.length?v.arr(b):b;e=a.undefined(d)?e:g(e,d);d=b[0];h=b.length;f=0;switch(e.length){case 0:case 1:for(;++f<h;)d=e(d);break;case 2:for(;++f<h;)d=e(d,b[f]);break;case 3:for(;++f<h;)d=e(d,b[f],f);break;default:for(;++f<
h;)d=e(d,b[f],f,b)}b=d}else{if(f)switch(e=c,d=m,h=n,f=p,d=3<h.length?v(d):d,h=a.undefined(f)?h:g(h,f),h.length){case 0:case 1:for(b in d)q(d,b)&&(e=h(e));break;case 2:for(b in d)q(d,b)&&(e=h(e,d[b]));break;case 3:for(b in d)q(d,b)&&(e=h(e,d[b],b));break;default:for(b in d)q(d,b)&&(e=h(e,d[b],b,d))}else{b=m;f=n;var r=p,b=3<f.length?v(b):b;f=a.undefined(r)?f:g(f,r);switch(f.length){case 0:case 1:for(d in b)q(b,d)&&(h?e=f(e):(e=b[d],h=!0));break;case 2:for(d in b)q(b,d)&&(h?e=f(e,b[d]):(e=b[d],h=!0));
break;case 3:for(d in b)q(b,d)&&(h?e=f(e,b[d],d):(e=b[d],h=!0));break;default:for(d in b)q(b,d)&&(h?e=f(e,b[d],d,b):(e=b[d],h=!0))}}b=e}return b}function g(a,c){switch(a.length){case 0:return function(){return a.call(c)};case 1:return function(g){return a.call(c,g)};case 2:return function(g,l){return a.call(c,g,l)};case 3:return function(g,l,f){return a.call(c,g,l,f)}}return function(g,l,f,b){return a.call(c,g,l,f,b)}}c.up=function(c,m,n,p){var f;if(2>arguments.length)throw l("No source or iteratee defined",
"up");2===arguments.length?(n=m,m=c):3!==arguments.length||a.func(n)?f=!0:(p=n,n=m,m=c);if(!a.func(n))throw l.type("iteratee","up");if(!a.nil.un.obj(p))throw l.type("thisArg","up");if(a.num(m)){if(!f)throw l("No base defined","up");var b=c,e=m,d=n,h=p,d=a.undefined(h)?d:g(d,h);if(d.length)for(h=0;e--;)b+=d(h++);else for(;e--;)b+=d();return b}if(!a._obj(m))throw l.type("source","up");if(a._arr(m))if(f)switch(b=c,e=m,d=n,h=p,e=2<d.length?v.arr(e):e,d=a.undefined(h)?d:g(d,h),h=e.length,f=-1,d.length){case 0:for(;++f<
h;)b+=d();break;case 1:for(;++f<h;)b+=d(e[f]);break;case 2:for(;++f<h;)b+=d(e[f],f);break;default:for(;++f<h;)b+=d(e[f],f,e)}else{b=m;e=n;d=p;b=2<e.length?v.arr(b):b;e=a.undefined(d)?e:g(e,d);d=b[0];h=b.length;f=0;switch(e.length){case 0:for(;++f<h;)d+=e();break;case 1:for(;++f<h;)d+=e(b[f]);break;case 2:for(;++f<h;)d+=e(b[f],f);break;default:for(;++f<h;)d+=e(b[f],f,b)}b=d}else{if(f)switch(e=c,d=m,h=n,f=p,d=2<h.length?v(d):d,h=a.undefined(f)?h:g(h,f),h.length){case 0:for(b in d)q(d,b)&&(e+=h());break;
case 1:for(b in d)q(d,b)&&(e+=h(d[b]));break;case 2:for(b in d)q(d,b)&&(e+=h(d[b],b));break;default:for(b in d)q(d,b)&&(e+=h(d[b],b,d))}else{b=m;f=n;var r=p,b=2<f.length?v(b):b;f=a.undefined(r)?f:g(f,r);switch(f.length){case 0:for(d in b)q(b,d)&&(h?e+=f():(e=b[d],h=!0));break;case 1:for(d in b)q(b,d)&&(h?e+=f(b[d]):(e=b[d],h=!0));break;case 2:for(d in b)q(b,d)&&(h?e+=f(b[d],d):(e=b[d],h=!0));break;default:for(d in b)q(b,d)&&(h?e+=f(b[d],d,b):(e=b[d],h=!0))}}b=e}return b};c.down=function(c,m,n,p){var f;
if(2>arguments.length)throw l("No source or iteratee defined","down");2===arguments.length?(n=m,m=c):3!==arguments.length||a.func(n)?f=!0:(p=n,n=m,m=c);if(!a.func(n))throw l.type("iteratee","down");if(!a.nil.un.obj(p))throw l.type("thisArg","down");if(a.num(m)){if(!f)throw l("No base defined","down");var b=c,e=m,d=n,h=p,d=a.undefined(h)?d:g(d,h);if(d.length)for(h=0;e--;)b-=d(h++);else for(;e--;)b-=d();return b}if(!a._obj(m))throw l.type("source","down");if(a._arr(m))if(f)switch(b=c,e=m,d=n,h=p,e=
2<d.length?v.arr(e):e,d=a.undefined(h)?d:g(d,h),h=e.length,f=-1,d.length){case 0:for(;++f<h;)b-=d();break;case 1:for(;++f<h;)b-=d(e[f]);break;case 2:for(;++f<h;)b-=d(e[f],f);break;default:for(;++f<h;)b-=d(e[f],f,e)}else{b=m;e=n;d=p;b=2<e.length?v.arr(b):b;e=a.undefined(d)?e:g(e,d);d=b[0];h=b.length;f=0;switch(e.length){case 0:for(;++f<h;)d-=e();break;case 1:for(;++f<h;)d-=e(b[f]);break;case 2:for(;++f<h;)d-=e(b[f],f);break;default:for(;++f<h;)d-=e(b[f],f,b)}b=d}else{if(f)switch(e=c,d=m,h=n,f=p,d=
2<h.length?v(d):d,h=a.undefined(f)?h:g(h,f),h.length){case 0:for(b in d)q(d,b)&&(e-=h());break;case 1:for(b in d)q(d,b)&&(e-=h(d[b]));break;case 2:for(b in d)q(d,b)&&(e-=h(d[b],b));break;default:for(b in d)q(d,b)&&(e-=h(d[b],b,d))}else{b=m;f=n;var r=p,b=2<f.length?v(b):b;f=a.undefined(r)?f:g(f,r);switch(f.length){case 0:for(d in b)q(b,d)&&(h?e-=f():(e=b[d],h=!0));break;case 1:for(d in b)q(b,d)&&(h?e-=f(b[d]):(e=b[d],h=!0));break;case 2:for(d in b)q(b,d)&&(h?e-=f(b[d],d):(e=b[d],h=!0));break;default:for(d in b)q(b,
d)&&(h?e-=f(b[d],d,b):(e=b[d],h=!0))}}b=e}return b};var l=w("roll");return c}(),R=function(){function a(c,k){if(2>arguments.length)throw g("Missing a val");return c===k}a.loose=function(a,c){if(2>arguments.length)throw g("Missing a val","loose");return a==c};a.ish=a.loose;var g=w("same");return a}(),S=function(){function c(c,k,m){if(!a.un.num(k))throw g.type("start");if(!a.un.num(m))throw g.type("end");if(a.nil(c))return null;if(a.str(c))return C(c,k,m);if(!a._obj(c))throw g.type("source");if(!a.num(c.length))throw g.type("source.length");
return r(c,k,m)}c.array=function(c,k,m){if(!a._obj(c))throw g.type("source","array");if(!a.num(c.length))throw g.type("source.length","array");if(!a.un.num(k))throw g.type("start","array");if(!a.un.num(m))throw g.type("end","array");return r(c,k,m)};c.arr=c.array;c.string=function(c,k,m){if(!a.str(c))throw g.type("str","string");if(!a.un.num(k))throw g.type("start","string");if(!a.un.num(m))throw g.type("end","string");return C(c,k,m)};c.str=c.string;var g=w("slice");return c}(),T=function(){var c=
{string:function(c,k){if(!arguments.length)throw g("Missing a val","string");if(!a.un.str(k))throw g.type("joiner","string");return a.arr(c)&&a.str(k)?c.join(k):String(c)}};c.str=c.string;c.number=function(c){if(!arguments.length)throw g("Missing a val","number");if(a.num(c))return c;if(a.nil.bool(c))return c?1:0;if(!a.str(c))throw g.type("val","number");c=Number(c);if(a.nan(c))throw g.range("val","see github.com/imaginate/vitals/wiki/vitals.to#tonumber","number");return c};c.num=c.number;c["boolean"]=
function(a){if(!arguments.length)throw g("Missing a val","boolean");return!!a};c.bool=c["boolean"];c.array=function(c,k){if(!arguments.length)throw g("Missing a val","array");if(a.num(c))return Array(c);if(!a.str(c))throw g.type("val","array");if(a.undefined(k))return y(c);k=a.regex(k)?k:String(k);return c.split(k)};c.arr=c.array;c.regexp=function(c,k){if(!arguments.length)throw g("Missing a source","regexp");if(!a.str(c))throw g.type("source","regexp");if(!a.un.str(k))throw g.type("flags","regexp");
return k?new RegExp(c,k):new RegExp(c)};c.regex=c.regexp;c.re=c.regexp;c.upperCase=function(c){if(!arguments.length)throw g("Missing a str","upperCase");if(!a.str(c))throw g.type("source","upperCase");return c.toUpperCase()};c.upper=c.upperCase;c.lowerCase=function(c){if(!arguments.length)throw g("Missing a str","lowerCase");if(!a.str(c))throw g.type("source","lowerCase");return c.toLowerCase()};c.lower=c.lowerCase;var g=w("to");return c}(),U=function(){function c(c,b,e,d){if(2>arguments.length)throw p("No end or iteratee defined");
if(2===arguments.length){e=b;if(!a.func(e))throw p.type("iteratee");return g(c,e)}if(3===arguments.length&&a.func(b)&&a.nil.obj(e))return d=e,g(c,b,d);if(!a.func(e))throw p.type("iteratee");if(!a.nil.un.obj(d))throw p.type("thisArg");if(a.num(b))return m(c,b,e,d);a.str(b)&&(b=y(b));if(!a._obj(b))throw p.type("source");return a._arr(b)?k(c,b,e,d):l(c,b,e,d)}function g(c,b,e){b=a.undefined(e)?b:n(b,e);if(b.length)for(e=0;b(e++)!==c;);else for(;b()!==c;);return!0}function l(c,b,e,d){var g;b=2<e.length?
v(b):b;e=a.undefined(d)?e:n(e,d);switch(e.length){case 0:for(g in b)if(q(b,g)&&e()===c)return!0;break;case 1:for(g in b)if(q(b,g)&&e(b[g])===c)return!0;break;case 2:for(g in b)if(q(b,g)&&e(b[g],g)===c)return!0;break;default:for(g in b)if(q(b,g)&&e(b[g],g,b)===c)return!0}return!1}function k(c,b,e,d){var g;b=2<e.length?v.arr(b):b;e=a.undefined(d)?e:n(e,d);d=b.length;g=-1;switch(e.length){case 0:for(;++g<d;)if(e()===c)return!0;break;case 1:for(;++g<d;)if(e(b[g])===c)return!0;break;case 2:for(;++g<d;)if(e(b[g],
g)===c)return!0;break;default:for(;++g<d;)if(e(b[g],g,b)===c)return!0}return!1}function m(c,b,e,d){e=a.undefined(d)?e:n(e,d);if(e.length)for(d=0;b--;){if(e(d++)===c)return!0}else for(;b--;)if(e()===c)return!0;return!1}function n(a,b){switch(a.length){case 0:return function(){return a.call(b)};case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)}}return function(c,d,g){return a.call(b,c,d,g)}}c.object=function(c,b,e,d){if(!a._obj(b))throw p.type("obj","object");
if(!a.func(e))throw p.type("iteratee","object");if(!a.nil.un.obj(d))throw p.type("thisArg","object");return l(c,b,e,d)};c.obj=c.object;c.array=function(c,b,e,d){a.str(b)&&(b=y(b));if(!a._obj(b))throw p.type("source","array");if(!a.num(b.length))throw p.type("source.length","array");if(!a.func(e))throw p.type("iteratee","array");if(!a.nil.un.obj(d))throw p.type("thisArg","array");return k(c,b,e,d)};c.arr=c.array;c.cycle=function(c,b,e,d){if(!a.num(b))throw p.type("count","cycle");if(!a.func(e))throw p.type("action",
"cycle");if(!a.nil.un.obj(d))throw p.type("thisArg","cycle");return m(c,b,e,d)};c.time=c.cycle;var p=w("until");return c}();return{copy:v,cut:J,each:K,fill:L,fuse:M,get:N,has:O,is:B,remap:P,roll:Q,same:R,slice:S,to:T,until:U}}());