react-scribble-pad
Version:
React Sketches just made easy.
6 lines • 92 kB
JavaScript
(function(he,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],v):(he=typeof globalThis<"u"?globalThis:he||self,v(he.ReactScribblePad={},he.jsxRuntime,he.React))})(this,(function(he,v,C){"use strict";function L(){return L=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)({}).hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},L.apply(null,arguments)}var Ce=255,fe=100,Ee=e=>{var{r,g:n,b:t,a:o}=e,s=Math.max(r,n,t),a=s-Math.min(r,n,t),i=a?s===r?(n-t)/a:s===n?2+(t-r)/a:4+(r-n)/a:0;return{h:60*(i<0?i+6:i),s:s?a/s*fe:0,v:s/Ce*fe,a:o}},kt=e=>{var{h:r,s:n,l:t,a:o}=_t(e);return"hsla("+r+", "+n+"%, "+t+"%, "+o+")"},_t=e=>{var{h:r,s:n,v:t,a:o}=e,s=(200-n)*t/fe;return{h:r,s:s>0&&s<200?n*t/fe/(s<=fe?s:200-s)*fe:0,l:s/2,a:o}},Ct=e=>{var{r,g:n,b:t}=e,o=r<<16|n<<8|t;return"#"+(s=>new Array(7-s.length).join("0")+s)(o.toString(16))},Lr=e=>{var{r,g:n,b:t,a:o}=e,s=typeof o=="number"&&(o*255|256).toString(16).slice(1);return""+Ct({r,g:n,b:t})+(s||"")},Le=e=>Ee(Dr(e)),Dr=e=>{var r=e.replace("#","");/^#?/.test(e)&&r.length===3&&(e="#"+r.charAt(0)+r.charAt(0)+r.charAt(1)+r.charAt(1)+r.charAt(2)+r.charAt(2));var n=new RegExp("[A-Za-z0-9]{2}","g"),[t,o,s=0,a]=e.match(n).map(i=>parseInt(i,16));return{r:t,g:o,b:s,a:(a??255)/Ce}},je=e=>{var{h:r,s:n,v:t,a:o}=e,s=r/60,a=n/fe,i=t/fe,f=Math.floor(s)%6,d=s-Math.floor(s),h=Ce*i*(1-a),c=Ce*i*(1-a*d),b=Ce*i*(1-a*(1-d));i*=Ce;var g={};switch(f){case 0:g.r=i,g.g=b,g.b=h;break;case 1:g.r=c,g.g=i,g.b=h;break;case 2:g.r=h,g.g=i,g.b=b;break;case 3:g.r=h,g.g=c,g.b=i;break;case 4:g.r=b,g.g=h,g.b=i;break;case 5:g.r=i,g.g=h,g.b=c;break}return g.r=Math.round(g.r),g.g=Math.round(g.g),g.b=Math.round(g.b),L({},g,{a:o})},Mr=e=>{var{r,g:n,b:t,a:o}=je(e);return"rgba("+r+", "+n+", "+t+", "+o+")"},Br=e=>{var{r,g:n,b:t}=e;return{r,g:n,b:t}},Or=e=>{var{h:r,s:n,l:t}=e;return{h:r,s:n,l:t}},Qe=e=>Ct(je(e)),jr=e=>{var{h:r,s:n,v:t}=e;return{h:r,s:n,v:t}},Hr=e=>{var{r,g:n,b:t}=e,o=function(h){return h<=.04045?h/12.92:Math.pow((h+.055)/1.055,2.4)},s=o(r/255),a=o(n/255),i=o(t/255),f={};return f.x=s*.4124+a*.3576+i*.1805,f.y=s*.2126+a*.7152+i*.0722,f.bri=s*.0193+a*.1192+i*.9505,f},Te=e=>{var r,n,t,o,s,a,i,f,d;return typeof e=="string"&&et(e)?(a=Le(e),f=e):typeof e!="string"&&(a=e),a&&(t=jr(a),s=_t(a),o=je(a),d=Lr(o),f=Qe(a),n=Or(s),r=Br(o),i=Hr(r)),{rgb:r,hsl:n,hsv:t,rgba:o,hsla:s,hsva:a,hex:f,hexa:d,xy:i}},et=e=>/^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(e);function ce(e,r){if(e==null)return{};var n={};for(var t in e)if({}.hasOwnProperty.call(e,t)){if(r.indexOf(t)!==-1)continue;n[t]=e[t]}return n}function Et(e){var r=C.useRef(e);return C.useEffect(()=>{r.current=e}),C.useCallback((n,t)=>r.current&&r.current(n,t),[])}var De=e=>"touches"in e,Tt=e=>{!De(e)&&e.preventDefault&&e.preventDefault()},Pt=function(r,n,t){return n===void 0&&(n=0),t===void 0&&(t=1),r>t?t:r<n?n:r},Nt=(e,r)=>{var n=e.getBoundingClientRect(),t=De(r)?r.touches[0]:r;return{left:Pt((t.pageX-(n.left+window.pageXOffset))/n.width),top:Pt((t.pageY-(n.top+window.pageYOffset))/n.height),width:n.width,height:n.height,x:t.pageX-(n.left+window.pageXOffset),y:t.pageY-(n.top+window.pageYOffset)}},Wr=["prefixCls","className","onMove","onDown"],tt=C.forwardRef((e,r)=>{var{prefixCls:n="w-color-interactive",className:t,onMove:o,onDown:s}=e,a=ce(e,Wr),i=C.useRef(null),f=C.useRef(!1),[d,h]=C.useState(!1),c=Et(o),b=Et(s),g=y=>f.current&&!De(y)?!1:(f.current=De(y),!0),m=C.useCallback(y=>{if(Tt(y),!!i.current){var D=De(y)?y.touches.length>0:y.buttons>0;if(!D){h(!1);return}c?.(Nt(i.current,y),y)}},[c]),u=C.useCallback(()=>h(!1),[]),S=C.useCallback(y=>{y?(window.addEventListener(f.current?"touchmove":"mousemove",m),window.addEventListener(f.current?"touchend":"mouseup",u)):(window.removeEventListener("mousemove",m),window.removeEventListener("mouseup",u),window.removeEventListener("touchmove",m),window.removeEventListener("touchend",u))},[m,u]);C.useEffect(()=>(S(d),()=>{S(!1)}),[d,m,u,S]);var k=C.useCallback(y=>{var D=document.activeElement;D?.blur(),Tt(y.nativeEvent),g(y.nativeEvent)&&i.current&&(b?.(Nt(i.current,y.nativeEvent),y.nativeEvent),h(!0))},[b]);return v.jsx("div",L({},a,{className:[n,t||""].filter(Boolean).join(" "),style:L({},a.style,{touchAction:"none"}),ref:i,tabIndex:0,onMouseDown:k,onTouchStart:k}))});tt.displayName="Interactive";var Fr=["className","prefixCls","left","top","style","fillProps"],Xr=e=>{var{className:r,prefixCls:n,left:t,top:o,style:s,fillProps:a}=e,i=ce(e,Fr),f=L({},s,{position:"absolute",left:t,top:o}),d=L({width:18,height:18,boxShadow:"var(--alpha-pointer-box-shadow)",borderRadius:"50%",backgroundColor:"var(--alpha-pointer-background-color)"},a?.style,{transform:t?"translate(-9px, -1px)":"translate(-1px, -9px)"});return v.jsx("div",L({className:n+"-pointer "+(r||""),style:f},i,{children:v.jsx("div",L({className:n+"-fill"},a,{style:d}))}))},Yr=["prefixCls","className","hsva","background","bgProps","innerProps","pointerProps","radius","width","height","direction","style","onChange","pointer"],Ur="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==",He=C.forwardRef((e,r)=>{var{prefixCls:n="w-color-alpha",className:t,hsva:o,background:s,bgProps:a={},innerProps:i={},pointerProps:f={},radius:d=0,width:h,height:c=16,direction:b="horizontal",style:g,onChange:m,pointer:u}=e,S=ce(e,Yr),k=w=>{m&&m(L({},o,{a:b==="horizontal"?w.left:w.top}),w)},y=kt(Object.assign({},o,{a:1})),D="linear-gradient(to "+(b==="horizontal"?"right":"bottom")+", rgba(244, 67, 54, 0) 0%, "+y+" 100%)",O={};b==="horizontal"?O.left=o.a*100+"%":O.top=o.a*100+"%";var K=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:d,background:"url("+Ur+") left center",backgroundColor:"var(--alpha-background-color)"},{width:h,height:c},g,{position:"relative"}),M=u&&typeof u=="function"?u(L({prefixCls:n},f,O)):v.jsx(Xr,L({},f,{prefixCls:n},O));return v.jsxs("div",L({},S,{className:[n,n+"-"+b,t||""].filter(Boolean).join(" "),style:K,ref:r,children:[v.jsx("div",L({},a,{style:L({inset:0,position:"absolute",background:s||D,borderRadius:d},a.style)})),v.jsx(tt,L({},i,{style:L({},i.style,{inset:0,zIndex:1,position:"absolute"}),onMove:k,onDown:k,children:M}))]}))});He.displayName="Alpha";var Gr=["prefixCls","placement","label","value","className","style","labelStyle","inputStyle","onChange","onBlur","renderInput"],Vr=e=>/^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(e),Rr=e=>Number(String(e).replace(/%/g,"")),Pe=C.forwardRef((e,r)=>{var{prefixCls:n="w-color-editable-input",placement:t="bottom",label:o,value:s,className:a,style:i,labelStyle:f,inputStyle:d,onChange:h,onBlur:c,renderInput:b}=e,g=ce(e,Gr),[m,u]=C.useState(s),S=C.useRef(!1);C.useEffect(()=>{e.value!==m&&(S.current||u(e.value))},[e.value]);function k(w,N){var E=(N||w.target.value).trim().replace(/^#/,"");Vr(E)&&h&&h(w,E);var z=Rr(E);isNaN(z)||h&&h(w,z),u(E)}function y(w){S.current=!1,u(e.value),c&&c(w)}var D={};t==="bottom"&&(D.flexDirection="column"),t==="top"&&(D.flexDirection="column-reverse"),t==="left"&&(D.flexDirection="row-reverse");var O=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},D,i),K=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)"},d),M=L({value:m,onChange:k,onBlur:y,autoComplete:"off",onFocus:()=>S.current=!0},g,{style:K});return v.jsxs("div",{className:[n,a||""].filter(Boolean).join(" "),style:O,children:[b?b(M,r):v.jsx("input",L({ref:r},M)),o&&v.jsx("span",{style:L({color:"var(--editable-input-label-color)",textTransform:"capitalize"},f),children:o})]})});Pe.displayName="EditableInput";var Kr=["prefixCls","className","color","colors","style","rectProps","onChange","addonAfter","addonBefore","rectRender"],At=C.forwardRef((e,r)=>{var{prefixCls:n="w-color-swatch",className:t,color:o,colors:s=[],style:a,rectProps:i={},onChange:f,addonAfter:d,addonBefore:h,rectRender:c}=e,b=ce(e,Kr),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),m=(u,S)=>{f&&f(Le(u),Te(Le(u)),S)};return v.jsxs("div",L({ref:r},b,{className:[n,t||""].filter(Boolean).join(" "),style:L({display:"flex",flexWrap:"wrap",position:"relative"},a),children:[h&&C.isValidElement(h)&&h,s&&Array.isArray(s)&&s.map((u,S)=>{var k="",y="";typeof u=="string"&&(k=u,y=u),typeof u=="object"&&u.color&&(k=u.title||u.color,y=u.color);var D=o&&o.toLocaleLowerCase()===y.toLocaleLowerCase(),O=c&&c({title:k,color:y,checked:!!D,style:L({},g,{background:y}),onClick:M=>m(y,M)});if(O)return v.jsx(C.Fragment,{children:O},S);var K=i.children&&C.isValidElement(i.children)?C.cloneElement(i.children,{color:y,checked:D}):null;return v.jsx("div",L({tabIndex:0,title:k,onClick:M=>m(y,M)},i,{children:K,style:L({},g,{background:y})}),S)}),d&&C.isValidElement(d)&&d]}))});At.displayName="Swatch";var qr=e=>{var{className:r,color:n,left:t,top:o,prefixCls:s}=e,a={position:"absolute",top:o,left:t},i={"--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:n};return C.useMemo(()=>v.jsx("div",{className:s+"-pointer "+(r||""),style:a,children:v.jsx("div",{className:s+"-fill",style:i})}),[o,t,n,r,s])},Jr=["prefixCls","radius","pointer","className","hue","style","hsva","onChange"],$t=C.forwardRef((e,r)=>{var n,{prefixCls:t="w-color-saturation",radius:o=0,pointer:s,className:a,hue:i=0,style:f,hsva:d,onChange:h}=e,c=ce(e,Jr),b=L({width:200,height:200,borderRadius:o},f,{position:"relative"}),g=(u,S)=>{h&&d&&h({h:d.h,s:u.left*100,v:(1-u.top)*100,a:d.a})},m=C.useMemo(()=>{if(!d)return null;var u={top:100-d.v+"%",left:d.s+"%",color:kt(d)};return s&&typeof s=="function"?s(L({prefixCls:t},u)):v.jsx(qr,L({prefixCls:t},u))},[d,s,t]);return v.jsx(tt,L({className:[t,a||""].filter(Boolean).join(" ")},c,{style:L({position:"absolute",inset:0,cursor:"crosshair",backgroundImage:"linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, hsl("+((n=d?.h)!=null?n:i)+", 100%, 50%))"},b),ref:r,onMove:g,onDown:g,children:m}))});$t.displayName="Saturation";var Zr=["prefixCls","className","hue","onChange","direction"],zt=C.forwardRef((e,r)=>{var{prefixCls:n="w-color-hue",className:t,hue:o=0,onChange:s,direction:a="horizontal"}=e,i=ce(e,Zr);return v.jsx(He,L({ref:r,className:n+" "+(t||"")},i,{direction:a,background:"linear-gradient(to "+(a==="horizontal"?"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:o,s:100,v:100,a:o/360},onChange:(f,d)=>{s&&s({h:a==="horizontal"?360*d.left:360*d.top})}}))});zt.displayName="Hue";var Qr=["prefixCls","hsva","placement","rProps","gProps","bProps","aProps","className","style","onChange"],It=C.forwardRef((e,r)=>{var{prefixCls:n="w-color-editable-input-rgba",hsva:t,placement:o="bottom",rProps:s={},gProps:a={},bProps:i={},aProps:f={},className:d,style:h,onChange:c}=e,b=ce(e,Qr),g=t?je(t):{};function m(S){var k=Number(S.target.value);k&&k>255&&(S.target.value="255"),k&&k<0&&(S.target.value="0")}var u=(S,k,y)=>{typeof S=="number"&&(k==="a"&&(S<0&&(S=0),S>100&&(S=100),c&&c(Te(Ee(L({},g,{a:S/100}))))),S>255&&(S=255,y.target.value="255"),S<0&&(S=0,y.target.value="0"),k==="r"&&c&&c(Te(Ee(L({},g,{r:S})))),k==="g"&&c&&c(Te(Ee(L({},g,{g:S})))),k==="b"&&c&&c(Te(Ee(L({},g,{b:S})))))};return v.jsxs("div",L({ref:r,className:[n,d||""].filter(Boolean).join(" ")},b,{style:L({fontSize:11,display:"flex"},h),children:[v.jsx(Pe,L({label:"R",value:g.r||0,onBlur:m,placement:o,onChange:(S,k)=>u(k,"r",S)},s,{style:L({},s.style)})),v.jsx(Pe,L({label:"G",value:g.g||0,onBlur:m,placement:o,onChange:(S,k)=>u(k,"g",S)},a,{style:L({marginLeft:5},s.style)})),v.jsx(Pe,L({label:"B",value:g.b||0,onBlur:m,placement:o,onChange:(S,k)=>u(k,"b",S)},i,{style:L({marginLeft:5},i.style)})),f&&v.jsx(Pe,L({label:"A",value:g.a?parseInt(String(g.a*100),10):0,onBlur:m,placement:o,onChange:(S,k)=>u(k,"a",S)},f,{style:L({marginLeft:5},f.style)}))]}))});It.displayName="EditableInputRGBA";var en=["prefixCls","className","onChange","width","presetColors","color","editableDisable","disableAlpha","style"],tn=["#D0021B","#F5A623","#f8e61b","#8B572A","#7ED321","#417505","#BD10E0","#9013FE","#4A90E2","#50E3C2","#B8E986","#000000","#4A4A4A","#9B9B9B","#FFFFFF"],Lt=e=>v.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"}}),Dt=C.forwardRef((e,r)=>{var{prefixCls:n="w-color-sketch",className:t,onChange:o,width:s=218,presetColors:a=tn,color:i,editableDisable:f=!0,disableAlpha:d=!1,style:h}=e,c=ce(e,en),[b,g]=C.useState({h:209,s:36,v:90,a:1});C.useEffect(()=>{typeof i=="string"&&et(i)&&g(Le(i)),typeof i=="object"&&g(i)},[i]);var m=M=>{g(M),o&&o(Te(M))},u=(M,w)=>{typeof M=="string"&&et(M)&&/(3|6)/.test(String(M.length))&&m(Le(M))},S=M=>m(L({},b,{a:M.a})),k=M=>m(L({},b,M,{a:b.a})),y=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},h),D={borderRadius:2,background:Mr(b),boxShadow:"var(--sketch-alpha-box-shadow)"},O={borderTop:"var(--sketch-swatch-border-top)",paddingTop:10,paddingLeft:10},K={marginRight:10,marginBottom:10,borderRadius:3,boxShadow:"var(--sketch-swatch-box-shadow)"};return v.jsxs("div",L({},c,{className:n+" "+(t||""),ref:r,style:y,children:[v.jsxs("div",{style:{padding:"10px 10px 8px"},children:[v.jsx($t,{hsva:b,style:{width:"auto",height:150},onChange:k}),v.jsxs("div",{style:{display:"flex",marginTop:4},children:[v.jsxs("div",{style:{flex:1},children:[v.jsx(zt,{width:"auto",height:10,hue:b.h,pointer:Lt,innerProps:{style:{marginLeft:1,marginRight:5}},onChange:M=>m(L({},b,M))}),!d&&v.jsx(He,{width:"auto",height:10,hsva:b,pointer:Lt,style:{marginTop:4},innerProps:{style:{marginLeft:1,marginRight:5}},onChange:S})]}),!d&&v.jsx(He,{width:24,height:24,hsva:b,radius:2,style:{marginLeft:4},bgProps:{style:{background:"transparent"}},innerProps:{style:D},pointer:()=>v.jsx(C.Fragment,{})})]})]}),f&&v.jsxs("div",{style:{display:"flex",margin:"0 10px 3px 10px"},children:[v.jsx(Pe,{label:"Hex",value:Qe(b).replace(/^#/,"").toLocaleUpperCase(),onChange:(M,w)=>u(w),style:{minWidth:58}}),v.jsx(It,{hsva:b,style:{marginLeft:6},aProps:d?!1:{},onChange:M=>m(M.hsva)})]}),a&&a.length>0&&v.jsx(At,{style:O,colors:a,color:Qe(b),onChange:M=>m(M),rectProps:{style:K}})]}))});Dt.displayName="Sketch";function Mt({pick:e,position:r,colorState:n,disableAplha:t}){const s=Ee(n);return v.jsx(Dt,{color:s,disableAlpha:t,style:{position:"absolute",bottom:50,left:r},onChange:a=>{e({...a.rgba})}})}const Me={},Bt=(e,r)=>e.unstable_is?e.unstable_is(r):r===e,Ot=e=>"init"in e,rt=e=>!!e.write,jt=e=>"v"in e||"e"in e,We=e=>{if("e"in e)throw e.e;if((Me?"production":void 0)!=="production"&&!("v"in e))throw new Error("[Bug] atom state is not initialized");return e.v},Fe=new WeakMap,Ht=e=>{var r;return Xe(e)&&!!((r=Fe.get(e))!=null&&r[0])},rn=e=>{const r=Fe.get(e);r?.[0]&&(r[0]=!1,r[1].forEach(n=>n()))},Wt=(e,r)=>{let n=Fe.get(e);if(!n){n=[!0,new Set],Fe.set(e,n);const t=()=>{n[0]=!1};e.then(t,t)}n[1].add(r)},Xe=e=>typeof e?.then=="function",Ft=(e,r,n)=>{n.p.has(e)||(n.p.add(e),r.then(()=>{n.p.delete(e)},()=>{n.p.delete(e)}))},nt=(e,r,n)=>{const t=n(e),o="v"in t,s=t.v;if(Xe(r))for(const a of t.d.keys())Ft(e,r,n(a));t.v=r,delete t.e,(!o||!Object.is(s,t.v))&&(++t.n,Xe(s)&&rn(s))},Xt=(e,r,n)=>{var t;const o=new Set;for(const s of((t=n.get(e))==null?void 0:t.t)||[])n.has(s)&&o.add(s);for(const s of r.p)o.add(s);return o},nn=Symbol(),on=(e=new WeakMap,r=new WeakMap,n=new WeakMap,t=new Set,o=new Set,s=new Set,a={},i=(b,...g)=>b.read(...g),f=(b,...g)=>b.write(...g),d=(b,g)=>{var m;return(m=b.unstable_onInit)==null?void 0:m.call(b,g)},h=(b,g)=>{var m;return(m=b.onMount)==null?void 0:m.call(b,g)},...c)=>{const b=c[0]||(w=>{if((Me?"production":void 0)!=="production"&&!w)throw new Error("Atom is undefined or null");let N=e.get(w);return N||(N={d:new Map,p:new Set,n:0},e.set(w,N),d?.(w,M)),N}),g=c[1]||(()=>{const w=[],N=E=>{try{E()}catch(z){w.push(z)}};do{a.f&&N(a.f);const E=new Set,z=E.add.bind(E);t.forEach(A=>{var I;return(I=r.get(A))==null?void 0:I.l.forEach(z)}),t.clear(),s.forEach(z),s.clear(),o.forEach(z),o.clear(),E.forEach(N),t.size&&m()}while(t.size||s.size||o.size);if(w.length)throw new AggregateError(w)}),m=c[2]||(()=>{const w=[],N=new WeakSet,E=new WeakSet,z=Array.from(t);for(;z.length;){const A=z[z.length-1],I=b(A);if(E.has(A)){z.pop();continue}if(N.has(A)){if(n.get(A)===I.n)w.push([A,I]);else if((Me?"production":void 0)!=="production"&&n.has(A))throw new Error("[Bug] invalidated atom exists");E.add(A),z.pop();continue}N.add(A);for(const V of Xt(A,I,r))N.has(V)||z.push(V)}for(let A=w.length-1;A>=0;--A){const[I,V]=w[A];let R=!1;for(const U of V.d.keys())if(U!==I&&t.has(U)){R=!0;break}R&&(u(I),y(I)),n.delete(I)}}),u=c[3]||(w=>{var N;const E=b(w);if(jt(E)&&(r.has(w)&&n.get(w)!==E.n||Array.from(E.d).every(([W,Q])=>u(W).n===Q)))return E;E.d.clear();let z=!0;const A=()=>{r.has(w)&&(y(w),m(),g())},I=W=>{var Q;if(Bt(w,W)){const se=b(W);if(!jt(se))if(Ot(W))nt(W,W.init,b);else throw new Error("no atom init");return We(se)}const ne=u(W);try{return We(ne)}finally{E.d.set(W,ne.n),Ht(E.v)&&Ft(w,E.v,ne),(Q=r.get(W))==null||Q.t.add(w),z||A()}};let V,R;const U={get signal(){return V||(V=new AbortController),V.signal},get setSelf(){return(Me?"production":void 0)!=="production"&&!rt(w)&&console.warn("setSelf function cannot be used with read-only atom"),!R&&rt(w)&&(R=(...W)=>{if((Me?"production":void 0)!=="production"&&z&&console.warn("setSelf function cannot be called in sync"),!z)try{return k(w,...W)}finally{m(),g()}}),R}},q=E.n;try{const W=i(w,I,U);return nt(w,W,b),Xe(W)&&(Wt(W,()=>V?.abort()),W.then(A,A)),E}catch(W){return delete E.v,E.e=W,++E.n,E}finally{z=!1,q!==E.n&&n.get(w)===q&&(n.set(w,E.n),t.add(w),(N=a.c)==null||N.call(a,w))}}),S=c[4]||(w=>{const N=[w];for(;N.length;){const E=N.pop(),z=b(E);for(const A of Xt(E,z,r)){const I=b(A);n.set(A,I.n),N.push(A)}}}),k=c[5]||((w,...N)=>{let E=!0;const z=I=>We(u(I)),A=(I,...V)=>{var R;const U=b(I);try{if(Bt(w,I)){if(!Ot(I))throw new Error("atom not writable");const q=U.n,W=V[0];nt(I,W,b),y(I),q!==U.n&&(t.add(I),(R=a.c)==null||R.call(a,I),S(I));return}else return k(I,...V)}finally{E||(m(),g())}};try{return f(w,z,A,...N)}finally{E=!1}}),y=c[6]||(w=>{var N;const E=b(w),z=r.get(w);if(z&&!Ht(E.v)){for(const[A,I]of E.d)if(!z.d.has(A)){const V=b(A);D(A).t.add(w),z.d.add(A),I!==V.n&&(t.add(A),(N=a.c)==null||N.call(a,A),S(A))}for(const A of z.d||[])if(!E.d.has(A)){z.d.delete(A);const I=O(A);I?.t.delete(w)}}}),D=c[7]||(w=>{var N;const E=b(w);let z=r.get(w);if(!z){u(w);for(const A of E.d.keys())D(A).t.add(w);if(z={l:new Set,d:new Set(E.d.keys()),t:new Set},r.set(w,z),(N=a.m)==null||N.call(a,w),rt(w)){const A=()=>{let I=!0;const V=(...R)=>{try{return k(w,...R)}finally{I||(m(),g())}};try{const R=h(w,V);R&&(z.u=()=>{I=!0;try{R()}finally{I=!1}})}finally{I=!1}};o.add(A)}}return z}),O=c[8]||(w=>{var N;const E=b(w);let z=r.get(w);if(z&&!z.l.size&&!Array.from(z.t).some(A=>{var I;return(I=r.get(A))==null?void 0:I.d.has(w)})){z.u&&s.add(z.u),z=void 0,r.delete(w),(N=a.u)==null||N.call(a,w);for(const A of E.d.keys()){const I=O(A);I?.t.delete(w)}return}return z}),K=[e,r,n,t,o,s,a,i,f,d,h,b,g,m,u,S,k,y,D,O],M={get:w=>We(u(w)),set:(w,...N)=>{try{return k(w,...N)}finally{m(),g()}},sub:(w,N)=>{const z=D(w).l;return z.add(N),g(),()=>{z.delete(N),O(w),g()}}};return Object.defineProperty(M,nn,{value:K}),M},Yt=Wt,Ut={};let sn=0;function Ye(e,r){const n=`atom${++sn}`,t={toString(){return(Ut?"production":void 0)!=="production"&&this.debugLabel?n+":"+this.debugLabel:n}};return typeof e=="function"?t.read=e:(t.init=e,t.read=an,t.write=ln),t}function an(e){return e(this)}function ln(e,r,n){return r(this,typeof n=="function"?n(e(this)):n)}function cn(){return on()}let Be;function un(){return Be||(Be=cn(),(Ut?"production":void 0)!=="production"&&(globalThis.__JOTAI_DEFAULT_STORE__||(globalThis.__JOTAI_DEFAULT_STORE__=Be),globalThis.__JOTAI_DEFAULT_STORE__!==Be&&console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"))),Be}const dn={},hn=C.createContext(void 0);function Gt(e){return C.useContext(hn)||un()}const ot=e=>typeof e?.then=="function",st=e=>{e.status||(e.status="pending",e.then(r=>{e.status="fulfilled",e.value=r},r=>{e.status="rejected",e.reason=r}))},fn=C.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(st(e),e)}),at=new WeakMap,Vt=(e,r)=>{let n=at.get(e);return n||(n=new Promise((t,o)=>{let s=e;const a=d=>h=>{s===d&&t(h)},i=d=>h=>{s===d&&o(h)},f=()=>{try{const d=r();ot(d)?(at.set(d,n),s=d,d.then(a(d),i(d)),Yt(d,f)):t(d)}catch(d){o(d)}};e.then(a(e),i(e)),Yt(e,f)}),at.set(e,n)),n};function vn(e,r){const{delay:n,unstable_promiseStatus:t=!C.use}={},o=Gt(),[[s,a,i],f]=C.useReducer(h=>{const c=o.get(e);return Object.is(h[0],c)&&h[1]===o&&h[2]===e?h:[c,o,e]},void 0,()=>[o.get(e),o,e]);let d=s;if((a!==o||i!==e)&&(f(),d=o.get(e)),C.useEffect(()=>{const h=o.sub(e,()=>{if(t)try{const c=o.get(e);ot(c)&&st(Vt(c,()=>o.get(e)))}catch{}if(typeof n=="number"){setTimeout(f,n);return}f()});return f(),h},[o,e,n,t]),C.useDebugValue(d),ot(d)){const h=Vt(d,()=>o.get(e));return t&&st(h),fn(h)}return d}function gn(e,r){const n=Gt();return C.useCallback((...o)=>{if((dn?"production":void 0)!=="production"&&!("write"in e))throw new Error("not writable atom");return n.set(e,...o)},[n,e])}function ie(e,r){return[vn(e),gn(e)]}/*!
* iro.js v5.5.2
* 2016-2021 James Daniel
* Licensed under MPL 2.0
* github.com/jaames/iro.js
*/var G,Ue,Rt,it,Kt,ve={},lt=[],pn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;function ge(e,r){for(var n in r)e[n]=r[n];return e}function qt(e){var r=e.parentNode;r&&r.removeChild(e)}function Y(e,r,n){var t,o,s,a,i=arguments;if(r=ge({},r),arguments.length>3)for(n=[n],t=3;t<arguments.length;t++)n.push(i[t]);if(n!=null&&(r.children=n),e!=null&&e.defaultProps!=null)for(o in e.defaultProps)r[o]===void 0&&(r[o]=e.defaultProps[o]);return a=r.key,(s=r.ref)!=null&&delete r.ref,a!=null&&delete r.key,ct(e,r,a,s)}function ct(e,r,n,t){var o={type:e,props:r,key:n,ref:t,__k:null,__p:null,__b:0,__e:null,l:null,__c:null,constructor:void 0};return G.vnode&&G.vnode(o),o}function Ge(e){return e.children}function bn(e){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number")return ct(null,e,null,null);if(e.__e!=null||e.__c!=null){var r=ct(e.type,e.props,e.key,null);return r.__e=e.__e,r}return e}function Ne(e,r){this.props=e,this.context=r}function Ve(e,r){if(r==null)return e.__p?Ve(e.__p,e.__p.__k.indexOf(e)+1):null;for(var n;r<e.__k.length;r++)if((n=e.__k[r])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Ve(e):null}function Jt(e){var r,n;if((e=e.__p)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,r=0;r<e.__k.length;r++)if((n=e.__k[r])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return Jt(e)}}function ut(e){(!e.__d&&(e.__d=!0)&&Ue.push(e)===1||it!==G.debounceRendering)&&(it=G.debounceRendering,(G.debounceRendering||Rt)(yn))}function yn(){var e,r,n,t,o,s,a,i;for(Ue.sort(function(f,d){return d.__v.__b-f.__v.__b});e=Ue.pop();)e.__d&&(n=void 0,t=void 0,s=(o=(r=e).__v).__e,a=r.__P,i=r.u,r.u=!1,a&&(n=[],t=ht(a,o,ge({},o),r.__n,a.ownerSVGElement!==void 0,null,n,i,s??Ve(o)),rr(n,o),t!=s&&Jt(o)))}function Zt(e,r,n,t,o,s,a,i,f){var d,h,c,b,g,m,u,S=n&&n.__k||lt,k=S.length;if(i==ve&&(i=s!=null?s[0]:k?Ve(n,0):null),d=0,r.__k=dt(r.__k,function(y){if(y!=null){if(y.__p=r,y.__b=r.__b+1,(c=S[d])===null||c&&y.key==c.key&&y.type===c.type)S[d]=void 0;else for(h=0;h<k;h++){if((c=S[h])&&y.key==c.key&&y.type===c.type){S[h]=void 0;break}c=null}if(b=ht(e,y,c=c||ve,t,o,s,a,null,i,f),(h=y.ref)&&c.ref!=h&&(u||(u=[])).push(h,y.__c||b,y),b!=null){if(m==null&&(m=b),y.l!=null)b=y.l,y.l=null;else if(s==c||b!=i||b.parentNode==null){e:if(i==null||i.parentNode!==e)e.appendChild(b);else{for(g=i,h=0;(g=g.nextSibling)&&h<k;h+=2)if(g==b)break e;e.insertBefore(b,i)}r.type=="option"&&(e.value="")}i=b.nextSibling,typeof r.type=="function"&&(r.l=b)}}return d++,y}),r.__e=m,s!=null&&typeof r.type!="function")for(d=s.length;d--;)s[d]!=null&&qt(s[d]);for(d=k;d--;)S[d]!=null&&or(S[d],S[d]);if(u)for(d=0;d<u.length;d++)nr(u[d],u[++d],u[++d])}function dt(e,r,n){if(n==null&&(n=[]),e==null||typeof e=="boolean")r&&n.push(r(null));else if(Array.isArray(e))for(var t=0;t<e.length;t++)dt(e[t],r,n);else n.push(r?r(bn(e)):e);return n}function xn(e,r,n,t,o){var s;for(s in n)s in r||er(e,s,null,n[s],t);for(s in r)o&&typeof r[s]!="function"||s==="value"||s==="checked"||n[s]===r[s]||er(e,s,r[s],n[s],t)}function Qt(e,r,n){r[0]==="-"?e.setProperty(r,n):e[r]=typeof n=="number"&&pn.test(r)===!1?n+"px":n??""}function er(e,r,n,t,o){var s,a,i,f,d;if(!((r=o?r==="className"?"class":r:r==="class"?"className":r)==="key"||r==="children"))if(r==="style")if(s=e.style,typeof n=="string")s.cssText=n;else{if(typeof t=="string"&&(s.cssText="",t=null),t)for(a in t)n&&a in n||Qt(s,a,"");if(n)for(i in n)t&&n[i]===t[i]||Qt(s,i,n[i])}else r[0]==="o"&&r[1]==="n"?(f=r!==(r=r.replace(/Capture$/,"")),d=r.toLowerCase(),r=(d in e?d:r).slice(2),n?(t||e.addEventListener(r,tr,f),(e.t||(e.t={}))[r]=n):e.removeEventListener(r,tr,f)):r!=="list"&&r!=="tagName"&&r!=="form"&&!o&&r in e?e[r]=n??"":typeof n!="function"&&r!=="dangerouslySetInnerHTML"&&(r!==(r=r.replace(/^xlink:?/,""))?n==null||n===!1?e.removeAttributeNS("http://www.w3.org/1999/xlink",r.toLowerCase()):e.setAttributeNS("http://www.w3.org/1999/xlink",r.toLowerCase(),n):n==null||n===!1?e.removeAttribute(r):e.setAttribute(r,n))}function tr(e){return this.t[e.type](G.event?G.event(e):e)}function ht(e,r,n,t,o,s,a,i,f,d){var h,c,b,g,m,u,S,k,y,D,O=r.type;if(r.constructor!==void 0)return null;(h=G.__b)&&h(r);try{e:if(typeof O=="function"){if(k=r.props,y=(h=O.contextType)&&t[h.__c],D=h?y?y.props.value:h.__p:t,n.__c?S=(c=r.__c=n.__c).__p=c.__E:("prototype"in O&&O.prototype.render?r.__c=c=new O(k,D):(r.__c=c=new Ne(k,D),c.constructor=O,c.render=wn),y&&y.sub(c),c.props=k,c.state||(c.state={}),c.context=D,c.__n=t,b=c.__d=!0,c.__h=[]),c.__s==null&&(c.__s=c.state),O.getDerivedStateFromProps!=null&&ge(c.__s==c.state?c.__s=ge({},c.__s):c.__s,O.getDerivedStateFromProps(k,c.__s)),b)O.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),c.componentDidMount!=null&&a.push(c);else{if(O.getDerivedStateFromProps==null&&i==null&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(k,D),!i&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(k,c.__s,D)===!1){for(c.props=k,c.state=c.__s,c.__d=!1,c.__v=r,r.__e=f!=null?f!==n.__e?f:n.__e:null,r.__k=n.__k,h=0;h<r.__k.length;h++)r.__k[h]&&(r.__k[h].__p=r);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(k,c.__s,D)}for(g=c.props,m=c.state,c.context=D,c.props=k,c.state=c.__s,(h=G.__r)&&h(r),c.__d=!1,c.__v=r,c.__P=e,h=c.render(c.props,c.state,c.context),r.__k=dt(h!=null&&h.type==Ge&&h.key==null?h.props.children:h),c.getChildContext!=null&&(t=ge(ge({},t),c.getChildContext())),b||c.getSnapshotBeforeUpdate==null||(u=c.getSnapshotBeforeUpdate(g,m)),Zt(e,r,n,t,o,s,a,f,d),c.base=r.__e;h=c.__h.pop();)c.__s&&(c.state=c.__s),h.call(c);b||g==null||c.componentDidUpdate==null||c.componentDidUpdate(g,m,u),S&&(c.__E=c.__p=null)}else r.__e=mn(n.__e,r,n,t,o,s,a,d);(h=G.diffed)&&h(r)}catch(K){G.__e(K,r,n)}return r.__e}function rr(e,r){for(var n;n=e.pop();)try{n.componentDidMount()}catch(t){G.__e(t,n.__v)}G.__c&&G.__c(r)}function mn(e,r,n,t,o,s,a,i){var f,d,h,c,b=n.props,g=r.props;if(o=r.type==="svg"||o,e==null&&s!=null){for(f=0;f<s.length;f++)if((d=s[f])!=null&&(r.type===null?d.nodeType===3:d.localName===r.type)){e=d,s[f]=null;break}}if(e==null){if(r.type===null)return document.createTextNode(g);e=o?document.createElementNS("http://www.w3.org/2000/svg",r.type):document.createElement(r.type),s=null}return r.type===null?b!==g&&(s!=null&&(s[s.indexOf(e)]=null),e.data=g):r!==n&&(s!=null&&(s=lt.slice.call(e.childNodes)),h=(b=n.props||ve).dangerouslySetInnerHTML,c=g.dangerouslySetInnerHTML,i||(c||h)&&(c&&h&&c.__html==h.__html||(e.innerHTML=c&&c.__html||"")),xn(e,g,b,o,i),r.__k=r.props.children,c||Zt(e,r,n,t,r.type!=="foreignObject"&&o,s,a,ve,i),i||("value"in g&&g.value!==void 0&&g.value!==e.value&&(e.value=g.value==null?"":g.value),"checked"in g&&g.checked!==void 0&&g.checked!==e.checked&&(e.checked=g.checked))),e}function nr(e,r,n){try{typeof e=="function"?e(r):e.current=r}catch(t){G.__e(t,n)}}function or(e,r,n){var t,o,s;if(G.unmount&&G.unmount(e),(t=e.ref)&&nr(t,null,r),n||typeof e.type=="function"||(n=(o=e.__e)!=null),e.__e=e.l=null,(t=e.__c)!=null){if(t.componentWillUnmount)try{t.componentWillUnmount()}catch(a){G.__e(a,r)}t.base=t.__P=null}if(t=e.__k)for(s=0;s<t.length;s++)t[s]&&or(t[s],r,n);o!=null&&qt(o)}function wn(e,r,n){return this.constructor(e,n)}function Sn(e,r,n){var t,o,s;G.__p&&G.__p(e,r),o=(t=n===Kt)?null:r.__k,e=Y(Ge,null,[e]),s=[],ht(r,r.__k=e,o||ve,ve,r.ownerSVGElement!==void 0,o?null:lt.slice.call(r.childNodes),s,!1,ve,t),rr(s,e)}G={},Ne.prototype.setState=function(e,r){var n=this.__s!==this.state&&this.__s||(this.__s=ge({},this.state));(typeof e!="function"||(e=e(n,this.props)))&&ge(n,e),e!=null&&this.__v&&(this.u=!1,r&&this.__h.push(r),ut(this))},Ne.prototype.forceUpdate=function(e){this.__v&&(e&&this.__h.push(e),this.u=!0,ut(this))},Ne.prototype.render=Ge,Ue=[],Rt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,it=G.debounceRendering,G.__e=function(e,r,n){for(var t;r=r.__p;)if((t=r.__c)&&!t.__p)try{if(t.constructor&&t.constructor.getDerivedStateFromError!=null)t.setState(t.constructor.getDerivedStateFromError(e));else{if(t.componentDidCatch==null)continue;t.componentDidCatch(e)}return ut(t.__E=t)}catch(o){e=o}throw e},Kt=ve;function kn(e,r){for(var n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}function _n(e,r,n){return r&&kn(e.prototype,r),e}function ee(){return ee=Object.assign||function(e){for(var r=arguments,n=1;n<arguments.length;n++){var t=r[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},ee.apply(this,arguments)}var Cn="[-\\+]?\\d+%?",En="[-\\+]?\\d*\\.\\d+%?",ye="(?:"+En+")|(?:"+Cn+")",sr="[\\s|\\(]+("+ye+")[,|\\s]+("+ye+")[,|\\s]+("+ye+")\\s*\\)?",ar="[\\s|\\(]+("+ye+")[,|\\s]+("+ye+")[,|\\s]+("+ye+")[,|\\s]+("+ye+")\\s*\\)?",Tn=new RegExp("rgb"+sr),Pn=new RegExp("rgba"+ar),Nn=new RegExp("hsl"+sr),An=new RegExp("hsla"+ar),Re="^(?:#?|0x?)",xe="([0-9a-fA-F]{1})",me="([0-9a-fA-F]{2})",$n=new RegExp(Re+xe+xe+xe+"$"),zn=new RegExp(Re+xe+xe+xe+xe+"$"),In=new RegExp(Re+me+me+me+"$"),Ln=new RegExp(Re+me+me+me+me+"$"),Dn=2e3,Mn=4e4,Ke=Math.log,Ae=Math.round,Oe=Math.floor;function oe(e,r,n){return Math.min(Math.max(e,r),n)}function te(e,r){var n=e.indexOf("%")>-1,t=parseFloat(e);return n?r/100*t:t}function re(e){return parseInt(e,16)}function we(e){return e.toString(16).padStart(2,"0")}var $e=(function(){function e(n,t){this.$={h:0,s:0,v:0,a:1},n&&this.set(n),this.onChange=t,this.initialValue=ee({},this.$)}var r=e.prototype;return r.set=function(t){if(typeof t=="string")/^(?:#?|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(typeof t=="object")t instanceof e?this.hsva=t.hsva:"r"in t&&"g"in t&&"b"in t?this.rgb=t:"h"in t&&"s"in t&&"v"in t?this.hsv=t:"h"in t&&"s"in t&&"l"in t?this.hsl=t:"kelvin"in t&&(this.kelvin=t.kelvin);else throw new Error("Invalid color value")},r.setChannel=function(t,o,s){var a;this[t]=ee({},this[t],(a={},a[o]=s,a))},r.reset=function(){this.hsva=this.initialValue},r.clone=function(){return new e(this)},r.unbind=function(){this.onChange=void 0},e.hsvToRgb=function(t){var o=t.h/60,s=t.s/100,a=t.v/100,i=Oe(o),f=o-i,d=a*(1-s),h=a*(1-f*s),c=a*(1-(1-f)*s),b=i%6,g=[a,h,d,d,c,a][b],m=[c,a,a,h,d,d][b],u=[d,d,c,a,a,h][b];return{r:oe(g*255,0,255),g:oe(m*255,0,255),b:oe(u*255,0,255)}},e.rgbToHsv=function(t){var o=t.r/255,s=t.g/255,a=t.b/255,i=Math.max(o,s,a),f=Math.min(o,s,a),d=i-f,h=0,c=i,b=i===0?0:d/i;switch(i){case f:h=0;break;case o:h=(s-a)/d+(s<a?6:0);break;case s:h=(a-o)/d+2;break;case a:h=(o-s)/d+4;break}return{h:h*60%360,s:oe(b*100,0,100),v:oe(c*100,0,100)}},e.hsvToHsl=function(t){var o=t.s/100,s=t.v/100,a=(2-o)*s,i=a<=1?a:2-a,f=i<1e-9?0:o*s/i;return{h:t.h,s:oe(f*100,0,100),l:oe(a*50,0,100)}},e.hslToHsv=function(t){var o=t.l*2,s=t.s*(o<=100?o:200-o)/100,a=o+s<1e-9?0:2*s/(o+s);return{h:t.h,s:oe(a*100,0,100),v:oe((o+s)/2,0,100)}},e.kelvinToRgb=function(t){var o=t/100,s,a,i;return o<66?(s=255,a=-155.25485562709179-.44596950469579133*(a=o-2)+104.49216199393888*Ke(a),i=o<20?0:-254.76935184120902+.8274096064007395*(i=o-10)+115.67994401066147*Ke(i)):(s=351.97690566805693+.114206453784165*(s=o-55)-40.25366309332127*Ke(s),a=325.4494125711974+.07943456536662342*(a=o-50)-28.0852963507957*Ke(a),i=255),{r:oe(Oe(s),0,255),g:oe(Oe(a),0,255),b:oe(Oe(i),0,255)}},e.rgbToKelvin=function(t){for(var o=t.r,s=t.b,a=.4,i=Dn,f=Mn,d;f-i>a;){d=(f+i)*.5;var h=e.kelvinToRgb(d);h.b/h.r>=s/o?f=d:i=d}return d},_n(e,[{key:"hsv",get:function(){var t=this.$;return{h:t.h,s:t.s,v:t.v}},set:function(t){var o=this.$;if(t=ee({},o,t),this.onChange){var s={h:!1,v:!1,s:!1,a:!1};for(var a in o)s[a]=t[a]!=o[a];this.$=t,(s.h||s.s||s.v||s.a)&&this.onChange(this,s)}else this.$=t}},{key:"hsva",get:function(){return ee({},this.$)},set:function(t){this.hsv=t}},{key:"hue",get:function(){return this.$.h},set:function(t){this.hsv={h:t}}},{key:"saturation",get:function(){return this.$.s},set:function(t){this.hsv={s:t}}},{key:"value",get:function(){return this.$.v},set:function(t){this.hsv={v:t}}},{key:"alpha",get:function(){return this.$.a},set:function(t){this.hsv=ee({},this.hsv,{a:t})}},{key:"kelvin",get:function(){return e.rgbToKelvin(this.rgb)},set:function(t){this.rgb=e.kelvinToRgb(t)}},{key:"red",get:function(){var t=this.rgb;return t.r},set:function(t){this.rgb=ee({},this.rgb,{r:t})}},{key:"green",get:function(){var t=this.rgb;return t.g},set:function(t){this.rgb=ee({},this.rgb,{g:t})}},{key:"blue",get:function(){var t=this.rgb;return t.b},set:function(t){this.rgb=ee({},this.rgb,{b:t})}},{key:"rgb",get:function(){var t=e.hsvToRgb(this.$),o=t.r,s=t.g,a=t.b;return{r:Ae(o),g:Ae(s),b:Ae(a)}},set:function(t){this.hsv=ee({},e.rgbToHsv(t),{a:t.a===void 0?1:t.a})}},{key:"rgba",get:function(){return ee({},this.rgb,{a:this.alpha})},set:function(t){this.rgb=t}},{key:"hsl",get:function(){var t=e.hsvToHsl(this.$),o=t.h,s=t.s,a=t.l;return{h:Ae(o),s:Ae(s),l:Ae(a)}},set:function(t){this.hsv=ee({},e.hslToHsv(t),{a:t.a===void 0?1:t.a})}},{key:"hsla",get:function(){return ee({},this.hsl,{a:this.alpha})},set:function(t){this.hsl=t}},{key:"rgbString",get:function(){var t=this.rgb;return"rgb("+t.r+", "+t.g+", "+t.b+")"},set:function(t){var o,s,a,i,f=1;if((o=Tn.exec(t))?(s=te(o[1],255),a=te(o[2],255),i=te(o[3],255)):(o=Pn.exec(t))&&(s=te(o[1],255),a=te(o[2],255),i=te(o[3],255),f=te(o[4],1)),o)this.rgb={r:s,g:a,b:i,a:f};else throw new Error("Invalid rgb string")}},{key:"rgbaString",get:function(){var t=this.rgba;return"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")"},set:function(t){this.rgbString=t}},{key:"hexString",get:function(){var t=this.rgb;return"#"+we(t.r)+we(t.g)+we(t.b)},set:function(t){var o,s,a,i,f=255;if((o=$n.exec(t))?(s=re(o[1])*17,a=re(o[2])*17,i=re(o[3])*17):(o=zn.exec(t))?(s=re(o[1])*17,a=re(o[2])*17,i=re(o[3])*17,f=re(o[4])*17):(o=In.exec(t))?(s=re(o[1]),a=re(o[2]),i=re(o[3])):(o=Ln.exec(t))&&(s=re(o[1]),a=re(o[2]),i=re(o[3]),f=re(o[4])),o)this.rgb={r:s,g:a,b:i,a:f/255};else throw new Error("Invalid hex string")}},{key:"hex8String",get:function(){var t=this.rgba;return"#"+we(t.r)+we(t.g)+we(t.b)+we(Oe(t.a*255))},set:function(t){this.hexString=t}},{key:"hslString",get:function(){var t=this.hsl;return"hsl("+t.h+", "+t.s+"%, "+t.l+"%)"},set:function(t){var o,s,a,i,f=1;if((o=Nn.exec(t))?(s=te(o[1],360),a=te(o[2],100),i=te(o[3],100)):(o=An.exec(t))&&(s=te(o[1],360),a=te(o[2],100),i=te(o[3],100),f=te(o[4],1)),o)this.hsl={h:s,s:a,l:i,a:f};else throw new Error("Invalid hsl string")}},{key:"hslaString",get:function(){var t=this.hsla;return"hsla("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"},set:function(t){this.hslString=t}}]),e})(),Bn={sliderShape:"bar",sliderType:"value",minTemperature:2200,maxTemperature:11e3};function ft(e){var r,n=e.width,t=e.sliderSize,o=e.borderWidth,s=e.handleRadius,a=e.padding,i=e.sliderShape,f=e.layoutDirection==="horizontal";return t=(r=t)!=null?r:a*2+s*2,i==="circle"?{handleStart:e.padding+e.handleRadius,handleRange:n-a*2-s*2,width:n,height:n,cx:n/2,cy:n/2,radius:n/2-o/2}:{handleStart:t/2,handleRange:n-t,radius:t/2,x:0,y:0,width:f?t:n,height:f?n:t}}function On(e,r){var n=r.hsva,t=r.rgb;switch(e.sliderType){case"red":return t.r/2.55;case"green":return t.g/2.55;case"blue":return t.b/2.55;case"alpha":return n.a*100;case"kelvin":var o=e.minTemperature,s=e.maxTemperature,a=s-o,i=(r.kelvin-o)/a*100;return Math.max(0,Math.min(i,100));case"hue":return n.h/=3.6;case"saturation":return n.s;case"value":default:return n.v}}function jn(e,r,n){var t=ft(e),o=t.handleRange,s=t.handleStart,a;e.layoutDirection==="horizontal"?a=-1*n+o+s:a=r-s,a=Math.max(Math.min(a,o),0);var i=Math.round(100/o*a);switch(e.sliderType){case"kelvin":var f=e.minTemperature,d=e.maxTemperature,h=d-f;return f+h*(i/100);case"alpha":return i/100;case"hue":return i*3.6;case"red":case"blue":case"green":return i*2.55;default:return i}}function Hn(e,r){var n=ft(e),t=n.width,o=n.height,s=n.handleRange,a=n.handleStart,i=e.layoutDirection==="horizontal",f=On(e,r),d=i?t/2:o/2,h=a+f/100*s;return i&&(h=-1*h+s+a*2),{x:i?d:h,y:i?h:d}}function Wn(e,r){var n=r.hsv,t=r.rgb;switch(e.sliderType){case"red":return[[0,"rgb(0,"+t.g+","+t.b+")"],[100,"rgb(255,"+t.g+","+t.b+")"]];case"green":return[[0,"rgb("+t.r+",0,"+t.b+")"],[100,"rgb("+t.r+",255,"+t.b+")"]];case"blue":return[[0,"rgb("+t.r+","+t.g+",0)"],[100,"rgb("+t.r+","+t.g+",255)"]];case"alpha":return[[0,"rgba("+t.r+","+t.g+","+t.b+",0)"],[100,"rgb("+t.r+","+t.g+","+t.b+")"]];case"kelvin":for(var o=[],s=e.minTemperature,a=e.maxTemperature,i=8,f=a-s,d=s,h=0;d<a;d+=f/i,h+=1){var c=$e.kelvinToRgb(d),b=c.r,g=c.g,m=c.b;o.push([100/i*h,"rgb("+b+","+g+","+m+")"])}return o;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=$e.hsvToHsl({h:n.h,s:0,v:n.v}),S=$e.hsvToHsl({h:n.h,s:100,v:n.v});return[[0,"hsl("+u.h+","+u.s+"%,"+u.l+"%)"],[100,"hsl("+S.h+","+S.s+"%,"+S.l+"%)"]];case"value":default:var k=$e.hsvToHsl({h:n.h,s:n.s,v:100});return[[0,"#000"],[100,"hsl("+k.h+","+k.s+"%,"+k.l+"%)"]]}}var ir=Math.PI*2,Fn=function(r,n){return(r%n+n)%n},lr=function(r,n){return Math.sqrt(r*r+n*n)};function cr(e){return e.width/2-e.padding-e.handleRadius-e.borderWidth}function Xn(e,r,n){var t=qe(e),o=t.cx,s=t.cy,a=e.width/2;return lr(o-r,s-n)<a}function qe(e){var r=e.width/2;return{width:e.width,radius:r-e.borderWidth,cx:r,cy:r}}function ur(e,r,n){var t=e.wheelAngle,o=e.wheelDirection;return n&&o==="clockwise"?r=t+r:o==="clockwise"?r=360-t+r:n&&o==="anticlockwise"?r=t+180-r:o==="anticlockwise"&&(r=t-r),Fn(r,360)}function Yn(e,r){var n=r.hsv,t=qe(e),o=t.cx,s=t.cy,a=cr(e),i=(180+ur(e,n.h,!0))*(ir/360),f=n.s/100*a,d=e.wheelDirection==="clockwise"?-1:1;return{x:o+f*Math.cos(i)*d,y:s+f*Math.sin(i)*d}}function dr(e,r,n){var t=qe(e),o=t.cx,s=t.cy,a=cr(e);r=o-r,n=s-n;var i=ur(e,Math.atan2(-n,-r)*(360/ir)),f=Math.min(lr(r,n),a);return{h:Math.round(i),s:Math.round(100/a*f)}}function vt(e){var r=e.width,n=e.boxHeight,t=e.padding,o=e.handleRadius;return{width:r,height:n??r,radius:t+o}}function hr(e,r,n){var t=vt(e),o=t.width,s=t.height,a=t.radius,i=a,f=o-a*2,d=s-a*2,h=(r-i)/f*100,c=(n-i)/d*100;return{s:Math.max(0,Math.min(h,100)),v:Math.max(0,Math.min(100-c,100))}}function Un(e,r){var n=vt(e),t=n.width,o=n.height,s=n.radius,a=r.hsv,i=s,f=t-s*2,d=o-s*2;return{x:i+a.s/100*f,y:i+(d-a.v/100*d)}}function Gn(e,r){var n=r.hue;return[[[0,"#fff"],[100,"hsl("+n+",100%,50%)"]],[[0,"rgba(0,0,0,0)"],[100,"#000"]]]}var gt;function Vn(e){gt||(gt=document.getElementsByTagName("base"));var r=window.navigator.userAgent,n=/^((?!chrome|android).)*safari/i.test(r),t=/iPhone|iPod|iPad/i.test(r),o=window.location;return(n||t)&>.length>0?o.protocol+"//"+o.host+o.pathname+o.search+e:e}function fr(e,r,n,t){for(var o=0;o<t.length;o++){var s=t[o].x-r,a=t[o].y-n,i=Math.sqrt(s*s+a*a);if(i<e.handleRadius)return o}return null}function pt(e){return{boxSizing:"border-box",border:e.borderWidth+"px solid "+e.borderColor}}function bt(e,r,n){return e+"-gradient("+r+", "+n.map(function(t){var o=t[0],s=t[1];return s+" "+o+"%"}).join(",")+")"}function Z(e){return typeof e=="string"?e:e+"px"}var Rn={width:300,height:300,color:"#fff",colors:[],padding:6,layoutDirection:"vertical",borderColor:"#fff",borderWidth:0,handleRadius:8,activeHandleRadius:null,handleSvg:null,handleProps:{x:0,y:0},wheelLightness:!0,wheelAngle:0,wheelDirection:"anticlockwise",sliderSize:null,sliderMargin:12,boxHeight:null},vr=["mousemove","touchmove","mouseup","touchend"],Je=(function(e){function r(n){e.call(this,n),this.uid=(Math.random()+1).toString(36).substring(5)}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.render=function(t){var o=this.handleEvent.bind(this),s={onMouseDown:o,ontouchstart:o},a=t.layoutDirection==="horizontal",i=t.margin===null?t.sliderMargin:t.margin,f={overflow:"visible",display:a?"inline-block":"block"};return t.index>0&&(f[a?"marginLeft":"marginTop"]=i),Y(Ge,null,t.children(this.uid,s,f))},r.prototype.handleEvent=function(t){var o=this,s=this.props.onInput,a=this.base.getBoundingClientRect();t.preventDefault();var i=t.touches?t.changedTouches[0]:t,f=i.clientX-a.left,d=i.clientY-a.top;switch(t.type){case"mousedown":case"touchstart":var h=s(f,d,0);h!==!1&&vr.forEach(function(c){document.addEventListener(c,o,{passive:!1})});break;case"mousemove":case"touchmove":s(f,d,1);break;case"mouseup":case"touchend":s(f,d,2),vr.forEach(function(c){document.removeEventListener(c,o,{passive:!1})});break}},r})(Ne);function Se(e){var r=e.r,n=e.url,t=r,o=r;return Y("svg",{className:"IroHandle IroHandle--"+e.index+" "+(e.isActive?"IroHandle--isActive":""),style:{"-webkit-tap-highlight-color":"rgba(0, 0, 0, 0);",transform:"translate("+Z(e.x)+", "+Z(e.y)+")",willChange:"transform",top:Z(-r),left:Z(-r),width:Z(r*2),height:Z(r*2),position:"absolute",overflow:"visible"}},n&&Y("use",Object.assign({xlinkHref:Vn(n)},e.props)),!n&&Y("circle",{cx:t,cy:o,r,fill:"none","stroke-width":2,stroke:"#000"}),!n&&Y("circle",{cx:t,cy:o,r:r-2,fill:e.fill,"stroke-width":2,stroke:"#fff"}))}Se.defaultProps={fill:"none",x:0,y:0,r:8,url:null,props:{x:0,y:0}};function Ze(e){var r=e.activeIndex,n=r!==void 0&&r<e.colors.length?e.colors[r]:e.color,t=ft(e),o=t.width,s=t.height,a=t.radius,i=Hn(e,n),f=Wn(e,n);function d(h,c,b){var g=jn(e,h,c);e.parent.inputActive=!0,n[e.sliderType]=g,e.onInput(b,e.id)}return Y(Je,Object.assign({},e,{onInput:d}),function(h,c,b){return Y("div",Object.assign({},c,{className:"IroSlider",style:Object.assign({},{position:"relative",width:Z(o),height:Z(s),borderRadius:Z(a),background:"conic-gradient(#ccc 25%, #fff 0 50%, #ccc 0 75%, #fff 0)",backgroundSize:"8px 8px"},b)}),Y("div",{className:"IroSliderGradient",style:Object.assign({},{position:"absolute",top:0,left:0,width:"100%",height:"100%",borderRadius:Z(a),background:bt("linear",e.layoutDirection==="horizontal"?"to top":"to right",f)},pt(e))}),Y(Se,{isActive:!0,index:n.index,r:e.handleRadius,url:e.handleSvg,props:e.handleProps,x:i.x,y:i.y}))})}Ze.defaultProps=Object.assign({},Bn);function Kn(e){var r=vt(e),n=r.width,t=r.height,o=r.radius,s=e.colors,a=e.parent,i=e.activeIndex,f=i!==void 0&&i<e.colors.length?e.colors[i]:e.color,d=Gn(e,f),h=s.map(function(b){return Un(e,b)});function c(b,g,m){if(m===0){var u=fr(e,b,g,h);u!==null?a.setActiveColor(u):(a.inputActive=!0,f.hsv=hr(e,b,g),e.onInput(m,e.id))}else m===1&&(a.inputActive=!0,f.hsv=hr(e,b,g));e.onInput(m,e.id)}return Y(Je,Object.assign({},e,{onInput:c}),function(b,g,m){return Y("div",Object.assign({},g,{className:"IroBox",style:Object.assign({},{width:Z(n),height:Z(t),position:"relative"},m)}),Y("div",{className:"IroBox",style:Object.assign({},{width:"100%",height:"100%",borderRadius:Z(o)},pt(e),{background:bt("linear","to bottom",d[1])+","+bt("linear","to right",d[0])})}),s.filter(function(u){return u!==f}).map(function(u){return Y(Se,{isActive:!1,index:u.index,fill:u.hslString,r:e.handleRadius,url:e.handleSvg,props:e.handleProps,x:h[u.index].x,y:h[u.index].y})}),Y(Se,{isActive:!0,index:f.index,fill:f.hslString,r:e.activeHandleRadius||e.handleRadius,url:e.handleSvg,props:e.handleProps,x:h[f.index].x,y:h[f.index].y}))})}var qn="conic-gradient(red, yellow, lime, aqua, blue, magenta, red)",Jn="conic-gradient(red, magenta, blue, aqua, lime, yellow, red)";function gr(e){var r=qe(e),n=r.width,t=e.colors;e.borderWidth;var o=e.parent,s=e.color,a=s.hsv,i=t.map(function(h){return Yn(e,h)}),f={position:"absolute",top:0,left:0,width:"100%",height:"100%",borderRadius:"50%",boxSizing:"border-box"};function d(h,c,b){if(b===0){if(!Xn(e,h,c))return!1;var g=fr(e,h,c,i);g!==null?o.setActiveColor(g):(o.inputActive=!0,s.hsv=dr(e,h,c),e.onInput(b,e.id))}else b===1&&(o.inputActive=!0,s.hsv=dr(e,h,c));e.onInput(b,e.id)}return Y(Je,Object.assign({},e,{onInput:d}),function(h,c,b){return Y("div",Object.assign({},c,{className:"IroWheel",style:Object.assign({},{width:Z(n),height:Z(n),position:"relative"},b)}),Y("div",{className:"IroWheelHue",style:Object.assign({},f,{transform:"rotateZ("+(e.wheelAngle+90)+"deg)",background:e.wheelDirection==="clockwise"?qn:Jn})}),Y("div",{className:"IroWheelSaturation",style:Object.assign({},f,{background:"radial-gradient(circle closest-side, #fff, transparent)"})}),e.wheelLightness&&Y("div",{className:"IroWheelLightness",style:Object.assign({},f,{background:"#000",opacity:1-a.v/100})}),Y("div",{className:"IroWheelBorder",style:Object.assign({},f,pt(e))}),t.filter(function(g){return g!==s}).map(function(g){return Y(Se,{isActive:!1,index:g.index,fill:g.hslString,r:e.handleRadius,url:e.handleSvg,props:e.handleProps,x:i[g.index].x,y:i[g.index].y})}),Y(Se,{isActive:!0,index:s.index,fill:s.hslString,r:e.activeHandleRadius||e.handleRadius,url:e.handleSvg,props:e.handleProps,x:i[s.index].x,y:i[s.index].y}))})}function Zn(e){var r=function(n,t){var o,s=document.createElement("div");Sn(Y(e,Object.assign({},{ref:function(i){return o=i}},t)),s);function a(){var i=n instanceof Element?n:document.querySelector(n);i.appendChild(o.base),o.onMount(i)}return document.readyState!=="loading"?a():document.addEventListener("DOMContentLoaded",a),o};return r.prototype=e.prototype,Object.assign(r,e),r.__component=e,r}var pr=(function(e){function r(n){var t=this;e.call(this,n),this.colors=[],this.inputActive=!1,this.events={},this.activeEvents={},this.deferredEvents={},this.id=n.id;var o=n.colors.length>0?n.colors:[n.color];o.forEach(function(s){return t.addColor(s)}),this.setActiveColor(0),this.state=Object.assign({},n,{color:this.color,colors:this.colors,layout:n.layout})}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.addColor=function(t,o){o===void 0&&(o=this.colors.length);var s=new $e(t,this.onColorChange.bind(this));this.colors.splice(o,0,s),this.colors.forEach(function(a,i){return a.index=i}),this.state&&this.setState({colors:this.colors}),this.deferredEmit("color:init",s)},r.prototype.removeColor=function(t){var o=this.colors.splice(t,1)[0];o.unbind(),this.colors.forEach(function(s,a){return s.index=a}),this.state&&this.setState({colors:this.colors}),o.index===this.color.index&&this.setActiveColor(0),this.emit("color:remove",o)},r.prototype.setActiveColor=function(t){this.color=this.colors[t],this.state&&this.setState({color:this.color}),this.emit("color:setActive",this.color)},r.prototype.setColors=function(t,o){var s=this;o===void 0&&(o=0),this.colors.forEach(function(a){return a.unbind()}),this.colors=[],t.forEach(function(a){return s.addColor(a)}),this.setActiveColor(o),this.emit("color:setAll",this.colors)},r.prototype.on=function(t,o){var s=this,a=this.events;(Array.isArray(t)?t:[t]).forEach(function(i){(a[i]||(a[i]=[])).push(o),s.deferredEvents[i]&&(s.deferredEvents[i].forEach(function(f){o.apply(null,f)}),s.deferredEvents[i]=[])})},r.prototype.off=function(t,o){var s=this;(Array.isArray(t)?t:[t]).forEach(function(a){var i=s.events[a];i&&i.splice(i.indexOf(o),1)})},r.prototype.emit=function(t){for(var o=this,s=[],a=arguments.length-1;a-- >0;)s[a]=arguments[a+1];var i=this.activeEvents,f=i.hasOwnPro