Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@irojs/iro-core

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@irojs/iro-core - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

2

dist/iro-core.es.js

@@ -1,2 +0,2 @@

var t="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",n="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",e=new RegExp("rgb"+r),i=new RegExp("rgba"+n),a=new RegExp("hsl"+r),s=new RegExp("hsla"+n),h=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$"),o=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$"),u=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$"),l=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$"),g=Math.log,c=Math.round,f=Math.floor;function v(t,r){var n=t.indexOf("%")>-1,e=parseFloat(t);return n?r/100*e:e}function b(t){return parseInt(t,16)}function d(t){return t.toString(16).padStart(2,"0")}var p=function(t,r){this.$={h:0,s:0,v:0,a:1},t&&this.set(t),this.onChange=r},x={hsv:{configurable:!0},hsva:{configurable:!0},hue:{configurable:!0},saturation:{configurable:!0},value:{configurable:!0},alpha:{configurable:!0},kelvin:{configurable:!0},rgb:{configurable:!0},rgba:{configurable:!0},hsl:{configurable:!0},hsla:{configurable:!0},rgbString:{configurable:!0},rgbaString:{configurable:!0},hexString:{configurable:!0},hex8String:{configurable:!0},hslString:{configurable:!0},hslaString:{configurable:!0}};p.prototype.set=function(t){if("string"==typeof t)/^(?:#?|0x?)[0-9a-fA-F]{3,8}$/.test(t)?this.hexString=t:/^rgba?/.test(t)?this.rgbString=t:/^hsla?/.test(t)&&(this.hslString=t);else{if("object"!=typeof t)throw new Error("Invalid color value");t instanceof p?this.hsv=t.hsv:"object"==typeof t&&"r"in t&&"g"in t&&"b"in t?this.rgb=t:"object"==typeof t&&"h"in t&&"s"in t&&"v"in t?this.hsv=t:"object"==typeof t&&"h"in t&&"s"in t&&"l"in t&&(this.hsl=t)}},p.prototype.setChannel=function(t,r,n){var e;this[t]=Object.assign({},this[t],((e={})[r]=n,e))},p.prototype.clone=function(){return new p(this)},p.hsvToRgb=function(t){var r=t.h/60,n=t.s/100,e=t.v/100,i=f(r),a=r-i,s=e*(1-n),h=e*(1-a*n),o=e*(1-(1-a)*n),u=i%6;return{r:255*[e,h,s,s,o,e][u],g:255*[o,e,e,h,s,s][u],b:255*[s,s,o,e,e,h][u]}},p.rgbToHsv=function(t){var r=t.r/255,n=t.g/255,e=t.b/255,i=Math.max(r,n,e),a=Math.min(r,n,e),s=i-a,h=0,o=i,u=0===i?0:s/i;switch(i){case a:h=0;break;case r:h=(n-e)/s+(n<e?6:0);break;case n:h=(e-r)/s+2;break;case e:h=(r-n)/s+4}return{h:60*h,s:100*u,v:100*o}},p.hsvToHsl=function(t){var r=t.s/100,n=t.v/100,e=(2-r)*n,i=e<=1?e:2-e;return{h:t.h,s:100*(i<1e-9?0:r*n/i),l:50*e}},p.hslToHsv=function(t){var r=2*t.l,n=t.s*(r<=100?r:200-r)/100;return{h:t.h,s:100*(r+n<1e-9?0:2*n/(r+n)),v:(r+n)/2}},p.kelvinToRgb=function(t){var r,n,e,i=t/100;return i<66?(r=255,n=-155.25485562709179-.44596950469579133*(n=i-2)+104.49216199393888*g(n),e=i<20?0:.8274096064007395*(e=i-10)-254.76935184120902+115.67994401066147*g(e)):(r=351.97690566805693+.114206453784165*(r=i-55)-40.25366309332127*g(r),n=325.4494125711974+.07943456536662342*(n=i-50)-28.0852963507957*g(n),e=255),{r:f(r),g:f(n),b:f(e)}},p.rgbToKelvin=function(t){for(var r,n=t.r,e=t.b,i=1e3,a=4e4;a-i>.4;){var s=p.kelvinToRgb(r=.5*(a+i));s.b/s.r>=e/n?a=r:i=r}return r},x.hsv.get=function(){var t=this.$;return{h:t.h,s:t.s,v:t.v}},x.hsv.set=function(t){var r=this.$;if(t=Object.assign({},r,t),this.onChange){var n={h:!1,v:!1,s:!1,a:!1};for(var e in r)n[e]=t[e]!=r[e];this.$=t,(n.h||n.s||n.v||n.a)&&this.onChange(this,n)}else this.$=t},x.hsva.get=function(){return Object.assign({},this.$)},x.hsva.set=function(t){this.hsv=t},x.hue.get=function(){return this.$.h},x.hue.set=function(t){this.hsv={h:t}},x.saturation.get=function(){return this.$.s},x.saturation.set=function(t){this.hsv={s:t}},x.value.get=function(){return this.$.v},x.value.set=function(t){this.hsv={v:t}},x.alpha.get=function(){return this.$.a},x.alpha.set=function(t){this.hsv=Object.assign({},this.hsv,{a:t})},x.kelvin.get=function(){return p.rgbToKelvin(this.rgb)},x.kelvin.set=function(t){this.rgb=p.kelvinToRgb(t)},x.rgb.get=function(){var t=p.hsvToRgb(this.$),r=t.g,n=t.b;return{r:c(t.r),g:c(r),b:c(n)}},x.rgb.set=function(t){this.hsv=Object.assign({},p.rgbToHsv(t),{a:void 0===t.a?1:t.a})},x.rgba.get=function(){return Object.assign({},this.rgb,{a:this.alpha})},x.rgba.set=function(t){this.rgb=t},x.hsl.get=function(){var t=p.hsvToHsl(this.$),r=t.s,n=t.l;return{h:c(t.h),s:c(r),l:c(n)}},x.hsl.set=function(t){this.hsv=Object.assign({},p.hslToHsv(t),{a:void 0===t.a?1:t.a})},x.hsla.get=function(){return Object.assign({},this.hsl,{a:this.alpha})},x.hsla.set=function(t){this.hsl=t},x.rgbString.get=function(){var t=this.rgb;return"rgb("+t.r+", "+t.g+", "+t.b+")"},x.rgbString.set=function(t){var r,n,a,s,h=1;if((r=e.exec(t))?(n=v(r[1],255),a=v(r[2],255),s=v(r[3],255)):(r=i.exec(t))&&(n=v(r[1],255),a=v(r[2],255),s=v(r[3],255),h=v(r[4],1)),!r)throw new Error("Invalid rgb string");this.rgb={r:n,g:a,b:s,a:h}},x.rgbaString.get=function(){var t=this.rgba;return"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")"},x.rgbaString.set=function(t){this.rgbString=t},x.hexString.get=function(){var t=this.rgb;return"#"+d(t.r)+d(t.g)+d(t.b)},x.hexString.set=function(t){var r,n,e,i,a=255;if((r=h.exec(t))?(n=17*b(r[1]),e=17*b(r[2]),i=17*b(r[3])):(r=o.exec(t))?(n=17*b(r[1]),e=17*b(r[2]),i=17*b(r[3]),a=17*b(r[4])):(r=u.exec(t))?(n=b(r[1]),e=b(r[2]),i=b(r[3])):(r=l.exec(t))&&(n=b(r[1]),e=b(r[2]),i=b(r[3]),a=b(r[4])),!r)throw new Error("Invalid hex string");this.rgb={r:n,g:e,b:i,a:a/255}},x.hex8String.get=function(){var t=this.rgba;return"#"+d(t.r)+d(t.g)+d(t.b)+d(f(255*t.a))},x.hex8String.set=function(t){this.hexString=t},x.hslString.get=function(){var t=this.hsl;return"hsl("+t.h+", "+t.s+"%, "+t.l+"%)"},x.hslString.set=function(t){var r,n,e,i,h=1;if((r=a.exec(t))?(n=v(r[1],360),e=v(r[2],100),i=v(r[3],100)):(r=s.exec(t))&&(n=v(r[1],360),e=v(r[2],100),i=v(r[3],100),h=v(r[4],1)),!r)throw new Error("Invalid hsl string");this.hsl={h:n,s:e,l:i,a:h}},x.hslaString.get=function(){var t=this.hsla;return"hsl("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"},x.hslaString.set=function(t){this.hslString=t},Object.defineProperties(p.prototype,x);var w={sliderShape:"bar",sliderType:"value",minTemperature:2200,maxTemperature:11e3};function m(t){var r;return(r={})["horizontal"===t.layoutDirection?"marginLeft":"marginTop"]=t.sliderMargin,r}function S(t){var r=t.width,n=t.sliderSize,e=t.borderWidth,i=t.handleRadius,a=t.padding,s="horizontal"===t.layoutDirection;return n=n||2*a+2*i+2*e,"circle"===t.sliderShape?{handleStart:t.padding+t.handleRadius,handleRange:r-2*a-2*i-2*e,width:r,height:r,cx:r/2,cy:r/2,radius:r/2-e/2}:{handleStart:n/2,handleRange:r-n,radius:n/2,x:0,y:0,width:s?n:r,height:s?r:n}}function M(t){var r=t.color.hsva;switch(t.sliderType){case"alpha":return 100*r.a;case"kelvin":var n=t.minTemperature;return Math.max(0,Math.min((t.color.kelvin-n)/(t.maxTemperature-n)*100,100));case"hue":return r.h/=3.6;case"saturation":return r.s;case"value":default:return r.v}}function y(t,r,n,e){var i,a=S(t),s=a.handleRange,h=a.handleStart;i="horizontal"===t.layoutDirection?-1*(n-e.top)+s+h:r-(e.left+h),i=Math.max(Math.min(i,s),0);var o=Math.round(100/s*i);switch(t.sliderType){case"kelvin":var u=t.minTemperature;return u+o/100*(t.maxTemperature-u);case"alpha":return o/100;case"hue":return 3.6*o;default:return o}}function T(t){var r=S(t),n=r.handleRange,e=r.handleStart,i="horizontal"===t.layoutDirection,a=i?r.width/2:r.height/2,s=e+M(t)/100*n;return i&&(s=-1*s+n+2*e),{x:i?a:s,y:i?s:a}}function R(t){var r=t.color.hsv;switch(t.sliderType){case"alpha":var n=t.color.rgb;return[[0,"rgba("+n.r+","+n.g+","+n.b+",0)"],[100,"rgb("+n.r+","+n.g+","+n.b+")"]];case"kelvin":for(var e=[],i=t.minTemperature,a=t.maxTemperature,s=a-i,h=i,o=0;h<a;h+=s/8,o+=1){var u=p.kelvinToRgb(h);e.push([12.5*o,"rgb("+u.r+","+u.g+","+u.b+")"])}return e;case"hue":return[[0,"#f00"],[16.666,"#ff0"],[33.333,"#0f0"],[50,"#0ff"],[66.666,"#00f"],[83.333,"#f0f"],[100,"#f00"]];case"saturation":var l=p.hsvToHsl({h:r.h,s:0,v:r.v}),g=p.hsvToHsl({h:r.h,s:100,v:r.v});return[[0,"hsl("+l.h+","+l.s+"%,"+l.l+"%)"],[100,"hsl("+g.h+","+g.s+"%,"+g.l+"%)"]];case"value":default:var c=p.hsvToHsl({h:r.h,s:r.s,v:100});return[[0,"#000"],[100,"hsl("+c.h+","+c.s+"%,"+c.l+"%)"]]}}function A(t){var r="horizontal"===t.layoutDirection;return{x1:"0%",y1:r?"100%":"0%",x2:r?"0%":"100%",y2:"0%"}}function k(t){var r=t.width/2;return{width:t.width,radius:r-t.borderWidth,cx:r,cy:r}}function $(t,r){var n=t.wheelAngle;return((r="clockwise"===t.wheelDirection?-360+r-n:n-r)%360+360)%360}function F(t){var r=t.color.hsv,n=k(t),e=n.cx,i=n.cy,a=t.width/2-t.padding-t.handleRadius-t.borderWidth,s=$(t,r.h)*(Math.PI/180),h=r.s/100*a,o="clockwise"===t.wheelDirection?-1:1;return{x:e+h*Math.cos(s)*o,y:i+h*Math.sin(s)*o}}function j(t,r,n,e){var i=k(t),a=t.width/2-t.padding-t.handleRadius-t.borderWidth;r=i.cx-(r-e.left),n=i.cy-(n-e.top);var s=$(t,Math.atan2(-n,-r)*(180/Math.PI)),h=Math.min(Math.sqrt(r*r+n*n),a);return{h:Math.round(s),s:Math.round(100/a*h)}}function E(t){var r;return(r={})["horizontal"===t.layoutDirection?"marginLeft":"marginTop"]=t.sliderMargin,r}function D(t){var r=t.width;return{width:r,height:r,radius:t.padding+t.handleRadius}}function O(t,r,n,e){var i=D(t),a=i.radius,s=(n-=e.top+a)/(i.height-2*a)*100;return{s:Math.max(0,Math.min((r-=e.left+a)/(i.width-2*a)*100,100)),v:Math.max(0,Math.min(100-s,100))}}function H(t){var r=D(t),n=r.radius,e=t.color.hsv,i=r.height-2*n;return{x:n+e.s/100*(r.width-2*n),y:n+(i-e.v/100*i)}}function I(t){return[[[0,"#fff"],[100,"hsl("+t.color.hue+",100%,50%)"]],[[0,"rgba(0,0,0,0)"],[100,"#000"]]]}var P=document.getElementsByTagName("base");function z(t){var r=window.navigator.userAgent,n=/^((?!chrome|android).)*safari/i.test(r),e=/iPhone|iPod|iPad/i.test(r),i=window.location;return(n||e)&&P.length>0?i.protocol+"//"+i.host+i.pathname+i.search+t:t}function C(t,r,n,e,i){var a=i-e<=180?0:1;return e*=Math.PI/180,i*=Math.PI/180,"M "+(t+n*Math.cos(i))+" "+(r+n*Math.sin(i))+" A "+n+" "+n+" 0 "+a+" 0 "+(t+n*Math.cos(e))+" "+(r+n*Math.sin(e))}var W={width:300,height:300,handleRadius:8,handleSvg:null,handleProps:{x:0,y:0},color:"#fff",borderColor:"#fff",borderWidth:0,wheelLightness:!0,wheelAngle:0,wheelDirection:"anticlockwise",layoutDirection:"vertical",sliderSize:null,sliderMargin:12,padding:6};export{p as IroColor,w as sliderDefaultOptions,m as getSliderStyles,S as getSliderDimensions,M as getCurrentSliderValue,y as getSliderValueFromInput,T as getSliderHandlePosition,R as getSliderGradient,A as getSliderGradientCoords,k as getWheelDimensions,$ as translateWheelAngle,F as getWheelHandlePosition,j as getWheelValueFromInput,E as getBoxStyles,D as getBoxDimensions,O as getBoxValueFromInput,H as getBoxHandlePosition,I as getBoxGradients,z as resolveSvgUrl,C as getSvgArcPath,W as iroColorPickerOptionDefaults};
var t="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",n="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",e=new RegExp("rgb"+r),i=new RegExp("rgba"+n),a=new RegExp("hsl"+r),s=new RegExp("hsla"+n),h=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$"),o=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$"),u=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$"),l=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$"),g=Math.log,c=Math.round,f=Math.floor;function v(t,r){var n=t.indexOf("%")>-1,e=parseFloat(t);return n?r/100*e:e}function b(t){return parseInt(t,16)}function d(t){return t.toString(16).padStart(2,"0")}var p=function(t,r){this.$={h:0,s:0,v:0,a:1},t&&this.set(t),this.onChange=r},x={hsv:{configurable:!0},hsva:{configurable:!0},hue:{configurable:!0},saturation:{configurable:!0},value:{configurable:!0},alpha:{configurable:!0},kelvin:{configurable:!0},rgb:{configurable:!0},rgba:{configurable:!0},hsl:{configurable:!0},hsla:{configurable:!0},rgbString:{configurable:!0},rgbaString:{configurable:!0},hexString:{configurable:!0},hex8String:{configurable:!0},hslString:{configurable:!0},hslaString:{configurable:!0}};p.prototype.set=function(t){if("string"==typeof t)/^(?:#?|0x?)[0-9a-fA-F]{3,8}$/.test(t)?this.hexString=t:/^rgba?/.test(t)?this.rgbString=t:/^hsla?/.test(t)&&(this.hslString=t);else{if("object"!=typeof t)throw new Error("Invalid color value");t instanceof p?this.hsv=t.hsv:"object"==typeof t&&"r"in t&&"g"in t&&"b"in t?this.rgb=t:"object"==typeof t&&"h"in t&&"s"in t&&"v"in t?this.hsv=t:"object"==typeof t&&"h"in t&&"s"in t&&"l"in t&&(this.hsl=t)}},p.prototype.setChannel=function(t,r,n){var e;this[t]=Object.assign({},this[t],((e={})[r]=n,e))},p.prototype.clone=function(){return new p(this)},p.hsvToRgb=function(t){var r=t.h/60,n=t.s/100,e=t.v/100,i=f(r),a=r-i,s=e*(1-n),h=e*(1-a*n),o=e*(1-(1-a)*n),u=i%6;return{r:255*[e,h,s,s,o,e][u],g:255*[o,e,e,h,s,s][u],b:255*[s,s,o,e,e,h][u]}},p.rgbToHsv=function(t){var r=t.r/255,n=t.g/255,e=t.b/255,i=Math.max(r,n,e),a=Math.min(r,n,e),s=i-a,h=0,o=i,u=0===i?0:s/i;switch(i){case a:h=0;break;case r:h=(n-e)/s+(n<e?6:0);break;case n:h=(e-r)/s+2;break;case e:h=(r-n)/s+4}return{h:60*h,s:100*u,v:100*o}},p.hsvToHsl=function(t){var r=t.s/100,n=t.v/100,e=(2-r)*n,i=e<=1?e:2-e;return{h:t.h,s:100*(i<1e-9?0:r*n/i),l:50*e}},p.hslToHsv=function(t){var r=2*t.l,n=t.s*(r<=100?r:200-r)/100;return{h:t.h,s:100*(r+n<1e-9?0:2*n/(r+n)),v:(r+n)/2}},p.kelvinToRgb=function(t){var r,n,e,i=t/100;return i<66?(r=255,n=-155.25485562709179-.44596950469579133*(n=i-2)+104.49216199393888*g(n),e=i<20?0:.8274096064007395*(e=i-10)-254.76935184120902+115.67994401066147*g(e)):(r=351.97690566805693+.114206453784165*(r=i-55)-40.25366309332127*g(r),n=325.4494125711974+.07943456536662342*(n=i-50)-28.0852963507957*g(n),e=255),{r:f(r),g:f(n),b:f(e)}},p.rgbToKelvin=function(t){for(var r,n=t.r,e=t.b,i=1e3,a=4e4;a-i>.4;){var s=p.kelvinToRgb(r=.5*(a+i));s.b/s.r>=e/n?a=r:i=r}return r},x.hsv.get=function(){var t=this.$;return{h:t.h,s:t.s,v:t.v}},x.hsv.set=function(t){var r=this.$;if(t=Object.assign({},r,t),this.onChange){var n={h:!1,v:!1,s:!1,a:!1};for(var e in r)n[e]=t[e]!=r[e];this.$=t,(n.h||n.s||n.v||n.a)&&this.onChange(this,n)}else this.$=t},x.hsva.get=function(){return Object.assign({},this.$)},x.hsva.set=function(t){this.hsv=t},x.hue.get=function(){return this.$.h},x.hue.set=function(t){this.hsv={h:t}},x.saturation.get=function(){return this.$.s},x.saturation.set=function(t){this.hsv={s:t}},x.value.get=function(){return this.$.v},x.value.set=function(t){this.hsv={v:t}},x.alpha.get=function(){return this.$.a},x.alpha.set=function(t){this.hsv=Object.assign({},this.hsv,{a:t})},x.kelvin.get=function(){return p.rgbToKelvin(this.rgb)},x.kelvin.set=function(t){this.rgb=p.kelvinToRgb(t)},x.rgb.get=function(){var t=p.hsvToRgb(this.$),r=t.g,n=t.b;return{r:c(t.r),g:c(r),b:c(n)}},x.rgb.set=function(t){this.hsv=Object.assign({},p.rgbToHsv(t),{a:void 0===t.a?1:t.a})},x.rgba.get=function(){return Object.assign({},this.rgb,{a:this.alpha})},x.rgba.set=function(t){this.rgb=t},x.hsl.get=function(){var t=p.hsvToHsl(this.$),r=t.s,n=t.l;return{h:c(t.h),s:c(r),l:c(n)}},x.hsl.set=function(t){this.hsv=Object.assign({},p.hslToHsv(t),{a:void 0===t.a?1:t.a})},x.hsla.get=function(){return Object.assign({},this.hsl,{a:this.alpha})},x.hsla.set=function(t){this.hsl=t},x.rgbString.get=function(){var t=this.rgb;return"rgb("+t.r+", "+t.g+", "+t.b+")"},x.rgbString.set=function(t){var r,n,a,s,h=1;if((r=e.exec(t))?(n=v(r[1],255),a=v(r[2],255),s=v(r[3],255)):(r=i.exec(t))&&(n=v(r[1],255),a=v(r[2],255),s=v(r[3],255),h=v(r[4],1)),!r)throw new Error("Invalid rgb string");this.rgb={r:n,g:a,b:s,a:h}},x.rgbaString.get=function(){var t=this.rgba;return"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")"},x.rgbaString.set=function(t){this.rgbString=t},x.hexString.get=function(){var t=this.rgb;return"#"+d(t.r)+d(t.g)+d(t.b)},x.hexString.set=function(t){var r,n,e,i,a=255;if((r=h.exec(t))?(n=17*b(r[1]),e=17*b(r[2]),i=17*b(r[3])):(r=o.exec(t))?(n=17*b(r[1]),e=17*b(r[2]),i=17*b(r[3]),a=17*b(r[4])):(r=u.exec(t))?(n=b(r[1]),e=b(r[2]),i=b(r[3])):(r=l.exec(t))&&(n=b(r[1]),e=b(r[2]),i=b(r[3]),a=b(r[4])),!r)throw new Error("Invalid hex string");this.rgb={r:n,g:e,b:i,a:a/255}},x.hex8String.get=function(){var t=this.rgba;return"#"+d(t.r)+d(t.g)+d(t.b)+d(f(255*t.a))},x.hex8String.set=function(t){this.hexString=t},x.hslString.get=function(){var t=this.hsl;return"hsl("+t.h+", "+t.s+"%, "+t.l+"%)"},x.hslString.set=function(t){var r,n,e,i,h=1;if((r=a.exec(t))?(n=v(r[1],360),e=v(r[2],100),i=v(r[3],100)):(r=s.exec(t))&&(n=v(r[1],360),e=v(r[2],100),i=v(r[3],100),h=v(r[4],1)),!r)throw new Error("Invalid hsl string");this.hsl={h:n,s:e,l:i,a:h}},x.hslaString.get=function(){var t=this.hsla;return"hsl("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"},x.hslaString.set=function(t){this.hslString=t},Object.defineProperties(p.prototype,x);var w={sliderShape:"bar",sliderType:"value",minTemperature:2200,maxTemperature:11e3};function m(t){var r;return(r={})["horizontal"===t.layoutDirection?"marginLeft":"marginTop"]=t.sliderMargin,r}function S(t){var r=t.width,n=t.sliderSize,e=t.borderWidth,i=t.handleRadius,a=t.padding,s="horizontal"===t.layoutDirection;return n=n||2*a+2*i+2*e,"circle"===t.sliderShape?{handleStart:t.padding+t.handleRadius,handleRange:r-2*a-2*i-2*e,width:r,height:r,cx:r/2,cy:r/2,radius:r/2-e/2}:{handleStart:n/2,handleRange:r-n,radius:n/2,x:0,y:0,width:s?n:r,height:s?r:n}}function M(t){var r=t.color.hsva;switch(t.sliderType){case"alpha":return 100*r.a;case"kelvin":var n=t.minTemperature;return Math.max(0,Math.min((t.color.kelvin-n)/(t.maxTemperature-n)*100,100));case"hue":return r.h/=3.6;case"saturation":return r.s;case"value":default:return r.v}}function y(t,r,n,e){var i,a=S(t),s=a.handleRange,h=a.handleStart;i="horizontal"===t.layoutDirection?-1*(n-e.top)+s+h:r-(e.left+h),i=Math.max(Math.min(i,s),0);var o=Math.round(100/s*i);switch(t.sliderType){case"kelvin":var u=t.minTemperature;return u+o/100*(t.maxTemperature-u);case"alpha":return o/100;case"hue":return 3.6*o;default:return o}}function T(t){var r=S(t),n=r.handleRange,e=r.handleStart,i="horizontal"===t.layoutDirection,a=i?r.width/2:r.height/2,s=e+M(t)/100*n;return i&&(s=-1*s+n+2*e),{x:i?a:s,y:i?s:a}}function R(t){var r=t.color.hsv;switch(t.sliderType){case"alpha":var n=t.color.rgb;return[[0,"rgba("+n.r+","+n.g+","+n.b+",0)"],[100,"rgb("+n.r+","+n.g+","+n.b+")"]];case"kelvin":for(var e=[],i=t.minTemperature,a=t.maxTemperature,s=a-i,h=i,o=0;h<a;h+=s/8,o+=1){var u=p.kelvinToRgb(h);e.push([12.5*o,"rgb("+u.r+","+u.g+","+u.b+")"])}return e;case"hue":return[[0,"#f00"],[16.666,"#ff0"],[33.333,"#0f0"],[50,"#0ff"],[66.666,"#00f"],[83.333,"#f0f"],[100,"#f00"]];case"saturation":var l=p.hsvToHsl({h:r.h,s:0,v:r.v}),g=p.hsvToHsl({h:r.h,s:100,v:r.v});return[[0,"hsl("+l.h+","+l.s+"%,"+l.l+"%)"],[100,"hsl("+g.h+","+g.s+"%,"+g.l+"%)"]];case"value":default:var c=p.hsvToHsl({h:r.h,s:r.s,v:100});return[[0,"#000"],[100,"hsl("+c.h+","+c.s+"%,"+c.l+"%)"]]}}function A(t){var r="horizontal"===t.layoutDirection;return{x1:"0%",y1:r?"100%":"0%",x2:r?"0%":"100%",y2:"0%"}}function k(t){var r=t.width/2;return{width:t.width,radius:r-t.borderWidth,cx:r,cy:r}}function $(t,r,n){var e=t.wheelAngle,i=t.wheelDirection;return((r=!n&&"clockwise"===i||n&&"anticlockwise"===i?(n?180:360)-(e-r):e+r)%360+360)%360}function F(t){var r=t.color.hsv,n=k(t),e=n.cx,i=n.cy,a=t.width/2-t.padding-t.handleRadius-t.borderWidth,s=(180+$(t,r.h,!0))*(Math.PI/180),h=r.s/100*a,o="clockwise"===t.wheelDirection?-1:1;return{x:e+h*Math.cos(s)*o,y:i+h*Math.sin(s)*o}}function j(t,r,n,e){var i=k(t),a=t.width/2-t.padding-t.handleRadius-t.borderWidth;r=i.cx-(r-e.left),n=i.cy-(n-e.top);var s=$(t,Math.atan2(-n,-r)*(180/Math.PI)),h=Math.min(Math.sqrt(r*r+n*n),a);return{h:Math.round(s),s:Math.round(100/a*h)}}function E(t){var r;return(r={})["horizontal"===t.layoutDirection?"marginLeft":"marginTop"]=t.sliderMargin,r}function D(t){var r=t.width;return{width:r,height:r,radius:t.padding+t.handleRadius}}function O(t,r,n,e){var i=D(t),a=i.radius,s=(n-=e.top+a)/(i.height-2*a)*100;return{s:Math.max(0,Math.min((r-=e.left+a)/(i.width-2*a)*100,100)),v:Math.max(0,Math.min(100-s,100))}}function H(t){var r=D(t),n=r.radius,e=t.color.hsv,i=r.height-2*n;return{x:n+e.s/100*(r.width-2*n),y:n+(i-e.v/100*i)}}function I(t){return[[[0,"#fff"],[100,"hsl("+t.color.hue+",100%,50%)"]],[[0,"rgba(0,0,0,0)"],[100,"#000"]]]}var P=document.getElementsByTagName("base");function z(t){var r=window.navigator.userAgent,n=/^((?!chrome|android).)*safari/i.test(r),e=/iPhone|iPod|iPad/i.test(r),i=window.location;return(n||e)&&P.length>0?i.protocol+"//"+i.host+i.pathname+i.search+t:t}function C(t,r,n,e,i){var a=i-e<=180?0:1;return e*=Math.PI/180,i*=Math.PI/180,"M "+(t+n*Math.cos(i))+" "+(r+n*Math.sin(i))+" A "+n+" "+n+" 0 "+a+" 0 "+(t+n*Math.cos(e))+" "+(r+n*Math.sin(e))}var W={width:300,height:300,handleRadius:8,handleSvg:null,handleProps:{x:0,y:0},color:"#fff",borderColor:"#fff",borderWidth:0,wheelLightness:!0,wheelAngle:0,wheelDirection:"anticlockwise",layoutDirection:"vertical",sliderSize:null,sliderMargin:12,padding:6};export{p as IroColor,w as sliderDefaultOptions,m as getSliderStyles,S as getSliderDimensions,M as getCurrentSliderValue,y as getSliderValueFromInput,T as getSliderHandlePosition,R as getSliderGradient,A as getSliderGradientCoords,k as getWheelDimensions,$ as translateWheelAngle,F as getWheelHandlePosition,j as getWheelValueFromInput,E as getBoxStyles,D as getBoxDimensions,O as getBoxValueFromInput,H as getBoxHandlePosition,I as getBoxGradients,z as resolveSvgUrl,C as getSvgArcPath,W as iroColorPickerOptionDefaults};
//# sourceMappingURL=iro-core.es.js.map

@@ -1,2 +0,2 @@

var t="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",e="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",n=new RegExp("rgb"+e),i=new RegExp("rgba"+r),a=new RegExp("hsl"+e),s=new RegExp("hsla"+r),h=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$"),o=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$"),l=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$"),u=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$"),g=Math.log,c=Math.round,f=Math.floor;function v(t,e){var r=t.indexOf("%")>-1,n=parseFloat(t);return r?e/100*n:n}function d(t){return parseInt(t,16)}function b(t){return t.toString(16).padStart(2,"0")}var p=function(t,e){this.$={h:0,s:0,v:0,a:1},t&&this.set(t),this.onChange=e},x={hsv:{configurable:!0},hsva:{configurable:!0},hue:{configurable:!0},saturation:{configurable:!0},value:{configurable:!0},alpha:{configurable:!0},kelvin:{configurable:!0},rgb:{configurable:!0},rgba:{configurable:!0},hsl:{configurable:!0},hsla:{configurable:!0},rgbString:{configurable:!0},rgbaString:{configurable:!0},hexString:{configurable:!0},hex8String:{configurable:!0},hslString:{configurable:!0},hslaString:{configurable:!0}};function w(t){var e=t.width,r=t.sliderSize,n=t.borderWidth,i=t.handleRadius,a=t.padding,s="horizontal"===t.layoutDirection;return r=r||2*a+2*i+2*n,"circle"===t.sliderShape?{handleStart:t.padding+t.handleRadius,handleRange:e-2*a-2*i-2*n,width:e,height:e,cx:e/2,cy:e/2,radius:e/2-n/2}:{handleStart:r/2,handleRange:e-r,radius:r/2,x:0,y:0,width:s?r:e,height:s?e:r}}function S(t){var e=t.color.hsva;switch(t.sliderType){case"alpha":return 100*e.a;case"kelvin":var r=t.minTemperature;return Math.max(0,Math.min((t.color.kelvin-r)/(t.maxTemperature-r)*100,100));case"hue":return e.h/=3.6;case"saturation":return e.s;case"value":default:return e.v}}function m(t){var e=t.width/2;return{width:t.width,radius:e-t.borderWidth,cx:e,cy:e}}function y(t,e){var r=t.wheelAngle;return((e="clockwise"===t.wheelDirection?-360+e-r:r-e)%360+360)%360}function M(t){var e=t.width;return{width:e,height:e,radius:t.padding+t.handleRadius}}p.prototype.set=function(t){if("string"==typeof t)/^(?:#?|0x?)[0-9a-fA-F]{3,8}$/.test(t)?this.hexString=t:/^rgba?/.test(t)?this.rgbString=t:/^hsla?/.test(t)&&(this.hslString=t);else{if("object"!=typeof t)throw new Error("Invalid color value");t instanceof p?this.hsv=t.hsv:"object"==typeof t&&"r"in t&&"g"in t&&"b"in t?this.rgb=t:"object"==typeof t&&"h"in t&&"s"in t&&"v"in t?this.hsv=t:"object"==typeof t&&"h"in t&&"s"in t&&"l"in t&&(this.hsl=t)}},p.prototype.setChannel=function(t,e,r){var n;this[t]=Object.assign({},this[t],((n={})[e]=r,n))},p.prototype.clone=function(){return new p(this)},p.hsvToRgb=function(t){var e=t.h/60,r=t.s/100,n=t.v/100,i=f(e),a=e-i,s=n*(1-r),h=n*(1-a*r),o=n*(1-(1-a)*r),l=i%6;return{r:255*[n,h,s,s,o,n][l],g:255*[o,n,n,h,s,s][l],b:255*[s,s,o,n,n,h][l]}},p.rgbToHsv=function(t){var e=t.r/255,r=t.g/255,n=t.b/255,i=Math.max(e,r,n),a=Math.min(e,r,n),s=i-a,h=0,o=i,l=0===i?0:s/i;switch(i){case a:h=0;break;case e:h=(r-n)/s+(r<n?6:0);break;case r:h=(n-e)/s+2;break;case n:h=(e-r)/s+4}return{h:60*h,s:100*l,v:100*o}},p.hsvToHsl=function(t){var e=t.s/100,r=t.v/100,n=(2-e)*r,i=n<=1?n:2-n;return{h:t.h,s:100*(i<1e-9?0:e*r/i),l:50*n}},p.hslToHsv=function(t){var e=2*t.l,r=t.s*(e<=100?e:200-e)/100;return{h:t.h,s:100*(e+r<1e-9?0:2*r/(e+r)),v:(e+r)/2}},p.kelvinToRgb=function(t){var e,r,n,i=t/100;return i<66?(e=255,r=-155.25485562709179-.44596950469579133*(r=i-2)+104.49216199393888*g(r),n=i<20?0:.8274096064007395*(n=i-10)-254.76935184120902+115.67994401066147*g(n)):(e=351.97690566805693+.114206453784165*(e=i-55)-40.25366309332127*g(e),r=325.4494125711974+.07943456536662342*(r=i-50)-28.0852963507957*g(r),n=255),{r:f(e),g:f(r),b:f(n)}},p.rgbToKelvin=function(t){for(var e,r=t.r,n=t.b,i=1e3,a=4e4;a-i>.4;){var s=p.kelvinToRgb(e=.5*(a+i));s.b/s.r>=n/r?a=e:i=e}return e},x.hsv.get=function(){var t=this.$;return{h:t.h,s:t.s,v:t.v}},x.hsv.set=function(t){var e=this.$;if(t=Object.assign({},e,t),this.onChange){var r={h:!1,v:!1,s:!1,a:!1};for(var n in e)r[n]=t[n]!=e[n];this.$=t,(r.h||r.s||r.v||r.a)&&this.onChange(this,r)}else this.$=t},x.hsva.get=function(){return Object.assign({},this.$)},x.hsva.set=function(t){this.hsv=t},x.hue.get=function(){return this.$.h},x.hue.set=function(t){this.hsv={h:t}},x.saturation.get=function(){return this.$.s},x.saturation.set=function(t){this.hsv={s:t}},x.value.get=function(){return this.$.v},x.value.set=function(t){this.hsv={v:t}},x.alpha.get=function(){return this.$.a},x.alpha.set=function(t){this.hsv=Object.assign({},this.hsv,{a:t})},x.kelvin.get=function(){return p.rgbToKelvin(this.rgb)},x.kelvin.set=function(t){this.rgb=p.kelvinToRgb(t)},x.rgb.get=function(){var t=p.hsvToRgb(this.$),e=t.g,r=t.b;return{r:c(t.r),g:c(e),b:c(r)}},x.rgb.set=function(t){this.hsv=Object.assign({},p.rgbToHsv(t),{a:void 0===t.a?1:t.a})},x.rgba.get=function(){return Object.assign({},this.rgb,{a:this.alpha})},x.rgba.set=function(t){this.rgb=t},x.hsl.get=function(){var t=p.hsvToHsl(this.$),e=t.s,r=t.l;return{h:c(t.h),s:c(e),l:c(r)}},x.hsl.set=function(t){this.hsv=Object.assign({},p.hslToHsv(t),{a:void 0===t.a?1:t.a})},x.hsla.get=function(){return Object.assign({},this.hsl,{a:this.alpha})},x.hsla.set=function(t){this.hsl=t},x.rgbString.get=function(){var t=this.rgb;return"rgb("+t.r+", "+t.g+", "+t.b+")"},x.rgbString.set=function(t){var e,r,a,s,h=1;if((e=n.exec(t))?(r=v(e[1],255),a=v(e[2],255),s=v(e[3],255)):(e=i.exec(t))&&(r=v(e[1],255),a=v(e[2],255),s=v(e[3],255),h=v(e[4],1)),!e)throw new Error("Invalid rgb string");this.rgb={r:r,g:a,b:s,a:h}},x.rgbaString.get=function(){var t=this.rgba;return"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")"},x.rgbaString.set=function(t){this.rgbString=t},x.hexString.get=function(){var t=this.rgb;return"#"+b(t.r)+b(t.g)+b(t.b)},x.hexString.set=function(t){var e,r,n,i,a=255;if((e=h.exec(t))?(r=17*d(e[1]),n=17*d(e[2]),i=17*d(e[3])):(e=o.exec(t))?(r=17*d(e[1]),n=17*d(e[2]),i=17*d(e[3]),a=17*d(e[4])):(e=l.exec(t))?(r=d(e[1]),n=d(e[2]),i=d(e[3])):(e=u.exec(t))&&(r=d(e[1]),n=d(e[2]),i=d(e[3]),a=d(e[4])),!e)throw new Error("Invalid hex string");this.rgb={r:r,g:n,b:i,a:a/255}},x.hex8String.get=function(){var t=this.rgba;return"#"+b(t.r)+b(t.g)+b(t.b)+b(f(255*t.a))},x.hex8String.set=function(t){this.hexString=t},x.hslString.get=function(){var t=this.hsl;return"hsl("+t.h+", "+t.s+"%, "+t.l+"%)"},x.hslString.set=function(t){var e,r,n,i,h=1;if((e=a.exec(t))?(r=v(e[1],360),n=v(e[2],100),i=v(e[3],100)):(e=s.exec(t))&&(r=v(e[1],360),n=v(e[2],100),i=v(e[3],100),h=v(e[4],1)),!e)throw new Error("Invalid hsl string");this.hsl={h:r,s:n,l:i,a:h}},x.hslaString.get=function(){var t=this.hsla;return"hsl("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"},x.hslaString.set=function(t){this.hslString=t},Object.defineProperties(p.prototype,x);var T=document.getElementsByTagName("base");exports.IroColor=p,exports.sliderDefaultOptions={sliderShape:"bar",sliderType:"value",minTemperature:2200,maxTemperature:11e3},exports.getSliderStyles=function(t){var e;return(e={})["horizontal"===t.layoutDirection?"marginLeft":"marginTop"]=t.sliderMargin,e},exports.getSliderDimensions=w,exports.getCurrentSliderValue=S,exports.getSliderValueFromInput=function(t,e,r,n){var i,a=w(t),s=a.handleRange,h=a.handleStart;i="horizontal"===t.layoutDirection?-1*(r-n.top)+s+h:e-(n.left+h),i=Math.max(Math.min(i,s),0);var o=Math.round(100/s*i);switch(t.sliderType){case"kelvin":var l=t.minTemperature;return l+o/100*(t.maxTemperature-l);case"alpha":return o/100;case"hue":return 3.6*o;default:return o}},exports.getSliderHandlePosition=function(t){var e=w(t),r=e.handleRange,n=e.handleStart,i="horizontal"===t.layoutDirection,a=i?e.width/2:e.height/2,s=n+S(t)/100*r;return i&&(s=-1*s+r+2*n),{x:i?a:s,y:i?s:a}},exports.getSliderGradient=function(t){var e=t.color.hsv;switch(t.sliderType){case"alpha":var r=t.color.rgb;return[[0,"rgba("+r.r+","+r.g+","+r.b+",0)"],[100,"rgb("+r.r+","+r.g+","+r.b+")"]];case"kelvin":for(var n=[],i=t.minTemperature,a=t.maxTemperature,s=a-i,h=i,o=0;h<a;h+=s/8,o+=1){var l=p.kelvinToRgb(h);n.push([12.5*o,"rgb("+l.r+","+l.g+","+l.b+")"])}return n;case"hue":return[[0,"#f00"],[16.666,"#ff0"],[33.333,"#0f0"],[50,"#0ff"],[66.666,"#00f"],[83.333,"#f0f"],[100,"#f00"]];case"saturation":var u=p.hsvToHsl({h:e.h,s:0,v:e.v}),g=p.hsvToHsl({h:e.h,s:100,v:e.v});return[[0,"hsl("+u.h+","+u.s+"%,"+u.l+"%)"],[100,"hsl("+g.h+","+g.s+"%,"+g.l+"%)"]];case"value":default:var c=p.hsvToHsl({h:e.h,s:e.s,v:100});return[[0,"#000"],[100,"hsl("+c.h+","+c.s+"%,"+c.l+"%)"]]}},exports.getSliderGradientCoords=function(t){var e="horizontal"===t.layoutDirection;return{x1:"0%",y1:e?"100%":"0%",x2:e?"0%":"100%",y2:"0%"}},exports.getWheelDimensions=m,exports.translateWheelAngle=y,exports.getWheelHandlePosition=function(t){var e=t.color.hsv,r=m(t),n=r.cx,i=r.cy,a=t.width/2-t.padding-t.handleRadius-t.borderWidth,s=y(t,e.h)*(Math.PI/180),h=e.s/100*a,o="clockwise"===t.wheelDirection?-1:1;return{x:n+h*Math.cos(s)*o,y:i+h*Math.sin(s)*o}},exports.getWheelValueFromInput=function(t,e,r,n){var i=m(t),a=t.width/2-t.padding-t.handleRadius-t.borderWidth;e=i.cx-(e-n.left),r=i.cy-(r-n.top);var s=y(t,Math.atan2(-r,-e)*(180/Math.PI)),h=Math.min(Math.sqrt(e*e+r*r),a);return{h:Math.round(s),s:Math.round(100/a*h)}},exports.getBoxStyles=function(t){var e;return(e={})["horizontal"===t.layoutDirection?"marginLeft":"marginTop"]=t.sliderMargin,e},exports.getBoxDimensions=M,exports.getBoxValueFromInput=function(t,e,r,n){var i=M(t),a=i.radius,s=(r-=n.top+a)/(i.height-2*a)*100;return{s:Math.max(0,Math.min((e-=n.left+a)/(i.width-2*a)*100,100)),v:Math.max(0,Math.min(100-s,100))}},exports.getBoxHandlePosition=function(t){var e=M(t),r=e.radius,n=t.color.hsv,i=e.height-2*r;return{x:r+n.s/100*(e.width-2*r),y:r+(i-n.v/100*i)}},exports.getBoxGradients=function(t){return[[[0,"#fff"],[100,"hsl("+t.color.hue+",100%,50%)"]],[[0,"rgba(0,0,0,0)"],[100,"#000"]]]},exports.resolveSvgUrl=function(t){var e=window.navigator.userAgent,r=/^((?!chrome|android).)*safari/i.test(e),n=/iPhone|iPod|iPad/i.test(e),i=window.location;return(r||n)&&T.length>0?i.protocol+"//"+i.host+i.pathname+i.search+t:t},exports.getSvgArcPath=function(t,e,r,n,i){var a=i-n<=180?0:1;return n*=Math.PI/180,i*=Math.PI/180,"M "+(t+r*Math.cos(i))+" "+(e+r*Math.sin(i))+" A "+r+" "+r+" 0 "+a+" 0 "+(t+r*Math.cos(n))+" "+(e+r*Math.sin(n))},exports.iroColorPickerOptionDefaults={width:300,height:300,handleRadius:8,handleSvg:null,handleProps:{x:0,y:0},color:"#fff",borderColor:"#fff",borderWidth:0,wheelLightness:!0,wheelAngle:0,wheelDirection:"anticlockwise",layoutDirection:"vertical",sliderSize:null,sliderMargin:12,padding:6};
var t="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",e="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",n=new RegExp("rgb"+e),i=new RegExp("rgba"+r),a=new RegExp("hsl"+e),s=new RegExp("hsla"+r),h=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$"),o=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$"),l=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$"),u=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$"),g=Math.log,c=Math.round,f=Math.floor;function v(t,e){var r=t.indexOf("%")>-1,n=parseFloat(t);return r?e/100*n:n}function d(t){return parseInt(t,16)}function b(t){return t.toString(16).padStart(2,"0")}var p=function(t,e){this.$={h:0,s:0,v:0,a:1},t&&this.set(t),this.onChange=e},x={hsv:{configurable:!0},hsva:{configurable:!0},hue:{configurable:!0},saturation:{configurable:!0},value:{configurable:!0},alpha:{configurable:!0},kelvin:{configurable:!0},rgb:{configurable:!0},rgba:{configurable:!0},hsl:{configurable:!0},hsla:{configurable:!0},rgbString:{configurable:!0},rgbaString:{configurable:!0},hexString:{configurable:!0},hex8String:{configurable:!0},hslString:{configurable:!0},hslaString:{configurable:!0}};function w(t){var e=t.width,r=t.sliderSize,n=t.borderWidth,i=t.handleRadius,a=t.padding,s="horizontal"===t.layoutDirection;return r=r||2*a+2*i+2*n,"circle"===t.sliderShape?{handleStart:t.padding+t.handleRadius,handleRange:e-2*a-2*i-2*n,width:e,height:e,cx:e/2,cy:e/2,radius:e/2-n/2}:{handleStart:r/2,handleRange:e-r,radius:r/2,x:0,y:0,width:s?r:e,height:s?e:r}}function S(t){var e=t.color.hsva;switch(t.sliderType){case"alpha":return 100*e.a;case"kelvin":var r=t.minTemperature;return Math.max(0,Math.min((t.color.kelvin-r)/(t.maxTemperature-r)*100,100));case"hue":return e.h/=3.6;case"saturation":return e.s;case"value":default:return e.v}}function m(t){var e=t.width/2;return{width:t.width,radius:e-t.borderWidth,cx:e,cy:e}}function y(t,e,r){var n=t.wheelAngle,i=t.wheelDirection;return((e=!r&&"clockwise"===i||r&&"anticlockwise"===i?(r?180:360)-(n-e):n+e)%360+360)%360}function M(t){var e=t.width;return{width:e,height:e,radius:t.padding+t.handleRadius}}p.prototype.set=function(t){if("string"==typeof t)/^(?:#?|0x?)[0-9a-fA-F]{3,8}$/.test(t)?this.hexString=t:/^rgba?/.test(t)?this.rgbString=t:/^hsla?/.test(t)&&(this.hslString=t);else{if("object"!=typeof t)throw new Error("Invalid color value");t instanceof p?this.hsv=t.hsv:"object"==typeof t&&"r"in t&&"g"in t&&"b"in t?this.rgb=t:"object"==typeof t&&"h"in t&&"s"in t&&"v"in t?this.hsv=t:"object"==typeof t&&"h"in t&&"s"in t&&"l"in t&&(this.hsl=t)}},p.prototype.setChannel=function(t,e,r){var n;this[t]=Object.assign({},this[t],((n={})[e]=r,n))},p.prototype.clone=function(){return new p(this)},p.hsvToRgb=function(t){var e=t.h/60,r=t.s/100,n=t.v/100,i=f(e),a=e-i,s=n*(1-r),h=n*(1-a*r),o=n*(1-(1-a)*r),l=i%6;return{r:255*[n,h,s,s,o,n][l],g:255*[o,n,n,h,s,s][l],b:255*[s,s,o,n,n,h][l]}},p.rgbToHsv=function(t){var e=t.r/255,r=t.g/255,n=t.b/255,i=Math.max(e,r,n),a=Math.min(e,r,n),s=i-a,h=0,o=i,l=0===i?0:s/i;switch(i){case a:h=0;break;case e:h=(r-n)/s+(r<n?6:0);break;case r:h=(n-e)/s+2;break;case n:h=(e-r)/s+4}return{h:60*h,s:100*l,v:100*o}},p.hsvToHsl=function(t){var e=t.s/100,r=t.v/100,n=(2-e)*r,i=n<=1?n:2-n;return{h:t.h,s:100*(i<1e-9?0:e*r/i),l:50*n}},p.hslToHsv=function(t){var e=2*t.l,r=t.s*(e<=100?e:200-e)/100;return{h:t.h,s:100*(e+r<1e-9?0:2*r/(e+r)),v:(e+r)/2}},p.kelvinToRgb=function(t){var e,r,n,i=t/100;return i<66?(e=255,r=-155.25485562709179-.44596950469579133*(r=i-2)+104.49216199393888*g(r),n=i<20?0:.8274096064007395*(n=i-10)-254.76935184120902+115.67994401066147*g(n)):(e=351.97690566805693+.114206453784165*(e=i-55)-40.25366309332127*g(e),r=325.4494125711974+.07943456536662342*(r=i-50)-28.0852963507957*g(r),n=255),{r:f(e),g:f(r),b:f(n)}},p.rgbToKelvin=function(t){for(var e,r=t.r,n=t.b,i=1e3,a=4e4;a-i>.4;){var s=p.kelvinToRgb(e=.5*(a+i));s.b/s.r>=n/r?a=e:i=e}return e},x.hsv.get=function(){var t=this.$;return{h:t.h,s:t.s,v:t.v}},x.hsv.set=function(t){var e=this.$;if(t=Object.assign({},e,t),this.onChange){var r={h:!1,v:!1,s:!1,a:!1};for(var n in e)r[n]=t[n]!=e[n];this.$=t,(r.h||r.s||r.v||r.a)&&this.onChange(this,r)}else this.$=t},x.hsva.get=function(){return Object.assign({},this.$)},x.hsva.set=function(t){this.hsv=t},x.hue.get=function(){return this.$.h},x.hue.set=function(t){this.hsv={h:t}},x.saturation.get=function(){return this.$.s},x.saturation.set=function(t){this.hsv={s:t}},x.value.get=function(){return this.$.v},x.value.set=function(t){this.hsv={v:t}},x.alpha.get=function(){return this.$.a},x.alpha.set=function(t){this.hsv=Object.assign({},this.hsv,{a:t})},x.kelvin.get=function(){return p.rgbToKelvin(this.rgb)},x.kelvin.set=function(t){this.rgb=p.kelvinToRgb(t)},x.rgb.get=function(){var t=p.hsvToRgb(this.$),e=t.g,r=t.b;return{r:c(t.r),g:c(e),b:c(r)}},x.rgb.set=function(t){this.hsv=Object.assign({},p.rgbToHsv(t),{a:void 0===t.a?1:t.a})},x.rgba.get=function(){return Object.assign({},this.rgb,{a:this.alpha})},x.rgba.set=function(t){this.rgb=t},x.hsl.get=function(){var t=p.hsvToHsl(this.$),e=t.s,r=t.l;return{h:c(t.h),s:c(e),l:c(r)}},x.hsl.set=function(t){this.hsv=Object.assign({},p.hslToHsv(t),{a:void 0===t.a?1:t.a})},x.hsla.get=function(){return Object.assign({},this.hsl,{a:this.alpha})},x.hsla.set=function(t){this.hsl=t},x.rgbString.get=function(){var t=this.rgb;return"rgb("+t.r+", "+t.g+", "+t.b+")"},x.rgbString.set=function(t){var e,r,a,s,h=1;if((e=n.exec(t))?(r=v(e[1],255),a=v(e[2],255),s=v(e[3],255)):(e=i.exec(t))&&(r=v(e[1],255),a=v(e[2],255),s=v(e[3],255),h=v(e[4],1)),!e)throw new Error("Invalid rgb string");this.rgb={r:r,g:a,b:s,a:h}},x.rgbaString.get=function(){var t=this.rgba;return"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")"},x.rgbaString.set=function(t){this.rgbString=t},x.hexString.get=function(){var t=this.rgb;return"#"+b(t.r)+b(t.g)+b(t.b)},x.hexString.set=function(t){var e,r,n,i,a=255;if((e=h.exec(t))?(r=17*d(e[1]),n=17*d(e[2]),i=17*d(e[3])):(e=o.exec(t))?(r=17*d(e[1]),n=17*d(e[2]),i=17*d(e[3]),a=17*d(e[4])):(e=l.exec(t))?(r=d(e[1]),n=d(e[2]),i=d(e[3])):(e=u.exec(t))&&(r=d(e[1]),n=d(e[2]),i=d(e[3]),a=d(e[4])),!e)throw new Error("Invalid hex string");this.rgb={r:r,g:n,b:i,a:a/255}},x.hex8String.get=function(){var t=this.rgba;return"#"+b(t.r)+b(t.g)+b(t.b)+b(f(255*t.a))},x.hex8String.set=function(t){this.hexString=t},x.hslString.get=function(){var t=this.hsl;return"hsl("+t.h+", "+t.s+"%, "+t.l+"%)"},x.hslString.set=function(t){var e,r,n,i,h=1;if((e=a.exec(t))?(r=v(e[1],360),n=v(e[2],100),i=v(e[3],100)):(e=s.exec(t))&&(r=v(e[1],360),n=v(e[2],100),i=v(e[3],100),h=v(e[4],1)),!e)throw new Error("Invalid hsl string");this.hsl={h:r,s:n,l:i,a:h}},x.hslaString.get=function(){var t=this.hsla;return"hsl("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"},x.hslaString.set=function(t){this.hslString=t},Object.defineProperties(p.prototype,x);var T=document.getElementsByTagName("base");exports.IroColor=p,exports.sliderDefaultOptions={sliderShape:"bar",sliderType:"value",minTemperature:2200,maxTemperature:11e3},exports.getSliderStyles=function(t){var e;return(e={})["horizontal"===t.layoutDirection?"marginLeft":"marginTop"]=t.sliderMargin,e},exports.getSliderDimensions=w,exports.getCurrentSliderValue=S,exports.getSliderValueFromInput=function(t,e,r,n){var i,a=w(t),s=a.handleRange,h=a.handleStart;i="horizontal"===t.layoutDirection?-1*(r-n.top)+s+h:e-(n.left+h),i=Math.max(Math.min(i,s),0);var o=Math.round(100/s*i);switch(t.sliderType){case"kelvin":var l=t.minTemperature;return l+o/100*(t.maxTemperature-l);case"alpha":return o/100;case"hue":return 3.6*o;default:return o}},exports.getSliderHandlePosition=function(t){var e=w(t),r=e.handleRange,n=e.handleStart,i="horizontal"===t.layoutDirection,a=i?e.width/2:e.height/2,s=n+S(t)/100*r;return i&&(s=-1*s+r+2*n),{x:i?a:s,y:i?s:a}},exports.getSliderGradient=function(t){var e=t.color.hsv;switch(t.sliderType){case"alpha":var r=t.color.rgb;return[[0,"rgba("+r.r+","+r.g+","+r.b+",0)"],[100,"rgb("+r.r+","+r.g+","+r.b+")"]];case"kelvin":for(var n=[],i=t.minTemperature,a=t.maxTemperature,s=a-i,h=i,o=0;h<a;h+=s/8,o+=1){var l=p.kelvinToRgb(h);n.push([12.5*o,"rgb("+l.r+","+l.g+","+l.b+")"])}return n;case"hue":return[[0,"#f00"],[16.666,"#ff0"],[33.333,"#0f0"],[50,"#0ff"],[66.666,"#00f"],[83.333,"#f0f"],[100,"#f00"]];case"saturation":var u=p.hsvToHsl({h:e.h,s:0,v:e.v}),g=p.hsvToHsl({h:e.h,s:100,v:e.v});return[[0,"hsl("+u.h+","+u.s+"%,"+u.l+"%)"],[100,"hsl("+g.h+","+g.s+"%,"+g.l+"%)"]];case"value":default:var c=p.hsvToHsl({h:e.h,s:e.s,v:100});return[[0,"#000"],[100,"hsl("+c.h+","+c.s+"%,"+c.l+"%)"]]}},exports.getSliderGradientCoords=function(t){var e="horizontal"===t.layoutDirection;return{x1:"0%",y1:e?"100%":"0%",x2:e?"0%":"100%",y2:"0%"}},exports.getWheelDimensions=m,exports.translateWheelAngle=y,exports.getWheelHandlePosition=function(t){var e=t.color.hsv,r=m(t),n=r.cx,i=r.cy,a=t.width/2-t.padding-t.handleRadius-t.borderWidth,s=(180+y(t,e.h,!0))*(Math.PI/180),h=e.s/100*a,o="clockwise"===t.wheelDirection?-1:1;return{x:n+h*Math.cos(s)*o,y:i+h*Math.sin(s)*o}},exports.getWheelValueFromInput=function(t,e,r,n){var i=m(t),a=t.width/2-t.padding-t.handleRadius-t.borderWidth;e=i.cx-(e-n.left),r=i.cy-(r-n.top);var s=y(t,Math.atan2(-r,-e)*(180/Math.PI)),h=Math.min(Math.sqrt(e*e+r*r),a);return{h:Math.round(s),s:Math.round(100/a*h)}},exports.getBoxStyles=function(t){var e;return(e={})["horizontal"===t.layoutDirection?"marginLeft":"marginTop"]=t.sliderMargin,e},exports.getBoxDimensions=M,exports.getBoxValueFromInput=function(t,e,r,n){var i=M(t),a=i.radius,s=(r-=n.top+a)/(i.height-2*a)*100;return{s:Math.max(0,Math.min((e-=n.left+a)/(i.width-2*a)*100,100)),v:Math.max(0,Math.min(100-s,100))}},exports.getBoxHandlePosition=function(t){var e=M(t),r=e.radius,n=t.color.hsv,i=e.height-2*r;return{x:r+n.s/100*(e.width-2*r),y:r+(i-n.v/100*i)}},exports.getBoxGradients=function(t){return[[[0,"#fff"],[100,"hsl("+t.color.hue+",100%,50%)"]],[[0,"rgba(0,0,0,0)"],[100,"#000"]]]},exports.resolveSvgUrl=function(t){var e=window.navigator.userAgent,r=/^((?!chrome|android).)*safari/i.test(e),n=/iPhone|iPod|iPad/i.test(e),i=window.location;return(r||n)&&T.length>0?i.protocol+"//"+i.host+i.pathname+i.search+t:t},exports.getSvgArcPath=function(t,e,r,n,i){var a=i-n<=180?0:1;return n*=Math.PI/180,i*=Math.PI/180,"M "+(t+r*Math.cos(i))+" "+(e+r*Math.sin(i))+" A "+r+" "+r+" 0 "+a+" 0 "+(t+r*Math.cos(n))+" "+(e+r*Math.sin(n))},exports.iroColorPickerOptionDefaults={width:300,height:300,handleRadius:8,handleSvg:null,handleProps:{x:0,y:0},color:"#fff",borderColor:"#fff",borderWidth:0,wheelLightness:!0,wheelAngle:0,wheelDirection:"anticlockwise",layoutDirection:"vertical",sliderSize:null,sliderMargin:12,padding:6};
//# sourceMappingURL=iro-core.js.map

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.iroCore={})}(this,function(t){var e="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",r="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",n="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",i=new RegExp("rgb"+r),a=new RegExp("rgba"+n),s=new RegExp("hsl"+r),h=new RegExp("hsla"+n),o=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$"),l=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$"),u=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$"),g=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$"),c=Math.log,f=Math.round,v=Math.floor;function d(t,e){var r=t.indexOf("%")>-1,n=parseFloat(t);return r?e/100*n:n}function b(t){return parseInt(t,16)}function p(t){return t.toString(16).padStart(2,"0")}var x=function(t,e){this.$={h:0,s:0,v:0,a:1},t&&this.set(t),this.onChange=e},w={hsv:{configurable:!0},hsva:{configurable:!0},hue:{configurable:!0},saturation:{configurable:!0},value:{configurable:!0},alpha:{configurable:!0},kelvin:{configurable:!0},rgb:{configurable:!0},rgba:{configurable:!0},hsl:{configurable:!0},hsla:{configurable:!0},rgbString:{configurable:!0},rgbaString:{configurable:!0},hexString:{configurable:!0},hex8String:{configurable:!0},hslString:{configurable:!0},hslaString:{configurable:!0}};function S(t){var e=t.width,r=t.sliderSize,n=t.borderWidth,i=t.handleRadius,a=t.padding,s="horizontal"===t.layoutDirection;return r=r||2*a+2*i+2*n,"circle"===t.sliderShape?{handleStart:t.padding+t.handleRadius,handleRange:e-2*a-2*i-2*n,width:e,height:e,cx:e/2,cy:e/2,radius:e/2-n/2}:{handleStart:r/2,handleRange:e-r,radius:r/2,x:0,y:0,width:s?r:e,height:s?e:r}}function m(t){var e=t.color.hsva;switch(t.sliderType){case"alpha":return 100*e.a;case"kelvin":var r=t.minTemperature;return Math.max(0,Math.min((t.color.kelvin-r)/(t.maxTemperature-r)*100,100));case"hue":return e.h/=3.6;case"saturation":return e.s;case"value":default:return e.v}}function y(t){var e=t.width/2;return{width:t.width,radius:e-t.borderWidth,cx:e,cy:e}}function M(t,e){var r=t.wheelAngle;return((e="clockwise"===t.wheelDirection?-360+e-r:r-e)%360+360)%360}function T(t){var e=t.width;return{width:e,height:e,radius:t.padding+t.handleRadius}}x.prototype.set=function(t){if("string"==typeof t)/^(?:#?|0x?)[0-9a-fA-F]{3,8}$/.test(t)?this.hexString=t:/^rgba?/.test(t)?this.rgbString=t:/^hsla?/.test(t)&&(this.hslString=t);else{if("object"!=typeof t)throw new Error("Invalid color value");t instanceof x?this.hsv=t.hsv:"object"==typeof t&&"r"in t&&"g"in t&&"b"in t?this.rgb=t:"object"==typeof t&&"h"in t&&"s"in t&&"v"in t?this.hsv=t:"object"==typeof t&&"h"in t&&"s"in t&&"l"in t&&(this.hsl=t)}},x.prototype.setChannel=function(t,e,r){var n;this[t]=Object.assign({},this[t],((n={})[e]=r,n))},x.prototype.clone=function(){return new x(this)},x.hsvToRgb=function(t){var e=t.h/60,r=t.s/100,n=t.v/100,i=v(e),a=e-i,s=n*(1-r),h=n*(1-a*r),o=n*(1-(1-a)*r),l=i%6;return{r:255*[n,h,s,s,o,n][l],g:255*[o,n,n,h,s,s][l],b:255*[s,s,o,n,n,h][l]}},x.rgbToHsv=function(t){var e=t.r/255,r=t.g/255,n=t.b/255,i=Math.max(e,r,n),a=Math.min(e,r,n),s=i-a,h=0,o=i,l=0===i?0:s/i;switch(i){case a:h=0;break;case e:h=(r-n)/s+(r<n?6:0);break;case r:h=(n-e)/s+2;break;case n:h=(e-r)/s+4}return{h:60*h,s:100*l,v:100*o}},x.hsvToHsl=function(t){var e=t.s/100,r=t.v/100,n=(2-e)*r,i=n<=1?n:2-n;return{h:t.h,s:100*(i<1e-9?0:e*r/i),l:50*n}},x.hslToHsv=function(t){var e=2*t.l,r=t.s*(e<=100?e:200-e)/100;return{h:t.h,s:100*(e+r<1e-9?0:2*r/(e+r)),v:(e+r)/2}},x.kelvinToRgb=function(t){var e,r,n,i=t/100;return i<66?(e=255,r=-155.25485562709179-.44596950469579133*(r=i-2)+104.49216199393888*c(r),n=i<20?0:.8274096064007395*(n=i-10)-254.76935184120902+115.67994401066147*c(n)):(e=351.97690566805693+.114206453784165*(e=i-55)-40.25366309332127*c(e),r=325.4494125711974+.07943456536662342*(r=i-50)-28.0852963507957*c(r),n=255),{r:v(e),g:v(r),b:v(n)}},x.rgbToKelvin=function(t){for(var e,r=t.r,n=t.b,i=1e3,a=4e4;a-i>.4;){var s=x.kelvinToRgb(e=.5*(a+i));s.b/s.r>=n/r?a=e:i=e}return e},w.hsv.get=function(){var t=this.$;return{h:t.h,s:t.s,v:t.v}},w.hsv.set=function(t){var e=this.$;if(t=Object.assign({},e,t),this.onChange){var r={h:!1,v:!1,s:!1,a:!1};for(var n in e)r[n]=t[n]!=e[n];this.$=t,(r.h||r.s||r.v||r.a)&&this.onChange(this,r)}else this.$=t},w.hsva.get=function(){return Object.assign({},this.$)},w.hsva.set=function(t){this.hsv=t},w.hue.get=function(){return this.$.h},w.hue.set=function(t){this.hsv={h:t}},w.saturation.get=function(){return this.$.s},w.saturation.set=function(t){this.hsv={s:t}},w.value.get=function(){return this.$.v},w.value.set=function(t){this.hsv={v:t}},w.alpha.get=function(){return this.$.a},w.alpha.set=function(t){this.hsv=Object.assign({},this.hsv,{a:t})},w.kelvin.get=function(){return x.rgbToKelvin(this.rgb)},w.kelvin.set=function(t){this.rgb=x.kelvinToRgb(t)},w.rgb.get=function(){var t=x.hsvToRgb(this.$),e=t.g,r=t.b;return{r:f(t.r),g:f(e),b:f(r)}},w.rgb.set=function(t){this.hsv=Object.assign({},x.rgbToHsv(t),{a:void 0===t.a?1:t.a})},w.rgba.get=function(){return Object.assign({},this.rgb,{a:this.alpha})},w.rgba.set=function(t){this.rgb=t},w.hsl.get=function(){var t=x.hsvToHsl(this.$),e=t.s,r=t.l;return{h:f(t.h),s:f(e),l:f(r)}},w.hsl.set=function(t){this.hsv=Object.assign({},x.hslToHsv(t),{a:void 0===t.a?1:t.a})},w.hsla.get=function(){return Object.assign({},this.hsl,{a:this.alpha})},w.hsla.set=function(t){this.hsl=t},w.rgbString.get=function(){var t=this.rgb;return"rgb("+t.r+", "+t.g+", "+t.b+")"},w.rgbString.set=function(t){var e,r,n,s,h=1;if((e=i.exec(t))?(r=d(e[1],255),n=d(e[2],255),s=d(e[3],255)):(e=a.exec(t))&&(r=d(e[1],255),n=d(e[2],255),s=d(e[3],255),h=d(e[4],1)),!e)throw new Error("Invalid rgb string");this.rgb={r:r,g:n,b:s,a:h}},w.rgbaString.get=function(){var t=this.rgba;return"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")"},w.rgbaString.set=function(t){this.rgbString=t},w.hexString.get=function(){var t=this.rgb;return"#"+p(t.r)+p(t.g)+p(t.b)},w.hexString.set=function(t){var e,r,n,i,a=255;if((e=o.exec(t))?(r=17*b(e[1]),n=17*b(e[2]),i=17*b(e[3])):(e=l.exec(t))?(r=17*b(e[1]),n=17*b(e[2]),i=17*b(e[3]),a=17*b(e[4])):(e=u.exec(t))?(r=b(e[1]),n=b(e[2]),i=b(e[3])):(e=g.exec(t))&&(r=b(e[1]),n=b(e[2]),i=b(e[3]),a=b(e[4])),!e)throw new Error("Invalid hex string");this.rgb={r:r,g:n,b:i,a:a/255}},w.hex8String.get=function(){var t=this.rgba;return"#"+p(t.r)+p(t.g)+p(t.b)+p(v(255*t.a))},w.hex8String.set=function(t){this.hexString=t},w.hslString.get=function(){var t=this.hsl;return"hsl("+t.h+", "+t.s+"%, "+t.l+"%)"},w.hslString.set=function(t){var e,r,n,i,a=1;if((e=s.exec(t))?(r=d(e[1],360),n=d(e[2],100),i=d(e[3],100)):(e=h.exec(t))&&(r=d(e[1],360),n=d(e[2],100),i=d(e[3],100),a=d(e[4],1)),!e)throw new Error("Invalid hsl string");this.hsl={h:r,s:n,l:i,a:a}},w.hslaString.get=function(){var t=this.hsla;return"hsl("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"},w.hslaString.set=function(t){this.hslString=t},Object.defineProperties(x.prototype,w);var R=document.getElementsByTagName("base");t.IroColor=x,t.sliderDefaultOptions={sliderShape:"bar",sliderType:"value",minTemperature:2200,maxTemperature:11e3},t.getSliderStyles=function(t){var e;return(e={})["horizontal"===t.layoutDirection?"marginLeft":"marginTop"]=t.sliderMargin,e},t.getSliderDimensions=S,t.getCurrentSliderValue=m,t.getSliderValueFromInput=function(t,e,r,n){var i,a=S(t),s=a.handleRange,h=a.handleStart;i="horizontal"===t.layoutDirection?-1*(r-n.top)+s+h:e-(n.left+h),i=Math.max(Math.min(i,s),0);var o=Math.round(100/s*i);switch(t.sliderType){case"kelvin":var l=t.minTemperature;return l+o/100*(t.maxTemperature-l);case"alpha":return o/100;case"hue":return 3.6*o;default:return o}},t.getSliderHandlePosition=function(t){var e=S(t),r=e.handleRange,n=e.handleStart,i="horizontal"===t.layoutDirection,a=i?e.width/2:e.height/2,s=n+m(t)/100*r;return i&&(s=-1*s+r+2*n),{x:i?a:s,y:i?s:a}},t.getSliderGradient=function(t){var e=t.color.hsv;switch(t.sliderType){case"alpha":var r=t.color.rgb;return[[0,"rgba("+r.r+","+r.g+","+r.b+",0)"],[100,"rgb("+r.r+","+r.g+","+r.b+")"]];case"kelvin":for(var n=[],i=t.minTemperature,a=t.maxTemperature,s=a-i,h=i,o=0;h<a;h+=s/8,o+=1){var l=x.kelvinToRgb(h);n.push([12.5*o,"rgb("+l.r+","+l.g+","+l.b+")"])}return n;case"hue":return[[0,"#f00"],[16.666,"#ff0"],[33.333,"#0f0"],[50,"#0ff"],[66.666,"#00f"],[83.333,"#f0f"],[100,"#f00"]];case"saturation":var u=x.hsvToHsl({h:e.h,s:0,v:e.v}),g=x.hsvToHsl({h:e.h,s:100,v:e.v});return[[0,"hsl("+u.h+","+u.s+"%,"+u.l+"%)"],[100,"hsl("+g.h+","+g.s+"%,"+g.l+"%)"]];case"value":default:var c=x.hsvToHsl({h:e.h,s:e.s,v:100});return[[0,"#000"],[100,"hsl("+c.h+","+c.s+"%,"+c.l+"%)"]]}},t.getSliderGradientCoords=function(t){var e="horizontal"===t.layoutDirection;return{x1:"0%",y1:e?"100%":"0%",x2:e?"0%":"100%",y2:"0%"}},t.getWheelDimensions=y,t.translateWheelAngle=M,t.getWheelHandlePosition=function(t){var e=t.color.hsv,r=y(t),n=r.cx,i=r.cy,a=t.width/2-t.padding-t.handleRadius-t.borderWidth,s=M(t,e.h)*(Math.PI/180),h=e.s/100*a,o="clockwise"===t.wheelDirection?-1:1;return{x:n+h*Math.cos(s)*o,y:i+h*Math.sin(s)*o}},t.getWheelValueFromInput=function(t,e,r,n){var i=y(t),a=t.width/2-t.padding-t.handleRadius-t.borderWidth;e=i.cx-(e-n.left),r=i.cy-(r-n.top);var s=M(t,Math.atan2(-r,-e)*(180/Math.PI)),h=Math.min(Math.sqrt(e*e+r*r),a);return{h:Math.round(s),s:Math.round(100/a*h)}},t.getBoxStyles=function(t){var e;return(e={})["horizontal"===t.layoutDirection?"marginLeft":"marginTop"]=t.sliderMargin,e},t.getBoxDimensions=T,t.getBoxValueFromInput=function(t,e,r,n){var i=T(t),a=i.radius,s=(r-=n.top+a)/(i.height-2*a)*100;return{s:Math.max(0,Math.min((e-=n.left+a)/(i.width-2*a)*100,100)),v:Math.max(0,Math.min(100-s,100))}},t.getBoxHandlePosition=function(t){var e=T(t),r=e.radius,n=t.color.hsv,i=e.height-2*r;return{x:r+n.s/100*(e.width-2*r),y:r+(i-n.v/100*i)}},t.getBoxGradients=function(t){return[[[0,"#fff"],[100,"hsl("+t.color.hue+",100%,50%)"]],[[0,"rgba(0,0,0,0)"],[100,"#000"]]]},t.resolveSvgUrl=function(t){var e=window.navigator.userAgent,r=/^((?!chrome|android).)*safari/i.test(e),n=/iPhone|iPod|iPad/i.test(e),i=window.location;return(r||n)&&R.length>0?i.protocol+"//"+i.host+i.pathname+i.search+t:t},t.getSvgArcPath=function(t,e,r,n,i){var a=i-n<=180?0:1;return n*=Math.PI/180,i*=Math.PI/180,"M "+(t+r*Math.cos(i))+" "+(e+r*Math.sin(i))+" A "+r+" "+r+" 0 "+a+" 0 "+(t+r*Math.cos(n))+" "+(e+r*Math.sin(n))},t.iroColorPickerOptionDefaults={width:300,height:300,handleRadius:8,handleSvg:null,handleProps:{x:0,y:0},color:"#fff",borderColor:"#fff",borderWidth:0,wheelLightness:!0,wheelAngle:0,wheelDirection:"anticlockwise",layoutDirection:"vertical",sliderSize:null,sliderMargin:12,padding:6}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.iroCore={})}(this,function(t){var e="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",r="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",n="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",i=new RegExp("rgb"+r),a=new RegExp("rgba"+n),s=new RegExp("hsl"+r),h=new RegExp("hsla"+n),o=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$"),l=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$"),u=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$"),g=new RegExp("^(?:#?|0x?)([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$"),c=Math.log,f=Math.round,v=Math.floor;function d(t,e){var r=t.indexOf("%")>-1,n=parseFloat(t);return r?e/100*n:n}function b(t){return parseInt(t,16)}function p(t){return t.toString(16).padStart(2,"0")}var x=function(t,e){this.$={h:0,s:0,v:0,a:1},t&&this.set(t),this.onChange=e},w={hsv:{configurable:!0},hsva:{configurable:!0},hue:{configurable:!0},saturation:{configurable:!0},value:{configurable:!0},alpha:{configurable:!0},kelvin:{configurable:!0},rgb:{configurable:!0},rgba:{configurable:!0},hsl:{configurable:!0},hsla:{configurable:!0},rgbString:{configurable:!0},rgbaString:{configurable:!0},hexString:{configurable:!0},hex8String:{configurable:!0},hslString:{configurable:!0},hslaString:{configurable:!0}};function S(t){var e=t.width,r=t.sliderSize,n=t.borderWidth,i=t.handleRadius,a=t.padding,s="horizontal"===t.layoutDirection;return r=r||2*a+2*i+2*n,"circle"===t.sliderShape?{handleStart:t.padding+t.handleRadius,handleRange:e-2*a-2*i-2*n,width:e,height:e,cx:e/2,cy:e/2,radius:e/2-n/2}:{handleStart:r/2,handleRange:e-r,radius:r/2,x:0,y:0,width:s?r:e,height:s?e:r}}function m(t){var e=t.color.hsva;switch(t.sliderType){case"alpha":return 100*e.a;case"kelvin":var r=t.minTemperature;return Math.max(0,Math.min((t.color.kelvin-r)/(t.maxTemperature-r)*100,100));case"hue":return e.h/=3.6;case"saturation":return e.s;case"value":default:return e.v}}function y(t){var e=t.width/2;return{width:t.width,radius:e-t.borderWidth,cx:e,cy:e}}function M(t,e,r){var n=t.wheelAngle,i=t.wheelDirection;return((e=!r&&"clockwise"===i||r&&"anticlockwise"===i?(r?180:360)-(n-e):n+e)%360+360)%360}function T(t){var e=t.width;return{width:e,height:e,radius:t.padding+t.handleRadius}}x.prototype.set=function(t){if("string"==typeof t)/^(?:#?|0x?)[0-9a-fA-F]{3,8}$/.test(t)?this.hexString=t:/^rgba?/.test(t)?this.rgbString=t:/^hsla?/.test(t)&&(this.hslString=t);else{if("object"!=typeof t)throw new Error("Invalid color value");t instanceof x?this.hsv=t.hsv:"object"==typeof t&&"r"in t&&"g"in t&&"b"in t?this.rgb=t:"object"==typeof t&&"h"in t&&"s"in t&&"v"in t?this.hsv=t:"object"==typeof t&&"h"in t&&"s"in t&&"l"in t&&(this.hsl=t)}},x.prototype.setChannel=function(t,e,r){var n;this[t]=Object.assign({},this[t],((n={})[e]=r,n))},x.prototype.clone=function(){return new x(this)},x.hsvToRgb=function(t){var e=t.h/60,r=t.s/100,n=t.v/100,i=v(e),a=e-i,s=n*(1-r),h=n*(1-a*r),o=n*(1-(1-a)*r),l=i%6;return{r:255*[n,h,s,s,o,n][l],g:255*[o,n,n,h,s,s][l],b:255*[s,s,o,n,n,h][l]}},x.rgbToHsv=function(t){var e=t.r/255,r=t.g/255,n=t.b/255,i=Math.max(e,r,n),a=Math.min(e,r,n),s=i-a,h=0,o=i,l=0===i?0:s/i;switch(i){case a:h=0;break;case e:h=(r-n)/s+(r<n?6:0);break;case r:h=(n-e)/s+2;break;case n:h=(e-r)/s+4}return{h:60*h,s:100*l,v:100*o}},x.hsvToHsl=function(t){var e=t.s/100,r=t.v/100,n=(2-e)*r,i=n<=1?n:2-n;return{h:t.h,s:100*(i<1e-9?0:e*r/i),l:50*n}},x.hslToHsv=function(t){var e=2*t.l,r=t.s*(e<=100?e:200-e)/100;return{h:t.h,s:100*(e+r<1e-9?0:2*r/(e+r)),v:(e+r)/2}},x.kelvinToRgb=function(t){var e,r,n,i=t/100;return i<66?(e=255,r=-155.25485562709179-.44596950469579133*(r=i-2)+104.49216199393888*c(r),n=i<20?0:.8274096064007395*(n=i-10)-254.76935184120902+115.67994401066147*c(n)):(e=351.97690566805693+.114206453784165*(e=i-55)-40.25366309332127*c(e),r=325.4494125711974+.07943456536662342*(r=i-50)-28.0852963507957*c(r),n=255),{r:v(e),g:v(r),b:v(n)}},x.rgbToKelvin=function(t){for(var e,r=t.r,n=t.b,i=1e3,a=4e4;a-i>.4;){var s=x.kelvinToRgb(e=.5*(a+i));s.b/s.r>=n/r?a=e:i=e}return e},w.hsv.get=function(){var t=this.$;return{h:t.h,s:t.s,v:t.v}},w.hsv.set=function(t){var e=this.$;if(t=Object.assign({},e,t),this.onChange){var r={h:!1,v:!1,s:!1,a:!1};for(var n in e)r[n]=t[n]!=e[n];this.$=t,(r.h||r.s||r.v||r.a)&&this.onChange(this,r)}else this.$=t},w.hsva.get=function(){return Object.assign({},this.$)},w.hsva.set=function(t){this.hsv=t},w.hue.get=function(){return this.$.h},w.hue.set=function(t){this.hsv={h:t}},w.saturation.get=function(){return this.$.s},w.saturation.set=function(t){this.hsv={s:t}},w.value.get=function(){return this.$.v},w.value.set=function(t){this.hsv={v:t}},w.alpha.get=function(){return this.$.a},w.alpha.set=function(t){this.hsv=Object.assign({},this.hsv,{a:t})},w.kelvin.get=function(){return x.rgbToKelvin(this.rgb)},w.kelvin.set=function(t){this.rgb=x.kelvinToRgb(t)},w.rgb.get=function(){var t=x.hsvToRgb(this.$),e=t.g,r=t.b;return{r:f(t.r),g:f(e),b:f(r)}},w.rgb.set=function(t){this.hsv=Object.assign({},x.rgbToHsv(t),{a:void 0===t.a?1:t.a})},w.rgba.get=function(){return Object.assign({},this.rgb,{a:this.alpha})},w.rgba.set=function(t){this.rgb=t},w.hsl.get=function(){var t=x.hsvToHsl(this.$),e=t.s,r=t.l;return{h:f(t.h),s:f(e),l:f(r)}},w.hsl.set=function(t){this.hsv=Object.assign({},x.hslToHsv(t),{a:void 0===t.a?1:t.a})},w.hsla.get=function(){return Object.assign({},this.hsl,{a:this.alpha})},w.hsla.set=function(t){this.hsl=t},w.rgbString.get=function(){var t=this.rgb;return"rgb("+t.r+", "+t.g+", "+t.b+")"},w.rgbString.set=function(t){var e,r,n,s,h=1;if((e=i.exec(t))?(r=d(e[1],255),n=d(e[2],255),s=d(e[3],255)):(e=a.exec(t))&&(r=d(e[1],255),n=d(e[2],255),s=d(e[3],255),h=d(e[4],1)),!e)throw new Error("Invalid rgb string");this.rgb={r:r,g:n,b:s,a:h}},w.rgbaString.get=function(){var t=this.rgba;return"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")"},w.rgbaString.set=function(t){this.rgbString=t},w.hexString.get=function(){var t=this.rgb;return"#"+p(t.r)+p(t.g)+p(t.b)},w.hexString.set=function(t){var e,r,n,i,a=255;if((e=o.exec(t))?(r=17*b(e[1]),n=17*b(e[2]),i=17*b(e[3])):(e=l.exec(t))?(r=17*b(e[1]),n=17*b(e[2]),i=17*b(e[3]),a=17*b(e[4])):(e=u.exec(t))?(r=b(e[1]),n=b(e[2]),i=b(e[3])):(e=g.exec(t))&&(r=b(e[1]),n=b(e[2]),i=b(e[3]),a=b(e[4])),!e)throw new Error("Invalid hex string");this.rgb={r:r,g:n,b:i,a:a/255}},w.hex8String.get=function(){var t=this.rgba;return"#"+p(t.r)+p(t.g)+p(t.b)+p(v(255*t.a))},w.hex8String.set=function(t){this.hexString=t},w.hslString.get=function(){var t=this.hsl;return"hsl("+t.h+", "+t.s+"%, "+t.l+"%)"},w.hslString.set=function(t){var e,r,n,i,a=1;if((e=s.exec(t))?(r=d(e[1],360),n=d(e[2],100),i=d(e[3],100)):(e=h.exec(t))&&(r=d(e[1],360),n=d(e[2],100),i=d(e[3],100),a=d(e[4],1)),!e)throw new Error("Invalid hsl string");this.hsl={h:r,s:n,l:i,a:a}},w.hslaString.get=function(){var t=this.hsla;return"hsl("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"},w.hslaString.set=function(t){this.hslString=t},Object.defineProperties(x.prototype,w);var R=document.getElementsByTagName("base");t.IroColor=x,t.sliderDefaultOptions={sliderShape:"bar",sliderType:"value",minTemperature:2200,maxTemperature:11e3},t.getSliderStyles=function(t){var e;return(e={})["horizontal"===t.layoutDirection?"marginLeft":"marginTop"]=t.sliderMargin,e},t.getSliderDimensions=S,t.getCurrentSliderValue=m,t.getSliderValueFromInput=function(t,e,r,n){var i,a=S(t),s=a.handleRange,h=a.handleStart;i="horizontal"===t.layoutDirection?-1*(r-n.top)+s+h:e-(n.left+h),i=Math.max(Math.min(i,s),0);var o=Math.round(100/s*i);switch(t.sliderType){case"kelvin":var l=t.minTemperature;return l+o/100*(t.maxTemperature-l);case"alpha":return o/100;case"hue":return 3.6*o;default:return o}},t.getSliderHandlePosition=function(t){var e=S(t),r=e.handleRange,n=e.handleStart,i="horizontal"===t.layoutDirection,a=i?e.width/2:e.height/2,s=n+m(t)/100*r;return i&&(s=-1*s+r+2*n),{x:i?a:s,y:i?s:a}},t.getSliderGradient=function(t){var e=t.color.hsv;switch(t.sliderType){case"alpha":var r=t.color.rgb;return[[0,"rgba("+r.r+","+r.g+","+r.b+",0)"],[100,"rgb("+r.r+","+r.g+","+r.b+")"]];case"kelvin":for(var n=[],i=t.minTemperature,a=t.maxTemperature,s=a-i,h=i,o=0;h<a;h+=s/8,o+=1){var l=x.kelvinToRgb(h);n.push([12.5*o,"rgb("+l.r+","+l.g+","+l.b+")"])}return n;case"hue":return[[0,"#f00"],[16.666,"#ff0"],[33.333,"#0f0"],[50,"#0ff"],[66.666,"#00f"],[83.333,"#f0f"],[100,"#f00"]];case"saturation":var u=x.hsvToHsl({h:e.h,s:0,v:e.v}),g=x.hsvToHsl({h:e.h,s:100,v:e.v});return[[0,"hsl("+u.h+","+u.s+"%,"+u.l+"%)"],[100,"hsl("+g.h+","+g.s+"%,"+g.l+"%)"]];case"value":default:var c=x.hsvToHsl({h:e.h,s:e.s,v:100});return[[0,"#000"],[100,"hsl("+c.h+","+c.s+"%,"+c.l+"%)"]]}},t.getSliderGradientCoords=function(t){var e="horizontal"===t.layoutDirection;return{x1:"0%",y1:e?"100%":"0%",x2:e?"0%":"100%",y2:"0%"}},t.getWheelDimensions=y,t.translateWheelAngle=M,t.getWheelHandlePosition=function(t){var e=t.color.hsv,r=y(t),n=r.cx,i=r.cy,a=t.width/2-t.padding-t.handleRadius-t.borderWidth,s=(180+M(t,e.h,!0))*(Math.PI/180),h=e.s/100*a,o="clockwise"===t.wheelDirection?-1:1;return{x:n+h*Math.cos(s)*o,y:i+h*Math.sin(s)*o}},t.getWheelValueFromInput=function(t,e,r,n){var i=y(t),a=t.width/2-t.padding-t.handleRadius-t.borderWidth;e=i.cx-(e-n.left),r=i.cy-(r-n.top);var s=M(t,Math.atan2(-r,-e)*(180/Math.PI)),h=Math.min(Math.sqrt(e*e+r*r),a);return{h:Math.round(s),s:Math.round(100/a*h)}},t.getBoxStyles=function(t){var e;return(e={})["horizontal"===t.layoutDirection?"marginLeft":"marginTop"]=t.sliderMargin,e},t.getBoxDimensions=T,t.getBoxValueFromInput=function(t,e,r,n){var i=T(t),a=i.radius,s=(r-=n.top+a)/(i.height-2*a)*100;return{s:Math.max(0,Math.min((e-=n.left+a)/(i.width-2*a)*100,100)),v:Math.max(0,Math.min(100-s,100))}},t.getBoxHandlePosition=function(t){var e=T(t),r=e.radius,n=t.color.hsv,i=e.height-2*r;return{x:r+n.s/100*(e.width-2*r),y:r+(i-n.v/100*i)}},t.getBoxGradients=function(t){return[[[0,"#fff"],[100,"hsl("+t.color.hue+",100%,50%)"]],[[0,"rgba(0,0,0,0)"],[100,"#000"]]]},t.resolveSvgUrl=function(t){var e=window.navigator.userAgent,r=/^((?!chrome|android).)*safari/i.test(e),n=/iPhone|iPod|iPad/i.test(e),i=window.location;return(r||n)&&R.length>0?i.protocol+"//"+i.host+i.pathname+i.search+t:t},t.getSvgArcPath=function(t,e,r,n,i){var a=i-n<=180?0:1;return n*=Math.PI/180,i*=Math.PI/180,"M "+(t+r*Math.cos(i))+" "+(e+r*Math.sin(i))+" A "+r+" "+r+" 0 "+a+" 0 "+(t+r*Math.cos(n))+" "+(e+r*Math.sin(n))},t.iroColorPickerOptionDefaults={width:300,height:300,handleRadius:8,handleSvg:null,handleProps:{x:0,y:0},color:"#fff",borderColor:"#fff",borderWidth:0,wheelLightness:!0,wheelAngle:0,wheelDirection:"anticlockwise",layoutDirection:"vertical",sliderSize:null,sliderMargin:12,padding:6}});
//# sourceMappingURL=iro-core.umd.js.map

@@ -21,3 +21,3 @@ import { IroColorPickerOptions } from './colorPickerOptions';

*/
export declare function translateWheelAngle(props: Partial<WheelProps>, angle: number): number;
export declare function translateWheelAngle(props: Partial<WheelProps>, angle: number, invert?: boolean): number;
/**

@@ -24,0 +24,0 @@ * @desc Get the current handle position

{
"name": "@irojs/iro-core",
"version": "0.0.4",
"version": "0.0.5",
"description": "Core functionality for iro.js",

@@ -5,0 +5,0 @@ "source": "src/index.ts",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc