"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var n=0;n=min&&value<=n},t=function(e,t){if(10===t)return e;if(16===t)return e.toString(16);if("percent"===t)return e/255;throw new Error("Format is invalid.")},n=function(){function n(e,t){_classCallCheck(this,n),this.channel={red:void 0,green:void 0,blue:void 0,alpha:void 0}}return _createClass(n,[{key:"setRed",value:function(t){if(!e(t,0,255))throw new Error("Please pass in a number between 0 ~ 255.");this.channel.red=parseInt(t,10)}},{key:"setGreen",value:function(t){if(!e(t,0,255))throw new Error("Please pass in a number between 0 ~ 255.");this.channel.green=parseInt(t,10)}},{key:"setBlue",value:function(t){if(!e(t,0,255))throw new Error("Please pass in a number between 0 ~ 255.");this.channel.blue=parseInt(t,10)}},{key:"setAlpha",value:function(t){if(!e(t,0,1))throw new Error("Please pass in a number between 0 ~ 1.");this.channel.alpha=parseInt(255*t,10)}},{key:"getRed",value:function(){var e=arguments.length<=0||void 0===arguments[0]?10:arguments[0];return t(this.channel.red,e)}},{key:"getGreen",value:function(){var e=arguments.length<=0||void 0===arguments[0]?10:arguments[0];return t(this.channel.green,e)}},{key:"getBlue",value:function(){var e=arguments.length<=0||void 0===arguments[0]?10:arguments[0];return t(this.channel.blue,e)}},{key:"getAlpha",value:function(){var e=arguments.length<=0||void 0===arguments[0]?"percent":arguments[0];return t(this.channel.alpha,e)}},{key:"toFormat",value:function(e){return e.replace(/\$r/i,this.getRed()).replace(/\$g/i,this.getGreen()).replace(/\$b/i,this.getBlue()).replace(/\$a/i,this.getAlpha()).replace(/\$0xR/,this.getRed(16).toUpperCase()).replace(/\$0xr/,this.getRed(16).toLowerCase()).replace(/\$0xG/,this.getGreen(16).toUpperCase()).replace(/\$0xg/,this.getGreen(16).toLowerCase()).replace(/\$0xB/,this.getBlue(16).toUpperCase()).replace(/\$0xb/,this.getBlue(16).toLowerCase()).replace(/\$0xA/,this.getAlpha(16).toUpperCase()).replace(/\$0xa/,this.getAlpha(16).toLowerCase())}},{key:"toRGBA",value:function(){return this.toFormat("rgba($r, $g, $b, $a)")}},{key:"toHex",value:function(){return this.toFormat("#$0xR$0xG$0xB")}}]),n}();window.Color=n}();