UNPKG

@uiw/react-color

Version:

Color Picker component for React.

2 lines 46.8 kB
/*! For license information please see color.min.js.LICENSE.txt */ !function(e,r){"object"===typeof exports&&"object"===typeof module?module.exports=r(require("react")):"function"===typeof define&&define.amd?define(["react"],r):"object"===typeof exports?exports["@uiw/react-color"]=r(require("react")):e["@uiw/react-color"]=r(e.React)}(self,e=>(()=>{"use strict";var r={85:(e,r,o)=>{e.exports=o(335)},335:(e,r,o)=>{var t=o(442),a=Symbol.for("react.element"),l=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,n=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function d(e,r,o){var t,l={},d=null,c=null;for(t in void 0!==o&&(d=""+o),void 0!==r.key&&(d=""+r.key),void 0!==r.ref&&(c=r.ref),r)s.call(r,t)&&!i.hasOwnProperty(t)&&(l[t]=r[t]);if(e&&e.defaultProps)for(t in r=e.defaultProps)void 0===l[t]&&(l[t]=r[t]);return{$$typeof:a,type:e,key:d,ref:c,props:l,_owner:n.current}}r.jsx=d,r.jsxs=d},442:r=>{r.exports=e}},o={};function t(e){var a=o[e];if(void 0!==a)return a.exports;var l=o[e]={exports:{}};return r[e](l,l.exports,t),l.exports}t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};function l(){return l=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var t in o)({}).hasOwnProperty.call(o,t)&&(e[t]=o[t])}return e},l.apply(null,arguments)}t.r(a),t.d(a,{Alpha:()=>ce,BACKGROUND_IMG:()=>ie,Block:()=>ye,Chrome:()=>Ve,Circle:()=>$e,Colorful:()=>tr,Compact:()=>ir,EditableInput:()=>ue,EditableInputHSLA:()=>_e,EditableInputRGBA:()=>Ie,Github:()=>Re,Hue:()=>Le,Material:()=>hr,Pointer:()=>se,Saturation:()=>De,ShadeSlider:()=>yr,Sketch:()=>Br,Slider:()=>Er,Swatch:()=>fe,Wheel:()=>zr,baseNamed:()=>br,color:()=>_,colorKeywords:()=>gr,colorKeywordsBase:()=>fr,colorNameToHex:()=>xr,equalColorObjects:()=>G,equalColorString:()=>q,equalHex:()=>X,getContrastingColor:()=>W,hexToHsva:()=>j,hexToRgba:()=>R,hexToXY:()=>H,hslStringToHsla:()=>u,hslStringToHsva:()=>b,hslaStringToHsva:()=>g,hslaToHsl:()=>P,hslaToHsva:()=>f,hsvStringToHsva:()=>C,hsvaStringToHsva:()=>v,hsvaToHex:()=>T,hsvaToHexa:()=>L,hsvaToHslString:()=>d,hsvaToHsla:()=>x,hsvaToHslaString:()=>h,hsvaToHsv:()=>M,hsvaToHsvString:()=>c,hsvaToHsvaString:()=>p,hsvaToRgbString:()=>E,hsvaToRgba:()=>S,hsvaToRgbaString:()=>N,parseHue:()=>y,rgbStringToHsva:()=>F,rgbToHex:()=>B,rgbToXY:()=>O,rgbaStringToHsva:()=>w,rgbaToHex:()=>k,rgbaToHexa:()=>A,rgbaToHsva:()=>i,rgbaToRgb:()=>D,validHex:()=>Y,xyToHex:()=>I,xyToRgb:()=>z});var s=255,n=100,i=e=>{var{r:r,g:o,b:t,a:a}=e,l=Math.max(r,o,t),i=l-Math.min(r,o,t),d=i?l===r?(o-t)/i:l===o?2+(t-r)/i:4+(r-o)/i:0;return{h:60*(d<0?d+6:d),s:l?i/l*n:0,v:l/s*n,a:a}},d=e=>{var{h:r,s:o,l:t}=x(e);return"hsl("+r+", "+Math.round(o)+"%, "+Math.round(t)+"%)"},c=e=>{var{h:r,s:o,v:t}=e;return"hsv("+r+", "+o+"%, "+t+"%)"},p=e=>{var{h:r,s:o,v:t,a:a}=e;return"hsva("+r+", "+o+"%, "+t+"%, "+a+")"},h=e=>{var{h:r,s:o,l:t,a:a}=x(e);return"hsla("+r+", "+o+"%, "+t+"%, "+a+")"},u=e=>{var[r,o,t,a]=(e.match(/\d+/g)||[]).map(Number);return{h:r,s:o,l:t,a:a}},g=e=>{var r=/hsla?\(?\s*(-?\d*\.?\d+)(deg|rad|grad|turn)?[,\s]+(-?\d*\.?\d+)%?[,\s]+(-?\d*\.?\d+)%?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e);return r?f({h:y(r[1],r[2]),s:Number(r[3]),l:Number(r[4]),a:void 0===r[5]?1:Number(r[5])/(r[6]?100:1)}):{h:0,s:0,v:0,a:1}},b=g,f=e=>{var{h:r,s:o,l:t,a:a}=e;return{h:r,s:(o*=(t<50?t:n-t)/n)>0?2*o/(t+o)*n:0,v:t+o,a:a}},x=e=>{var{h:r,s:o,v:t,a:a}=e,l=(200-o)*t/n;return{h:r,s:l>0&&l<200?o*t/n/(l<=n?l:200-l)*n:0,l:l/2,a:a}},v=e=>{var r=/hsva?\(?\s*(-?\d*\.?\d+)(deg|rad|grad|turn)?[,\s]+(-?\d*\.?\d+)%?[,\s]+(-?\d*\.?\d+)%?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e);return r?{h:y(r[1],r[2]),s:Number(r[3]),v:Number(r[4]),a:void 0===r[5]?1:Number(r[5])/(r[6]?n:1)}:{h:0,s:0,v:0,a:1}},m={grad:.9,turn:360,rad:360/(2*Math.PI)},y=function(e,r){return void 0===r&&(r="deg"),Number(e)*(m[r]||1)},C=v,w=e=>{var r=/rgba?\(?\s*(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e);return r?i({r:Number(r[1])/(r[2]?n/s:1),g:Number(r[3])/(r[4]?n/s:1),b:Number(r[5])/(r[6]?n/s:1),a:void 0===r[7]?1:Number(r[7])/(r[8]?n:1)}):{h:0,s:0,v:0,a:1}},F=w,k=e=>{var{r:r,g:o,b:t}=e;return B({r:r,g:o,b:t})},B=e=>{var r,{r:o,g:t,b:a}=e;return"#"+(r=(o<<16|t<<8|a).toString(16),new Array(7-r.length).join("0")+r)},A=e=>{var{r:r,g:o,b:t,a:a}=e,l="number"===typeof a&&(255*a|256).toString(16).slice(1);return""+B({r:r,g:o,b:t})+(l||"")},j=e=>i(R(e)),R=e=>{var r=e.replace("#","");/^#?/.test(e)&&3===r.length&&(e="#"+r.charAt(0)+r.charAt(0)+r.charAt(1)+r.charAt(1)+r.charAt(2)+r.charAt(2));var o=new RegExp("[A-Za-z0-9]{2}","g"),[t,a,l=0,n]=e.match(o).map(e=>parseInt(e,16));return{r:t,g:a,b:l,a:(null!=n?n:255)/s}},S=e=>{var{h:r,s:o,v:t,a:a}=e,i=r/60,d=o/n,c=t/n,p=Math.floor(i)%6,h=i-Math.floor(i),u=s*c*(1-d),g=s*c*(1-d*h),b=s*c*(1-d*(1-h));c*=s;var f={};switch(p){case 0:f.r=c,f.g=b,f.b=u;break;case 1:f.r=g,f.g=c,f.b=u;break;case 2:f.r=u,f.g=c,f.b=b;break;case 3:f.r=u,f.g=g,f.b=c;break;case 4:f.r=b,f.g=u,f.b=c;break;case 5:f.r=c,f.g=u,f.b=g}return f.r=Math.round(f.r),f.g=Math.round(f.g),f.b=Math.round(f.b),l({},f,{a:a})},E=e=>{var{r:r,g:o,b:t}=S(e);return"rgb("+r+", "+o+", "+t+")"},N=e=>{var{r:r,g:o,b:t,a:a}=S(e);return"rgba("+r+", "+o+", "+t+", "+a+")"},D=e=>{var{r:r,g:o,b:t}=e;return{r:r,g:o,b:t}},P=e=>{var{h:r,s:o,l:t}=e;return{h:r,s:o,l:t}},T=e=>B(S(e)),L=e=>A(S(e)),M=e=>{var{h:r,s:o,v:t}=e;return{h:r,s:o,v:t}},H=e=>O(D(R(e))),I=e=>B(l({},z(e))),z=e=>{var{x:r,y:o,bri:t=255}=e,a=3.2406255*r+-1.537208*o+-.4986286*t,l=-.9689307*r+1.8757561*o+.0415175*t,s=.0557101*r+-.2040211*o+1.0569959*t,n=function(e){return e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055};return{r:Math.round(255*n(a)),g:Math.round(255*n(l)),b:Math.round(255*n(s))}},O=e=>{var{r:r,g:o,b:t}=e,a=function(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)},l=a(r/255),s=a(o/255),n=a(t/255),i={};return i.x=.4124*l+.3576*s+.1805*n,i.y=.2126*l+.7152*s+.0722*n,i.bri=.0193*l+.1192*s+.9505*n,i},_=e=>{var r,o,t,a,l,s,n,i,d;return"string"===typeof e&&Y(e)?(s=j(e),i=e):"string"!==typeof e&&(s=e),s&&(t=M(s),l=x(s),a=S(s),d=A(a),i=T(s),o=P(l),r=D(a),n=O(r)),{rgb:r,hsl:o,hsv:t,rgba:a,hsla:l,hsva:s,hex:i,hexa:d,xy:n}},W=e=>{if(!e)return"#ffffff";var r=_(e);return(299*r.rgb.r+587*r.rgb.g+114*r.rgb.b)/1e3>=128?"#000000":"#ffffff"},G=(e,r)=>{if(e===r)return!0;for(var o in e)if(e[o]!==r[o])return!1;return!0},q=(e,r)=>e.replace(/\s/g,"")===r.replace(/\s/g,""),X=(e,r)=>e.toLowerCase()===r.toLowerCase()||G(R(e),R(r)),Y=e=>/^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(e);function U(e,r){if(null==e)return{};var o={};for(var t in e)if({}.hasOwnProperty.call(e,t)){if(-1!==r.indexOf(t))continue;o[t]=e[t]}return o}var V=t(442),K=t.n(V);function Q(e){var r=(0,V.useRef)(e);return(0,V.useEffect)(()=>{r.current=e}),(0,V.useCallback)((e,o)=>r.current&&r.current(e,o),[])}var Z=e=>"touches"in e,$=e=>{!Z(e)&&e.preventDefault&&e.preventDefault()},J=function(e,r,o){return void 0===r&&(r=0),void 0===o&&(o=1),e>o?o:e<r?r:e},ee=(e,r)=>{var o=e.getBoundingClientRect(),t=Z(r)?r.touches[0]:r;return{left:J((t.pageX-(o.left+window.pageXOffset))/o.width),top:J((t.pageY-(o.top+window.pageYOffset))/o.height),width:o.width,height:o.height,x:t.pageX-(o.left+window.pageXOffset),y:t.pageY-(o.top+window.pageYOffset)}},re=t(85),oe=["prefixCls","className","onMove","onDown"],te=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-interactive",className:t,onMove:a,onDown:s}=e,n=U(e,oe),i=(0,V.useRef)(null),d=(0,V.useRef)(!1),[c,p]=(0,V.useState)(!1),h=Q(a),u=Q(s),g=(0,V.useCallback)(e=>{($(e),i.current)&&((Z(e)?e.touches.length>0:e.buttons>0)?null==h||h(ee(i.current,e),e):p(!1))},[h]),b=(0,V.useCallback)(()=>p(!1),[]),f=(0,V.useCallback)(e=>{e?(window.addEventListener(d.current?"touchmove":"mousemove",g),window.addEventListener(d.current?"touchend":"mouseup",b)):(window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",b),window.removeEventListener("touchmove",g),window.removeEventListener("touchend",b))},[g,b]);(0,V.useEffect)(()=>(f(c),()=>{f(!1)}),[c,g,b,f]);var x=(0,V.useCallback)(e=>{$(e.nativeEvent),(e=>!(d.current&&!Z(e))&&(d.current=Z(e),!0))(e.nativeEvent)&&i.current&&(null==u||u(ee(i.current,e.nativeEvent),e.nativeEvent),p(!0))},[u]);return(0,re.jsx)("div",l({},n,{className:[o,t||""].filter(Boolean).join(" "),style:l({},n.style,{touchAction:"none"}),ref:i,tabIndex:0,onMouseDown:x,onTouchStart:x}))});te.displayName="Interactive";const ae=te;var le=["className","prefixCls","left","top","style","fillProps"],se=e=>{var{className:r,prefixCls:o,left:t,top:a,style:s,fillProps:n}=e,i=U(e,le),d=l({},s,{position:"absolute",left:t,top:a}),c=l({width:18,height:18,boxShadow:"var(--alpha-pointer-box-shadow)",borderRadius:"50%",backgroundColor:"var(--alpha-pointer-background-color)"},null==n?void 0:n.style,{transform:t?"translate(-9px, -1px)":"translate(-1px, -9px)"});return(0,re.jsx)("div",l({className:o+"-pointer "+(r||""),style:d},i,{children:(0,re.jsx)("div",l({className:o+"-fill"},n,{style:c}))}))},ne=["prefixCls","className","hsva","background","bgProps","innerProps","pointerProps","radius","width","height","direction","style","onChange","pointer"],ie="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==",de=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-alpha",className:t,hsva:a,background:s,bgProps:n={},innerProps:i={},pointerProps:d={},radius:c=0,width:p,height:u=16,direction:g="horizontal",style:b,onChange:f,pointer:x}=e,v=U(e,ne),m=e=>{f&&f(l({},a,{a:"horizontal"===g?e.left:e.top}),e)},y=h(Object.assign({},a,{a:1})),C="linear-gradient(to "+("horizontal"===g?"right":"bottom")+", rgba(244, 67, 54, 0) 0%, "+y+" 100%)",w={};"horizontal"===g?w.left=100*a.a+"%":w.top=100*a.a+"%";var F=l({"--alpha-background-color":"#fff","--alpha-pointer-background-color":"rgb(248, 248, 248)","--alpha-pointer-box-shadow":"rgb(0 0 0 / 37%) 0px 1px 4px 0px",borderRadius:c,background:"url("+ie+") left center",backgroundColor:"var(--alpha-background-color)"},{width:p,height:u},b,{position:"relative"}),k=x&&"function"===typeof x?x(l({prefixCls:o},d,w)):(0,re.jsx)(se,l({},d,{prefixCls:o},w));return(0,re.jsxs)("div",l({},v,{className:[o,o+"-"+g,t||""].filter(Boolean).join(" "),style:F,ref:r,children:[(0,re.jsx)("div",l({},n,{style:l({inset:0,position:"absolute",background:s||C,borderRadius:c},n.style)})),(0,re.jsx)(ae,l({},i,{style:l({},i.style,{inset:0,zIndex:1,position:"absolute"}),onMove:m,onDown:m,children:k}))]}))});de.displayName="Alpha";const ce=de;var pe=["prefixCls","placement","label","value","className","style","labelStyle","inputStyle","onChange","onBlur","renderInput"],he=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-editable-input",placement:t="bottom",label:a,value:s,className:n,style:i,labelStyle:d,inputStyle:c,onChange:p,onBlur:h,renderInput:u}=e,g=U(e,pe),[b,f]=(0,V.useState)(s),x=(0,V.useRef)(!1);(0,V.useEffect)(()=>{e.value!==b&&(x.current||f(e.value))},[e.value]);var v={};"bottom"===t&&(v.flexDirection="column"),"top"===t&&(v.flexDirection="column-reverse"),"left"===t&&(v.flexDirection="row-reverse");var m=l({"--editable-input-label-color":"rgb(153, 153, 153)","--editable-input-box-shadow":"rgb(204 204 204) 0px 0px 0px 1px inset","--editable-input-color":"#666",position:"relative",alignItems:"center",display:"flex",fontSize:11},v,i),y=l({width:"100%",paddingTop:2,paddingBottom:2,paddingLeft:3,paddingRight:3,fontSize:11,background:"transparent",boxSizing:"border-box",border:"none",color:"var(--editable-input-color)",boxShadow:"var(--editable-input-box-shadow)"},c),C=l({value:b,onChange:function(e,r){var o=(r||e.target.value).trim().replace(/^#/,"");/^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(o)&&p&&p(e,o);var t=(e=>Number(String(e).replace(/%/g,"")))(o);isNaN(t)||p&&p(e,t),f(o)},onBlur:function(r){x.current=!1,f(e.value),h&&h(r)},autoComplete:"off",onFocus:()=>x.current=!0},g,{style:y});return(0,re.jsxs)("div",{className:[o,n||""].filter(Boolean).join(" "),style:m,children:[u?u(C,r):(0,re.jsx)("input",l({ref:r},C)),a&&(0,re.jsx)("span",{style:l({color:"var(--editable-input-label-color)",textTransform:"capitalize"},d),children:a})]})});he.displayName="EditableInput";const ue=he;var ge=["prefixCls","className","color","colors","style","rectProps","onChange","addonAfter","addonBefore","rectRender"],be=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-swatch",className:t,color:a,colors:s=[],style:n,rectProps:i={},onChange:d,addonAfter:c,addonBefore:p,rectRender:h}=e,u=U(e,ge),g=l({"--swatch-background-color":"rgb(144, 19, 254)",background:"var(--swatch-background-color)",height:15,width:15,marginRight:5,marginBottom:5,cursor:"pointer",position:"relative",outline:"none",borderRadius:2},i.style),b=(e,r)=>{d&&d(j(e),_(j(e)),r)};return(0,re.jsxs)("div",l({ref:r},u,{className:[o,t||""].filter(Boolean).join(" "),style:l({display:"flex",flexWrap:"wrap",position:"relative"},n),children:[p&&K().isValidElement(p)&&p,s&&Array.isArray(s)&&s.map((e,r)=>{var o="",t="";"string"===typeof e&&(o=e,t=e),"object"===typeof e&&e.color&&(o=e.title||e.color,t=e.color);var s=a&&a.toLocaleLowerCase()===t.toLocaleLowerCase(),n=h&&h({title:o,color:t,checked:!!s,style:l({},g,{background:t}),onClick:e=>b(t,e)});if(n)return(0,re.jsx)(V.Fragment,{children:n},r);var d=i.children&&K().isValidElement(i.children)?K().cloneElement(i.children,{color:t,checked:s}):null;return(0,re.jsx)("div",l({tabIndex:0,title:o,onClick:e=>b(t,e)},i,{children:d,style:l({},g,{background:t})}),r)}),c&&K().isValidElement(c)&&c]}))});be.displayName="Swatch";const fe=be;var xe=["prefixCls","className","style","color","colors","showTriangle","onChange"],ve=["#D9E3F0","#F47373","#697689","#37D67A","#2CCCE4","#555555","#dce775","#ff8a65","#ba68c8"],me=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-block",className:t,style:a,color:s,colors:n=ve,showTriangle:i=!0,onChange:d}=e,c=U(e,xe),p="string"===typeof s&&Y(s)?j(s):s,h=s?T(p):"",u=(e,r)=>{"string"===typeof e&&Y(e)&&/(3|6)/.test(String(e.replace(/^#/,"").length))&&d&&d(_(j(e)))},g=l({"--block-background-color":"rgb(255, 255, 255)","--block-box-shadow":"rgb(0 0 0 / 10%) 0 1px",width:170,borderRadius:6,background:"var(--block-background-color)",boxShadow:"var(--block-box-shadow)",position:"relative"},a);return(0,re.jsxs)("div",l({ref:r,className:[o,t].filter(Boolean).join(" "),style:g},c,{children:[i&&(0,re.jsx)("div",{style:{width:0,height:0,borderStyle:"solid",borderWidth:"0 10px 10px",borderColor:"transparent transparent "+h,position:"absolute",top:-10,left:"50%",marginLeft:-10}}),(0,re.jsx)("div",{title:h,style:{backgroundColor:""+h,color:W(h),height:110,fontSize:18,borderRadius:"6px 6px 0 0",display:"flex",alignItems:"center",justifyContent:"center"},children:h.toLocaleUpperCase()}),(0,re.jsx)(fe,{colors:n,color:h,style:{paddingLeft:10,paddingTop:10},rectProps:{style:{marginRight:10,marginBottom:10,borderRadius:4,height:22,width:22}},onChange:e=>{d&&d(_(e))}}),(0,re.jsx)(ue,{value:h.toLocaleUpperCase(),onChange:(e,r)=>u(r),onBlur:e=>{var r=e.target.value;e.target.value=r.slice(0,6),u(r.slice(0,6))},inputStyle:{height:22,outline:0,borderRadius:3,padding:"0 7px"},style:{padding:10,paddingTop:0,borderRadius:"0 0 6px 6px"}})]}))});me.displayName="Block";const ye=me;function Ce(e){if(null==e)throw new TypeError("Cannot destructure "+e)}var we={marginRight:0,marginBottom:0,borderRadius:0,boxSizing:"border-box",height:25,width:25};function Fe(e){var{style:r,title:o,checked:t,color:a,onClick:s,rectProps:n}=e,i=(0,V.useRef)(null),d=(0,V.useCallback)(()=>{i.current.style.zIndex="2",i.current.style.outline="#fff solid 2px",i.current.style.boxShadow="rgb(0 0 0 / 25%) 0 0 5px 2px"},[]),c=(0,V.useCallback)(()=>{t||(i.current.style.zIndex="0",i.current.style.outline="initial",i.current.style.boxShadow="initial")},[t]),p=t?{zIndex:1,outline:"#fff solid 2px",boxShadow:"rgb(0 0 0 / 25%) 0 0 5px 2px"}:{zIndex:0};return(0,re.jsx)("div",l({ref:i,title:o},n,{onClick:s,onMouseEnter:d,onMouseLeave:c,style:l({},r,{marginRight:0,marginBottom:0,borderRadius:0,boxSizing:"border-box",height:25,width:25},we,p,null==n?void 0:n.style)}))}var ke=["prefixCls","placement","className","style","color","colors","showTriangle","rectProps","onChange","rectRender"],Be=["#B80000","#DB3E00","#FCCB00","#008B02","#006B76","#1273DE","#004DCF","#5300EB","#EB9694","#FAD0C3","#FEF3BD","#C1E1C5","#BEDADC","#C4DEF6","#BED3F3","#D4C4FB"],Ae=function(e){return e.Left="L",e.LeftTop="LT",e.LeftBottom="LB",e.Right="R",e.RightTop="RT",e.RightBottom="RB",e.Top="T",e.TopRight="TR",e.TopLeft="TL",e.Bottom="B",e.BottomLeft="BL",e.BottomRight="BR",e}({}),je=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-github",placement:t=Ae.TopRight,className:a,style:s,color:n,colors:i=Be,showTriangle:d=!0,rectProps:c={},onChange:p,rectRender:h}=e,u=U(e,ke),g="string"===typeof n&&Y(n)?j(n):n,b=n?T(g):"",f=l({"--github-border":"1px solid rgba(0, 0, 0, 0.2)","--github-background-color":"#fff","--github-box-shadow":"rgb(0 0 0 / 15%) 0px 3px 12px","--github-arrow-border-color":"rgba(0, 0, 0, 0.15)",width:200,borderRadius:4,background:"var(--github-background-color)",boxShadow:"var(--github-box-shadow)",border:"var(--github-border)",position:"relative",padding:5},s),x={borderStyle:"solid",position:"absolute"},v=l({},x),m=l({},x);/^T/.test(t)&&(v.borderWidth="0 8px 8px",v.borderColor="transparent transparent var(--github-arrow-border-color)",m.borderWidth="0 7px 7px",m.borderColor="transparent transparent var(--github-background-color)"),t===Ae.TopRight&&(v.top=-8,m.top=-7),t===Ae.Top&&(v.top=-8,m.top=-7),t===Ae.TopLeft&&(v.top=-8,m.top=-7),/^B/.test(t)&&(v.borderWidth="8px 8px 0",v.borderColor="var(--github-arrow-border-color) transparent transparent",m.borderWidth="7px 7px 0",m.borderColor="var(--github-background-color) transparent transparent",t===Ae.BottomRight&&(v.top="100%",m.top="100%"),t===Ae.Bottom&&(v.top="100%",m.top="100%"),t===Ae.BottomLeft&&(v.top="100%",m.top="100%")),/^(B|T)/.test(t)&&(t!==Ae.Top&&t!==Ae.Bottom||(v.left="50%",v.marginLeft=-8,m.left="50%",m.marginLeft=-7),t!==Ae.TopRight&&t!==Ae.BottomRight||(v.right=10,m.right=11),t!==Ae.TopLeft&&t!==Ae.BottomLeft||(v.left=7,m.left=8)),/^L/.test(t)&&(v.borderWidth="8px 8px 8px 0",v.borderColor="transparent var(--github-arrow-border-color) transparent transparent",m.borderWidth="7px 7px 7px 0",m.borderColor="transparent var(--github-background-color) transparent transparent",v.left=-8,m.left=-7),/^R/.test(t)&&(v.borderWidth="8px 0 8px 8px",v.borderColor="transparent transparent transparent var(--github-arrow-border-color)",m.borderWidth="7px 0 7px 7px",m.borderColor="transparent transparent transparent var(--github-background-color)",v.right=-8,m.right=-7),/^(L|R)/.test(t)&&(t!==Ae.RightTop&&t!==Ae.LeftTop||(v.top=5,m.top=6),t!==Ae.Left&&t!==Ae.Right||(v.top="50%",m.top="50%",v.marginTop=-8,m.marginTop=-7),t!==Ae.LeftBottom&&t!==Ae.RightBottom||(v.top="100%",m.top="100%",v.marginTop=-21,m.marginTop=-20));return(0,re.jsx)(fe,l({ref:r,className:[o,a].filter(Boolean).join(" "),colors:i,color:b,rectRender:e=>{var r=l({},(Ce(e),e)),o=h&&h(l({},r));return o||(0,re.jsx)(Fe,l({},r,{rectProps:c}))}},u,{onChange:e=>p&&p(_(e)),style:f,rectProps:{style:{marginRight:0,marginBottom:0,borderRadius:0,height:25,width:25}},addonBefore:(0,re.jsx)(V.Fragment,{children:d&&(0,re.jsxs)(V.Fragment,{children:[(0,re.jsx)("div",{style:v}),(0,re.jsx)("div",{style:m})]})})}))});je.displayName="Github";const Re=je;var Se=e=>{var{className:r,color:o,left:t,top:a,prefixCls:l}=e,s={position:"absolute",top:a,left:t},n={"--saturation-pointer-box-shadow":"rgb(255 255 255) 0px 0px 0px 1.5px, rgb(0 0 0 / 30%) 0px 0px 1px 1px inset, rgb(0 0 0 / 40%) 0px 0px 1px 2px",width:6,height:6,transform:"translate(-3px, -3px)",boxShadow:"var(--saturation-pointer-box-shadow)",borderRadius:"50%",backgroundColor:o};return(0,V.useMemo)(()=>(0,re.jsx)("div",{className:l+"-pointer "+(r||""),style:s,children:(0,re.jsx)("div",{className:l+"-fill",style:n})}),[a,t,o,r,l])},Ee=["prefixCls","radius","pointer","className","hue","style","hsva","onChange"],Ne=K().forwardRef((e,r)=>{var o,{prefixCls:t="w-color-saturation",radius:a=0,pointer:s,className:n,hue:i=0,style:d,hsva:c,onChange:p}=e,u=U(e,Ee),g=l({width:200,height:200,borderRadius:a},d,{position:"relative"}),b=(e,r)=>{p&&c&&p({h:c.h,s:100*e.left,v:100*(1-e.top),a:c.a})},f=(0,V.useMemo)(()=>{if(!c)return null;var e={top:100-c.v+"%",left:c.s+"%",color:h(c)};return s&&"function"===typeof s?s(l({prefixCls:t},e)):(0,re.jsx)(Se,l({prefixCls:t},e))},[c,s,t]);return(0,re.jsx)(ae,l({className:[t,n||""].filter(Boolean).join(" ")},u,{style:l({position:"absolute",inset:0,cursor:"crosshair",backgroundImage:"linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, hsl("+(null!=(o=null==c?void 0:c.h)?o:i)+", 100%, 50%))"},g),ref:r,onMove:b,onDown:b,children:f}))});Ne.displayName="Saturation";const De=Ne;var Pe=["prefixCls","className","hue","onChange","direction"],Te=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-hue",className:t,hue:a=0,onChange:s,direction:n="horizontal"}=e,i=U(e,Pe);return(0,re.jsx)(ce,l({ref:r,className:o+" "+(t||"")},i,{direction:n,background:"linear-gradient(to "+("horizontal"===n?"right":"bottom")+", rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)",hsva:{h:a,s:100,v:100,a:a/360},onChange:(e,r)=>{s&&s({h:"horizontal"===n?360*r.left:360*r.top})}}))});Te.displayName="Hue";const Le=Te;var Me=["prefixCls","hsva","placement","rProps","gProps","bProps","aProps","className","style","onChange"],He=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-editable-input-rgba",hsva:t,placement:a="bottom",rProps:s={},gProps:n={},bProps:d={},aProps:c={},className:p,style:h,onChange:u}=e,g=U(e,Me),b=t?S(t):{};function f(e){var r=Number(e.target.value);r&&r>255&&(e.target.value="255"),r&&r<0&&(e.target.value="0")}var x=(e,r,o)=>{"number"===typeof e&&("a"===r&&(e<0&&(e=0),e>100&&(e=100),u&&u(_(i(l({},b,{a:e/100}))))),e>255&&(e=255,o.target.value="255"),e<0&&(e=0,o.target.value="0"),"r"===r&&u&&u(_(i(l({},b,{r:e})))),"g"===r&&u&&u(_(i(l({},b,{g:e})))),"b"===r&&u&&u(_(i(l({},b,{b:e})))))};return(0,re.jsxs)("div",l({ref:r,className:[o,p||""].filter(Boolean).join(" ")},g,{style:l({fontSize:11,display:"flex"},h),children:[(0,re.jsx)(ue,l({label:"R",value:b.r||0,onBlur:f,placement:a,onChange:(e,r)=>x(r,"r",e)},s,{style:l({},s.style)})),(0,re.jsx)(ue,l({label:"G",value:b.g||0,onBlur:f,placement:a,onChange:(e,r)=>x(r,"g",e)},n,{style:l({marginLeft:5},s.style)})),(0,re.jsx)(ue,l({label:"B",value:b.b||0,onBlur:f,placement:a,onChange:(e,r)=>x(r,"b",e)},d,{style:l({marginLeft:5},d.style)})),c&&(0,re.jsx)(ue,l({label:"A",value:b.a?parseInt(String(100*b.a),10):0,onBlur:f,placement:a,onChange:(e,r)=>x(r,"a",e)},c,{style:l({marginLeft:5},c.style)}))]}))});He.displayName="EditableInputRGBA";const Ie=He;var ze=["prefixCls","hsva","hProps","sProps","lProps","aProps","className","onChange"],Oe=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-editable-input-hsla",hsva:t,hProps:a={},sProps:s={},lProps:n={},aProps:i={},className:d,onChange:c}=e,p=U(e,ze),h=t?x(t):{h:0,s:0,l:0,a:0},u=(e,r,o)=>{"number"===typeof e&&("h"===r&&(e<0&&(e=0),e>360&&(e=360),c&&c(_(f(l({},h,{h:e}))))),"s"===r&&(e<0&&(e=0),e>100&&(e=100),c&&c(_(f(l({},h,{s:e}))))),"l"===r&&(e<0&&(e=0),e>100&&(e=100),c&&c(_(f(l({},h,{l:e}))))),"a"===r&&(e<0&&(e=0),e>1&&(e=1),c&&c(_(f(l({},h,{a:e}))))))},g=0!=i&&l({label:"A",value:Math.round(100*h.a)/100},i,{onChange:(e,r)=>u(r,"a")});return(0,re.jsx)(Ie,l({ref:r,hsva:t,rProps:l({label:"H",value:Math.round(h.h)},a,{onChange:(e,r)=>u(r,"h")}),gProps:l({label:"S",value:Math.round(h.s)+"%"},s,{onChange:(e,r)=>u(r,"s")}),bProps:l({label:"L",value:Math.round(h.l)+"%"},n,{onChange:(e,r)=>u(r,"l")}),aProps:g,className:[o,d||""].filter(Boolean).join(" ")},p))});Oe.displayName="EditableInputHSLA";const _e=Oe;var We=["style"];function Ge(e){var{style:r}=e,o=U(e,We),t=(0,V.useRef)(null),a=(0,V.useCallback)(()=>{t.current.style.backgroundColor="var(--chrome-arrow-background-color)"},[]),s=(0,V.useCallback)(()=>{t.current.style.backgroundColor="transparent"},[]);return(0,re.jsx)("div",l({ref:t,style:l({marginLeft:5,cursor:"pointer",transition:"background-color .3s",borderRadius:2},r)},o,{onMouseEnter:a,onMouseLeave:s,children:(0,re.jsx)("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24",style:{display:"block"},children:(0,re.jsx)("path",{d:"M373.888 576h276.224c9.322667 0 14.293333 11.178667 9.173333 18.773333l-1.258666 1.557334-138.112 146.858666a10.709333 10.709333 0 0 1-14.293334 1.365334l-1.536-1.365334-138.112-146.858666c-6.592-6.997333-2.666667-18.645333 5.973334-20.16l1.941333-0.170667h276.224-276.224z m146.026667-295.189333l138.112 146.858666c7.04 7.509333 2.069333 20.330667-7.914667 20.330667H373.888c-9.984 0-14.976-12.821333-7.914667-20.330667l138.112-146.858666a10.730667 10.730667 0 0 1 15.829334 0z",fill:"var(--chrome-arrow-fill)"})})}))}function qe(e){return(0,re.jsx)("svg",{viewBox:"0 0 512 512",height:"1em",width:"1em",onClick:()=>{"EyeDropper"in window&&(new window.EyeDropper).open().then(r=>{null==e.onPickColor||e.onPickColor(r.sRGBHex)}).catch(e=>{e.name})},children:(0,re.jsx)("path",{fill:"currentColor",d:"M482.8 29.23c38.9 38.98 38.9 102.17 0 141.17L381.2 271.9l9.4 9.5c12.5 12.5 12.5 32.7 0 45.2s-32.7 12.5-45.2 0l-160-160c-12.5-12.5-12.5-32.7 0-45.2s32.7-12.5 45.2 0l9.5 9.4L341.6 29.23c39-38.974 102.2-38.974 141.2 0zM55.43 323.3 176.1 202.6l45.3 45.3-120.7 120.7c-3.01 3-4.7 7-4.7 11.3V416h36.1c4.3 0 8.3-1.7 11.3-4.7l120.7-120.7 45.3 45.3-120.7 120.7c-15 15-35.4 23.4-56.6 23.4H89.69l-39.94 26.6c-12.69 8.5-29.59 6.8-40.377-4-10.786-10.8-12.459-27.7-3.998-40.4L32 422.3v-42.4c0-21.2 8.43-41.6 23.43-56.6z"})})}var Xe=["prefixCls","className","style","color","showEditableInput","showEyeDropper","showColorPreview","showHue","showAlpha","inputType","rectProps","onChange"],Ye=function(e){return e.HEXA="hexa",e.RGBA="rgba",e.HSLA="hsla",e}({}),Ue=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-chrome",className:t,style:a,color:s,showEditableInput:n=!0,showEyeDropper:i=!0,showColorPreview:d=!0,showHue:c=!0,showAlpha:p=!0,inputType:h=Ye.RGBA,rectProps:u={},onChange:g}=e,b=U(e,Xe),f="string"===typeof s&&Y(s)?j(s):s||{h:0,s:0,l:0,a:0},x=e=>g&&g(_(e)),[v,m]=(0,V.useState)(h),y={paddingTop:6},C={textAlign:"center",paddingTop:4,paddingBottom:4},w=l({"--chrome-arrow-fill":"#333","--chrome-arrow-background-color":"#e8e8e8",borderRadius:0,flexDirection:"column",width:230,padding:0},a),F={"--chrome-alpha-box-shadow":"rgb(0 0 0 / 25%) 0px 0px 1px inset",borderRadius:"50%",background:N(f),boxShadow:"var(--chrome-alpha-box-shadow)"},k={height:14,width:14},B={style:l({},k),fillProps:{style:k}};return(0,re.jsx)(Re,l({ref:r,color:f,style:w,colors:void 0,className:[o,t].filter(Boolean).join(" "),placement:Ae.TopLeft},b,{addonAfter:(0,re.jsxs)(V.Fragment,{children:[(0,re.jsx)(De,{hsva:f,style:{width:"100%",height:130},onChange:e=>{x(l({},f,e,{a:f.a}))}}),(0,re.jsxs)("div",{style:{padding:15,display:"flex",alignItems:"center",gap:10},children:["EyeDropper"in window&&i&&(0,re.jsx)(qe,{onPickColor:e=>{var r=j(e);x(l({},r))}}),d&&(0,re.jsx)(ce,{width:28,height:28,hsva:f,radius:2,style:{borderRadius:"50%"},bgProps:{style:{background:"transparent"}},innerProps:{style:F},pointer:()=>(0,re.jsx)(V.Fragment,{})}),(0,re.jsxs)("div",{style:{flex:1},children:[1==c&&(0,re.jsx)(Le,{hue:f.h,style:{width:"100%",height:12,borderRadius:2},pointerProps:B,bgProps:{style:{borderRadius:2}},onChange:e=>{x(l({},f,e))}}),1==p&&(0,re.jsx)(ce,{hsva:f,style:{marginTop:6,height:12,borderRadius:2},pointerProps:B,bgProps:{style:{borderRadius:2}},onChange:e=>{x(l({},f,e))}})]})]}),n&&(0,re.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",padding:"0 15px 15px 15px",userSelect:"none"},children:[(0,re.jsxs)("div",{style:{flex:1},children:[v==Ye.RGBA&&(0,re.jsx)(Ie,{hsva:f,rProps:{labelStyle:y,inputStyle:C},gProps:{labelStyle:y,inputStyle:C},bProps:{labelStyle:y,inputStyle:C},aProps:0!=p&&{labelStyle:y,inputStyle:C},onChange:e=>x(e.hsva)}),v===Ye.HEXA&&(0,re.jsx)(ue,{label:"HEX",labelStyle:y,inputStyle:C,value:f.a>0&&f.a<1?L(f).toLocaleUpperCase():T(f).toLocaleUpperCase(),onChange:(e,r)=>{"string"===typeof r&&x(j(/^#/.test(r)?r:"#"+r))}}),v===Ye.HSLA&&(0,re.jsx)(_e,{hsva:f,hProps:{labelStyle:y,inputStyle:C},sProps:{labelStyle:y,inputStyle:C},lProps:{labelStyle:y,inputStyle:C},aProps:0!=p&&{labelStyle:y,inputStyle:C},onChange:e=>x(e.hsva)})]}),(0,re.jsx)(Ge,{onClick:()=>{v===Ye.RGBA&&m(Ye.HSLA),v===Ye.HSLA&&m(Ye.HEXA),v===Ye.HEXA&&m(Ye.RGBA)}})]})]}),rectRender:()=>(0,re.jsx)(V.Fragment,{})}))});Ue.displayName="Chrome";const Ve=Ue;function Ke(e){var{style:r,className:o,title:t,checked:a,color:s,onClick:n,rectProps:i}=e,d=(0,V.useRef)(null),c=(0,V.useCallback)(()=>{d.current.style.transform="scale(1.2)"},[]),p=(0,V.useCallback)(()=>{d.current.style.transform="scale(1)"},[]),h=l({"--circle-point-background-color":"#fff",height:a?"100%":0,width:a?"100%":0,borderRadius:"50%",backgroundColor:"var(--circle-point-background-color)",boxSizing:"border-box",transition:"height 100ms ease 0s, width 100ms ease 0s"},i.style);return(0,re.jsx)("div",{ref:d,onClick:n,onMouseEnter:c,onMouseLeave:p,title:t,className:o,style:l({padding:3,marginRight:12,marginBottom:12,display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:"50%",boxSizing:"border-box",transform:"scale(1)",transition:"transform 100ms ease 0s, box-shadow 100ms ease 0s"},r,{boxShadow:s+" 0px 0px "+(a?5:0)+"px"}),children:(0,re.jsx)("div",l({},i,{style:h}))})}var Qe=["prefixCls","className","color","colors","rectProps","pointProps","onChange"],Ze=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-circle",className:t,color:a,colors:s=[],rectProps:n={},pointProps:i={},onChange:d}=e,c=U(e,Qe),p="string"===typeof a&&Y(a)?j(a):a||{},h=a?T(p):"",u=[o,t].filter(Boolean).join(" "),g=[o+"-point",null==i?void 0:i.className].filter(Boolean).join(" ");return(0,re.jsx)(fe,l({ref:r,colors:s,color:h},c,{className:u,rectRender:e=>{var r=l({},(Ce(e),e));return(0,re.jsx)(Ke,l({},r,i,{style:l({},r.style,i.style),className:g,rectProps:n}))},onChange:e=>{d&&d(_(e))}}))});Ze.displayName="Circle";const $e=Ze;var Je=["style","color"],er=["prefixCls","className","onChange","color","style","disableAlpha"],rr=e=>{var{style:r,color:o}=e,t=U(e,Je),a=l({"--colorful-pointer-background-color":"#fff","--colorful-pointer-border":"2px solid #fff",height:28,width:28,position:"absolute",transform:"translate(-16px, -16px)",boxShadow:"0 2px 4px rgb(0 0 0 / 20%)",borderRadius:"50%",background:"url("+ie+")",backgroundColor:"var(--colorful-pointer-background-color)",border:"var(--colorful-pointer-border)",zIndex:1},r);return(0,re.jsx)("div",l({},t,{style:a,children:(0,re.jsx)("div",{style:{backgroundColor:o,borderRadius:"50%",height:"100%",width:"100%"}})}))},or=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-colorful",className:t,onChange:a,color:s,style:n,disableAlpha:i}=e,d=U(e,er),c="string"===typeof s&&Y(s)?j(s):s||{},p=e=>a&&a(_(e));return(0,re.jsxs)("div",l({ref:r,style:l({width:200,position:"relative"},n)},d,{className:o+" "+(t||""),children:[(0,re.jsx)(De,{hsva:c,className:o,radius:"8px 8px 0 0",style:{width:"auto",height:150,minWidth:120,borderBottom:"12px solid #000"},pointer:e=>{var{left:r,top:o,color:t}=e;return(0,re.jsx)(rr,{style:{left:r,top:o},color:T(c)})},onChange:e=>p(l({},c,e))}),(0,re.jsx)(Le,{hue:c.h,height:24,radius:i?"0 0 8px 8px":0,className:o,onChange:e=>p(l({},c,e)),pointer:e=>{var{left:r}=e;return(0,re.jsx)(rr,{style:{left:r,transform:"translate(-16px, -5px)"},color:"hsl("+(c.h||0)+"deg 100% 50%)"})}}),!i&&(0,re.jsx)(ce,{hsva:c,height:24,className:o,radius:"0 0 8px 8px",pointer:e=>{var{left:r}=e;return(0,re.jsx)(rr,{style:{left:r,transform:"translate(-16px, -5px)"},color:N(c)})},onChange:e=>p(l({},c,e))})]}))});or.displayName="Colorful";const tr=or;var ar=["prefixCls","className","style","onChange","color","colors","rectProps","rectRender"],lr=["#4D4D4D","#999999","#FFFFFF","#F44E3B","#FE9200","#FCDC00","#DBDF00","#A4DD00","#68CCCA","#73D8FF","#AEA1FF","#FDA1FF","#333333","#808080","#cccccc","#D33115","#E27300","#FCC400","#B0BC00","#68BC00","#16A5A5","#009CE0","#7B64FF","#FA28FF","#000000","#666666","#B3B3B3","#9F0500","#C45100","#FB9E00","#808900","#194D33","#0C797D","#0062B1","#653294","#AB149E"];function sr(e){return e.checked?(0,re.jsx)("div",{style:{height:5,width:5,borderRadius:"50%",backgroundColor:W(e.color)}}):null}var nr=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-compact",className:t,style:a,onChange:s,color:n,colors:i=lr,rectProps:d,rectRender:c}=e,p=U(e,ar),h="string"===typeof n&&Y(n)?j(n):n,u=n?T(h).replace(/^#/,""):"",g=(0,V.useCallback)(e=>s&&s(_(e)),[]),b={style:{alignItems:"baseline"},inputStyle:{boxShadow:"none",backgroundColor:"transparent",outline:0}},f=l({"--compact-background-color":"#f6f6f6",background:"var(--compact-background-color)",borderRadius:3,display:"flex",width:240,flexWrap:"wrap",paddingTop:5,paddingLeft:5},a);return(0,re.jsxs)("div",l({ref:r,style:f,className:[o,t||""].filter(Boolean).join(" ")},p,{children:[(0,re.jsx)(fe,{colors:i,color:n?T(h):void 0,rectRender:c,rectProps:l({children:(0,re.jsx)(sr,{})},d,{style:l({display:"flex",alignItems:"center",justifyContent:"center"},null==d?void 0:d.style)}),onChange:e=>g(e)}),(0,re.jsxs)("div",{style:{display:"flex",margin:"0 4px 3px 0"},children:[(0,re.jsx)(ue,{onChange:(e,r)=>{var o;"string"===typeof(o=r)&&Y(o)&&/(3|6)/.test(String(o.length))&&g(j(o))},labelStyle:{paddingRight:5,marginTop:-1},value:u.toLocaleUpperCase(),label:(0,re.jsx)("div",{style:{width:8,height:8,backgroundColor:"#"+u}}),inputStyle:{outline:"none",boxShadow:"initial",background:"transparent"},style:{flexDirection:"row-reverse",flex:"1 1 0%",minWidth:80}}),(0,re.jsx)(Ie,{hsva:h,placement:"left",onChange:e=>g(e.hsva),aProps:!1,rProps:b,gProps:b,bProps:b})]})]}))});nr.displayName="Compact";const ir=nr;var dr=["prefixCls","className","style","color","onChange"],cr={boxShadow:"initial",borderWidth:"0 0 1px 0",borderBottomColor:"var(--material-border-bottom-color)",borderBottomStyle:"solid",height:30,outline:0,fontSize:15,padding:0},pr=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-material",className:t,style:a,color:s,onChange:n}=e,i=U(e,dr),d="string"===typeof s&&Y(s)?j(s):s,c=s?T(d).replace(/^#/,""):"",p=(e,r)=>{"string"===typeof e&&Y(e)&&/(3|6)/.test(String(e.length))&&n&&n(_(j(e)))},h=l({"--material-border-bottom-color":"#eee","--material-background-color":"#fff",padding:16,width:98,fontFamily:"Roboto",backgroundColor:"var(--material-background-color)"},a);return(0,re.jsxs)("div",l({ref:r,className:[o,t||""].filter(Boolean).join(" "),style:h},i,{children:[(0,re.jsx)(ue,{label:"Hex",value:c.toLocaleUpperCase(),onChange:(e,r)=>p(r),onBlur:e=>{var r=e.target.value;e.target.value=r.slice(0,6),p(r.slice(0,6))},inputStyle:{outline:0,border:0,height:30,fontSize:15,padding:0,boxShadow:"initial",borderWidth:"0 0 2px 0",borderBottomColor:c?"#"+c:"var(--material-border-bottom-color)",borderBottomStyle:"solid",background:"transparent"},style:{flexDirection:"column-reverse",alignItems:"flex-start"}}),(0,re.jsx)(Ie,{hsva:d,placement:"top",style:{marginTop:11},rProps:{style:{alignItems:"flex-start"},inputStyle:l({},cr)},gProps:{style:{alignItems:"flex-start"},inputStyle:l({},cr)},bProps:{style:{alignItems:"flex-start"},inputStyle:l({},cr)},aProps:!1,onChange:e=>{return r=e.hsva,void(n&&n(_(r)));var r}})]}))});pr.displayName="Material";const hr=pr,ur=["#F0F8FF","#FAEBD7","#00FFFF","#7FFFD4","#F0FFFF","#F5F5DC","#FFE4C4","#000000","#FFEBCD","#0000FF","#8A2BE2","#A52A2A","#DEB887","#5F9EA0","#7FFF00","#D2691E","#FF7F50","#6495ED","#FFF8DC","#DC143C","#00FFFF","#00008B","#008B8B","#B8860B","#A9A9A9","#006400","#A9A9A9","#BDB76B","#8B008B","#556B2F","#FF8C00","#9932CC","#8B0000","#E9967A","#8FBC8F","#483D8B","#2F4F4F","#2F4F4F","#00CED1","#9400D3","#FF1493","#00BFFF","#696969","#696969","#1E90FF","#B22222","#FFFAF0","#228B22","#FF00FF","#DCDCDC","#F8F8FF","#FFD700","#DAA520","#808080","#008000","#ADFF2F","#808080","#F0FFF0","#FF69B4","#CD5C5C","#4B0082","#FFFFF0","#F0E68C","#E6E6FA","#FFF0F5","#7CFC00","#FFFACD","#ADD8E6","#F08080","#E0FFFF","#FAFAD2","#D3D3D3","#90EE90","#D3D3D3","#FFB6C1","#FFA07A","#20B2AA","#87CEFA","#778899","#778899","#B0C4DE","#FFFFE0","#00FF00","#32CD32","#FAF0E6","#FF00FF","#800000","#66CDAA","#0000CD","#BA55D3","#9370DB","#3CB371","#7B68EE","#00FA9A","#48D1CC","#C71585","#191970","#F5FFFA","#FFE4E1","#FFE4B5","#FFDEAD","#000080","#FDF5E6","#808000","#6B8E23","#FFA500","#FF4500","#DA70D6","#EEE8AA","#98FB98","#AFEEEE","#DB7093","#FFEFD5","#FFDAB9","#CD853F","#FFC0CB","#DDA0DD","#B0E0E6","#800080","#663399","#FF0000","#BC8F8F","#4169E1","#8B4513","#FA8072","#F4A460","#2E8B57","#FFF5EE","#A0522D","#C0C0C0","#87CEEB","#6A5ACD","#708090","#708090","#FFFAFA","#00FF7F","#4682B4","#D2B48C","#008080","#D8BFD8","#FF6347","#40E0D0","#EE82EE","#F5DEB3","#FFFFFF","#F5F5F5","#FFFF00","#9ACD32"];var gr=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].reduce((e,r,o)=>(e[r]=ur[o],e),{}),br=["aqua","black","blue","fuchsia","gray","green","lime","maroon","navy","olive","purple","red","silver","teal","white","yellow"],fr=br.reduce((e,r)=>(e[r]=gr[r],e),{});function xr(e){return gr[e]}var vr=["prefixCls","className","onChange","direction","hsva"],mr=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-saturation",className:t,onChange:a,direction:s="horizontal",hsva:n}=e,i=U(e,vr),d=h(l({},n,{a:1,v:100}));return(0,re.jsx)(ce,l({ref:r},i,{className:o+" "+(t||""),hsva:{h:n.h,s:n.s,v:n.v,a:1-n.v/100},direction:s,background:"linear-gradient(to "+("horizontal"===s?"right":"bottom")+", "+d+", rgb(0, 0, 0))",onChange:(e,r)=>{a&&a({v:"horizontal"===s?100-100*r.left:100-100*r.top})}}))});mr.displayName="ShadeSlider";const yr=mr;var Cr=["prefixCls","className","onChange","width","presetColors","color","editableDisable","disableAlpha","style"],wr=["#D0021B","#F5A623","#f8e61b","#8B572A","#7ED321","#417505","#BD10E0","#9013FE","#4A90E2","#50E3C2","#B8E986","#000000","#4A4A4A","#9B9B9B","#FFFFFF"],Fr=e=>(0,re.jsx)("div",{style:{boxShadow:"rgb(0 0 0 / 60%) 0px 0px 2px",width:4,top:1,bottom:1,left:e.left,borderRadius:1,position:"absolute",backgroundColor:"#fff"}}),kr=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-sketch",className:t,onChange:a,width:s=218,presetColors:n=wr,color:i,editableDisable:d=!0,disableAlpha:c=!1,style:p}=e,h=U(e,Cr),[u,g]=(0,V.useState)({h:209,s:36,v:90,a:1});(0,V.useEffect)(()=>{"string"===typeof i&&Y(i)&&g(j(i)),"object"===typeof i&&g(i)},[i]);var b=e=>{g(e),a&&a(_(e))},f=l({"--sketch-background":"rgb(255, 255, 255)","--sketch-box-shadow":"rgb(0 0 0 / 15%) 0px 0px 0px 1px, rgb(0 0 0 / 15%) 0px 8px 16px","--sketch-swatch-box-shadow":"rgb(0 0 0 / 15%) 0px 0px 0px 1px inset","--sketch-alpha-box-shadow":"rgb(0 0 0 / 15%) 0px 0px 0px 1px inset, rgb(0 0 0 / 25%) 0px 0px 4px inset","--sketch-swatch-border-top":"1px solid rgb(238, 238, 238)",background:"var(--sketch-background)",borderRadius:4,boxShadow:"var(--sketch-box-shadow)",width:s},p),x={borderRadius:2,background:N(u),boxShadow:"var(--sketch-alpha-box-shadow)"};return(0,re.jsxs)("div",l({},h,{className:o+" "+(t||""),ref:r,style:f,children:[(0,re.jsxs)("div",{style:{padding:"10px 10px 8px"},children:[(0,re.jsx)(De,{hsva:u,style:{width:"auto",height:150},onChange:e=>b(l({},u,e,{a:u.a}))}),(0,re.jsxs)("div",{style:{display:"flex",marginTop:4},children:[(0,re.jsxs)("div",{style:{flex:1},children:[(0,re.jsx)(Le,{width:"auto",height:10,hue:u.h,pointer:Fr,innerProps:{style:{marginLeft:1,marginRight:5}},onChange:e=>b(l({},u,e))}),!c&&(0,re.jsx)(ce,{width:"auto",height:10,hsva:u,pointer:Fr,style:{marginTop:4},innerProps:{style:{marginLeft:1,marginRight:5}},onChange:e=>b(l({},u,{a:e.a}))})]}),!c&&(0,re.jsx)(ce,{width:24,height:24,hsva:u,radius:2,style:{marginLeft:4},bgProps:{style:{background:"transparent"}},innerProps:{style:x},pointer:()=>(0,re.jsx)(V.Fragment,{})})]})]}),d&&(0,re.jsxs)("div",{style:{display:"flex",margin:"0 10px 3px 10px"},children:[(0,re.jsx)(ue,{label:"Hex",value:T(u).replace(/^#/,"").toLocaleUpperCase(),onChange:(e,r)=>{var o;"string"===typeof(o=r)&&Y(o)&&/(3|6)/.test(String(o.length))&&b(j(o))},style:{minWidth:58}}),(0,re.jsx)(Ie,{hsva:u,style:{marginLeft:6},aProps:!c&&{},onChange:e=>b(e.hsva)})]}),n&&n.length>0&&(0,re.jsx)(fe,{style:{borderTop:"var(--sketch-swatch-border-top)",paddingTop:10,paddingLeft:10},colors:n,color:T(u),onChange:e=>b(e),rectProps:{style:{marginRight:10,marginBottom:10,borderRadius:3,boxShadow:"var(--sketch-swatch-box-shadow)"}}})]}))});kr.displayName="Sketch";const Br=kr;var Ar=["prefixCls","className","style","onChange","color","customColorShades","lightness"],jr=e=>"string"===typeof e&&Y(e)?j(e):e||{},Rr=function(e,r,o){return void 0===o&&(o=2),Math.abs(e-r)<=o},Sr=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-slider",className:t,style:a,onChange:s,color:n,customColorShades:i=[{color:"#000000",lightness:[50,40,30,20,10]},{color:"#ffffff",lightness:[95,90,80,70,60]}],lightness:d=[80,65,50,35,20]}=e,c=U(e,Ar),p=jr(n),h=i.find(e=>{var r=((e,r,o)=>{var t=Rr(e.h,r.h)&&Rr(e.s,r.s)&&Rr(e.a,r.a);return!(!t||!Rr(e.v,r.v))||!!o&&t&&o.some(e=>Rr(r.v,e))})(jr(e.color),p,e.lightness);return r}),u=h?h.lightness:d;return(0,re.jsx)("div",l({ref:r,style:l({display:"flex"},a),className:[o,t||""].filter(Boolean).join(" ")},c,{children:u.map((e,r)=>{var o=l({},p,{v:e}),t=S(o),a="rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")",n=a===N(p);return(0,re.jsx)("div",{style:{paddingLeft:1,width:100/u.length+"%",boxSizing:"border-box"},children:(0,re.jsx)("div",{onClick:e=>((e,r)=>{var o=w(e);s&&s(_(o),r)})(a,e),style:l({backgroundColor:a,height:12,cursor:"pointer"},n?{borderRadius:2,transform:"scale(1, 1.5)"}:{})})},r)})}))});Sr.displayName="Slider";const Er=Sr;var Nr=e=>{var{className:r,color:o,left:t,top:a,style:s,prefixCls:n}=e,i=l({},s,{position:"absolute",top:a,left:t}),d=n+"-pointer "+(r||"");return(0,re.jsx)("div",{className:d,style:i,children:(0,re.jsx)("div",{className:n+"-fill",style:{width:10,height:10,transform:"translate(-5px, -5px)",boxShadow:"rgb(255 255 255) 0px 0px 0px 1.5px, rgb(0 0 0 / 30%) 0px 0px 1px 1px inset, rgb(0 0 0 / 40%) 0px 0px 1px 2px",borderRadius:"50%",backgroundColor:"#fff"},children:(0,re.jsx)("div",{style:{inset:0,borderRadius:"50%",position:"absolute",backgroundColor:o}})})})},Dr=2*Math.PI,Pr=(e,r)=>Math.sqrt(e*e+r*r);function Tr(e){var{width:r=0}=e,o=r/2;return{width:r,radius:o,cx:o,cy:o}}function Lr(e){var{width:r=0}=e;return r/2}function Mr(e,r,o){var t,a=e.angle||0,l=e.direction;return o&&"clockwise"===l?r=a+r:"clockwise"===l?r=360-a+r:o&&"anticlockwise"===l?r=a+180-r:"anticlockwise"===l&&(r=a-r),(r%(t=360)+t)%t}var Hr=["prefixCls","radius","pointer","className","style","width","height","oval","direction","angle","color","onChange"],Ir=K().forwardRef((e,r)=>{var{prefixCls:o="w-color-wheel",radius:t=0,pointer:a,className:s,style:n,width:i=200,height:d=200,oval:c,direction:p="anticlockwise",angle:h=180,color:u,onChange:g}=e,b=U(e,Hr),f="string"===typeof u&&Y(u)?j(u):u||{},x=u?T(f):"",v=function(e,r){var{cx:o,cy:t}=Tr(e),a=Lr(e),l=(180+Mr(e,r.h,!0))*(Dr/360),s=r.s/100*a,n="clockwise"===e.direction?-1:1;return{x:o+s*Math.cos(l)*n,y:t+s*Math.sin(l)*n}}({width:i},f),m={top:"0",left:"0",color:x},y=(e,r)=>{var o=function(e,r,o){var{cx:t,cy:a}=Tr(e),l=Lr(e);r=t-r,o=a-o;var s=Mr(e,Math.atan2(-o,-r)*(360/Dr)),n=Math.min(Pr(r,o),l);return{h:Math.round(s),s:Math.round(100/l*n)}}({width:i},i-e.x,d-e.y),t={h:o.h,s:o.s,v:f.v,a:f.a};g&&g(_(t))},C={zIndex:1,position:"absolute",transform:"translate("+v.x+"px, "+v.y+"px) "+("x"===c||"X"===c?"scaleY(2)":"y"===c||"Y"===c?"scaleX(2)":"")},w=a&&"function"===typeof a?a(l({prefixCls:o,style:C},m)):(0,re.jsx)(Nr,l({prefixCls:o,style:C},m));return(0,re.jsxs)(ae,l({className:[o,s||""].filter(Boolean).join(" ")},b,{style:l({position:"relative",width:i,transform:"x"===c||"X"===c?"scaleY(0.5)":"y"===c||"Y"===c?"scaleX(0.5)":"",height:d},n),ref:r,onMove:y,onDown:y,children:[w,(0,re.jsx)("div",{style:{position:"absolute",borderRadius:"50%",background:"anticlockwise"===p?"conic-gradient(red, yellow, lime, aqua, blue, magenta, red)":"conic-gradient(red, magenta, blue, aqua, lime, yellow, red)",transform:"rotateZ("+(h+90)+"deg)",inset:0}}),(0,re.jsx)("div",{style:{position:"absolute",borderRadius:"50%",background:"radial-gradient(circle closest-side, #fff, transparent)",inset:0}}),(0,re.jsx)("div",{style:{backgroundColor:"#000",borderRadius:"50%",position:"absolute",inset:0,opacity:"number"===typeof f.v?1-f.v/100:0}})]}))});Ir.displayName="Wheel";const zr=Ir;return a})());