import {a,b as b$1}from'../chunk-6JXMCEQE.mjs';import'../chunk-Q3O3QQ4H.mjs';import {b,l,d,h,i,f,g,a as a$1,c as c$1,k}from'../chunk-IOXRZECH.mjs';var c=o=>{let r=a$1(o.w,0,1/0),t=a$1(o.b,0,1/0),n=r+t;return {h:c$1(o.h),w:n>100?r/n*100:r,b:n>100?t/n*100:t,alpha:a$1(b(o.alpha,3),0,1)}},R=o=>{let{h:r}=a(o);return c({h:r,w:Math.min(o.r,o.g,o.b)/255*100,b:100-Math.max(o.r,o.g,o.b)/255*100,alpha:o.alpha})},$=({h:o,w:r,b:t,alpha:n})=>{let e=t===100?0:100-r/(100-t)*100;return b$1({h:o,s:e,v:100-t,alpha:n})},m=o=>{if(!h(o)||!i(o,["h","w","b"]))return null;let{h:r,w:t,b:n,alpha:e=1}=o;return !f(r)||!f(t)||!f(n)||!f(e)?null:$(c({h:g(r),w:g(t),b:g(n),alpha:g(e)}))},N=new RegExp(`^hwb\\(\\s*(?<h>${k})(?<hu>deg|rad|grad|turn)?\\s+(?<w>${k})(?<wp>%?)\\s+(?<b>${k})(?<bp>%?)\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),H=o=>{if(typeof o!="string")return null;let r=N.exec(o.trim())?.groups;if(!r)return null;let t=r.hu?.toLowerCase()??"deg",n=l(r.h)*(d[t]??1),e=l(r.w),l$1=l(r.b),b=r.al===void 0?1:l(r.al)/(r.alp?100:1);return $(c({h:n,w:e,b:l$1,alpha:b}))};var j=(o,r,t)=>{o.prototype.toHwb=function(n=0){let{h:e,w:l,b: b$1,alpha:h}=R(this._rawRgb());return {h:b(e,n),w:b(l,n),b:b(b$1,n),alpha:b(h,3)}},o.prototype.toHwbString=function(n=0){let{h:e,w:l,b,alpha:h}=this.toHwb(n);return h<1?`hwb(${e} ${l}% ${b}% / ${h})`:`hwb(${e} ${l}% ${b}%)`},r.push(H,m),t.push([H,"hwb"],[m,"hwb"]);},E=j;export{E as default};//# sourceMappingURL=hwb.mjs.map
//# sourceMappingURL=hwb.mjs.map