// TinyColor.js - <https://github.com/bgrins/TinyColor> - 2011 Brian Grinstead - v0.5
(function(A){var r,s,t,u,v,w,x;function d(a){if("object"==typeof a&&a.hasOwnProperty("_tc_id"))return a;var a=B(a),b=a.r,c=a.g,j=a.b,d=parseFloat(a.a),g=f(100*d)/100,e=a.format;1>b&&(b=f(b));1>c&&(c=f(c));1>j&&(j=f(j));return{ok:a.ok,format:e,_tc_id:C++,alpha:d,toHsv:function(){var a=y(b,c,j);return{h:360*a.h,s:a.s,v:a.v,a:d}},toHsvString:function(){var a=y(b,c,j),e=f(360*a.h),i=f(100*a.s),a=f(100*a.v);return 1==d?"hsv("+e+", "+i+"%, "+a+"%)":"hsva("+e+", "+i+"%, "+a+"%, "+g+")"},toHsl:function(){var a=
z(b,c,j);return{h:360*a.h,s:a.s,l:a.l,a:d}},toHslString:function(){var a=z(b,c,j),e=f(360*a.h),i=f(100*a.s),a=f(100*a.l);return 1==d?"hsl("+e+", "+i+"%, "+a+"%)":"hsla("+e+", "+i+"%, "+a+"%, "+g+")"},toHex:function(){return o(b,c,j)},toHexString:function(){return"#"+o(b,c,j)},toRgb:function(){return{r:f(b),g:f(c),b:f(j),a:d}},toRgbString:function(){return 1==d?"rgb("+f(b)+", "+f(c)+", "+f(j)+")":"rgba("+f(b)+", "+f(c)+", "+f(j)+", "+g+")"},toName:function(){return D[o(b,c,j)]||!1},toFilter:function(){var a=
o(b,c,j),e=Math.round(255*parseFloat(d)).toString(16);return"progid:DXImageTransform.Microsoft.gradient(startColorstr=#"+e+a+",endColorstr=#"+e+a+")"},toString:function(a){var a=a||this.format,b=!1;"rgb"===a&&(b=this.toRgbString());"hex"===a&&(b=this.toHexString());"name"===a&&(b=this.toName());"hsl"===a&&(b=this.toHslString());"hsv"===a&&(b=this.toHsvString());return b||this.toHexString()}}}function B(a){var b={r:255,g:255,b:255},c=1,d=!1,h=!1;if("string"==typeof a)a:{var a=a.replace(E,"").replace(F,
"").toLowerCase(),g=!1;if(p[a])a=p[a],g=!0;else if("transparent"==a){a={r:0,g:0,b:0,a:0};break a}var e,a=(e=r.exec(a))?{r:e[1],g:e[2],b:e[3]}:(e=s.exec(a))?{r:e[1],g:e[2],b:e[3],a:e[4]}:(e=t.exec(a))?{h:e[1],s:e[2],l:e[3]}:(e=u.exec(a))?{h:e[1],s:e[2],l:e[3],a:e[4]}:(e=v.exec(a))?{h:e[1],s:e[2],v:e[3]}:(e=w.exec(a))?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16),format:g?"name":"hex"}:(e=x.exec(a))?{r:parseInt(e[1]+""+e[1],16),g:parseInt(e[2]+""+e[2],16),b:parseInt(e[3]+""+e[3],16),
format:g?"name":"hex"}:!1}if("object"==typeof a){if(a.hasOwnProperty("r")&&a.hasOwnProperty("g")&&a.hasOwnProperty("b"))b={r:255*i(a.r,255),g:255*i(a.g,255),b:255*i(a.b,255)},d=!0,h="rgb";else if(a.hasOwnProperty("h")&&a.hasOwnProperty("s")&&a.hasOwnProperty("v")){a.s=n(a.s);a.v=n(a.v);var h=a.h,g=a.s,b=a.v,h=6*i(h,360),g=i(g,100),b=i(b,100),d=m.floor(h),f=h-d,h=b*(1-g);e=b*(1-f*g);g=b*(1-(1-f)*g);d%=6;b={r:255*[b,e,h,h,g,b][d],g:255*[g,b,b,e,h,h][d],b:255*[h,h,g,b,b,e][d]};d=!0;h="hsv"}else a.hasOwnProperty("h")&&
a.hasOwnProperty("s")&&a.hasOwnProperty("l")&&(a.s=n(a.s),a.l=n(a.l),b=G(a.h,a.s,a.l),d=!0,h="hsl");a.hasOwnProperty("a")&&(c=a.a)}return{ok:d,format:a.format||h,r:k(255,l(b.r,0)),g:k(255,l(b.g,0)),b:k(255,l(b.b,0)),a:c}}function z(a,b,c){var a=i(a,255),b=i(b,255),c=i(c,255),d=l(a,b,c),h=k(a,b,c),g,e=(d+h)/2;if(d==h)g=h=0;else{var f=d-h,h=0.5<e?f/(2-d-h):f/(d+h);switch(d){case a:g=(b-c)/f+(b<c?6:0);break;case b:g=(c-a)/f+2;break;case c:g=(a-b)/f+4}g/=6}return{h:g,s:h,l:e}}function G(a,b,c){function d(a,
b,c){0>c&&(c+=1);1<c&&(c-=1);return c<1/6?a+6*(b-a)*c:0.5>c?b:c<2/3?a+6*(b-a)*(2/3-c):a}a=i(a,360);b=i(b,100);c=i(c,100);if(0==b)c=b=a=c;else var h=0.5>c?c*(1+b):c+b-c*b,g=2*c-h,c=d(g,h,a+1/3),b=d(g,h,a),a=d(g,h,a-1/3);return{r:255*c,g:255*b,b:255*a}}function y(a,b,c){var a=i(a,255),b=i(b,255),c=i(c,255),d=l(a,b,c),h=k(a,b,c),g,e=d-h;if(d==h)g=0;else{switch(d){case a:g=(b-c)/e+(b<c?6:0);break;case b:g=(c-a)/e+2;break;case c:g=(a-b)/e+4}g/=6}return{h:g,s:0==d?0:e/d,v:d}}function o(a,b,c){function d(a){return 1==
a.length?"0"+a:""+a}a=[d(f(a).toString(16)),d(f(b).toString(16)),d(f(c).toString(16))];return a[0][0]==a[0][1]&&a[1][0]==a[1][1]&&a[2][0]==a[2][1]?a[0][0]+a[1][0]+a[2][0]:a.join("")}function i(a,b){"string"==typeof a&&-1!=a.indexOf(".")&&1===parseFloat(a)&&(a="100%");var c="string"===typeof a&&-1!=a.indexOf("%"),a=k(b,l(0,parseFloat(a)));c&&(a=parseInt(a*b)/100);return 1.0E-6>m.abs(a-b)?1:a%b/parseFloat(b)}function n(a){1>=a&&(a=100*a+"%");return a}var E=/^[\s,#]+/,F=/\s+$/,C=0,m=Math,f=m.round,k=
m.min,l=m.max,q=m.random;d.fromRatio=function(a){if("object"==typeof a){var b={},c;for(c in a)b[c]=n(a[c]);a=b}return d(a)};d.equals=function(a,b){return!a||!b?!1:d(a).toHex()==d(b).toHex()};d.random=function(){return d.fromRatio({r:q(),g:q(),b:q()})};d.desaturate=function(a,b){var c=d(a).toHsl();c.s-=(b||10)/100;c.s=k(1,l(0,c.s));return d(c)};d.saturate=function(a,b){var c=d(a).toHsl();c.s+=(b||10)/100;c.s=k(1,l(0,c.s));return d(c)};d.greyscale=function(a){return d.desaturate(a,100)};d.lighten=function(a,
b){var c=d(a).toHsl();c.l+=(b||10)/100;c.l=k(1,l(0,c.l));return d(c)};d.darken=function(a,b){var c=d(a).toHsl();c.l-=(b||10)/100;c.l=k(1,l(0,c.l));return d(c)};d.complement=function(a){a=d(a).toHsl();a.h=(a.h+180)%360;return d(a)};d.triad=function(a){var b=d(a).toHsl(),c=b.h;return[d(a),d({h:(c+120)%360,s:b.s,l:b.l}),d({h:(c+240)%360,s:b.s,l:b.l})]};d.tetrad=function(a){var b=d(a).toHsl(),c=b.h;return[d(a),d({h:(c+90)%360,s:b.s,l:b.l}),d({h:(c+180)%360,s:b.s,l:b.l}),d({h:(c+270)%360,s:b.s,l:b.l})]};
d.splitcomplement=function(a){var b=d(a).toHsl(),c=b.h;return[d(a),d({h:(c+72)%360,s:b.s,l:b.l}),d({h:(c+216)%360,s:b.s,l:b.l})]};d.analogous=function(a,b,c){var b=b||6,c=c||30,f=d(a).toHsl(),c=360/c,a=[d(a)];for(f.h=(f.h-(c*b>>1)+720)%360;--b;)f.h=(f.h+c)%360,a.push(d(f));return a};d.monochromatic=function(a,b){for(var b=b||6,c=d(a).toHsv(),f=c.h,h=c.s,c=c.v,g=[],e=1/b;b--;)g.push(d({h:f,s:h,v:c})),c=(c+e)%1;return g};d.readable=function(a,b){var c=d(a).toRgb(),f=d(b).toRgb();return 10404<(f.r-c.r)*
(f.r-c.r)+(f.g-c.g)*(f.g-c.g)+(f.b-c.b)*(f.b-c.b)};var p=d.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",
darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",
ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",
lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",
oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",
slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},D=d.hexNames=function(a){var b={},c;for(c in a)a.hasOwnProperty(c)&&(b[a[c]]=c);return b}(p);r=RegExp("rgb[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?");
s=RegExp("rgba[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?");t=RegExp("hsl[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?");u=RegExp("hsla[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?");
v=RegExp("hsv[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?");x=/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;w=/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/;"undefined"!==typeof module&&module.exports?module.exports=d:A.tinycolor=d})(this);
