/** * jQuery asColor v0.3.6 * https://github.com/amazingSurge/asColor * * Copyright (c) amazingSurge * Released under the LGPL-3.0 license */ !function(e,t){if("function"==typeof define&&define.amd)define("AsColor",["exports","jquery"],t);else if("undefined"!=typeof exports)t(exports,require("jquery"));else{var r={exports:{}};t(r.exports,e.jQuery),e.AsColor=r.exports}}(this,function(e,t){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e){return 0===e.indexOf("#")&&(e=e.substr(1)),e?(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length?"#"+e:null):null}function n(e){return 0===e.indexOf("#")&&(e=e.substr(1)),6===e.length&&e[0]===e[1]&&e[2]===e[3]&&e[4]===e[5]&&(e=e[0]+e[2]+e[4]),"#"+e}function o(e){return parseInt(e,16)}function i(e){return"string"==typeof e&&e.indexOf("%")===e.length-1}function f(e){return parseInt(Math.round(2.55*e.slice(0,-1)),10)}function u(e){return parseFloat(e.slice(0,-1)/100,10)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(e){return e&&e.__esModule?e:{default:e}}(t),l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h=function(){function e(e,t){for(var r=0;r1&&(r-=1),a=6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e,Math.round(255*a)},RGBtoHSL:function(e){var t=e.r/255,r=e.g/255,a=e.b/255,n=Math.min(t,r,a),o=Math.max(t,r,a),i=o-n,f=o+n,u=.5*f,s=void 0,l=void 0;return s=n===o?0:t===o?60*(r-a)/i+360:r===o?60*(a-t)/i+120:60*(t-r)/i+240,l=0===i?0:u<=.5?i/f:i/(2-f),{h:Math.round(s)%360,s:l,l:u}},RGBtoHEX:function(e){var t=[e.r.toString(16),e.g.toString(16),e.b.toString(16)];return s.default.each(t,function(e,r){1===r.length&&(t[e]="0"+r)}),"#"+t.join("")},HSLtoHEX:function(e){var t=this.HSLtoRGB(e);return this.RGBtoHEX(t)},HSVtoHEX:function(e){var t=this.HSVtoRGB(e);return this.RGBtoHEX(t)},RGBtoHSV:function(e){var t=e.r/255,r=e.g/255,a=e.b/255,n=Math.max(t,r,a),o=Math.min(t,r,a),i=void 0,f=void 0,u=n,s=n-o;if(f=0===n?0:s/n,n===o)i=0;else{switch(n){case t:i=(r-a)/s+(rthis.length)&&-1!==this.indexOf(e,t)});var k=function(){function e(t,a){r(this,e),"object"===(void 0===t?"undefined":l(t))&&void 0===a&&(a=t,t=void 0),"string"==typeof a&&(a={format:a}),this.options=s.default.extend(!0,{},d,a),this.value={r:0,g:0,b:0,h:0,s:0,v:0,a:1},this._format=!1,this._matchFormat="HEX",this._valid=!0,this.init(t)}return h(e,[{key:"init",value:function(e){return this.format(this.options.format),this.fromString(e),this}},{key:"isValid",value:function(){return this._valid}},{key:"val",value:function(e){return void 0===e?this.toString():(this.fromString(e),this)}},{key:"alpha",value:function(e){return void 0===e||isNaN(e)?this.value.a:((e=parseFloat(e))>1?e=1:e<0&&(e=0),this.value.a=e,this)}},{key:"matchString",value:function(t){return e.matchString(t)}},{key:"fromString",value:function(e,t){if("string"==typeof e){e=s.default.trim(e);var r=null,a=void 0;this._valid=!1;for(var n in y)if(null!==(r=y[n].match.exec(e))&&(a=y[n].parse(r))){this.set(a),"TRANSPARENT"===n&&(n="HEX"),this._matchFormat=n,!0===t&&this.format(n);break}}else"object"===(void 0===e?"undefined":l(e))&&this.set(e);return this}},{key:"format",value:function(e){return"string"==typeof e&&(e=e.toUpperCase())&&void 0!==y[e]?this._format="TRANSPARENT"!==e?e:"HEX":!1===e&&(this._format=!1),!1===this._format?this._matchFormat:this._format}},{key:"toRGBA",value:function(){return y.RGBA.to(this.value,this)}},{key:"toRGB",value:function(){return y.RGB.to(this.value,this)}},{key:"toHSLA",value:function(){return y.HSLA.to(this.value,this)}},{key:"toHSL",value:function(){return y.HSL.to(this.value,this)}},{key:"toHEX",value:function(){return y.HEX.to(this.value,this)}},{key:"toNAME",value:function(){return y.NAME.to(this.value,this)}},{key:"to",value:function(e){return"string"==typeof e&&(e=e.toUpperCase())&&void 0!==y[e]?y[e].to(this.value,this):this.toString()}},{key:"toString",value:function(){var e=this.value;if(!this._valid&&"string"==typeof(e=this.options.invalidValue))return e;if(0===e.a&&this.options.zeroAlphaAsTransparent)return y.TRANSPARENT.to(e,this);var t=void 0;if(t=!1===this._format?this._matchFormat:this._format,this.options.reduceAlpha&&1===e.a)switch(t){case"RGBA":t="RGB";break;case"HSLA":t="HSL"}return 1!==e.a&&"RGBA"!==t&&"HSLA"!==t&&this.options.alphaConvert&&("string"==typeof this.options.alphaConvert&&(t=this.options.alphaConvert),void 0!==this.options.alphaConvert[t]&&(t=this.options.alphaConvert[t])),y[t].to(e,this)}},{key:"get",value:function(){return this.value}},{key:"set",value:function(e){this._valid=!0;var t=0,r=0,a=void 0,n=void 0;for(var o in e)"hsv".includes(o)?(r++,this.value[o]=e[o]):"rgb".includes(o)?(t++,this.value[o]=e[o]):"a"===o&&(this.value.a=e.a);return t>r?(a=b.RGBtoHSV(this.value),0===this.value.r&&0===this.value.g&&0===this.value.b||(this.value.h=a.h),this.value.s=a.s,this.value.v=a.v):r>t&&(n=b.HSVtoRGB(this.value),this.value.r=n.r,this.value.g=n.g,this.value.b=n.b),this}}],[{key:"matchString",value:function(e){if("string"==typeof e){e=s.default.trim(e);var t=null;for(var r in y)if(null!==(t=y[r].match.exec(e))&&y[r].parse(t))return!0}return!1}},{key:"setDefaults",value:function(e){s.default.extend(!0,d,s.default.isPlainObject(e)&&e)}}]),e}(),R={version:"0.3.6"},S=s.default.asColor,H=function(){for(var e=arguments.length,t=Array(e),r=0;r