'use strict';var chunkPI5KJ3ZM_cjs=require('../chunk-PI5KJ3ZM.cjs');require('../chunk-INDSIUQQ.cjs'),require('../chunk-3V4MONNR.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var w=c=>({l:chunkYISEJCI6_cjs.a(c.l,0,100),c:Math.max(0,c.c),h:chunkYISEJCI6_cjs.c(c.h),alpha:chunkYISEJCI6_cjs.a(c.alpha,0,1),colorSpace:"lch"}),$=c=>{let o=chunkPI5KJ3ZM_cjs.m(c),l=Math.sqrt(o.a**2+o.b**2),r=Math.atan2(o.b,o.a)/Math.PI*180;return {l:o.l,c:l,h:l<.0015?0:r<0?r+360:r,alpha:o.alpha,colorSpace:"lch"}};var x=({l:c,c:o,h:l,alpha:r})=>chunkPI5KJ3ZM_cjs.q({l:c,a:o*Math.cos(l*Math.PI/180),b:o*Math.sin(l*Math.PI/180),alpha:r,colorSpace:"lab"}),m=c=>{if(!chunkYISEJCI6_cjs.h(c)||c.colorSpace!=="lch"||!chunkYISEJCI6_cjs.i(c,["l","c","h"]))return null;let{l:o,c:l,h:r,alpha:t=1}=c;return !chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(l)||!chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(t)?null:x(w({l:chunkYISEJCI6_cjs.g(o),c:chunkYISEJCI6_cjs.g(l),h:chunkYISEJCI6_cjs.g(r),alpha:chunkYISEJCI6_cjs.g(t)}))},y=new RegExp(`^lch\\(\\s*(?<l>${chunkYISEJCI6_cjs.k})(?<lp>%?)\\s+(?<c>${chunkYISEJCI6_cjs.k})(?<cp>%?)\\s+(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),L=c=>{if(typeof c!="string")return null;let o=y.exec(c.trim())?.groups;if(!o)return null;let l=chunkYISEJCI6_cjs.l(o.l),r=o.cp?chunkYISEJCI6_cjs.l(o.c)*1.5:chunkYISEJCI6_cjs.l(o.c),t=o.hu?.toLowerCase()??"deg",n=chunkYISEJCI6_cjs.l(o.h)*(chunkYISEJCI6_cjs.d[t]??1),h=o.al===void 0?1:chunkYISEJCI6_cjs.l(o.al)/(o.alp?100:1);return x(w({l,c:r,h:n,alpha:h}))};var T=(c,o,l)=>{c.prototype.toLch=function(r=2){let{l:t,c:n,h,alpha:i}=$(this._rawRgb()),b=chunkYISEJCI6_cjs.b(n,r);return {l:chunkYISEJCI6_cjs.b(t,r),c:b,h:n<.0015?0:chunkYISEJCI6_cjs.b(h,r),alpha:i,colorSpace:"lch"}},c.prototype.toLchString=function(r=2){let{l:t,c:n,h,alpha:i}=this.toLch(r),b=n===0?"none":h;return i<1?`lch(${t} ${n} ${b} / ${i})`:`lch(${t} ${n} ${b})`},o.push(m,L),l.push([m,"lch"],[L,"lch"]);},_=T;module.exports=_;//# sourceMappingURL=lch.cjs.map
//# sourceMappingURL=lch.cjs.map